DELETE: 1 patches - swm-everything-else
authorNikhil Marathe <nsm.nikhil@gmail.com>
Wed, 23 Jul 2014 17:31:51 -0700
changeset 1108 57c5c4c43a7bd6dc92f3531b194e1626633c4685
parent 1107 bc176b378a8c2b0ff7bed8a82e77f38a6177a7e8
child 1109 f399569a6fddf0a9ed8793676892322e6c5e3c34
push id32
push usernsm.nikhil@gmail.com
push dateThu, 24 Jul 2014 00:32:46 +0000
DELETE: 1 patches - swm-everything-else DELETE: swm-everything-else qparent: 666e5e6b3abf qtip: 666e5e6b3abf top: (none)
series
swm-everything-else
--- a/series
+++ b/series
@@ -9,17 +9,16 @@ 885093-push-prompt
 sw-push
 sw-push-mix
 903441-navigation-event
 903441-setup-request
 903441-intercepts
 903441-sw-nointercept
 foo
 898524-cache
-swm-everything-else
 sw-install-tests2
 sw-more-install-tests
 931249-caching1
 943704-importscripts
 939636-toolkit
 939636-browser
 939636-testing
 939636-dom
deleted file mode 100644
--- a/swm-everything-else
+++ /dev/null
@@ -1,704 +0,0 @@
-# HG changeset patch
-# Parent bf2aff75a41a1b70cdda1fee001ae2cd1da14a74
-# User Nikhil Marathe <nsm.nikhil@gmail.com>
-diff --git a/dom/workers/ServiceWorkerManager.cpp b/dom/workers/ServiceWorkerManager.cpp
---- a/dom/workers/ServiceWorkerManager.cpp
-+++ b/dom/workers/ServiceWorkerManager.cpp
-@@ -85,16 +85,127 @@ public:
-     nsRefPtr<ResolvePromisesOnMainThreadRunnable> r =
-       new ResolvePromisesOnMainThreadRunnable(mRegistration,
-                                               NS_ConvertUTF16toUTF8(aWorkerPrivate->ScriptURL()));
-     NS_DispatchToMainThread(r);
-     return true;
-   }
- };
- 
-+class FinishInstallRunnable : public nsRunnable
-+{
-+  const nsCString mDomain;
-+  const nsCString mScope;
-+
-+public:
-+  FinishInstallRunnable(const nsACString& aDomain, const nsACString& aScope)
-+    : mDomain(aDomain), mScope(aScope)
-+  {
-+    MOZ_ASSERT(!NS_IsMainThread());
-+  }
-+
-+  NS_IMETHODIMP
-+  Run()
-+  {
-+    AssertIsOnMainThread();
-+
-+    // FinishInstall takes ownership of the passed info.
-+    ServiceWorkerManager::GetInstance()->FinishInstall(mDomain, mScope);
-+    return NS_OK;
-+  }
-+};
-+
-+class FinishInstallHandler : public PromiseNativeHandler
-+{
-+  const nsCString mScope;
-+
-+public:
-+  NS_DECL_ISUPPORTS_INHERITED
-+
-+  FinishInstallHandler(const nsACString& aScope)
-+    : mScope(aScope)
-+  {
-+    MOZ_ASSERT(!NS_IsMainThread());
-+  }
-+
-+  virtual
-+  ~FinishInstallHandler()
-+  { }
-+
-+  void
-+  ResolvedCallback(JS::Handle<JS::Value> aValue)
-+  {
-+    WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
-+    MOZ_ASSERT(workerPrivate);
-+
-+    nsRefPtr<FinishInstallRunnable> r =
-+      new FinishInstallRunnable(workerPrivate->Domain(), mScope);
-+    NS_DispatchToMainThread(r);
-+  }
-+
-+  void
-+  RejectedCallback(JS::Handle<JS::Value> aValue)
-+  {
-+    // We don't have to do anything right now to cancel the install.
-+    // When the worker stops running it will terminate and nothing will have
-+    // happened.
-+  }
-+};
-+
-+NS_IMPL_ISUPPORTS_INHERITED0(FinishInstallHandler, PromiseNativeHandler)
-+
-+InstallEventRunnable::InstallEventRunnable(WorkerPrivate* aWorkerPrivate, const nsACString& aScope)
-+    : WorkerRunnable(aWorkerPrivate, WorkerThreadModifyBusyCount),
-+      mScope(aScope)
-+{
-+  MOZ_ASSERT(aWorkerPrivate);
-+}
-+
-+bool
-+InstallEventRunnable::DispatchInstallEvent(JSContext* aCx, WorkerPrivate* aWorkerPrivate)
-+{
-+  MOZ_ASSERT(aWorkerPrivate->IsServiceWorker());
-+  nsRefPtr<WorkerGlobalScope> target = aWorkerPrivate->GlobalScope();
-+
-+  // FIXME(nsm): Set activeWorker to the correct thing.
-+  InstallEventInit init;
-+  init.mBubbles = false;
-+  init.mCancelable = true;
-+  nsRefPtr<InstallEvent> event =
-+    InstallEvent::Constructor(target, NS_LITERAL_STRING("install"), init);
-+
-+  event->SetTrusted(true);
-+
-+  nsresult rv = target->DispatchDOMEvent(nullptr, event, nullptr, nullptr);
-+  MOZ_ASSERT(NS_SUCCEEDED(rv));
-+
-+  nsRefPtr<Promise> waitingOn;
-+  if (event->WaitingOnPromise()) {
-+    waitingOn = event->GetPromise();
-+  } else {
-+    ErrorResult rv;
-+    waitingOn =
-+      Promise::Resolve(aWorkerPrivate->GlobalScope(),
-+                       aCx, JS::UndefinedHandleValue, rv);
-+  }
-+  nsRefPtr<FinishInstallHandler> handler = new FinishInstallHandler(mScope);
-+  waitingOn->AppendNativeHandler(handler);
-+  return true;
-+}
-+
-+bool
-+InstallEventRunnable::WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate)
-+{
-+  MOZ_ASSERT(aWorkerPrivate);
-+  if (aWorkerPrivate->GetStatus() > Running) {
-+    return true;
-+  }
-+  return DispatchInstallEvent(aCx, aWorkerPrivate);
-+}
-+
- //////////////////////////
- // ServiceWorkerManager //
- //////////////////////////
- 
- NS_IMPL_ISUPPORTS(ServiceWorkerManager, nsIServiceWorkerManager)
- 
- ServiceWorkerManager::ServiceWorkerManager()
- {
-@@ -307,27 +418,129 @@ ServiceWorkerManager::Update(ServiceWork
-     RejectUpdatePromiseObservers(aRegistration, rv);
-     return rv;
-   }
- 
-   mBeingFetched.Put(aRegistration->mScriptSpec, fetcher);
-   return NS_OK;
- }
- 
-+// If we return an error, ServiceWorkerContainer will reject the Promise.
-+NS_IMETHODIMP
-+ServiceWorkerManager::Unregister(nsIDOMWindow* aWindow, const nsAString& aScope,
-+                                 nsISupports** aPromise)
-+{
-+  AssertIsOnMainThread();
-+  MOZ_ASSERT(aWindow);
-+
-+  // XXXnsm Don't allow chrome callers for now.
-+  MOZ_ASSERT(!nsContentUtils::IsCallerChrome());
-+
-+  // TODO(nsm): Implement unregistration.
-+
-+  return NS_ERROR_FAILURE;
-+}
-+
-+NS_IMETHODIMP
-+ServiceWorkerManager::GetDocumentController(nsIDocument* aDoc, nsISupports** aServiceWorker)
-+{
-+    fprintf(stderr, "\n\n\n\n\n NSM CALL FOR CHECK \n\n\n\n");
-+  // FIXME(nsm): There may not always be a running service worker.
-+  // In addition, we usually want to create a shell ServiceWorker, with no
-+  // backing WorkerPrivate, and instantiate the worker only on requests or
-+  // postMessage. And be willing to kill it again fast.
-+  MOZ_ASSERT(NS_IsMainThread());
-+  MOZ_ASSERT(aDoc);
-+
-+  ServiceWorkerRegistration* registration = nullptr;
-+  if (!FindPossibleController(aDoc, &registration)) {
-+    return NS_ERROR_NOT_AVAILABLE;
-+  }
-+
-+  if (!registration->mCurrentWorker) {
-+    fprintf(stderr, "\n\n\n\n NSM Complaining because not current!\n\n\n");
-+    return NS_ERROR_NOT_AVAILABLE;
-+  }
-+
-+  if (!registration->mCurrentWorker->mControlledDocuments.Contains(aDoc)) {
-+    return NS_ERROR_NOT_AVAILABLE;
-+  }
-+
-+  // FIXME(nsm): Check activating status.
-+
-+  nsRefPtr<ServiceWorker> serviceWorker;
-+  nsresult rv =
-+    CreateServiceWorkerForDocument(aDoc,
-+                                   registration->mScriptSpec,
-+                                   registration->mScope,
-+                                   getter_AddRefs(serviceWorker));
-+
-+  if (NS_WARN_IF(NS_FAILED(rv))) {
-+    return rv;
-+  }
-+
-+  serviceWorker.forget(aServiceWorker);
-+  return NS_OK;
-+}
-+
- /* static */
- ServiceWorkerManager*
- ServiceWorkerManager::GetInstance()
- {
-   nsCOMPtr<nsIServiceWorkerManager> swm = do_GetService(SERVICEWORKERMANAGER_CONTRACTID);
-   ServiceWorkerManager* concrete = static_cast<ServiceWorkerManager*>(swm.get());
-   MOZ_ASSERT(concrete);
-   return concrete;
- }
- 
- void
-+ServiceWorkerManager::FetchAndParseError(const nsACString& aURL,
-+                                         nsString aMessage,
-+                                         nsString aFilename,
-+                                         nsString aLine,
-+                                         uint32_t aLineNumber,
-+                                         uint32_t aColumnNumber,
-+                                         uint32_t aFlags,
-+                                         uint32_t aErrorNumber)
-+{
-+  AssertIsOnMainThread();
-+  // FIXME(nsm): Bug 983497 Fire error on relevant ServiceWorkerContainers.
-+  nsAutoPtr<nsTArray<nsTWeakRef<Promise>>> entry;
-+  mRegisterPromises.RemoveAndForget(aURL, entry);
-+  MOZ_ASSERT(entry);
-+
-+  nsCOMPtr<nsIScriptError> errorObject =
-+    do_CreateInstance("@mozilla.org/scripterror;1");
-+  if (NS_WARN_IF(!errorObject)) {
-+    return;
-+  }
-+
-+  nsresult rv = errorObject->Init(aMessage, aFilename, aLine,
-+                                  aLineNumber, aColumnNumber, aFlags,
-+                                  "content");
-+
-+  if (NS_WARN_IF(NS_FAILED(rv))) {
-+    return;
-+  }
-+
-+  for (uint32_t i = 0; i < entry->Length(); ++i) {
-+    nsTWeakRef<Promise>& item = entry->ElementAt(i);
-+    if (item) {
-+      nsCOMPtr<nsIGlobalObject> go = do_QueryInterface(item->GetParentObject());
-+      MOZ_ASSERT(go);
-+
-+      AutoSafeJSContext cx;
-+      JS::Rooted<JSObject*> global(cx, go->GetGlobalJSObject());
-+      JSAutoCompartment ac(cx, global);
-+      item->MaybeReject(errorObject);
-+    }
-+  }
-+}
-+
-+void
- ServiceWorkerManager::ResolveRegisterPromises(ServiceWorkerRegistration* aRegistration, const nsACString& aWorkerScriptSpec)
- {
-   AssertIsOnMainThread();
-   MOZ_ASSERT(aRegistration->HasUpdatePromise());
- 
-   RuntimeService* rs = RuntimeService::GetOrCreateService();
-   MOZ_ASSERT(rs);
- 
-@@ -433,16 +646,84 @@ ServiceWorkerManager::FinishFetch(Servic
- 
-   Install(aFetcher->mRegistration, worker);
- }
- 
- void
- ServiceWorkerManager::Install(ServiceWorkerRegistration* aRegistration,
-                               ServiceWorker* aServiceWorker)
- {
-+  if (!aRegistration->mWaitingWorker) {
-+    // FIXME(nsm): Clean up queued worker.
-+  }
-+
-+  // FIXME(nsm): Bug 983497 Fire "install" on NSWs.
-+
-+  // FIXME(nsm): Bug 982787
-+  AutoSafeJSContext cx;
-+  nsRefPtr<WorkerRunnable> r =
-+    new InstallEventRunnable(aServiceWorker->GetWorkerPrivate(),
-+                             aRegistration->mScope);
-+  if (!r->Dispatch(cx)) {
-+    MOZ_CRASH("Could not dispatch InstallEventRunnable!");
-+    return;
-+  }
-+}
-+
-+void
-+ServiceWorkerManager::FinishInstall(const nsACString& aDomain, const nsACString& aScope)
-+{
-+  AssertIsOnMainThread();
-+  ServiceWorkerDomainInfo* domainInfo;
-+  if (!mDomainMap.Get(aDomain, &domainInfo)) {
-+    MOZ_CRASH("No domain entry found!");
-+    return;
-+  }
-+
-+  MOZ_ASSERT(domainInfo);
-+
-+  ServiceWorkerRegistration* registration;
-+  if (!domainInfo->mServiceWorkerRegistrations.Get(aScope, &registration)) {
-+    // Someone called unregister() while this was installing, what do we do?
-+    // FIXME(nsm):
-+    MOZ_CRASH("Implement me");
-+  }
-+
-+  // We can finally queue it up for documents to look up.
-+  AddScope(domainInfo->mOrderedScopes, registration->mScope);
-+
-+  registration->mWaitingWorker = new ServiceWorkerInfo(registration->mScriptSpec);
-+  fprintf(stderr, "\n\n\n\n NSM Queued so don't complain!\n\n\n");
-+
-+  // FIXME(nsm): Bug 983499, Bug 983497 Fire "installend" on global scope.
-+  // FIXME(nsm): If any handler calls replace, do stuff.
-+
-+  // FIXME(nsm): Add no document is using check.
-+  Activate(registration);
-+}
-+
-+void
-+ServiceWorkerManager::Activate(ServiceWorkerRegistration* aRegistration)
-+{
-+  AssertIsOnMainThread();
-+  MOZ_ASSERT(aRegistration);
-+
-+  nsAutoPtr<ServiceWorkerInfo> activatingWorker = aRegistration->mWaitingWorker;
-+  nsAutoPtr<ServiceWorkerInfo> exitingWorker = aRegistration->mCurrentWorker;
-+
-+  // FIXME(nsm): Deal with current worker cleanup.
-+  
-+  aRegistration->mCurrentWorker = activatingWorker;
-+
-+  // FIXME(nsm): Bug 982760.
-+  // Bug 983499 Fire "activate" event worker scope.
-+  // Bug 983497 Fire "activate" event on NSWs
-+  // Deal with waitUntil()
-+  // Bug 983497 Fire "activateend" event on NSWs. Move this to
-+  // FinishServiceWorkerActivate.
- }
- 
- NS_IMETHODIMP
- ServiceWorkerManager::CreateServiceWorkerForWindow(nsPIDOMWindow* aWindow,
-                                                    const nsACString& aScriptSpec,
-                                                    const nsACString& aScope,
-                                                    ServiceWorker** aServiceWorker)
- {
-@@ -467,9 +748,245 @@ ServiceWorkerManager::CreateServiceWorke
-   if (NS_WARN_IF(NS_FAILED(rv))) {
-     return rv;
-   }
- 
-   serviceWorker.forget(aServiceWorker);
-   return rv;
- }
- 
-+NS_IMETHODIMP
-+ServiceWorkerManager::CreateServiceWorkerForDocument(nsIDocument* aDoc,
-+                                                     const nsACString& aScriptSpec,
-+                                                     const nsACString& aScope,
-+                                                     ServiceWorker** aServiceWorker)
-+{
-+  MOZ_ASSERT(aDoc);
-+
-+  RuntimeService* rs = RuntimeService::GetOrCreateService();
-+  nsRefPtr<ServiceWorker> serviceWorker;
-+
-+  nsCOMPtr<nsIGlobalObject> sgo = aDoc->GetScopeObject();
-+
-+  AutoSafeJSContext cx;
-+  JS::Rooted<JSObject*> jsGlobal(cx, sgo->GetGlobalJSObject());
-+  JSAutoCompartment ac(cx, jsGlobal);
-+
-+  GlobalObject global(cx, jsGlobal);
-+  nsresult rv = rs->CreateServiceWorker(global,
-+                                        NS_ConvertUTF8toUTF16(aScriptSpec),
-+                                        aScope,
-+                                        getter_AddRefs(serviceWorker));
-+
-+  if (NS_WARN_IF(NS_FAILED(rv))) {
-+    return rv;
-+  }
-+
-+  serviceWorker.forget(aServiceWorker);
-+  return rv;
-+}
-+
-+bool
-+ServiceWorkerManager::FindPossibleController(ServiceWorkerDomainInfo* aDomainInfo, nsIURI* aURI, ServiceWorkerRegistration** aInfo)
-+{
-+  MOZ_ASSERT(aDomainInfo);
-+  MOZ_ASSERT(aURI);
-+  nsCString path;
-+  aURI->GetPath(path);
-+
-+  nsCString scope = FindScopeForPath(aDomainInfo->mOrderedScopes, path);
-+  if (scope.IsEmpty()) {
-+    return false;
-+  }
-+
-+  ServiceWorkerRegistration* registration;
-+  if (!aDomainInfo->mServiceWorkerRegistrations.Get(scope, &registration)) {
-+      NS_WARNING("No registration found in the domain registrations!");
-+    // FIXME(nsm): Is this possible?
-+    return false;
-+  }
-+
-+  *aInfo = registration;
-+  return true;
-+}
-+
-+bool
-+ServiceWorkerManager::FindPossibleController(nsIDocument* aDoc, ServiceWorkerRegistration** aInfo)
-+{
-+  MOZ_ASSERT(aDoc);
-+  nsCString domain;
-+  nsIPrincipal* nodePrincipal = aDoc->NodePrincipal();
-+  MOZ_ASSERT(nodePrincipal);
-+  nsresult rv = nodePrincipal->GetBaseDomain(domain);
-+  if (NS_WARN_IF(NS_FAILED(rv))) {
-+    return false;
-+  }
-+
-+  ServiceWorkerDomainInfo* domainInfo;
-+  if (!mDomainMap.Get(domain, &domainInfo)) {
-+    fprintf(stderr, "NSM FindPossibleController no information found for domain \"%s\"\n", domain.get());
-+    return false;
-+  }
-+
-+  nsCOMPtr<nsIURI> uri = aDoc->GetDocumentURIObject();
-+
-+  return FindPossibleController(domainInfo, uri, aInfo);
-+}
-+
-+NS_IMETHODIMP
-+ServiceWorkerManager::MaybeStartControlling(nsIDocument* aDoc)
-+{
-+  MOZ_ASSERT(NS_IsMainThread());
-+  MOZ_ASSERT(aDoc);
-+
-+  ServiceWorkerRegistration* registration;
-+  if (FindPossibleController(aDoc, &registration) && registration->mCurrentWorker) {
-+    registration->mCurrentWorker->mControlledDocuments.AppendElement(aDoc);
-+    return NS_OK;
-+  }
-+
-+  return NS_ERROR_FAILURE;
-+}
-+
-+NS_IMETHODIMP
-+ServiceWorkerManager::MaybeStopControlling(nsIDocument* aDoc)
-+{
-+  MOZ_ASSERT(NS_IsMainThread());
-+  MOZ_ASSERT(aDoc);
-+
-+  ServiceWorkerRegistration* registration;
-+  if (FindPossibleController(aDoc, &registration) && registration->mCurrentWorker) {
-+    registration->mCurrentWorker->mControlledDocuments.RemoveElement(aDoc);
-+    return NS_OK;
-+  }
-+
-+  return NS_ERROR_FAILURE;
-+}
-+
-+namespace {
-+/*
-+ * Returns string without trailing '*'.
-+ */
-+void ScopeWithoutStar(const nsACString& aScope, nsACString& out)
-+{
-+  if (aScope.Last() == '*') {
-+    out.Assign(StringHead(aScope, aScope.Length() - 1));
-+    return;
-+  }
-+
-+  out.Assign(aScope);
-+}
-+}; // anonymous namespace
-+
-+// FIXME(nsm): Just use Comparator and let nsTArray do all these operations.
-+// Possible?
-+void
-+ServiceWorkerManager::AddScope(nsTArray<nsCString>& aList, const nsACString& aScope)
-+{
-+  for (uint32_t i = 0; i < aList.Length(); ++i) {
-+    nsCString current = aList[i];
-+
-+    // Perfect match!
-+    if (aScope.Equals(current)) {
-+      return;
-+    }
-+
-+    nsCString normalizedCurrentScope;
-+    ScopeWithoutStar(current, normalizedCurrentScope);
-+    // Edge case of match without '*'.
-+    // /foo should be sorted before /foo*.
-+    if (aScope.Equals(normalizedCurrentScope)) {
-+      aList.InsertElementAt(i, aScope);
-+      return;
-+    }
-+
-+    // /foo/bar* should be before /foo/*
-+    // Similarly /foo/b* is between the two.
-+    // But is /foo* categorically different?
-+    if (StringBeginsWith(aScope, normalizedCurrentScope)) {
-+      // If the new scope is a pattern and the old one is a path, the new one
-+      // goes after.  This way Add(/foo) followed by Add(/foo*) ends up with
-+      // [/foo, /foo*].
-+      if (aScope.Last() == '*' &&
-+          normalizedCurrentScope.Equals(current)) {
-+        aList.InsertElementAt(i+1, aScope);
-+      } else {
-+        aList.InsertElementAt(i, aScope);
-+      }
-+      return;
-+    }
-+  }
-+
-+  aList.AppendElement(aScope);
-+}
-+
-+// Returns the pair since aPath and the actual scope will be different, we're
-+// doing a match and not a equality search.
-+// Returns a copy whose ownership is the responsibility of the caller.
-+// aPath can never have '*'.
-+nsCString
-+ServiceWorkerManager::FindScopeForPath(nsTArray<nsCString>& aList, const nsACString& aPath)
-+{
-+  MOZ_ASSERT(aPath.FindChar('*') == -1);
-+
-+  nsCString match;
-+
-+  for (uint32_t i = 0; i < aList.Length(); ++i) {
-+    const nsCString& current = aList[i];
-+    nsCString normalizedCurrentScope;
-+    ScopeWithoutStar(current, normalizedCurrentScope);
-+    if (StringBeginsWith(aPath, normalizedCurrentScope)) {
-+      // If non-pattern match, then check equality.
-+      if (current.Last() == '*' ||
-+          aPath.Equals(current)) {
-+        match = current;
-+        break;
-+      }
-+    }
-+  }
-+
-+  return match;
-+}
-+
-+void
-+ServiceWorkerManager::RemoveScope(nsTArray<nsCString>& aList, const nsACString& aScope)
-+{
-+  aList.RemoveElement(aScope);
-+}
-+
-+// Testing only.
-+NS_IMETHODIMP
-+ServiceWorkerManager::GetControllingWorkerScriptURLForPath(nsIDocument* aDoc,
-+                                                           const nsAString& aPath,
-+                                                           nsAString& aScriptURL)
-+{
-+  MOZ_ASSERT(aDoc);
-+  nsCString domain;
-+  nsIPrincipal* nodePrincipal = aDoc->NodePrincipal();
-+  MOZ_ASSERT(nodePrincipal);
-+  nsresult rv = nodePrincipal->GetBaseDomain(domain);
-+  if (NS_WARN_IF(NS_FAILED(rv))) {
-+    return rv;
-+  }
-+
-+  ServiceWorkerDomainInfo* domainInfo;
-+  if (!mDomainMap.Get(domain, &domainInfo)) {
-+    fprintf(stderr, "NSM FindPossibleController no information found for domain %s\n", domain.get());
-+    return NS_ERROR_FAILURE;
-+  }
-+
-+  nsCOMPtr<nsIURI> uri;
-+  rv = NS_NewURI(getter_AddRefs(uri), aPath, nullptr, aDoc->GetDocumentURI());
-+  if (NS_WARN_IF(NS_FAILED(rv))) {
-+    return rv;
-+  }
-+
-+  ServiceWorkerRegistration *registration;
-+  if (!FindPossibleController(domainInfo, uri, &registration)) {
-+    return NS_ERROR_FAILURE;
-+  }
-+
-+  MOZ_ASSERT(registration);
-+  aScriptURL = NS_ConvertUTF8toUTF16(registration->mScriptSpec);
-+  return NS_OK;
-+}
-+
- END_WORKERS_NAMESPACE
-diff --git a/dom/workers/ServiceWorkerManager.h b/dom/workers/ServiceWorkerManager.h
---- a/dom/workers/ServiceWorkerManager.h
-+++ b/dom/workers/ServiceWorkerManager.h
-@@ -180,47 +180,105 @@ public:
-   // while the install is in progress. The async install steps for register
-   // bar_worker.js could finish before foo_worker.js, but bar_worker still has
-   // to be the winning controller.
-   // FIXME(nsm): Move this into per domain?
- 
-   // URL to fetcher.
-   nsRefPtrHashtable<nsCStringHashKey, ServiceWorkerFetcher> mBeingFetched;
- 
-+  // the Promise's are the return value of `register()` and will be
-+  // resolved/rejected based on the fetch/parse/install.
-+  // Indexed by script URL sent in for register().
-+  nsClassHashtable<nsCStringHashKey, nsTArray<nsTWeakRef<Promise>>> mRegisterPromises;
-+
-+  nsresult
-+  CreateServiceWorkerInternal(JSContext* aCx,
-+                              nsPIDOMWindow* aWindow,
-+                              ServiceWorkerInfo* aServiceWorkerInfo,
-+                              ServiceWorker** aServiceWorker);
-+
-+  void
-+  FetchAndParseError(const nsACString& aURL,
-+                     nsString aMessage,
-+                     nsString aFilename,
-+                     nsString aLine,
-+                     uint32_t aLineNumber,
-+                     uint32_t aColumnNumber,
-+                     uint32_t aFlags,
-+                     uint32_t aErrorNumber);
-+
-   void
-   ResolveRegisterPromises(ServiceWorkerRegistration* aRegistration,
-                           const nsACString& aWorkerScriptSpec);
- 
-   void
-   RejectUpdatePromiseObservers(ServiceWorkerRegistration* aRegistration, nsresult aResult);
- 
-   void
-   FinishFetch(ServiceWorkerFetcher* aFetcher,
-               nsresult aStatus, uint32_t aStringLen,
-               const uint8_t* aString);
- 
-+  void
-+  FinishInstall(const nsACString& aDomain, const nsACString& aScriptSpec);
-+
-   static ServiceWorkerManager* GetInstance();
- 
- private:
-   ServiceWorkerManager();
-   ~ServiceWorkerManager();
- 
-   NS_IMETHOD
-   Update(ServiceWorkerRegistration* aRegistration, nsPIDOMWindow* aWindow);
- 
-   void
-   Install(ServiceWorkerRegistration* aRegistration,
-           ServiceWorker* aServiceWorker);
- 
-+  void
-+  Activate(ServiceWorkerRegistration* aRegistration);
-+
-+  static bool CleanedScope(const nsACString& aInputScope,
-+                           nsCString& cleanedScope);
-+
-+  void
-+  AddScope(nsTArray<nsCString>& aList, const nsACString& aScope);
-+
-+  nsCString
-+  FindScopeForPath(nsTArray<nsCString>& aList, const nsACString& aPath);
-+
-+  void
-+  RemoveScope(nsTArray<nsCString>& aList, const nsACString& aScope);
-+
-   NS_IMETHODIMP
-   CreateServiceWorkerForWindow(nsPIDOMWindow* aWindow,
-                                const nsACString& aScriptSpec,
-                                const nsACString& aScope,
-                                ServiceWorker** aServiceWorker);
- 
-+  NS_IMETHOD
-+  CreateServiceWorkerForDocument(nsIDocument* aDoc,
-+                                 const nsACString& aScriptSpec,
-+                                 const nsACString& aScope,
-+                                 ServiceWorker** aServiceWorker);
-+
-+  bool
-+  FindPossibleController(ServiceWorkerDomainInfo* aDomainInfo, nsIURI* aURI,
-+                         ServiceWorkerRegistration** aInfo);
-+
-+  // Finds a candidate to control aDoc. True if found, false on errors or not
-+  // found.
-+  bool
-+  FindPossibleController(nsIDocument* aDoc, ServiceWorkerRegistration** aInfo);
-+
-+  // Used to stop controlling a document.
-+  bool
-+  FindControllingWorkerInfo(nsIDocument* aDoc, ServiceWorkerRegistration** aInfo);
-+
-   static PLDHashOperator
-   CleanupServiceWorkerInformation(const nsACString& aDomain,
-                                   ServiceWorkerDomainInfo* aDomainInfo,
-                                   void *aUnused);
- };
- 
- END_WORKERS_NAMESPACE
-