Backed out changesets bacfdc83424a and 7d12b5d7446f (bug 984048) for crashes.
authorRyan VanderMeulen <ryanvm@gmail.com>
Mon, 30 Jun 2014 17:22:47 -0400
changeset 212393 b969a37d51aa776cbac3d2b87e0e9d77aeb3b039
parent 212392 f74b2c50ea0bc991eb69d7c6390c6986d5cba0d6
child 212394 b409824b125d62257b116ce1b91a6015b1285316
push id3857
push userraliiev@mozilla.com
push dateTue, 02 Sep 2014 16:39:23 +0000
treeherdermozilla-beta@5638b907b505 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs984048
milestone33.0a1
backs outbacfdc83424a680dc34ad10ebe645ec4e101cba1
7d12b5d7446fcae7c64c75d2942998cadae8caa9
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changesets bacfdc83424a and 7d12b5d7446f (bug 984048) for crashes.
dom/promise/Promise.h
dom/promise/PromiseCallback.cpp
dom/workers/RuntimeService.cpp
dom/workers/RuntimeService.h
dom/workers/ServiceWorkerManager.cpp
dom/workers/ServiceWorkerManager.h
dom/workers/WorkerPrivate.cpp
dom/workers/test/serviceworkers/install_event_worker.js
dom/workers/test/serviceworkers/mochitest.ini
dom/workers/test/serviceworkers/parse_error_worker.js
dom/workers/test/serviceworkers/test_install_event.html
dom/workers/test/serviceworkers/test_installation_simple.html
js/src/jsapi-tests/testUncaughtError.cpp
js/src/jsapi.h
js/src/jsexn.cpp
--- a/dom/promise/Promise.h
+++ b/dom/promise/Promise.h
@@ -22,17 +22,16 @@
 
 class nsIGlobalObject;
 
 namespace mozilla {
 namespace dom {
 
 class AnyCallback;
 class DOMError;
-class ErrorEvent;
 class PromiseCallback;
 class PromiseInit;
 class PromiseNativeHandler;
 
 class Promise;
 class PromiseReportRejectFeature : public workers::WorkerFeature
 {
   // The Promise that owns this feature.
@@ -90,20 +89,16 @@ public:
   void MaybeResolve(const T& aArg) {
     MaybeSomething(aArg, &Promise::MaybeResolve);
   }
 
   inline void MaybeReject(nsresult aArg) {
     MOZ_ASSERT(NS_FAILED(aArg));
     MaybeSomething(aArg, &Promise::MaybeReject);
   }
-
-  inline void MaybeReject(ErrorEvent* aArg) {
-    MaybeSomething(aArg, &Promise::MaybeReject);
-  }
   // DO NOT USE MaybeRejectBrokenly with in new code.  Promises should be
   // rejected with Error instances.
   // Note: MaybeRejectBrokenly is a template so we can use it with DOMError
   // without instantiating the DOMError specialization of MaybeSomething in
   // every translation unit that includes this header, because that would
   // require use to include DOMError.h either here or in all those translation
   // units.
   template<typename T>
--- a/dom/promise/PromiseCallback.cpp
+++ b/dom/promise/PromiseCallback.cpp
@@ -273,18 +273,18 @@ WrapperPromiseCallback::Call(JSContext* 
           "then() cannot return same Promise that it resolves."));
       if (!message) {
         // Out of memory. Promise will stay unresolved.
         JS_ClearPendingException(aCx);
         return;
       }
 
       JS::Rooted<JS::Value> typeError(aCx);
-      if (!JS::CreateError(aCx, JSEXN_TYPEERR, stack, fn, lineNumber, 0,
-                           nullptr, message, &typeError)) {
+      if (!JS::CreateTypeError(aCx, stack, fn, lineNumber, 0,
+                               nullptr, message, &typeError)) {
         // Out of memory. Promise will stay unresolved.
         JS_ClearPendingException(aCx);
         return;
       }
 
       mNextPromise->RejectInternal(aCx, typeError, Promise::SyncTask);
       return;
     }
--- a/dom/workers/RuntimeService.cpp
+++ b/dom/workers/RuntimeService.cpp
@@ -2171,43 +2171,16 @@ RuntimeService::CreateServiceWorker(cons
   serviceWorker->mURL = aScriptURL;
   serviceWorker->mScope = NS_ConvertUTF8toUTF16(aScope);
 
   serviceWorker.forget(aServiceWorker);
   return rv;
 }
 
 nsresult
-RuntimeService::CreateServiceWorkerFromLoadInfo(JSContext* aCx,
-                                               WorkerPrivate::LoadInfo aLoadInfo,
-                                               const nsAString& aScriptURL,
-                                               const nsACString& aScope,
-                                               ServiceWorker** aServiceWorker)
-{
-
-  nsRefPtr<SharedWorker> sharedWorker;
-  nsresult rv = CreateSharedWorkerFromLoadInfo(aCx, aLoadInfo, aScriptURL, aScope,
-                                               WorkerTypeService,
-                                               getter_AddRefs(sharedWorker));
-
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    return rv;
-  }
-
-  nsRefPtr<ServiceWorker> serviceWorker =
-    new ServiceWorker(nullptr, sharedWorker);
-
-  serviceWorker->mURL = aScriptURL;
-  serviceWorker->mScope = NS_ConvertUTF8toUTF16(aScope);
-
-  serviceWorker.forget(aServiceWorker);
-  return rv;
-}
-
-nsresult
 RuntimeService::CreateSharedWorkerInternal(const GlobalObject& aGlobal,
                                            const nsAString& aScriptURL,
                                            const nsACString& aName,
                                            WorkerType aType,
                                            SharedWorker** aSharedWorker)
 {
   AssertIsOnMainThread();
   MOZ_ASSERT(aType == WorkerTypeShared || aType == WorkerTypeService);
@@ -2217,68 +2190,53 @@ RuntimeService::CreateSharedWorkerIntern
 
   JSContext* cx = aGlobal.Context();
 
   WorkerPrivate::LoadInfo loadInfo;
   nsresult rv = WorkerPrivate::GetLoadInfo(cx, window, nullptr, aScriptURL,
                                            false, &loadInfo);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  return CreateSharedWorkerFromLoadInfo(cx, loadInfo, aScriptURL, aName, aType,
-                                        aSharedWorker);
-}
-
-nsresult
-RuntimeService::CreateSharedWorkerFromLoadInfo(JSContext* aCx,
-                                               WorkerPrivate::LoadInfo aLoadInfo,
-                                               const nsAString& aScriptURL,
-                                               const nsACString& aName,
-                                               WorkerType aType,
-                                               SharedWorker** aSharedWorker)
-{
-  AssertIsOnMainThread();
-
-  MOZ_ASSERT(aLoadInfo.mResolvedScriptURI);
+  MOZ_ASSERT(loadInfo.mResolvedScriptURI);
+
+  nsCString scriptSpec;
+  rv = loadInfo.mResolvedScriptURI->GetSpec(scriptSpec);
+  NS_ENSURE_SUCCESS(rv, rv);
 
   nsRefPtr<WorkerPrivate> workerPrivate;
   {
     MutexAutoLock lock(mMutex);
 
     WorkerDomainInfo* domainInfo;
     SharedWorkerInfo* sharedWorkerInfo;
 
-    nsCString scriptSpec;
-    nsresult rv = aLoadInfo.mResolvedScriptURI->GetSpec(scriptSpec);
-    NS_ENSURE_SUCCESS(rv, rv);
-
     nsAutoCString key;
     GenerateSharedWorkerKey(scriptSpec, aName, key);
 
-    if (mDomainMap.Get(aLoadInfo.mDomain, &domainInfo) &&
+    if (mDomainMap.Get(loadInfo.mDomain, &domainInfo) &&
         domainInfo->mSharedWorkerInfos.Get(key, &sharedWorkerInfo)) {
       workerPrivate = sharedWorkerInfo->mWorkerPrivate;
     }
   }
 
   bool created = false;
 
   if (!workerPrivate) {
     ErrorResult rv;
     workerPrivate =
-      WorkerPrivate::Constructor(aCx, aScriptURL, false,
-                                 aType, aName, &aLoadInfo, rv);
+      WorkerPrivate::Constructor(aGlobal, aScriptURL, false,
+                                 aType, aName, &loadInfo, rv);
     NS_ENSURE_TRUE(workerPrivate, rv.ErrorCode());
 
     created = true;
   }
 
-  nsCOMPtr<nsPIDOMWindow> window = aLoadInfo.mWindow;
   nsRefPtr<SharedWorker> sharedWorker = new SharedWorker(window, workerPrivate);
 
-  if (!workerPrivate->RegisterSharedWorker(aCx, sharedWorker)) {
+  if (!workerPrivate->RegisterSharedWorker(cx, sharedWorker)) {
     NS_WARNING("Worker is unreachable, this shouldn't happen!");
     sharedWorker->Close();
     return NS_ERROR_FAILURE;
   }
 
   // This is normally handled in RegisterWorker, but that wasn't called if the
   // worker already existed.
   if (!created) {
--- a/dom/workers/RuntimeService.h
+++ b/dom/workers/RuntimeService.h
@@ -12,17 +12,16 @@
 
 #include "nsIObserver.h"
 
 #include "mozilla/TimeStamp.h"
 #include "mozilla/dom/BindingDeclarations.h"
 #include "nsClassHashtable.h"
 #include "nsHashKeys.h"
 #include "nsTArray.h"
-#include "WorkerPrivate.h"
 
 class nsIRunnable;
 class nsIThread;
 class nsITimer;
 class nsPIDOMWindow;
 
 BEGIN_WORKERS_NAMESPACE
 
@@ -154,23 +153,16 @@ public:
   }
 
   nsresult
   CreateServiceWorker(const GlobalObject& aGlobal,
                       const nsAString& aScriptURL,
                       const nsACString& aScope,
                       ServiceWorker** aServiceWorker);
 
-  nsresult
-  CreateServiceWorkerFromLoadInfo(JSContext* aCx,
-                                  WorkerPrivate::LoadInfo aLoadInfo,
-                                  const nsAString& aScriptURL,
-                                  const nsACString& aScope,
-                                  ServiceWorker** aServiceWorker);
-
   void
   ForgetSharedWorker(WorkerPrivate* aWorkerPrivate);
 
   const NavigatorProperties&
   GetNavigatorProperties() const
   {
     return mNavigatorProperties;
   }
@@ -299,21 +291,13 @@ private:
   JSVersionChanged(const char* aPrefName, void* aClosure);
 
   nsresult
   CreateSharedWorkerInternal(const GlobalObject& aGlobal,
                              const nsAString& aScriptURL,
                              const nsACString& aName,
                              WorkerType aType,
                              SharedWorker** aSharedWorker);
-
-  nsresult
-  CreateSharedWorkerFromLoadInfo(JSContext* aCx,
-                                 WorkerPrivate::LoadInfo aLoadInfo,
-                                 const nsAString& aScriptURL,
-                                 const nsACString& aName,
-                                 WorkerType aType,
-                                 SharedWorker** aSharedWorker);
 };
 
 END_WORKERS_NAMESPACE
 
 #endif /* mozilla_dom_workers_runtimeservice_h__ */
--- a/dom/workers/ServiceWorkerManager.cpp
+++ b/dom/workers/ServiceWorkerManager.cpp
@@ -1,40 +1,34 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "ServiceWorkerManager.h"
 
 #include "nsIDocument.h"
-#include "nsIScriptSecurityManager.h"
 #include "nsPIDOMWindow.h"
 
 #include "jsapi.h"
 
 #include "mozilla/Preferences.h"
 #include "mozilla/dom/BindingUtils.h"
 #include "mozilla/dom/DOMError.h"
-#include "mozilla/dom/ErrorEvent.h"
-#include "mozilla/dom/InstallEventBinding.h"
-#include "mozilla/dom/PromiseNativeHandler.h"
 
 #include "nsContentUtils.h"
 #include "nsCxPusher.h"
 #include "nsNetUtil.h"
 #include "nsProxyRelease.h"
 #include "nsTArray.h"
 
 #include "RuntimeService.h"
 #include "ServiceWorker.h"
-#include "ServiceWorkerEvents.h"
 #include "WorkerInlines.h"
 #include "WorkerPrivate.h"
 #include "WorkerRunnable.h"
-#include "WorkerScope.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 BEGIN_WORKERS_NAMESPACE
 
 NS_IMPL_ISUPPORTS0(ServiceWorkerRegistration)
 
@@ -113,59 +107,16 @@ UpdatePromise::RejectAllPromises(nsresul
         do_QueryInterface(pendingPromise->GetParentObject());
       MOZ_ASSERT(window);
       nsRefPtr<DOMError> domError = new DOMError(window, aRv);
       pendingPromise->MaybeRejectBrokenly(domError);
     }
   }
 }
 
-void
-UpdatePromise::RejectAllPromises(const ErrorEventInit& aErrorDesc)
-{
-  MOZ_ASSERT(mState == Pending);
-  mState = Rejected;
-
-  nsTArray<nsTWeakRef<Promise>> array;
-  array.SwapElements(mPromises);
-  for (uint32_t i = 0; i < array.Length(); ++i) {
-    nsTWeakRef<Promise>& pendingPromise = array.ElementAt(i);
-    if (pendingPromise) {
-      // Since ServiceWorkerContainer is only exposed to windows we can be
-      // certain about this cast.
-      nsCOMPtr<nsIGlobalObject> go = do_QueryInterface(pendingPromise->GetParentObject());
-      MOZ_ASSERT(go);
-
-      AutoJSAPI jsapi;
-      jsapi.Init(go);
-
-      JSContext* cx = jsapi.cx();
-
-      JS::Rooted<JSString*> stack(cx, JS_GetEmptyString(JS_GetRuntime(cx)));
-
-      JS::Rooted<JS::Value> fnval(cx);
-      ToJSValue(cx, aErrorDesc.mFilename, &fnval);
-      JS::Rooted<JSString*> fn(cx, fnval.toString());
-
-      JS::Rooted<JS::Value> msgval(cx);
-      ToJSValue(cx, aErrorDesc.mMessage, &msgval);
-      JS::Rooted<JSString*> msg(cx, msgval.toString());
-
-      JS::Rooted<JS::Value> error(cx);
-      if (!JS::CreateError(cx, JSEXN_ERR, stack, fn, aErrorDesc.mLineno,
-                           aErrorDesc.mColno, nullptr, msg, &error)) {
-        pendingPromise->MaybeReject(NS_ERROR_FAILURE);
-        continue;
-      }
-
-      pendingPromise->MaybeReject(cx, error);
-    }
-  }
-}
-
 class FinishFetchOnMainThreadRunnable : public nsRunnable
 {
   nsMainThreadPtrHandle<ServiceWorkerUpdateInstance> mUpdateInstance;
 public:
   FinishFetchOnMainThreadRunnable
     (const nsMainThreadPtrHandle<ServiceWorkerUpdateInstance>& aUpdateInstance)
     : mUpdateInstance(aUpdateInstance)
   { }
@@ -222,22 +173,16 @@ public:
       // Capture the current script spec in case register() gets called.
       mScriptSpec(aRegistration->mScriptSpec),
       mWindow(aWindow),
       mAborted(false)
   {
     AssertIsOnMainThread();
   }
 
-  const nsCString&
-  GetScriptSpec() const
-  {
-    return mScriptSpec;
-  }
-
   void
   Abort()
   {
     MOZ_ASSERT(!mAborted);
     mAborted = true;
   }
 
   void
@@ -525,26 +470,16 @@ ServiceWorkerManager::RejectUpdatePromis
                                                    nsresult aRv)
 {
   AssertIsOnMainThread();
   MOZ_ASSERT(aRegistration->HasUpdatePromise());
   aRegistration->mUpdatePromise->RejectAllPromises(aRv);
   aRegistration->mUpdatePromise = nullptr;
 }
 
-void
-ServiceWorkerManager::RejectUpdatePromiseObservers(ServiceWorkerRegistration* aRegistration,
-                                                   const ErrorEventInit& aErrorDesc)
-{
-  AssertIsOnMainThread();
-  MOZ_ASSERT(aRegistration->HasUpdatePromise());
-  aRegistration->mUpdatePromise->RejectAllPromises(aErrorDesc);
-  aRegistration->mUpdatePromise = nullptr;
-}
-
 /*
  * Update() does not return the Promise that the spec says it should. Callers
  * may access the registration's (new) Promise after calling this method.
  */
 NS_IMETHODIMP
 ServiceWorkerManager::Update(ServiceWorkerRegistration* aRegistration,
                              nsPIDOMWindow* aWindow)
 {
@@ -650,311 +585,20 @@ ServiceWorkerManager::FinishFetch(Servic
 
   ResolveRegisterPromises(aRegistration, aRegistration->mScriptSpec);
 
   ServiceWorkerInfo info(aRegistration->mScriptSpec);
   Install(aRegistration, info);
 }
 
 void
-ServiceWorkerManager::HandleError(JSContext* aCx,
-                                  const nsACString& aScope,
-                                  const nsAString& aWorkerURL,
-                                  nsString aMessage,
-                                  nsString aFilename,
-                                  nsString aLine,
-                                  uint32_t aLineNumber,
-                                  uint32_t aColumnNumber,
-                                  uint32_t aFlags)
-{
-  AssertIsOnMainThread();
-
-  nsCOMPtr<nsIURI> uri;
-  nsresult rv = NS_NewURI(getter_AddRefs(uri), aScope, nullptr, nullptr);
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    return;
-  }
-
-  nsCString domain;
-  rv = uri->GetHost(domain);
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    return;
-  }
-
-  ServiceWorkerDomainInfo* domainInfo;
-  if (!mDomainMap.Get(domain, &domainInfo)) {
-    return;
-  }
-
-  nsCString scope;
-  scope.Assign(aScope);
-  nsRefPtr<ServiceWorkerRegistration> registration = domainInfo->GetRegistration(scope);
-  MOZ_ASSERT(registration);
-
-  ErrorEventInit init;
-  init.mMessage = aMessage;
-  init.mFilename = aFilename;
-  init.mLineno = aLineNumber;
-  init.mColno = aColumnNumber;
-
-  // If the worker was the one undergoing registration, we reject the promises,
-  // otherwise we fire events on the ServiceWorker instances.
-
-  // If there is an update in progress and the worker that errored is the same one
-  // that is being updated, it is a sufficient test for 'this worker is being
-  // registered'.
-  // FIXME(nsm): Except the case where an update is found for a worker, in
-  // which case we'll need some other association than simply the URL.
-  if (registration->mUpdateInstance &&
-      registration->mUpdateInstance->GetScriptSpec().Equals(NS_ConvertUTF16toUTF8(aWorkerURL))) {
-    RejectUpdatePromiseObservers(registration, init);
-    // We don't need to abort here since the worker has already run.
-    registration->mUpdateInstance = nullptr;
-  } else {
-    // FIXME(nsm): Bug 983497 Fire 'error' on ServiceWorkerContainers.
-  }
-}
-
-class FinishInstallRunnable MOZ_FINAL : public nsRunnable
-{
-  nsMainThreadPtrHandle<ServiceWorkerRegistration> mRegistration;
-
-public:
-  explicit FinishInstallRunnable(
-    const nsMainThreadPtrHandle<ServiceWorkerRegistration>& aRegistration)
-    : mRegistration(aRegistration)
-  {
-    MOZ_ASSERT(!NS_IsMainThread());
-  }
-
-  NS_IMETHOD
-  Run() MOZ_OVERRIDE
-  {
-    AssertIsOnMainThread();
-
-    nsRefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
-    swm->FinishInstall(mRegistration.get());
-    return NS_OK;
-  }
-};
-
-class CancelServiceWorkerInstallationRunnable MOZ_FINAL : public nsRunnable
-{
-  nsMainThreadPtrHandle<ServiceWorkerRegistration> mRegistration;
-
-public:
-  explicit CancelServiceWorkerInstallationRunnable(
-    const nsMainThreadPtrHandle<ServiceWorkerRegistration>& aRegistration)
-    : mRegistration(aRegistration)
-  {
-  }
-
-  NS_IMETHOD
-  Run() MOZ_OVERRIDE
-  {
-    AssertIsOnMainThread();
-    // FIXME(nsm): Change installing worker state to redundant.
-    // FIXME(nsm): Fire statechange.
-    mRegistration->mInstallingWorker.Invalidate();
-    return NS_OK;
-  }
-};
-
-/*
- * Used to handle InstallEvent::waitUntil() and proceed with installation.
- */
-class FinishInstallHandler MOZ_FINAL : public PromiseNativeHandler
-{
-  nsMainThreadPtrHandle<ServiceWorkerRegistration> mRegistration;
-
-  virtual
-  ~FinishInstallHandler()
-  { }
-
-public:
-  explicit FinishInstallHandler(
-    const nsMainThreadPtrHandle<ServiceWorkerRegistration>& aRegistration)
-    : mRegistration(aRegistration)
-  {
-    MOZ_ASSERT(!NS_IsMainThread());
-  }
-
-  void
-  ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) MOZ_OVERRIDE
-  {
-    WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
-    MOZ_ASSERT(workerPrivate);
-    workerPrivate->AssertIsOnWorkerThread();
-
-    nsRefPtr<FinishInstallRunnable> r = new FinishInstallRunnable(mRegistration);
-    NS_DispatchToMainThread(r);
-  }
-
-  void
-  RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) MOZ_OVERRIDE
-  {
-    nsRefPtr<CancelServiceWorkerInstallationRunnable> r =
-      new CancelServiceWorkerInstallationRunnable(mRegistration);
-    NS_DispatchToMainThread(r);
-  }
-};
-
-/*
- * Fires 'install' event on the ServiceWorkerGlobalScope. Modifies busy count
- * since it fires the event. This is ok since there can't be nested
- * ServiceWorkers, so the parent thread -> worker thread requirement for
- * runnables is satisfied.
- */
-class InstallEventRunnable MOZ_FINAL : public WorkerRunnable
-{
-  nsMainThreadPtrHandle<ServiceWorkerRegistration> mRegistration;
-  nsCString mScope;
-
-public:
-  InstallEventRunnable(
-    WorkerPrivate* aWorkerPrivate,
-    const nsMainThreadPtrHandle<ServiceWorkerRegistration>& aRegistration)
-      : WorkerRunnable(aWorkerPrivate, WorkerThreadModifyBusyCount),
-        mRegistration(aRegistration),
-        mScope(aRegistration.get()->mScope) // copied for access on worker thread.
-  {
-    AssertIsOnMainThread();
-    MOZ_ASSERT(aWorkerPrivate);
-  }
-
-  bool
-  WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate)
-  {
-    MOZ_ASSERT(aWorkerPrivate);
-    return DispatchInstallEvent(aCx, aWorkerPrivate);
-  }
-
-private:
-  bool
-  DispatchInstallEvent(JSContext* aCx, WorkerPrivate* aWorkerPrivate)
-  {
-    aWorkerPrivate->AssertIsOnWorkerThread();
-    MOZ_ASSERT(aWorkerPrivate->IsServiceWorker());
-    InstallEventInit init;
-    init.mBubbles = false;
-    init.mCancelable = true;
-
-    // FIXME(nsm): Bug 982787 pass previous active worker.
-
-    nsRefPtr<EventTarget> target = aWorkerPrivate->GlobalScope();
-    nsRefPtr<InstallEvent> event =
-      InstallEvent::Constructor(target, NS_LITERAL_STRING("install"), init);
-
-    event->SetTrusted(true);
-
-    nsRefPtr<Promise> waitUntilPromise;
-
-    nsresult rv = target->DispatchDOMEvent(nullptr, event, nullptr, nullptr);
-
-    nsCOMPtr<nsIGlobalObject> sgo = aWorkerPrivate->GlobalScope();
-    if (NS_SUCCEEDED(rv)) {
-      waitUntilPromise = event->GetPromise();
-      if (!waitUntilPromise) {
-        ErrorResult rv;
-        waitUntilPromise =
-          Promise::Resolve(sgo,
-                           aCx, JS::UndefinedHandleValue, rv);
-      }
-    } else {
-      ErrorResult rv;
-      // Continue with a canceled install.
-      waitUntilPromise = Promise::Reject(sgo, aCx,
-                                         JS::UndefinedHandleValue, rv);
-    }
-
-    nsRefPtr<FinishInstallHandler> handler =
-      new FinishInstallHandler(mRegistration);
-    waitUntilPromise->AppendNativeHandler(handler);
-    return true;
-  }
-};
-
-void
 ServiceWorkerManager::Install(ServiceWorkerRegistration* aRegistration,
                               ServiceWorkerInfo aServiceWorkerInfo)
 {
-  AssertIsOnMainThread();
-  aRegistration->mInstallingWorker = aServiceWorkerInfo;
-
-  nsMainThreadPtrHandle<ServiceWorkerRegistration> handle =
-    new nsMainThreadPtrHolder<ServiceWorkerRegistration>(aRegistration);
-
-  nsRefPtr<ServiceWorker> serviceWorker;
-  nsresult rv =
-    CreateServiceWorker(aServiceWorkerInfo.GetScriptSpec(),
-                        aRegistration->mScope,
-                        getter_AddRefs(serviceWorker));
-
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    aRegistration->mInstallingWorker.Invalidate();
-    return;
-  }
-
-  nsRefPtr<InstallEventRunnable> r =
-    new InstallEventRunnable(serviceWorker->GetWorkerPrivate(), handle);
-
-  AutoSafeJSContext cx;
-  r->Dispatch(cx);
-
-  // When this function exits, although we've lost references to the ServiceWorker,
-  // which means the underlying WorkerPrivate has no references, the worker
-  // will stay alive due to the modified busy count until the install event has
-  // been dispatched.
-  // NOTE: The worker spec does not require Promises to keep a worker alive, so
-  // the waitUntil() construct by itself will not keep a worker alive beyond
-  // the event dispatch. On the other hand, networking, IDB and so on do keep
-  // the worker alive, so the waitUntil() is only relevant if the Promise is
-  // gated on those actions. I (nsm) am not sure if it is worth requiring
-  // a special spec mention saying the install event should keep the worker
-  // alive indefinitely purely on the basis of calling waitUntil(), since
-  // a wait is likely to be required only when performing networking or storage
-  // transactions in the first place.
-
-  // FIXME(nsm): Bug 983497. Fire "updatefound" on ServiceWorkerContainers.
-}
-
-class ActivationRunnable : public nsRunnable
-{
-public:
-  explicit ActivationRunnable(ServiceWorkerRegistration* aRegistration)
-  { }
-};
-
-void
-ServiceWorkerManager::FinishInstall(ServiceWorkerRegistration* aRegistration)
-{
-  AssertIsOnMainThread();
-
-  if (aRegistration->mWaitingWorker.IsValid()) {
-    // FIXME(nsm): Actually update the state of active ServiceWorker instances.
-  }
-
-  aRegistration->mWaitingWorker = aRegistration->mInstallingWorker;
-  aRegistration->mInstallingWorker.Invalidate();
-
-  // FIXME(nsm): Actually update state of active ServiceWorker instances to
-  // installed.
-  // FIXME(nsm): Fire statechange on the instances.
-
-  // FIXME(nsm): Handle replace().
-
-  // FIXME(nsm): Check that no document is using the registration!
-
-  nsRefPtr<ActivationRunnable> r =
-    new ActivationRunnable(aRegistration);
-
-  nsresult rv = NS_DispatchToMainThread(r);
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    // FIXME(nsm): Handle error.
-  }
+  // FIXME(nsm): Same bug, different patch.
 }
 
 NS_IMETHODIMP
 ServiceWorkerManager::CreateServiceWorkerForWindow(nsPIDOMWindow* aWindow,
                                                    const nsACString& aScriptSpec,
                                                    const nsACString& aScope,
                                                    ServiceWorker** aServiceWorker)
 {
@@ -979,57 +623,9 @@ ServiceWorkerManager::CreateServiceWorke
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   serviceWorker.forget(aServiceWorker);
   return rv;
 }
 
-NS_IMETHODIMP
-ServiceWorkerManager::CreateServiceWorker(const nsACString& aScriptSpec,
-                                          const nsACString& aScope,
-                                          ServiceWorker** aServiceWorker)
-{
-  AssertIsOnMainThread();
-
-  WorkerPrivate::LoadInfo info;
-  nsresult rv = NS_NewURI(getter_AddRefs(info.mBaseURI), aScriptSpec, nullptr, nullptr);
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    return rv;
-  }
-
-  info.mResolvedScriptURI = info.mBaseURI;
-
-  rv = info.mBaseURI->GetHost(info.mDomain);
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    return rv;
-  }
-
-  // FIXME(nsm): Create correct principal based on app-ness.
-  // Would it make sense to store the nsIPrincipal of the first register() in
-  // the ServiceWorkerRegistration and use that?
-  nsIScriptSecurityManager* ssm = nsContentUtils::GetSecurityManager();
-  rv = ssm->GetNoAppCodebasePrincipal(info.mBaseURI, getter_AddRefs(info.mPrincipal));
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    return rv;
-  }
-
-  AutoSafeJSContext cx;
-
-  nsRefPtr<ServiceWorker> serviceWorker;
-  RuntimeService* rs = RuntimeService::GetService();
-  if (!rs) {
-    return NS_ERROR_FAILURE;
-  }
-
-  rv = rs->CreateServiceWorkerFromLoadInfo(cx, info, NS_ConvertUTF8toUTF16(aScriptSpec), aScope,
-                                           getter_AddRefs(serviceWorker));
-
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    return rv;
-  }
-
-  serviceWorker.forget(aServiceWorker);
-  return NS_OK;
-}
-
 END_WORKERS_NAMESPACE
--- a/dom/workers/ServiceWorkerManager.h
+++ b/dom/workers/ServiceWorkerManager.h
@@ -13,24 +13,21 @@
 #include "mozilla/dom/BindingUtils.h"
 #include "mozilla/dom/Promise.h"
 #include "nsClassHashtable.h"
 #include "nsDataHashtable.h"
 #include "nsRefPtrHashtable.h"
 #include "nsTArrayForwardDeclare.h"
 #include "nsTWeakRef.h"
 
-class nsIScriptError;
-
 namespace mozilla {
 namespace dom {
 namespace workers {
 
 class ServiceWorker;
-class ServiceWorkerContainer;
 class ServiceWorkerUpdateInstance;
 
 /**
  * UpdatePromise is a utility class that sort of imitates Promise, but not
  * completely. Using DOM Promise from C++ is a pain when we know the precise types
  * we're dealing with since it involves dealing with JSAPI. In this case we
  * also don't (yet) need the 'thenables added after resolution should trigger
  * immediately' support and other things like that. All we want is something
@@ -41,17 +38,16 @@ class UpdatePromise MOZ_FINAL
 {
 public:
   UpdatePromise();
   ~UpdatePromise();
 
   void AddPromise(Promise* aPromise);
   void ResolveAllPromises(const nsACString& aScriptSpec, const nsACString& aScope);
   void RejectAllPromises(nsresult aRv);
-  void RejectAllPromises(const ErrorEventInit& aErrorDesc);
 
   bool
   IsRejected() const
   {
     return mState == Rejected;
   }
 
 private:
@@ -230,62 +226,39 @@ public:
   ResolveRegisterPromises(ServiceWorkerRegistration* aRegistration,
                           const nsACString& aWorkerScriptSpec);
 
   void
   RejectUpdatePromiseObservers(ServiceWorkerRegistration* aRegistration,
                                nsresult aResult);
 
   void
-  RejectUpdatePromiseObservers(ServiceWorkerRegistration* aRegistration,
-                               const ErrorEventInit& aErrorDesc);
-
-  void
   FinishFetch(ServiceWorkerRegistration* aRegistration,
               nsPIDOMWindow* aWindow);
 
-  void
-  FinishInstall(ServiceWorkerRegistration* aRegistration);
-
-  void
-  HandleError(JSContext* aCx,
-              const nsACString& aScope,
-              const nsAString& aWorkerURL,
-              nsString aMessage,
-              nsString aFilename,
-              nsString aLine,
-              uint32_t aLineNumber,
-              uint32_t aColumnNumber,
-              uint32_t aFlags);
-
   static already_AddRefed<ServiceWorkerManager>
   GetInstance();
 
 private:
   ServiceWorkerManager();
   ~ServiceWorkerManager();
 
   NS_IMETHOD
   Update(ServiceWorkerRegistration* aRegistration, nsPIDOMWindow* aWindow);
 
   void
   Install(ServiceWorkerRegistration* aRegistration,
           ServiceWorkerInfo aServiceWorkerInfo);
 
-  NS_IMETHOD
+  NS_IMETHODIMP
   CreateServiceWorkerForWindow(nsPIDOMWindow* aWindow,
                                const nsACString& aScriptSpec,
                                const nsACString& aScope,
                                ServiceWorker** aServiceWorker);
 
-  NS_IMETHOD
-  CreateServiceWorker(const nsACString& aScriptSpec,
-                      const nsACString& aScope,
-                      ServiceWorker** aServiceWorker);
-
   static PLDHashOperator
   CleanupServiceWorkerInformation(const nsACString& aDomain,
                                   ServiceWorkerDomainInfo* aDomainInfo,
                                   void *aUnused);
 };
 
 NS_DEFINE_STATIC_IID_ACCESSOR(ServiceWorkerManager,
                               NS_SERVICEWORKERMANAGER_IMPL_IID);
--- a/dom/workers/WorkerPrivate.cpp
+++ b/dom/workers/WorkerPrivate.cpp
@@ -72,17 +72,16 @@
 #endif
 
 #include "File.h"
 #include "MessagePort.h"
 #include "Navigator.h"
 #include "Principal.h"
 #include "RuntimeService.h"
 #include "ScriptLoader.h"
-#include "ServiceWorkerManager.h"
 #include "SharedWorker.h"
 #include "WorkerFeature.h"
 #include "WorkerRunnable.h"
 #include "WorkerScope.h"
 
 // JS_MaybeGC will run once every second during normal execution.
 #define PERIODIC_GC_TIMER_DELAY_SEC 1
 
@@ -1318,25 +1317,17 @@ private:
     else {
       AssertIsOnMainThread();
 
       if (aWorkerPrivate->IsSuspended()) {
         aWorkerPrivate->QueueRunnable(this);
         return true;
       }
 
-      if (aWorkerPrivate->IsServiceWorker()) {
-        nsRefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
-        MOZ_ASSERT(swm);
-        swm->HandleError(aCx, aWorkerPrivate->SharedWorkerName(),
-                         aWorkerPrivate->ScriptURL(),
-                         mMessage,
-                         mFilename, mLine, mLineNumber, mColumnNumber, mFlags);
-        return true;
-      } else if (aWorkerPrivate->IsSharedWorker()) {
+      if (aWorkerPrivate->IsSharedWorker() || aWorkerPrivate->IsServiceWorker()) {
         aWorkerPrivate->BroadcastErrorToSharedWorkers(aCx, mMessage, mFilename,
                                                       mLine, mLineNumber,
                                                       mColumnNumber, mFlags);
         return true;
       }
 
       aWorkerPrivate->AssertInnerWindowIsCorrect();
 
deleted file mode 100644
--- a/dom/workers/test/serviceworkers/install_event_worker.js
+++ /dev/null
@@ -1,4 +0,0 @@
-oninstall = function(e) {
-  dump("NSM Got install event\n");
-  dump(e.activeWorker);
-}
--- a/dom/workers/test/serviceworkers/mochitest.ini
+++ b/dom/workers/test/serviceworkers/mochitest.ini
@@ -1,11 +1,8 @@
 [DEFAULT]
 support-files =
   worker.js
   worker2.js
   worker3.js
-  parse_error_worker.js
-  install_event_worker.js
 
 [test_installation_simple.html]
-[test_install_event.html]
 [test_navigator.html]
deleted file mode 100644
--- a/dom/workers/test/serviceworkers/parse_error_worker.js
+++ /dev/null
@@ -1,2 +0,0 @@
-// intentional parse error.
-var foo = {;
deleted file mode 100644
--- a/dom/workers/test/serviceworkers/test_install_event.html
+++ /dev/null
@@ -1,49 +0,0 @@
-<!--
-  Any copyright is dedicated to the Public Domain.
-  http://creativecommons.org/publicdomain/zero/1.0/
--->
-<!DOCTYPE HTML>
-<html>
-<head>
-  <title>Bug 94048 - test install event.</title>
-  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
-</head>
-<body>
-<p id="display"></p>
-<div id="content" style="display: none"></div>
-<pre id="test"></pre>
-<script class="testbody" type="text/javascript">
-
-  function simpleRegister() {
-    var p = navigator.serviceWorker.register("worker.js");
-    return p;
-  }
-
-  function nextRegister() {
-    var p = navigator.serviceWorker.register("install_event_worker.js");
-    todo(false, "Check for onupdatefound event");
-    return p;
-  }
-
-  function runTest() {
-    simpleRegister()
-      .then(nextRegister)
-      .then(function() {
-        SimpleTest.finish();
-      }).catch(function(e) {
-        ok(false, "Some test failed with error " + e);
-        SimpleTest.finish();
-      });
-  }
-
-  SimpleTest.waitForExplicitFinish();
-  SpecialPowers.pushPrefEnv({"set": [
-    ["dom.serviceWorkers.enabled", true],
-    ["dom.serviceWorkers.testing.enabled", true]
-  ]}, runTest);
-</script>
-</pre>
-</body>
-</html>
-
--- a/dom/workers/test/serviceworkers/test_installation_simple.html
+++ b/dom/workers/test/serviceworkers/test_installation_simple.html
@@ -58,18 +58,18 @@
   function realWorker() {
     var p = navigator.serviceWorker.register("worker.js");
     return p.then(function(w) {
       ok(w instanceof ServiceWorker, "Register a ServiceWorker");
       info(w.scope);
       ok(w.scope == (new URL("/*", document.baseURI)).href, "Scope should match");
       ok(w.url == (new URL("worker.js", document.baseURI)).href, "URL should be of the worker");
     }, function(e) {
-      info("Error: " + e.name);
-      ok(false, "realWorker Registration should have succeeded!");
+      info(e.name);
+      ok(false, "Registration should have succeeded!");
     });
   }
 
   function abortPrevious() {
     var p = navigator.serviceWorker.register("worker2.js", { scope: "foo/*" });
     var q = navigator.serviceWorker.register("worker3.js", { scope: "foo/*" });
 
     return Promise.all([
@@ -90,37 +90,25 @@
   function networkError404() {
     return navigator.serviceWorker.register("404.js").then(function(w) {
         todo(false, "Should fail with NetworkError");
       }, function(e) {
         todo(e.name === "NetworkError", "Should fail with NetworkError");
       });
   }
 
-  function parseError() {
-    var p = navigator.serviceWorker.register("parse_error_worker.js");
-    return p.then(function(w) {
-      ok(false, "Registration should fail with parse error");
-    }, function(e) {
-    info("NSM " + e.name);
-      ok(e instanceof Error, "Registration should fail with parse error");
-    });
-  }
-
-  // FIXME(nsm): test for parse error when Update step doesn't happen (directly from register).
-
   function runTest() {
     simpleRegister()
       .then(sameOriginWorker)
       .then(sameOriginScope)
       .then(httpsOnly)
       .then(realWorker)
       .then(abortPrevious)
-      .then(networkError404)
-      .then(parseError)
+      // FIXME(nsm): Uncomment once we have the error trapping patch from Bug 984048.
+      // .then(networkError404)
       // put more tests here.
       .then(function() {
         SimpleTest.finish();
       }).catch(function(e) {
         ok(false, "Some test failed with error " + e);
         SimpleTest.finish();
       });
   }
--- a/js/src/jsapi-tests/testUncaughtError.cpp
+++ b/js/src/jsapi-tests/testUncaughtError.cpp
@@ -1,15 +1,15 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "jsapi-tests/tests.h"
 
-using JS::CreateError;
+using JS::CreateTypeError;
 using JS::Rooted;
 using JS::ObjectValue;
 using JS::Value;
 
 static size_t uncaughtCount = 0;
 
 BEGIN_TEST(testUncaughtError)
 {
@@ -17,17 +17,17 @@ BEGIN_TEST(testUncaughtError)
 
     CHECK(uncaughtCount == 0);
 
     Rooted<JSString*> empty(cx, JS_GetEmptyString(JS_GetRuntime(cx)));
     if (!empty)
         return false;
 
     Rooted<Value> err(cx);
-    if (!CreateError(cx, JSEXN_TYPEERR, empty, empty, 0, 0, nullptr, empty, &err))
+    if (!CreateTypeError(cx, empty, empty, 0, 0, nullptr, empty, &err))
         return false;
 
     Rooted<JSObject*> errObj(cx, &err.toObject());
     if (!JS_SetProperty(cx, errObj, "fileName", err))
         return false;
     if (!JS_SetProperty(cx, errObj, "lineNumber", err))
         return false;
     if (!JS_SetProperty(cx, errObj, "columnNumber", err))
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -4601,19 +4601,19 @@ extern JS_PUBLIC_API(JSErrorReporter)
 JS_GetErrorReporter(JSContext *cx);
 
 extern JS_PUBLIC_API(JSErrorReporter)
 JS_SetErrorReporter(JSContext *cx, JSErrorReporter er);
 
 namespace JS {
 
 extern JS_PUBLIC_API(bool)
-CreateError(JSContext *cx, JSExnType type, HandleString stack,
-            HandleString fileName, uint32_t lineNumber, uint32_t columnNumber,
-            JSErrorReport *report, HandleString message, MutableHandleValue rval);
+CreateTypeError(JSContext *cx, HandleString stack, HandleString fileName,
+                uint32_t lineNumber, uint32_t columnNumber, JSErrorReport *report,
+                HandleString message, MutableHandleValue rval);
 
 /************************************************************************/
 
 /*
  * Weak Maps.
  */
 
 extern JS_PUBLIC_API(JSObject *)
--- a/js/src/jsexn.cpp
+++ b/js/src/jsexn.cpp
@@ -910,26 +910,26 @@ js_CopyErrorObject(JSContext *cx, Handle
     JSExnType errorType = err->type();
 
     // Create the Error object.
     return ErrorObject::create(cx, errorType, stack, fileName,
                                lineNumber, columnNumber, &copyReport, message);
 }
 
 JS_PUBLIC_API(bool)
-JS::CreateError(JSContext *cx, JSExnType type, HandleString stack, HandleString fileName,
+JS::CreateTypeError(JSContext *cx, HandleString stack, HandleString fileName,
                     uint32_t lineNumber, uint32_t columnNumber, JSErrorReport *report,
                     HandleString message, MutableHandleValue rval)
 {
     assertSameCompartment(cx, stack, fileName, message);
     js::ScopedJSFreePtr<JSErrorReport> rep;
     if (report)
         rep = CopyErrorReport(cx, report);
 
     RootedObject obj(cx,
-        js::ErrorObject::create(cx, type, stack, fileName,
+        js::ErrorObject::create(cx, JSEXN_TYPEERR, stack, fileName,
                                 lineNumber, columnNumber, &rep, message));
     if (!obj)
         return false;
 
     rval.setObject(*obj);
     return true;
 }