localStorage and IE8

IE8 implements the localStorage feature of the Web Storage specification:


However, in a recent thread on the whatwg mailing list [1], it was noticed 
that IE8 fails to implement the following requirement from the section 
entitled "3.6 Threads":

# Multiple browsing contexts must be able to access the local storage 
# areas simultaneously in such a manner that scripts cannot detect any 
# concurrent script execution.
 -- http://dev.w3.org/html5/webstorage/#threads

This can be demonstrated by opening two separate IE8 windows, navigating 
both to the following URL:


Typing the following into the first window:

   localStorage.foo = 0;
   while (true)
      localStorage.foo = parseInt(localStorage.foo) + 1;

Typing the following into the second window:

   var x = 0;
   while (localStorage.foo == localStorage.foo)
     x += 1;

...and then pressing the "Evaluate..." button in both windows.

In a compliant implementation, both would spin until the browser trips the 
"hung script" limit. (Both scripts are effectively infinite loops; the 
condition in the second script is guaranteed to be true by the condition 
quoted above.)

In IE8, the second script will return in finite time, indicating that the 
condition is not always true.

This leads to the possibility of race conditions, where scripts like this:

   localStorage.pendingName = "Fred";
   // ...
   if (localStorage.pendingName != "n/a") {
     output("Hello " + localStorage.pendingName + "!");
     localStorage.pendingName == "n/a";

...if run in two windows side by side, would sometimes lead to two 
different calls to the output() method, one with "Hello Fred!" as 
expected, and one with "Hello n/a!", despite the check.

This is likely to be extremely hard for authors to debug.

This problem is exacerbated with Web Workers. It would be useful if 
someone from the IE team could contribute to the aforementioned thread [1] 
so that whatever solution is found is one that Microsoft would be willing 
to implement.

[1] http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2009-March/thread.html#18907

Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

Received on Monday, 23 March 2009 23:25:16 UTC