There should be no such thing as "fail to activate" for a Service Worker script

RESOLVED WORKSFORME

Status

()

RESOLVED WORKSFORME
4 years ago
3 years ago

People

(Reporter: flaki, Assigned: rnath, Mentored)

Tracking

Trunk
Points:
---

Firefox Tracking Flags

(firefox40 affected)

Details

(Whiteboard: [good first bug][lang=C++])

Attachments

(1 attachment)

(Reporter)

Description

4 years ago
Browsing the spec issue #659 (There should be no such thing as "fail to activate") based on the disussion:
https://github.com/slightlyoff/ServiceWorker/issues/659#issuecomment-95471388

...and according to the revised Activation algorithm (15.4)
https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#activation-algorithm

...shouldn't the ServiceWorkerRegistrationInfo::FinishActivate() method in dom/workers/ServiceWorkerManager.cpp
https://dxr.mozilla.org/mozilla-central/source/dom/﷒0﷓

...set the worker state to "Activated", regardless of the activation result "aSuccess"?

In other words (from Chrome's impl.): "e.waitUntil(reject) is the same as e.waitUntil(resolve)"
https://code.google.com/p/chromium/issues/detail?id=480050
(Reporter)

Updated

4 years ago
Flags: needinfo?(nsm.nikhil)
I guess it might block v2. Please, change it if it is not the case. Thanks!
Blocks: 1131322
This is a good first bug if someone wants to take it up.
Mentor: nsm.nikhil
Flags: needinfo?(nsm.nikhil)
Whiteboard: [good first bug][lang=C++]

Comment 3

4 years ago
Hi!
I'd like to fix this bug. Any suggestions?
(Assignee)

Comment 4

4 years ago
Created attachment 8607378 [details] [diff] [review]
Bug1163412_revA.patch

This is a proposed patch. Can someone take a look and let me know if I'm on the right track?

Updated

4 years ago
Attachment #8607378 - Flags: feedback?(nsm.nikhil)
Comment on attachment 8607378 [details] [diff] [review]
Bug1163412_revA.patch

Review of attachment 8607378 [details] [diff] [review]:
-----------------------------------------------------------------

Please add a test too. The test will be soemthing like:
1) In the test html file, register a SW for a scope
2) In the directory of that scope, have a ready.html file or similar (there are similar files in dom/worker/test/serviceworkers that can be re-used). This waits on navigator.serviceWorker.ready.then(r => parent.postMessage("Activated!")
3) Have the SW script be:
onactivate = function(e) {
  e.waitUntil(Promise.reject());
}

onfetch = function(e) {
  e.respondWith(new Response("hello"));
}

4) make sure a fetch() to a controlled scope results in hello response.
Attachment #8607378 - Flags: feedback?(nsm.nikhil) → feedback+
Assignee: nobody → nathmatics

Updated

3 years ago
Status: NEW → ASSIGNED
Blocks: 1173500
No longer blocks: 1131322
Sorry, but I think we have implemented this in other bugs changing the job queue logic.  Thank you for your help!
Status: ASSIGNED → RESOLVED
Last Resolved: 3 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.