[whatwg] Worker feedback

Robert O'Callahan robert at ocallahan.org
Mon Apr 6 04:20:19 PDT 2009


On Mon, Apr 6, 2009 at 7:03 PM, Darin Fisher <darin at chromium.org> wrote:

> On Fri, Apr 3, 2009 at 2:49 PM, Robert O'Callahan <robert at ocallahan.org>wrote:
>
>> On Sat, Apr 4, 2009 at 6:35 AM, Jeremy Orlow <jorlow at google.com> wrote:
>>
>>> If I understood the discussion correctly, the spec for document.cookie
>>> never stated anything about it being immutable while a script is running.
>>
>>
>> Well, there never was a decent spec for document.cookie for most of its
>> life, and even if there had been, no implementations allowed asynchronous
>> changes to cookies while a script was running (except for maybe during
>> alert()) and no-one really thought about it. Was this even identified as a
>> possible issue during Chrome development?
>>
>
> In addition to alert(), don't forget about all the great state changing
> things that can happen to the cookie database (and other data stores) during
> a synchronous XMLHttpRequest (or synchronous document.load) in Firefox.
>  Maybe those are just bugs?  What if a Firefox extension wants to muck
> around with the cookie database while a web page is blocked on a synchronous
> XMLHttpRequest?  Maybe that should fail to avoid dead-locking?  Sounds like
> a recipe for flaky extensions since it is unlikely that the extension author
> would have been prepared for being called at this time when access to the
> cookie database would have to be denied.
>

According to the spec the storage mutex is dropped for blocking operations
like alert() and sync XHR, and as you know, that's effectively what we do.

But the general rule of DOM API design is that operations do not block and
we offer asynchronous APIs instead. alert() and sync XHR are exceptions to
this rule, but they're ugly stepchildren of DOM APIs and we don't want to
treat them as norms.

When deciding how to handle cookies in Chrome, we did not worry about the
> problem being debated here.  Our concerns were allayed by recognizing that
> IE does not try to solve it (and IE6 is multi-process just like Chrome with
> a shared network stack), so clearly web developers must already have to
> cope.
>

You mean IE8.

How would Web developers cope? There's no way to synchronize. I doubt more
than a handful of Web developers even know this problem could exist.

I think it would be best to specify that document.cookie returns a snapshot.
>  I think that is consistent with existing implementations including IE,
> Firefox, and Chrome.
>

Not at all. In Firefox, cookies don't change while a script is running, as
long as it doesn't call the handful of blocking DOM APIs (such as alert() or
sync XHR); we satisfy the current spec.

The insidious part is that almost all the time, IE and Chrome will also be
observed to obey the spec; when a quick cookie-read-modify-write script
runs, it is very unlikely cookies will change underneath it. (Is it possible
people don't write such scripts?)

Maybe we need dynamic race detection for Web browsers. After a script reads
document.cookie, stall for a while to give network transactions or scripts
running in other threads a chance to change the cookies so the original
script carries on with wrong data.

Rob
-- 
"He was pierced for our transgressions, he was crushed for our iniquities;
the punishment that brought us peace was upon him, and by his wounds we are
healed. We all, like sheep, have gone astray, each of us has turned to his
own way; and the LORD has laid on him the iniquity of us all." [Isaiah
53:5-6]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.whatwg.org/pipermail/whatwg-whatwg.org/attachments/20090406/0565bbf4/attachment-0002.htm>


More information about the whatwg mailing list