Re: [w3c/ServiceWorker] skipWaiting() promise should resolve after promotion to .active (#1187)

Heads-up that I think the current WPT test for this is wrong. Would be great if @wanderview @jakearchibald @jungkees can confirm my analysis. 

The current test skip-waiting-installed.https.html[1] sets up a waiting worker and an active worker with a client. The worker calls skipWaiting() and then checks that the promise resolves before the 'activate' event handler runs.

But tracing through the spec, skipWaiting() enters "Try Activate". "Try Activate" invokes "Activate". "Activate" blocks until the final step:
"13. Run the Update Worker State algorithm passing registration’s active worker and activated as the arguments."

"Update Worker State" queues a task to set ServiceWorker#state to 'activated'. That means skipWaiting's promise resolves before that task runs. But back in step 10, we have dispatched the 'activate' event. Therefore the order should be:

1. 'activate' event handler runs
2. skipWaiting() promise resolves
3. ServiceWorker#state is set to 'activated'

We're planning to change the test to assert that order.

For more context, this came up in https://chromium-review.googlesource.com/c/chromium/src/+/599570, Xiaofeng Zhang believes the spec changed in https://github.com/w3c/ServiceWorker/pull/1065 so that the test is now wrong.

[1]
* https://github.com/w3c/web-platform-tests/blob/master/service-workers/service-worker/skip-waiting-installed.https.html
* https://github.com/w3c/web-platform-tests/blob/master/service-workers/service-worker/resources/skip-waiting-installed-worker.js

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/ServiceWorker/issues/1187#issuecomment-326488845

Received on Friday, 1 September 2017 05:06:23 UTC