Following up on this. I created two pages, one that tests cookies in a loop, and one that sets cookies in a loop, and ran them in separate windows in Firefox 3, IE7, and Chrome.<br><br>Chrome and IE7 currently allow concurrent modification of document.cookies (i.e. the test loop throws up an alert). Firefox does not.<br>
<br>My two pages are below - do you see any problems with my test? If not, I'd like to propose that browsers do not currently impose any guarantees as to the immutability of document.cookies, so there's no reason not to support synchronous access to cookies from workers.<br>
<br>-atw<br><br><html><br><head><br></head><br><body><br>  Testing cookies: <span id="log">0</span><br>  <a href="#" onclick="cookieTest()">Start</a><br>
  <script><br>    var count = 1;<br>    function cookieTest() {<br>      var a = document.cookie;<br>      for (var i = 0 ; i < 10000 ; i++) {<br>        var b = document.cookie;<br>        if (a != b) {<br>          alert("a: " + a + "\nb:" + b);<br>
        }<br>      }<br>      setTimeout(cookieTest, 0);<br>      document.getElementById('log').innerHTML = count++; <br>    };<br>  </script><br>  <br></body><br></html><br><br><br><html><br>
<head><br></head><br><body><br>  setCookies: <span id="log">0</span><br>  <a href="#" onclick="cookieSet()">Start</a><br>  <script><br>    var count = 1;<br>
    function cookieSet() {<br>      for (var i = 0 ; i < 10000 ; i++) {<br>        document.cookie = ("cookieSetVal=" + i);<br>      }<br>      setTimeout(cookieSet, 0);<br>      document.getElementById('log').innerHTML = count++; <br>
    };<br>  </script><br></body><br></html><br><br><br><div class="gmail_quote">On Mon, Mar 9, 2009 at 11:38 AM, Drew Wilson <span dir="ltr"><<a href="mailto:atwilson@google.com">atwilson@google.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br><br><div class="gmail_quote"><div class="im">On Mon, Mar 9, 2009 at 10:23 AM, Jonas Sicking <span dir="ltr"><jonas@sicking.cc></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div>
<br>
</div>The problem is that people are likely to write code like:<br>
<br>
if (self.getAllCookies() != "magic value") {<br>
  a = self.getAllCookies();<br>
  ...do stuff...<br>
}<br>
<br>
at that point it's entirely possible for 'a' to have the value "magic<br>
value" which is likely to cause the script to break.</blockquote></div><div><br>Here we are making assumptions about how people will use routines that don't actually exist yet. If you were to substitute "new Date().getTime()" for "self.getAllCookies()" in the code above, I think we'd all agree that the user expectation is faulty - is it not feasible to state that, just like Date().getTime(),. getAllCookies() returns a snapshot of a mutable value?<br>

<br>I'm OK with making setCookie() asynchronous, because I think there may be a valid point that you don't want new worker code to suddenly break existing JS code that expects document.cookies to remain immutable across a single block of execution. But I don't see that argument extending to getAllCookies().<br>

<br></div><div class="im"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><br>
<br>
</div>Indeed. It does seem like you would be able to ask ;)<br>
<font color="#888888"></font></blockquote></div><div><br>I'm looking into this now, actually :) - I'll let you know what I find out.<br><br>-atw <br></div></div><br>
</blockquote></div><br>