[ServiceWorker] ServiceWorker to "service worker" mapping and stability (#622)

Stumbled upon this while running blink wpt tests. The spec doesn't define anything, maybe I'm just missing some obvious knowledge. Specific example is the test service-workers/active.html (console.log additions are mine):

          .then(step(function(f) {
          frame = f;
          return navigator.serviceWorker.register(url, {scope: scope});
        }))
      .then(step(function(r) {
          registration = r;
          console.log(r.installing.state);
          r.installing.addEventListener('statechange', function() {
            console.log("State changed to " , r.installing.state);
          });
          return wait_for_state(t, r.installing, 'activating');
        }))

Here r.installing is valid in the promise handler, but inside the event listener, there is no reason r.installing has to be valid in the current spec. In the first statechange the spec says to set the 'waiting worker to the installing worker' then 'set installing worker to null', then 'update waiting worker's state to installed' and so on. The same switch happens of waiting -> active, waiting = null, when the worker finishes activation. When this happens, Gecko will immediately (not violating JS run to completion, but noticable in event handlers) invalidate installing and set waiting. With nothing specified, I assume that when the spec says to set waiting to something, that is also immediately reflected in the per-global JS exposed 'waiting'. In such a case the wait_for_state() function does not track these attribute changes correctly. If Blink passes the test, it may be shipping an incompatible implementation.

cc/ @mattto 

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

Received on Friday, 13 February 2015 19:48:38 UTC