Last Comment Bug 903441 - (ServiceWorkers) [meta] Implement Service Workers
(ServiceWorkers)
: [meta] Implement Service Workers
Status: NEW
[games:p1][platform-rel-Games]
: dev-doc-needed
Product: Core
Classification: Components
Component: DOM (show other bugs)
: Trunk
: All All
: -- normal with 19 votes (vote)
: ---
Assigned To: Nobody; OK to take it and work on it
:
: Andrew Overholt [:overholt]
Mentors:
https://w3c.github.io/ServiceWorker/
Depends on: ServiceWorkers-foreign ServiceWorkers-compat ServiceWorkers-e10s ServiceWorkers-devtools ServiceWorkers-streams ServiceWorkers-data ServiceWorkers-tests ServiceWorkers-perf ServiceWorkers-stability 643325 NavigationController 915233 930347 930348 930351 930611 931243 967264 975799 982711 982728 983499 984575 1002571 1003991 1011268 1025077 1025082 1041335 1043004 1043701 1043711 1045257 1046107 1047398 1048595 1048699 1049599 1053483 1059174 ServiceWorkers-v1 1065366 1065367 1109680 ServiceWorkers-postv1 1194562
Blocks: 922363 progressive-apps 1018320 1053255
  Show dependency treegraph
 
Reported: 2013-08-09 07:35 PDT by :Ehsan Akhgari (in Taipei, laggy response time)
Modified: 2017-01-05 07:25 PST (History)
90 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---
?


Attachments
Patch 1: rebased-sharedworkers (250.59 KB, patch)
2013-08-12 17:15 PDT, Nikhil Marathe [:nsm] (No longer reading bugmail, please needinfo?)
no flags Details | Diff | Splinter Review
Patch 2: Service (51.52 KB, patch)
2013-08-12 17:54 PDT, Nikhil Marathe [:nsm] (No longer reading bugmail, please needinfo?)
ehsan: feedback+
Details | Diff | Splinter Review
Service Worker proof of concept (14.72 KB, patch)
2013-09-06 15:21 PDT, Nikhil Marathe [:nsm] (No longer reading bugmail, please needinfo?)
no flags Details | Diff | Splinter Review
Alarm API that uses Service Worker (7.11 KB, patch)
2013-09-06 15:22 PDT, Nikhil Marathe [:nsm] (No longer reading bugmail, please needinfo?)
no flags Details | Diff | Splinter Review
ServiceWorkerManager (26.55 KB, patch)
2013-10-01 20:14 PDT, Nikhil Marathe [:nsm] (No longer reading bugmail, please needinfo?)
no flags Details | Diff | Splinter Review
Switch to enum over bool for worker type (20.74 KB, patch)
2013-10-01 20:17 PDT, Nikhil Marathe [:nsm] (No longer reading bugmail, please needinfo?)
no flags Details | Diff | Splinter Review
Promises on Workers. (6.59 KB, patch)
2013-10-09 09:08 PDT, Josh Matthews [:jdm]
no flags Details | Diff | Splinter Review
Add Response, Request, SameOriginResponse, and FetchEvent implementations. (26.15 KB, patch)
2013-10-09 09:10 PDT, Josh Matthews [:jdm]
no flags Details | Diff | Splinter Review
Make document navigation cause a ServiceWorker fetch event. (16.12 KB, patch)
2013-10-10 08:35 PDT, Josh Matthews [:jdm]
no flags Details | Diff | Splinter Review
Add Response, Request, SameOriginResponse, and FetchEvent implementations. (28.15 KB, patch)
2013-10-10 16:19 PDT, Josh Matthews [:jdm]
no flags Details | Diff | Splinter Review
Intercept images, fonts, objects, stylesheets, and XHRs. (32.20 KB, patch)
2013-10-14 09:25 PDT, Josh Matthews [:jdm]
no flags Details | Diff | Splinter Review
window.navigator stubs for ServiceWorker. (9.45 KB, patch)
2013-11-07 17:16 PST, Nikhil Marathe [:nsm] (No longer reading bugmail, please needinfo?)
no flags Details | Diff | Splinter Review
WIP: ServiceWorker, ServiceWorkerGlobalScope, InstallEvent WebIDL + basic implementation (61.12 KB, patch)
2013-11-07 17:20 PST, Nikhil Marathe [:nsm] (No longer reading bugmail, please needinfo?)
no flags Details | Diff | Splinter Review
WIP: ServiceWorker, ServiceWorkerGlobalScope, InstallEvent WebIDL + basic implementation (67.24 KB, patch)
2013-11-11 18:47 PST, Nikhil Marathe [:nsm] (No longer reading bugmail, please needinfo?)
no flags Details | Diff | Splinter Review
Add Response, Request, SameOriginResponse, and FetchEvent implementations. (27.53 KB, patch)
2013-11-11 18:48 PST, Nikhil Marathe [:nsm] (No longer reading bugmail, please needinfo?)
no flags Details | Diff | Splinter Review
Make document navigation cause a ServiceWorker fetch event. (17.04 KB, patch)
2013-11-11 18:50 PST, Nikhil Marathe [:nsm] (No longer reading bugmail, please needinfo?)
no flags Details | Diff | Splinter Review
Intercept images, fonts, objects, stylesheets, and XHRs. (34.40 KB, patch)
2013-11-12 10:05 PST, Nikhil Marathe [:nsm] (No longer reading bugmail, please needinfo?)
no flags Details | Diff | Splinter Review
WIP: ServiceWorker, ServiceWorkerGlobalScope, InstallEvent WebIDL + basic implementation* * * (71.13 KB, patch)
2013-12-05 17:10 PST, Nikhil Marathe [:nsm] (No longer reading bugmail, please needinfo?)
no flags Details | Diff | Splinter Review
Add Response, Request, SameOriginResponse, and FetchEvent implementations. (30.90 KB, patch)
2013-12-05 17:19 PST, Nikhil Marathe [:nsm] (No longer reading bugmail, please needinfo?)
no flags Details | Diff | Splinter Review
Make document navigation cause a ServiceWorker fetch event. (33.05 KB, patch)
2013-12-05 17:24 PST, Nikhil Marathe [:nsm] (No longer reading bugmail, please needinfo?)
no flags Details | Diff | Splinter Review
Intercept images, fonts, objects, stylesheets, and XHRs. (42.66 KB, patch)
2013-12-05 17:25 PST, Nikhil Marathe [:nsm] (No longer reading bugmail, please needinfo?)
no flags Details | Diff | Splinter Review
Add Response, Request, SameOriginResponse, and FetchEvent implementations. (30.42 KB, patch)
2014-04-01 18:42 PDT, Nikhil Marathe [:nsm] (No longer reading bugmail, please needinfo?)
no flags Details | Diff | Splinter Review
Make document navigation cause a ServiceWorker fetch event. (23.95 KB, patch)
2014-04-01 18:57 PDT, Nikhil Marathe [:nsm] (No longer reading bugmail, please needinfo?)
no flags Details | Diff | Splinter Review
Patch 3 - Setup Request object (5.48 KB, patch)
2014-04-01 18:59 PDT, Nikhil Marathe [:nsm] (No longer reading bugmail, please needinfo?)
no flags Details | Diff | Splinter Review
Patch 4 - Intercept images, fonts, objects, stylesheets, and XHRs. (35.31 KB, patch)
2014-04-01 19:02 PDT, Nikhil Marathe [:nsm] (No longer reading bugmail, please needinfo?)
no flags Details | Diff | Splinter Review
Patch 5 - Don't intercept ServiceWorker load requests. (9.15 KB, patch)
2014-04-01 19:11 PDT, Nikhil Marathe [:nsm] (No longer reading bugmail, please needinfo?)
no flags Details | Diff | Splinter Review

Description User image :Ehsan Akhgari (in Taipei, laggy response time) 2013-08-09 07:35:35 PDT

    
Comment 1 User image David Bruant 2013-08-09 09:19:25 PDT
Is there a spec somewhere? Or is it an internal thing?
Comment 2 User image Nikhil Marathe [:nsm] (No longer reading bugmail, please needinfo?) 2013-08-09 09:41:09 PDT
Its an experimental API right now. Updated URL to relevant discussion, but everything else is hand-wavy.
Comment 3 User image Nikhil Marathe [:nsm] (No longer reading bugmail, please needinfo?) 2013-08-12 17:15:57 PDT
Created attachment 789277 [details] [diff] [review]
Patch 1: rebased-sharedworkers

A cleaned up patch bent sent me that is required before applying the event page/service patch.
Comment 4 User image Nikhil Marathe [:nsm] (No longer reading bugmail, please needinfo?) 2013-08-12 17:54:55 PDT
Created attachment 789292 [details] [diff] [review]
Patch 2: Service

This is a first pass of Services that doesn't do a lot, but might be useful to Ehsan to figure out Navigation Controller and also a good time to layout my thoughts about further implementation.

What this code does do right now:
Inherits SharedWorker, to expose a Service() constructor to DOM (we could call it EventPage I guess, depending on how it gets used). This starts a (shared )worker, with the addition of a `mIsService` flag. A service is *not* immediately killed when all referring windows are closed. In fact, right now its lifetime is completely isolated from referring windows (which is not how it should be!). When it's event loop Dispatch() receives no events for some time (right now 13 seconds for no real reason), it cancels the service.

The rest of the discussion is in dev.platform (will paste link here).
Comment 5 User image Mounir Lamouri (:mounir) 2013-08-13 05:23:36 PDT
Comment on attachment 789292 [details] [diff] [review]
Patch 2: Service

Jonas and Ehsan's feedbacks should be enough.
Comment 6 User image :Ehsan Akhgari (in Taipei, laggy response time) 2013-08-14 08:27:35 PDT
Comment on attachment 789292 [details] [diff] [review]
Patch 2: Service

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

Feedback on the concept level issues given on the dev.webapi thread.

::: dom/workers/RuntimeService.cpp
@@ +2091,5 @@
> +    }
> +
> +    if (!windowArray->Contains(workerPrivate)) {
> +      windowArray->AppendElement(workerPrivate);
> +    }

Can this be refactored into a helper method?

::: dom/workers/RuntimeService.h
@@ +155,5 @@
>  
> +  nsresult
> +  CreateBackgroundService(JSContext* aCx, nsPIDOMWindow* aWindow,
> +                          const nsAString& aScriptURL, const nsAString& aName,
> +                          Service** aSharedWorker);

Nit: please prefer returning an already_AddRefed<Service> if possible.

::: dom/workers/Service.cpp
@@ +20,5 @@
> +} // anonymous namespace
> +
> +Service::Service(nsPIDOMWindow* aWindow,
> +                           WorkerPrivate* aWorkerPrivate)
> +: SharedWorker(aWindow, aWorkerPrivate)

Not sure if you're looking for whitespace nits quite yet.  ;-)

@@ +27,5 @@
> +}
> +
> +Service::~Service()
> +{
> +  AssertIsOnMainThread();

It's not immediately clear to me what guarantees this...

::: dom/workers/SharedWorker.h
@@ +47,5 @@
>    nsRefPtr<MessagePort> mMessagePort;
> +
> +  /**
> +   * Used to dispatch a Resume() event back to the SharedWorker itself.
> +   * XXXnsm I'm not sure why this has to be done using a Runnable.

Perhaps because we want to keep the object alive until the desired method is called on it?

@@ -80,5 @@
>  
>    virtual nsresult
>    PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
>  
> -private:

Nit: please make these protected.

::: dom/workers/Worker.cpp
@@ +105,5 @@
>  
>    static JSObject*
>    Construct(JSContext* aCx, WorkerPrivate* aParentObj,
>              const nsAString& aScriptURL, bool aIsChromeWorker,
> +            const nsAString& aSharedWorkerName, bool aIsService);

Nit: an enum would probably make the call sites more readable than a bool.

::: modules/libpref/src/init/all.js
@@ +89,5 @@
>  // Whether or not Shared Web Workers are enabled.
>  pref("dom.workers.sharedWorkers.enabled", true);
>  
> +// Whether or not Background Service Workers are enabled.
> +pref("dom.workers.service.enabled", true);

This should obviously default to false when you get to land this...
Comment 7 User image Jonas Sicking (:sicking) No longer reading bugmail consistently 2013-08-29 20:53:25 PDT
Comment on attachment 789292 [details] [diff] [review]
Patch 2: Service

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

Nikhil, sadly I won't have time to go over this very soon. Especially as I'm heading out for vacation for a week and then it's the B2G workweek. Feel free to poke me after that if you want my feedback on the code. But I'd prefer to just go over the API instead.
Comment 8 User image Nikhil Marathe [:nsm] (No longer reading bugmail, please needinfo?) 2013-09-06 15:21:00 PDT
Created attachment 801003 [details] [diff] [review]
Service Worker proof of concept

This is a much simplified patch over the earlier 'ugliness'. It:

* Does not present a DOM facing constructor or access to these workers.
* Does not require Shared Workers patches
* Almost entirely avoids modifying any existing worker code.
* Adds a single interface nsIServiceWorkerManager with a SendEvent() method that always creates a new Worker and sends the event to it. The plan is to make this do caching and stuff and integrate it with existing worker infrastructure.

Ehsan,
If you have the time, can you fiddle with integrating this into Necko in some tiny sense? intercepting a http request and feeding it to this as an event. SendEvent() does not currently accept data, just an event name.
Comment 9 User image Nikhil Marathe [:nsm] (No longer reading bugmail, please needinfo?) 2013-09-06 15:22:49 PDT
Created attachment 801004 [details] [diff] [review]
Alarm API that uses Service Worker

Alarm API with certain security checks disabled that enables it on web pages on Firefox Desktop, and uses nsIServiceWorkerManager rather than system messages.
Comment 10 User image Nikhil Marathe [:nsm] (No longer reading bugmail, please needinfo?) 2013-09-06 15:27:01 PDT
Forgot to point out that the patch hard codes the Service Worker being at http://localhost:8000. Change the paths when you compile. Patches to fix this will come later.

Small test page https://github.com/nikhilm/serviceworker-demo which served from |python -m SimpleHTTPServer| will work with the localhost:8000 thing.
Comment 11 User image :Ehsan Akhgari (in Taipei, laggy response time) 2013-09-09 06:01:34 PDT
Nikhil, Josh is now working on NavController.  Josh, please see comment 8.  Thanks!
Comment 12 User image Nikhil Marathe [:nsm] (No longer reading bugmail, please needinfo?) 2013-10-01 20:14:40 PDT
Created attachment 812948 [details] [diff] [review]
ServiceWorkerManager

Creates a window-less Worker.

RegisterServiceWorker() will load the URL and send it an install event.

SendEvent() can be used to send events. This will spawn a new Worker for every event, which is not what we want if the previous worker is alive (which it is since this does not terminate service workers yet).
Comment 13 User image Nikhil Marathe [:nsm] (No longer reading bugmail, please needinfo?) 2013-10-01 20:17:08 PDT
Created attachment 812949 [details] [diff] [review]
Switch to enum over bool for worker type

Useful for doing service worker specific stuff like introducing Cache APIs.

Josh, could you write a small WebIDL wrapper around your work in the Navigation Controller bug to create a simple Cache or SameOriginResponse and introduce it into the worker scope of a Service Worker?
Comment 14 User image Nikhil Marathe [:nsm] (No longer reading bugmail, please needinfo?) 2013-10-01 20:18:03 PDT
SharedWorkers patch that applies against current m-c at https://hg.mozilla.org/try/rev/092e09f82da8
Comment 15 User image Josh Matthews [:jdm] 2013-10-09 09:08:46 PDT
Created attachment 814940 [details] [diff] [review]
Promises on Workers.
Comment 16 User image Josh Matthews [:jdm] 2013-10-09 09:10:43 PDT
Created attachment 814942 [details] [diff] [review]
Add Response, Request, SameOriginResponse, and FetchEvent implementations.

This is still missing some glue to create a FetchEvent, since we need to pass it a channel. In theory calling respondWith and passing a SameOriginResponse would do the right thing, however.
Comment 17 User image Nikhil Marathe [:nsm] (No longer reading bugmail, please needinfo?) 2013-10-09 09:31:35 PDT
Marked Promises on worker bug as blocking this. That patch may be updated on bug 915233.

I have a WIP patch that adds InstallPhaseEvent and InstallEvent and some changes to existing patches.Since ServiceWorkers introduces these new events that may be dispatched on the Worker global, we need to wait for the conversion of WorkerPrivate and WorkerScope to use the main thread EventTarget infrastructure rather than implement custom events on the current code. khuey has a WIP patch for this, but he is on pseudo-vacation.
Comment 18 User image Nikhil Marathe [:nsm] (No longer reading bugmail, please needinfo?) 2013-10-09 09:34:31 PDT
Comment on attachment 814940 [details] [diff] [review]
Promises on Workers.

Obsoleting this patch as it does not make Promises 'usable' (runnable dispatch) on workers, while patch in referenced bug does.refer
Comment 19 User image Florian Bender 2013-10-10 00:32:16 PDT
(In reply to Nikhil Marathe [:nsm] from comment #17)
> … we need to wait for the conversion of WorkerPrivate and WorkerScope to
> use the main thread EventTarget infrastructure rather than implement 
> custom events on the current code. khuey has a WIP patch for this, but
> he is on pseudo-vacation.

Can you add the bug to the dependency list then, please?
Comment 20 User image Florian Bender 2013-10-10 00:34:45 PDT
Ah sorry, I misunderstood your comment. I just saw that Bug 915233 depends on Bug 914762 which you probably meant in Comment 18, right?
Comment 21 User image Nikhil Marathe [:nsm] (No longer reading bugmail, please needinfo?) 2013-10-10 06:56:13 PDT
(In reply to Florian Bender from comment #20)
> Ah sorry, I misunderstood your comment. I just saw that Bug 915233 depends
> on Bug 914762 which you probably meant in Comment 18, right?

I did mean 915233 in comment 18. As for Kyle's patch, I don't know the bug number.
Comment 22 User image Josh Matthews [:jdm] 2013-10-10 08:35:12 PDT
Created attachment 815393 [details] [diff] [review]
Make document navigation cause a ServiceWorker fetch event.

Unfinished, since the whole bit about actually creating and dispatching the FetchEvent is unclear to me. However, this should theoretically intercept document navigations for documents with active service workers.
Comment 23 User image Josh Matthews [:jdm] 2013-10-10 08:37:46 PDT
I stole this by accident.
Comment 24 User image Nikhil Marathe [:nsm] (No longer reading bugmail, please needinfo?) 2013-10-10 11:03:56 PDT
Josh, ' Add Response, Request, SameOriginResponse, and FetchEvent implementations.' is missing FetchEvent.cpp. Could you update the patch? Thanks!
Comment 25 User image Olli Pettay [:smaug] (review request backlog because of a work week) 2013-10-10 12:57:35 PDT
(please use Gecko coding style in content/ and dom/* code)
Comment 26 User image Josh Matthews [:jdm] 2013-10-10 16:19:53 PDT
Created attachment 815624 [details] [diff] [review]
Add Response, Request, SameOriginResponse, and FetchEvent implementations.
Comment 27 User image Josh Matthews [:jdm] 2013-10-14 09:25:26 PDT
Created attachment 816658 [details] [diff] [review]
Intercept images, fonts, objects, stylesheets, and XHRs.

More interception, along with deducing fetch type and top level-ness.
Comment 28 User image Nikhil Marathe [:nsm] (No longer reading bugmail, please needinfo?) 2013-10-23 19:36:57 PDT
Hanging off tasks off this as I think of them.
Comment 29 User image Nikhil Marathe [:nsm] (No longer reading bugmail, please needinfo?) 2013-11-07 17:16:15 PST
Created attachment 829002 [details] [diff] [review]
window.navigator stubs for ServiceWorker.

Adds empty (un)registerServiceWorker.
Comment 30 User image Nikhil Marathe [:nsm] (No longer reading bugmail, please needinfo?) 2013-11-07 17:20:41 PST
Created attachment 829005 [details] [diff] [review]
WIP: ServiceWorker, ServiceWorkerGlobalScope, InstallEvent WebIDL + basic implementation

Integrates into the SharedWorker infrastructure (needs more work) and dispatches the "install" event. Will be split into more bugs soon.
Comment 31 User image Nikhil Marathe [:nsm] (No longer reading bugmail, please needinfo?) 2013-11-11 18:47:01 PST
Created attachment 830584 [details] [diff] [review]
WIP: ServiceWorker, ServiceWorkerGlobalScope, InstallEvent WebIDL + basic implementation

Plug service workers into domain info.
Comment 32 User image Nikhil Marathe [:nsm] (No longer reading bugmail, please needinfo?) 2013-11-11 18:48:34 PST
Created attachment 830586 [details] [diff] [review]
Add Response, Request, SameOriginResponse, and FetchEvent implementations.

Unbitrotted and rebased over ServiceWorker.
Comment 33 User image Nikhil Marathe [:nsm] (No longer reading bugmail, please needinfo?) 2013-11-11 18:50:09 PST
Created attachment 830589 [details] [diff] [review]
Make document navigation cause a ServiceWorker fetch event.

Unbitrot, add support for querying domain info about service worker.
Comment 34 User image Nikhil Marathe [:nsm] (No longer reading bugmail, please needinfo?) 2013-11-12 10:05:31 PST
Created attachment 830923 [details] [diff] [review]
Intercept images, fonts, objects, stylesheets, and XHRs.

Patch rebased to compile, haven't tested yet.
Comment 35 User image Josh Matthews [:jdm] 2013-11-21 01:42:04 PST
Comment on attachment 830923 [details] [diff] [review]
Intercept images, fonts, objects, stylesheets, and XHRs.

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

::: image/src/imgLoader.cpp
@@ +434,5 @@
>                       aPolicy);
>    if (NS_FAILED(rv))
>      return rv;
>  
> +  newChannel = aLoadingDocument->InterceptFetch(newChannel, nsIDocument::Fetch);

This needs a null check.
Comment 36 User image Nikhil Marathe [:nsm] (No longer reading bugmail, please needinfo?) 2013-12-05 17:10:12 PST
Created attachment 8343436 [details] [diff] [review]
WIP: ServiceWorker, ServiceWorkerGlobalScope, InstallEvent WebIDL + basic implementation* * *

ServiceWorker in memory structures and installation procedure.
Comment 37 User image Nikhil Marathe [:nsm] (No longer reading bugmail, please needinfo?) 2013-12-05 17:19:51 PST
Created attachment 8343446 [details] [diff] [review]
Add Response, Request, SameOriginResponse, and FetchEvent implementations.

Cycle collection fixes and other additions.
Comment 38 User image Nikhil Marathe [:nsm] (No longer reading bugmail, please needinfo?) 2013-12-05 17:24:16 PST
Created attachment 8343448 [details] [diff] [review]
Make document navigation cause a ServiceWorker fetch event.

Added hashtables to keep track of ServiceWorkers.
Various Runnables to pass requests to and from workers.
Mark a document as being controlled in StartDocumentLoad.
Comment 39 User image Nikhil Marathe [:nsm] (No longer reading bugmail, please needinfo?) 2013-12-05 17:25:27 PST
Created attachment 8343449 [details] [diff] [review]
Intercept images, fonts, objects, stylesheets, and XHRs.

Minor changes.
Comment 40 User image Josh Matthews [:jdm] 2014-01-06 14:11:37 PST
Comment on attachment 8343448 [details] [diff] [review]
Make document navigation cause a ServiceWorker fetch event.

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

::: content/base/src/nsDocument.cpp
@@ +2474,5 @@
>    }
>  
> +  bool dummy;
> +  nsCOMPtr<nsIServiceWorkerManager> swm = do_GetService(SERVICEWORKERMANAGER_CONTRACTID);
> +  swm->StartInterception(this, &dummy);

How do we plan to make use of the success value in the future?

::: dom/interfaces/base/nsIServiceWorkerManager.idl
@@ +17,5 @@
> +  void sendFetchEvent(in nsIDocument aDocument, in nsIAlternateSourceChannel aChannel, in nsIURI aPageURI);
> +  bool isControlled(in nsIDocument aDocument);
> +  // Returns a ServiceWorker or null.
> +  nsISupports GetServiceWorker(in nsIDocument aDocument);
> +  bool startInterception(in nsIDocument aDocument);

The return value needs documentation.

::: dom/workers/ServiceWorkerManager.cpp
@@ +355,5 @@
> +    JS::Rooted<JSObject*> jsGlobal(aCx, target->GetWrapper());
> +    GlobalObject globalObject(aCx, jsGlobal);
> +
> +    mozilla::dom::RequestInit init;
> +    init.mUrl.Construct(NS_ConvertUTF8toUTF16(mResourceURL));

I'm not convinced that using this URL across threads is safe. I would be inclined to store the spec and create a new URL here.

@@ +468,5 @@
> +  return NS_OK;
> +}
> +
> +static nsresult
> +GetDocumentDomain(nsIDocument* aDoc, nsCString& domain, JSContext* cx = nullptr)

This method feels like it should reside elsewhere (like in document code), but that's just my gut feeling.

@@ +520,5 @@
> +ServiceWorkerManager::IsControlled(nsIDocument* aDoc, bool* aControlled)
> +{
> +  MOZ_ASSERT(NS_IsMainThread());
> +  nsCString domain;
> +  nsresult rv = GetDocumentDomain(aDoc, domain);

rv is ignored

@@ +560,5 @@
> +ServiceWorkerManager::StartInterception(nsIDocument* aDoc, bool* aSuccess)
> +{
> +  MOZ_ASSERT(NS_IsMainThread());
> +  nsCString domain;
> +  nsresult rv = GetDocumentDomain(aDoc, domain);

rv is ignored.

@@ +821,5 @@
> +    return NS_OK;
> +  }
> +
> +  nsCString domain;
> +  nsresult rv = aDocument->GetDocumentURI()->GetHost(domain);

rv is ignored
Comment 41 User image Nikhil Marathe [:nsm] (No longer reading bugmail, please needinfo?) 2014-04-01 18:42:50 PDT
Created attachment 8400324 [details] [diff] [review]
Add Response, Request, SameOriginResponse, and FetchEvent implementations.

Various rebases, spec updates and minor things to make these usable.
Comment 42 User image Nikhil Marathe [:nsm] (No longer reading bugmail, please needinfo?) 2014-04-01 18:57:22 PDT
Created attachment 8400330 [details] [diff] [review]
Make document navigation cause a ServiceWorker fetch event.
Comment 43 User image Nikhil Marathe [:nsm] (No longer reading bugmail, please needinfo?) 2014-04-01 18:59:37 PDT
Created attachment 8400331 [details] [diff] [review]
Patch 3 - Setup Request object
Comment 44 User image Nikhil Marathe [:nsm] (No longer reading bugmail, please needinfo?) 2014-04-01 19:02:57 PDT
Created attachment 8400335 [details] [diff] [review]
Patch 4 - Intercept images, fonts, objects, stylesheets, and XHRs.
Comment 45 User image Nikhil Marathe [:nsm] (No longer reading bugmail, please needinfo?) 2014-04-01 19:11:29 PDT
Created attachment 8400339 [details] [diff] [review]
Patch 5 - Don't intercept ServiceWorker load requests.
Comment 46 User image Nikhil Marathe [:nsm] (No longer reading bugmail, please needinfo?) 2015-02-09 14:55:30 PST
jdm, are any of the attachments here relevant any longer? Otherwise I'll obsolete all of them.
Comment 47 User image Josh Matthews [:jdm] 2015-02-09 15:18:59 PST
Wow. No.
Comment 48 User image Ben Kelly [:bkelly] 2017-01-04 08:34:00 PST
I've attempted to clean up this bug to use as a meta for ongoing service worker efforts.  I've hung some child meta bugs for different efforts underneath it:

  Bug 1226983 (ServiceWorkers-compat): Spec compatibility issues
  Bug 1262699 (ServiceWorkers-devtools): Make it easier for web devs to build service workers
  Bug 1328391 (ServiceWorkers-data): Add telemetry to support data driven development
  Bug 1328622 (ServiceWorkers-perf): Performance testing and optimizations
  Bug 1328614 (ServiceWorkers-tests): Issues with service worker related tests
  Bug 1283191 (ServiceWorkers-streams): Integrate WHATWG streams API into service workers
  Bug 1212882 (ServiceWorkers-foreign): Implement foreign fetch
Comment 49 User image Ben Kelly [:bkelly] 2017-01-04 08:42:36 PST
I also added:

  Bug 1328631 (ServiceWorkers-stability): To track crashes, assertions, or other stability issues

Note You need to log in before you can comment on or make changes to this bug.