[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Public WebGL] Firefox 4 and blacklist reporting

Okay, so I checked and you're correct in that a very few events are delivered synchronously.

So, if we want it to work that way though it needs to be in the spec. The spec as it is not does not require this and so if you want to make sure your app works you have to use the setTimeout method I showed.

If we change the spec to say the event must be delivered before getContext returns then we can try writing a conformance test (although you'd have to test it in a browser configured to fail context creation)

Unfortunately at this point you might be stuck with implementations out there that require the setTimeout method.


On Wed, Mar 30, 2011 at 10:35 AM, Cedric Vivier <cedricv@neonux.com> wrote:
On Thu, Mar 31, 2011 at 00:51, Gregg Tavares (wrk) <gman@google.com> wrote:
>> There's no later, the event listener (if any) will be executed before
>> getContext returns, which allows to capture the additional
>> information. Also I don't think we require the canvas itself to listen
>> to the event.
> This is NOT how _javascript_ works. Events are always asynchronous AFAIK.
> _javascript_ does not support being "interrupted" by an event. Events are not
> delivered until _javascript_ exits.

Nope, this IS how it works Gregg ;-)
As pointed out in my previous email, DOM2 events are synchronous :

"The return value of dispatchEvent indicates whether any of the
listeners which handled the event called preventDefault. If
preventDefault was called the value is false, else the value is true."

This requires event bubbling and execution of listeners to happen
before dispatchEvent returns.

Simple testcase:
document.body.addEventListener("foo", function(evt) { alert("FOO"); }, false);
var evt = document.createEvent("Event");
evt.initEvent("foo", true, true);
alert("after foo...");

And I'm pretty sure this is how native's dispatchEvent work as well :
DOM2 interface is not limited to the _javascript_ language and I
remember using this long time ago (dispatching events from native, on