Re: [presentation-api-tests] [presentation-api] update a test to check start() event order (again) (#4187)

Hey, that looks nice, @tomoyukilabs! :)

For what it's worth, on top of making the test fail nicely (and without timeout) when the order of events is incorrect, your code avoids having to answer the following question that came to mind yesterday evening: my suggested code started to listen to the `connect` event as part of the resolution (a) of a `Promise` created under the hoods while handling the `connectionavailable` event. User agents may queue a task to fire the `connect` event (b) at any time after the `connectionavailable` event.

In theory, I think (b) cannot happen before (a) because user agents queue a _microtask_ for promise resolution, whereas they queue a _macrotask_ for event firing. Microtasks should run to completion first, or rather they should run right after the current macrotask and before the next one.

In practice, some web browsers do not seem to run Promise resolutions at the end of a callback as they should, see related [Firefox ticket](https://bugzilla.mozilla.org/show_bug.cgi?id=1193394) for instance. I'm not really sure whether that would have affected this code, but it's probably a good idea to take a conservative approach in tests and not rely on promise resolution code being run before other kinds of tasks.


View on GitHub: https://github.com/w3c/web-platform-tests/pull/4187#issuecomment-259411185

Received on Wednesday, 9 November 2016 13:11:48 UTC