[ServiceWorker] Possible run-to-completion violation in "Handle Service Worker Client Unload" (#746)

Consider the first test at https://code.google.com/p/chromium/codesearch#chromium/src/third_party/WebKit/LayoutTests/http/tests/serviceworker/unregister-then-register-new-script.html

In this big block:

    .then(function(r) {
          new_registration = r;
          assert_equals(registration.installing.scriptURL,
                        normalizeURL(new_worker_url),
                        'before activated registration.installing');
          assert_equals(registration.waiting, null,
                        'before activated registration.waiting');
          assert_equals(registration.active.scriptURL, normalizeURL(worker_url),
                        'before activated registration.active');
          assert_equals(new_registration.installing.scriptURL,
                        normalizeURL(new_worker_url),
                        'before activated new_registration.installing');
          assert_equals(new_registration.waiting, null,
                        'before activated new_registration.waiting');
          assert_equals(new_registration.active.scriptURL,
                        normalizeURL(worker_url),
                        'before activated new_registration.active');
          iframe.remove();
          return wait_for_state(t, registration.installing, 'activated');
        })

At `iframe.remove()`, "Handle Service Worker Client Unload" will run. Note that the call to `register(new_worker_url)` did not lead to the `uninstalling flag` being reset to `false` since the conditions are not satisfied in `[[Register]]` (Is this a bug at that point?).

This leads to the underlying registration being cleared (`[[Clear Registration]]`), so that the call to `registration.installing` will be null according to spec. Blink seems to pass the test due to asynchronicity between their processes, but according to spec this seems like a violation of run-to-completion with installing changing.

IMO this should not actually happen since the `reset uninstalling flag` conditions need to be relaxed. In either case this sounds like a BigDeal issue.

@jakearchibald @jungkees 

---
Reply to this email directly or view it on GitHub:
https://github.com/slightlyoff/ServiceWorker/issues/746

Received on Wednesday, 9 September 2015 00:26:52 UTC