<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>19540</bug_id>
          
          <creation_ts>2012-10-15 12:19:16 +0000</creation_ts>
          <short_desc>Firing WebStorage storage event</short_desc>
          <delta_ts>2016-02-05 06:16:13 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebAppsWG</product>
          <component>Web Storage (editor: Ian Hickson)</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Janusz Majnert">jmajnert</reporter>
          <assigned_to name="Ian &apos;Hixie&apos; Hickson">ian</assigned_to>
          <cc>dewa</cc>
    
    <cc>ian</cc>
    
    <cc>mike</cc>
    
    <cc>public-webapps</cc>
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>76298</commentid>
    <comment_count>0</comment_count>
    <who name="Janusz Majnert">jmajnert</who>
    <bug_when>2012-10-15 12:19:16 +0000</bug_when>
    <thetext>When trying to implement local storage I found it hard to understand the rules for firing the &quot;storage&quot; event.

In section 11.2.3
(http://www.whatwg.org/specs/web-apps/current-work/multipage/webstorage.html#the-localstorage-attribute)
we have this sentence [1]:
&quot;
When the setItem(), removeItem(), and clear() methods are called on a
Storage object x that is associated with a local storage area, if the
methods did something, then in every Document object whose Window
object&apos;s localStorage attribute&apos;s Storage object is associated with
the same storage area, other than x, a storage event must be fired, as
described below.
&quot;


&quot;as described below&quot; points to section 11.2.4, which reads [2]:
&quot;
The storage event is fired when a storage area changes, as described
in the previous two sections (for session storage, for local storage).
When this happens, the user agent must queue a task to fire an event
with the name storage, which does not bubble and is not cancelable,
and which uses the StorageEvent interface, at each Window object whose
Document object has a Storage object that is affected.
&quot;

What I understood:
Sentence [1] says that storage events should be fired on affected
Document objects, except the one that originated the change.
Sentences in [2]  say that when a storage event is fired as described
in [1], a task must be queued to fire storage events on all affected
Window objects. It also says that Document objects have Storage
objects, which I don&apos;t think is true.

Is my understanding correct? What am I missing?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>80377</commentid>
    <comment_count>1</comment_count>
    <who name="">contributor</who>
    <bug_when>2012-12-18 22:29:56 +0000</bug_when>
    <thetext>Checked in as WHATWG revision r7592.
Check-in comment: Try to clarify how &apos;storage&apos; events are sent.
http://html5.org/tools/web-apps-tracker?from=7591&amp;to=7592</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>80392</commentid>
    <comment_count>2</comment_count>
    <who name="Janusz Majnert">jmajnert</who>
    <bug_when>2012-12-19 07:46:11 +0000</bug_when>
    <thetext>Looks good to me now. Two things though:

1. Typo: &quot;events are fired on the Window objecys&quot;.

2. I&apos;m not sure how the condition &quot;if the methods did something&quot; evaluates for this code:

localStorage.setItem(&apos;key1&apos;,&apos;value1&apos;);
localStorage.setItem(&apos;key1&apos;,&apos;value1&apos;);

When running the above code, should UA generate one or two storage events?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>80729</commentid>
    <comment_count>3</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2012-12-30 19:44:16 +0000</bug_when>
    <thetext>Yeah, that could have been clearer. How is it now? Please don&apos;t hesitate to reopen this bug if it&apos;s still not clear.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>80730</commentid>
    <comment_count>4</comment_count>
    <who name="">contributor</who>
    <bug_when>2012-12-30 19:45:36 +0000</bug_when>
    <thetext>Checked in as WHATWG revision r7615.
Check-in comment: Try to clarify when &apos;storage&apos; even fires.
http://html5.org/tools/web-apps-tracker?from=7614&amp;to=7615</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>80787</commentid>
    <comment_count>5</comment_count>
    <who name="Janusz Majnert">jmajnert</who>
    <bug_when>2012-12-31 07:58:13 +0000</bug_when>
    <thetext>I think it&apos;s OK now. Thanks.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>124852</commentid>
    <comment_count>6</comment_count>
    <who name="">dewa</who>
    <bug_when>2016-02-05 06:16:13 +0000</bug_when>
    <thetext>(In reply to Ian &apos;Hixie&apos; Hickson from comment #3)
&gt; Yeah, that could have been clearer. How is it now? Please don&apos;t hesitate to
&gt; reopen this bug if it&apos;s still not clear.

Sorry for respond such a old thread, but I have unclear point about storage event firing rule. If it makes sense, please response. The point is &quot;Should this event occur in Window document that causes this result?&quot; I know this event for &quot;other&quot; document in other window to recognize a Storage object change, but how about itself? The specification seems to be unclear this point. Nothing happens in the document makes changes. Correct?</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>