W3C home > Mailing lists > Public > public-webapps@w3.org > January to March 2009

localStorage and IE8

From: Ian Hickson <ian@hixie.ch>
Date: Mon, 23 Mar 2009 23:24:37 +0000 (UTC)
To: HTML WG <public-html@w3.org>, public-webapps@w3.org
Cc: Jonas Sicking <jonas@sicking.cc>, Anne van Kesteren <annevk@opera.com>, Cameron McCormack <cam@mcc.id.au>, Drew Wilson <atwilson@google.com>, Jeremy Orlow <jorlow@google.com>, Michael Nordman <michaeln@google.com>, Oliver Hunt <oliver@apple.com>, Aaron Boodman <aa@google.com>, Robert O'Callahan <robert@ocallahan.org>, Dmitry Titov <dimich@google.com>, Adam Barth <whatwg@adambarth.com>
Message-ID: <Pine.LNX.4.62.0903232129170.25082@hixie.dreamhostps.com>

IE8 implements the localStorage feature of the Web Storage specification:

   http://dev.w3.org/html5/webstorage/#storage

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:

   http://software.hixie.ch/utilities/js/js-eval-window/

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;
   x

...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 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:30 GMT