Browse Source

Patches for bug 1432963

Ian Neal 4 months ago
parent
commit
1e74d11a16
37 changed files with 21561 additions and 235 deletions
  1. 18 17
      mozilla-release/patches/1193394-1-60a1.patch
  2. 3 3
      mozilla-release/patches/1252998-01-61a1.patch
  3. 50 0
      mozilla-release/patches/1397152-1-57a1.patch
  4. 35 0
      mozilla-release/patches/1397152-2-57a1.patch
  5. 32 0
      mozilla-release/patches/1402504-fix-58a1.patch
  6. 11 11
      mozilla-release/patches/1403027-63a1.patch
  7. 64 0
      mozilla-release/patches/1421355-5-59a1.patch
  8. 61 0
      mozilla-release/patches/1421355-6-59a1.patch
  9. 483 0
      mozilla-release/patches/1421358-59a1.patch
  10. 3 3
      mozilla-release/patches/1422036-60a1.patch
  11. 233 0
      mozilla-release/patches/1432963-01-60a1.patch
  12. 274 0
      mozilla-release/patches/1432963-02-60a1.patch
  13. 312 0
      mozilla-release/patches/1432963-03-60a1.patch
  14. 220 0
      mozilla-release/patches/1432963-04-60a1.patch
  15. 551 0
      mozilla-release/patches/1432963-05-60a1.patch
  16. 58 0
      mozilla-release/patches/1432963-06-60a1.patch
  17. 380 0
      mozilla-release/patches/1432963-07-60a1.patch
  18. 349 0
      mozilla-release/patches/1432963-08-60a1.patch
  19. 157 0
      mozilla-release/patches/1432963-09-60a1.patch
  20. 333 0
      mozilla-release/patches/1432963-10-60a1.patch
  21. 165 0
      mozilla-release/patches/1432963-11-60a1.patch
  22. 738 0
      mozilla-release/patches/1432963-12-60a1.patch
  23. 2592 0
      mozilla-release/patches/1432963-13-60a1.patch
  24. 5579 0
      mozilla-release/patches/1432963-14-60a1.patch
  25. 1186 0
      mozilla-release/patches/1432963-15-60a1.patch
  26. 2072 0
      mozilla-release/patches/1432963-16-60a1.patch
  27. 2425 0
      mozilla-release/patches/1432963-17-60a1.patch
  28. 2834 0
      mozilla-release/patches/1435174-60a1.patch
  29. 144 0
      mozilla-release/patches/1435197-60a1.patch
  30. 34 34
      mozilla-release/patches/1437554-60a1.patch
  31. 3 3
      mozilla-release/patches/1440816-2-60a1.patch
  32. 2 2
      mozilla-release/patches/1447409-61a1.patch
  33. 12 39
      mozilla-release/patches/1449135-3-61a1.patch
  34. 113 113
      mozilla-release/patches/1465585-3-std-62a1.patch
  35. 7 7
      mozilla-release/patches/1485216-1-66a1.patch
  36. 3 3
      mozilla-release/patches/1575420-70a1.patch
  37. 25 0
      mozilla-release/patches/series

+ 18 - 17
mozilla-release/patches/1193394-1-60a1.patch

@@ -3,7 +3,7 @@
 # Date 1510887687 -28800
 #      Fri Nov 17 11:01:27 2017 +0800
 # Node ID 068c59c7c4ec46802b4a18e98adc227aed6d5da1
-# Parent  c0f0ba194403ffc348b4f7cb79714ae5d85167fd
+# Parent  cad5dd16b5ebfdda65f707ce9ec987367bf5d9b7
 Bug 1193394 - Part 1: Microtasks and promises scheduling. r=bevis
 
 diff --git a/dom/animation/Animation.cpp b/dom/animation/Animation.cpp
@@ -495,7 +495,7 @@ diff --git a/dom/events/EventListenerManager.cpp b/dom/events/EventListenerManag
 diff --git a/dom/indexedDB/ActorsChild.cpp b/dom/indexedDB/ActorsChild.cpp
 --- a/dom/indexedDB/ActorsChild.cpp
 +++ b/dom/indexedDB/ActorsChild.cpp
-@@ -846,32 +846,36 @@ DispatchSuccessEvent(ResultHelper* aResu
+@@ -844,32 +844,36 @@ DispatchSuccessEvent(ResultHelper* aResu
    } else {
      IDB_LOG_MARK("IndexedDB %s: Child  Request[%llu]: Firing %s event",
                   "IndexedDB %s: C R[%llu]: %s",
@@ -563,7 +563,7 @@ diff --git a/dom/indexedDB/IDBFileHandle.cpp b/dom/indexedDB/IDBFileHandle.cpp
 diff --git a/dom/indexedDB/IDBTransaction.cpp b/dom/indexedDB/IDBTransaction.cpp
 --- a/dom/indexedDB/IDBTransaction.cpp
 +++ b/dom/indexedDB/IDBTransaction.cpp
-@@ -189,25 +189,21 @@ IDBTransaction::CreateVersionChange(
+@@ -187,25 +187,21 @@ IDBTransaction::CreateVersionChange(
      new IDBTransaction(aDatabase,
                         emptyObjectStoreNames,
                         VERSION_CHANGE);
@@ -589,7 +589,7 @@ diff --git a/dom/indexedDB/IDBTransaction.cpp b/dom/indexedDB/IDBTransaction.cpp
  }
  
  // static
-@@ -247,17 +243,17 @@ IDBTransaction::Create(JSContext* aCx, I
+@@ -245,17 +241,17 @@ IDBTransaction::Create(JSContext* aCx, I
  #endif
        return nullptr;
      }
@@ -611,7 +611,7 @@ diff --git a/dom/indexedDB/IDBTransaction.cpp b/dom/indexedDB/IDBTransaction.cpp
 diff --git a/dom/promise/Promise.cpp b/dom/promise/Promise.cpp
 --- a/dom/promise/Promise.cpp
 +++ b/dom/promise/Promise.cpp
-@@ -503,136 +503,16 @@ Promise::ReportRejectedPromise(JSContext
+@@ -501,136 +501,16 @@ Promise::ReportRejectedPromise(JSContext
    nsGlobalWindow* win = isMainThread ? xpc::WindowGlobalOrNull(aPromise) : nullptr;
    xpcReport->Init(report.report(), report.toStringResult().c_str(), isChrome,
                    win ? win->AsInner()->WindowID() : 0);
@@ -844,7 +844,7 @@ diff --git a/dom/script/ScriptSettings.h b/dom/script/ScriptSettings.h
 diff --git a/dom/serviceworkers/ServiceWorkerPrivate.cpp b/dom/serviceworkers/ServiceWorkerPrivate.cpp
 --- a/dom/serviceworkers/ServiceWorkerPrivate.cpp
 +++ b/dom/serviceworkers/ServiceWorkerPrivate.cpp
-@@ -327,17 +327,17 @@ public:
+@@ -328,17 +328,17 @@ public:
    }
  
    void
@@ -863,7 +863,7 @@ diff --git a/dom/serviceworkers/ServiceWorkerPrivate.cpp b/dom/serviceworkers/Se
  
      MaybeCleanup();
    }
-@@ -359,16 +359,28 @@ private:
+@@ -360,16 +360,28 @@ private:
      if (mWorkerHolderAdded) {
        ReleaseWorker();
      }
@@ -892,7 +892,7 @@ diff --git a/dom/serviceworkers/ServiceWorkerPrivate.cpp b/dom/serviceworkers/Se
      MOZ_DIAGNOSTIC_ASSERT(mPendingPromisesCount > 0);
  
      // Note: mSelfRef and mKeepAliveToken can be nullptr here
-@@ -382,20 +394,17 @@ private:
+@@ -383,20 +395,17 @@ private:
      --mPendingPromisesCount;
      if (mPendingPromisesCount) {
        return;
@@ -917,7 +917,7 @@ diff --git a/dom/serviceworkers/ServiceWorkerPrivate.cpp b/dom/serviceworkers/Se
 diff --git a/dom/workers/RuntimeService.cpp b/dom/workers/RuntimeService.cpp
 --- a/dom/workers/RuntimeService.cpp
 +++ b/dom/workers/RuntimeService.cpp
-@@ -1047,16 +1047,20 @@ class MOZ_STACK_CLASS WorkerJSContext fi
+@@ -1043,16 +1043,20 @@ class MOZ_STACK_CLASS WorkerJSContext fi
  public:
    // The heap size passed here doesn't matter, we will change it later in the
    // call to JS_SetGCParameter inside InitJSContextForWorker.
@@ -938,7 +938,7 @@ diff --git a/dom/workers/RuntimeService.cpp b/dom/workers/RuntimeService.cpp
      JSContext* cx = MaybeContext();
      if (!cx) {
        return;   // Initialize() must have failed
-@@ -1100,53 +1104,41 @@ public:
+@@ -1096,54 +1100,42 @@ public:
      JS_SetWrapObjectCallbacks(cx, &WrapObjectCallbacks);
      if (mWorkerPrivate->IsDedicatedWorker()) {
        JS_SetFutexCanWait(cx);
@@ -971,7 +971,7 @@ diff --git a/dom/workers/RuntimeService.cpp b/dom/workers/RuntimeService.cpp
 -    std::queue<nsCOMPtr<nsIRunnable>>* microTaskQueue = nullptr;
 +    std::queue<RefPtr<MicroTaskRunnable>>* microTaskQueue = nullptr;
  
-     JSContext* cx = GetCurrentThreadJSContext();
+     JSContext* cx = GetCurrentWorkerThreadJSContext();
      NS_ASSERTION(cx, "This should never be null!");
  
      JS::Rooted<JSObject*> global(cx, JS::CurrentGlobalOrNull(cx));
@@ -987,7 +987,8 @@ diff --git a/dom/workers/RuntimeService.cpp b/dom/workers/RuntimeService.cpp
 -      microTaskQueue = &mPromiseMicroTaskQueue;
 +      microTaskQueue = &GetMicroTaskQueue();
      } else {
-       MOZ_ASSERT(IsDebuggerGlobal(global) || IsDebuggerSandbox(global));
+       MOZ_ASSERT(IsWorkerDebuggerGlobal(global) ||
+                  IsWorkerDebuggerSandbox(global));
  
 -      microTaskQueue = &mDebuggerPromiseMicroTaskQueue;
 +      microTaskQueue = &GetDebuggerMicroTaskQueue();
@@ -1002,7 +1003,7 @@ diff --git a/dom/workers/RuntimeService.cpp b/dom/workers/RuntimeService.cpp
 diff --git a/dom/workers/WorkerPrivate.cpp b/dom/workers/WorkerPrivate.cpp
 --- a/dom/workers/WorkerPrivate.cpp
 +++ b/dom/workers/WorkerPrivate.cpp
-@@ -5173,18 +5173,20 @@ WorkerPrivate::DoRunLoop(JSContext* aCx)
+@@ -3557,18 +3557,20 @@ WorkerPrivate::DoRunLoop(JSContext* aCx)
          mDebuggerQueue.Pop(runnable);
          debuggerRunnablesPending = !mDebuggerQueue.IsEmpty();
        }
@@ -1025,7 +1026,7 @@ diff --git a/dom/workers/WorkerPrivate.cpp b/dom/workers/WorkerPrivate.cpp
          // Now *might* be a good time to GC. Let the JS engine make the decision.
          JSAutoCompartment ac(aCx, globalScope->GetGlobalJSObject());
          JS_MaybeGC(aCx);
-@@ -6258,28 +6260,32 @@ WorkerPrivate::EnterDebuggerEventLoop()
+@@ -4642,28 +4644,32 @@ WorkerPrivate::EnterDebuggerEventLoop()
      if (!debuggerRunnablesPending) {
        SetGCTimerMode(IdleTimer);
      }
@@ -1061,7 +1062,7 @@ diff --git a/dom/workers/WorkerPrivate.cpp b/dom/workers/WorkerPrivate.cpp
        WorkerRunnable* runnable = nullptr;
  
        {
-@@ -6287,18 +6293,20 @@ WorkerPrivate::EnterDebuggerEventLoop()
+@@ -4671,18 +4677,20 @@ WorkerPrivate::EnterDebuggerEventLoop()
  
          mDebuggerQueue.Pop(runnable);
        }
@@ -1084,7 +1085,7 @@ diff --git a/dom/workers/WorkerPrivate.cpp b/dom/workers/WorkerPrivate.cpp
      }
    }
  }
-@@ -6703,18 +6711,18 @@ WorkerPrivate::RunExpiredTimeouts(JSCont
+@@ -5037,18 +5045,18 @@ WorkerPrivate::RunExpiredTimeouts(JSCont
      if (info->mIsInterval) {
        reason = "setInterval handler";
      } else {
@@ -1105,7 +1106,7 @@ diff --git a/dom/workers/WorkerPrivate.cpp b/dom/workers/WorkerPrivate.cpp
        const char* filename = nullptr;
        uint32_t lineNo = 0, dummyColumn = 0;
        info->mHandler->GetLocation(&filename, &lineNo, &dummyColumn);
-@@ -6739,20 +6747,16 @@ WorkerPrivate::RunExpiredTimeouts(JSCont
+@@ -5073,20 +5081,16 @@ WorkerPrivate::RunExpiredTimeouts(JSCont
          rv.SuppressException();
          retval = false;
          break;

+ 3 - 3
mozilla-release/patches/1252998-01-61a1.patch

@@ -2,7 +2,7 @@
 # User Andrea Marchesini <amarchesini@mozilla.com>
 # Date 1524068350 -7200
 # Node ID 558fef850d425f13465fe7b8ec0fd249d1527981
-# Parent  eab2041da3fc187d35c8715b4683d49d2526d484
+# Parent  88a22cce2ed7f1ae3951bd8444672197dc3fee7b
 Bug 1252998 - StorageActivityService - part 1 - Introduce StorageActivityService to monitor origin activities, r=asuth
 
 diff --git a/dom/interfaces/storage/moz.build b/dom/interfaces/storage/moz.build
@@ -397,7 +397,7 @@ diff --git a/ipc/glue/BackgroundParentImpl.cpp b/ipc/glue/BackgroundParentImpl.c
  #include "mozilla/dom/ipc/TemporaryIPCBlobParent.h"
  #include "mozilla/dom/quota/ActorsParent.h"
  #include "mozilla/dom/StorageIPC.h"
-@@ -981,16 +982,23 @@ BackgroundParentImpl::DeallocPClientMana
+@@ -976,16 +977,23 @@ BackgroundParentImpl::DeallocPClientMana
  
  mozilla::ipc::IPCResult
  BackgroundParentImpl::RecvPClientManagerConstructor(mozilla::dom::PClientManagerParent* aActor)
@@ -496,7 +496,7 @@ diff --git a/layout/build/nsLayoutModule.cpp b/layout/build/nsLayoutModule.cpp
  #include "mozilla/dom/ServiceWorkerManager.h"
  #include "mozilla/dom/SessionStorageManager.h"
 +#include "mozilla/dom/StorageActivityService.h"
- #include "mozilla/dom/workers/WorkerDebuggerManager.h"
+ #include "mozilla/dom/WorkerDebuggerManager.h"
  #include "mozilla/dom/Notification.h"
  #include "mozilla/OSFileConstants.h"
  #include "mozilla/Services.h"

+ 50 - 0
mozilla-release/patches/1397152-1-57a1.patch

@@ -0,0 +1,50 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1504714627 -7200
+# Node ID 4707bf6e77794a524d169dd8bc133c949540d001
+# Parent  282830520781f5c90f951800c6babed09708e7db
+Bug 1397152 - Remove Telemetry ID SHARED_WORKER_COUNT, r=bkelly
+
+diff --git a/dom/workers/SharedWorker.cpp b/dom/workers/SharedWorker.cpp
+--- a/dom/workers/SharedWorker.cpp
++++ b/dom/workers/SharedWorker.cpp
+@@ -72,18 +72,16 @@ SharedWorker::Constructor(const GlobalOb
+   RefPtr<SharedWorker> sharedWorker;
+   nsresult rv = rts->CreateSharedWorker(aGlobal, aScriptURL, name,
+                                         getter_AddRefs(sharedWorker));
+   if (NS_FAILED(rv)) {
+     aRv = rv;
+     return nullptr;
+   }
+ 
+-  Telemetry::Accumulate(Telemetry::SHARED_WORKER_COUNT, 1);
+-
+   return sharedWorker.forget();
+ }
+ 
+ MessagePort*
+ SharedWorker::Port()
+ {
+   AssertIsOnMainThread();
+   return mMessagePort;
+diff --git a/toolkit/components/telemetry/histogram-whitelists.json b/toolkit/components/telemetry/histogram-whitelists.json
+--- a/toolkit/components/telemetry/histogram-whitelists.json
++++ b/toolkit/components/telemetry/histogram-whitelists.json
+@@ -1370,17 +1370,16 @@
+     "SEARCH_SERVICE_US_COUNTRY_MISMATCHED_TIMEZONE",
+     "SEARCH_SERVICE_US_TIMEZONE_MISMATCHED_COUNTRY",
+     "SERVICE_WORKER_CONTROLLED_DOCUMENTS",
+     "SERVICE_WORKER_REGISTRATIONS",
+     "SERVICE_WORKER_SPAWN_ATTEMPTS",
+     "SERVICE_WORKER_SPAWN_GETS_QUEUED",
+     "SERVICE_WORKER_UPDATED",
+     "SERVICE_WORKER_WAS_SPAWNED",
+-    "SHARED_WORKER_COUNT",
+     "SHARED_WORKER_SPAWN_GETS_QUEUED",
+     "SHOULD_AUTO_DETECT_LANGUAGE",
+     "SHOULD_TRANSLATION_UI_APPEAR",
+     "SLOW_SCRIPT_NOTICE_COUNT",
+     "SLOW_SCRIPT_PAGE_COUNT",
+     "STARTUP_CRASH_DETECTED",
+     "STORAGE_SYNC_REMOVE_OPS",
+     "SUBJECT_PRINCIPAL_ACCESSED_WITHOUT_SCRIPT_ON_STACK",

+ 35 - 0
mozilla-release/patches/1397152-2-57a1.patch

@@ -0,0 +1,35 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1504715132 -7200
+# Node ID 979e046fd7375ed8d4c442f01f48178cbe552d62
+# Parent  73590287146f78f6a95170879e730de21d174921
+Bug 1397152 - Remove Telemetry ID SHARED_WORKER_COUNT - part 2, r=me CLOSED TREE
+
+diff --git a/toolkit/components/telemetry/Histograms.json b/toolkit/components/telemetry/Histograms.json
+--- a/toolkit/components/telemetry/Histograms.json
++++ b/toolkit/components/telemetry/Histograms.json
+@@ -9747,24 +9747,16 @@
+     "record_in_processes": ["main", "content"],
+     "alert_emails": ["jh+bugzilla@buttercookie.de"],
+     "expires_in_version": "61",
+     "kind": "flag",
+     "bug_numbers": [1337115],
+     "description": "Both the main session file and its backup could not be read and and the first run pref is false.",
+     "cpp_guard": "ANDROID"
+   },
+-  "SHARED_WORKER_COUNT": {
+-    "record_in_processes": ["main", "content"],
+-    "alert_emails": ["amarchesini@mozilla.com"],
+-    "expires_in_version": "58",
+-    "kind": "count",
+-    "bug_numbers": [1295980],
+-    "description": "Number of the use of SharedWorkers."
+-  },
+   "NUMBER_OF_PROFILES": {
+     "record_in_processes": ["main", "content"],
+     "alert_emails": ["amarchesini@mozilla.com"],
+     "expires_in_version": "58",
+     "bug_numbers": [1296606],
+     "kind": "count",
+     "description": "Number of named browser profiles for the current user, as reported by the profile service at startup."
+   },

+ 32 - 0
mozilla-release/patches/1402504-fix-58a1.patch

@@ -0,0 +1,32 @@
+# HG changeset patch
+# User Steve Fink <sfink@mozilla.com>
+# Date 1506013142 25200
+# Node ID c0e228638fe4bce3321c16a3ab812beb7275556c
+# Parent  721f461882942e7e8b0dae2b7da7571864bde67b
+Bug 1402504 - Switch to using in-source annotations more directly, r=jonco
+
+diff --git a/js/src/devtools/rootAnalysis/annotations.js b/js/src/devtools/rootAnalysis/annotations.js
+--- a/js/src/devtools/rootAnalysis/annotations.js
++++ b/js/src/devtools/rootAnalysis/annotations.js
+@@ -219,19 +219,19 @@ var ignoreFunctions = {
+ 
+     "float64 JS_GetCurrentEmbedderTime()" : true,
+ 
+     // This calls any JSObjectMovedOp for the tenured object via an indirect call.
+     "JSObject* js::TenuringTracer::moveToTenuredSlow(JSObject*)" : true,
+ 
+     "void js::Nursery::freeMallocedBuffers()" : true,
+ 
+-    "void mozilla::dom::workers::WorkerPrivate::AssertIsOnWorkerThread() const" : true,
++    "void js::AutoEnterOOMUnsafeRegion::crash(uint64, int8*)" : true,
+ 
+-    "void js::AutoEnterOOMUnsafeRegion::crash(uint64, int8*)" : true,
++    "void mozilla::dom::workers::WorkerPrivate::AssertIsOnWorkerThread() const" : true,
+ 
+     // It would be cool to somehow annotate that nsTHashtable<T> will use
+     // nsTHashtable<T>::s_MatchEntry for its matchEntry function pointer, but
+     // there is no mechanism for that. So we will just annotate a particularly
+     // troublesome logging-related usage.
+     "EntryType* nsTHashtable<EntryType>::PutEntry(nsTHashtable<EntryType>::KeyType, const fallible_t&) [with EntryType = nsBaseHashtableET<nsCharPtrHashKey, nsAutoPtr<mozilla::LogModule> >; nsTHashtable<EntryType>::KeyType = const char*; nsTHashtable<EntryType>::fallible_t = mozilla::fallible_t]" : true,
+     "EntryType* nsTHashtable<EntryType>::GetEntry(nsTHashtable<EntryType>::KeyType) const [with EntryType = nsBaseHashtableET<nsCharPtrHashKey, nsAutoPtr<mozilla::LogModule> >; nsTHashtable<EntryType>::KeyType = const char*]" : true,
+     "EntryType* nsTHashtable<EntryType>::PutEntry(nsTHashtable<EntryType>::KeyType) [with EntryType = nsBaseHashtableET<nsPtrHashKey<const mozilla::BlockingResourceBase>, nsAutoPtr<mozilla::DeadlockDetector<mozilla::BlockingResourceBase>::OrderingEntry> >; nsTHashtable<EntryType>::KeyType = const mozilla::BlockingResourceBase*]" : true,

+ 11 - 11
mozilla-release/patches/1403027-63a1.patch

@@ -2,7 +2,7 @@
 # User Thomas Wisniewski <wisniewskit@gmail.com>
 # Date 1516845544 18000
 # Node ID f839685ceb8eebc50fa69c9273141a4bdc8ce1e2
-# Parent  c87ed26d521b8ea454139959af87aad52696f502
+# Parent  675bb05931f792c4a00cc5c616f8eb98cc551061
 Bug 1403027 - Do not throw from PerformanceObserver.observe when none of the entryTypes are known (log a JS console warning instead); r=bz
 
 MozReview-Commit-ID: Lx2cjWDX8sh
@@ -23,25 +23,25 @@ diff --git a/dom/locales/en-US/chrome/dom/dom.properties b/dom/locales/en-US/chr
 diff --git a/dom/performance/PerformanceObserver.cpp b/dom/performance/PerformanceObserver.cpp
 --- a/dom/performance/PerformanceObserver.cpp
 +++ b/dom/performance/PerformanceObserver.cpp
-@@ -5,16 +5,17 @@
-  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
- 
+@@ -7,16 +7,17 @@
  #include "PerformanceObserver.h"
  
  #include "mozilla/dom/Performance.h"
  #include "mozilla/dom/PerformanceBinding.h"
  #include "mozilla/dom/PerformanceEntryBinding.h"
  #include "mozilla/dom/PerformanceObserverBinding.h"
+ #include "mozilla/dom/WorkerPrivate.h"
+ #include "mozilla/dom/WorkerScope.h"
 +#include "nsIScriptError.h"
  #include "nsPIDOMWindow.h"
  #include "nsQueryObject.h"
  #include "nsString.h"
  #include "PerformanceEntry.h"
  #include "PerformanceObserverEntryList.h"
- #include "WorkerPrivate.h"
- #include "WorkerScope.h"
  
-@@ -139,36 +140,63 @@ PerformanceObserver::QueueEntry(Performa
+ using namespace mozilla;
+ using namespace mozilla::dom;
+@@ -138,36 +139,63 @@ PerformanceObserver::QueueEntry(Performa
  static const char16_t *const sValidTypeNames[4] = {
    u"mark",
    u"measure",
@@ -112,8 +112,8 @@ diff --git a/dom/performance/PerformanceObserver.cpp b/dom/performance/Performan
 diff --git a/dom/performance/PerformanceObserver.h b/dom/performance/PerformanceObserver.h
 --- a/dom/performance/PerformanceObserver.h
 +++ b/dom/performance/PerformanceObserver.h
-@@ -49,18 +49,17 @@ public:
-   PerformanceObserver(workers::WorkerPrivate* aWorkerPrivate,
+@@ -47,18 +47,17 @@ public:
+   PerformanceObserver(WorkerPrivate* aWorkerPrivate,
                        PerformanceObserverCallback& aCb);
  
    virtual JSObject* WrapObject(JSContext* aCx,
@@ -372,7 +372,7 @@ diff --git a/dom/webidl/PerformanceObserver.webidl b/dom/webidl/PerformanceObser
 diff --git a/dom/workers/WorkerPrivate.cpp b/dom/workers/WorkerPrivate.cpp
 --- a/dom/workers/WorkerPrivate.cpp
 +++ b/dom/workers/WorkerPrivate.cpp
-@@ -554,65 +554,74 @@ private:
+@@ -544,65 +544,74 @@ private:
    {
      return aWorkerPrivate->ThawInternal();
    }
@@ -456,7 +456,7 @@ diff --git a/dom/workers/WorkerPrivate.cpp b/dom/workers/WorkerPrivate.cpp
                              public nsITimerCallback,
                              public nsINamed
  {
-@@ -5070,22 +5079,31 @@ WorkerPrivate::ReportError(JSContext* aC
+@@ -4877,22 +4886,31 @@ WorkerPrivate::ReportError(JSContext* aC
  
    mErrorHandlerRecursionCount--;
  }

+ 64 - 0
mozilla-release/patches/1421355-5-59a1.patch

@@ -0,0 +1,64 @@
+# HG changeset patch
+# User Andrew McCreight <continuation@gmail.com>
+# Date 1511892038 28800
+# Node ID 771c241071237f4868f27c4ca7c5fc877c5a0b21
+# Parent  4a54a8e29ea12c8ac55cbc70df9f9ceaa8b79b90
+Bug 1421355, part 5 - Remove nsXPConnect::NotifyDidPaint(). r=mrbkap
+
+Presshell still does something along these lines, but it works completely differently.
+
+MozReview-Commit-ID: JRenEDNlo6p
+
+diff --git a/js/xpconnect/idl/nsIXPConnect.idl b/js/xpconnect/idl/nsIXPConnect.idl
+--- a/js/xpconnect/idl/nsIXPConnect.idl
++++ b/js/xpconnect/idl/nsIXPConnect.idl
+@@ -456,22 +456,16 @@ interface nsIXPConnect : nsISupports
+                                          in JSObjectPtr sandbox);
+ 
+     /**
+      * Trigger a JS garbage collection.
+      * Use a js::gcreason::Reason from jsfriendapi.h for the kind.
+      */
+     void GarbageCollect(in uint32_t reason);
+ 
+-    /**
+-     * Signals a good place to do an incremental GC slice, because the
+-     * browser is drawing a frame.
+-     */
+-    void NotifyDidPaint();
+-
+ %{C++
+     /**
+      * Get the object principal for this wrapper.  Note that this may well end
+      * up being null; in that case one should seek principals elsewhere.  Null
+      * here does NOT indicate system principal or no principals at all, just
+      * that this wrapper doesn't have an intrinsic one.
+      */
+     virtual nsIPrincipal* GetPrincipal(JSObject* obj,
+diff --git a/js/xpconnect/src/nsXPConnect.cpp b/js/xpconnect/src/nsXPConnect.cpp
+--- a/js/xpconnect/src/nsXPConnect.cpp
++++ b/js/xpconnect/src/nsXPConnect.cpp
+@@ -1068,23 +1068,16 @@ void
+ SetLocationForGlobal(JSObject* global, nsIURI* locationURI)
+ {
+     MOZ_ASSERT(global);
+     CompartmentPrivate::Get(global)->SetLocationURI(locationURI);
+ }
+ 
+ } // namespace xpc
+ 
+-NS_IMETHODIMP
+-nsXPConnect::NotifyDidPaint()
+-{
+-    JS::NotifyDidPaint(XPCJSContext::Get()->Context());
+-    return NS_OK;
+-}
+-
+ static nsresult
+ WriteScriptOrFunction(nsIObjectOutputStream* stream, JSContext* cx,
+                       JSScript* scriptArg, HandleObject functionObj)
+ {
+     // Exactly one of script or functionObj must be given
+     MOZ_ASSERT(!scriptArg != !functionObj);
+ 
+     RootedScript script(cx, scriptArg);

+ 61 - 0
mozilla-release/patches/1421355-6-59a1.patch

@@ -0,0 +1,61 @@
+# HG changeset patch
+# User Andrew McCreight <continuation@gmail.com>
+# Date 1511892263 28800
+# Node ID 0b00ae699a2d720d59399cb88752a99de8fc2257
+# Parent  c6fcd3dc7987826cd48c8057fee30ea379081e82
+Bug 1421355, part 6 - Remove JS::NotifyDidPaint. r=jonco
+
+MozReview-Commit-ID: 6rdvr6QfAD1
+
+diff --git a/js/public/GCAPI.h b/js/public/GCAPI.h
+--- a/js/public/GCAPI.h
++++ b/js/public/GCAPI.h
+@@ -876,22 +876,16 @@ class JS_PUBLIC_API(AutoCheckCannotGC) :
+ #endif
+ 
+ /*
+  * Internal to Firefox.
+  */
+ extern JS_FRIEND_API(void)
+ NotifyGCRootsRemoved(JSContext* cx);
+ 
+-/*
+- * Internal to Firefox.
+- */
+-extern JS_FRIEND_API(void)
+-NotifyDidPaint(JSContext* cx);
+-
+ } /* namespace JS */
+ 
+ /**
+  * Register externally maintained GC roots.
+  *
+  * traceOp: the trace operation. For each root the implementation should call
+  *          JS::TraceEdge whenever the root contains a traceable thing.
+  * data:    the data argument to pass to each invocation of traceOp.
+diff --git a/js/src/jsfriendapi.cpp b/js/src/jsfriendapi.cpp
+--- a/js/src/jsfriendapi.cpp
++++ b/js/src/jsfriendapi.cpp
+@@ -1244,22 +1244,16 @@ js::DumpHeap(JSContext* cx, FILE* fp, js
+ JS_FRIEND_API(void)
+ js::SetActivityCallback(JSContext* cx, ActivityCallback cb, void* arg)
+ {
+     cx->activityCallback = cb;
+     cx->activityCallbackArg = arg;
+ }
+ 
+ JS_FRIEND_API(void)
+-JS::NotifyDidPaint(JSContext* cx)
+-{
+-    cx->runtime()->gc.notifyDidPaint();
+-}
+-
+-JS_FRIEND_API(void)
+ JS::NotifyGCRootsRemoved(JSContext* cx)
+ {
+     cx->runtime()->gc.notifyRootsRemoved();
+ }
+ 
+ JS_FRIEND_API(JSCompartment*)
+ js::GetAnyCompartmentInZone(JS::Zone* zone)
+ {

+ 483 - 0
mozilla-release/patches/1421358-59a1.patch

@@ -0,0 +1,483 @@
+# HG changeset patch
+# User Adrian Wielgosik <adrian.wielgosik@gmail.com>
+# Date 1513205551 -3600
+# Node ID 30237d58eb352f8246585b2b2361b407d9915c49
+# Parent  2e4db9503982875e85a4b6b733d670cafc4edbf7
+Bug 1421358 - Remove GCRuntime::notifyDidPaint and refresh_frame_slices.enabled pref. r=jonco
+
+MozReview-Commit-ID: HBh0qyPckKv
+
+diff --git a/dom/base/nsJSEnvironment.cpp b/dom/base/nsJSEnvironment.cpp
+--- a/dom/base/nsJSEnvironment.cpp
++++ b/dom/base/nsJSEnvironment.cpp
+@@ -2684,20 +2684,16 @@ nsJSContext::EnsureStatics()
+                                        "javascript.options.mem.gc_high_frequency_time_limit_ms",
+                                        (void *)JSGC_HIGH_FREQUENCY_TIME_LIMIT);
+ 
+   Preferences::RegisterCallbackAndCall(SetMemoryPrefChangedCallbackBool,
+                                        "javascript.options.mem.gc_dynamic_mark_slice",
+                                        (void *)JSGC_DYNAMIC_MARK_SLICE);
+ 
+   Preferences::RegisterCallbackAndCall(SetMemoryPrefChangedCallbackBool,
+-                                       "javascript.options.mem.gc_refresh_frame_slices_enabled",
+-                                       (void *)JSGC_REFRESH_FRAME_SLICES_ENABLED);
+-
+-  Preferences::RegisterCallbackAndCall(SetMemoryPrefChangedCallbackBool,
+                                        "javascript.options.mem.gc_dynamic_heap_growth",
+                                        (void *)JSGC_DYNAMIC_HEAP_GROWTH);
+ 
+   Preferences::RegisterCallbackAndCall(SetMemoryPrefChangedCallbackInt,
+                                        "javascript.options.mem.gc_low_frequency_heap_growth",
+                                        (void *)JSGC_LOW_FREQUENCY_HEAP_GROWTH);
+ 
+   Preferences::RegisterCallbackAndCall(SetMemoryPrefChangedCallbackInt,
+diff --git a/dom/workers/RuntimeService.cpp b/dom/workers/RuntimeService.cpp
+--- a/dom/workers/RuntimeService.cpp
++++ b/dom/workers/RuntimeService.cpp
+@@ -548,25 +548,16 @@ LoadJSGCMemoryOptions(const char* aPrefN
+     if (memPrefName == matchName ||
+         (gRuntimeServiceDuringInit && index == 14)) {
+       bool prefValue = GetWorkerPref(matchName, false);
+       UpdateOtherJSGCMemoryOption(rts, JSGC_COMPACTING_ENABLED,
+                                  prefValue ? 0 : 1);
+       continue;
+     }
+ 
+-    matchName.RebindLiteral(PREF_MEM_OPTIONS_PREFIX "gc_refresh_frame_slices_enabled");
+-    if (memPrefName == matchName ||
+-        (gRuntimeServiceDuringInit && index == 15)) {
+-      bool prefValue = GetWorkerPref(matchName, false);
+-      UpdateOtherJSGCMemoryOption(rts, JSGC_REFRESH_FRAME_SLICES_ENABLED,
+-                                 prefValue ? 0 : 1);
+-      continue;
+-    }
+-
+ #ifdef DEBUG
+     nsAutoCString message("Workers don't support the 'mem.");
+     message.Append(memPrefName);
+     message.AppendLiteral("' preference!");
+     NS_WARNING(message.get());
+ #endif
+   }
+ }
+diff --git a/dom/workers/Workers.h b/dom/workers/Workers.h
+--- a/dom/workers/Workers.h
++++ b/dom/workers/Workers.h
+@@ -90,17 +90,16 @@ struct JSSettings
+     JSSettings_JSGC_HIGH_FREQUENCY_HEAP_GROWTH_MIN,
+     JSSettings_JSGC_HIGH_FREQUENCY_HEAP_GROWTH_MAX,
+     JSSettings_JSGC_HIGH_FREQUENCY_LOW_LIMIT,
+     JSSettings_JSGC_HIGH_FREQUENCY_HIGH_LIMIT,
+     JSSettings_JSGC_ALLOCATION_THRESHOLD,
+     JSSettings_JSGC_SLICE_TIME_BUDGET,
+     JSSettings_JSGC_DYNAMIC_HEAP_GROWTH,
+     JSSettings_JSGC_DYNAMIC_MARK_SLICE,
+-    JSSettings_JSGC_REFRESH_FRAME_SLICES,
+     // JSGC_MODE not supported
+ 
+     // This must be last so that we get an accurate count.
+     kGCSettingsArraySize
+   };
+ 
+   struct JSGCSetting
+   {
+diff --git a/js/public/GCAPI.h b/js/public/GCAPI.h
+--- a/js/public/GCAPI.h
++++ b/js/public/GCAPI.h
+@@ -240,24 +240,16 @@ typedef enum JSGCParamKey {
+      * Whether compacting GC is enabled.
+      *
+      * Pref: javascript.options.mem.gc_compacting
+      * Default: CompactingEnabled
+      */
+     JSGC_COMPACTING_ENABLED = 23,
+ 
+     /**
+-     * If true, painting can trigger IGC slices.
+-     *
+-     * Pref: javascript.options.mem.gc_refresh_frame_slices_enabled
+-     * Default: RefreshFrameSlicesEnabled
+-     */
+-    JSGC_REFRESH_FRAME_SLICES_ENABLED = 24,
+-
+-    /**
+      * Factor for triggering a GC based on JSGC_ALLOCATION_THRESHOLD
+      *
+      * Default: ZoneAllocThresholdFactorDefault
+      * Pref: None
+      */
+     JSGC_ALLOCATION_THRESHOLD_FACTOR = 25,
+ 
+     /**
+@@ -385,17 +377,17 @@ struct Zone;
+     D(PAGE_HIDE)                                \
+     D(NSJSCONTEXT_DESTROY)                      \
+     D(SET_NEW_DOCUMENT)                         \
+     D(SET_DOC_SHELL)                            \
+     D(DOM_UTILS)                                \
+     D(DOM_IPC)                                  \
+     D(DOM_WORKER)                               \
+     D(INTER_SLICE_GC)                           \
+-    D(REFRESH_FRAME)                            \
++    D(UNUSED1)                                  \
+     D(FULL_GC_TIMER)                            \
+     D(SHUTDOWN_CC)                              \
+     D(UNUSED2)                                  \
+     D(USER_INACTIVE)                            \
+     D(XPCONNECT_SHUTDOWN)                       \
+     D(DOCSHELL)                                 \
+     D(HTML_PARSER)
+ 
+diff --git a/js/src/builtin/TestingFunctions.cpp b/js/src/builtin/TestingFunctions.cpp
+--- a/js/src/builtin/TestingFunctions.cpp
++++ b/js/src/builtin/TestingFunctions.cpp
+@@ -365,18 +365,17 @@ MinorGC(JSContext* cx, unsigned argc, Va
+     _("highFrequencyHeapGrowthMax", JSGC_HIGH_FREQUENCY_HEAP_GROWTH_MAX, true)  \
+     _("highFrequencyHeapGrowthMin", JSGC_HIGH_FREQUENCY_HEAP_GROWTH_MIN, true)  \
+     _("lowFrequencyHeapGrowth",     JSGC_LOW_FREQUENCY_HEAP_GROWTH,      true)  \
+     _("dynamicHeapGrowth",          JSGC_DYNAMIC_HEAP_GROWTH,            true)  \
+     _("dynamicMarkSlice",           JSGC_DYNAMIC_MARK_SLICE,             true)  \
+     _("allocationThreshold",        JSGC_ALLOCATION_THRESHOLD,           true)  \
+     _("minEmptyChunkCount",         JSGC_MIN_EMPTY_CHUNK_COUNT,          true)  \
+     _("maxEmptyChunkCount",         JSGC_MAX_EMPTY_CHUNK_COUNT,          true)  \
+-    _("compactingEnabled",          JSGC_COMPACTING_ENABLED,             true)  \
+-    _("refreshFrameSlicesEnabled",  JSGC_REFRESH_FRAME_SLICES_ENABLED,   true)
++    _("compactingEnabled",          JSGC_COMPACTING_ENABLED,             true)
+ 
+ static const struct ParamInfo {
+     const char*     name;
+     JSGCParamKey    param;
+     bool            writable;
+ } paramMap[] = {
+ #define DEFINE_PARAM_INFO(name, key, writable)                                  \
+     {name, key, writable},
+diff --git a/js/src/gc/GCEnum.h b/js/src/gc/GCEnum.h
+--- a/js/src/gc/GCEnum.h
++++ b/js/src/gc/GCEnum.h
+@@ -55,19 +55,17 @@ enum class AbortReason {
+ #define MAKE_REASON(name) name,
+     GC_ABORT_REASONS(MAKE_REASON)
+ #undef MAKE_REASON
+ };
+ 
+ #define JS_FOR_EACH_ZEAL_MODE(D)       \
+     D(RootsChange, 1)                  \
+     D(Alloc, 2)                        \
+-    D(FrameGC, 3)                      \
+     D(VerifierPre, 4)                  \
+-    D(FrameVerifierPre, 5)             \
+     D(GenerationalGC, 7)               \
+     D(IncrementalRootsThenFinish, 8)   \
+     D(IncrementalMarkAllThenFinish, 9) \
+     D(IncrementalMultipleSlices, 10)   \
+     D(IncrementalMarkingValidator, 11) \
+     D(ElementsBarrier, 12)             \
+     D(CheckHashTablesOnMinorGC, 13)    \
+     D(Compact, 14)                     \
+diff --git a/js/src/gc/GCRuntime.h b/js/src/gc/GCRuntime.h
+--- a/js/src/gc/GCRuntime.h
++++ b/js/src/gc/GCRuntime.h
+@@ -233,23 +233,16 @@ class GCSchedulingTunables
+     /*
+      * JSGC_DYNAMIC_MARK_SLICE
+      *
+      * Doubles the length of IGC slices when in the |highFrequencyGC| mode.
+      */
+     ActiveThreadData<bool> dynamicMarkSliceEnabled_;
+ 
+     /*
+-     * JSGC_REFRESH_FRAME_SLICES_ENABLED
+-     *
+-     * Controls whether painting can trigger IGC slices.
+-     */
+-    ActiveThreadData<bool> refreshFrameSlicesEnabled_;
+-
+-    /*
+      * JSGC_MIN_EMPTY_CHUNK_COUNT
+      * JSGC_MAX_EMPTY_CHUNK_COUNT
+      *
+      * Controls the number of empty chunks reserved for future allocation.
+      */
+     UnprotectedData<uint32_t> minEmptyChunkCount_;
+     UnprotectedData<uint32_t> maxEmptyChunkCount_;
+ 
+@@ -266,17 +259,16 @@ class GCSchedulingTunables
+     bool isDynamicHeapGrowthEnabled() const { return dynamicHeapGrowthEnabled_; }
+     uint64_t highFrequencyThresholdUsec() const { return highFrequencyThresholdUsec_; }
+     uint64_t highFrequencyLowLimitBytes() const { return highFrequencyLowLimitBytes_; }
+     uint64_t highFrequencyHighLimitBytes() const { return highFrequencyHighLimitBytes_; }
+     double highFrequencyHeapGrowthMax() const { return highFrequencyHeapGrowthMax_; }
+     double highFrequencyHeapGrowthMin() const { return highFrequencyHeapGrowthMin_; }
+     double lowFrequencyHeapGrowth() const { return lowFrequencyHeapGrowth_; }
+     bool isDynamicMarkSliceEnabled() const { return dynamicMarkSliceEnabled_; }
+-    bool areRefreshFrameSlicesEnabled() const { return refreshFrameSlicesEnabled_; }
+     unsigned minEmptyChunkCount(const AutoLockGC&) const { return minEmptyChunkCount_; }
+     unsigned maxEmptyChunkCount() const { return maxEmptyChunkCount_; }
+ 
+     MOZ_MUST_USE bool setParameter(JSGCParamKey key, uint32_t value, const AutoLockGC& lock);
+     void resetParameter(JSGCParamKey key, const AutoLockGC& lock);
+ 
+     void setMaxMallocBytes(size_t value);
+ 
+@@ -796,17 +788,16 @@ class GCRuntime
+ 
+     enum TraceOrMarkRuntime {
+         TraceRuntime,
+         MarkRuntime
+     };
+     void traceRuntime(JSTracer* trc, AutoLockForExclusiveAccess& lock);
+     void traceRuntimeForMinorGC(JSTracer* trc, AutoLockForExclusiveAccess& lock);
+ 
+-    void notifyDidPaint();
+     void shrinkBuffers();
+     void onOutOfMallocMemory();
+     void onOutOfMallocMemory(const AutoLockGC& lock);
+ 
+ #ifdef JS_GC_ZEAL
+     const void* addressOfZealModeBits() { return &zealModeBits; }
+     void getZealBits(uint32_t* zealBits, uint32_t* frequency, uint32_t* nextScheduled);
+     void setZeal(uint8_t zeal, uint32_t frequency);
+@@ -1382,23 +1373,16 @@ class GCRuntime
+     ActiveThreadData<ZoneList> zonesToMaybeCompact;
+     ActiveThreadData<Arena*> relocatedArenasToRelease;
+ 
+ #ifdef JS_GC_ZEAL
+     ActiveThreadData<MarkingValidator*> markingValidator;
+ #endif
+ 
+     /*
+-     * Indicates that a GC slice has taken place in the middle of an animation
+-     * frame, rather than at the beginning. In this case, the next slice will be
+-     * delayed so that we don't get back-to-back slices.
+-     */
+-    ActiveThreadData<bool> interFrameGC;
+-
+-    /*
+      * Default budget for incremental GC slice. See js/SliceBudget.h.
+      *
+      * JSGC_SLICE_TIME_BUDGET
+      * pref: javascript.options.mem.gc_incremental_slice_ms,
+      */
+     ActiveThreadData<int64_t> defaultTimeBudget_;
+ 
+     /*
+diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp
+--- a/js/src/jsgc.cpp
++++ b/js/src/jsgc.cpp
+@@ -320,19 +320,16 @@ namespace TuningDefaults {
+     static const double HighFrequencyHeapGrowthMin = 1.5;
+ 
+     /* JSGC_LOW_FREQUENCY_HEAP_GROWTH */
+     static const double LowFrequencyHeapGrowth = 1.5;
+ 
+     /* JSGC_DYNAMIC_MARK_SLICE */
+     static const bool DynamicMarkSliceEnabled = false;
+ 
+-    /* JSGC_REFRESH_FRAME_SLICES_ENABLED */
+-    static const bool RefreshFrameSlicesEnabled = true;
+-
+     /* JSGC_MIN_EMPTY_CHUNK_COUNT */
+     static const uint32_t MinEmptyChunkCount = 1;
+ 
+     /* JSGC_MAX_EMPTY_CHUNK_COUNT */
+     static const uint32_t MaxEmptyChunkCount = 30;
+ 
+     /* JSGC_SLICE_TIME_BUDGET */
+     static const int64_t DefaultTimeBudget = SliceBudget::UnlimitedTimeBudget;
+@@ -937,17 +934,16 @@ GCRuntime::GCRuntime(JSRuntime* rt) :
+     sweepZone(nullptr),
+     abortSweepAfterCurrentGroup(false),
+     arenasAllocatedDuringSweep(nullptr),
+     startedCompacting(false),
+     relocatedArenasToRelease(nullptr),
+ #ifdef JS_GC_ZEAL
+     markingValidator(nullptr),
+ #endif
+-    interFrameGC(false),
+     defaultTimeBudget_(TuningDefaults::DefaultTimeBudget),
+     incrementalAllowed(true),
+     compactingEnabled(TuningDefaults::CompactingEnabled),
+     rootsRemoved(false),
+ #ifdef JS_GC_ZEAL
+     zealModeBits(0),
+     zealFrequency(0),
+     nextScheduled(0),
+@@ -985,19 +981,17 @@ const char* gc::ZealModeHelpText =
+     "  Specifies how zealous the garbage collector should be. Some of these modes can\n"
+     "  be set simultaneously, by passing multiple level options, e.g. \"2;4\" will activate\n"
+     "  both modes 2 and 4. Modes can be specified by name or number.\n"
+     "  \n"
+     "  Values:\n"
+     "    0: (None) Normal amount of collection (resets all modes)\n"
+     "    1: (RootsChange) Collect when roots are added or removed\n"
+     "    2: (Alloc) Collect when every N allocations (default: 100)\n"
+-    "    3: (FrameGC) Collect when the window paints (browser only)\n"
+     "    4: (VerifierPre) Verify pre write barriers between instructions\n"
+-    "    5: (FrameVerifierPre) Verify pre write barriers between paints\n"
+     "    7: (GenerationalGC) Collect the nursery every N nursery allocations\n"
+     "    8: (IncrementalRootsThenFinish) Incremental GC in two slices: 1) mark roots 2) finish collection\n"
+     "    9: (IncrementalMarkAllThenFinish) Incremental GC in two slices: 1) mark all 2) new marking and finish\n"
+     "   10: (IncrementalMultipleSlices) Incremental GC in multiple slices\n"
+     "   11: (IncrementalMarkingValidator) Verify incremental marking\n"
+     "   12: (ElementsBarrier) Always use the individual element post-write barrier, regardless of elements size\n"
+     "   13: (CheckHashTablesOnMinorGC) Check internal hashtables on minor GC\n"
+     "   14: (Compact) Perform a shrinking collection every N allocations\n"
+@@ -1373,19 +1367,16 @@ GCSchedulingTunables::setParameter(JSGCP
+         break;
+       }
+       case JSGC_MIN_EMPTY_CHUNK_COUNT:
+         setMinEmptyChunkCount(value);
+         break;
+       case JSGC_MAX_EMPTY_CHUNK_COUNT:
+         setMaxEmptyChunkCount(value);
+         break;
+-      case JSGC_REFRESH_FRAME_SLICES_ENABLED:
+-        refreshFrameSlicesEnabled_ = value != 0;
+-        break;
+       default:
+         MOZ_CRASH("Unknown GC parameter.");
+     }
+ 
+     return true;
+ }
+ 
+ void
+@@ -1441,17 +1432,16 @@ GCSchedulingTunables::GCSchedulingTunabl
+     dynamicHeapGrowthEnabled_(TuningDefaults::DynamicHeapGrowthEnabled),
+     highFrequencyThresholdUsec_(TuningDefaults::HighFrequencyThresholdUsec),
+     highFrequencyLowLimitBytes_(TuningDefaults::HighFrequencyLowLimitBytes),
+     highFrequencyHighLimitBytes_(TuningDefaults::HighFrequencyHighLimitBytes),
+     highFrequencyHeapGrowthMax_(TuningDefaults::HighFrequencyHeapGrowthMax),
+     highFrequencyHeapGrowthMin_(TuningDefaults::HighFrequencyHeapGrowthMin),
+     lowFrequencyHeapGrowth_(TuningDefaults::LowFrequencyHeapGrowth),
+     dynamicMarkSliceEnabled_(TuningDefaults::DynamicMarkSliceEnabled),
+-    refreshFrameSlicesEnabled_(TuningDefaults::RefreshFrameSlicesEnabled),
+     minEmptyChunkCount_(TuningDefaults::MinEmptyChunkCount),
+     maxEmptyChunkCount_(TuningDefaults::MaxEmptyChunkCount)
+ {}
+ 
+ void
+ GCRuntime::resetParameter(JSGCParamKey key, AutoLockGC& lock)
+ {
+     switch (key) {
+@@ -1529,19 +1519,16 @@ GCSchedulingTunables::resetParameter(JSG
+         allocThresholdFactorAvoidInterrupt_ = TuningDefaults::AllocThresholdFactorAvoidInterrupt;
+         break;
+       case JSGC_MIN_EMPTY_CHUNK_COUNT:
+         setMinEmptyChunkCount(TuningDefaults::MinEmptyChunkCount);
+         break;
+       case JSGC_MAX_EMPTY_CHUNK_COUNT:
+         setMaxEmptyChunkCount(TuningDefaults::MaxEmptyChunkCount);
+         break;
+-      case JSGC_REFRESH_FRAME_SLICES_ENABLED:
+-        refreshFrameSlicesEnabled_ = TuningDefaults::RefreshFrameSlicesEnabled;
+-        break;
+       default:
+         MOZ_CRASH("Unknown GC parameter.");
+     }
+ }
+ 
+ uint32_t
+ GCRuntime::getParameter(JSGCParamKey key, const AutoLockGC& lock)
+ {
+@@ -1593,18 +1580,16 @@ GCRuntime::getParameter(JSGCParamKey key
+       case JSGC_ALLOCATION_THRESHOLD_FACTOR_AVOID_INTERRUPT:
+         return uint32_t(tunables.allocThresholdFactorAvoidInterrupt() * 100);
+       case JSGC_MIN_EMPTY_CHUNK_COUNT:
+         return tunables.minEmptyChunkCount(lock);
+       case JSGC_MAX_EMPTY_CHUNK_COUNT:
+         return tunables.maxEmptyChunkCount();
+       case JSGC_COMPACTING_ENABLED:
+         return compactingEnabled;
+-      case JSGC_REFRESH_FRAME_SLICES_ENABLED:
+-        return tunables.areRefreshFrameSlicesEnabled();
+       default:
+         MOZ_ASSERT(key == JSGC_NUMBER);
+         return uint32_t(number);
+     }
+ }
+ 
+ void
+ GCRuntime::setMarkStackLimit(size_t limit, AutoLockGC& lock)
+@@ -7340,17 +7325,16 @@ GCRuntime::gcCycle(bool nonincrementalBy
+ 
+     gcstats::AutoGCSlice agc(stats(), scanZonesBeforeGC(), invocationKind, budget, reason);
+ 
+     minorGC(reason, gcstats::PhaseKind::EVICT_NURSERY_FOR_MAJOR_GC);
+ 
+     AutoTraceSession session(rt, JS::HeapState::MajorCollecting);
+ 
+     majorGCTriggerReason = JS::gcreason::NO_REASON;
+-    interFrameGC = true;
+ 
+     number++;
+     if (!isIncrementalGCInProgress())
+         incMajorGcNumber();
+ 
+     // It's ok if threads other than the active thread have suppressGC set, as
+     // they are operating on zones which will not be collected from here.
+     MOZ_ASSERT(!TlsContext.get()->suppressGC);
+@@ -7649,40 +7633,16 @@ GCRuntime::abortGC()
+ {
+     MOZ_ASSERT(isIncrementalGCInProgress());
+     checkCanCallAPI();
+     MOZ_ASSERT(!TlsContext.get()->suppressGC);
+ 
+     collect(false, SliceBudget::unlimited(), JS::gcreason::ABORT_GC);
+ }
+ 
+-void
+-GCRuntime::notifyDidPaint()
+-{
+-    MOZ_ASSERT(CurrentThreadCanAccessRuntime(rt));
+-
+-#ifdef JS_GC_ZEAL
+-    if (hasZealMode(ZealMode::FrameVerifierPre))
+-        verifyPreBarriers();
+-
+-    if (hasZealMode(ZealMode::FrameGC)) {
+-        JS::PrepareForFullGC(rt->activeContextFromOwnThread());
+-        gc(GC_NORMAL, JS::gcreason::REFRESH_FRAME);
+-        return;
+-    }
+-#endif
+-
+-    if (isIncrementalGCInProgress() && !interFrameGC && tunables.areRefreshFrameSlicesEnabled()) {
+-        JS::PrepareForIncrementalGC(rt->activeContextFromOwnThread());
+-        gcSlice(JS::gcreason::REFRESH_FRAME);
+-    }
+-
+-    interFrameGC = false;
+-}
+-
+ static bool
+ ZonesSelected(JSRuntime* rt)
+ {
+     for (ZonesIter zone(rt, WithAtoms); !zone.done(); zone.next()) {
+         if (zone->isGCScheduled())
+             return true;
+     }
+     return false;
+diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js
+--- a/modules/libpref/init/all.js
++++ b/modules/libpref/init/all.js
+@@ -1534,19 +1534,16 @@ pref("javascript.options.mem.gc_low_freq
+ // JSGC_DYNAMIC_HEAP_GROWTH
+ // Override SpiderMonkey default (false).
+ pref("javascript.options.mem.gc_dynamic_heap_growth", true);
+ 
+ // JSGC_DYNAMIC_MARK_SLICE
+ // Override SpiderMonkey default (false).
+ pref("javascript.options.mem.gc_dynamic_mark_slice", true);
+ 
+-// JSGC_REFRESH_FRAME_SLICES_ENABLED
+-pref("javascript.options.mem.gc_refresh_frame_slices_enabled", true);
+-
+ // JSGC_ALLOCATION_THRESHOLD
+ pref("javascript.options.mem.gc_allocation_threshold_mb", 30);
+ 
+ // JSGC_ALLOCATION_THRESHOLD_FACTOR
+ pref("javascript.options.mem.gc_allocation_threshold_factor", 90);
+ 
+ // JSGC_ALLOCATION_THRESHOLD_FACTOR_AVOID_INTERRUPT
+ pref("javascript.options.mem.gc_allocation_threshold_factor_avoid_interrupt", 90);

+ 3 - 3
mozilla-release/patches/1422036-60a1.patch

@@ -2,7 +2,7 @@
 # User Andrea Marchesini <amarchesini@mozilla.com>
 # Date 1517856908 -3600
 # Node ID d79788e03f7451ebc4a3c694117497f091a5a129
-# Parent  dc287c69de65a05ee6394fe350fc2baa076721ee
+# Parent  57416fff91cffdf84bcecdb07d0a08068d3b5c17
 Bug 1422036 - Using WorkerControlRunnable to release resources in fetch when the worker is shutting down, r=catalinb
 
 diff --git a/dom/fetch/FetchConsumer.cpp b/dom/fetch/FetchConsumer.cpp
@@ -281,7 +281,7 @@ diff --git a/dom/fetch/FetchConsumer.cpp b/dom/fetch/FetchConsumer.cpp
 diff --git a/dom/fetch/FetchConsumer.h b/dom/fetch/FetchConsumer.h
 --- a/dom/fetch/FetchConsumer.h
 +++ b/dom/fetch/FetchConsumer.h
-@@ -49,20 +49,21 @@ public:
+@@ -46,20 +46,21 @@ public:
  
    void
    ReleaseObject();
@@ -301,7 +301,7 @@ diff --git a/dom/fetch/FetchConsumer.h b/dom/fetch/FetchConsumer.h
    void
    ShutDownMainThreadConsuming();
  
-   workers::WorkerPrivate*
+   WorkerPrivate*
    GetWorkerPrivate() const
    {
      return mWorkerPrivate;

+ 233 - 0
mozilla-release/patches/1432963-01-60a1.patch

@@ -0,0 +1,233 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1517383150 -3600
+# Node ID d7e5e7c4cf8857e267c60689e355aafeddfd2bdd
+# Parent  4d7ded83036fe9e5366f5352631fcabc9c4ba63d
+Bug 1432963 - Fixing workers headers - part 1 - no workers namespace for SharedWorker, r=smaug
+
+diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf
+--- a/dom/bindings/Bindings.conf
++++ b/dom/bindings/Bindings.conf
+@@ -767,21 +767,16 @@ DOMInterfaces = {
+ 'ServiceWorkerGlobalScope': {
+     'headerFile': 'mozilla/dom/WorkerScope.h',
+ },
+ 
+ 'ServiceWorkerRegistration': {
+     'implicitJSContext': [ 'pushManager' ],
+ },
+ 
+-'SharedWorker': {
+-    'nativeType': 'mozilla::dom::workers::SharedWorker',
+-    'headerFile': 'mozilla/dom/workers/bindings/SharedWorker.h',
+-},
+-
+ 'SharedWorkerGlobalScope': {
+     'headerFile': 'mozilla/dom/WorkerScope.h',
+     'implicitJSContext': [ 'close' ],
+ },
+ 
+ 'StreamFilter': {
+     'nativeType': 'mozilla::extensions::StreamFilter',
+ },
+diff --git a/dom/workers/RuntimeService.h b/dom/workers/RuntimeService.h
+--- a/dom/workers/RuntimeService.h
++++ b/dom/workers/RuntimeService.h
+@@ -14,19 +14,24 @@
+ #include "mozilla/dom/BindingDeclarations.h"
+ #include "nsClassHashtable.h"
+ #include "nsHashKeys.h"
+ #include "nsTArray.h"
+ 
+ class nsITimer;
+ class nsPIDOMWindowInner;
+ 
++namespace mozilla {
++namespace dom {
++class SharedWorker;
++}
++}
++
+ BEGIN_WORKERS_NAMESPACE
+ 
+-class SharedWorker;
+ struct WorkerLoadInfo;
+ class WorkerThread;
+ 
+ class RuntimeService final : public nsIObserver
+ {
+   struct SharedWorkerInfo
+   {
+     WorkerPrivate* mWorkerPrivate;
+diff --git a/dom/workers/SharedWorker.cpp b/dom/workers/SharedWorker.cpp
+--- a/dom/workers/SharedWorker.cpp
++++ b/dom/workers/SharedWorker.cpp
+@@ -24,18 +24,18 @@
+ #ifdef XP_WIN
+ #undef PostMessage
+ #endif
+ 
+ using mozilla::dom::Optional;
+ using mozilla::dom::Sequence;
+ using mozilla::dom::MessagePort;
+ using namespace mozilla;
+-
+-USING_WORKERS_NAMESPACE
++using namespace mozilla::dom;
++using namespace mozilla::dom::workers;
+ 
+ SharedWorker::SharedWorker(nsPIDOMWindowInner* aWindow,
+                            WorkerPrivate* aWorkerPrivate,
+                            MessagePort* aMessagePort)
+   : DOMEventTargetHelper(aWindow)
+   , mWorkerPrivate(aWorkerPrivate)
+   , mMessagePort(aMessagePort)
+   , mFrozen(false)
+diff --git a/dom/workers/SharedWorker.h b/dom/workers/SharedWorker.h
+--- a/dom/workers/SharedWorker.h
++++ b/dom/workers/SharedWorker.h
+@@ -20,32 +20,30 @@ class nsIDOMEvent;
+ class nsPIDOMWindowInner;
+ 
+ namespace mozilla {
+ class EventChainPreVisitor;
+ 
+ namespace dom {
+ class MessagePort;
+ class StringOrWorkerOptions;
+-}
+-} // namespace mozilla
+ 
+-BEGIN_WORKERS_NAMESPACE
+-
++namespace workers {
+ class RuntimeService;
+ class WorkerPrivate;
++}
+ 
+ class SharedWorker final : public DOMEventTargetHelper
+ {
+-  friend class RuntimeService;
++  friend class workers::RuntimeService;
+ 
+   typedef mozilla::ErrorResult ErrorResult;
+   typedef mozilla::dom::GlobalObject GlobalObject;
+ 
+-  RefPtr<WorkerPrivate> mWorkerPrivate;
++  RefPtr<workers::WorkerPrivate> mWorkerPrivate;
+   RefPtr<MessagePort> mMessagePort;
+   nsTArray<nsCOMPtr<nsIDOMEvent>> mFrozenEvents;
+   bool mFrozen;
+ 
+ public:
+   static already_AddRefed<SharedWorker>
+   Constructor(const GlobalObject& aGlobal, const nsAString& aScriptURL,
+               const StringOrWorkerOptions& aOptions, ErrorResult& aRv);
+@@ -77,32 +75,33 @@ public:
+   IMPL_EVENT_HANDLER(error)
+ 
+   virtual JSObject*
+   WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
+ 
+   virtual nsresult
+   GetEventTargetParent(EventChainPreVisitor& aVisitor) override;
+ 
+-  WorkerPrivate*
++  workers::WorkerPrivate*
+   GetWorkerPrivate() const
+   {
+     return mWorkerPrivate;
+   }
+ 
+ private:
+   // This class can only be created from the RuntimeService.
+   SharedWorker(nsPIDOMWindowInner* aWindow,
+-               WorkerPrivate* aWorkerPrivate,
++               workers::WorkerPrivate* aWorkerPrivate,
+                MessagePort* aMessagePort);
+ 
+   // This class is reference-counted and will be destroyed from Release().
+   ~SharedWorker();
+ 
+   // Only called by MessagePort.
+   void
+   PostMessage(JSContext* aCx, JS::Handle<JS::Value> aMessage,
+               const Sequence<JSObject*>& aTransferable, ErrorResult& aRv);
+ };
+ 
+-END_WORKERS_NAMESPACE
++} // dom namespace
++} // mozilla namespace
+ 
+ #endif // mozilla_dom_workers_sharedworker_h__
+diff --git a/dom/workers/WorkerPrivate.h b/dom/workers/WorkerPrivate.h
+--- a/dom/workers/WorkerPrivate.h
++++ b/dom/workers/WorkerPrivate.h
+@@ -31,27 +31,27 @@ namespace mozilla {
+ namespace dom {
+ 
+ class ClientInfo;
+ class ClientSource;
+ class Function;
+ class MessagePort;
+ class MessagePortIdentifier;
+ class PerformanceStorage;
++class SharedWorker;
+ class WorkerDebuggerGlobalScope;
+ class WorkerErrorReport;
+ class WorkerGlobalScope;
+ struct WorkerOptions;
+ 
+ } // dom namespace
+ } // mozilla namespace
+ 
+ BEGIN_WORKERS_NAMESPACE
+ 
+-class SharedWorker;
+ class WorkerControlRunnable;
+ class WorkerDebugger;
+ class WorkerEventTarget;
+ class WorkerRunnable;
+ class WorkerThread;
+ 
+ // SharedMutex is a small wrapper around an (internal) reference-counted Mutex
+ // object. It exists to avoid changing a lot of code to use Mutex* instead of
+diff --git a/dom/workers/moz.build b/dom/workers/moz.build
+--- a/dom/workers/moz.build
++++ b/dom/workers/moz.build
+@@ -4,16 +4,17 @@
+ # 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/.
+ 
+ with Files("**"):
+     BUG_COMPONENT = ("Core", "DOM: Workers")
+ 
+ # Public stuff.
+ EXPORTS.mozilla.dom += [
++    'SharedWorker.h',
+     'WorkerLocation.h',
+     'WorkerNavigator.h',
+     'WorkerPrivate.h',
+     'WorkerRunnable.h',
+     'WorkerScope.h',
+ ]
+ 
+ EXPORTS.mozilla.dom.workers += [
+@@ -21,17 +22,16 @@ EXPORTS.mozilla.dom.workers += [
+     'WorkerCommon.h',
+     'WorkerDebugger.h',
+     'WorkerDebuggerManager.h',
+     'WorkerLoadInfo.h',
+ ]
+ 
+ # Stuff needed for the bindings, not really public though.
+ EXPORTS.mozilla.dom.workers.bindings += [
+-    'SharedWorker.h',
+     'WorkerHolder.h',
+     'WorkerHolderToken.h',
+ ]
+ 
+ XPIDL_MODULE = 'dom_workers'
+ 
+ XPIDL_SOURCES += [
+     'nsIWorkerDebugger.idl',

+ 274 - 0
mozilla-release/patches/1432963-02-60a1.patch

@@ -0,0 +1,274 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1517383169 -3600
+# Node ID 5c06802f7ce455df5f539484af97c5bc063dc8f9
+# Parent  8fcdf974568dc973dc4b3f0c051a0841586ec2c9
+Bug 1432963 - Fixing workers headers - part 2 - Get rid of WorkerCrossThreadDispatcher and WorkerTask, r=smaug
+
+diff --git a/dom/workers/RuntimeService.cpp b/dom/workers/RuntimeService.cpp
+--- a/dom/workers/RuntimeService.cpp
++++ b/dom/workers/RuntimeService.cpp
+@@ -1198,48 +1198,16 @@ public:
+ 
+ private:
+   ~WorkerThreadPrimaryRunnable()
+   { }
+ 
+   NS_DECL_NSIRUNNABLE
+ };
+ 
+-class WorkerTaskRunnable final : public WorkerRunnable
+-{
+-  RefPtr<WorkerTask> mTask;
+-
+-public:
+-  WorkerTaskRunnable(WorkerPrivate* aWorkerPrivate, WorkerTask* aTask)
+-  : WorkerRunnable(aWorkerPrivate, WorkerThreadUnchangedBusyCount), mTask(aTask)
+-  {
+-    MOZ_ASSERT(aTask);
+-  }
+-
+-private:
+-  virtual bool
+-  PreDispatch(WorkerPrivate* aWorkerPrivate) override
+-  {
+-    // May be called on any thread!
+-    return true;
+-  }
+-
+-  virtual void
+-  PostDispatch(WorkerPrivate* aWorkerPrivate, bool aDispatchResult) override
+-  {
+-    // May be called on any thread!
+-  }
+-
+-  virtual bool
+-  WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate) override
+-  {
+-    return mTask->RunTask(aCx);
+-  }
+-};
+-
+ void
+ PrefLanguagesChanged(const char* /* aPrefName */, void* /* aClosure */)
+ {
+   AssertIsOnMainThread();
+ 
+   nsTArray<nsString> languages;
+   Navigator::GetAcceptLanguages(languages);
+ 
+@@ -1340,42 +1308,16 @@ ResumeWorkersForWindow(nsPIDOMWindowInne
+ {
+   AssertIsOnMainThread();
+   RuntimeService* runtime = RuntimeService::GetService();
+   if (runtime) {
+     runtime->ResumeWorkersForWindow(aWindow);
+   }
+ }
+ 
+-WorkerCrossThreadDispatcher::WorkerCrossThreadDispatcher(
+-                                                  WorkerPrivate* aWorkerPrivate)
+-: mMutex("WorkerCrossThreadDispatcher::mMutex"),
+-  mWorkerPrivate(aWorkerPrivate)
+-{
+-  MOZ_ASSERT(aWorkerPrivate);
+-}
+-
+-bool
+-WorkerCrossThreadDispatcher::PostTask(WorkerTask* aTask)
+-{
+-  MOZ_ASSERT(aTask);
+-
+-  MutexAutoLock lock(mMutex);
+-
+-  if (!mWorkerPrivate) {
+-    NS_WARNING("Posted a task to a WorkerCrossThreadDispatcher that is no "
+-               "longer accepting tasks!");
+-    return false;
+-  }
+-
+-  RefPtr<WorkerTaskRunnable> runnable =
+-    new WorkerTaskRunnable(mWorkerPrivate, aTask);
+-  return runnable->Dispatch();
+-}
+-
+ WorkerPrivate*
+ GetWorkerPrivateFromContext(JSContext* aCx)
+ {
+   MOZ_ASSERT(!NS_IsMainThread());
+   MOZ_ASSERT(aCx);
+ 
+   void* cxPrivate = JS_GetContextPrivate(aCx);
+   if (!cxPrivate) {
+diff --git a/dom/workers/WorkerCommon.h b/dom/workers/WorkerCommon.h
+--- a/dom/workers/WorkerCommon.h
++++ b/dom/workers/WorkerCommon.h
+@@ -178,68 +178,16 @@ void
+ ThawWorkersForWindow(nsPIDOMWindowInner* aWindow);
+ 
+ void
+ SuspendWorkersForWindow(nsPIDOMWindowInner* aWindow);
+ 
+ void
+ ResumeWorkersForWindow(nsPIDOMWindowInner* aWindow);
+ 
+-// A class that can be used with WorkerCrossThreadDispatcher to run a
+-// bit of C++ code on the worker thread.
+-class WorkerTask
+-{
+-protected:
+-  WorkerTask()
+-  { }
+-
+-  virtual ~WorkerTask()
+-  { }
+-
+-public:
+-  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(WorkerTask)
+-
+-  // The return value here has the same semantics as the return value
+-  // of WorkerRunnable::WorkerRun.
+-  virtual bool
+-  RunTask(JSContext* aCx) = 0;
+-};
+-
+-class WorkerCrossThreadDispatcher
+-{
+-   friend class WorkerPrivate;
+-
+-  // Must be acquired *before* the WorkerPrivate's mutex, when they're both
+-  // held.
+-  Mutex mMutex;
+-  WorkerPrivate* mWorkerPrivate;
+-
+-private:
+-  // Only created by WorkerPrivate.
+-  explicit WorkerCrossThreadDispatcher(WorkerPrivate* aWorkerPrivate);
+-
+-  // Only called by WorkerPrivate.
+-  void
+-  Forget()
+-  {
+-    MutexAutoLock lock(mMutex);
+-    mWorkerPrivate = nullptr;
+-  }
+-
+-  ~WorkerCrossThreadDispatcher() {}
+-
+-public:
+-  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(WorkerCrossThreadDispatcher)
+-
+-  // Generically useful function for running a bit of C++ code on the worker
+-  // thread.
+-  bool
+-  PostTask(WorkerTask* aTask);
+-};
+-
+ // Random unique constant to facilitate JSPrincipal debugging
+ const uint32_t kJSPrincipalsDebugToken = 0x7e2df9d2;
+ 
+ bool
+ IsWorkerGlobal(JSObject* global);
+ 
+ bool
+ IsDebuggerGlobal(JSObject* global);
+diff --git a/dom/workers/WorkerPrivate.cpp b/dom/workers/WorkerPrivate.cpp
+--- a/dom/workers/WorkerPrivate.cpp
++++ b/dom/workers/WorkerPrivate.cpp
+@@ -4953,25 +4953,16 @@ WorkerPrivate::NotifyInternal(JSContext*
+ 
+     // Mark parent status as closing immediately to avoid new events being
+     // dispatched after we clear the queue below.
+     if (aStatus == Closing) {
+       Close();
+     }
+   }
+ 
+-  if (mCrossThreadDispatcher) {
+-    // Since we'll no longer process events, make sure we no longer allow
+-    // anyone to post them. We have to do this without mMutex held, since our
+-    // mutex must be acquired *after* mCrossThreadDispatcher's mutex when
+-    // they're both held.
+-    mCrossThreadDispatcher->Forget();
+-    mCrossThreadDispatcher = nullptr;
+-  }
+-
+   MOZ_ASSERT(previousStatus != Pending);
+ 
+   // Let all our holders know the new status.
+   NotifyHolders(aCx, aStatus);
+   MOZ_ASSERT(!JS_IsExceptionPending(aCx));
+ 
+   // If this is the first time our status has changed then we need to clear the
+   // main event queue.
+@@ -5556,28 +5547,16 @@ WorkerPrivate::SetThread(WorkerThread* a
+ 
+       mThread->SetWorker(friendKey, nullptr);
+ 
+       mThread.swap(doomedThread);
+     }
+   }
+ }
+ 
+-WorkerCrossThreadDispatcher*
+-WorkerPrivate::GetCrossThreadDispatcher()
+-{
+-  MutexAutoLock lock(mMutex);
+-
+-  if (!mCrossThreadDispatcher && mStatus <= Running) {
+-    mCrossThreadDispatcher = new WorkerCrossThreadDispatcher(this);
+-  }
+-
+-  return mCrossThreadDispatcher;
+-}
+-
+ void
+ WorkerPrivate::BeginCTypesCall()
+ {
+   AssertIsOnWorkerThread();
+ 
+   // Don't try to GC while we're blocked in a ctypes call.
+   SetGCTimerMode(NoTimer);
+ }
+diff --git a/dom/workers/WorkerPrivate.h b/dom/workers/WorkerPrivate.h
+--- a/dom/workers/WorkerPrivate.h
++++ b/dom/workers/WorkerPrivate.h
+@@ -895,18 +895,16 @@ class WorkerPrivate : public WorkerPriva
+   bool mDebuggerRegistered;
+   WorkerDebugger* mDebugger;
+ 
+   Queue<WorkerControlRunnable*, 4> mControlQueue;
+   Queue<WorkerRunnable*, 4> mDebuggerQueue;
+ 
+   // Touched on multiple threads, protected with mMutex.
+   JSContext* mJSContext;
+-  RefPtr<WorkerCrossThreadDispatcher> mCrossThreadDispatcher;
+-  nsTArray<nsCOMPtr<nsIRunnable>> mUndispatchedRunnablesForSyncLoop;
+   RefPtr<WorkerThread> mThread;
+   PRThread* mPRThread;
+ 
+   // Things touched on worker thread only.
+   RefPtr<WorkerGlobalScope> mScope;
+   RefPtr<WorkerDebuggerGlobalScope> mDebuggerScope;
+   nsTArray<ParentType*> mChildWorkers;
+   nsTObserverArray<WorkerHolder*> mHolders;
+@@ -1243,19 +1241,16 @@ public:
+   void
+   AssertIsOnWorkerThread() const
+ #ifdef DEBUG
+   ;
+ #else
+   { }
+ #endif
+ 
+-  WorkerCrossThreadDispatcher*
+-  GetCrossThreadDispatcher();
+-
+   // This may block!
+   void
+   BeginCTypesCall();
+ 
+   // This may block!
+   void
+   EndCTypesCall();
+ 

+ 312 - 0
mozilla-release/patches/1432963-03-60a1.patch

@@ -0,0 +1,312 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1517383191 -3600
+# Node ID d3c3ec4cbe7820c2b5370504ed1377eb260d5e1e
+# Parent  1080be0af8db81282c6c339cccc2be150f477687
+Bug 1432963 - Fixing workers headers - part 3 - WorkerError and WorkerPrincipal without workers namespace, r=smaug
+
+diff --git a/dom/workers/Principal.cpp b/dom/workers/Principal.cpp
+--- a/dom/workers/Principal.cpp
++++ b/dom/workers/Principal.cpp
+@@ -4,17 +4,18 @@
+  * 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 "Principal.h"
+ 
+ #include "jsapi.h"
+ #include "mozilla/Assertions.h"
+ 
+-BEGIN_WORKERS_NAMESPACE
++namespace mozilla {
++namespace dom {
+ 
+ struct WorkerPrincipal final : public JSPrincipals
+ {
+   bool write(JSContext* aCx, JSStructuredCloneWriter* aWriter) override {
+     MOZ_CRASH("WorkerPrincipal::write not implemented");
+     return false;
+   }
+ };
+@@ -43,9 +44,10 @@ GetWorkerPrincipal()
+ }
+ 
+ void
+ DestroyWorkerPrincipals(JSPrincipals* aPrincipals)
+ {
+   MOZ_ASSERT_UNREACHABLE("Worker principals refcount should never fall below one");
+ }
+ 
+-END_WORKERS_NAMESPACE
++} // dom namespace
++} // mozilla namespace
+diff --git a/dom/workers/Principal.h b/dom/workers/Principal.h
+--- a/dom/workers/Principal.h
++++ b/dom/workers/Principal.h
+@@ -4,19 +4,21 @@
+  * 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/. */
+ 
+ #ifndef mozilla_dom_workers_principal_h__
+ #define mozilla_dom_workers_principal_h__
+ 
+ #include "WorkerCommon.h"
+ 
+-BEGIN_WORKERS_NAMESPACE
++namespace mozilla {
++namespace dom {
+ 
+ JSPrincipals*
+ GetWorkerPrincipal();
+ 
+ void
+ DestroyWorkerPrincipals(JSPrincipals* aPrincipals);
+ 
+-END_WORKERS_NAMESPACE
++} // dom namespace
++} // mozilla namespace
+ 
+ #endif /* mozilla_dom_workers_principal_h__ */
+diff --git a/dom/workers/WorkerDebugger.cpp b/dom/workers/WorkerDebugger.cpp
+--- a/dom/workers/WorkerDebugger.cpp
++++ b/dom/workers/WorkerDebugger.cpp
+@@ -464,15 +464,15 @@ WorkerDebugger::ReportErrorToDebuggerOnM
+   nsTArray<nsCOMPtr<nsIWorkerDebuggerListener>> listeners(mListeners);
+   for (size_t index = 0; index < listeners.Length(); ++index) {
+     listeners[index]->OnError(aFilename, aLineno, aMessage);
+   }
+ 
+   WorkerErrorReport report;
+   report.mMessage = aMessage;
+   report.mFilename = aFilename;
+-  LogErrorToConsole(report, 0);
++  WorkerErrorReport::LogErrorToConsole(report, 0);
+ }
+ 
+ 
+ } // worker namespace
+ } // dom namespace
+ } // mozilla namespace
+diff --git a/dom/workers/WorkerError.cpp b/dom/workers/WorkerError.cpp
+--- a/dom/workers/WorkerError.cpp
++++ b/dom/workers/WorkerError.cpp
+@@ -152,17 +152,17 @@ public:
+     if (aWorkerPrivate) {
+       RefPtr<ReportErrorRunnable> runnable =
+         new ReportErrorRunnable(aWorkerPrivate, aReport);
+       runnable->Dispatch();
+       return;
+     }
+ 
+     // Otherwise log an error to the error console.
+-    LogErrorToConsole(aReport, aInnerWindowId);
++    WorkerErrorReport::LogErrorToConsole(aReport, aInnerWindowId);
+   }
+ 
+   ReportErrorRunnable(WorkerPrivate* aWorkerPrivate,
+                       const WorkerErrorReport& aReport)
+   : WorkerRunnable(aWorkerPrivate, ParentThreadUnchangedBusyCount),
+     mReport(aReport)
+   { }
+ 
+@@ -282,26 +282,25 @@ WorkerErrorReport::AssignErrorReport(JSE
+     size_t i = 0;
+     for (auto&& note : *aReport->notes) {
+       mNotes.ElementAt(i).AssignErrorNote(note.get());
+       i++;
+     }
+   }
+ }
+ 
+-namespace workers {
+-
+ // aWorkerPrivate is the worker thread we're on (or the main thread, if null)
+ // aTarget is the worker object that we are going to fire an error at
+ // (if any).
+-void
+-ReportError(JSContext* aCx, WorkerPrivate* aWorkerPrivate,
+-            bool aFireAtScope, DOMEventTargetHelper* aTarget,
+-            const WorkerErrorReport& aReport, uint64_t aInnerWindowId,
+-            JS::Handle<JS::Value> aException)
++/* static */ void
++WorkerErrorReport::ReportError(JSContext* aCx, WorkerPrivate* aWorkerPrivate,
++                               bool aFireAtScope, DOMEventTargetHelper* aTarget,
++                               const WorkerErrorReport& aReport,
++                               uint64_t aInnerWindowId,
++                               JS::Handle<JS::Value> aException)
+ {
+   if (aWorkerPrivate) {
+     aWorkerPrivate->AssertIsOnWorkerThread();
+   } else {
+     AssertIsOnMainThread();
+   }
+ 
+   // We should not fire error events for warnings but instead make sure that
+@@ -409,21 +408,22 @@ ReportError(JSContext* aCx, WorkerPrivat
+   if (aWorkerPrivate) {
+     RefPtr<ReportErrorRunnable> runnable =
+       new ReportErrorRunnable(aWorkerPrivate, aReport);
+     runnable->Dispatch();
+     return;
+   }
+ 
+   // Otherwise log an error to the error console.
+-  LogErrorToConsole(aReport, aInnerWindowId);
++  WorkerErrorReport::LogErrorToConsole(aReport, aInnerWindowId);
+ }
+ 
+-void
+-LogErrorToConsole(const WorkerErrorReport& aReport, uint64_t aInnerWindowId)
++/* static */ void
++WorkerErrorReport::LogErrorToConsole(const WorkerErrorReport& aReport,
++                                     uint64_t aInnerWindowId)
+ {
+   AssertIsOnMainThread();
+ 
+   RefPtr<nsScriptErrorBase> scriptError = new nsScriptError();
+   NS_WARNING_ASSERTION(scriptError, "Failed to create script error!");
+ 
+   if (scriptError) {
+     nsAutoCString category("Web Worker");
+@@ -475,11 +475,10 @@ LogErrorToConsole(const WorkerErrorRepor
+   __android_log_print(ANDROID_LOG_INFO, "Gecko", kErrorString, msg.get(),
+                       filename.get(), aReport.mLineNumber);
+ #endif
+ 
+   fprintf(stderr, kErrorString, msg.get(), filename.get(), aReport.mLineNumber);
+   fflush(stderr);
+ }
+ 
+-} // workers namespace
+ } // dom namespace
+ } // mozilla namespace
+diff --git a/dom/workers/WorkerError.h b/dom/workers/WorkerError.h
+--- a/dom/workers/WorkerError.h
++++ b/dom/workers/WorkerError.h
+@@ -35,48 +35,47 @@ public:
+ };
+ 
+ class WorkerErrorNote : public WorkerErrorBase
+ {
+ public:
+   void AssignErrorNote(JSErrorNotes::Note* aNote);
+ };
+ 
++namespace workers {
++class WorkerPrivate;
++}
++
+ class WorkerErrorReport : public WorkerErrorBase
+ {
+ public:
+   nsString mLine;
+   uint32_t mFlags;
+   JSExnType mExnType;
+   bool mMutedError;
+   nsTArray<WorkerErrorNote> mNotes;
+ 
+   WorkerErrorReport()
+   : mFlags(0),
+     mExnType(JSEXN_ERR),
+     mMutedError(false)
+   { }
+ 
+   void AssignErrorReport(JSErrorReport* aReport);
++
++  // aWorkerPrivate is the worker thread we're on (or the main thread, if null)
++  // aTarget is the worker object that we are going to fire an error at
++  // (if any).
++  static void
++  ReportError(JSContext* aCx, workers::WorkerPrivate* aWorkerPrivate,
++              bool aFireAtScope, DOMEventTargetHelper* aTarget,
++              const WorkerErrorReport& aReport, uint64_t aInnerWindowId,
++              JS::Handle<JS::Value> aException = JS::NullHandleValue);
++
++  static void
++  LogErrorToConsole(const WorkerErrorReport& aReport, uint64_t aInnerWindowId);
++
+ };
+ 
+ } // dom namespace
+ } // mozilla namespace
+ 
+-BEGIN_WORKERS_NAMESPACE
+-
+-class WorkerPrivate;
+-
+-// aWorkerPrivate is the worker thread we're on (or the main thread, if null)
+-// aTarget is the worker object that we are going to fire an error at
+-// (if any).
+-void
+-ReportError(JSContext* aCx, WorkerPrivate* aWorkerPrivate,
+-            bool aFireAtScope, DOMEventTargetHelper* aTarget,
+-            const WorkerErrorReport& aReport, uint64_t aInnerWindowId,
+-            JS::Handle<JS::Value> aException = JS::NullHandleValue);
+-
+-void
+-LogErrorToConsole(const WorkerErrorReport& aReport, uint64_t aInnerWindowId);
+-
+-END_WORKERS_NAMESPACE
+-
+ #endif // mozilla_dom_workers_WorkerError_h
+diff --git a/dom/workers/WorkerPrivate.cpp b/dom/workers/WorkerPrivate.cpp
+--- a/dom/workers/WorkerPrivate.cpp
++++ b/dom/workers/WorkerPrivate.cpp
+@@ -2607,17 +2607,17 @@ WorkerPrivateParent<Derived>::BroadcastE
+                                                     bool aIsErrorEvent)
+ {
+   AssertIsOnMainThread();
+ 
+   if (aIsErrorEvent && JSREPORT_IS_WARNING(aReport->mFlags)) {
+     // Don't fire any events anywhere.  Just log to console.
+     // XXXbz should we log to all the consoles of all the relevant windows?
+     MOZ_ASSERT(aReport);
+-    LogErrorToConsole(*aReport, 0);
++    WorkerErrorReport::LogErrorToConsole(*aReport, 0);
+     return;
+   }
+ 
+   AutoTArray<RefPtr<SharedWorker>, 10> sharedWorkers;
+   GetAllSharedWorkers(sharedWorkers);
+ 
+   if (sharedWorkers.IsEmpty()) {
+     return;
+@@ -2726,17 +2726,17 @@ WorkerPrivateParent<Derived>::BroadcastE
+     if (status == nsEventStatus_eConsumeNoDefault) {
+       shouldLogErrorToConsole = false;
+     }
+   }
+ 
+   // Finally log a warning in the console if no window tried to prevent it.
+   if (shouldLogErrorToConsole) {
+     MOZ_ASSERT(aReport);
+-    LogErrorToConsole(*aReport, 0);
++    WorkerErrorReport::LogErrorToConsole(*aReport, 0);
+   }
+ }
+ 
+ template <class Derived>
+ void
+ WorkerPrivateParent<Derived>::GetAllSharedWorkers(
+                                nsTArray<RefPtr<SharedWorker>>& aSharedWorkers)
+ {
+@@ -5044,17 +5044,18 @@ WorkerPrivate::ReportError(JSContext* aC
+   mErrorHandlerRecursionCount++;
+ 
+   // Don't want to run the scope's error handler if this is a recursive error or
+   // if we ran out of memory.
+   bool fireAtScope = mErrorHandlerRecursionCount == 1 &&
+                      report.mErrorNumber != JSMSG_OUT_OF_MEMORY &&
+                      JS::CurrentGlobalOrNull(aCx);
+ 
+-  workers::ReportError(aCx, this, fireAtScope, nullptr, report, 0, exn);
++  WorkerErrorReport::ReportError(aCx, this, fireAtScope, nullptr, report, 0,
++                                 exn);
+ 
+   mErrorHandlerRecursionCount--;
+ }
+ 
+ // static
+ void
+ WorkerPrivate::ReportErrorToConsole(const char* aMessage)
+ {

+ 220 - 0
mozilla-release/patches/1432963-04-60a1.patch

@@ -0,0 +1,220 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1517383207 -3600
+# Node ID a8f2bea31ba98fa456e56365a0e6250490009ab1
+# Parent  e0e36f198751c54c3c5cf10e4a5c40086b96d906
+Bug 1432963 - Fixing workers headers - part 4 - WorkerThread without workers namespace, r=smaug
+
+diff --git a/dom/workers/RuntimeService.h b/dom/workers/RuntimeService.h
+--- a/dom/workers/RuntimeService.h
++++ b/dom/workers/RuntimeService.h
+@@ -17,23 +17,23 @@
+ #include "nsTArray.h"
+ 
+ class nsITimer;
+ class nsPIDOMWindowInner;
+ 
+ namespace mozilla {
+ namespace dom {
+ class SharedWorker;
++class WorkerThread;
+ }
+ }
+ 
+ BEGIN_WORKERS_NAMESPACE
+ 
+ struct WorkerLoadInfo;
+-class WorkerThread;
+ 
+ class RuntimeService final : public nsIObserver
+ {
+   struct SharedWorkerInfo
+   {
+     WorkerPrivate* mWorkerPrivate;
+     nsCString mScriptSpec;
+     nsString mName;
+diff --git a/dom/workers/WorkerPrivate.h b/dom/workers/WorkerPrivate.h
+--- a/dom/workers/WorkerPrivate.h
++++ b/dom/workers/WorkerPrivate.h
+@@ -36,27 +36,27 @@ class Function;
+ class MessagePort;
+ class MessagePortIdentifier;
+ class PerformanceStorage;
+ class SharedWorker;
+ class WorkerDebuggerGlobalScope;
+ class WorkerErrorReport;
+ class WorkerGlobalScope;
+ struct WorkerOptions;
++class WorkerThread;
+ 
+ } // dom namespace
+ } // mozilla namespace
+ 
+ BEGIN_WORKERS_NAMESPACE
+ 
+ class WorkerControlRunnable;
+ class WorkerDebugger;
+ class WorkerEventTarget;
+ class WorkerRunnable;
+-class WorkerThread;
+ 
+ // SharedMutex is a small wrapper around an (internal) reference-counted Mutex
+ // object. It exists to avoid changing a lot of code to use Mutex* instead of
+ // Mutex&.
+ class SharedMutex
+ {
+   typedef mozilla::Mutex Mutex;
+ 
+@@ -878,17 +878,17 @@ class WorkerPrivate : public WorkerPriva
+   typedef WorkerPrivateParent<WorkerPrivate> ParentType;
+   friend class AutoSyncLoopHolder;
+ 
+   struct TimeoutInfo;
+ 
+   class MemoryReporter;
+   friend class MemoryReporter;
+ 
+-  friend class WorkerThread;
++  friend class mozilla::dom::WorkerThread;
+ 
+   enum GCTimerMode
+   {
+     PeriodicTimer = 0,
+     IdleTimer,
+     NoTimer
+   };
+ 
+diff --git a/dom/workers/WorkerThread.cpp b/dom/workers/WorkerThread.cpp
+--- a/dom/workers/WorkerThread.cpp
++++ b/dom/workers/WorkerThread.cpp
+@@ -15,18 +15,18 @@
+ #include "WorkerRunnable.h"
+ 
+ #ifdef DEBUG
+ #include "nsThreadManager.h"
+ #endif
+ 
+ namespace mozilla {
+ namespace dom {
+-namespace workers {
+ 
++using namespace workers;
+ using namespace mozilla::ipc;
+ 
+ namespace {
+ 
+ // The C stack size. We use the same stack size on all platforms for
+ // consistency.
+ const uint32_t kWorkerStackSize = 256 * sizeof(size_t) * 1024;
+ 
+@@ -351,11 +351,10 @@ WorkerThread::Observer::AfterProcessNext
+                                               bool /* aEventWasProcessed */)
+ {
+   mWorkerPrivate->AssertIsOnWorkerThread();
+ 
+   mWorkerPrivate->AfterProcessNextEvent();
+   return NS_OK;
+ }
+ 
+-} // namespace workers
+ } // namespace dom
+ } // namespace mozilla
+diff --git a/dom/workers/WorkerThread.h b/dom/workers/WorkerThread.h
+--- a/dom/workers/WorkerThread.h
++++ b/dom/workers/WorkerThread.h
+@@ -13,46 +13,47 @@
+ #include "nsISupportsImpl.h"
+ #include "mozilla/RefPtr.h"
+ #include "nsThread.h"
+ 
+ class nsIRunnable;
+ 
+ namespace mozilla {
+ namespace dom {
++
+ namespace workers {
+-
+ class RuntimeService;
+ class WorkerPrivate;
+ template <class> class WorkerPrivateParent;
+ class WorkerRunnable;
++}
+ 
+ // This class lets us restrict the public methods that can be called on
+ // WorkerThread to RuntimeService and WorkerPrivate without letting them gain
+ // full access to private methods (as would happen if they were simply friends).
+ class WorkerThreadFriendKey
+ {
+-  friend class RuntimeService;
+-  friend class WorkerPrivate;
+-  friend class WorkerPrivateParent<WorkerPrivate>;
++  friend class workers::RuntimeService;
++  friend class workers::WorkerPrivate;
++  friend class workers::WorkerPrivateParent<workers::WorkerPrivate>;
+ 
+   WorkerThreadFriendKey();
+   ~WorkerThreadFriendKey();
+ };
+ 
+ class WorkerThread final
+   : public nsThread
+ {
+   class Observer;
+ 
+   Mutex mLock;
+   CondVar mWorkerPrivateCondVar;
+ 
+   // Protected by nsThread::mLock.
+-  WorkerPrivate* mWorkerPrivate;
++  workers::WorkerPrivate* mWorkerPrivate;
+ 
+   // Only touched on the target thread.
+   RefPtr<Observer> mObserver;
+ 
+   // Protected by nsThread::mLock and waited on with mWorkerPrivateCondVar.
+   uint32_t mOtherThreadsDispatchingViaEventTarget;
+ 
+ #ifdef DEBUG
+@@ -60,25 +61,26 @@ class WorkerThread final
+   bool mAcceptingNonWorkerRunnables;
+ #endif
+ 
+ public:
+   static already_AddRefed<WorkerThread>
+   Create(const WorkerThreadFriendKey& aKey);
+ 
+   void
+-  SetWorker(const WorkerThreadFriendKey& aKey, WorkerPrivate* aWorkerPrivate);
++  SetWorker(const WorkerThreadFriendKey& aKey,
++            workers::WorkerPrivate* aWorkerPrivate);
+ 
+   nsresult
+   DispatchPrimaryRunnable(const WorkerThreadFriendKey& aKey,
+                           already_AddRefed<nsIRunnable> aRunnable);
+ 
+   nsresult
+   DispatchAnyThread(const WorkerThreadFriendKey& aKey,
+-           already_AddRefed<WorkerRunnable> aWorkerRunnable);
++           already_AddRefed<workers::WorkerRunnable> aWorkerRunnable);
+ 
+   uint32_t
+   RecursionDepth(const WorkerThreadFriendKey& aKey) const;
+ 
+   NS_DECL_ISUPPORTS_INHERITED
+ 
+ private:
+   WorkerThread();
+@@ -91,13 +93,12 @@ private:
+ 
+   NS_IMETHOD
+   DispatchFromScript(nsIRunnable* aRunnable, uint32_t aFlags) override;
+ 
+   NS_IMETHOD
+   DelayedDispatch(already_AddRefed<nsIRunnable>, uint32_t) override;
+ };
+ 
+-} // namespace workers
+ } // namespace dom
+ } // namespace mozilla
+ 
+ #endif // mozilla_dom_workers_WorkerThread_h__

+ 551 - 0
mozilla-release/patches/1432963-05-60a1.patch

@@ -0,0 +1,551 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1517383225 -3600
+# Node ID 89714cb6e883b06aba04d3572238c97933002228
+# Parent  5765953ba9b4925aab4add6449d4e363c613cd3d
+Bug 1432963 - Fixing workers headers - part 5 - WorkerEventTarget in a separate file, r=smaug
+
+diff --git a/dom/workers/WorkerEventTarget.cpp b/dom/workers/WorkerEventTarget.cpp
+new file mode 100644
+--- /dev/null
++++ b/dom/workers/WorkerEventTarget.cpp
+@@ -0,0 +1,160 @@
++/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
++/* vim: set ts=8 sts=2 et sw=2 tw=80: */
++/* 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 "WorkerEventTarget.h"
++
++namespace mozilla {
++namespace dom {
++
++using namespace workers;
++
++namespace {
++
++class WrappedControlRunnable final : public WorkerControlRunnable
++{
++  nsCOMPtr<nsIRunnable> mInner;
++
++  ~WrappedControlRunnable()
++  {
++  }
++
++public:
++  WrappedControlRunnable(WorkerPrivate* aWorkerPrivate,
++                         already_AddRefed<nsIRunnable>&& aInner)
++    : WorkerControlRunnable(aWorkerPrivate, WorkerThreadUnchangedBusyCount)
++    , mInner(aInner)
++  {
++  }
++
++  virtual bool
++  PreDispatch(WorkerPrivate* aWorkerPrivate) override
++  {
++    // Silence bad assertions, this can be dispatched from any thread.
++    return true;
++  }
++
++  virtual void
++  PostDispatch(WorkerPrivate* aWorkerPrivate, bool aDispatchResult) override
++  {
++    // Silence bad assertions, this can be dispatched from any thread.
++  }
++
++  bool
++  WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate) override
++  {
++    mInner->Run();
++    return true;
++  }
++
++  nsresult
++  Cancel() override
++  {
++    nsCOMPtr<nsICancelableRunnable> cr = do_QueryInterface(mInner);
++
++    // If the inner runnable is not cancellable, then just do the normal
++    // WorkerControlRunnable thing.  This will end up calling Run().
++    if (!cr) {
++      WorkerControlRunnable::Cancel();
++      return NS_OK;
++    }
++
++    // Otherwise call the inner runnable's Cancel() and treat this like
++    // a WorkerRunnable cancel.  We can't call WorkerControlRunnable::Cancel()
++    // in this case since that would result in both Run() and the inner
++    // Cancel() being called.
++    Unused << cr->Cancel();
++    return WorkerRunnable::Cancel();
++  }
++};
++
++} // anonymous namespace
++
++NS_IMPL_ISUPPORTS(WorkerEventTarget, nsIEventTarget, nsISerialEventTarget)
++
++WorkerEventTarget::WorkerEventTarget(WorkerPrivate* aWorkerPrivate,
++                                    Behavior aBehavior)
++  : mMutex("WorkerEventTarget")
++  , mWorkerPrivate(aWorkerPrivate)
++  , mBehavior(aBehavior)
++{
++  MOZ_DIAGNOSTIC_ASSERT(mWorkerPrivate);
++}
++
++void
++WorkerEventTarget::ForgetWorkerPrivate(WorkerPrivate* aWorkerPrivate)
++{
++  MutexAutoLock lock(mMutex);
++  MOZ_DIAGNOSTIC_ASSERT(!mWorkerPrivate || mWorkerPrivate == aWorkerPrivate);
++  mWorkerPrivate = nullptr;
++}
++
++NS_IMETHODIMP
++WorkerEventTarget::DispatchFromScript(nsIRunnable* aRunnable,
++                                      uint32_t aFlags)
++{
++  nsCOMPtr<nsIRunnable> runnable(aRunnable);
++  return Dispatch(runnable.forget(), aFlags);
++}
++
++NS_IMETHODIMP
++WorkerEventTarget::Dispatch(already_AddRefed<nsIRunnable> aRunnable,
++                            uint32_t aFlags)
++{
++  MutexAutoLock lock(mMutex);
++
++  if (!mWorkerPrivate) {
++    return NS_ERROR_FAILURE;
++  }
++
++  nsCOMPtr<nsIRunnable> runnable(aRunnable);
++
++  if (mBehavior == Behavior::Hybrid) {
++    RefPtr<WorkerRunnable> r =
++      mWorkerPrivate->MaybeWrapAsWorkerRunnable(runnable.forget());
++    if (r->Dispatch()) {
++      return NS_OK;
++    }
++
++    runnable = r.forget();
++  }
++
++  RefPtr<WorkerControlRunnable> r =
++    new WrappedControlRunnable(mWorkerPrivate, runnable.forget());
++  if (!r->Dispatch()) {
++    return NS_ERROR_FAILURE;
++  }
++
++  return NS_OK;
++}
++
++NS_IMETHODIMP
++WorkerEventTarget::DelayedDispatch(already_AddRefed<nsIRunnable>, uint32_t)
++{
++  return NS_ERROR_NOT_IMPLEMENTED;
++}
++
++NS_IMETHODIMP_(bool)
++WorkerEventTarget::IsOnCurrentThreadInfallible()
++{
++  MutexAutoLock lock(mMutex);
++
++  if (!mWorkerPrivate) {
++    return false;
++  }
++
++  return mWorkerPrivate->IsOnCurrentThread();
++}
++
++NS_IMETHODIMP
++WorkerEventTarget::IsOnCurrentThread(bool* aIsOnCurrentThread)
++{
++  MOZ_ASSERT(aIsOnCurrentThread);
++  *aIsOnCurrentThread = IsOnCurrentThreadInfallible();
++  return NS_OK;
++}
++
++} // dom namespace
++} // mozilla namespace
+diff --git a/dom/workers/WorkerEventTarget.h b/dom/workers/WorkerEventTarget.h
+new file mode 100644
+--- /dev/null
++++ b/dom/workers/WorkerEventTarget.h
+@@ -0,0 +1,59 @@
++/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
++/* vim: set ts=8 sts=2 et sw=2 tw=80: */
++/* 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/. */
++
++#ifndef mozilla_dom_WorkerEventTarget_h
++#define mozilla_dom_WorkerEventTarget_h
++
++#include "nsISerialEventTarget.h"
++#include "mozilla/Mutex.h"
++
++namespace mozilla {
++namespace dom {
++
++namespace workers {
++class WorkerPrivate;
++}
++
++class WorkerEventTarget final : public nsISerialEventTarget
++{
++public:
++  // The WorkerEventTarget supports different dispatch behaviors:
++  //
++  // * Hybrid targets will attempt to dispatch as a normal runnable,
++  //   but fallback to a control runnable if that fails.  This is
++  //   often necessary for code that wants normal dispatch order, but
++  //   also needs to execute while the worker is shutting down (possibly
++  //   with a holder in place.)
++  //
++  // * ControlOnly targets will simply dispatch a control runnable.
++  enum class Behavior : uint8_t {
++    Hybrid,
++    ControlOnly
++  };
++
++private:
++  mozilla::Mutex mMutex;
++  workers::WorkerPrivate* mWorkerPrivate;
++  const Behavior mBehavior;
++
++  ~WorkerEventTarget() = default;
++
++public:
++  WorkerEventTarget(workers::WorkerPrivate* aWorkerPrivate,
++                    Behavior aBehavior);
++
++  void
++  ForgetWorkerPrivate(workers::WorkerPrivate* aWorkerPrivate);
++
++  NS_DECL_THREADSAFE_ISUPPORTS
++  NS_DECL_NSIEVENTTARGET
++  NS_DECL_NSISERIALEVENTTARGET
++};
++
++} // dom namespace
++} // mozilla namespace
++
++#endif // mozilla_dom_WorkerEventTarget_h
+diff --git a/dom/workers/WorkerPrivate.cpp b/dom/workers/WorkerPrivate.cpp
+--- a/dom/workers/WorkerPrivate.cpp
++++ b/dom/workers/WorkerPrivate.cpp
+@@ -22,16 +22,17 @@
+ #include "mozilla/dom/MessageEvent.h"
+ #include "mozilla/dom/MessageEventBinding.h"
+ #include "mozilla/dom/MessagePort.h"
+ #include "mozilla/dom/MessagePortBinding.h"
+ #include "mozilla/dom/nsCSPUtils.h"
+ #include "mozilla/dom/Performance.h"
+ #include "mozilla/dom/PerformanceStorageWorker.h"
+ #include "mozilla/dom/PromiseDebugging.h"
++#include "mozilla/dom/WorkerBinding.h"
+ #include "mozilla/ThreadEventQueue.h"
+ #include "mozilla/ThrottledEventQueue.h"
+ #include "mozilla/TimelineConsumers.h"
+ #include "mozilla/WorkerTimelineMarker.h"
+ #include "nsCycleCollector.h"
+ #include "nsNetUtil.h"
+ #include "nsIMemoryReporter.h"
+ #include "nsIPermissionManager.h"
+@@ -47,16 +48,17 @@
+ #include "RuntimeService.h"
+ #include "ScriptLoader.h"
+ #include "mozilla/dom/ServiceWorkerEvents.h"
+ #include "mozilla/dom/ServiceWorkerManager.h"
+ #include "SharedWorker.h"
+ #include "WorkerDebugger.h"
+ #include "WorkerDebuggerManager.h"
+ #include "WorkerError.h"
++#include "WorkerEventTarget.h"
+ #include "WorkerNavigator.h"
+ #include "WorkerRunnable.h"
+ #include "WorkerScope.h"
+ #include "WorkerThread.h"
+ 
+ #ifdef DEBUG
+ #include "nsThreadManager.h"
+ #endif
+@@ -968,190 +970,16 @@ public:
+ 
+   virtual bool Notify(Status aStatus) override { return true; }
+ };
+ 
+ } /* anonymous namespace */
+ 
+ NS_IMPL_ISUPPORTS_INHERITED0(TopLevelWorkerFinishedRunnable, Runnable)
+ 
+-namespace {
+-
+-class WrappedControlRunnable final : public WorkerControlRunnable
+-{
+-  nsCOMPtr<nsIRunnable> mInner;
+-
+-  ~WrappedControlRunnable()
+-  {
+-  }
+-
+-public:
+-  WrappedControlRunnable(WorkerPrivate* aWorkerPrivate,
+-                         already_AddRefed<nsIRunnable>&& aInner)
+-    : WorkerControlRunnable(aWorkerPrivate, WorkerThreadUnchangedBusyCount)
+-    , mInner(aInner)
+-  {
+-  }
+-
+-  virtual bool
+-  PreDispatch(WorkerPrivate* aWorkerPrivate) override
+-  {
+-    // Silence bad assertions, this can be dispatched from any thread.
+-    return true;
+-  }
+-
+-  virtual void
+-  PostDispatch(WorkerPrivate* aWorkerPrivate, bool aDispatchResult) override
+-  {
+-    // Silence bad assertions, this can be dispatched from any thread.
+-  }
+-
+-  bool
+-  WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate) override
+-  {
+-    mInner->Run();
+-    return true;
+-  }
+-
+-  nsresult
+-  Cancel() override
+-  {
+-    nsCOMPtr<nsICancelableRunnable> cr = do_QueryInterface(mInner);
+-
+-    // If the inner runnable is not cancellable, then just do the normal
+-    // WorkerControlRunnable thing.  This will end up calling Run().
+-    if (!cr) {
+-      WorkerControlRunnable::Cancel();
+-      return NS_OK;
+-    }
+-
+-    // Otherwise call the inner runnable's Cancel() and treat this like
+-    // a WorkerRunnable cancel.  We can't call WorkerControlRunnable::Cancel()
+-    // in this case since that would result in both Run() and the inner
+-    // Cancel() being called.
+-    Unused << cr->Cancel();
+-    return WorkerRunnable::Cancel();
+-  }
+-};
+-
+-} // anonymous namespace
+-
+-BEGIN_WORKERS_NAMESPACE
+-
+-class WorkerEventTarget final : public nsISerialEventTarget
+-{
+-public:
+-  // The WorkerEventTarget supports different dispatch behaviors:
+-  //
+-  // * Hybrid targets will attempt to dispatch as a normal runnable,
+-  //   but fallback to a control runnable if that fails.  This is
+-  //   often necessary for code that wants normal dispatch order, but
+-  //   also needs to execute while the worker is shutting down (possibly
+-  //   with a holder in place.)
+-  //
+-  // * ControlOnly targets will simply dispatch a control runnable.
+-  enum class Behavior : uint8_t {
+-    Hybrid,
+-    ControlOnly
+-  };
+-
+-private:
+-  mozilla::Mutex mMutex;
+-  WorkerPrivate* mWorkerPrivate;
+-  const Behavior mBehavior;
+-
+-  ~WorkerEventTarget() = default;
+-
+-public:
+-  WorkerEventTarget(WorkerPrivate* aWorkerPrivate,
+-                           Behavior aBehavior)
+-    : mMutex("WorkerEventTarget")
+-    , mWorkerPrivate(aWorkerPrivate)
+-    , mBehavior(aBehavior)
+-  {
+-    MOZ_DIAGNOSTIC_ASSERT(mWorkerPrivate);
+-  }
+-
+-  void
+-  ForgetWorkerPrivate(WorkerPrivate* aWorkerPrivate)
+-  {
+-    MutexAutoLock lock(mMutex);
+-    MOZ_DIAGNOSTIC_ASSERT(!mWorkerPrivate || mWorkerPrivate == aWorkerPrivate);
+-    mWorkerPrivate = nullptr;
+-  }
+-
+-  NS_IMETHOD
+-  DispatchFromScript(nsIRunnable* aRunnable, uint32_t aFlags) override
+-  {
+-    nsCOMPtr<nsIRunnable> runnable(aRunnable);
+-    return Dispatch(runnable.forget(), aFlags);
+-  }
+-
+-  NS_IMETHOD
+-  Dispatch(already_AddRefed<nsIRunnable> aRunnable, uint32_t aFlags = NS_DISPATCH_NORMAL) override
+-  {
+-    MutexAutoLock lock(mMutex);
+-
+-    if (!mWorkerPrivate) {
+-      return NS_ERROR_FAILURE;
+-    }
+-
+-    nsCOMPtr<nsIRunnable> runnable(aRunnable);
+-
+-    if (mBehavior == Behavior::Hybrid) {
+-      RefPtr<WorkerRunnable> r =
+-        mWorkerPrivate->MaybeWrapAsWorkerRunnable(runnable.forget());
+-      if (r->Dispatch()) {
+-        return NS_OK;
+-      }
+-
+-      runnable = r.forget();
+-    }
+-
+-    RefPtr<WorkerControlRunnable> r = new WrappedControlRunnable(mWorkerPrivate,
+-                                                                 runnable.forget());
+-    if (!r->Dispatch()) {
+-      return NS_ERROR_FAILURE;
+-    }
+-
+-    return NS_OK;
+-  }
+-
+-  NS_IMETHOD
+-  DelayedDispatch(already_AddRefed<nsIRunnable>, uint32_t) override
+-  {
+-    return NS_ERROR_NOT_IMPLEMENTED;
+-  }
+-
+-  NS_IMETHOD_(bool) IsOnCurrentThreadInfallible() override
+-  {
+-    MutexAutoLock lock(mMutex);
+-
+-    if (!mWorkerPrivate) {
+-      return false;
+-    }
+-
+-    return mWorkerPrivate->IsOnCurrentThread();
+-  }
+-
+-  NS_IMETHOD
+-  IsOnCurrentThread(bool* aIsOnCurrentThread) override
+-  {
+-    MOZ_ASSERT(aIsOnCurrentThread);
+-    *aIsOnCurrentThread = IsOnCurrentThreadInfallible();
+-    return NS_OK;
+-  }
+-
+-  NS_DECL_THREADSAFE_ISUPPORTS
+-};
+-
+-NS_IMPL_ISUPPORTS(WorkerEventTarget, nsIEventTarget,
+-                                            nsISerialEventTarget)
+-
+-END_WORKERS_NAMESPACE
+ 
+ template <class Derived>
+ class WorkerPrivateParent<Derived>::EventTarget final
+   : public nsISerialEventTarget
+ {
+   // This mutex protects mWorkerPrivate and must be acquired *before* the
+   // WorkerPrivate's mutex whenever they must both be held.
+   mozilla::Mutex mMutex;
+diff --git a/dom/workers/WorkerPrivate.h b/dom/workers/WorkerPrivate.h
+--- a/dom/workers/WorkerPrivate.h
++++ b/dom/workers/WorkerPrivate.h
+@@ -34,28 +34,28 @@ class ClientInfo;
+ class ClientSource;
+ class Function;
+ class MessagePort;
+ class MessagePortIdentifier;
+ class PerformanceStorage;
+ class SharedWorker;
+ class WorkerDebuggerGlobalScope;
+ class WorkerErrorReport;
++class WorkerEventTarget;
+ class WorkerGlobalScope;
+ struct WorkerOptions;
+ class WorkerThread;
+ 
+ } // dom namespace
+ } // mozilla namespace
+ 
+ BEGIN_WORKERS_NAMESPACE
+ 
+ class WorkerControlRunnable;
+ class WorkerDebugger;
+-class WorkerEventTarget;
+ class WorkerRunnable;
+ 
+ // SharedMutex is a small wrapper around an (internal) reference-counted Mutex
+ // object. It exists to avoid changing a lot of code to use Mutex* instead of
+ // Mutex&.
+ class SharedMutex
+ {
+   typedef mozilla::Mutex Mutex;
+diff --git a/dom/workers/moz.build b/dom/workers/moz.build
+--- a/dom/workers/moz.build
++++ b/dom/workers/moz.build
+@@ -5,29 +5,29 @@
+ # file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ 
+ with Files("**"):
+     BUG_COMPONENT = ("Core", "DOM: Workers")
+ 
+ # Public stuff.
+ EXPORTS.mozilla.dom += [
+     'SharedWorker.h',
++    'WorkerLoadInfo.h',
+     'WorkerLocation.h',
+     'WorkerNavigator.h',
+     'WorkerPrivate.h',
+     'WorkerRunnable.h',
+     'WorkerScope.h',
+ ]
+ 
+ EXPORTS.mozilla.dom.workers += [
+     'RuntimeService.h',
+     'WorkerCommon.h',
+     'WorkerDebugger.h',
+     'WorkerDebuggerManager.h',
+-    'WorkerLoadInfo.h',
+ ]
+ 
+ # Stuff needed for the bindings, not really public though.
+ EXPORTS.mozilla.dom.workers.bindings += [
+     'WorkerHolder.h',
+     'WorkerHolderToken.h',
+ ]
+ 
+@@ -44,16 +44,17 @@ UNIFIED_SOURCES += [
+     'Principal.cpp',
+     'RegisterBindings.cpp',
+     'RuntimeService.cpp',
+     'ScriptLoader.cpp',
+     'SharedWorker.cpp',
+     'WorkerDebugger.cpp',
+     'WorkerDebuggerManager.cpp',
+     'WorkerError.cpp',
++    'WorkerEventTarget.cpp',
+     'WorkerHolder.cpp',
+     'WorkerHolderToken.cpp',
+     'WorkerLoadInfo.cpp',
+     'WorkerLocation.cpp',
+     'WorkerNavigator.cpp',
+     'WorkerPrivate.cpp',
+     'WorkerRunnable.cpp',
+     'WorkerScope.cpp',

+ 58 - 0
mozilla-release/patches/1432963-06-60a1.patch

@@ -0,0 +1,58 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1517383242 -3600
+# Node ID 2d8d6c014e67ad9478b41893f51ff8064d1f135f
+# Parent  e0f34f20be1a7dcc010023505313e23ded1b8aab
+Bug 1432963 - Fixing workers headers - part 6 - Get rid of WorkerInlines.h, r=smaug
+
+diff --git a/dom/serviceworkers/ServiceWorkerManager.cpp b/dom/serviceworkers/ServiceWorkerManager.cpp
+--- a/dom/serviceworkers/ServiceWorkerManager.cpp
++++ b/dom/serviceworkers/ServiceWorkerManager.cpp
+@@ -78,17 +78,16 @@
+ #include "ServiceWorkerRegistrar.h"
+ #include "ServiceWorkerRegistration.h"
+ #include "ServiceWorkerScriptCache.h"
+ #include "ServiceWorkerEvents.h"
+ #include "ServiceWorkerUnregisterJob.h"
+ #include "ServiceWorkerUpdateJob.h"
+ #include "ServiceWorkerUpdaterChild.h"
+ #include "SharedWorker.h"
+-#include "WorkerInlines.h"
+ #include "WorkerPrivate.h"
+ #include "WorkerRunnable.h"
+ #include "WorkerScope.h"
+ 
+ #ifdef PostMessage
+ #undef PostMessage
+ #endif
+ 
+diff --git a/dom/workers/WorkerInlines.h b/dom/workers/WorkerInlines.h
+deleted file mode 100644
+--- a/dom/workers/WorkerInlines.h
++++ /dev/null
+@@ -1,25 +0,0 @@
+-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+-/* 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/. */
+-
+-BEGIN_WORKERS_NAMESPACE
+-
+-inline
+-void
+-SetJSPrivateSafeish(JSObject* aObj, PrivatizableBase* aBase)
+-{
+-  JS_SetPrivate(aObj, aBase);
+-}
+-
+-template <class Derived>
+-inline
+-Derived*
+-GetJSPrivateSafeish(JSObject* aObj)
+-{
+-  return static_cast<Derived*>(
+-    static_cast<PrivatizableBase*>(JS_GetPrivate(aObj)));
+-}
+-
+-END_WORKERS_NAMESPACE

+ 380 - 0
mozilla-release/patches/1432963-07-60a1.patch

@@ -0,0 +1,380 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1517383266 -3600
+# Node ID 6978eec68f5fedf561425d62e71eb477fc2bc0f2
+# Parent  b8875b82dc591139a6a9152cb4d6df6f576f9df3
+Bug 1432963 - Fixing workers headers - part 7 - WorkerDebugger without workers namespace, r=smaug
+
+diff --git a/dom/workers/WorkerDebugger.cpp b/dom/workers/WorkerDebugger.cpp
+--- a/dom/workers/WorkerDebugger.cpp
++++ b/dom/workers/WorkerDebugger.cpp
+@@ -15,17 +15,18 @@
+ #include "WorkerCommon.h"
+ #include "WorkerError.h"
+ #include "WorkerPrivate.h"
+ #include "WorkerRunnable.h"
+ #include "WorkerScope.h"
+ 
+ namespace mozilla {
+ namespace dom {
+-namespace workers {
++
++using namespace workers;
+ 
+ namespace {
+ 
+ class DebuggerMessageEventRunnable : public WorkerDebuggerRunnable
+ {
+   nsString mMessage;
+ 
+ public:
+@@ -468,11 +469,10 @@ WorkerDebugger::ReportErrorToDebuggerOnM
+ 
+   WorkerErrorReport report;
+   report.mMessage = aMessage;
+   report.mFilename = aFilename;
+   WorkerErrorReport::LogErrorToConsole(report, 0);
+ }
+ 
+ 
+-} // worker namespace
+ } // dom namespace
+ } // mozilla namespace
+diff --git a/dom/workers/WorkerDebugger.h b/dom/workers/WorkerDebugger.h
+--- a/dom/workers/WorkerDebugger.h
++++ b/dom/workers/WorkerDebugger.h
+@@ -5,29 +5,34 @@
+  * You can obtain one at http://mozilla.org/MPL/2.0/. */
+ 
+ #ifndef mozilla_dom_workers_WorkerDebugger_h
+ #define mozilla_dom_workers_WorkerDebugger_h
+ 
+ #include "mozilla/dom/workers/WorkerCommon.h"
+ #include "nsIWorkerDebugger.h"
+ 
+-BEGIN_WORKERS_NAMESPACE
++namespace mozilla {
++namespace dom {
++
++namespace workers {
++class WorkerPrivate;
++}
+ 
+ class WorkerDebugger : public nsIWorkerDebugger
+ {
+   class ReportDebuggerErrorRunnable;
+   class PostDebuggerMessageRunnable;
+ 
+-  WorkerPrivate* mWorkerPrivate;
++  workers::WorkerPrivate* mWorkerPrivate;
+   bool mIsInitialized;
+   nsTArray<nsCOMPtr<nsIWorkerDebuggerListener>> mListeners;
+ 
+ public:
+-  explicit WorkerDebugger(WorkerPrivate* aWorkerPrivate);
++  explicit WorkerDebugger(workers::WorkerPrivate* aWorkerPrivate);
+ 
+   NS_DECL_ISUPPORTS
+   NS_DECL_NSIWORKERDEBUGGER
+ 
+   void
+   AssertIsOnParentThread();
+ 
+   void
+@@ -48,11 +53,12 @@ private:
+   PostMessageToDebuggerOnMainThread(const nsAString& aMessage);
+ 
+   void
+   ReportErrorToDebuggerOnMainThread(const nsAString& aFilename,
+                                     uint32_t aLineno,
+                                     const nsAString& aMessage);
+ };
+ 
+-END_WORKERS_NAMESPACE
++} // dom namespace
++} // mozilla namespace
+ 
+ #endif // mozilla_dom_workers_WorkerDebugger_h
+diff --git a/dom/workers/WorkerDebuggerManager.cpp b/dom/workers/WorkerDebuggerManager.cpp
+--- a/dom/workers/WorkerDebuggerManager.cpp
++++ b/dom/workers/WorkerDebuggerManager.cpp
+@@ -9,17 +9,20 @@
+ #include "nsISimpleEnumerator.h"
+ 
+ #include "mozilla/ClearOnShutdown.h"
+ #include "mozilla/StaticPtr.h"
+ 
+ #include "WorkerDebugger.h"
+ #include "WorkerPrivate.h"
+ 
+-USING_WORKERS_NAMESPACE
++namespace mozilla {
++namespace dom {
++
++using namespace workers;
+ 
+ namespace {
+ 
+ class RegisterDebuggerMainThreadRunnable final : public mozilla::Runnable
+ {
+   WorkerPrivate* mWorkerPrivate;
+   bool mNotifyListeners;
+ 
+@@ -70,18 +73,16 @@ private:
+     return NS_OK;
+   }
+ };
+ 
+ static StaticRefPtr<WorkerDebuggerManager> gWorkerDebuggerManager;
+ 
+ } /* anonymous namespace */
+ 
+-BEGIN_WORKERS_NAMESPACE
+-
+ class WorkerDebuggerEnumerator final : public nsISimpleEnumerator
+ {
+   nsTArray<RefPtr<WorkerDebugger>> mDebuggers;
+   uint32_t mIndex;
+ 
+ public:
+   explicit WorkerDebuggerEnumerator(
+                              const nsTArray<RefPtr<WorkerDebugger>>& aDebuggers)
+@@ -357,9 +358,10 @@ WorkerDebuggerManager::UnregisterDebugge
+   for (size_t index = 0; index < listeners.Length(); ++index) {
+     listeners[index]->OnUnregister(debugger);
+   }
+ 
+   debugger->Close();
+   aWorkerPrivate->SetIsDebuggerRegistered(false);
+ }
+ 
+-END_WORKERS_NAMESPACE
++} // dom namespace
++} // mozilla namespace
+diff --git a/dom/workers/WorkerDebuggerManager.h b/dom/workers/WorkerDebuggerManager.h
+--- a/dom/workers/WorkerDebuggerManager.h
++++ b/dom/workers/WorkerDebuggerManager.h
+@@ -2,32 +2,37 @@
+ /* vim: set ts=8 sts=2 et sw=2 tw=80: */
+ /* 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/. */
+ 
+ #ifndef mozilla_dom_workers_workerdebuggermanager_h
+ #define mozilla_dom_workers_workerdebuggermanager_h
+ 
+-#include "WorkerCommon.h"
++#include "mozilla/dom/workers/WorkerCommon.h"
+ 
+ #include "nsIObserver.h"
+ #include "nsIWorkerDebuggerManager.h"
+ 
+ #include "nsServiceManagerUtils.h"
+ #include "nsTArray.h"
+ #include "nsThreadUtils.h"
+ 
+ #define WORKERDEBUGGERMANAGER_CID \
+   { 0x62ec8731, 0x55ad, 0x4246, \
+     { 0xb2, 0xea, 0xf2, 0x6c, 0x1f, 0xe1, 0x9d, 0x2d } }
+ #define WORKERDEBUGGERMANAGER_CONTRACTID \
+   "@mozilla.org/dom/workers/workerdebuggermanager;1"
+ 
+-BEGIN_WORKERS_NAMESPACE
++namespace mozilla {
++namespace dom {
++
++namespace workers {
++class WorkerPrivate;
++}
+ 
+ class WorkerDebugger;
+ 
+ class WorkerDebuggerManager final : public nsIObserver,
+                                     public nsIWorkerDebuggerManager
+ {
+   Mutex mMutex;
+ 
+@@ -55,34 +60,34 @@ public:
+ 
+   nsresult
+   Init();
+ 
+   void
+   Shutdown();
+ 
+   void
+-  RegisterDebugger(WorkerPrivate* aWorkerPrivate);
++  RegisterDebugger(workers::WorkerPrivate* aWorkerPrivate);
+ 
+   void
+-  RegisterDebuggerMainThread(WorkerPrivate* aWorkerPrivate,
++  RegisterDebuggerMainThread(workers::WorkerPrivate* aWorkerPrivate,
+                              bool aNotifyListeners);
+ 
+   void
+-  UnregisterDebugger(WorkerPrivate* aWorkerPrivate);
++  UnregisterDebugger(workers::WorkerPrivate* aWorkerPrivate);
+ 
+   void
+-  UnregisterDebuggerMainThread(WorkerPrivate* aWorkerPrivate);
++  UnregisterDebuggerMainThread(workers::WorkerPrivate* aWorkerPrivate);
+ 
+ private:
+   virtual ~WorkerDebuggerManager();
+ };
+ 
+ inline nsresult
+-RegisterWorkerDebugger(WorkerPrivate* aWorkerPrivate)
++RegisterWorkerDebugger(workers::WorkerPrivate* aWorkerPrivate)
+ {
+   WorkerDebuggerManager* manager;
+ 
+   if (NS_IsMainThread()) {
+     manager = WorkerDebuggerManager::GetOrCreate();
+     if (!manager) {
+       NS_WARNING("Failed to create worker debugger manager!");
+       return NS_ERROR_FAILURE;
+@@ -92,17 +97,17 @@ RegisterWorkerDebugger(WorkerPrivate* aW
+     manager = WorkerDebuggerManager::Get();
+   }
+ 
+   manager->RegisterDebugger(aWorkerPrivate);
+   return NS_OK;
+ }
+ 
+ inline nsresult
+-UnregisterWorkerDebugger(WorkerPrivate* aWorkerPrivate)
++UnregisterWorkerDebugger(workers::WorkerPrivate* aWorkerPrivate)
+ {
+   WorkerDebuggerManager* manager;
+ 
+   if (NS_IsMainThread()) {
+     manager = WorkerDebuggerManager::GetOrCreate();
+     if (!manager) {
+       NS_WARNING("Failed to create worker debugger manager!");
+       return NS_ERROR_FAILURE;
+@@ -111,11 +116,12 @@ UnregisterWorkerDebugger(WorkerPrivate* 
+   else {
+     manager = WorkerDebuggerManager::Get();
+   }
+ 
+   manager->UnregisterDebugger(aWorkerPrivate);
+   return NS_OK;
+ }
+ 
+-END_WORKERS_NAMESPACE
++} // dom namespace
++} // mozilla namespace
+ 
+ #endif // mozilla_dom_workers_workerdebuggermanager_h
+diff --git a/dom/workers/WorkerPrivate.h b/dom/workers/WorkerPrivate.h
+--- a/dom/workers/WorkerPrivate.h
++++ b/dom/workers/WorkerPrivate.h
+@@ -32,30 +32,30 @@ namespace dom {
+ 
+ class ClientInfo;
+ class ClientSource;
+ class Function;
+ class MessagePort;
+ class MessagePortIdentifier;
+ class PerformanceStorage;
+ class SharedWorker;
++class WorkerDebugger;
+ class WorkerDebuggerGlobalScope;
+ class WorkerErrorReport;
+ class WorkerEventTarget;
+ class WorkerGlobalScope;
+ struct WorkerOptions;
+ class WorkerThread;
+ 
+ } // dom namespace
+ } // mozilla namespace
+ 
+ BEGIN_WORKERS_NAMESPACE
+ 
+ class WorkerControlRunnable;
+-class WorkerDebugger;
+ class WorkerRunnable;
+ 
+ // SharedMutex is a small wrapper around an (internal) reference-counted Mutex
+ // object. It exists to avoid changing a lot of code to use Mutex* instead of
+ // Mutex&.
+ class SharedMutex
+ {
+   typedef mozilla::Mutex Mutex;
+diff --git a/dom/workers/moz.build b/dom/workers/moz.build
+--- a/dom/workers/moz.build
++++ b/dom/workers/moz.build
+@@ -5,29 +5,29 @@
+ # file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ 
+ with Files("**"):
+     BUG_COMPONENT = ("Core", "DOM: Workers")
+ 
+ # Public stuff.
+ EXPORTS.mozilla.dom += [
+     'SharedWorker.h',
++    'WorkerDebugger.h',
++    'WorkerDebuggerManager.h',
+     'WorkerLoadInfo.h',
+     'WorkerLocation.h',
+     'WorkerNavigator.h',
+     'WorkerPrivate.h',
+     'WorkerRunnable.h',
+     'WorkerScope.h',
+ ]
+ 
+ EXPORTS.mozilla.dom.workers += [
+     'RuntimeService.h',
+     'WorkerCommon.h',
+-    'WorkerDebugger.h',
+-    'WorkerDebuggerManager.h',
+ ]
+ 
+ # Stuff needed for the bindings, not really public though.
+ EXPORTS.mozilla.dom.workers.bindings += [
+     'WorkerHolder.h',
+     'WorkerHolderToken.h',
+ ]
+ 
+diff --git a/layout/build/nsLayoutModule.cpp b/layout/build/nsLayoutModule.cpp
+--- a/layout/build/nsLayoutModule.cpp
++++ b/layout/build/nsLayoutModule.cpp
+@@ -80,17 +80,17 @@
+ #include "mozilla/Attributes.h"
+ #include "mozilla/dom/DOMException.h"
+ #include "mozilla/dom/DOMRequest.h"
+ #include "mozilla/dom/LocalStorageManager.h"
+ #include "mozilla/dom/network/UDPSocketChild.h"
+ #include "mozilla/dom/quota/QuotaManagerService.h"
+ #include "mozilla/dom/ServiceWorkerManager.h"
+ #include "mozilla/dom/SessionStorageManager.h"
+-#include "mozilla/dom/workers/WorkerDebuggerManager.h"
++#include "mozilla/dom/WorkerDebuggerManager.h"
+ #include "mozilla/dom/Notification.h"
+ #include "mozilla/OSFileConstants.h"
+ #include "mozilla/Services.h"
+ 
+ #ifdef MOZ_WEBSPEECH_TEST_BACKEND
+ #include "mozilla/dom/FakeSpeechRecognitionService.h"
+ #endif
+ #ifdef MOZ_WEBSPEECH
+@@ -169,17 +169,17 @@ static void Shutdown();
+ #include "nsScriptError.h"
+ 
+ #include "mozilla/TextInputProcessor.h"
+ 
+ using namespace mozilla;
+ using namespace mozilla::dom;
+ using mozilla::dom::power::PowerManagerService;
+ using mozilla::dom::quota::QuotaManagerService;
+-using mozilla::dom::workers::WorkerDebuggerManager;
++using mozilla::dom::WorkerDebuggerManager;
+ using mozilla::dom::UDPSocketChild;
+ using mozilla::gmp::GeckoMediaPluginService;
+ 
+ #define NS_EDITORCOMMANDTABLE_CID \
+ { 0x4f5e62b8, 0xd659, 0x4156, \
+   { 0x84, 0xfc, 0x2f, 0x60, 0x99, 0x40, 0x03, 0x69 } }
+ 
+ #define NS_EDITINGCOMMANDTABLE_CID \

+ 349 - 0
mozilla-release/patches/1432963-08-60a1.patch

@@ -0,0 +1,349 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1517383287 -3600
+# Node ID 7a76ef9f9fd5d3fe3b11054486c8a29581685afd
+# Parent  4f2551b15a4f349695f75e5c66bd06499c5d4434
+Bug 1432963 - Fixing workers headers - part 8 - WorkerTargetHolder without workers namespace, r=smaug
+
+diff --git a/dom/clients/api/Client.cpp b/dom/clients/api/Client.cpp
+--- a/dom/clients/api/Client.cpp
++++ b/dom/clients/api/Client.cpp
+@@ -16,17 +16,16 @@
+ #include "mozilla/dom/WorkerScope.h"
+ #include "nsIGlobalObject.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+ using mozilla::dom::workers::Closing;
+ using mozilla::dom::workers::GetCurrentThreadWorkerPrivate;
+-using mozilla::dom::workers::WorkerHolderToken;
+ using mozilla::dom::workers::WorkerPrivate;
+ using mozilla::dom::ipc::StructuredCloneData;
+ 
+ NS_IMPL_CYCLE_COLLECTING_ADDREF(mozilla::dom::Client);
+ NS_IMPL_CYCLE_COLLECTING_RELEASE(mozilla::dom::Client);
+ NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(mozilla::dom::Client, mGlobal);
+ 
+ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(mozilla::dom::Client)
+diff --git a/dom/clients/api/ClientDOMUtil.h b/dom/clients/api/ClientDOMUtil.h
+--- a/dom/clients/api/ClientDOMUtil.h
++++ b/dom/clients/api/ClientDOMUtil.h
+@@ -3,35 +3,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/. */
+ #ifndef _mozilla_dom_ClientDOMUtil_h
+ #define _mozilla_dom_ClientDOMUtil_h
+ 
+ #include "mozilla/dom/ClientIPCTypes.h"
+ #include "mozilla/dom/ClientOpPromise.h"
++#include "mozilla/dom/WorkerHolderToken.h"
+ #include "mozilla/dom/WorkerPrivate.h"
+-#include "mozilla/dom/workers/bindings/WorkerHolderToken.h"
+ 
+ class nsIGlobalObject;
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+ // Utility method to properly execute a ClientManager operation.  It
+ // will properly hold a worker thread alive and avoid executing callbacks
+ // if the thread is shutting down.
+ template<typename Func, typename Arg, typename Resolve, typename Reject>
+ void
+ StartClientManagerOp(Func aFunc, const Arg& aArg, nsISerialEventTarget* aTarget,
+                      Resolve aResolve, Reject aReject)
+ {
+   using mozilla::dom::workers::Closing;
+   using mozilla::dom::workers::GetCurrentThreadWorkerPrivate;
+-  using mozilla::dom::workers::WorkerHolderToken;
+ 
+   RefPtr<WorkerHolderToken> token;
+   if (!NS_IsMainThread()) {
+     token = WorkerHolderToken::Create(GetCurrentThreadWorkerPrivate(), Closing);
+   }
+ 
+   RefPtr<ClientOpPromise> promise = aFunc(aArg, aTarget);
+   promise->Then(aTarget, __func__,
+diff --git a/dom/clients/manager/ClientManager.cpp b/dom/clients/manager/ClientManager.cpp
+--- a/dom/clients/manager/ClientManager.cpp
++++ b/dom/clients/manager/ClientManager.cpp
+@@ -6,32 +6,31 @@
+ 
+ #include "ClientManager.h"
+ 
+ #include "ClientHandle.h"
+ #include "ClientManagerChild.h"
+ #include "ClientManagerOpChild.h"
+ #include "ClientPrefs.h"
+ #include "ClientSource.h"
++#include "mozilla/dom/WorkerHolderToken.h"
+ #include "mozilla/dom/WorkerPrivate.h"
+-#include "mozilla/dom/workers/bindings/WorkerHolderToken.h"
+ #include "mozilla/ipc/BackgroundChild.h"
+ #include "mozilla/ipc/PBackgroundChild.h"
+ #include "nsContentUtils.h"
+ #include "prthread.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+ using mozilla::ipc::BackgroundChild;
+ using mozilla::ipc::PBackgroundChild;
+ using mozilla::ipc::PrincipalInfo;
+ using mozilla::dom::workers::Closing;
+ using mozilla::dom::workers::GetCurrentThreadWorkerPrivate;
+-using mozilla::dom::workers::WorkerHolderToken;
+ using mozilla::dom::workers::WorkerPrivate;
+ 
+ namespace {
+ 
+ uint32_t kBadThreadLocalIndex = -1;
+ uint32_t sClientManagerThreadLocalIndex = kBadThreadLocalIndex;
+ 
+ } // anonymous namespace
+diff --git a/dom/clients/manager/ClientManagerChild.cpp b/dom/clients/manager/ClientManagerChild.cpp
+--- a/dom/clients/manager/ClientManagerChild.cpp
++++ b/dom/clients/manager/ClientManagerChild.cpp
+@@ -9,17 +9,16 @@
+ #include "ClientHandleChild.h"
+ #include "ClientManagerOpChild.h"
+ #include "ClientNavigateOpChild.h"
+ #include "ClientSourceChild.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+-using mozilla::dom::workers::WorkerHolderToken;
+ using mozilla::dom::workers::WorkerPrivate;
+ 
+ void
+ ClientManagerChild::ActorDestroy(ActorDestroyReason aReason)
+ {
+   if (mWorkerHolderToken) {
+     mWorkerHolderToken->RemoveListener(this);
+     mWorkerHolderToken = nullptr;
+diff --git a/dom/clients/manager/ClientManagerChild.h b/dom/clients/manager/ClientManagerChild.h
+--- a/dom/clients/manager/ClientManagerChild.h
++++ b/dom/clients/manager/ClientManagerChild.h
+@@ -3,31 +3,31 @@
+ /* 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/. */
+ #ifndef _mozilla_dom_ClientManagerChild_h
+ #define _mozilla_dom_ClientManagerChild_h
+ 
+ #include "ClientThing.h"
+ #include "mozilla/dom/PClientManagerChild.h"
+-#include "mozilla/dom/workers/bindings/WorkerHolderToken.h"
++#include "mozilla/dom/WorkerHolderToken.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+ namespace workers {
+ class WorkerPrivate;
+ } // workers namespace
+ 
+ class ClientManagerChild final : public PClientManagerChild
+-                               , public mozilla::dom::workers::WorkerHolderToken::Listener
++                               , public WorkerHolderToken::Listener
+ {
+   ClientThing<ClientManagerChild>* mManager;
+ 
+-  RefPtr<mozilla::dom::workers::WorkerHolderToken> mWorkerHolderToken;
++  RefPtr<WorkerHolderToken> mWorkerHolderToken;
+   bool mTeardownStarted;
+ 
+   // PClientManagerChild interface
+   void
+   ActorDestroy(ActorDestroyReason aReason) override;
+ 
+   PClientHandleChild*
+   AllocPClientHandleChild(const IPCClientInfo& aClientInfo) override;
+@@ -57,17 +57,17 @@ class ClientManagerChild final : public 
+   bool
+   DeallocPClientSourceChild(PClientSourceChild* aActor) override;
+ 
+   // WorkerHolderToken::Listener interface
+   void
+   WorkerShuttingDown() override;
+ 
+ public:
+-  explicit ClientManagerChild(workers::WorkerHolderToken* aWorkerHolderToken);
++  explicit ClientManagerChild(WorkerHolderToken* aWorkerHolderToken);
+ 
+   void
+   SetOwner(ClientThing<ClientManagerChild>* aThing);
+ 
+   void
+   RevokeOwner(ClientThing<ClientManagerChild>* aThing);
+ 
+   void
+diff --git a/dom/workers/WorkerHolderToken.cpp b/dom/workers/WorkerHolderToken.cpp
+--- a/dom/workers/WorkerHolderToken.cpp
++++ b/dom/workers/WorkerHolderToken.cpp
+@@ -3,17 +3,20 @@
+ /* 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 "WorkerHolderToken.h"
+ 
+ #include "WorkerPrivate.h"
+ 
+-BEGIN_WORKERS_NAMESPACE
++namespace mozilla {
++namespace dom {
++
++using namespace workers;
+ 
+ // static
+ already_AddRefed<WorkerHolderToken>
+ WorkerHolderToken::Create(WorkerPrivate* aWorkerPrivate, Status aShutdownStatus,
+                           Behavior aBehavior)
+ {
+   MOZ_DIAGNOSTIC_ASSERT(aWorkerPrivate);
+   aWorkerPrivate->AssertIsOnWorkerThread();
+@@ -105,9 +108,10 @@ WorkerHolderToken::Notify(Status aStatus
+ 
+   // Set this after calling WorkerShuttingDown() on listener list in case
+   // one callback triggers another listener to be added.
+   mShuttingDown = true;
+ 
+   return true;
+ }
+ 
+-END_WORKERS_NAMESPACE
++} // dom namespace
++} // mozilla namespace
+diff --git a/dom/workers/WorkerHolderToken.h b/dom/workers/WorkerHolderToken.h
+--- a/dom/workers/WorkerHolderToken.h
++++ b/dom/workers/WorkerHolderToken.h
+@@ -6,43 +6,47 @@
+ 
+ #ifndef mozilla_dom_workers_WorkerHolderToken_h
+ #define mozilla_dom_workers_WorkerHolderToken_h
+ 
+ #include "nsISupportsImpl.h"
+ #include "nsTObserverArray.h"
+ #include "WorkerHolder.h"
+ 
+-BEGIN_WORKERS_NAMESPACE
++namespace mozilla {
++namespace dom {
+ 
++namespace workers {
+ class WorkerPrivate;
++}
+ 
+ // This is a ref-counted WorkerHolder implementation.  If you wish
+ // to be notified of worker shutdown beginning, then you can implement
+ // the Listener interface and call AddListener().
+ //
+ // This is purely a convenience class to avoid requiring code to
+ // extend WorkerHolder all the time.
+-class WorkerHolderToken final : public WorkerHolder
++class WorkerHolderToken final : public workers::WorkerHolder
+ {
+ public:
+   // Pure virtual class defining the interface for objects that
+   // wish to be notified of worker shutdown.
+   class Listener
+   {
+   public:
+     virtual void
+     WorkerShuttingDown() = 0;
+   };
+ 
+   // Attempt to create a WorkerHolderToken().  If the shutdown has already
+   // passed the given shutdown phase or fails for another reason then
+   // nullptr is returned.
+   static already_AddRefed<WorkerHolderToken>
+-  Create(workers::WorkerPrivate* aWorkerPrivate, Status aShutdownStatus,
++  Create(workers::WorkerPrivate* aWorkerPrivate,
++         workers::Status aShutdownStatus,
+          Behavior aBehavior = PreventIdleShutdownStart);
+ 
+   // Add a listener to the token.  Note, this does not hold a strong
+   // reference to the listener.  You must call RemoveListener() before
+   // the listener is destroyed.  This can only be called on the owning
+   // worker thread.
+   void
+   AddListener(Listener* aListener);
+@@ -50,31 +54,32 @@ public:
+   // Remove a previously added listener.  This can only be called on the
+   // owning worker thread.
+   void
+   RemoveListener(Listener* aListener);
+ 
+   bool
+   IsShuttingDown() const;
+ 
+-  WorkerPrivate*
++  workers::WorkerPrivate*
+   GetWorkerPrivate() const;
+ 
+ private:
+-  WorkerHolderToken(Status aShutdownStatus, Behavior aBehavior);
++  WorkerHolderToken(workers::Status aShutdownStatus, Behavior aBehavior);
+ 
+   ~WorkerHolderToken();
+ 
+   // WorkerHolder methods
+   virtual bool
+   Notify(workers::Status aStatus) override;
+ 
+   nsTObserverArray<Listener*> mListenerList;
+-  const Status mShutdownStatus;
++  const workers::Status mShutdownStatus;
+   bool mShuttingDown;
+ 
+ public:
+   NS_INLINE_DECL_REFCOUNTING(WorkerHolderToken)
+ };
+ 
+-END_WORKERS_NAMESPACE
++} // dom namespace
++} // mozilla namespace
+ 
+ #endif // mozilla_dom_workers_WorkerHolderToken_h
+diff --git a/dom/workers/moz.build b/dom/workers/moz.build
+--- a/dom/workers/moz.build
++++ b/dom/workers/moz.build
+@@ -7,33 +7,33 @@
+ with Files("**"):
+     BUG_COMPONENT = ("Core", "DOM: Workers")
+ 
+ # Public stuff.
+ EXPORTS.mozilla.dom += [
+     'SharedWorker.h',
+     'WorkerDebugger.h',
+     'WorkerDebuggerManager.h',
++    'WorkerHolderToken.h',
+     'WorkerLoadInfo.h',
+     'WorkerLocation.h',
+     'WorkerNavigator.h',
+     'WorkerPrivate.h',
+     'WorkerRunnable.h',
+     'WorkerScope.h',
+ ]
+ 
+ EXPORTS.mozilla.dom.workers += [
+     'RuntimeService.h',
+     'WorkerCommon.h',
+ ]
+ 
+ # Stuff needed for the bindings, not really public though.
+ EXPORTS.mozilla.dom.workers.bindings += [
+     'WorkerHolder.h',
+-    'WorkerHolderToken.h',
+ ]
+ 
+ XPIDL_MODULE = 'dom_workers'
+ 
+ XPIDL_SOURCES += [
+     'nsIWorkerDebugger.idl',
+     'nsIWorkerDebuggerManager.idl',
+ ]

+ 157 - 0
mozilla-release/patches/1432963-09-60a1.patch

@@ -0,0 +1,157 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1517383306 -3600
+# Node ID b83b357dc475728dd9982160018e7ba923b26ccf
+# Parent  713be5e89ea188b3ceeaebf45bc2e86e58a19f0f
+Bug 1432963 - Fixing workers headers - part 9 - WorkerLoadInfo without workers namespace, r=smaug
+
+diff --git a/dom/workers/RuntimeService.h b/dom/workers/RuntimeService.h
+--- a/dom/workers/RuntimeService.h
++++ b/dom/workers/RuntimeService.h
+@@ -17,24 +17,23 @@
+ #include "nsTArray.h"
+ 
+ class nsITimer;
+ class nsPIDOMWindowInner;
+ 
+ namespace mozilla {
+ namespace dom {
+ class SharedWorker;
++struct WorkerLoadInfo;
+ class WorkerThread;
+ }
+ }
+ 
+ BEGIN_WORKERS_NAMESPACE
+ 
+-struct WorkerLoadInfo;
+-
+ class RuntimeService final : public nsIObserver
+ {
+   struct SharedWorkerInfo
+   {
+     WorkerPrivate* mWorkerPrivate;
+     nsCString mScriptSpec;
+     nsString mName;
+ 
+diff --git a/dom/workers/ScriptLoader.h b/dom/workers/ScriptLoader.h
+--- a/dom/workers/ScriptLoader.h
++++ b/dom/workers/ScriptLoader.h
+@@ -16,22 +16,25 @@ class nsIURI;
+ class nsIDocument;
+ class nsILoadGroup;
+ class nsIChannel;
+ 
+ namespace mozilla {
+ 
+ class ErrorResult;
+ 
++namespace dom {
++
++struct WorkerLoadInfo;
++
++} // dom namespace
+ } // namespace mozilla
+ 
+ BEGIN_WORKERS_NAMESPACE
+ 
+-struct WorkerLoadInfo;
+-
+ enum WorkerScriptType {
+   WorkerScript,
+   DebuggerScript
+ };
+ 
+ namespace scriptloader {
+ 
+ nsresult
+diff --git a/dom/workers/WorkerLoadInfo.cpp b/dom/workers/WorkerLoadInfo.cpp
+--- a/dom/workers/WorkerLoadInfo.cpp
++++ b/dom/workers/WorkerLoadInfo.cpp
+@@ -18,17 +18,18 @@
+ #include "nsITabChild.h"
+ #include "nsNetUtil.h"
+ 
+ namespace mozilla {
+ 
+ using namespace ipc;
+ 
+ namespace dom {
+-namespace workers {
++
++using namespace workers;
+ 
+ namespace {
+ 
+ class MainThreadReleaseRunnable final : public Runnable
+ {
+   nsTArray<nsCOMPtr<nsISupports>> mDoomed;
+   nsCOMPtr<nsILoadGroup> mLoadGroupToCancel;
+ 
+@@ -537,11 +538,10 @@ InterfaceRequestor::GetAnyLiveTabChild()
+   return nullptr;
+ }
+ 
+ NS_IMPL_ADDREF(WorkerLoadInfo::InterfaceRequestor)
+ NS_IMPL_RELEASE(WorkerLoadInfo::InterfaceRequestor)
+ NS_IMPL_QUERY_INTERFACE(WorkerLoadInfo::InterfaceRequestor,
+                         nsIInterfaceRequestor)
+ 
+-} // worker namespace
+ } // dom namespace
+ } // mozilla namespace
+diff --git a/dom/workers/WorkerLoadInfo.h b/dom/workers/WorkerLoadInfo.h
+--- a/dom/workers/WorkerLoadInfo.h
++++ b/dom/workers/WorkerLoadInfo.h
+@@ -22,22 +22,26 @@ class nsILoadGroup;
+ class nsIPrincipal;
+ class nsIRunnable;
+ class nsIScriptContext;
+ class nsITabChild;
+ class nsIURI;
+ class nsPIDOMWindowInner;
+ 
+ namespace mozilla {
++
+ namespace ipc {
+ class PrincipalInfo;
+ } // namespace ipc
+-} // namespace mozilla
++
++namespace dom {
+ 
+-BEGIN_WORKERS_NAMESPACE
++namespace workers {
++class WorkerPrivate;
++}
+ 
+ struct WorkerLoadInfo
+ {
+   // All of these should be released in WorkerPrivateParent::ForgetMainThreadObjects.
+   nsCOMPtr<nsIURI> mBaseURI;
+   nsCOMPtr<nsIURI> mResolvedScriptURI;
+ 
+   // This is the principal of the global (parent worker or a window) loading
+@@ -131,18 +135,19 @@ struct WorkerLoadInfo
+   bool
+   PrincipalIsValid() const;
+ 
+   bool
+   PrincipalURIMatchesScriptURL();
+ #endif
+ 
+   bool
+-  ProxyReleaseMainThreadObjects(WorkerPrivate* aWorkerPrivate);
++  ProxyReleaseMainThreadObjects(workers::WorkerPrivate* aWorkerPrivate);
+ 
+   bool
+-  ProxyReleaseMainThreadObjects(WorkerPrivate* aWorkerPrivate,
++  ProxyReleaseMainThreadObjects(workers::WorkerPrivate* aWorkerPrivate,
+                                 nsCOMPtr<nsILoadGroup>& aLoadGroupToCancel);
+ };
+ 
+-END_WORKERS_NAMESPACE
++} // dom namespace
++} // mozilla namespace
+ 
+ #endif // mozilla_dom_workers_WorkerLoadInfo_h

+ 333 - 0
mozilla-release/patches/1432963-10-60a1.patch

@@ -0,0 +1,333 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1517383323 -3600
+# Node ID 0f5abdabc30ff20091227790593131964716fa4e
+# Parent  d249fc07fbd7a1437ea2b5ce13fa23c2c27187df
+Bug 1432963 - Fixing workers headers - part 10 - ScriptLoader into a workerinternals namespace, r=smaug
+
+diff --git a/dom/workers/ScriptLoader.cpp b/dom/workers/ScriptLoader.cpp
+--- a/dom/workers/ScriptLoader.cpp
++++ b/dom/workers/ScriptLoader.cpp
+@@ -70,22 +70,25 @@
+ #include "WorkerPrivate.h"
+ #include "WorkerRunnable.h"
+ #include "WorkerScope.h"
+ 
+ #define MAX_CONCURRENT_SCRIPTS 1000
+ 
+ USING_WORKERS_NAMESPACE
+ 
+-using namespace mozilla;
+-using namespace mozilla::dom;
+ using mozilla::dom::cache::Cache;
+ using mozilla::dom::cache::CacheStorage;
+ using mozilla::ipc::PrincipalInfo;
+ 
++namespace mozilla {
++namespace dom {
++
++using namespace workers;
++
+ namespace {
+ 
+ nsIURI*
+ GetBaseURI(bool aIsMainScript, WorkerPrivate* aWorkerPrivate)
+ {
+   MOZ_ASSERT(aWorkerPrivate);
+   nsIURI* baseURI;
+   WorkerPrivate* parentWorker = aWorkerPrivate->GetParent();
+@@ -1918,27 +1921,27 @@ public:
+     nsCOMPtr<nsIDocument> parentDoc = mWorkerPrivate->GetDocument();
+ 
+     mLoadInfo.mLoadGroup = mWorkerPrivate->GetLoadGroup();
+ 
+     Maybe<ClientInfo> clientInfo;
+     clientInfo.emplace(mClientInfo);
+ 
+     nsCOMPtr<nsIChannel> channel;
+-    mResult =
+-      scriptloader::ChannelFromScriptURLMainThread(mLoadInfo.mLoadingPrincipal,
+-                                                   baseURI, parentDoc,
+-                                                   mLoadInfo.mLoadGroup,
+-                                                   mScriptURL,
+-                                                   clientInfo,
+-                                                   // Nested workers are always dedicated.
+-                                                   nsIContentPolicy::TYPE_INTERNAL_WORKER,
+-                                                   // Nested workers use default uri encoding.
+-                                                   true,
+-                                                   getter_AddRefs(channel));
++    mResult = workerinternals::
++      ChannelFromScriptURLMainThread(mLoadInfo.mLoadingPrincipal,
++                                     baseURI, parentDoc,
++                                     mLoadInfo.mLoadGroup,
++                                     mScriptURL,
++                                     clientInfo,
++                                     // Nested workers are always dedicated.
++                                     nsIContentPolicy::TYPE_INTERNAL_WORKER,
++                                     // Nested workers use default uri encoding.
++                                     true,
++                                     getter_AddRefs(channel));
+     NS_ENSURE_SUCCESS(mResult, true);
+ 
+     mResult = mLoadInfo.SetPrincipalFromChannel(channel);
+     NS_ENSURE_SUCCESS(mResult, true);
+ 
+     mLoadInfo.mChannel = channel.forget();
+     return true;
+   }
+@@ -2045,18 +2048,18 @@ ScriptExecutorRunnable::WorkerRun(JSCont
+ 
+     NS_ASSERTION(!loadInfo.mChannel, "Should no longer have a channel!");
+     NS_ASSERTION(loadInfo.mExecutionScheduled, "Should be scheduled!");
+     NS_ASSERTION(!loadInfo.mExecutionResult, "Should not have executed yet!");
+ 
+     MOZ_ASSERT(!mScriptLoader.mRv.Failed(), "Who failed it and why?");
+     mScriptLoader.mRv.MightThrowJSException();
+     if (NS_FAILED(loadInfo.mLoadResult)) {
+-      scriptloader::ReportLoadError(mScriptLoader.mRv,
+-                                    loadInfo.mLoadResult, loadInfo.mURL);
++      workerinternals::ReportLoadError(mScriptLoader.mRv,
++                                       loadInfo.mLoadResult, loadInfo.mURL);
+       // Top level scripts only!
+       if (mIsWorkerScript) {
+         aWorkerPrivate->MaybeDispatchLoadFailedRunnable();
+       }
+       return true;
+     }
+ 
+     // If this is a top level script that succeeded, then mark the
+@@ -2252,19 +2255,17 @@ LoadAllScripts(WorkerPrivate* aWorkerPri
+     return;
+   }
+ 
+   syncLoop.Run();
+ }
+ 
+ } /* anonymous namespace */
+ 
+-BEGIN_WORKERS_NAMESPACE
+-
+-namespace scriptloader {
++namespace workerinternals {
+ 
+ nsresult
+ ChannelFromScriptURLMainThread(nsIPrincipal* aPrincipal,
+                                nsIURI* aBaseURI,
+                                nsIDocument* aParentDoc,
+                                nsILoadGroup* aLoadGroup,
+                                const nsAString& aScriptURL,
+                                const Maybe<ClientInfo>& aClientInfo,
+@@ -2401,11 +2402,12 @@ Load(WorkerPrivate* aWorkerPrivate,
+   for (uint32_t index = 0; index < urlCount; index++) {
+     loadInfos[index].mURL = aScriptURLs[index];
+     loadInfos[index].mLoadFlags = aWorkerPrivate->GetLoadFlags();
+   }
+ 
+   LoadAllScripts(aWorkerPrivate, loadInfos, false, aWorkerScriptType, aRv);
+ }
+ 
+-} // namespace scriptloader
+-
+-END_WORKERS_NAMESPACE
++} // namespace workerinternals
++
++} // dom namespace
++} // mozilla namespace
+diff --git a/dom/workers/ScriptLoader.h b/dom/workers/ScriptLoader.h
+--- a/dom/workers/ScriptLoader.h
++++ b/dom/workers/ScriptLoader.h
+@@ -18,57 +18,57 @@ class nsILoadGroup;
+ class nsIChannel;
+ 
+ namespace mozilla {
+ 
+ class ErrorResult;
+ 
+ namespace dom {
+ 
+-struct WorkerLoadInfo;
++namespace workers {
++class WorkerPrivate;
++}
+ 
+-} // dom namespace
+-} // namespace mozilla
+-
+-BEGIN_WORKERS_NAMESPACE
++struct WorkerLoadInfo;
+ 
+ enum WorkerScriptType {
+   WorkerScript,
+   DebuggerScript
+ };
+ 
+-namespace scriptloader {
++namespace workerinternals {
+ 
+ nsresult
+ ChannelFromScriptURLMainThread(nsIPrincipal* aPrincipal,
+                                nsIURI* aBaseURI,
+                                nsIDocument* aParentDoc,
+                                nsILoadGroup* aLoadGroup,
+                                const nsAString& aScriptURL,
+                                const Maybe<ClientInfo>& aClientInfo,
+                                nsContentPolicyType aContentPolicyType,
+                                bool aDefaultURIEncoding,
+                                nsIChannel** aChannel);
+ 
+ nsresult
+ ChannelFromScriptURLWorkerThread(JSContext* aCx,
+-                                 WorkerPrivate* aParent,
++                                 workers::WorkerPrivate* aParent,
+                                  const nsAString& aScriptURL,
+                                  WorkerLoadInfo& aLoadInfo);
+ 
+ void ReportLoadError(ErrorResult& aRv, nsresult aLoadResult,
+                      const nsAString& aScriptURL);
+ 
+-void LoadMainScript(WorkerPrivate* aWorkerPrivate,
++void LoadMainScript(workers::WorkerPrivate* aWorkerPrivate,
+                     const nsAString& aScriptURL,
+                     WorkerScriptType aWorkerScriptType,
+                     ErrorResult& aRv);
+ 
+-void Load(WorkerPrivate* aWorkerPrivate,
++void Load(workers::WorkerPrivate* aWorkerPrivate,
+           const nsTArray<nsString>& aScriptURLs,
+           WorkerScriptType aWorkerScriptType,
+-          mozilla::ErrorResult& aRv);
++          ErrorResult& aRv);
+ 
+-} // namespace scriptloader
++} // namespace workerinternals
+ 
+-END_WORKERS_NAMESPACE
++} // dom namespace
++} // namespace mozilla
+ 
+ #endif /* mozilla_dom_workers_scriptloader_h__ */
+diff --git a/dom/workers/WorkerDebugger.cpp b/dom/workers/WorkerDebugger.cpp
+--- a/dom/workers/WorkerDebugger.cpp
++++ b/dom/workers/WorkerDebugger.cpp
+@@ -98,18 +98,18 @@ private:
+     if (NS_WARN_IF(!aWorkerPrivate->EnsureClientSource())) {
+       return false;
+     }
+ 
+     JS::Rooted<JSObject*> global(aCx, globalScope->GetWrapper());
+ 
+     ErrorResult rv;
+     JSAutoCompartment ac(aCx, global);
+-    scriptloader::LoadMainScript(aWorkerPrivate, mScriptURL,
+-                                 DebuggerScript, rv);
++    workerinternals::LoadMainScript(aWorkerPrivate, mScriptURL,
++                                    DebuggerScript, rv);
+     rv.WouldReportJSException();
+     // Explicitly ignore NS_BINDING_ABORTED on rv.  Or more precisely, still
+     // return false and don't SetWorkerScriptExecutedSuccessfully() in that
+     // case, but don't throw anything on aCx.  The idea is to not dispatch error
+     // events if our load is canceled with that error code.
+     if (rv.ErrorCodeIs(NS_BINDING_ABORTED)) {
+       rv.SuppressException();
+       return false;
+diff --git a/dom/workers/WorkerPrivate.cpp b/dom/workers/WorkerPrivate.cpp
+--- a/dom/workers/WorkerPrivate.cpp
++++ b/dom/workers/WorkerPrivate.cpp
+@@ -430,17 +430,17 @@ private:
+   {
+     aWorkerPrivate->AssertIsOnWorkerThread();
+ 
+     if (NS_WARN_IF(!aWorkerPrivate->EnsureClientSource())) {
+       return false;
+     }
+ 
+     ErrorResult rv;
+-    scriptloader::LoadMainScript(aWorkerPrivate, mScriptURL, WorkerScript, rv);
++    workerinternals::LoadMainScript(aWorkerPrivate, mScriptURL, WorkerScript, rv);
+     rv.WouldReportJSException();
+     // Explicitly ignore NS_BINDING_ABORTED on rv.  Or more precisely, still
+     // return false and don't SetWorkerScriptExecutedSuccessfully() in that
+     // case, but don't throw anything on aCx.  The idea is to not dispatch error
+     // events if our load is canceled with that error code.
+     if (rv.ErrorCodeIs(NS_BINDING_ABORTED)) {
+       rv.SuppressException();
+       return false;
+@@ -3073,17 +3073,17 @@ WorkerPrivate::Constructor(JSContext* aC
+   if (!aLoadInfo) {
+     stackLoadInfo.emplace();
+ 
+     nsresult rv = GetLoadInfo(aCx, nullptr, parent, aScriptURL,
+                               aIsChromeWorker, InheritLoadGroup,
+                               aWorkerType, stackLoadInfo.ptr());
+     aRv.MightThrowJSException();
+     if (NS_FAILED(rv)) {
+-      scriptloader::ReportLoadError(aRv, rv, aScriptURL);
++      workerinternals::ReportLoadError(aRv, rv, aScriptURL);
+       return nullptr;
+     }
+ 
+     aLoadInfo = stackLoadInfo.ptr();
+   }
+ 
+   // NB: This has to be done before creating the WorkerPrivate, because it will
+   // attempt to use static variables that are initialized in the RuntimeService
+@@ -3145,17 +3145,17 @@ WorkerPrivate::Constructor(JSContext* aC
+ nsresult
+ WorkerPrivate::GetLoadInfo(JSContext* aCx, nsPIDOMWindowInner* aWindow,
+                            WorkerPrivate* aParent, const nsAString& aScriptURL,
+                            bool aIsChromeWorker,
+                            LoadGroupBehavior aLoadGroupBehavior,
+                            WorkerType aWorkerType,
+                            WorkerLoadInfo* aLoadInfo)
+ {
+-  using namespace mozilla::dom::workers::scriptloader;
++  using namespace mozilla::dom::workerinternals;
+ 
+   MOZ_ASSERT(aCx);
+   MOZ_ASSERT_IF(NS_IsMainThread(), aCx == nsContentUtils::GetCurrentJSContext());
+ 
+   if (aWindow) {
+     AssertIsOnMainThread();
+   }
+ 
+diff --git a/dom/workers/WorkerScope.cpp b/dom/workers/WorkerScope.cpp
+--- a/dom/workers/WorkerScope.cpp
++++ b/dom/workers/WorkerScope.cpp
+@@ -249,17 +249,17 @@ WorkerGlobalScope::SetOnerror(OnErrorEve
+   }
+ }
+ 
+ void
+ WorkerGlobalScope::ImportScripts(const Sequence<nsString>& aScriptURLs,
+                                  ErrorResult& aRv)
+ {
+   mWorkerPrivate->AssertIsOnWorkerThread();
+-  scriptloader::Load(mWorkerPrivate, aScriptURLs, WorkerScript, aRv);
++  workerinternals::Load(mWorkerPrivate, aScriptURLs, WorkerScript, aRv);
+ }
+ 
+ int32_t
+ WorkerGlobalScope::SetTimeout(JSContext* aCx,
+                               Function& aHandler,
+                               const int32_t aTimeout,
+                               const Sequence<JS::Value>& aArguments,
+                               ErrorResult& aRv)
+@@ -990,17 +990,17 @@ WorkerDebuggerGlobalScope::LoadSubScript
+       return;
+     }
+ 
+     ac.emplace(aCx, sandbox);
+   }
+ 
+   nsTArray<nsString> urls;
+   urls.AppendElement(aURL);
+-  scriptloader::Load(mWorkerPrivate, urls, DebuggerScript, aRv);
++  workerinternals::Load(mWorkerPrivate, urls, DebuggerScript, aRv);
+ }
+ 
+ void
+ WorkerDebuggerGlobalScope::EnterEventLoop()
+ {
+   mWorkerPrivate->EnterDebuggerEventLoop();
+ }
+ 

+ 165 - 0
mozilla-release/patches/1432963-11-60a1.patch

@@ -0,0 +1,165 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1517383348 -3600
+# Node ID 69e7ac848a5d98e3eb94ba0c5fcd069ac432a5cc
+# Parent  89a644ee8f6eacc5e790ae5e2e203bd0ff8a1ff7
+Bug 1432963 - Fixing workers headers - part 11 - MessageEventRunnable without workers namespace, r=smaug
+
+diff --git a/dom/workers/ChromeWorkerScope.cpp b/dom/workers/ChromeWorkerScope.cpp
+--- a/dom/workers/ChromeWorkerScope.cpp
++++ b/dom/workers/ChromeWorkerScope.cpp
+@@ -9,18 +9,18 @@
+ #include "jsapi.h"
+ 
+ #include "nsXPCOM.h"
+ #include "nsNativeCharsetUtils.h"
+ #include "nsString.h"
+ 
+ #include "WorkerPrivate.h"
+ 
+-using namespace mozilla::dom;
+-USING_WORKERS_NAMESPACE
++namespace mozilla {
++namespace dom {
+ 
+ namespace {
+ 
+ #ifdef BUILD_CTYPES
+ 
+ char*
+ UnicodeToNative(JSContext* aCx, const char16_t* aSource, size_t aSourceLen)
+ {
+@@ -41,18 +41,16 @@ UnicodeToNative(JSContext* aCx, const ch
+   result[native.Length()] = 0;
+   return result;
+ }
+ 
+ #endif // BUILD_CTYPES
+ 
+ } // namespace
+ 
+-BEGIN_WORKERS_NAMESPACE
+-
+ bool
+ DefineChromeWorkerFunctions(JSContext* aCx, JS::Handle<JSObject*> aGlobal)
+ {
+   // Currently ctypes is the only special property given to ChromeWorkers.
+ #ifdef BUILD_CTYPES
+   {
+     JS::Rooted<JS::Value> ctypes(aCx);
+     if (!JS_InitCTypesClass(aCx, aGlobal) ||
+@@ -66,9 +64,10 @@ DefineChromeWorkerFunctions(JSContext* a
+ 
+     JS_SetCTypesCallbacks(ctypes.toObjectOrNull(), &callbacks);
+   }
+ #endif // BUILD_CTYPES
+ 
+   return true;
+ }
+ 
+-END_WORKERS_NAMESPACE
++} // dom namespace
++} // mozilla namespace
+diff --git a/dom/workers/ChromeWorkerScope.h b/dom/workers/ChromeWorkerScope.h
+--- a/dom/workers/ChromeWorkerScope.h
++++ b/dom/workers/ChromeWorkerScope.h
+@@ -4,16 +4,18 @@
+  * 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/. */
+ 
+ #ifndef mozilla_dom_workers_chromeworkerscope_h__
+ #define mozilla_dom_workers_chromeworkerscope_h__
+ 
+ #include "WorkerCommon.h"
+ 
+-BEGIN_WORKERS_NAMESPACE
++namespace mozilla {
++namespace dom {
+ 
+ bool
+ DefineChromeWorkerFunctions(JSContext* aCx, JS::Handle<JSObject*> aGlobal);
+ 
+-END_WORKERS_NAMESPACE
++} // dom namespace
++} // mozilla namespace
+ 
+ #endif // mozilla_dom_workers_chromeworkerscope_h__
+diff --git a/dom/workers/MessageEventRunnable.cpp b/dom/workers/MessageEventRunnable.cpp
+--- a/dom/workers/MessageEventRunnable.cpp
++++ b/dom/workers/MessageEventRunnable.cpp
+@@ -9,17 +9,20 @@
+ #include "mozilla/dom/MessageEvent.h"
+ #include "mozilla/dom/MessageEventBinding.h"
+ #include "mozilla/TimelineConsumers.h"
+ #include "mozilla/WorkerTimelineMarker.h"
+ #include "nsQueryObject.h"
+ #include "WorkerPrivate.h"
+ #include "WorkerScope.h"
+ 
+-BEGIN_WORKERS_NAMESPACE
++namespace mozilla {
++namespace dom {
++
++using namespace workers;
+ 
+ MessageEventRunnable::MessageEventRunnable(WorkerPrivate* aWorkerPrivate,
+                                            TargetAndBusyBehavior aBehavior)
+   : WorkerRunnable(aWorkerPrivate, aBehavior)
+   , StructuredCloneHolder(CloningSupported, TransferringSupported,
+                           StructuredCloneScope::SameProcessDifferentThread)
+ {
+ }
+@@ -146,9 +149,10 @@ MessageEventRunnable::DispatchError(JSCo
+   RefPtr<Event> event =
+     MessageEvent::Constructor(aTarget, NS_LITERAL_STRING("messageerror"), init);
+   event->SetTrusted(true);
+ 
+   bool dummy;
+   aTarget->DispatchEvent(event, &dummy);
+ }
+ 
+-END_WORKERS_NAMESPACE
++} // dom namespace
++} // mozilla namespace
+diff --git a/dom/workers/MessageEventRunnable.h b/dom/workers/MessageEventRunnable.h
+--- a/dom/workers/MessageEventRunnable.h
++++ b/dom/workers/MessageEventRunnable.h
+@@ -11,34 +11,32 @@
+ #include "WorkerRunnable.h"
+ #include "mozilla/dom/StructuredCloneHolder.h"
+ 
+ namespace mozilla {
+ 
+ class DOMEventTargetHelper;
+ 
+ namespace dom {
+-namespace workers {
+ 
+-class MessageEventRunnable final : public WorkerRunnable
++class MessageEventRunnable final : public workers::WorkerRunnable
+                                  , public StructuredCloneHolder
+ {
+ public:
+-  MessageEventRunnable(WorkerPrivate* aWorkerPrivate,
++  MessageEventRunnable(workers::WorkerPrivate* aWorkerPrivate,
+                        TargetAndBusyBehavior aBehavior);
+ 
+   bool
+-  DispatchDOMEvent(JSContext* aCx, WorkerPrivate* aWorkerPrivate,
++  DispatchDOMEvent(JSContext* aCx, workers::WorkerPrivate* aWorkerPrivate,
+                    DOMEventTargetHelper* aTarget, bool aIsMainThread);
+ 
+ private:
+   bool
+-  WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate) override;
++  WorkerRun(JSContext* aCx, workers::WorkerPrivate* aWorkerPrivate) override;
+ 
+   void
+   DispatchError(JSContext* aCx, DOMEventTargetHelper* aTarget);
+ };
+ 
+-} // workers namespace
+ } // dom namespace
+ } // mozilla namespace
+ 
+ #endif // mozilla_dom_workers_MessageEventRunnable_h

+ 738 - 0
mozilla-release/patches/1432963-12-60a1.patch

@@ -0,0 +1,738 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1517383376 -3600
+# Node ID 765fff03aebd5aef2ddd338c893b69b86a3fa81b
+# Parent  04bdd53a04ad9a9247717f4c1a8602dcdd66f3a4
+Bug 1432963 - Fixing workers headers - part 12 - WorkerRunnable without workers namespace, r=smaug
+
+diff --git a/dom/fetch/Request.cpp b/dom/fetch/Request.cpp
+--- a/dom/fetch/Request.cpp
++++ b/dom/fetch/Request.cpp
+@@ -243,24 +243,24 @@ GetRequestURLFromWorker(const GlobalObje
+     return;
+   }
+   url->Stringify(aRequestURL, aRv);
+   if (NS_WARN_IF(aRv.Failed())) {
+     return;
+   }
+ }
+ 
+-class ReferrerSameOriginChecker final : public workers::WorkerMainThreadRunnable
++class ReferrerSameOriginChecker final : public WorkerMainThreadRunnable
+ {
+ public:
+   ReferrerSameOriginChecker(workers::WorkerPrivate* aWorkerPrivate,
+                             const nsAString& aReferrerURL,
+                             nsresult& aResult)
+-    : workers::WorkerMainThreadRunnable(aWorkerPrivate,
+-                                        NS_LITERAL_CSTRING("Fetch :: Referrer same origin check")),
++    : WorkerMainThreadRunnable(aWorkerPrivate,
++                               NS_LITERAL_CSTRING("Fetch :: Referrer same origin check")),
+       mReferrerURL(aReferrerURL),
+       mResult(aResult)
+   {
+     mWorkerPrivate->AssertIsOnWorkerThread();
+   }
+ 
+   bool
+   MainThreadRun() override
+diff --git a/dom/serviceworkers/ServiceWorkerPrivate.h b/dom/serviceworkers/ServiceWorkerPrivate.h
+--- a/dom/serviceworkers/ServiceWorkerPrivate.h
++++ b/dom/serviceworkers/ServiceWorkerPrivate.h
+@@ -226,15 +226,15 @@ private:
+   // Meant for keeping objects alive while handling requests from the worker
+   // on the main thread. Access to this array is provided through
+   // |StoreISupports| and |RemoveISupports|. Note that the array is also
+   // cleared whenever the worker is terminated.
+   nsTArray<nsCOMPtr<nsISupports>> mSupportsArray;
+ 
+   // Array of function event worker runnables that are pending due to
+   // the worker activating.  Main thread only.
+-  nsTArray<RefPtr<workers::WorkerRunnable>> mPendingFunctionalEvents;
++  nsTArray<RefPtr<WorkerRunnable>> mPendingFunctionalEvents;
+ };
+ 
+ } // namespace dom
+ } // namespace mozilla
+ 
+ #endif // mozilla_dom_serviceworkerprivate_h
+diff --git a/dom/workers/MessageEventRunnable.h b/dom/workers/MessageEventRunnable.h
+--- a/dom/workers/MessageEventRunnable.h
++++ b/dom/workers/MessageEventRunnable.h
+@@ -12,17 +12,17 @@
+ #include "mozilla/dom/StructuredCloneHolder.h"
+ 
+ namespace mozilla {
+ 
+ class DOMEventTargetHelper;
+ 
+ namespace dom {
+ 
+-class MessageEventRunnable final : public workers::WorkerRunnable
++class MessageEventRunnable final : public WorkerRunnable
+                                  , public StructuredCloneHolder
+ {
+ public:
+   MessageEventRunnable(workers::WorkerPrivate* aWorkerPrivate,
+                        TargetAndBusyBehavior aBehavior);
+ 
+   bool
+   DispatchDOMEvent(JSContext* aCx, workers::WorkerPrivate* aWorkerPrivate,
+diff --git a/dom/workers/WorkerPrivate.h b/dom/workers/WorkerPrivate.h
+--- a/dom/workers/WorkerPrivate.h
++++ b/dom/workers/WorkerPrivate.h
+@@ -32,32 +32,31 @@ namespace dom {
+ 
+ class ClientInfo;
+ class ClientSource;
+ class Function;
+ class MessagePort;
+ class MessagePortIdentifier;
+ class PerformanceStorage;
+ class SharedWorker;
++class WorkerControlRunnable;
+ class WorkerDebugger;
+ class WorkerDebuggerGlobalScope;
+ class WorkerErrorReport;
+ class WorkerEventTarget;
+ class WorkerGlobalScope;
+ struct WorkerOptions;
++class WorkerRunnable;
+ class WorkerThread;
+ 
+ } // dom namespace
+ } // mozilla namespace
+ 
+ BEGIN_WORKERS_NAMESPACE
+ 
+-class WorkerControlRunnable;
+-class WorkerRunnable;
+-
+ // SharedMutex is a small wrapper around an (internal) reference-counted Mutex
+ // object. It exists to avoid changing a lot of code to use Mutex* instead of
+ // Mutex&.
+ class SharedMutex
+ {
+   typedef mozilla::Mutex Mutex;
+ 
+   class RefCountedMutex final : public Mutex
+diff --git a/dom/workers/WorkerRunnable.cpp b/dom/workers/WorkerRunnable.cpp
+--- a/dom/workers/WorkerRunnable.cpp
++++ b/dom/workers/WorkerRunnable.cpp
+@@ -18,17 +18,20 @@
+ #include "mozilla/Telemetry.h"
+ 
+ #include "js/RootingAPI.h"
+ #include "js/Value.h"
+ 
+ #include "WorkerPrivate.h"
+ #include "WorkerScope.h"
+ 
+-USING_WORKERS_NAMESPACE
++namespace mozilla {
++namespace dom {
++
++using namespace workers;
+ 
+ namespace {
+ 
+ const nsIID kWorkerRunnableIID = {
+   0x320cc0b5, 0xef12, 0x4084, { 0x88, 0x6e, 0xca, 0x6a, 0x81, 0xe4, 0x1d, 0x68 }
+ };
+ 
+ } // namespace
+@@ -787,8 +790,11 @@ WorkerProxyToMainThreadRunnable::HoldWor
+ 
+ void
+ WorkerProxyToMainThreadRunnable::ReleaseWorker()
+ {
+   mWorkerPrivate->AssertIsOnWorkerThread();
+   MOZ_ASSERT(mWorkerHolder);
+   mWorkerHolder = nullptr;
+ }
++
++} // dom namespace
++} // mozilla namespace
+diff --git a/dom/workers/WorkerRunnable.h b/dom/workers/WorkerRunnable.h
+--- a/dom/workers/WorkerRunnable.h
++++ b/dom/workers/WorkerRunnable.h
+@@ -15,22 +15,24 @@
+ #include "mozilla/Atomics.h"
+ #include "nsISupportsImpl.h"
+ #include "nsThreadUtils.h" /* nsRunnable */
+ 
+ struct JSContext;
+ class nsIEventTarget;
+ 
+ namespace mozilla {
++
+ class ErrorResult;
+-} // namespace mozilla
+ 
+-BEGIN_WORKERS_NAMESPACE
++namespace dom {
+ 
++namespace workers {
+ class WorkerPrivate;
++}
+ 
+ // Use this runnable to communicate from the worker to its parent or vice-versa.
+ // The busy count must be taken into consideration and declared at construction
+ // time.
+ class WorkerRunnable : public nsIRunnable,
+                        public nsICancelableRunnable
+ {
+ public:
+@@ -47,17 +49,17 @@ public:
+     // Target the thread where the worker event loop runs. The busy count will
+     // not be modified in any way. Besides worker-internal runnables this is
+     // almost always the wrong choice.
+     WorkerThreadUnchangedBusyCount
+   };
+ 
+ protected:
+   // The WorkerPrivate that this runnable is associated with.
+-  WorkerPrivate* mWorkerPrivate;
++  workers::WorkerPrivate* mWorkerPrivate;
+ 
+   // See above.
+   TargetAndBusyBehavior mBehavior;
+ 
+   // It's unclear whether or not Cancel() is supposed to work when called on any
+   // thread. To be safe we're using an atomic but it's likely overkill.
+   Atomic<uint32_t> mCanceled;
+ 
+@@ -87,17 +89,17 @@ public:
+   {
+     return mCanceled != 0;
+   }
+ 
+   static WorkerRunnable*
+   FromRunnable(nsIRunnable* aRunnable);
+ 
+ protected:
+-  WorkerRunnable(WorkerPrivate* aWorkerPrivate,
++  WorkerRunnable(workers::WorkerPrivate* aWorkerPrivate,
+                  TargetAndBusyBehavior aBehavior = WorkerThreadModifyBusyCount)
+ #ifdef DEBUG
+   ;
+ #else
+   : mWorkerPrivate(aWorkerPrivate), mBehavior(aBehavior), mCanceled(0),
+     mCallingCancelWithinRun(false)
+   { }
+ #endif
+@@ -114,32 +116,32 @@ protected:
+   nsIGlobalObject*
+   DefaultGlobalObject() const;
+ 
+   // By default asserts that Dispatch() is being called on the right thread
+   // (ParentThread if |mTarget| is WorkerThread, or WorkerThread otherwise).
+   // Also increments the busy count of |mWorkerPrivate| if targeting the
+   // WorkerThread.
+   virtual bool
+-  PreDispatch(WorkerPrivate* aWorkerPrivate);
++  PreDispatch(workers::WorkerPrivate* aWorkerPrivate);
+ 
+   // By default asserts that Dispatch() is being called on the right thread
+   // (ParentThread if |mTarget| is WorkerThread, or WorkerThread otherwise).
+   virtual void
+-  PostDispatch(WorkerPrivate* aWorkerPrivate, bool aDispatchResult);
++  PostDispatch(workers::WorkerPrivate* aWorkerPrivate, bool aDispatchResult);
+ 
+   // May be implemented by subclasses if desired if they need to do some sort of
+   // setup before we try to set up our JSContext and compartment for real.
+   // Typically the only thing that should go in here is creation of the worker's
+   // global.
+   //
+   // If false is returned, WorkerRun will not be called at all.  PostRun will
+   // still be called, with false passed for aRunResult.
+   virtual bool
+-  PreRun(WorkerPrivate* aWorkerPrivate);
++  PreRun(workers::WorkerPrivate* aWorkerPrivate);
+ 
+   // Must be implemented by subclasses. Called on the target thread.  The return
+   // value will be passed to PostRun().  The JSContext passed in here comes from
+   // an AutoJSAPI (or AutoEntryScript) that we set up on the stack.  If
+   // mBehavior is ParentThreadUnchangedBusyCount, it is in the compartment of
+   // mWorkerPrivate's reflector (i.e. the worker object in the parent thread),
+   // unless that reflector is null, in which case it's in the compartment of the
+   // parent global (which is the compartment reflector would have been in), or
+@@ -152,136 +154,139 @@ protected:
+   // sandbox compartment!).  If aCx wasn't in a compartment to start with, aCx
+   // will be in either the debugger global's compartment or the worker's
+   // global's compartment depending on whether IsDebuggerRunnable() is true.
+   //
+   // Immediately after WorkerRun returns, the caller will assert that either it
+   // returns false or there is no exception pending on aCx.  Then it will report
+   // any pending exceptions on aCx.
+   virtual bool
+-  WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate) = 0;
++  WorkerRun(JSContext* aCx, workers::WorkerPrivate* aWorkerPrivate) = 0;
+ 
+   // By default asserts that Run() (and WorkerRun()) were called on the correct
+   // thread.  Also sends an asynchronous message to the ParentThread if the
+   // busy count was previously modified in PreDispatch().
+   //
+   // The aCx passed here is the same one as was passed to WorkerRun and is
+   // still in the same compartment.  PostRun implementations must NOT leave an
+   // exception on the JSContext and must not run script, because the incoming
+   // JSContext may be in the null compartment.
+   virtual void
+-  PostRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate, bool aRunResult);
++  PostRun(JSContext* aCx, workers::WorkerPrivate* aWorkerPrivate,
++          bool aRunResult);
+ 
+   virtual bool
+   DispatchInternal();
+ 
+   // Calling Run() directly is not supported. Just call Dispatch() and
+   // WorkerRun() will be called on the correct thread automatically.
+   NS_DECL_NSIRUNNABLE
+ };
+ 
+ // This runnable is used to send a message to a worker debugger.
+ class WorkerDebuggerRunnable : public WorkerRunnable
+ {
+ protected:
+-  explicit WorkerDebuggerRunnable(WorkerPrivate* aWorkerPrivate)
++  explicit WorkerDebuggerRunnable(workers::WorkerPrivate* aWorkerPrivate)
+   : WorkerRunnable(aWorkerPrivate, WorkerThreadUnchangedBusyCount)
+   {
+   }
+ 
+   virtual ~WorkerDebuggerRunnable()
+   { }
+ 
+ private:
+   virtual bool
+   IsDebuggerRunnable() const override
+   {
+     return true;
+   }
+ 
+   virtual bool
+-  PreDispatch(WorkerPrivate* aWorkerPrivate) override final
++  PreDispatch(workers::WorkerPrivate* aWorkerPrivate) override final
+   {
+-    AssertIsOnMainThread();
++    workers::AssertIsOnMainThread();
+ 
+     return true;
+   }
+ 
+   virtual void
+-  PostDispatch(WorkerPrivate* aWorkerPrivate, bool aDispatchResult) override;
++  PostDispatch(workers::WorkerPrivate* aWorkerPrivate,
++               bool aDispatchResult) override;
+ };
+ 
+ // This runnable is used to send a message directly to a worker's sync loop.
+ class WorkerSyncRunnable : public WorkerRunnable
+ {
+ protected:
+   nsCOMPtr<nsIEventTarget> mSyncLoopTarget;
+ 
+   // Passing null for aSyncLoopTarget is allowed and will result in the behavior
+   // of a normal WorkerRunnable.
+-  WorkerSyncRunnable(WorkerPrivate* aWorkerPrivate,
++  WorkerSyncRunnable(workers::WorkerPrivate* aWorkerPrivate,
+                      nsIEventTarget* aSyncLoopTarget);
+ 
+-  WorkerSyncRunnable(WorkerPrivate* aWorkerPrivate,
++  WorkerSyncRunnable(workers::WorkerPrivate* aWorkerPrivate,
+                      already_AddRefed<nsIEventTarget>&& aSyncLoopTarget);
+ 
+   virtual ~WorkerSyncRunnable();
+ 
+   virtual bool
+   DispatchInternal() override;
+ };
+ 
+ // This runnable is identical to WorkerSyncRunnable except it is meant to be
+ // created on and dispatched from the main thread only.  Its WorkerRun/PostRun
+ // will run on the worker thread.
+ class MainThreadWorkerSyncRunnable : public WorkerSyncRunnable
+ {
+ protected:
+   // Passing null for aSyncLoopTarget is allowed and will result in the behavior
+   // of a normal WorkerRunnable.
+-  MainThreadWorkerSyncRunnable(WorkerPrivate* aWorkerPrivate,
++  MainThreadWorkerSyncRunnable(workers::WorkerPrivate* aWorkerPrivate,
+                                nsIEventTarget* aSyncLoopTarget)
+   : WorkerSyncRunnable(aWorkerPrivate, aSyncLoopTarget)
+   {
+-    AssertIsOnMainThread();
++    workers::AssertIsOnMainThread();
+   }
+ 
+-  MainThreadWorkerSyncRunnable(WorkerPrivate* aWorkerPrivate,
++  MainThreadWorkerSyncRunnable(workers::WorkerPrivate* aWorkerPrivate,
+                                already_AddRefed<nsIEventTarget>&& aSyncLoopTarget)
+   : WorkerSyncRunnable(aWorkerPrivate, Move(aSyncLoopTarget))
+   {
+-    AssertIsOnMainThread();
++    workers::AssertIsOnMainThread();
+   }
+ 
+   virtual ~MainThreadWorkerSyncRunnable()
+   { }
+ 
+ private:
+   virtual bool
+-  PreDispatch(WorkerPrivate* aWorkerPrivate) override
++  PreDispatch(workers::WorkerPrivate* aWorkerPrivate) override
+   {
+-    AssertIsOnMainThread();
++    workers::AssertIsOnMainThread();
+     return true;
+   }
+ 
+   virtual void
+-  PostDispatch(WorkerPrivate* aWorkerPrivate, bool aDispatchResult) override;
++  PostDispatch(workers::WorkerPrivate* aWorkerPrivate,
++               bool aDispatchResult) override;
+ };
+ 
+ // This runnable is processed as soon as it is received by the worker,
+ // potentially running before previously queued runnables and perhaps even with
+ // other JS code executing on the stack. These runnables must not alter the
+ // state of the JS runtime and should only twiddle state values. The busy count
+ // is never modified.
+ class WorkerControlRunnable : public WorkerRunnable
+ {
+-  friend class WorkerPrivate;
++  friend class workers::WorkerPrivate;
+ 
+ protected:
+-  WorkerControlRunnable(WorkerPrivate* aWorkerPrivate,
++  WorkerControlRunnable(workers::WorkerPrivate* aWorkerPrivate,
+                         TargetAndBusyBehavior aBehavior = WorkerThreadModifyBusyCount)
+ #ifdef DEBUG
+   ;
+ #else
+   : WorkerRunnable(aWorkerPrivate, aBehavior)
+   { }
+ #endif
+ 
+@@ -293,126 +298,128 @@ protected:
+ 
+ public:
+   NS_DECL_ISUPPORTS_INHERITED
+ 
+ private:
+   virtual bool
+   DispatchInternal() override;
+ 
+-  // Should only be called by WorkerPrivate::DoRunLoop.
++  // Should only be called by workers::WorkerPrivate::DoRunLoop.
+   using WorkerRunnable::Cancel;
+ };
+ 
+ // A convenience class for WorkerRunnables that are originated on the main
+ // thread.
+ class MainThreadWorkerRunnable : public WorkerRunnable
+ {
+ protected:
+-  explicit MainThreadWorkerRunnable(WorkerPrivate* aWorkerPrivate)
++  explicit MainThreadWorkerRunnable(workers::WorkerPrivate* aWorkerPrivate)
+   : WorkerRunnable(aWorkerPrivate, WorkerThreadUnchangedBusyCount)
+   {
+-    AssertIsOnMainThread();
++    workers::AssertIsOnMainThread();
+   }
+ 
+   virtual ~MainThreadWorkerRunnable()
+   {}
+ 
+   virtual bool
+-  PreDispatch(WorkerPrivate* aWorkerPrivate) override
++  PreDispatch(workers::WorkerPrivate* aWorkerPrivate) override
+   {
+-    AssertIsOnMainThread();
++    workers::AssertIsOnMainThread();
+     return true;
+   }
+ 
+   virtual void
+-  PostDispatch(WorkerPrivate* aWorkerPrivate,
++  PostDispatch(workers::WorkerPrivate* aWorkerPrivate,
+                bool aDispatchResult) override
+   {
+-    AssertIsOnMainThread();
++    workers::AssertIsOnMainThread();
+   }
+ };
+ 
+ // A convenience class for WorkerControlRunnables that originate on the main
+ // thread.
+ class MainThreadWorkerControlRunnable : public WorkerControlRunnable
+ {
+ protected:
+-  explicit MainThreadWorkerControlRunnable(WorkerPrivate* aWorkerPrivate)
++  explicit MainThreadWorkerControlRunnable(workers::WorkerPrivate* aWorkerPrivate)
+   : WorkerControlRunnable(aWorkerPrivate, WorkerThreadUnchangedBusyCount)
+   { }
+ 
+   virtual ~MainThreadWorkerControlRunnable()
+   { }
+ 
+   virtual bool
+-  PreDispatch(WorkerPrivate* aWorkerPrivate) override
++  PreDispatch(workers::WorkerPrivate* aWorkerPrivate) override
+   {
+-    AssertIsOnMainThread();
++    workers::AssertIsOnMainThread();
+     return true;
+   }
+ 
+   virtual void
+-  PostDispatch(WorkerPrivate* aWorkerPrivate, bool aDispatchResult) override
++  PostDispatch(workers::WorkerPrivate* aWorkerPrivate,
++               bool aDispatchResult) override
+   {
+-    AssertIsOnMainThread();
++    workers::AssertIsOnMainThread();
+   }
+ };
+ 
+ // A WorkerRunnable that should be dispatched from the worker to itself for
+ // async tasks. This will increment the busy count PostDispatch() (only if
+ // dispatch was successful) and decrement it in PostRun().
+ //
+ // Async tasks will almost always want to use this since
+ // a WorkerSameThreadRunnable keeps the Worker from being GCed.
+ class WorkerSameThreadRunnable : public WorkerRunnable
+ {
+ protected:
+-  explicit WorkerSameThreadRunnable(WorkerPrivate* aWorkerPrivate)
++  explicit WorkerSameThreadRunnable(workers::WorkerPrivate* aWorkerPrivate)
+   : WorkerRunnable(aWorkerPrivate, WorkerThreadModifyBusyCount)
+   { }
+ 
+   virtual ~WorkerSameThreadRunnable()
+   { }
+ 
+   virtual bool
+-  PreDispatch(WorkerPrivate* aWorkerPrivate) override;
++  PreDispatch(workers::WorkerPrivate* aWorkerPrivate) override;
+ 
+   virtual void
+-  PostDispatch(WorkerPrivate* aWorkerPrivate, bool aDispatchResult) override;
++  PostDispatch(workers::WorkerPrivate* aWorkerPrivate,
++               bool aDispatchResult) override;
+ 
+   // We just delegate PostRun to WorkerRunnable, since it does exactly
+   // what we want.
+ };
+ 
+ // Base class for the runnable objects, which makes a synchronous call to
+ // dispatch the tasks from the worker thread to the main thread.
+ //
+ // Note that the derived class must override MainThreadRun.
+ class WorkerMainThreadRunnable : public Runnable
+ {
+ protected:
+-  WorkerPrivate* mWorkerPrivate;
++  workers::WorkerPrivate* mWorkerPrivate;
+   nsCOMPtr<nsIEventTarget> mSyncLoopTarget;
+   const nsCString mTelemetryKey;
+ 
+-  explicit WorkerMainThreadRunnable(WorkerPrivate* aWorkerPrivate,
++  explicit WorkerMainThreadRunnable(workers::WorkerPrivate* aWorkerPrivate,
+                                     const nsACString& aTelemetryKey);
+   ~WorkerMainThreadRunnable() {}
+ 
+   virtual bool MainThreadRun() = 0;
+ 
+ public:
+   // Dispatch the runnable to the main thread.  If dispatch to main thread
+   // fails, or if the worker is in a state equal or greater of aFailStatus, an
+   // error will be reported on aRv. Normally you want to use 'Terminating' for
+   // aFailStatus, except if you want an infallible runnable. In this case, use
+   // 'Killing'.
+   // In that case the error MUST be propagated out to script.
+-  void Dispatch(Status aFailStatus, ErrorResult& aRv);
++  void Dispatch(workers::Status aFailStatus, ErrorResult& aRv);
+ 
+ private:
+   NS_IMETHOD Run() override;
+ };
+ 
+ // This runnable is an helper class for dispatching something from a worker
+ // thread to the main-thread and back to the worker-thread. During this
+ // operation, this class will keep the worker alive.
+@@ -420,17 +427,17 @@ private:
+ // says, only to release resources, no JS has to be executed, no timers, or
+ // other things. The reason of such limitations is that, in order to execute
+ // this method in any condition (also when the worker is shutting down), a
+ // Control Runnable is used, and, this could generate a reordering of existing
+ // runnables.
+ class WorkerProxyToMainThreadRunnable : public Runnable
+ {
+ protected:
+-  explicit WorkerProxyToMainThreadRunnable(WorkerPrivate* aWorkerPrivate);
++  explicit WorkerProxyToMainThreadRunnable(workers::WorkerPrivate* aWorkerPrivate);
+ 
+   virtual ~WorkerProxyToMainThreadRunnable();
+ 
+   // First this method is called on the main-thread.
+   virtual void RunOnMainThread() = 0;
+ 
+   // After this second method is called on the worker-thread.
+   virtual void RunBackOnWorkerThreadForCleanup() = 0;
+@@ -442,33 +449,33 @@ private:
+   NS_IMETHOD Run() override;
+ 
+   void PostDispatchOnMainThread();
+ 
+   bool HoldWorker();
+   void ReleaseWorker();
+ 
+ protected:
+-  WorkerPrivate* mWorkerPrivate;
+-  UniquePtr<WorkerHolder> mWorkerHolder;
++  workers::WorkerPrivate* mWorkerPrivate;
++  UniquePtr<workers::WorkerHolder> mWorkerHolder;
+ };
+ 
+ // Class for checking API exposure.  This totally violates the "MUST" in the
+ // comments on WorkerMainThreadRunnable::Dispatch, because API exposure checks
+ // can't throw.  Maybe we should change it so they _could_ throw.  But for now
+ // we are bad people and should be ashamed of ourselves.  Let's hope none of
+ // them happen while a worker is shutting down.
+ //
+ // Do NOT copy what this class is doing elsewhere.  Just don't.
+ class WorkerCheckAPIExposureOnMainThreadRunnable
+   : public WorkerMainThreadRunnable
+ {
+ public:
+   explicit
+-  WorkerCheckAPIExposureOnMainThreadRunnable(WorkerPrivate* aWorkerPrivate);
++  WorkerCheckAPIExposureOnMainThreadRunnable(workers::WorkerPrivate* aWorkerPrivate);
+   virtual
+   ~WorkerCheckAPIExposureOnMainThreadRunnable();
+ 
+   // Returns whether the dispatch succeeded.  If this returns false, the API
+   // should not be exposed.
+   bool Dispatch();
+ };
+ 
+@@ -478,42 +485,44 @@ public:
+ // in any way.
+ class MainThreadStopSyncLoopRunnable : public WorkerSyncRunnable
+ {
+   bool mResult;
+ 
+ public:
+   // Passing null for aSyncLoopTarget is not allowed.
+   MainThreadStopSyncLoopRunnable(
+-                               WorkerPrivate* aWorkerPrivate,
++                               workers::WorkerPrivate* aWorkerPrivate,
+                                already_AddRefed<nsIEventTarget>&& aSyncLoopTarget,
+                                bool aResult);
+ 
+   // By default StopSyncLoopRunnables cannot be canceled since they could leave
+   // a sync loop spinning forever.
+   nsresult
+   Cancel() override;
+ 
+ protected:
+   virtual ~MainThreadStopSyncLoopRunnable()
+   { }
+ 
+ private:
+   virtual bool
+-  PreDispatch(WorkerPrivate* aWorkerPrivate) override final
++  PreDispatch(workers::WorkerPrivate* aWorkerPrivate) override final
+   {
+-    AssertIsOnMainThread();
++    workers::AssertIsOnMainThread();
+     return true;
+   }
+ 
+   virtual void
+-  PostDispatch(WorkerPrivate* aWorkerPrivate, bool aDispatchResult) override;
++  PostDispatch(workers::WorkerPrivate* aWorkerPrivate,
++               bool aDispatchResult) override;
+ 
+   virtual bool
+-  WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate) override;
++  WorkerRun(JSContext* aCx, workers::WorkerPrivate* aWorkerPrivate) override;
+ 
+   virtual bool
+   DispatchInternal() override final;
+ };
+ 
+-END_WORKERS_NAMESPACE
++} // dom namespace
++} // mozilla namespace
+ 
+ #endif // mozilla_dom_workers_workerrunnable_h__
+diff --git a/dom/workers/WorkerThread.h b/dom/workers/WorkerThread.h
+--- a/dom/workers/WorkerThread.h
++++ b/dom/workers/WorkerThread.h
+@@ -14,21 +14,22 @@
+ #include "mozilla/RefPtr.h"
+ #include "nsThread.h"
+ 
+ class nsIRunnable;
+ 
+ namespace mozilla {
+ namespace dom {
+ 
++class WorkerRunnable;
++
+ namespace workers {
+ class RuntimeService;
+ class WorkerPrivate;
+ template <class> class WorkerPrivateParent;
+-class WorkerRunnable;
+ }
+ 
+ // This class lets us restrict the public methods that can be called on
+ // WorkerThread to RuntimeService and WorkerPrivate without letting them gain
+ // full access to private methods (as would happen if they were simply friends).
+ class WorkerThreadFriendKey
+ {
+   friend class workers::RuntimeService;
+@@ -70,17 +71,17 @@ public:
+             workers::WorkerPrivate* aWorkerPrivate);
+ 
+   nsresult
+   DispatchPrimaryRunnable(const WorkerThreadFriendKey& aKey,
+                           already_AddRefed<nsIRunnable> aRunnable);
+ 
+   nsresult
+   DispatchAnyThread(const WorkerThreadFriendKey& aKey,
+-           already_AddRefed<workers::WorkerRunnable> aWorkerRunnable);
++           already_AddRefed<WorkerRunnable> aWorkerRunnable);
+ 
+   uint32_t
+   RecursionDepth(const WorkerThreadFriendKey& aKey) const;
+ 
+   NS_DECL_ISUPPORTS_INHERITED
+ 
+ private:
+   WorkerThread();
+diff --git a/gfx/thebes/gfxUtils.cpp b/gfx/thebes/gfxUtils.cpp
+--- a/gfx/thebes/gfxUtils.cpp
++++ b/gfx/thebes/gfxUtils.cpp
+@@ -1405,17 +1405,17 @@ gfxUtils::GetInputStream(gfx::DataSource
+         return NS_ERROR_FAILURE;
+ 
+     return dom::ImageEncoder::GetInputStream(aSurface->GetSize().width,
+                                              aSurface->GetSize().height,
+                                              imageBuffer.get(), format,
+                                              encoder, aEncoderOptions, outStream);
+ }
+ 
+-class GetFeatureStatusRunnable final : public dom::workers::WorkerMainThreadRunnable
++class GetFeatureStatusRunnable final : public dom::WorkerMainThreadRunnable
+ {
+ public:
+     GetFeatureStatusRunnable(dom::workers::WorkerPrivate* workerPrivate,
+                              const nsCOMPtr<nsIGfxInfo>& gfxInfo,
+                              int32_t feature,
+                              nsACString& failureId,
+                              int32_t* status)
+       : WorkerMainThreadRunnable(workerPrivate,

+ 2592 - 0
mozilla-release/patches/1432963-13-60a1.patch

@@ -0,0 +1,2592 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1517383424 -3600
+# Node ID 68a1d607cbc487975686cd7e5e3fbd10e76004c5
+# Parent  aa6f8162a4f6237e5a004adb664d660d600378eb
+Bug 1432963 - Fixing workers headers - part 13 - WorkerHolder without workers namespace, r=smaug
+
+diff --git a/dom/base/EventSource.cpp b/dom/base/EventSource.cpp
+--- a/dom/base/EventSource.cpp
++++ b/dom/base/EventSource.cpp
+@@ -1789,19 +1789,19 @@ class EventSourceWorkerHolder final : pu
+ {
+ public:
+   explicit EventSourceWorkerHolder(EventSourceImpl* aEventSourceImpl)
+     : WorkerHolder("EventSourceWorkerHolder")
+     , mEventSourceImpl(aEventSourceImpl)
+   {
+   }
+ 
+-  bool Notify(Status aStatus) override
++  bool Notify(WorkerStatus aStatus) override
+   {
+-    MOZ_ASSERT(aStatus > workers::Running);
++    MOZ_ASSERT(aStatus > Running);
+     if (aStatus >= Canceling) {
+       mEventSourceImpl->Close();
+     }
+     return true;
+   }
+ 
+ private:
+   // Raw pointer because the EventSourceImpl object keeps alive the holder.
+diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf
+--- a/dom/bindings/Bindings.conf
++++ b/dom/bindings/Bindings.conf
+@@ -639,18 +639,16 @@ DOMInterfaces = {
+     'wrapperCache': False,
+ },
+ 
+ 'NodeList': {
+     'nativeType': 'nsINodeList',
+ },
+ 
+ 'NotificationEvent': {
+-    'headerFile': 'mozilla/dom/NotificationEvent.h',
+-    'nativeType': 'mozilla::dom::workers::NotificationEvent',
+     'binaryNames': {
+         'notification': 'notification_'
+     }
+ },
+ 
+ 'OfflineAudioContext': {
+     'nativeType': 'mozilla::dom::AudioContext',
+ },
+diff --git a/dom/broadcastchannel/BroadcastChannel.cpp b/dom/broadcastchannel/BroadcastChannel.cpp
+--- a/dom/broadcastchannel/BroadcastChannel.cpp
++++ b/dom/broadcastchannel/BroadcastChannel.cpp
+@@ -229,29 +229,29 @@ public:
+ private:
+   ~TeardownRunnable() {}
+ 
+   RefPtr<BroadcastChannelChild> mActor;
+ };
+ 
+ NS_IMPL_ISUPPORTS(TeardownRunnable, nsICancelableRunnable, nsIRunnable)
+ 
+-class BroadcastChannelWorkerHolder final : public workers::WorkerHolder
++class BroadcastChannelWorkerHolder final : public WorkerHolder
+ {
+   BroadcastChannel* mChannel;
+ 
+ public:
+   explicit BroadcastChannelWorkerHolder(BroadcastChannel* aChannel)
+-    : workers::WorkerHolder("BroadcastChannelWorkerHolder")
++    : WorkerHolder("BroadcastChannelWorkerHolder")
+     , mChannel(aChannel)
+   {
+     MOZ_COUNT_CTOR(BroadcastChannelWorkerHolder);
+   }
+ 
+-  virtual bool Notify(workers::Status aStatus) override
++  virtual bool Notify(WorkerStatus aStatus) override
+   {
+     if (aStatus >= Closing) {
+       mChannel->Shutdown();
+     }
+ 
+     return true;
+   }
+ 
+diff --git a/dom/broadcastchannel/BroadcastChannel.h b/dom/broadcastchannel/BroadcastChannel.h
+--- a/dom/broadcastchannel/BroadcastChannel.h
++++ b/dom/broadcastchannel/BroadcastChannel.h
+@@ -19,22 +19,19 @@ class nsPIDOMWindowInner;
+ namespace mozilla {
+ 
+ namespace ipc {
+ class PrincipalInfo;
+ } // namespace ipc
+ 
+ namespace dom {
+ 
+-namespace workers {
+-class WorkerHolder;
+-} // namespace workers
+-
+ class BroadcastChannelChild;
+ class BroadcastChannelMessage;
++class WorkerHolder;
+ 
+ class BroadcastChannel final
+   : public DOMEventTargetHelper
+   , public nsIObserver
+ {
+   friend class BroadcastChannelChild;
+ 
+   NS_DECL_NSIOBSERVER
+@@ -81,17 +78,17 @@ private:
+ 
+   void PostMessageInternal(JSContext* aCx, JS::Handle<JS::Value> aMessage,
+                            ErrorResult& aRv);
+ 
+   void RemoveDocFromBFCache();
+ 
+   RefPtr<BroadcastChannelChild> mActor;
+ 
+-  nsAutoPtr<workers::WorkerHolder> mWorkerHolder;
++  nsAutoPtr<WorkerHolder> mWorkerHolder;
+ 
+   nsString mChannel;
+ 
+   uint64_t mInnerID;
+ 
+   enum {
+     StateActive,
+     StateClosed
+diff --git a/dom/cache/CacheWorkerHolder.cpp b/dom/cache/CacheWorkerHolder.cpp
+--- a/dom/cache/CacheWorkerHolder.cpp
++++ b/dom/cache/CacheWorkerHolder.cpp
+@@ -8,18 +8,16 @@
+ 
+ #include "mozilla/dom/cache/ActorChild.h"
+ #include "WorkerPrivate.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ namespace cache {
+ 
+-using mozilla::dom::workers::Terminating;
+-using mozilla::dom::workers::Status;
+ using mozilla::dom::workers::WorkerPrivate;
+ 
+ // static
+ already_AddRefed<CacheWorkerHolder>
+ CacheWorkerHolder::Create(WorkerPrivate* aWorkerPrivate, Behavior aBehavior)
+ {
+   MOZ_DIAGNOSTIC_ASSERT(aWorkerPrivate);
+ 
+@@ -88,17 +86,17 @@ CacheWorkerHolder::RemoveActor(ActorChil
+ 
+ bool
+ CacheWorkerHolder::Notified() const
+ {
+   return mNotified;
+ }
+ 
+ bool
+-CacheWorkerHolder::Notify(Status aStatus)
++CacheWorkerHolder::Notify(WorkerStatus aStatus)
+ {
+   NS_ASSERT_OWNINGTHREAD(CacheWorkerHolder);
+ 
+   // When the service worker thread is stopped we will get Terminating,
+   // but nothing higher than that.  We must shut things down at Terminating.
+   if (aStatus < Terminating || mNotified) {
+     return true;
+   }
+diff --git a/dom/cache/CacheWorkerHolder.h b/dom/cache/CacheWorkerHolder.h
+--- a/dom/cache/CacheWorkerHolder.h
++++ b/dom/cache/CacheWorkerHolder.h
+@@ -17,33 +17,33 @@ namespace workers {
+ class WorkerPrivate;
+ } // namespace workers
+ 
+ namespace dom {
+ namespace cache {
+ 
+ class ActorChild;
+ 
+-class CacheWorkerHolder final : public workers::WorkerHolder
++class CacheWorkerHolder final : public WorkerHolder
+ {
+ public:
+   static already_AddRefed<CacheWorkerHolder>
+   Create(workers::WorkerPrivate* aWorkerPrivate,
+          Behavior aBehavior);
+ 
+   static already_AddRefed<CacheWorkerHolder>
+   PreferBehavior(CacheWorkerHolder* aCurrentHolder, Behavior aBehavior);
+ 
+   void AddActor(ActorChild* aActor);
+   void RemoveActor(ActorChild* aActor);
+ 
+   bool Notified() const;
+ 
+   // WorkerHolder methods
+-  virtual bool Notify(workers::Status aStatus) override;
++  virtual bool Notify(WorkerStatus aStatus) override;
+ 
+ private:
+   explicit CacheWorkerHolder(Behavior aBehavior);
+   ~CacheWorkerHolder();
+ 
+   nsTArray<ActorChild*> mActorList;
+   bool mNotified;
+ 
+diff --git a/dom/canvas/ImageBitmap.cpp b/dom/canvas/ImageBitmap.cpp
+--- a/dom/canvas/ImageBitmap.cpp
++++ b/dom/canvas/ImageBitmap.cpp
+@@ -1350,17 +1350,17 @@ public:
+   CreateImageBitmapFromBlobHolder(WorkerPrivate* aWorkerPrivate,
+                                   CreateImageBitmapFromBlob* aTask)
+     : WorkerHolder("CreateImageBitmapFromBlobHolder")
+     , mWorkerPrivate(aWorkerPrivate)
+     , mTask(aTask)
+     , mNotified(false)
+   {}
+ 
+-  bool Notify(Status aStatus) override
++  bool Notify(WorkerStatus aStatus) override
+   {
+     if (!mNotified) {
+       mNotified = true;
+       mTask->WorkerShuttingDown();
+     }
+     return true;
+   }
+ 
+diff --git a/dom/clients/api/Client.cpp b/dom/clients/api/Client.cpp
+--- a/dom/clients/api/Client.cpp
++++ b/dom/clients/api/Client.cpp
+@@ -14,17 +14,16 @@
+ #include "mozilla/dom/Promise.h"
+ #include "mozilla/dom/WorkerPrivate.h"
+ #include "mozilla/dom/WorkerScope.h"
+ #include "nsIGlobalObject.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+-using mozilla::dom::workers::Closing;
+ using mozilla::dom::workers::GetCurrentThreadWorkerPrivate;
+ using mozilla::dom::workers::WorkerPrivate;
+ using mozilla::dom::ipc::StructuredCloneData;
+ 
+ NS_IMPL_CYCLE_COLLECTING_ADDREF(mozilla::dom::Client);
+ NS_IMPL_CYCLE_COLLECTING_RELEASE(mozilla::dom::Client);
+ NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(mozilla::dom::Client, mGlobal);
+ 
+diff --git a/dom/clients/api/ClientDOMUtil.h b/dom/clients/api/ClientDOMUtil.h
+--- a/dom/clients/api/ClientDOMUtil.h
++++ b/dom/clients/api/ClientDOMUtil.h
+@@ -19,17 +19,17 @@ namespace dom {
+ // Utility method to properly execute a ClientManager operation.  It
+ // will properly hold a worker thread alive and avoid executing callbacks
+ // if the thread is shutting down.
+ template<typename Func, typename Arg, typename Resolve, typename Reject>
+ void
+ StartClientManagerOp(Func aFunc, const Arg& aArg, nsISerialEventTarget* aTarget,
+                      Resolve aResolve, Reject aReject)
+ {
+-  using mozilla::dom::workers::Closing;
++  using mozilla::dom::WorkerStatus::Closing;
+   using mozilla::dom::workers::GetCurrentThreadWorkerPrivate;
+ 
+   RefPtr<WorkerHolderToken> token;
+   if (!NS_IsMainThread()) {
+     token = WorkerHolderToken::Create(GetCurrentThreadWorkerPrivate(), Closing);
+   }
+ 
+   RefPtr<ClientOpPromise> promise = aFunc(aArg, aTarget);
+diff --git a/dom/clients/manager/ClientManager.cpp b/dom/clients/manager/ClientManager.cpp
+--- a/dom/clients/manager/ClientManager.cpp
++++ b/dom/clients/manager/ClientManager.cpp
+@@ -19,17 +19,16 @@
+ #include "prthread.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+ using mozilla::ipc::BackgroundChild;
+ using mozilla::ipc::PBackgroundChild;
+ using mozilla::ipc::PrincipalInfo;
+-using mozilla::dom::workers::Closing;
+ using mozilla::dom::workers::GetCurrentThreadWorkerPrivate;
+ using mozilla::dom::workers::WorkerPrivate;
+ 
+ namespace {
+ 
+ uint32_t kBadThreadLocalIndex = -1;
+ uint32_t sClientManagerThreadLocalIndex = kBadThreadLocalIndex;
+ 
+diff --git a/dom/crypto/WebCryptoTask.cpp b/dom/crypto/WebCryptoTask.cpp
+--- a/dom/crypto/WebCryptoTask.cpp
++++ b/dom/crypto/WebCryptoTask.cpp
+@@ -14,18 +14,18 @@
+ #include "mozilla/Telemetry.h"
+ #include "mozilla/dom/CryptoBuffer.h"
+ #include "mozilla/dom/CryptoKey.h"
+ #include "mozilla/dom/KeyAlgorithmProxy.h"
+ #include "mozilla/dom/TypedArray.h"
+ #include "mozilla/dom/WebCryptoCommon.h"
+ #include "mozilla/dom/WebCryptoTask.h"
+ #include "mozilla/dom/WebCryptoThreadPool.h"
++#include "mozilla/dom/WorkerHolder.h"
+ #include "mozilla/dom/WorkerPrivate.h"
+-#include "mozilla/dom/workers/bindings/WorkerHolder.h"
+ 
+ // Template taken from security/nss/lib/util/templates.c
+ // This (or SGN_EncodeDigestInfo) would ideally be exported
+ // by NSS and until that happens we have to keep our own copy.
+ const SEC_ASN1Template SGN_DigestInfoTemplate[] = {
+     { SEC_ASN1_SEQUENCE,
+       0, NULL, sizeof(SGNDigestInfo) },
+     { SEC_ASN1_INLINE,
+@@ -34,20 +34,17 @@ const SEC_ASN1Template SGN_DigestInfoTem
+     { SEC_ASN1_OCTET_STRING,
+       offsetof(SGNDigestInfo,digest) },
+     { 0, }
+ };
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+-using mozilla::dom::workers::Canceling;
+ using mozilla::dom::workers::GetCurrentThreadWorkerPrivate;
+-using mozilla::dom::workers::Status;
+-using mozilla::dom::workers::WorkerHolder;
+ using mozilla::dom::workers::WorkerPrivate;
+ 
+ // Pre-defined identifiers for telemetry histograms
+ 
+ enum TelemetryMethod {
+   TM_ENCRYPT      = 0,
+   TM_DECRYPT      = 1,
+   TM_SIGN         = 2,
+@@ -164,17 +161,17 @@ public:
+     RefPtr<InternalWorkerHolder> ref = new InternalWorkerHolder();
+     if (NS_WARN_IF(!ref->HoldWorker(workerPrivate, Canceling))) {
+       return nullptr;
+     }
+     return ref.forget();
+   }
+ 
+   virtual bool
+-  Notify(Status aStatus) override
++  Notify(WorkerStatus aStatus) override
+   {
+     NS_ASSERT_OWNINGTHREAD(InternalWorkerHolder);
+     // Do nothing here.  Since WebCryptoTask dispatches back to
+     // the worker thread using nsThread::Dispatch() instead of
+     // WorkerRunnable it will always be able to execute its
+     // runnables.
+     return true;
+   }
+diff --git a/dom/fetch/Fetch.cpp b/dom/fetch/Fetch.cpp
+--- a/dom/fetch/Fetch.cpp
++++ b/dom/fetch/Fetch.cpp
+@@ -168,17 +168,17 @@ class WorkerNotifier final : public Work
+ 
+ public:
+   explicit WorkerNotifier(WorkerFetchResolver* aResolver)
+     : WorkerHolder("WorkerNotifier", AllowIdleShutdownStart)
+     , mResolver(aResolver)
+   {}
+ 
+   bool
+-  Notify(Status aStatus) override;
++  Notify(WorkerStatus aStatus) override;
+ };
+ 
+ class WorkerFetchResolver final : public FetchDriverObserver
+ {
+   // Thread-safe:
+   RefPtr<PromiseWorkerProxy> mPromiseProxy;
+   RefPtr<AbortSignalProxy> mSignalProxy;
+ 
+@@ -770,17 +770,17 @@ public:
+     WorkerRunInternal(aWorkerPrivate);
+     return true;
+   }
+ 
+   // Control runnable cancel already calls Run().
+ };
+ 
+ bool
+-WorkerNotifier::Notify(Status aStatus)
++WorkerNotifier::Notify(WorkerStatus aStatus)
+ {
+   if (mResolver) {
+     // This will nullify this object.
+     // No additional operation after this line!
+     mResolver->Shutdown(mWorkerPrivate);
+   }
+ 
+   return true;
+diff --git a/dom/fetch/FetchConsumer.cpp b/dom/fetch/FetchConsumer.cpp
+--- a/dom/fetch/FetchConsumer.cpp
++++ b/dom/fetch/FetchConsumer.cpp
+@@ -18,35 +18,35 @@
+ namespace mozilla {
+ namespace dom {
+ 
+ using namespace workers;
+ 
+ namespace {
+ 
+ template <class Derived>
+-class FetchBodyWorkerHolder final : public workers::WorkerHolder
++class FetchBodyWorkerHolder final : public WorkerHolder
+ {
+   RefPtr<FetchBodyConsumer<Derived>> mConsumer;
+   bool mWasNotified;
+ 
+ public:
+   explicit FetchBodyWorkerHolder(FetchBodyConsumer<Derived>* aConsumer)
+-    : workers::WorkerHolder("FetchBodyWorkerHolder")
++    : WorkerHolder("FetchBodyWorkerHolder")
+     , mConsumer(aConsumer)
+     , mWasNotified(false)
+   {
+     MOZ_ASSERT(aConsumer);
+   }
+ 
+   ~FetchBodyWorkerHolder() = default;
+ 
+-  bool Notify(workers::Status aStatus) override
++  bool Notify(WorkerStatus aStatus) override
+   {
+-    MOZ_ASSERT(aStatus > workers::Running);
++    MOZ_ASSERT(aStatus > Running);
+     if (!mWasNotified) {
+       mWasNotified = true;
+       mConsumer->ShutDownMainThreadConsuming();
+     }
+ 
+     return true;
+   }
+ };
+diff --git a/dom/fetch/FetchConsumer.h b/dom/fetch/FetchConsumer.h
+--- a/dom/fetch/FetchConsumer.h
++++ b/dom/fetch/FetchConsumer.h
+@@ -14,20 +14,20 @@
+ #include "nsWeakReference.h"
+ 
+ class nsIThread;
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+ class Promise;
++class WorkerHolder;
+ 
+ namespace workers {
+ class WorkerPrivate;
+-class WorkerHolder;
+ }
+ 
+ template <class Derived> class FetchBody;
+ 
+ // FetchBody is not thread-safe but we need to move it around threads.
+ // In order to keep it alive all the time, we use a WorkerHolder, if created on
+ // workers, plus a this consumer.
+ template <class Derived>
+@@ -107,17 +107,17 @@ private:
+   nsCOMPtr<nsIInputStream> mBodyStream;
+ 
+   MutableBlobStorage::MutableBlobStorageType mBlobStorageType;
+   nsCString mBodyMimeType;
+ 
+   // Set when consuming the body is attempted on a worker.
+   // Unset when consumption is done/aborted.
+   // This WorkerHolder keeps alive the consumer via a cycle.
+-  UniquePtr<workers::WorkerHolder> mWorkerHolder;
++  UniquePtr<WorkerHolder> mWorkerHolder;
+ 
+   nsCOMPtr<nsIGlobalObject> mGlobal;
+ 
+   // Always set whenever the FetchBodyConsumer is created on the worker thread.
+   workers::WorkerPrivate* mWorkerPrivate;
+ 
+   // Touched on the main-thread only.
+   nsCOMPtr<nsIInputStreamPump> mConsumeBodyPump;
+diff --git a/dom/fetch/FetchStream.cpp b/dom/fetch/FetchStream.cpp
+--- a/dom/fetch/FetchStream.cpp
++++ b/dom/fetch/FetchStream.cpp
+@@ -29,17 +29,17 @@ class FetchStreamWorkerHolder final : pu
+ public:
+   explicit FetchStreamWorkerHolder(FetchStream* aStream)
+     : WorkerHolder("FetchStreamWorkerHolder",
+                    WorkerHolder::Behavior::AllowIdleShutdownStart)
+     , mStream(aStream)
+     , mWasNotified(false)
+   {}
+ 
+-  bool Notify(Status aStatus) override
++  bool Notify(WorkerStatus aStatus) override
+   {
+     if (!mWasNotified) {
+       mWasNotified = true;
+       mStream->Close();
+     }
+ 
+     return true;
+   }
+diff --git a/dom/fetch/FetchStream.h b/dom/fetch/FetchStream.h
+--- a/dom/fetch/FetchStream.h
++++ b/dom/fetch/FetchStream.h
+@@ -16,21 +16,18 @@
+ 
+ class nsIGlobalObject;
+ 
+ class nsIInputStream;
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+-namespace workers {
++class FetchStreamHolder;
+ class WorkerHolder;
+-}
+-
+-class FetchStreamHolder;
+ 
+ class FetchStream final : public nsIInputStreamCallback
+                         , public nsIObserver
+                         , public nsSupportsWeakReference
+ {
+ public:
+   NS_DECL_THREADSAFE_ISUPPORTS
+   NS_DECL_NSIINPUTSTREAMCALLBACK
+@@ -120,15 +117,15 @@ private:
+   nsCOMPtr<nsIEventTarget> mOwningEventTarget;
+ 
+   // This is the original inputStream received during the CTOR. It will be
+   // converted into an nsIAsyncInputStream and stored into mInputStream at the
+   // first use.
+   nsCOMPtr<nsIInputStream> mOriginalInputStream;
+   nsCOMPtr<nsIAsyncInputStream> mInputStream;
+ 
+-  UniquePtr<workers::WorkerHolder> mWorkerHolder;
++  UniquePtr<WorkerHolder> mWorkerHolder;
+ };
+ 
+ } // dom namespace
+ } // mozilla namespace
+ 
+ #endif // mozilla_dom_FetchStream_h
+diff --git a/dom/fetch/FetchStreamReader.cpp b/dom/fetch/FetchStreamReader.cpp
+--- a/dom/fetch/FetchStreamReader.cpp
++++ b/dom/fetch/FetchStreamReader.cpp
+@@ -25,17 +25,17 @@ class FetchStreamReaderWorkerHolder fina
+ public:
+   explicit FetchStreamReaderWorkerHolder(FetchStreamReader* aReader)
+     : WorkerHolder("FetchStreamReaderWorkerHolder",
+                    WorkerHolder::Behavior::AllowIdleShutdownStart)
+     , mReader(aReader)
+     , mWasNotified(false)
+   {}
+ 
+-  bool Notify(Status aStatus) override
++  bool Notify(WorkerStatus aStatus) override
+   {
+     if (!mWasNotified) {
+       mWasNotified = true;
+       // The WorkerPrivate does have a context available, and we could pass it
+       // here to trigger cancellation of the reader, but the author of this
+       // comment chickened out.
+       mReader->CloseAndRelease(nullptr, NS_ERROR_DOM_INVALID_STATE_ERR);
+     }
+diff --git a/dom/fetch/FetchStreamReader.h b/dom/fetch/FetchStreamReader.h
+--- a/dom/fetch/FetchStreamReader.h
++++ b/dom/fetch/FetchStreamReader.h
+@@ -10,19 +10,17 @@
+ #include "jsapi.h"
+ #include "mozilla/dom/FetchBinding.h"
+ #include "mozilla/dom/PromiseNativeHandler.h"
+ #include "nsIAsyncOutputStream.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+-namespace workers {
+ class WorkerHolder;
+-}
+ 
+ class FetchStreamReader final : public nsIOutputStreamCallback
+                               , public PromiseNativeHandler
+ {
+ public:
+   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
+   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(FetchStreamReader, nsIOutputStreamCallback)
+   NS_DECL_NSIOUTPUTSTREAMCALLBACK
+@@ -63,17 +61,17 @@ private:
+   void
+   ReportErrorToConsole(JSContext* aCx, JS::Handle<JS::Value> aValue);
+ 
+   nsCOMPtr<nsIGlobalObject> mGlobal;
+   nsCOMPtr<nsIEventTarget> mOwningEventTarget;
+ 
+   nsCOMPtr<nsIAsyncOutputStream> mPipeOut;
+ 
+-  UniquePtr<workers::WorkerHolder> mWorkerHolder;
++  UniquePtr<WorkerHolder> mWorkerHolder;
+ 
+   JS::Heap<JSObject*> mReader;
+ 
+   UniquePtr<FetchReadableStreamReadDataArray> mBuffer;
+   uint32_t mBufferRemaining;
+   uint32_t mBufferOffset;
+ 
+   bool mStreamClosed;
+diff --git a/dom/fetch/FetchUtil.cpp b/dom/fetch/FetchUtil.cpp
+--- a/dom/fetch/FetchUtil.cpp
++++ b/dom/fetch/FetchUtil.cpp
+@@ -279,17 +279,17 @@ public:
+     , mStream(aStream)
+   {}
+ 
+   static UniquePtr<WorkerStreamOwner>
+   Create(nsIAsyncInputStream* aStream, WorkerPrivate* aWorker)
+   {
+     auto self = MakeUnique<WorkerStreamOwner>(aStream);
+ 
+-    if (!self->HoldWorker(aWorker, workers::Closing)) {
++    if (!self->HoldWorker(aWorker, Closing)) {
+       return nullptr;
+     }
+ 
+     return self;
+   }
+ 
+   struct Destroyer final : CancelableRunnable
+   {
+@@ -311,17 +311,17 @@ public:
+     Cancel() override
+     {
+       return Run();
+     }
+   };
+ 
+   // WorkerHolder:
+ 
+-  bool Notify(workers::Status aStatus) override
++  bool Notify(WorkerStatus aStatus) override
+   {
+     if (!mStream) {
+       return true;
+     }
+ 
+     // If this Close() calls JSStreamConsumer::OnInputStreamReady and drops the
+     // last reference to the JSStreamConsumer, 'this' will not be destroyed
+     // since ~JSStreamConsumer() only enqueues a Destroyer.
+diff --git a/dom/file/FileReader.cpp b/dom/file/FileReader.cpp
+--- a/dom/file/FileReader.cpp
++++ b/dom/file/FileReader.cpp
+@@ -829,17 +829,17 @@ FileReader::DecreaseBusyCounter()
+ {
+   MOZ_ASSERT_IF(mWorkerPrivate, mBusyCount);
+   if (mWorkerPrivate && --mBusyCount == 0) {
+     ReleaseWorker();
+   }
+ }
+ 
+ bool
+-FileReader::Notify(Status aStatus)
++FileReader::Notify(WorkerStatus aStatus)
+ {
+   MOZ_ASSERT(mWorkerPrivate);
+   mWorkerPrivate->AssertIsOnWorkerThread();
+ 
+   if (aStatus > Running) {
+     Shutdown();
+   }
+ 
+diff --git a/dom/file/FileReader.h b/dom/file/FileReader.h
+--- a/dom/file/FileReader.h
++++ b/dom/file/FileReader.h
+@@ -38,17 +38,17 @@ extern const uint64_t kUnknownSize;
+ class FileReaderDecreaseBusyCounter;
+ 
+ class FileReader final : public DOMEventTargetHelper,
+                          public nsIInterfaceRequestor,
+                          public nsSupportsWeakReference,
+                          public nsIInputStreamCallback,
+                          public nsITimerCallback,
+                          public nsINamed,
+-                         public workers::WorkerHolder
++                         public WorkerHolder
+ {
+   friend class FileReaderDecreaseBusyCounter;
+ 
+ public:
+   FileReader(nsIGlobalObject* aGlobal,
+              workers::WorkerPrivate* aWorkerPrivate);
+ 
+   NS_DECL_ISUPPORTS_INHERITED
+@@ -110,17 +110,17 @@ public:
+   IMPL_EVENT_HANDLER(loadend)
+ 
+   void ReadAsBinaryString(Blob& aBlob, ErrorResult& aRv)
+   {
+     ReadFileContent(aBlob, EmptyString(), FILE_AS_BINARY, aRv);
+   }
+ 
+   // WorkerHolder
+-  bool Notify(workers::Status) override;
++  bool Notify(WorkerStatus) override;
+ 
+ private:
+   virtual ~FileReader();
+ 
+   // This must be in sync with dom/webidl/FileReader.webidl
+   enum eReadyState {
+     EMPTY = 0,
+     LOADING = 1,
+diff --git a/dom/file/ipc/IPCBlobInputStreamChild.cpp b/dom/file/ipc/IPCBlobInputStreamChild.cpp
+--- a/dom/file/ipc/IPCBlobInputStreamChild.cpp
++++ b/dom/file/ipc/IPCBlobInputStreamChild.cpp
+@@ -94,28 +94,27 @@ private:
+ 
+ class IPCBlobInputStreamWorkerHolder final : public WorkerHolder
+ {
+ public:
+   IPCBlobInputStreamWorkerHolder()
+     : WorkerHolder("IPCBlobInputStreamWorkerHolder")
+   {}
+ 
+-  bool Notify(Status aStatus) override
++  bool Notify(WorkerStatus aStatus) override
+   {
+     // We must keep the worker alive until the migration is completed.
+     return true;
+   }
+ };
+ 
+ class ReleaseWorkerHolderRunnable final : public CancelableRunnable
+ {
+ public:
+-  explicit ReleaseWorkerHolderRunnable(
+-    UniquePtr<workers::WorkerHolder>&& aWorkerHolder)
++  explicit ReleaseWorkerHolderRunnable(UniquePtr<WorkerHolder>&& aWorkerHolder)
+     : CancelableRunnable("dom::ReleaseWorkerHolderRunnable")
+     , mWorkerHolder(Move(aWorkerHolder))
+   {}
+ 
+   NS_IMETHOD
+   Run() override
+   {
+     mWorkerHolder = nullptr;
+@@ -124,17 +123,17 @@ public:
+ 
+   nsresult
+   Cancel() override
+   {
+     return Run();
+   }
+ 
+ private:
+-  UniquePtr<workers::WorkerHolder> mWorkerHolder;
++  UniquePtr<WorkerHolder> mWorkerHolder;
+ };
+ 
+ } // anonymous
+ 
+ IPCBlobInputStreamChild::IPCBlobInputStreamChild(const nsID& aID,
+                                                  uint64_t aSize)
+   : mMutex("IPCBlobInputStreamChild::mMutex")
+   , mID(aID)
+diff --git a/dom/file/ipc/IPCBlobInputStreamChild.h b/dom/file/ipc/IPCBlobInputStreamChild.h
+--- a/dom/file/ipc/IPCBlobInputStreamChild.h
++++ b/dom/file/ipc/IPCBlobInputStreamChild.h
+@@ -11,21 +11,18 @@
+ #include "mozilla/Mutex.h"
+ #include "mozilla/UniquePtr.h"
+ #include "nsIThread.h"
+ #include "nsTArray.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+-namespace workers {
++class IPCBlobInputStream;
+ class WorkerHolder;
+-}
+-
+-class IPCBlobInputStream;
+ 
+ class IPCBlobInputStreamChild final
+   : public mozilla::ipc::PIPCBlobInputStreamChild
+ {
+ public:
+   enum ActorState
+   {
+     // The actor is connected via IPDL to the parent.
+@@ -105,15 +102,15 @@ private:
+   {
+     RefPtr<IPCBlobInputStream> mStream;
+     nsCOMPtr<nsIEventTarget> mEventTarget;
+   };
+   nsTArray<PendingOperation> mPendingOperations;
+ 
+   nsCOMPtr<nsISerialEventTarget> mOwningEventTarget;
+ 
+-  UniquePtr<workers::WorkerHolder> mWorkerHolder;
++  UniquePtr<WorkerHolder> mWorkerHolder;
+ };
+ 
+ } // namespace dom
+ } // namespace mozilla
+ 
+ #endif // mozilla_dom_ipc_IPCBlobInputStreamChild_h
+diff --git a/dom/indexedDB/IDBRequest.cpp b/dom/indexedDB/IDBRequest.cpp
+--- a/dom/indexedDB/IDBRequest.cpp
++++ b/dom/indexedDB/IDBRequest.cpp
+@@ -411,29 +411,29 @@ IDBRequest::GetEventTargetParent(EventCh
+   AssertIsOnOwningThread();
+ 
+   aVisitor.mCanHandle = true;
+   aVisitor.SetParentTarget(mTransaction, false);
+   return NS_OK;
+ }
+ 
+ class IDBOpenDBRequest::WorkerHolder final
+-  : public mozilla::dom::workers::WorkerHolder
++  : public mozilla::dom::WorkerHolder
+ {
+   WorkerPrivate* mWorkerPrivate;
+ #ifdef DEBUG
+   // This is only here so that assertions work in the destructor even if
+   // NoteAddWorkerHolderFailed was called.
+   WorkerPrivate* mWorkerPrivateDEBUG;
+ #endif
+ 
+ public:
+   explicit
+   WorkerHolder(WorkerPrivate* aWorkerPrivate)
+-    : mozilla::dom::workers::WorkerHolder("IDBOpenDBRequest::WorkerHolder")
++    : mozilla::dom::WorkerHolder("IDBOpenDBRequest::WorkerHolder")
+     , mWorkerPrivate(aWorkerPrivate)
+ #ifdef DEBUG
+     , mWorkerPrivateDEBUG(aWorkerPrivate)
+ #endif
+   {
+     MOZ_ASSERT(aWorkerPrivate);
+     aWorkerPrivate->AssertIsOnWorkerThread();
+ 
+@@ -455,17 +455,17 @@ public:
+     MOZ_ASSERT(mWorkerPrivate);
+     mWorkerPrivate->AssertIsOnWorkerThread();
+ 
+     mWorkerPrivate = nullptr;
+   }
+ 
+ private:
+   virtual bool
+-  Notify(Status aStatus) override;
++  Notify(WorkerStatus aStatus) override;
+ };
+ 
+ IDBOpenDBRequest::IDBOpenDBRequest(IDBFactory* aFactory,
+                                    nsPIDOMWindowInner* aOwner,
+                                    bool aFileHandleDisabled)
+   : IDBRequest(aOwner)
+   , mFactory(aFactory)
+   , mFileHandleDisabled(aFileHandleDisabled)
+@@ -659,17 +659,17 @@ IDBOpenDBRequest::WrapObject(JSContext* 
+ {
+   AssertIsOnOwningThread();
+ 
+   return IDBOpenDBRequestBinding::Wrap(aCx, this, aGivenProto);
+ }
+ 
+ bool
+ IDBOpenDBRequest::
+-WorkerHolder::Notify(Status aStatus)
++WorkerHolder::Notify(WorkerStatus aStatus)
+ {
+   MOZ_ASSERT(mWorkerPrivate);
+   mWorkerPrivate->AssertIsOnWorkerThread();
+   MOZ_ASSERT(aStatus > Running);
+ 
+   // There's nothing we can really do here at the moment...
+   NS_WARNING("Worker closing but IndexedDB is waiting to open a database!");
+ 
+diff --git a/dom/indexedDB/IDBTransaction.cpp b/dom/indexedDB/IDBTransaction.cpp
+--- a/dom/indexedDB/IDBTransaction.cpp
++++ b/dom/indexedDB/IDBTransaction.cpp
+@@ -31,28 +31,27 @@
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+ using namespace mozilla::dom::indexedDB;
+ using namespace mozilla::dom::workers;
+ using namespace mozilla::ipc;
+ 
+-class IDBTransaction::WorkerHolder final
+-  : public mozilla::dom::workers::WorkerHolder
++class IDBTransaction::WorkerHolder final : public mozilla::dom::WorkerHolder
+ {
+   WorkerPrivate* mWorkerPrivate;
+ 
+   // The IDBTransaction owns this object so we only need a weak reference back
+   // to it.
+   IDBTransaction* mTransaction;
+ 
+ public:
+   WorkerHolder(WorkerPrivate* aWorkerPrivate, IDBTransaction* aTransaction)
+-    : mozilla::dom::workers::WorkerHolder("IDBTransaction::WorkerHolder")
++    : mozilla::dom::WorkerHolder("IDBTransaction::WorkerHolder")
+     , mWorkerPrivate(aWorkerPrivate)
+     , mTransaction(aTransaction)
+   {
+     MOZ_ASSERT(aWorkerPrivate);
+     MOZ_ASSERT(aTransaction);
+     aWorkerPrivate->AssertIsOnWorkerThread();
+     aTransaction->AssertIsOnOwningThread();
+ 
+@@ -63,17 +62,17 @@ public:
+   {
+     mWorkerPrivate->AssertIsOnWorkerThread();
+ 
+     MOZ_COUNT_DTOR(IDBTransaction::WorkerHolder);
+   }
+ 
+ private:
+   virtual bool
+-  Notify(Status aStatus) override;
++  Notify(WorkerStatus aStatus) override;
+ };
+ 
+ IDBTransaction::IDBTransaction(IDBDatabase* aDatabase,
+                                const nsTArray<nsString>& aObjectStoreNames,
+                                Mode aMode)
+   : IDBWrapperCache(aDatabase)
+   , mDatabase(aDatabase)
+   , mObjectStoreNames(aObjectStoreNames)
+@@ -1073,17 +1072,17 @@ IDBTransaction::Run()
+     SendCommit();
+   }
+ 
+   return NS_OK;
+ }
+ 
+ bool
+ IDBTransaction::
+-WorkerHolder::Notify(Status aStatus)
++WorkerHolder::Notify(WorkerStatus aStatus)
+ {
+   MOZ_ASSERT(mWorkerPrivate);
+   mWorkerPrivate->AssertIsOnWorkerThread();
+   MOZ_ASSERT(aStatus > Running);
+ 
+   if (mTransaction && aStatus > Terminating) {
+     mTransaction->AssertIsOnOwningThread();
+ 
+diff --git a/dom/messagechannel/MessagePort.cpp b/dom/messagechannel/MessagePort.cpp
+--- a/dom/messagechannel/MessagePort.cpp
++++ b/dom/messagechannel/MessagePort.cpp
+@@ -199,30 +199,30 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(
+   NS_INTERFACE_MAP_ENTRY(nsIObserver)
+ NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
+ 
+ NS_IMPL_ADDREF_INHERITED(MessagePort, DOMEventTargetHelper)
+ NS_IMPL_RELEASE_INHERITED(MessagePort, DOMEventTargetHelper)
+ 
+ namespace {
+ 
+-class MessagePortWorkerHolder final : public workers::WorkerHolder
++class MessagePortWorkerHolder final : public WorkerHolder
+ {
+   MessagePort* mPort;
+ 
+ public:
+   explicit MessagePortWorkerHolder(MessagePort* aPort)
+-    : workers::WorkerHolder("MessagePortWorkerHolder")
++    : WorkerHolder("MessagePortWorkerHolder")
+     , mPort(aPort)
+   {
+     MOZ_ASSERT(aPort);
+     MOZ_COUNT_CTOR(MessagePortWorkerHolder);
+   }
+ 
+-  virtual bool Notify(workers::Status aStatus) override
++  virtual bool Notify(WorkerStatus aStatus) override
+   {
+     if (aStatus > Running) {
+       // We cannot process messages anymore because we cannot dispatch new
+       // runnables. Let's force a Close().
+       mPort->CloseForced();
+     }
+ 
+     return true;
+diff --git a/dom/messagechannel/MessagePort.h b/dom/messagechannel/MessagePort.h
+--- a/dom/messagechannel/MessagePort.h
++++ b/dom/messagechannel/MessagePort.h
+@@ -21,20 +21,17 @@ class nsIGlobalObject;
+ namespace mozilla {
+ namespace dom {
+ 
+ class ClonedMessageData;
+ class MessagePortChild;
+ class MessagePortIdentifier;
+ class PostMessageRunnable;
+ class SharedMessagePortMessage;
+-
+-namespace workers {
+ class WorkerHolder;
+-} // namespace workers
+ 
+ class MessagePort final : public DOMEventTargetHelper
+                         , public nsIObserver
+ {
+   friend class PostMessageRunnable;
+ 
+ public:
+   NS_DECL_NSIOBSERVER
+@@ -160,17 +157,17 @@ private:
+   // We release the object when the port is closed or disentangled.
+   void UpdateMustKeepAlive();
+ 
+   bool IsCertainlyAliveForCC() const override
+   {
+     return mIsKeptAlive;
+   }
+ 
+-  nsAutoPtr<workers::WorkerHolder> mWorkerHolder;
++  nsAutoPtr<WorkerHolder> mWorkerHolder;
+ 
+   RefPtr<PostMessageRunnable> mPostMessageRunnable;
+ 
+   RefPtr<MessagePortChild> mActor;
+ 
+   RefPtr<MessagePort> mUnshippedEntangledPort;
+ 
+   nsTArray<RefPtr<SharedMessagePortMessage>> mMessages;
+diff --git a/dom/network/ConnectionWorker.cpp b/dom/network/ConnectionWorker.cpp
+--- a/dom/network/ConnectionWorker.cpp
++++ b/dom/network/ConnectionWorker.cpp
+@@ -31,17 +31,17 @@ public:
+ 
+     return proxy.forget();
+   }
+ 
+   // For IObserver - main-thread only.
+   void Notify(const hal::NetworkInformation& aNetworkInfo) override;
+ 
+   // Worker notification
+-  virtual bool Notify(Status aStatus) override
++  virtual bool Notify(WorkerStatus aStatus) override
+   {
+     Shutdown();
+     return true;
+   }
+ 
+   void Shutdown();
+ 
+   void Update(ConnectionType aType, bool aIsWifi, uint32_t aDHCPGateway)
+diff --git a/dom/notification/Notification.cpp b/dom/notification/Notification.cpp
+--- a/dom/notification/Notification.cpp
++++ b/dom/notification/Notification.cpp
+@@ -2253,17 +2253,17 @@ class CloseNotificationRunnable final
+   bool
+   HadObserver()
+   {
+     return mHadObserver;
+   }
+ };
+ 
+ bool
+-NotificationWorkerHolder::Notify(Status aStatus)
++NotificationWorkerHolder::Notify(WorkerStatus aStatus)
+ {
+   if (aStatus >= Canceling) {
+     // CloseNotificationRunnable blocks the worker by pushing a sync event loop
+     // on the stack. Meanwhile, WorkerControlRunnables dispatched to the worker
+     // can still continue running. One of these is
+     // ReleaseNotificationControlRunnable that releases the notification,
+     // invalidating the notification and this feature. We hold this reference to
+     // keep the notification valid until we are done with it.
+diff --git a/dom/notification/Notification.h b/dom/notification/Notification.h
+--- a/dom/notification/Notification.h
++++ b/dom/notification/Notification.h
+@@ -5,17 +5,17 @@
+  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+ 
+ #ifndef mozilla_dom_notification_h__
+ #define mozilla_dom_notification_h__
+ 
+ #include "mozilla/DOMEventTargetHelper.h"
+ #include "mozilla/UniquePtr.h"
+ #include "mozilla/dom/NotificationBinding.h"
+-#include "mozilla/dom/workers/bindings/WorkerHolder.h"
++#include "mozilla/dom/WorkerHolder.h"
+ 
+ #include "nsIObserver.h"
+ #include "nsISupports.h"
+ 
+ #include "nsCycleCollectionParticipant.h"
+ #include "nsHashKeys.h"
+ #include "nsTHashtable.h"
+ #include "nsWeakReference.h"
+@@ -30,27 +30,27 @@ class NotificationRef;
+ class WorkerNotificationObserver;
+ class Promise;
+ 
+ namespace workers {
+   class WorkerPrivate;
+ } // namespace workers
+ 
+ class Notification;
+-class NotificationWorkerHolder final : public workers::WorkerHolder
++class NotificationWorkerHolder final : public WorkerHolder
+ {
+   // Since the feature is strongly held by a Notification, it is ok to hold
+   // a raw pointer here.
+   Notification* mNotification;
+ 
+ public:
+   explicit NotificationWorkerHolder(Notification* aNotification);
+ 
+   bool
+-  Notify(workers::Status aStatus) override;
++  Notify(WorkerStatus aStatus) override;
+ };
+ 
+ /*
+  * Notifications on workers introduce some lifetime issues. The property we
+  * are trying to satisfy is:
+  *   Whenever a task is dispatched to the main thread to operate on
+  *   a Notification, the Notification should be addrefed on the worker thread
+  *   and a feature should be added to observe the worker lifetime. This main
+diff --git a/dom/notification/NotificationEvent.cpp b/dom/notification/NotificationEvent.cpp
+--- a/dom/notification/NotificationEvent.cpp
++++ b/dom/notification/NotificationEvent.cpp
+@@ -3,24 +3,20 @@
+ /* 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 "NotificationEvent.h"
+ 
+ using namespace mozilla::dom;
+ 
+-BEGIN_WORKERS_NAMESPACE
+-
+ NotificationEvent::NotificationEvent(EventTarget* aOwner)
+   : ExtendableEvent(aOwner)
+ {
+ }
+ 
+ NS_IMPL_ADDREF_INHERITED(NotificationEvent, ExtendableEvent)
+ NS_IMPL_RELEASE_INHERITED(NotificationEvent, ExtendableEvent)
+ 
+ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(NotificationEvent)
+ NS_INTERFACE_MAP_END_INHERITING(ExtendableEvent)
+ 
+ NS_IMPL_CYCLE_COLLECTION_INHERITED(NotificationEvent, ExtendableEvent, mNotification)
+-
+-END_WORKERS_NAMESPACE
+diff --git a/dom/notification/NotificationEvent.h b/dom/notification/NotificationEvent.h
+--- a/dom/notification/NotificationEvent.h
++++ b/dom/notification/NotificationEvent.h
+@@ -7,17 +7,18 @@
+ #ifndef mozilla_dom_workers_notificationevent_h__
+ #define mozilla_dom_workers_notificationevent_h__
+ 
+ #include "mozilla/dom/Event.h"
+ #include "mozilla/dom/NotificationEventBinding.h"
+ #include "mozilla/dom/ServiceWorkerEvents.h"
+ #include "mozilla/dom/workers/WorkerCommon.h"
+ 
+-BEGIN_WORKERS_NAMESPACE
++namespace mozilla {
++namespace dom {
+ 
+ class ServiceWorker;
+ class ServiceWorkerClient;
+ 
+ class NotificationEvent final : public ExtendableEvent
+ {
+ protected:
+   explicit NotificationEvent(EventTarget* aOwner);
+@@ -66,11 +67,12 @@ public:
+     RefPtr<Notification> n = mNotification;
+     return n.forget();
+   }
+ 
+ private:
+   RefPtr<Notification> mNotification;
+ };
+ 
+-END_WORKERS_NAMESPACE
++} // dom namspace
++} // mozilla namespace
++
+ #endif /* mozilla_dom_workers_notificationevent_h__ */
+-
+diff --git a/dom/performance/PerformanceStorageWorker.cpp b/dom/performance/PerformanceStorageWorker.cpp
+--- a/dom/performance/PerformanceStorageWorker.cpp
++++ b/dom/performance/PerformanceStorageWorker.cpp
+@@ -121,17 +121,17 @@ class PerformanceStorageWorkerHolder fin
+ public:
+   explicit PerformanceStorageWorkerHolder(PerformanceStorageWorker* aStorage)
+     : WorkerHolder("PerformanceStorageWorkerHolder",
+                    WorkerHolder::AllowIdleShutdownStart)
+     , mStorage(aStorage)
+   {}
+ 
+   bool
+-  Notify(Status aStatus) override
++  Notify(WorkerStatus aStatus) override
+   {
+     if (mStorage) {
+       RefPtr<PerformanceStorageWorker> storage;
+       storage.swap(mStorage);
+       storage->ShutdownOnWorker();
+     }
+ 
+     return true;
+diff --git a/dom/performance/PerformanceStorageWorker.h b/dom/performance/PerformanceStorageWorker.h
+--- a/dom/performance/PerformanceStorageWorker.h
++++ b/dom/performance/PerformanceStorageWorker.h
+@@ -7,18 +7,19 @@
+ #ifndef mozilla_dom_PerformanceStorageWorker_h
+ #define mozilla_dom_PerformanceStorageWorker_h
+ 
+ #include "PerformanceStorage.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
++class WorkerHolder;
++
+ namespace workers {
+-class WorkerHolder;
+ class WorkerPrivate;
+ }
+ 
+ class PerformanceProxyData;
+ 
+ class PerformanceStorageWorker final : public PerformanceStorage
+ {
+ public:
+@@ -50,15 +51,15 @@ private:
+   // Protected by mutex.
+   enum {
+     eInitializing,
+     eReady,
+     eTerminated,
+   } mState;
+ 
+   // Touched on worker-thread only.
+-  UniquePtr<workers::WorkerHolder> mWorkerHolder;
++  UniquePtr<WorkerHolder> mWorkerHolder;
+ };
+ 
+ } // namespace dom
+ } // namespace mozilla
+ 
+ #endif // mozilla_dom_PerformanceStorageWorker_h
+diff --git a/dom/promise/Promise.cpp b/dom/promise/Promise.cpp
+--- a/dom/promise/Promise.cpp
++++ b/dom/promise/Promise.cpp
+@@ -699,17 +699,17 @@ public:
+   explicit PromiseWorkerHolder(PromiseWorkerProxy* aProxy)
+     : WorkerHolder("PromiseWorkerHolder")
+     , mProxy(aProxy)
+   {
+     MOZ_ASSERT(aProxy);
+   }
+ 
+   bool
+-  Notify(Status aStatus) override
++  Notify(WorkerStatus aStatus) override
+   {
+     if (aStatus >= Canceling) {
+       mProxy->CleanUp();
+     }
+ 
+     return true;
+   }
+ };
+diff --git a/dom/promise/PromiseWorkerProxy.h b/dom/promise/PromiseWorkerProxy.h
+--- a/dom/promise/PromiseWorkerProxy.h
++++ b/dom/promise/PromiseWorkerProxy.h
+@@ -6,17 +6,17 @@
+ 
+ #ifndef mozilla_dom_PromiseWorkerProxy_h
+ #define mozilla_dom_PromiseWorkerProxy_h
+ 
+ // Required for Promise::PromiseTaskSync.
+ #include "mozilla/dom/Promise.h"
+ #include "mozilla/dom/PromiseNativeHandler.h"
+ #include "mozilla/dom/StructuredCloneHolder.h"
+-#include "mozilla/dom/workers/bindings/WorkerHolder.h"
++#include "mozilla/dom/WorkerHolder.h"
+ #include "nsProxyRelease.h"
+ 
+ #include "WorkerRunnable.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+ class Promise;
+@@ -213,14 +213,14 @@ private:
+   // Main thread must always acquire a lock.
+   bool mCleanedUp; // To specify if the cleanUp() has been done.
+ 
+   const PromiseWorkerProxyStructuredCloneCallbacks* mCallbacks;
+ 
+   // Ensure the worker and the main thread won't race to access |mCleanedUp|.
+   Mutex mCleanUpLock;
+ 
+-  UniquePtr<workers::WorkerHolder> mWorkerHolder;
++  UniquePtr<WorkerHolder> mWorkerHolder;
+ };
+ } // namespace dom
+ } // namespace mozilla
+ 
+ #endif // mozilla_dom_PromiseWorkerProxy_h
+diff --git a/dom/serviceworkers/ServiceWorkerPrivate.cpp b/dom/serviceworkers/ServiceWorkerPrivate.cpp
+--- a/dom/serviceworkers/ServiceWorkerPrivate.cpp
++++ b/dom/serviceworkers/ServiceWorkerPrivate.cpp
+@@ -310,17 +310,17 @@ public:
+ 
+   void
+   RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override
+   {
+     RemovePromise(Rejected);
+   }
+ 
+   bool
+-  Notify(Status aStatus) override
++  Notify(WorkerStatus aStatus) override
+   {
+     MOZ_ASSERT(mWorkerPrivate);
+     mWorkerPrivate->AssertIsOnWorkerThread();
+     if (aStatus < Terminating) {
+       return true;
+     }
+ 
+     MaybeCleanup();
+@@ -727,17 +727,17 @@ public:
+       ReportResult(false);
+       return false;
+     }
+ 
+     return true;
+   }
+ 
+   bool
+-  Notify(Status aStatus) override
++  Notify(WorkerStatus aStatus) override
+   {
+     if (aStatus < Terminating) {
+       return true;
+     }
+ 
+     MOZ_ASSERT(GetCurrentThreadWorkerPrivate() == mWorkerPrivate);
+     ReportResult(false);
+ 
+@@ -1147,17 +1147,17 @@ class AllowWindowInteractionHandler fina
+   GetName(nsACString& aName) override
+   {
+     aName.AssignLiteral("AllowWindowInteractionHandler");
+     return NS_OK;
+   }
+ 
+   // WorkerHolder virtual methods
+   bool
+-  Notify(Status aStatus) override
++  Notify(WorkerStatus aStatus) override
+   {
+     // We could try to hold the worker alive until the timer fires, but other
+     // APIs are not likely to work in this partially shutdown state.  We might
+     // as well let the worker thread exit.
+     ClearWindowAllowed(mWorkerPrivate);
+     return true;
+   }
+ 
+diff --git a/dom/serviceworkers/ServiceWorkerRegistration.cpp b/dom/serviceworkers/ServiceWorkerRegistration.cpp
+--- a/dom/serviceworkers/ServiceWorkerRegistration.cpp
++++ b/dom/serviceworkers/ServiceWorkerRegistration.cpp
+@@ -936,17 +936,17 @@ public:
+   ServiceWorkerUpdateViaCache
+   GetUpdateViaCache(ErrorResult& aRv) const override
+   {
+     // FIXME(hopang): Will be implemented after Bug 1113522.
+     return ServiceWorkerUpdateViaCache::Imports;
+   }
+ 
+   bool
+-  Notify(Status aStatus) override;
++  Notify(WorkerStatus aStatus) override;
+ 
+   already_AddRefed<PushManager>
+   GetPushManager(JSContext* aCx, ErrorResult& aRv) override;
+ 
+ private:
+   ~ServiceWorkerRegistrationWorkerThread();
+ 
+   void
+@@ -1242,17 +1242,17 @@ ServiceWorkerRegistrationWorkerThread::R
+                       &WorkerListener::StopListeningForEvents);
+   MOZ_ALWAYS_SUCCEEDS(mWorkerPrivate->DispatchToMainThread(r.forget()));
+ 
+   mListener = nullptr;
+   mWorkerPrivate = nullptr;
+ }
+ 
+ bool
+-ServiceWorkerRegistrationWorkerThread::Notify(Status aStatus)
++ServiceWorkerRegistrationWorkerThread::Notify(WorkerStatus aStatus)
+ {
+   ReleaseListener();
+   return true;
+ }
+ 
+ class FireUpdateFoundRunnable final : public WorkerRunnable
+ {
+   RefPtr<WorkerListener> mListener;
+diff --git a/dom/serviceworkers/ServiceWorkerRegistration.h b/dom/serviceworkers/ServiceWorkerRegistration.h
+--- a/dom/serviceworkers/ServiceWorkerRegistration.h
++++ b/dom/serviceworkers/ServiceWorkerRegistration.h
+@@ -7,17 +7,17 @@
+ #ifndef mozilla_dom_ServiceWorkerRegistration_h
+ #define mozilla_dom_ServiceWorkerRegistration_h
+ 
+ #include "mozilla/DOMEventTargetHelper.h"
+ #include "mozilla/dom/DOMPrefs.h"
+ #include "mozilla/dom/ServiceWorkerBinding.h"
+ #include "mozilla/dom/ServiceWorkerCommon.h"
+ #include "mozilla/dom/ServiceWorkerRegistrationBinding.h"
+-#include "mozilla/dom/workers/bindings/WorkerHolder.h"
++#include "mozilla/dom/WorkerHolder.h"
+ 
+ // Support for Notification API extension.
+ #include "mozilla/dom/NotificationBinding.h"
+ 
+ class nsPIDOMWindowInner;
+ 
+ namespace mozilla {
+ namespace dom {
+diff --git a/dom/websocket/WebSocket.cpp b/dom/websocket/WebSocket.cpp
+--- a/dom/websocket/WebSocket.cpp
++++ b/dom/websocket/WebSocket.cpp
+@@ -2255,19 +2255,19 @@ class WebSocketWorkerHolder final : publ
+ {
+ public:
+   explicit WebSocketWorkerHolder(WebSocketImpl* aWebSocketImpl)
+     : WorkerHolder("WebSocketWorkerHolder")
+     , mWebSocketImpl(aWebSocketImpl)
+   {
+   }
+ 
+-  bool Notify(Status aStatus) override
++  bool Notify(WorkerStatus aStatus) override
+   {
+-    MOZ_ASSERT(aStatus > workers::Running);
++    MOZ_ASSERT(aStatus > Running);
+ 
+     if (aStatus >= Canceling) {
+       {
+         MutexAutoLock lock(mWebSocketImpl->mMutex);
+         mWebSocketImpl->mWorkerShuttingDown = true;
+       }
+ 
+       mWebSocketImpl->CloseConnection(nsIWebSocketChannel::CLOSE_GOING_AWAY,
+diff --git a/dom/workers/ScriptLoader.cpp b/dom/workers/ScriptLoader.cpp
+--- a/dom/workers/ScriptLoader.cpp
++++ b/dom/workers/ScriptLoader.cpp
+@@ -789,17 +789,17 @@ private:
+ 
+     loadInfo.mCachePromise.swap(cachePromise);
+     loadInfo.mCacheStatus = ScriptLoadInfo::WritingToCache;
+ 
+     return NS_OK;
+   }
+ 
+   bool
+-  Notify(Status aStatus)
++  Notify(WorkerStatus aStatus)
+   {
+     mWorkerPrivate->AssertIsOnWorkerThread();
+ 
+     if (aStatus >= Terminating && !mCanceled) {
+       mCanceled = true;
+ 
+       MOZ_ALWAYS_SUCCEEDS(
+         NS_DispatchToMainThread(NewRunnableMethod("ScriptLoaderRunnable::CancelMainThreadWithBindingAborted",
+@@ -1460,17 +1460,17 @@ public:
+   explicit ScriptLoaderHolder(ScriptLoaderRunnable* aRunnable)
+     : WorkerHolder("ScriptLoaderHolder")
+     , mRunnable(aRunnable)
+   {
+     MOZ_ASSERT(aRunnable);
+   }
+ 
+   virtual bool
+-  Notify(Status aStatus) override
++  Notify(WorkerStatus aStatus) override
+   {
+     mRunnable->Notify(aStatus);
+     return true;
+   }
+ };
+ 
+ NS_IMETHODIMP
+ LoaderListener::OnStreamComplete(nsIStreamLoader* aLoader, nsISupports* aContext,
+diff --git a/dom/workers/WorkerHolder.cpp b/dom/workers/WorkerHolder.cpp
+--- a/dom/workers/WorkerHolder.cpp
++++ b/dom/workers/WorkerHolder.cpp
+@@ -2,17 +2,18 @@
+ /* vim: set ts=8 sts=2 et sw=2 tw=80: */
+ /* 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 "WorkerHolder.h"
+ #include "WorkerPrivate.h"
+ 
+-BEGIN_WORKERS_NAMESPACE
++namespace mozilla {
++namespace dom {
+ 
+ namespace {
+ 
+ void
+ AssertOnOwningThread(void* aThread)
+ {
+   if (MOZ_UNLIKELY(aThread != GetCurrentVirtualThread())) {
+     MOZ_CRASH_UNSAFE_OOL("WorkerHolder on the wrong thread.");
+@@ -32,17 +33,18 @@ WorkerHolder::WorkerHolder(const char* a
+ WorkerHolder::~WorkerHolder()
+ {
+   AssertOnOwningThread(mThread);
+   ReleaseWorkerInternal();
+   MOZ_ASSERT(mWorkerPrivate == nullptr);
+ }
+ 
+ bool
+-WorkerHolder::HoldWorker(WorkerPrivate* aWorkerPrivate, Status aFailStatus)
++WorkerHolder::HoldWorker(WorkerPrivate* aWorkerPrivate,
++                         WorkerStatus aFailStatus)
+ {
+   AssertOnOwningThread(mThread);
+   MOZ_ASSERT(aWorkerPrivate);
+   aWorkerPrivate->AssertIsOnWorkerThread();
+ 
+   if (!aWorkerPrivate->AddHolder(this, aFailStatus)) {
+     return false;
+   }
+@@ -73,9 +75,10 @@ WorkerHolder::ReleaseWorkerInternal()
+ 
+   if (mWorkerPrivate) {
+     mWorkerPrivate->AssertIsOnWorkerThread();
+     mWorkerPrivate->RemoveHolder(this);
+     mWorkerPrivate = nullptr;
+   }
+ }
+ 
+-END_WORKERS_NAMESPACE
++} // dom namespace
++} // mozilla namespace
+diff --git a/dom/workers/WorkerHolder.h b/dom/workers/WorkerHolder.h
+--- a/dom/workers/WorkerHolder.h
++++ b/dom/workers/WorkerHolder.h
+@@ -4,17 +4,22 @@
+  * 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/. */
+ 
+ #ifndef mozilla_dom_workers_WorkerHolder_h
+ #define mozilla_dom_workers_WorkerHolder_h
+ 
+ #include "mozilla/dom/workers/WorkerCommon.h"
+ 
+-BEGIN_WORKERS_NAMESPACE
++namespace mozilla {
++namespace dom {
++
++namespace workers {
++class WorkerPrivate;
++}
+ 
+ /**
+  * Use this chart to help figure out behavior during each of the closing
+  * statuses. Details below.
+  *
+  * +==============================================================+
+  * |                       Closing Statuses                       |
+  * +=============+=============+=================+================+
+@@ -30,17 +35,17 @@ BEGIN_WORKERS_NAMESPACE
+  * +-------------+-------------+-----------------+----------------+
+  */
+ 
+ #ifdef Status
+ /* Xlib headers insist on this for some reason... Nuke it because
+    it'll override our member name */
+ #undef Status
+ #endif
+-enum Status
++enum WorkerStatus
+ {
+   // Not yet scheduled.
+   Pending = 0,
+ 
+   // This status means that the close handler has not yet been scheduled.
+   Running,
+ 
+   // Inner script called close() on the worker global scope. Setting this
+@@ -76,39 +81,41 @@ public:
+     AllowIdleShutdownStart,
+     PreventIdleShutdownStart,
+   };
+ 
+   explicit WorkerHolder(const char* aName,
+                         Behavior aBehavior = PreventIdleShutdownStart);
+   virtual ~WorkerHolder();
+ 
+-  bool HoldWorker(WorkerPrivate* aWorkerPrivate, Status aFailStatus);
++  bool HoldWorker(workers::WorkerPrivate* aWorkerPrivate,
++                  WorkerStatus aFailStatus);
+   void ReleaseWorker();
+ 
+-  virtual bool Notify(Status aStatus) = 0;
++  virtual bool Notify(WorkerStatus aStatus) = 0;
+ 
+   Behavior GetBehavior() const;
+ 
+   const char*
+   Name() const
+   {
+     return mName;
+   }
+ 
+ protected:
+   void ReleaseWorkerInternal();
+ 
+-  WorkerPrivate* MOZ_NON_OWNING_REF mWorkerPrivate;
++  workers::WorkerPrivate* MOZ_NON_OWNING_REF mWorkerPrivate;
+ 
+ private:
+   void AssertIsOwningThread() const;
+ 
+   const Behavior mBehavior;
+ 
+   // For debugging only.
+   void* mThread;
+   const char* mName;
+ };
+ 
+-END_WORKERS_NAMESPACE
++} // dom namespace
++} // mozilla namespace
+ 
+ #endif /* mozilla_dom_workers_WorkerHolder_h */
+diff --git a/dom/workers/WorkerHolderToken.cpp b/dom/workers/WorkerHolderToken.cpp
+--- a/dom/workers/WorkerHolderToken.cpp
++++ b/dom/workers/WorkerHolderToken.cpp
+@@ -10,17 +10,18 @@
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+ using namespace workers;
+ 
+ // static
+ already_AddRefed<WorkerHolderToken>
+-WorkerHolderToken::Create(WorkerPrivate* aWorkerPrivate, Status aShutdownStatus,
++WorkerHolderToken::Create(WorkerPrivate* aWorkerPrivate,
++                          WorkerStatus aShutdownStatus,
+                           Behavior aBehavior)
+ {
+   MOZ_DIAGNOSTIC_ASSERT(aWorkerPrivate);
+   aWorkerPrivate->AssertIsOnWorkerThread();
+ 
+   RefPtr<WorkerHolderToken> workerHolder =
+     new WorkerHolderToken(aShutdownStatus, aBehavior);
+ 
+@@ -69,32 +70,32 @@ WorkerHolderToken::IsShuttingDown() cons
+ 
+ WorkerPrivate*
+ WorkerHolderToken::GetWorkerPrivate() const
+ {
+   NS_ASSERT_OWNINGTHREAD(WorkerHolderToken);
+   return mWorkerPrivate;
+ }
+ 
+-WorkerHolderToken::WorkerHolderToken(Status aShutdownStatus,
++WorkerHolderToken::WorkerHolderToken(WorkerStatus aShutdownStatus,
+                                      Behavior aBehavior)
+   : WorkerHolder("WorkerHolderToken", aBehavior)
+   , mShutdownStatus(aShutdownStatus)
+   , mShuttingDown(false)
+ {
+ }
+ 
+ WorkerHolderToken::~WorkerHolderToken()
+ {
+   NS_ASSERT_OWNINGTHREAD(WorkerHolderToken);
+   MOZ_ASSERT(mListenerList.IsEmpty());
+ }
+ 
+ bool
+-WorkerHolderToken::Notify(Status aStatus)
++WorkerHolderToken::Notify(WorkerStatus aStatus)
+ {
+   NS_ASSERT_OWNINGTHREAD(WorkerHolderToken);
+ 
+   // When the service worker thread is stopped we will get Terminating,
+   // but nothing higher than that.  We must shut things down at Terminating.
+   if (aStatus < mShutdownStatus || mShuttingDown) {
+     return true;
+   }
+diff --git a/dom/workers/WorkerHolderToken.h b/dom/workers/WorkerHolderToken.h
+--- a/dom/workers/WorkerHolderToken.h
++++ b/dom/workers/WorkerHolderToken.h
+@@ -19,34 +19,34 @@ class WorkerPrivate;
+ }
+ 
+ // This is a ref-counted WorkerHolder implementation.  If you wish
+ // to be notified of worker shutdown beginning, then you can implement
+ // the Listener interface and call AddListener().
+ //
+ // This is purely a convenience class to avoid requiring code to
+ // extend WorkerHolder all the time.
+-class WorkerHolderToken final : public workers::WorkerHolder
++class WorkerHolderToken final : public WorkerHolder
+ {
+ public:
+   // Pure virtual class defining the interface for objects that
+   // wish to be notified of worker shutdown.
+   class Listener
+   {
+   public:
+     virtual void
+     WorkerShuttingDown() = 0;
+   };
+ 
+   // Attempt to create a WorkerHolderToken().  If the shutdown has already
+   // passed the given shutdown phase or fails for another reason then
+   // nullptr is returned.
+   static already_AddRefed<WorkerHolderToken>
+   Create(workers::WorkerPrivate* aWorkerPrivate,
+-         workers::Status aShutdownStatus,
++         WorkerStatus aShutdownStatus,
+          Behavior aBehavior = PreventIdleShutdownStart);
+ 
+   // Add a listener to the token.  Note, this does not hold a strong
+   // reference to the listener.  You must call RemoveListener() before
+   // the listener is destroyed.  This can only be called on the owning
+   // worker thread.
+   void
+   AddListener(Listener* aListener);
+@@ -58,26 +58,26 @@ public:
+ 
+   bool
+   IsShuttingDown() const;
+ 
+   workers::WorkerPrivate*
+   GetWorkerPrivate() const;
+ 
+ private:
+-  WorkerHolderToken(workers::Status aShutdownStatus, Behavior aBehavior);
++  WorkerHolderToken(WorkerStatus aShutdownStatus, Behavior aBehavior);
+ 
+   ~WorkerHolderToken();
+ 
+   // WorkerHolder methods
+   virtual bool
+-  Notify(workers::Status aStatus) override;
++  Notify(WorkerStatus aStatus) override;
+ 
+   nsTObserverArray<Listener*> mListenerList;
+-  const workers::Status mShutdownStatus;
++  const WorkerStatus mShutdownStatus;
+   bool mShuttingDown;
+ 
+ public:
+   NS_INLINE_DECL_REFCOUNTING(WorkerHolderToken)
+ };
+ 
+ } // dom namespace
+ } // mozilla namespace
+diff --git a/dom/workers/WorkerPrivate.cpp b/dom/workers/WorkerPrivate.cpp
+--- a/dom/workers/WorkerPrivate.cpp
++++ b/dom/workers/WorkerPrivate.cpp
+@@ -477,20 +477,20 @@ private:
+ 
+     aWorkerPrivate->SetWorkerScriptExecutedSuccessfully();
+     return true;
+   }
+ };
+ 
+ class NotifyRunnable final : public WorkerControlRunnable
+ {
+-  Status mStatus;
++  WorkerStatus mStatus;
+ 
+ public:
+-  NotifyRunnable(WorkerPrivate* aWorkerPrivate, Status aStatus)
++  NotifyRunnable(WorkerPrivate* aWorkerPrivate, WorkerStatus aStatus)
+   : WorkerControlRunnable(aWorkerPrivate, WorkerThreadUnchangedBusyCount),
+     mStatus(aStatus)
+   {
+     MOZ_ASSERT(aStatus == Closing || aStatus == Terminating ||
+                aStatus == Canceling || aStatus == Killing);
+   }
+ 
+ private:
+@@ -963,17 +963,17 @@ PRThreadFromThread(nsIThread* aThread)
+ 
+ class SimpleWorkerHolder final : public WorkerHolder
+ {
+ public:
+   SimpleWorkerHolder()
+     : WorkerHolder("SimpleWorkerHolder")
+   {}
+ 
+-  virtual bool Notify(Status aStatus) override { return true; }
++  virtual bool Notify(WorkerStatus aStatus) override { return true; }
+ };
+ 
+ } /* anonymous namespace */
+ 
+ NS_IMPL_ISUPPORTS_INHERITED0(TopLevelWorkerFinishedRunnable, Runnable)
+ 
+ 
+ template <class Derived>
+@@ -1862,17 +1862,17 @@ WorkerPrivateParent<Derived>::Start()
+   }
+ 
+   return false;
+ }
+ 
+ // aCx is null when called from the finalizer
+ template <class Derived>
+ bool
+-WorkerPrivateParent<Derived>::NotifyPrivate(Status aStatus)
++WorkerPrivateParent<Derived>::NotifyPrivate(WorkerStatus aStatus)
+ {
+   AssertIsOnParentThread();
+ 
+   bool pending;
+   {
+     MutexAutoLock lock(mMutex);
+ 
+     if (mParentStatus >= aStatus) {
+@@ -3161,17 +3161,17 @@ WorkerPrivate::GetLoadInfo(JSContext* aC
+ 
+   WorkerLoadInfo loadInfo;
+   nsresult rv;
+ 
+   if (aParent) {
+     aParent->AssertIsOnWorkerThread();
+ 
+     // If the parent is going away give up now.
+-    Status parentStatus;
++    WorkerStatus parentStatus;
+     {
+       MutexAutoLock lock(aParent->mMutex);
+       parentStatus = aParent->mStatus;
+     }
+ 
+     if (parentStatus > Running) {
+       return NS_ERROR_FAILURE;
+     }
+@@ -3468,17 +3468,17 @@ WorkerPrivate::DoRunLoop(JSContext* aCx)
+ 
+   EnableMemoryReporter();
+ 
+   InitializeGCTimers();
+ 
+   Maybe<JSAutoCompartment> workerCompartment;
+ 
+   for (;;) {
+-    Status currentStatus, previousStatus;
++    WorkerStatus currentStatus, previousStatus;
+     bool debuggerRunnablesPending = false;
+     bool normalRunnablesPending = false;
+ 
+     {
+       MutexAutoLock lock(mMutex);
+       previousStatus = mStatus;
+ 
+       while (mControlQueue.IsEmpty() &&
+@@ -4199,17 +4199,17 @@ WorkerPrivate::ModifyBusyCountFromWorker
+ 
+ bool
+ WorkerPrivate::AddChildWorker(ParentType* aChildWorker)
+ {
+   AssertIsOnWorkerThread();
+ 
+ #ifdef DEBUG
+   {
+-    Status currentStatus;
++    WorkerStatus currentStatus;
+     {
+       MutexAutoLock lock(mMutex);
+       currentStatus = mStatus;
+     }
+ 
+     MOZ_ASSERT(currentStatus == Running);
+   }
+ #endif
+@@ -4233,17 +4233,17 @@ WorkerPrivate::RemoveChildWorker(ParentT
+   mChildWorkers.RemoveElement(aChildWorker);
+ 
+   if (mChildWorkers.IsEmpty() && !ModifyBusyCountFromWorker(false)) {
+     NS_WARNING("Failed to modify busy count!");
+   }
+ }
+ 
+ bool
+-WorkerPrivate::AddHolder(WorkerHolder* aHolder, Status aFailStatus)
++WorkerPrivate::AddHolder(WorkerHolder* aHolder, WorkerStatus aFailStatus)
+ {
+   AssertIsOnWorkerThread();
+ 
+   {
+     MutexAutoLock lock(mMutex);
+ 
+     if (mStatus >= aFailStatus) {
+       return false;
+@@ -4275,17 +4275,17 @@ WorkerPrivate::RemoveHolder(WorkerHolder
+     mNumHoldersPreventingShutdownStart -= 1;
+     if (!mNumHoldersPreventingShutdownStart && !ModifyBusyCountFromWorker(false)) {
+       NS_WARNING("Failed to modify busy count!");
+     }
+   }
+ }
+ 
+ void
+-WorkerPrivate::NotifyHolders(JSContext* aCx, Status aStatus)
++WorkerPrivate::NotifyHolders(JSContext* aCx, WorkerStatus aStatus)
+ {
+   AssertIsOnWorkerThread();
+   MOZ_ASSERT(!JS_IsExceptionPending(aCx));
+ 
+   NS_ASSERTION(aStatus > Running, "Bad status!");
+ 
+   if (aStatus >= Closing) {
+     CancelAllTimeouts();
+@@ -4349,17 +4349,17 @@ WorkerPrivate::CancelAllTimeouts()
+   }
+ #endif
+ 
+   mTimer = nullptr;
+   mTimerRunnable = nullptr;
+ }
+ 
+ already_AddRefed<nsIEventTarget>
+-WorkerPrivate::CreateNewSyncLoop(Status aFailStatus)
++WorkerPrivate::CreateNewSyncLoop(WorkerStatus aFailStatus)
+ {
+   AssertIsOnWorkerThread();
+ 
+   {
+     MutexAutoLock lock(mMutex);
+ 
+     if (mStatus >= aFailStatus) {
+       return nullptr;
+@@ -4734,26 +4734,26 @@ void
+ WorkerPrivate::ReportErrorToDebugger(const nsAString& aFilename,
+                                      uint32_t aLineno,
+                                      const nsAString& aMessage)
+ {
+   mDebugger->ReportErrorToDebugger(aFilename, aLineno, aMessage);
+ }
+ 
+ bool
+-WorkerPrivate::NotifyInternal(JSContext* aCx, Status aStatus)
++WorkerPrivate::NotifyInternal(JSContext* aCx, WorkerStatus aStatus)
+ {
+   AssertIsOnWorkerThread();
+ 
+   NS_ASSERTION(aStatus > Running && aStatus < Dead, "Bad status!");
+ 
+   RefPtr<EventTarget> eventTarget;
+ 
+   // Save the old status and set the new status.
+-  Status previousStatus;
++  WorkerStatus previousStatus;
+   {
+     MutexAutoLock lock(mMutex);
+ 
+     if (mStatus >= aStatus) {
+       return true;
+     }
+ 
+     // Make sure the hybrid event target stops dispatching runnables
+@@ -4901,17 +4901,17 @@ WorkerPrivate::SetTimeout(JSContext* aCx
+                           int32_t aTimeout, bool aIsInterval,
+                           ErrorResult& aRv)
+ {
+   AssertIsOnWorkerThread();
+   MOZ_ASSERT(aHandler);
+ 
+   const int32_t timerId = mNextTimeoutId++;
+ 
+-  Status currentStatus;
++  WorkerStatus currentStatus;
+   {
+     MutexAutoLock lock(mMutex);
+     currentStatus = mStatus;
+   }
+ 
+   // If the worker is trying to call setTimeout/setInterval and the parent
+   // thread has initiated the close process then just silently fail.
+   if (currentStatus >= Closing) {
+diff --git a/dom/workers/WorkerPrivate.h b/dom/workers/WorkerPrivate.h
+--- a/dom/workers/WorkerPrivate.h
++++ b/dom/workers/WorkerPrivate.h
+@@ -157,17 +157,17 @@ private:
+ 
+   // This is touched on parent thread only, but it can be read on a different
+   // thread before crashing because hanging.
+   Atomic<uint64_t> mBusyCount;
+ 
+   // SharedWorkers may have multiple windows paused, so this must be
+   // a count instead of just a boolean.
+   uint32_t mParentWindowPausedDepth;
+-  Status mParentStatus;
++  WorkerStatus mParentStatus;
+   bool mParentFrozen;
+   bool mIsChromeWorker;
+   bool mMainThreadObjectsForgotten;
+   // mIsSecureContext is set once in our constructor; after that it can be read
+   // from various threads.  We could make this const if we were OK with setting
+   // it in the initializer list via calling some function that takes all sorts
+   // of state (loadinfo, worker type, parent).
+   //
+@@ -197,17 +197,17 @@ protected:
+ private:
+   Derived*
+   ParentAsWorkerPrivate() const
+   {
+     return static_cast<Derived*>(const_cast<WorkerPrivateParent*>(this));
+   }
+ 
+   bool
+-  NotifyPrivate(Status aStatus);
++  NotifyPrivate(WorkerStatus aStatus);
+ 
+   bool
+   TerminatePrivate()
+   {
+     return NotifyPrivate(Terminating);
+   }
+ 
+   void
+@@ -256,17 +256,17 @@ public:
+   MaybeWrapAsWorkerRunnable(already_AddRefed<nsIRunnable> aRunnable);
+ 
+   // May be called on any thread...
+   bool
+   Start();
+ 
+   // Called on the parent thread.
+   bool
+-  Notify(Status aStatus)
++  Notify(WorkerStatus aStatus)
+   {
+     return NotifyPrivate(aStatus);
+   }
+ 
+   bool
+   Cancel()
+   {
+     return Notify(Canceling);
+@@ -388,17 +388,17 @@ public:
+   IsAcceptingEvents()
+   {
+     AssertIsOnParentThread();
+ 
+     MutexAutoLock lock(mMutex);
+     return mParentStatus < Terminating;
+     }
+ 
+-  Status
++  WorkerStatus
+   ParentStatus() const
+   {
+     mMutex.AssertCurrentThreadOwns();
+     return mParentStatus;
+   }
+ 
+   nsIScriptContext*
+   GetScriptContext() const
+@@ -867,17 +867,17 @@ public:
+   BusyCount()
+   {
+     return mBusyCount;
+   }
+ };
+ 
+ class WorkerPrivate : public WorkerPrivateParent<WorkerPrivate>
+ {
+-  friend class WorkerHolder;
++  friend class mozilla::dom::WorkerHolder;
+   friend class WorkerPrivateParent<WorkerPrivate>;
+   typedef WorkerPrivateParent<WorkerPrivate> ParentType;
+   friend class AutoSyncLoopHolder;
+ 
+   struct TimeoutInfo;
+ 
+   class MemoryReporter;
+   friend class MemoryReporter;
+@@ -943,17 +943,17 @@ class WorkerPrivate : public WorkerPriva
+   nsCOMPtr<nsIRunnable> mLoadFailedRunnable;
+ 
+   RefPtr<PerformanceStorage> mPerformanceStorage;
+ 
+   JS::UniqueChars mDefaultLocale; // nulled during worker JSContext init
+   TimeStamp mKillTime;
+   uint32_t mErrorHandlerRecursionCount;
+   uint32_t mNextTimeoutId;
+-  Status mStatus;
++  WorkerStatus mStatus;
+   UniquePtr<ClientSource> mClientSource;
+   bool mFrozen;
+   bool mTimerRunning;
+   bool mRunningExpiredTimeouts;
+   bool mPendingEventQueueClearing;
+   bool mCancelAllPendingRunnables;
+   bool mPeriodicGCTimerRunning;
+   bool mIdleGCTimerRunning;
+@@ -1131,17 +1131,17 @@ public:
+   void
+   SetDebuggerImmediate(Function& aHandler, ErrorResult& aRv);
+ 
+   void
+   ReportErrorToDebugger(const nsAString& aFilename, uint32_t aLineno,
+                         const nsAString& aMessage);
+ 
+   bool
+-  NotifyInternal(JSContext* aCx, Status aStatus);
++  NotifyInternal(JSContext* aCx, WorkerStatus aStatus);
+ 
+   void
+   ReportError(JSContext* aCx, JS::ConstUTF8CharsZ aToStringResult,
+               JSErrorReport* aReport);
+ 
+   static void
+   ReportErrorToConsole(const char* aMessage);
+ 
+@@ -1396,17 +1396,17 @@ private:
+                 const nsACString& aServiceWorkerScope,
+                 WorkerLoadInfo& aLoadInfo);
+ 
+   bool
+   MayContinueRunning()
+   {
+     AssertIsOnWorkerThread();
+ 
+-    Status status;
++    WorkerStatus status;
+     {
+       MutexAutoLock lock(mMutex);
+       status = mStatus;
+     }
+ 
+     if (status < Terminating) {
+       return true;
+     }
+@@ -1452,17 +1452,17 @@ private:
+                               JS::Handle<JS::Value> aMessage,
+                               const Sequence<JSObject*>& aTransferable,
+                               ErrorResult& aRv);
+ 
+   // If the worker shutdown status is equal or greater then aFailStatus, this
+   // operation will fail and nullptr will be returned. See WorkerHolder.h for
+   // more information about the correct value to use.
+   already_AddRefed<nsIEventTarget>
+-  CreateNewSyncLoop(Status aFailStatus);
++  CreateNewSyncLoop(WorkerStatus aFailStatus);
+ 
+   bool
+   RunCurrentSyncLoop();
+ 
+   bool
+   DestroySyncLoop(uint32_t aLoopIndex, nsIThreadInternal* aThread = nullptr);
+ 
+   void
+@@ -1470,23 +1470,23 @@ private:
+ 
+   void
+   SetGCTimerMode(GCTimerMode aMode);
+ 
+   void
+   ShutdownGCTimers();
+ 
+   bool
+-  AddHolder(WorkerHolder* aHolder, Status aFailStatus);
++  AddHolder(WorkerHolder* aHolder, WorkerStatus aFailStatus);
+ 
+   void
+   RemoveHolder(WorkerHolder* aHolder);
+ 
+   void
+-  NotifyHolders(JSContext* aCx, Status aStatus);
++  NotifyHolders(JSContext* aCx, WorkerStatus aStatus);
+ 
+   bool
+   HasActiveHolders()
+   {
+     return !(mChildWorkers.IsEmpty() && mTimeouts.IsEmpty() &&
+              mHolders.IsEmpty());
+   }
+ };
+@@ -1529,17 +1529,17 @@ class AutoSyncLoopHolder
+ {
+   WorkerPrivate* mWorkerPrivate;
+   nsCOMPtr<nsIEventTarget> mTarget;
+   uint32_t mIndex;
+ 
+ public:
+   // See CreateNewSyncLoop() for more information about the correct value to use
+   // for aFailStatus.
+-  AutoSyncLoopHolder(WorkerPrivate* aWorkerPrivate, Status aFailStatus)
++  AutoSyncLoopHolder(WorkerPrivate* aWorkerPrivate, WorkerStatus aFailStatus)
+   : mWorkerPrivate(aWorkerPrivate)
+   , mTarget(aWorkerPrivate->CreateNewSyncLoop(aFailStatus))
+   , mIndex(aWorkerPrivate->mSyncLoopStack.Length() - 1)
+   {
+     aWorkerPrivate->AssertIsOnWorkerThread();
+   }
+ 
+   ~AutoSyncLoopHolder()
+diff --git a/dom/workers/WorkerRunnable.cpp b/dom/workers/WorkerRunnable.cpp
+--- a/dom/workers/WorkerRunnable.cpp
++++ b/dom/workers/WorkerRunnable.cpp
+@@ -568,17 +568,18 @@ WorkerMainThreadRunnable::WorkerMainThre
+   : mozilla::Runnable("dom::workers::WorkerMainThreadRunnable")
+   , mWorkerPrivate(aWorkerPrivate)
+   , mTelemetryKey(aTelemetryKey)
+ {
+   mWorkerPrivate->AssertIsOnWorkerThread();
+ }
+ 
+ void
+-WorkerMainThreadRunnable::Dispatch(Status aFailStatus, mozilla::ErrorResult& aRv)
++WorkerMainThreadRunnable::Dispatch(WorkerStatus aFailStatus,
++                                   mozilla::ErrorResult& aRv)
+ {
+   mWorkerPrivate->AssertIsOnWorkerThread();
+ 
+   TimeStamp startTime = TimeStamp::NowLoRes();
+ 
+   AutoSyncLoopHolder syncLoop(mWorkerPrivate, aFailStatus);
+ 
+   mSyncLoopTarget = syncLoop.GetEventTarget();
+@@ -766,17 +767,17 @@ WorkerProxyToMainThreadRunnable::HoldWor
+ 
+   class SimpleWorkerHolder final : public WorkerHolder
+   {
+   public:
+     SimpleWorkerHolder()
+       : WorkerHolder("WorkerProxyToMainThreadRunnable::SimpleWorkerHolder")
+     {}
+ 
+-    bool Notify(Status aStatus) override
++    bool Notify(WorkerStatus aStatus) override
+     {
+       // We don't care about the notification. We just want to keep the
+       // mWorkerPrivate alive.
+       return true;
+     }
+   };
+ 
+   UniquePtr<WorkerHolder> workerHolder(new SimpleWorkerHolder());
+diff --git a/dom/workers/WorkerRunnable.h b/dom/workers/WorkerRunnable.h
+--- a/dom/workers/WorkerRunnable.h
++++ b/dom/workers/WorkerRunnable.h
+@@ -409,17 +409,17 @@ protected:
+ 
+ public:
+   // Dispatch the runnable to the main thread.  If dispatch to main thread
+   // fails, or if the worker is in a state equal or greater of aFailStatus, an
+   // error will be reported on aRv. Normally you want to use 'Terminating' for
+   // aFailStatus, except if you want an infallible runnable. In this case, use
+   // 'Killing'.
+   // In that case the error MUST be propagated out to script.
+-  void Dispatch(workers::Status aFailStatus, ErrorResult& aRv);
++  void Dispatch(WorkerStatus aFailStatus, ErrorResult& aRv);
+ 
+ private:
+   NS_IMETHOD Run() override;
+ };
+ 
+ // This runnable is an helper class for dispatching something from a worker
+ // thread to the main-thread and back to the worker-thread. During this
+ // operation, this class will keep the worker alive.
+@@ -450,17 +450,17 @@ private:
+ 
+   void PostDispatchOnMainThread();
+ 
+   bool HoldWorker();
+   void ReleaseWorker();
+ 
+ protected:
+   workers::WorkerPrivate* mWorkerPrivate;
+-  UniquePtr<workers::WorkerHolder> mWorkerHolder;
++  UniquePtr<WorkerHolder> mWorkerHolder;
+ };
+ 
+ // Class for checking API exposure.  This totally violates the "MUST" in the
+ // comments on WorkerMainThreadRunnable::Dispatch, because API exposure checks
+ // can't throw.  Maybe we should change it so they _could_ throw.  But for now
+ // we are bad people and should be ashamed of ourselves.  Let's hope none of
+ // them happen while a worker is shutting down.
+ //
+diff --git a/dom/workers/moz.build b/dom/workers/moz.build
+--- a/dom/workers/moz.build
++++ b/dom/workers/moz.build
+@@ -7,35 +7,31 @@
+ with Files("**"):
+     BUG_COMPONENT = ("Core", "DOM: Workers")
+ 
+ # Public stuff.
+ EXPORTS.mozilla.dom += [
+     'SharedWorker.h',
+     'WorkerDebugger.h',
+     'WorkerDebuggerManager.h',
++    'WorkerHolder.h',
+     'WorkerHolderToken.h',
+     'WorkerLoadInfo.h',
+     'WorkerLocation.h',
+     'WorkerNavigator.h',
+     'WorkerPrivate.h',
+     'WorkerRunnable.h',
+     'WorkerScope.h',
+ ]
+ 
+ EXPORTS.mozilla.dom.workers += [
+     'RuntimeService.h',
+     'WorkerCommon.h',
+ ]
+ 
+-# Stuff needed for the bindings, not really public though.
+-EXPORTS.mozilla.dom.workers.bindings += [
+-    'WorkerHolder.h',
+-]
+-
+ XPIDL_MODULE = 'dom_workers'
+ 
+ XPIDL_SOURCES += [
+     'nsIWorkerDebugger.idl',
+     'nsIWorkerDebuggerManager.idl',
+ ]
+ 
+ UNIFIED_SOURCES += [
+diff --git a/dom/xhr/XMLHttpRequestWorker.cpp b/dom/xhr/XMLHttpRequestWorker.cpp
+--- a/dom/xhr/XMLHttpRequestWorker.cpp
++++ b/dom/xhr/XMLHttpRequestWorker.cpp
+@@ -208,17 +208,17 @@ public:
+   , mErrorCode(NS_OK)
+   {
+     MOZ_ASSERT(aWorkerPrivate);
+     MOZ_ASSERT(aProxy);
+     aWorkerPrivate->AssertIsOnWorkerThread();
+   }
+ 
+   void
+-  Dispatch(Status aFailStatus, ErrorResult& aRv)
++  Dispatch(WorkerStatus aFailStatus, ErrorResult& aRv)
+   {
+     WorkerMainThreadRunnable::Dispatch(aFailStatus, aRv);
+     if (NS_WARN_IF(aRv.Failed())) {
+       return;
+     }
+ 
+     if (NS_FAILED(mErrorCode)) {
+       aRv.Throw(mErrorCode);
+@@ -1851,17 +1851,17 @@ XMLHttpRequestWorker::SendInternal(SendR
+   // for it will come from ProxyCompleteRunnable and that always passes true for
+   // the second arg.
+   if (!succeeded && !aRv.Failed()) {
+     aRv.Throw(NS_ERROR_FAILURE);
+   }
+ }
+ 
+ bool
+-XMLHttpRequestWorker::Notify(Status aStatus)
++XMLHttpRequestWorker::Notify(WorkerStatus aStatus)
+ {
+   mWorkerPrivate->AssertIsOnWorkerThread();
+ 
+   if (aStatus >= Canceling && !mCanceled) {
+     mCanceled = true;
+     ReleaseProxy(WorkerIsGoingAway);
+   }
+ 
+diff --git a/dom/xhr/XMLHttpRequestWorker.h b/dom/xhr/XMLHttpRequestWorker.h
+--- a/dom/xhr/XMLHttpRequestWorker.h
++++ b/dom/xhr/XMLHttpRequestWorker.h
+@@ -19,17 +19,17 @@ class Proxy;
+ class SendRunnable;
+ class DOMString;
+ 
+ namespace workers {
+ class WorkerPrivate;
+ }
+ 
+ class XMLHttpRequestWorker final : public XMLHttpRequest,
+-                                   public workers::WorkerHolder
++                                   public WorkerHolder
+ {
+ public:
+   struct StateData
+   {
+     XMLHttpRequestStringSnapshot mResponseText;
+     nsString mResponseURL;
+     uint32_t mStatus;
+     nsCString mStatusText;
+@@ -76,17 +76,17 @@ public:
+   Construct(const GlobalObject& aGlobal,
+             const MozXMLHttpRequestParameters& aParams,
+             ErrorResult& aRv);
+ 
+   void
+   Unpin();
+ 
+   bool
+-  Notify(workers::Status aStatus) override;
++  Notify(WorkerStatus aStatus) override;
+ 
+   virtual uint16_t
+   ReadyState() const override
+   {
+     return mStateData.mReadyState;
+   }
+ 
+   virtual void
+diff --git a/gfx/thebes/gfxUtils.cpp b/gfx/thebes/gfxUtils.cpp
+--- a/gfx/thebes/gfxUtils.cpp
++++ b/gfx/thebes/gfxUtils.cpp
+@@ -1461,17 +1461,17 @@ gfxUtils::ThreadSafeGetFeatureStatus(con
+     dom::workers::WorkerPrivate* workerPrivate =
+       dom::workers::GetCurrentThreadWorkerPrivate();
+ 
+     RefPtr<GetFeatureStatusRunnable> runnable =
+       new GetFeatureStatusRunnable(workerPrivate, gfxInfo, feature, failureId,
+                                    status);
+ 
+     ErrorResult rv;
+-    runnable->Dispatch(dom::workers::Terminating, rv);
++    runnable->Dispatch(dom::WorkerStatus::Terminating, rv);
+     if (rv.Failed()) {
+         // XXXbz This is totally broken, since we're supposed to just abort
+         // everything up the callstack but the callers basically eat the
+         // exception.  Ah, well.
+         return rv.StealNSResult();
+     }
+ 
+     return runnable->GetNSResult();
+diff --git a/ipc/glue/IPCStreamSource.cpp b/ipc/glue/IPCStreamSource.cpp
+--- a/ipc/glue/IPCStreamSource.cpp
++++ b/ipc/glue/IPCStreamSource.cpp
+@@ -8,20 +8,19 @@
+ #include "mozilla/webrender/WebRenderTypes.h"
+ #include "nsIAsyncInputStream.h"
+ #include "nsICancelableRunnable.h"
+ #include "nsIRunnable.h"
+ #include "nsISerialEventTarget.h"
+ #include "nsStreamUtils.h"
+ #include "nsThreadUtils.h"
+ 
+-using mozilla::dom::workers::Canceling;
+ using mozilla::dom::workers::GetCurrentThreadWorkerPrivate;
+-using mozilla::dom::workers::Status;
+ using mozilla::dom::workers::WorkerPrivate;
++using mozilla::dom::WorkerStatus;
+ using mozilla::wr::ByteBuffer;
+ 
+ namespace mozilla {
+ namespace ipc {
+ 
+ class IPCStreamSource::Callback final : public nsIInputStreamCallback
+                                       , public nsIRunnable
+                                       , public nsICancelableRunnable
+@@ -136,17 +135,17 @@ IPCStreamSource::Initialize()
+   // to the requirement  that the thread be guaranteed to live long enough to
+   // receive messages. We can enforce this guarantee with a WorkerHolder on
+   // worker threads, but not other threads. Main-thread and PBackground thread
+   // do not need anything special in order to be kept alive.
+   WorkerPrivate* workerPrivate = nullptr;
+   if (!NS_IsMainThread()) {
+     workerPrivate = GetCurrentThreadWorkerPrivate();
+     if (workerPrivate) {
+-      bool result = HoldWorker(workerPrivate, Canceling);
++      bool result = HoldWorker(workerPrivate, WorkerStatus::Canceling);
+       if (!result) {
+         return false;
+       }
+ 
+       mWorkerPrivate = workerPrivate;
+     } else {
+       AssertIsOnBackgroundThread();
+     }
+@@ -158,17 +157,17 @@ IPCStreamSource::Initialize()
+ void
+ IPCStreamSource::ActorConstructed()
+ {
+   MOZ_ASSERT(mState == ePending);
+   mState = eActorConstructed;
+ }
+ 
+ bool
+-IPCStreamSource::Notify(Status aStatus)
++IPCStreamSource::Notify(WorkerStatus aStatus)
+ {
+   NS_ASSERT_OWNINGTHREAD(IPCStreamSource);
+ 
+   // Keep the worker thread alive until the stream is finished.
+   return true;
+ }
+ 
+ void
+diff --git a/ipc/glue/IPCStreamSource.h b/ipc/glue/IPCStreamSource.h
+--- a/ipc/glue/IPCStreamSource.h
++++ b/ipc/glue/IPCStreamSource.h
+@@ -3,18 +3,18 @@
+ /* 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/. */
+ 
+ #ifndef mozilla_ipc_IPCStreamSource_h
+ #define mozilla_ipc_IPCStreamSource_h
+ 
+ #include "mozilla/AlreadyAddRefed.h"
++#include "mozilla/dom/WorkerHolder.h"
+ #include "mozilla/dom/WorkerPrivate.h"
+-#include "mozilla/dom/workers/bindings/WorkerHolder.h"
+ 
+ class nsIAsyncInputStream;
+ 
+ namespace mozilla {
+ 
+ namespace dom {
+ class nsIContentChild;
+ class nsIContentParent;
+@@ -49,17 +49,17 @@ class PBackgroundParent;
+ //  2) If the actor is never sent to the other-side, then this code must
+ //     call IPCStreamSource{Child,Parent}::StartDestroy() to avoid memory leaks.
+ //  3) The IPCStreamSource actor can only be used on threads that can be
+ //     guaranteed to stay alive as long as the actor is alive.  Right now
+ //     this limits IPCStream to the main thread and Worker threads.
+ //
+ // In general you should probably use the AutoIPCStreamSource RAII class
+ // defined in InputStreamUtils.h instead of using IPCStreamSource directly.
+-class IPCStreamSource : public dom::workers::WorkerHolder
++class IPCStreamSource : public dom::WorkerHolder
+ {
+ public:
+   // Create a IPCStreamSource using a PContent IPC manager on the
+   // main thread.  This can return nullptr if the provided stream is
+   // blocking.
+   static PChildToParentStreamChild*
+   Create(nsIAsyncInputStream* aInputStream, dom::nsIContentChild* aManager);
+ 
+@@ -118,17 +118,17 @@ protected:
+   void
+   ActorConstructed();
+ 
+ private:
+   class Callback;
+ 
+   // WorkerHolder methods
+   virtual bool
+-  Notify(dom::workers::Status aStatus) override;
++  Notify(dom::WorkerStatus aStatus) override;
+ 
+   void DoRead();
+ 
+   void Wait();
+ 
+   void OnStreamReady(Callback* aCallback);
+ 
+   nsCOMPtr<nsIAsyncInputStream> mStream;

+ 5579 - 0
mozilla-release/patches/1432963-14-60a1.patch

@@ -0,0 +1,5579 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1517383448 -3600
+# Node ID 22ab83c80c5e38ab1b32b7e8186825ecd855ee1f
+# Parent  12db4ef527e6dd333a396a6c21f6e9c7b15dced5
+Bug 1432963 - Fixing workers headers - part 14 - WorkerPrivate without workers namespace, r=smaug
+
+diff --git a/dom/base/ImageEncoder.cpp b/dom/base/ImageEncoder.cpp
+--- a/dom/base/ImageEncoder.cpp
++++ b/dom/base/ImageEncoder.cpp
+@@ -84,17 +84,17 @@ public:
+   explicit EncodingCompleteEvent(EncodeCompleteCallback* aEncodeCompleteCallback)
+     : CancelableRunnable("EncodingCompleteEvent")
+     , mImgSize(0)
+     , mType()
+     , mImgData(nullptr)
+     , mEncodeCompleteCallback(aEncodeCompleteCallback)
+     , mFailed(false)
+   {
+-    if (!NS_IsMainThread() && workers::GetCurrentThreadWorkerPrivate()) {
++    if (!NS_IsMainThread() && GetCurrentThreadWorkerPrivate()) {
+       mCreationEventTarget = GetCurrentThreadEventTarget();
+     } else {
+       mCreationEventTarget = GetMainThreadEventTarget();
+     }
+   }
+ 
+   NS_IMETHOD Run() override
+   {
+diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp
+--- a/dom/base/nsContentUtils.cpp
++++ b/dom/base/nsContentUtils.cpp
+@@ -2512,17 +2512,17 @@ nsContentUtils::CalcRoundedWindowSizeFor
+   *aOutputHeight = resultHeight;
+ }
+ 
+ bool
+ nsContentUtils::ThreadsafeIsCallerChrome()
+ {
+   return NS_IsMainThread() ?
+     IsCallerChrome() :
+-    mozilla::dom::workers::IsCurrentThreadRunningChromeWorker();
++    mozilla::dom::IsCurrentThreadRunningChromeWorker();
+ }
+ 
+ bool
+ nsContentUtils::IsCallerContentXBL()
+ {
+   JSContext *cx = GetCurrentJSContext();
+   if (!cx)
+     return false;
+@@ -2551,17 +2551,17 @@ nsContentUtils::IsSystemCaller(JSContext
+ 
+ bool
+ nsContentUtils::ThreadsafeIsSystemCaller(JSContext* aCx)
+ {
+   if (NS_IsMainThread()) {
+     return IsSystemCaller(aCx);
+   }
+ 
+-  return workers::GetWorkerPrivateFromContext(aCx)->UsesSystemPrincipal();
++  return GetWorkerPrivateFromContext(aCx)->UsesSystemPrincipal();
+ }
+ 
+ // static
+ bool
+ nsContentUtils::LookupBindingMember(JSContext* aCx, nsIContent *aContent,
+                                     JS::Handle<jsid> aId,
+                                     JS::MutableHandle<JS::PropertyDescriptor> aDesc)
+ {
+@@ -6208,17 +6208,17 @@ nsContentUtils::GetCurrentJSContext()
+ /* static */
+ JSContext *
+ nsContentUtils::GetCurrentJSContextForThread()
+ {
+   MOZ_ASSERT(IsInitialized());
+   if (MOZ_LIKELY(NS_IsMainThread())) {
+     return GetCurrentJSContext();
+   }
+-  return workers::GetCurrentThreadJSContext();
++  return GetCurrentThreadJSContext();
+ }
+ 
+ template<typename StringType, typename CharType>
+ void
+ _ASCIIToLowerInSitu(StringType& aStr)
+ {
+   CharType* iter = aStr.BeginWriting();
+   CharType* end = aStr.EndWriting();
+diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf
+--- a/dom/bindings/Bindings.conf
++++ b/dom/bindings/Bindings.conf
+@@ -145,17 +145,17 @@ DOMInterfaces = {
+ },
+ 
+ 'ChromeWindow': {
+     'concrete': False,
+ },
+ 
+ 'ChromeWorker': {
+     'headerFile': 'mozilla/dom/WorkerPrivate.h',
+-    'nativeType': 'mozilla::dom::workers::ChromeWorkerPrivate',
++    'nativeType': 'mozilla::dom::ChromeWorkerPrivate',
+ },
+ 
+ 'console': {
+     'nativeType': 'mozilla::dom::Console',
+ },
+ 
+ 'ConsoleInstance': {
+     'implicitJSContext': ['clear', 'count', 'groupEnd', 'time', 'timeEnd'],
+@@ -1357,17 +1357,17 @@ DOMInterfaces = {
+ },
+ 
+ 'WindowRoot': {
+     'nativeType': 'nsWindowRoot'
+ },
+ 
+ 'Worker': {
+     'headerFile': 'mozilla/dom/WorkerPrivate.h',
+-    'nativeType': 'mozilla::dom::workers::WorkerPrivate',
++    'nativeType': 'mozilla::dom::WorkerPrivate',
+ },
+ 
+ 'WorkerDebuggerGlobalScope': {
+     'headerFile': 'mozilla/dom/WorkerScope.h',
+     'implicitJSContext': [
+         'dump', 'global', 'reportError', 'setConsoleEventHandler',
+     ],
+ },
+diff --git a/dom/cache/Cache.cpp b/dom/cache/Cache.cpp
+--- a/dom/cache/Cache.cpp
++++ b/dom/cache/Cache.cpp
+@@ -22,18 +22,16 @@
+ #include "mozilla/Preferences.h"
+ #include "mozilla/Unused.h"
+ #include "nsIGlobalObject.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ namespace cache {
+ 
+-using mozilla::dom::workers::GetCurrentThreadWorkerPrivate;
+-using mozilla::dom::workers::WorkerPrivate;
+ using mozilla::ipc::PBackgroundChild;
+ 
+ namespace {
+ 
+ enum class PutStatusPolicy {
+   Default,
+   RequireOK
+ };
+diff --git a/dom/cache/CacheStorage.cpp b/dom/cache/CacheStorage.cpp
+--- a/dom/cache/CacheStorage.cpp
++++ b/dom/cache/CacheStorage.cpp
+@@ -33,17 +33,16 @@
+ #include "WorkerPrivate.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ namespace cache {
+ 
+ using mozilla::Unused;
+ using mozilla::ErrorResult;
+-using mozilla::dom::workers::WorkerPrivate;
+ using mozilla::ipc::BackgroundChild;
+ using mozilla::ipc::PBackgroundChild;
+ using mozilla::ipc::IProtocol;
+ using mozilla::ipc::PrincipalInfo;
+ using mozilla::ipc::PrincipalToPrincipalInfo;
+ 
+ NS_IMPL_CYCLE_COLLECTING_ADDREF(mozilla::dom::cache::CacheStorage);
+ NS_IMPL_CYCLE_COLLECTING_RELEASE(mozilla::dom::cache::CacheStorage);
+diff --git a/dom/cache/CacheStorage.h b/dom/cache/CacheStorage.h
+--- a/dom/cache/CacheStorage.h
++++ b/dom/cache/CacheStorage.h
+@@ -24,20 +24,17 @@ class ErrorResult;
+ namespace ipc {
+   class PrincipalInfo;
+ } // namespace ipc
+ 
+ namespace dom {
+ 
+ enum class CacheStorageNamespace : uint8_t;
+ class Promise;
+-
+-namespace workers {
+-  class WorkerPrivate;
+-} // namespace workers
++class WorkerPrivate;
+ 
+ namespace cache {
+ 
+ class CacheStorageChild;
+ class CacheWorkerHolder;
+ 
+ class CacheStorage final : public nsISupports
+                          , public nsWrapperCache
+@@ -48,17 +45,17 @@ class CacheStorage final : public nsISup
+ public:
+   static already_AddRefed<CacheStorage>
+   CreateOnMainThread(Namespace aNamespace, nsIGlobalObject* aGlobal,
+                      nsIPrincipal* aPrincipal, bool aStorageDisabled,
+                      bool aForceTrustedOrigin, ErrorResult& aRv);
+ 
+   static already_AddRefed<CacheStorage>
+   CreateOnWorker(Namespace aNamespace, nsIGlobalObject* aGlobal,
+-                 workers::WorkerPrivate* aWorkerPrivate, ErrorResult& aRv);
++                 WorkerPrivate* aWorkerPrivate, ErrorResult& aRv);
+ 
+   static bool
+   DefineCaches(JSContext* aCx, JS::Handle<JSObject*> aGlobal);
+ 
+   // webidl interface methods
+   already_AddRefed<Promise>
+   Match(JSContext* aCx, const RequestOrUSVString& aRequest,
+         const CacheQueryOptions& aOptions, ErrorResult& aRv);
+diff --git a/dom/cache/CacheWorkerHolder.cpp b/dom/cache/CacheWorkerHolder.cpp
+--- a/dom/cache/CacheWorkerHolder.cpp
++++ b/dom/cache/CacheWorkerHolder.cpp
+@@ -8,18 +8,16 @@
+ 
+ #include "mozilla/dom/cache/ActorChild.h"
+ #include "WorkerPrivate.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ namespace cache {
+ 
+-using mozilla::dom::workers::WorkerPrivate;
+-
+ // static
+ already_AddRefed<CacheWorkerHolder>
+ CacheWorkerHolder::Create(WorkerPrivate* aWorkerPrivate, Behavior aBehavior)
+ {
+   MOZ_DIAGNOSTIC_ASSERT(aWorkerPrivate);
+ 
+   RefPtr<CacheWorkerHolder> workerHolder = new CacheWorkerHolder(aBehavior);
+   if (NS_WARN_IF(!workerHolder->HoldWorker(aWorkerPrivate, Terminating))) {
+diff --git a/dom/cache/CacheWorkerHolder.h b/dom/cache/CacheWorkerHolder.h
+--- a/dom/cache/CacheWorkerHolder.h
++++ b/dom/cache/CacheWorkerHolder.h
+@@ -8,30 +8,28 @@
+ #define mozilla_dom_cache_CacheWorkerHolder_h
+ 
+ #include "nsISupportsImpl.h"
+ #include "nsTArray.h"
+ #include "WorkerHolder.h"
+ 
+ namespace mozilla {
+ 
+-namespace workers {
+ class WorkerPrivate;
+-} // namespace workers
+ 
+ namespace dom {
+ namespace cache {
+ 
+ class ActorChild;
+ 
+ class CacheWorkerHolder final : public WorkerHolder
+ {
+ public:
+   static already_AddRefed<CacheWorkerHolder>
+-  Create(workers::WorkerPrivate* aWorkerPrivate,
++  Create(WorkerPrivate* aWorkerPrivate,
+          Behavior aBehavior);
+ 
+   static already_AddRefed<CacheWorkerHolder>
+   PreferBehavior(CacheWorkerHolder* aCurrentHolder, Behavior aBehavior);
+ 
+   void AddActor(ActorChild* aActor);
+   void RemoveActor(ActorChild* aActor);
+ 
+diff --git a/dom/canvas/OffscreenCanvas.cpp b/dom/canvas/OffscreenCanvas.cpp
+--- a/dom/canvas/OffscreenCanvas.cpp
++++ b/dom/canvas/OffscreenCanvas.cpp
+@@ -298,18 +298,17 @@ OffscreenCanvas::GetSurfaceSnapshot(gfxA
+ 
+ nsCOMPtr<nsIGlobalObject>
+ OffscreenCanvas::GetGlobalObject()
+ {
+   if (NS_IsMainThread()) {
+     return GetParentObject();
+   }
+ 
+-  dom::workers::WorkerPrivate* workerPrivate =
+-    dom::workers::GetCurrentThreadWorkerPrivate();
++  dom::WorkerPrivate* workerPrivate = dom::GetCurrentThreadWorkerPrivate();
+   return workerPrivate->GlobalScope();
+ }
+ 
+ /* static */ already_AddRefed<OffscreenCanvas>
+ OffscreenCanvas::CreateFromCloneData(nsIGlobalObject* aGlobal, OffscreenCanvasCloneData* aData)
+ {
+   MOZ_ASSERT(aData);
+   RefPtr<OffscreenCanvas> wc =
+diff --git a/dom/clients/api/Client.cpp b/dom/clients/api/Client.cpp
+--- a/dom/clients/api/Client.cpp
++++ b/dom/clients/api/Client.cpp
+@@ -14,18 +14,16 @@
+ #include "mozilla/dom/Promise.h"
+ #include "mozilla/dom/WorkerPrivate.h"
+ #include "mozilla/dom/WorkerScope.h"
+ #include "nsIGlobalObject.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+-using mozilla::dom::workers::GetCurrentThreadWorkerPrivate;
+-using mozilla::dom::workers::WorkerPrivate;
+ using mozilla::dom::ipc::StructuredCloneData;
+ 
+ NS_IMPL_CYCLE_COLLECTING_ADDREF(mozilla::dom::Client);
+ NS_IMPL_CYCLE_COLLECTING_RELEASE(mozilla::dom::Client);
+ NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(mozilla::dom::Client, mGlobal);
+ 
+ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(mozilla::dom::Client)
+   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
+diff --git a/dom/clients/api/ClientDOMUtil.h b/dom/clients/api/ClientDOMUtil.h
+--- a/dom/clients/api/ClientDOMUtil.h
++++ b/dom/clients/api/ClientDOMUtil.h
+@@ -20,17 +20,16 @@ namespace dom {
+ // will properly hold a worker thread alive and avoid executing callbacks
+ // if the thread is shutting down.
+ template<typename Func, typename Arg, typename Resolve, typename Reject>
+ void
+ StartClientManagerOp(Func aFunc, const Arg& aArg, nsISerialEventTarget* aTarget,
+                      Resolve aResolve, Reject aReject)
+ {
+   using mozilla::dom::WorkerStatus::Closing;
+-  using mozilla::dom::workers::GetCurrentThreadWorkerPrivate;
+ 
+   RefPtr<WorkerHolderToken> token;
+   if (!NS_IsMainThread()) {
+     token = WorkerHolderToken::Create(GetCurrentThreadWorkerPrivate(), Closing);
+   }
+ 
+   RefPtr<ClientOpPromise> promise = aFunc(aArg, aTarget);
+   promise->Then(aTarget, __func__,
+diff --git a/dom/clients/api/Clients.cpp b/dom/clients/api/Clients.cpp
+--- a/dom/clients/api/Clients.cpp
++++ b/dom/clients/api/Clients.cpp
+@@ -16,18 +16,16 @@
+ #include "mozilla/dom/WorkerPrivate.h"
+ #include "mozilla/SystemGroup.h"
+ #include "nsIGlobalObject.h"
+ #include "nsString.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+-using mozilla::dom::workers::GetCurrentThreadWorkerPrivate;
+-using mozilla::dom::workers::WorkerPrivate;
+ using mozilla::ipc::PrincipalInfo;
+ 
+ NS_IMPL_CYCLE_COLLECTING_ADDREF(Clients);
+ NS_IMPL_CYCLE_COLLECTING_RELEASE(Clients);
+ NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(Clients, mGlobal);
+ 
+ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(Clients)
+   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
+diff --git a/dom/clients/manager/ClientManager.cpp b/dom/clients/manager/ClientManager.cpp
+--- a/dom/clients/manager/ClientManager.cpp
++++ b/dom/clients/manager/ClientManager.cpp
+@@ -19,18 +19,16 @@
+ #include "prthread.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+ using mozilla::ipc::BackgroundChild;
+ using mozilla::ipc::PBackgroundChild;
+ using mozilla::ipc::PrincipalInfo;
+-using mozilla::dom::workers::GetCurrentThreadWorkerPrivate;
+-using mozilla::dom::workers::WorkerPrivate;
+ 
+ namespace {
+ 
+ uint32_t kBadThreadLocalIndex = -1;
+ uint32_t sClientManagerThreadLocalIndex = kBadThreadLocalIndex;
+ 
+ } // anonymous namespace
+ 
+diff --git a/dom/clients/manager/ClientManager.h b/dom/clients/manager/ClientManager.h
+--- a/dom/clients/manager/ClientManager.h
++++ b/dom/clients/manager/ClientManager.h
+@@ -24,20 +24,17 @@ class ClientHandle;
+ class ClientInfo;
+ class ClientManagerChild;
+ class ClientMatchAllArgs;
+ class ClientNavigateArgs;
+ class ClientOpConstructorArgs;
+ class ClientOpenWindowArgs;
+ class ClientSource;
+ enum class ClientType : uint8_t;
+-
+-namespace workers {
+ class WorkerPrivate;
+-} // workers namespace
+ 
+ // The ClientManager provides a per-thread singleton interface workering
+ // with the client subsystem.  It allows globals to create ClientSource
+ // objects.  It allows other parts of the system to attach to this globals
+ // by creating ClientHandle objects.  The ClientManager also provides
+ // methods for querying the list of clients active in the system.
+ class ClientManager final : public ClientThing<ClientManagerChild>
+ {
+@@ -71,17 +68,17 @@ class ClientManager final : public Clien
+ 
+   // Get or create the TLS singleton.  Currently this is only used
+   // internally and external code indirectly calls it by invoking
+   // static methods.
+   static already_AddRefed<ClientManager>
+   GetOrCreateForCurrentThread();
+ 
+   // Private methods called by ClientSource
+-  mozilla::dom::workers::WorkerPrivate*
++  mozilla::dom::WorkerPrivate*
+   GetWorkerPrivate() const;
+ 
+ public:
+   // Initialize the ClientManager at process start.  This
+   // does book-keeping like creating a TLS identifier, etc.
+   // This should only be called by process startup code.
+   static void
+   Startup();
+diff --git a/dom/clients/manager/ClientManagerChild.cpp b/dom/clients/manager/ClientManagerChild.cpp
+--- a/dom/clients/manager/ClientManagerChild.cpp
++++ b/dom/clients/manager/ClientManagerChild.cpp
+@@ -9,18 +9,16 @@
+ #include "ClientHandleChild.h"
+ #include "ClientManagerOpChild.h"
+ #include "ClientNavigateOpChild.h"
+ #include "ClientSourceChild.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+-using mozilla::dom::workers::WorkerPrivate;
+-
+ void
+ ClientManagerChild::ActorDestroy(ActorDestroyReason aReason)
+ {
+   if (mWorkerHolderToken) {
+     mWorkerHolderToken->RemoveListener(this);
+     mWorkerHolderToken = nullptr;
+ 
+   }
+diff --git a/dom/clients/manager/ClientManagerChild.h b/dom/clients/manager/ClientManagerChild.h
+--- a/dom/clients/manager/ClientManagerChild.h
++++ b/dom/clients/manager/ClientManagerChild.h
+@@ -8,19 +8,17 @@
+ 
+ #include "ClientThing.h"
+ #include "mozilla/dom/PClientManagerChild.h"
+ #include "mozilla/dom/WorkerHolderToken.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+-namespace workers {
+ class WorkerPrivate;
+-} // workers namespace
+ 
+ class ClientManagerChild final : public PClientManagerChild
+                                , public WorkerHolderToken::Listener
+ {
+   ClientThing<ClientManagerChild>* mManager;
+ 
+   RefPtr<WorkerHolderToken> mWorkerHolderToken;
+   bool mTeardownStarted;
+@@ -68,16 +66,16 @@ public:
+   SetOwner(ClientThing<ClientManagerChild>* aThing);
+ 
+   void
+   RevokeOwner(ClientThing<ClientManagerChild>* aThing);
+ 
+   void
+   MaybeStartTeardown();
+ 
+-  mozilla::dom::workers::WorkerPrivate*
++  mozilla::dom::WorkerPrivate*
+   GetWorkerPrivate() const;
+ };
+ 
+ } // namespace dom
+ } // namespace mozilla
+ 
+ #endif // _mozilla_dom_ClientManagerChild_h
+diff --git a/dom/clients/manager/ClientSource.cpp b/dom/clients/manager/ClientSource.cpp
+--- a/dom/clients/manager/ClientSource.cpp
++++ b/dom/clients/manager/ClientSource.cpp
+@@ -24,17 +24,16 @@
+ #include "nsContentUtils.h"
+ #include "nsIDocShell.h"
+ #include "nsPIDOMWindow.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+ using mozilla::dom::ipc::StructuredCloneData;
+-using mozilla::dom::workers::WorkerPrivate;
+ using mozilla::ipc::PrincipalInfo;
+ using mozilla::ipc::PrincipalInfoToPrincipal;
+ 
+ void
+ ClientSource::Shutdown()
+ {
+   NS_ASSERT_OWNINGTHREAD(ClientSource);
+   if (IsShutdown()) {
+diff --git a/dom/clients/manager/ClientSource.h b/dom/clients/manager/ClientSource.h
+--- a/dom/clients/manager/ClientSource.h
++++ b/dom/clients/manager/ClientSource.h
+@@ -30,20 +30,17 @@ class ClientGetInfoAndStateArgs;
+ class ClientManager;
+ class ClientPostMessageArgs;
+ class ClientSourceChild;
+ class ClientSourceConstructorArgs;
+ class ClientSourceExecutionReadyArgs;
+ class ClientState;
+ class ClientWindowState;
+ class PClientManagerChild;
+-
+-namespace workers {
+ class WorkerPrivate;
+-} // workers namespace
+ 
+ // ClientSource is an RAII style class that is designed to be held via
+ // a UniquePtr<>.  When created ClientSource will register the existence
+ // of a client in the cross-process ClientManagerService.  When the
+ // ClientSource is destroyed then client entry will be removed.  Code
+ // that represents globals or browsing environments, such as nsGlobalWindow
+ // or WorkerPrivate, should use ClientManager to create a ClientSource.
+ class ClientSource final : public ClientThing<ClientSourceChild>
+@@ -53,34 +50,34 @@ class ClientSource final : public Client
+   NS_DECL_OWNINGTHREAD
+ 
+   RefPtr<ClientManager> mManager;
+   nsCOMPtr<nsISerialEventTarget> mEventTarget;
+ 
+   Variant<Nothing,
+           RefPtr<nsPIDOMWindowInner>,
+           nsCOMPtr<nsIDocShell>,
+-          mozilla::dom::workers::WorkerPrivate*> mOwner;
++          WorkerPrivate*> mOwner;
+ 
+   ClientInfo mClientInfo;
+   Maybe<ServiceWorkerDescriptor> mController;
+ 
+   // Contained a de-duplicated list of ServiceWorker scope strings
+   // for which this client has called navigator.serviceWorker.register().
+   // Typically there will be either be zero or one scope strings, but
+   // there could be more.  We keep this list until the client is closed.
+   AutoTArray<nsCString, 1> mRegisteringScopeList;
+ 
+   void
+   Shutdown();
+ 
+   void
+   ExecutionReady(const ClientSourceExecutionReadyArgs& aArgs);
+ 
+-  mozilla::dom::workers::WorkerPrivate*
++  WorkerPrivate*
+   GetWorkerPrivate() const;
+ 
+   nsIDocShell*
+   GetDocShell() const;
+ 
+   void
+   MaybeCreateInitialDocument();
+ 
+@@ -97,17 +94,17 @@ class ClientSource final : public Client
+ 
+ public:
+   ~ClientSource();
+ 
+   nsPIDOMWindowInner*
+   GetInnerWindow() const;
+ 
+   void
+-  WorkerExecutionReady(mozilla::dom::workers::WorkerPrivate* aWorkerPrivate);
++  WorkerExecutionReady(WorkerPrivate* aWorkerPrivate);
+ 
+   nsresult
+   WindowExecutionReady(nsPIDOMWindowInner* aInnerWindow);
+ 
+   nsresult
+   DocShellExecutionReady(nsIDocShell* aDocShell);
+ 
+   void
+@@ -119,17 +116,17 @@ public:
+   const ClientInfo&
+   Info() const;
+ 
+   // Trigger a synchronous IPC ping to the parent process to confirm that
+   // the ClientSource actor has been created.  This should only be used
+   // by the WorkerPrivate startup code to deal with a ClientHandle::Control()
+   // call racing on the main thread.  Do not call this in other circumstances!
+   void
+-  WorkerSyncPing(mozilla::dom::workers::WorkerPrivate* aWorkerPrivate);
++  WorkerSyncPing(WorkerPrivate* aWorkerPrivate);
+ 
+   // Synchronously mark the ClientSource as controlled by the given service
+   // worker.  This can happen as a result of a remote operation or directly
+   // by local code.  For example, if a client's initial network load is
+   // intercepted by a controlling service worker then this should be called
+   // immediately.
+   //
+   // Note, there is no way to clear the controlling service worker because
+diff --git a/dom/crypto/WebCryptoTask.cpp b/dom/crypto/WebCryptoTask.cpp
+--- a/dom/crypto/WebCryptoTask.cpp
++++ b/dom/crypto/WebCryptoTask.cpp
+@@ -34,19 +34,16 @@ const SEC_ASN1Template SGN_DigestInfoTem
+     { SEC_ASN1_OCTET_STRING,
+       offsetof(SGNDigestInfo,digest) },
+     { 0, }
+ };
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+-using mozilla::dom::workers::GetCurrentThreadWorkerPrivate;
+-using mozilla::dom::workers::WorkerPrivate;
+-
+ // Pre-defined identifiers for telemetry histograms
+ 
+ enum TelemetryMethod {
+   TM_ENCRYPT      = 0,
+   TM_DECRYPT      = 1,
+   TM_SIGN         = 2,
+   TM_VERIFY       = 3,
+   TM_DIGEST       = 4,
+diff --git a/dom/events/Event.cpp b/dom/events/Event.cpp
+--- a/dom/events/Event.cpp
++++ b/dom/events/Event.cpp
+@@ -329,17 +329,17 @@ Event::SetTrusted(bool aTrusted)
+ {
+   mEvent->mFlags.mIsTrusted = aTrusted;
+ }
+ 
+ bool
+ Event::Init(mozilla::dom::EventTarget* aGlobal)
+ {
+   if (!mIsMainThreadEvent) {
+-    return workers::IsCurrentThreadRunningChromeWorker();
++    return IsCurrentThreadRunningChromeWorker();
+   }
+   bool trusted = false;
+   nsCOMPtr<nsPIDOMWindowInner> w = do_QueryInterface(aGlobal);
+   if (w) {
+     nsCOMPtr<nsIDocument> d = w->GetExtantDoc();
+     if (d) {
+       trusted = nsContentUtils::IsChromeDoc(d);
+       nsIPresShell* s = d->GetShell();
+@@ -1113,18 +1113,17 @@ Event::TimeStampImpl() const
+     Performance* perf = win->GetPerformance();
+     if (NS_WARN_IF(!perf)) {
+       return 0.0;
+     }
+ 
+     return perf->GetDOMTiming()->TimeStampToDOMHighRes(mEvent->mTimeStamp);
+   }
+ 
+-  workers::WorkerPrivate* workerPrivate =
+-    workers::GetCurrentThreadWorkerPrivate();
++  WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
+   MOZ_ASSERT(workerPrivate);
+ 
+   return workerPrivate->TimeStampToDOMHighRes(mEvent->mTimeStamp);
+ }
+ 
+ double
+ Event::TimeStamp() const
+ {
+diff --git a/dom/events/EventDispatcher.cpp b/dom/events/EventDispatcher.cpp
+--- a/dom/events/EventDispatcher.cpp
++++ b/dom/events/EventDispatcher.cpp
+@@ -920,17 +920,17 @@ EventDispatcher::DispatchDOMEvent(nsISup
+       innerEvent->mOriginalTarget = nullptr;
+     } else {
+       aDOMEvent->GetIsTrusted(&dontResetTrusted);
+     }
+ 
+     if (!dontResetTrusted) {
+       //Check security state to determine if dispatcher is trusted
+       bool trusted = NS_IsMainThread() ? nsContentUtils::LegacyIsCallerChromeOrNativeCode()
+-                                       : mozilla::dom::workers::IsCurrentThreadRunningChromeWorker();
++                                       : mozilla::dom::IsCurrentThreadRunningChromeWorker();
+       aDOMEvent->SetTrusted(trusted);
+     }
+ 
+     return EventDispatcher::Dispatch(aTarget, aPresContext, innerEvent,
+                                      aDOMEvent, aEventStatus);
+   } else if (aEvent) {
+     return EventDispatcher::Dispatch(aTarget, aPresContext, aEvent,
+                                      aDOMEvent, aEventStatus);
+diff --git a/dom/events/JSEventHandler.cpp b/dom/events/JSEventHandler.cpp
+--- a/dom/events/JSEventHandler.cpp
++++ b/dom/events/JSEventHandler.cpp
+@@ -121,17 +121,17 @@ JSEventHandler::HandleEvent(nsIDOMEvent*
+ 
+   Event* event = aEvent->InternalDOMEvent();
+   bool isMainThread = event->IsMainThreadEvent();
+   bool isChromeHandler =
+     isMainThread ?
+       nsContentUtils::ObjectPrincipal(
+         GetTypedEventHandler().Ptr()->CallbackPreserveColor()) ==
+         nsContentUtils::GetSystemPrincipal() :
+-      mozilla::dom::workers::IsCurrentThreadRunningChromeWorker();
++      mozilla::dom::IsCurrentThreadRunningChromeWorker();
+ 
+   if (mTypedHandler.Type() == TypedEventHandler::eOnError) {
+     MOZ_ASSERT_IF(mEventName, mEventName == nsGkAtoms::onerror);
+ 
+     nsString errorMsg, file;
+     EventOrString msgOrEvent;
+     Optional<nsAString> fileName;
+     Optional<uint32_t> lineNumber;
+diff --git a/dom/fetch/Fetch.cpp b/dom/fetch/Fetch.cpp
+--- a/dom/fetch/Fetch.cpp
++++ b/dom/fetch/Fetch.cpp
+@@ -184,17 +184,17 @@ class WorkerFetchResolver final : public
+ 
+   // Touched only on the worker thread.
+   RefPtr<FetchObserver> mFetchObserver;
+   UniquePtr<WorkerHolder> mWorkerHolder;
+ 
+ public:
+   // Returns null if worker is shutting down.
+   static already_AddRefed<WorkerFetchResolver>
+-  Create(workers::WorkerPrivate* aWorkerPrivate, Promise* aPromise,
++  Create(WorkerPrivate* aWorkerPrivate, Promise* aPromise,
+          AbortSignal* aSignal, FetchObserver* aObserver)
+   {
+     MOZ_ASSERT(aWorkerPrivate);
+     aWorkerPrivate->AssertIsOnWorkerThread();
+     RefPtr<PromiseWorkerProxy> proxy =
+       PromiseWorkerProxy::Create(aWorkerPrivate, aPromise);
+     if (!proxy) {
+       return nullptr;
+@@ -861,17 +861,17 @@ WorkerFetchResolver::FlushConsoleReport(
+ {
+   AssertIsOnMainThread();
+   MOZ_ASSERT(mPromiseProxy);
+ 
+   if(!mReporter) {
+     return;
+   }
+ 
+-  workers::WorkerPrivate* worker = mPromiseProxy->GetWorkerPrivate();
++  WorkerPrivate* worker = mPromiseProxy->GetWorkerPrivate();
+   if (!worker) {
+     mReporter->FlushReportsToConsole(0);
+     return;
+   }
+ 
+   if (worker->IsServiceWorker()) {
+     // Flush to service worker
+     mReporter->FlushReportsToConsoleForServiceWorkerScope(worker->ServiceWorkerScope());
+diff --git a/dom/fetch/Fetch.h b/dom/fetch/Fetch.h
+--- a/dom/fetch/Fetch.h
++++ b/dom/fetch/Fetch.h
+@@ -30,21 +30,19 @@ namespace dom {
+ 
+ class BlobOrArrayBufferViewOrArrayBufferOrFormDataOrURLSearchParamsOrUSVString;
+ class BlobOrArrayBufferViewOrArrayBufferOrFormDataOrURLSearchParamsOrReadableStreamOrUSVString;
+ class BlobImpl;
+ class InternalRequest;
+ class OwningBlobOrArrayBufferViewOrArrayBufferOrFormDataOrURLSearchParamsOrUSVString;
+ struct  ReadableStream;
+ class RequestOrUSVString;
+-enum class CallerType : uint32_t;
++class WorkerPrivate;
+ 
+-namespace workers {
+-class WorkerPrivate;
+-} // namespace workers
++enum class CallerType : uint32_t;
+ 
+ already_AddRefed<Promise>
+ FetchRequest(nsIGlobalObject* aGlobal, const RequestOrUSVString& aInput,
+              const RequestInit& aInit, CallerType aCallerType,
+              ErrorResult& aRv);
+ 
+ nsresult
+ UpdateRequestReferrer(nsIGlobalObject* aGlobal, InternalRequest* aRequest);
+@@ -248,17 +246,17 @@ public:
+   // AbortFollower
+   void
+   Abort() override;
+ 
+ protected:
+   nsCOMPtr<nsIGlobalObject> mOwner;
+ 
+   // Always set whenever the FetchBody is created on the worker thread.
+-  workers::WorkerPrivate* mWorkerPrivate;
++  WorkerPrivate* mWorkerPrivate;
+ 
+   // This is the ReadableStream exposed to content. It's underlying source is a
+   // FetchStream object.
+   JS::Heap<JSObject*> mReadableStreamBody;
+ 
+   // This is the Reader used to retrieve data from the body.
+   JS::Heap<JSObject*> mReadableStreamReader;
+   RefPtr<FetchStreamReader> mFetchStreamReader;
+diff --git a/dom/fetch/FetchConsumer.h b/dom/fetch/FetchConsumer.h
+--- a/dom/fetch/FetchConsumer.h
++++ b/dom/fetch/FetchConsumer.h
+@@ -15,20 +15,17 @@
+ 
+ class nsIThread;
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+ class Promise;
+ class WorkerHolder;
+-
+-namespace workers {
+ class WorkerPrivate;
+-}
+ 
+ template <class Derived> class FetchBody;
+ 
+ // FetchBody is not thread-safe but we need to move it around threads.
+ // In order to keep it alive all the time, we use a WorkerHolder, if created on
+ // workers, plus a this consumer.
+ template <class Derived>
+ class FetchBodyConsumer final : public nsIObserver
+@@ -57,17 +54,17 @@ public:
+   ContinueConsumeBody(nsresult aStatus, uint32_t aLength, uint8_t* aResult);
+ 
+   void
+   ContinueConsumeBlobBody(BlobImpl* aBlobImpl);
+ 
+   void
+   ShutDownMainThreadConsuming();
+ 
+-  workers::WorkerPrivate*
++  WorkerPrivate*
+   GetWorkerPrivate() const
+   {
+     return mWorkerPrivate;
+   }
+ 
+   void
+   NullifyConsumeBodyPump()
+   {
+@@ -76,17 +73,17 @@ public:
+   }
+ 
+   // AbortFollower
+   void Abort() override;
+ 
+ private:
+   FetchBodyConsumer(nsIEventTarget* aMainThreadEventTarget,
+                     nsIGlobalObject* aGlobalObject,
+-                    workers::WorkerPrivate* aWorkerPrivate,
++                    WorkerPrivate* aWorkerPrivate,
+                     FetchBody<Derived>* aBody,
+                     nsIInputStream* aBodyStream,
+                     Promise* aPromise,
+                     FetchConsumeType aType);
+ 
+   ~FetchBodyConsumer();
+ 
+   void
+@@ -112,17 +109,17 @@ private:
+   // Set when consuming the body is attempted on a worker.
+   // Unset when consumption is done/aborted.
+   // This WorkerHolder keeps alive the consumer via a cycle.
+   UniquePtr<WorkerHolder> mWorkerHolder;
+ 
+   nsCOMPtr<nsIGlobalObject> mGlobal;
+ 
+   // Always set whenever the FetchBodyConsumer is created on the worker thread.
+-  workers::WorkerPrivate* mWorkerPrivate;
++  WorkerPrivate* mWorkerPrivate;
+ 
+   // Touched on the main-thread only.
+   nsCOMPtr<nsIInputStreamPump> mConsumeBodyPump;
+ 
+   // Only ever set once, always on target thread.
+   FetchConsumeType mConsumeType;
+   RefPtr<Promise> mConsumePromise;
+ 
+diff --git a/dom/fetch/FetchUtil.cpp b/dom/fetch/FetchUtil.cpp
+--- a/dom/fetch/FetchUtil.cpp
++++ b/dom/fetch/FetchUtil.cpp
+@@ -403,17 +403,17 @@ class JSStreamConsumer final : public ns
+   }
+ 
+ public:
+   NS_DECL_THREADSAFE_ISUPPORTS
+ 
+   static bool Start(nsIInputStream* aStream,
+                     JS::StreamConsumer* aConsumer,
+                     nsIGlobalObject* aGlobal,
+-                    workers::WorkerPrivate* aMaybeWorker)
++                    WorkerPrivate* aMaybeWorker)
+   {
+     nsresult rv;
+ 
+     bool nonBlocking = false;
+     rv = aStream->IsNonBlocking(&nonBlocking);
+     if (NS_WARN_IF(NS_FAILED(rv))) {
+       return false;
+     }
+@@ -526,17 +526,17 @@ ThrowException(JSContext* aCx, unsigned 
+ }
+ 
+ // static
+ bool
+ FetchUtil::StreamResponseToJS(JSContext* aCx,
+                               JS::HandleObject aObj,
+                               JS::MimeType aMimeType,
+                               JS::StreamConsumer* aConsumer,
+-                              workers::WorkerPrivate* aMaybeWorker)
++                              WorkerPrivate* aMaybeWorker)
+ {
+   MOZ_ASSERT(!aMaybeWorker == NS_IsMainThread());
+ 
+   RefPtr<Response> response;
+   nsresult rv = UNWRAP_OBJECT(Response, aObj, response);
+   if (NS_FAILED(rv)) {
+     return ThrowException(aCx, JSMSG_BAD_RESPONSE_VALUE);
+   }
+diff --git a/dom/fetch/FetchUtil.h b/dom/fetch/FetchUtil.h
+--- a/dom/fetch/FetchUtil.h
++++ b/dom/fetch/FetchUtil.h
+@@ -17,20 +17,17 @@
+ class nsIPrincipal;
+ class nsIDocument;
+ class nsIHttpChannel;
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+ class InternalRequest;
+-
+-namespace workers {
+ class WorkerPrivate;
+-}
+ 
+ class FetchUtil final
+ {
+ private:
+   FetchUtil() = delete;
+ 
+ public:
+   /**
+@@ -64,14 +61,14 @@ public:
+    * given JSContext before returning false. If executing in a worker, the
+    * WorkerPrivate must be given.
+    */
+   static bool
+   StreamResponseToJS(JSContext* aCx,
+                      JS::HandleObject aObj,
+                      JS::MimeType aMimeType,
+                      JS::StreamConsumer* aConsumer,
+-                     workers::WorkerPrivate* aMaybeWorker);
++                     WorkerPrivate* aMaybeWorker);
+ };
+ 
+ } // namespace dom
+ } // namespace mozilla
+ #endif
+diff --git a/dom/fetch/Request.cpp b/dom/fetch/Request.cpp
+--- a/dom/fetch/Request.cpp
++++ b/dom/fetch/Request.cpp
+@@ -185,17 +185,17 @@ GetRequestURLFromChrome(const nsAString&
+   if (NS_WARN_IF(aRv.Failed())) {
+     return;
+   }
+ }
+ already_AddRefed<URL>
+ ParseURLFromWorker(const GlobalObject& aGlobal, const nsAString& aInput,
+                    ErrorResult& aRv)
+ {
+-  workers::WorkerPrivate* worker = workers::GetCurrentThreadWorkerPrivate();
++  WorkerPrivate* worker = GetCurrentThreadWorkerPrivate();
+   MOZ_ASSERT(worker);
+   worker->AssertIsOnWorkerThread();
+ 
+   NS_ConvertUTF8toUTF16 baseURL(worker->GetLocationInfo().mHref);
+   RefPtr<URL> url = URL::WorkerConstructor(aGlobal, aInput, baseURL, aRv);
+   if (NS_WARN_IF(aRv.Failed())) {
+     aRv.ThrowTypeError<MSG_INVALID_URL>(aInput);
+   }
+@@ -246,17 +246,17 @@ GetRequestURLFromWorker(const GlobalObje
+   if (NS_WARN_IF(aRv.Failed())) {
+     return;
+   }
+ }
+ 
+ class ReferrerSameOriginChecker final : public WorkerMainThreadRunnable
+ {
+ public:
+-  ReferrerSameOriginChecker(workers::WorkerPrivate* aWorkerPrivate,
++  ReferrerSameOriginChecker(WorkerPrivate* aWorkerPrivate,
+                             const nsAString& aReferrerURL,
+                             nsresult& aResult)
+     : WorkerMainThreadRunnable(aWorkerPrivate,
+                                NS_LITERAL_CSTRING("Fetch :: Referrer same origin check")),
+       mReferrerURL(aReferrerURL),
+       mResult(aResult)
+   {
+     mWorkerPrivate->AssertIsOnWorkerThread();
+@@ -402,17 +402,17 @@ Request::Constructor(const GlobalObject&
+           return nullptr;
+         }
+         url->Stringify(referrerURL, aRv);
+         if (NS_WARN_IF(aRv.Failed())) {
+           aRv.ThrowTypeError<MSG_INVALID_REFERRER_URL>(referrer);
+           return nullptr;
+         }
+         if (!referrerURL.EqualsLiteral(kFETCH_CLIENT_REFERRER_STR)) {
+-          workers::WorkerPrivate* worker = workers::GetCurrentThreadWorkerPrivate();
++          WorkerPrivate* worker = GetCurrentThreadWorkerPrivate();
+           nsresult rv = NS_OK;
+           // ReferrerSameOriginChecker uses a sync loop to get the main thread
+           // to perform the same-origin check.  Overall, on Workers this method
+           // can create 3 sync loops (two for constructing URLs and one here) so
+           // in the future we may want to optimize it all by off-loading all of
+           // this work in a single sync loop.
+           RefPtr<ReferrerSameOriginChecker> checker =
+             new ReferrerSameOriginChecker(worker, referrerURL, rv);
+@@ -440,17 +440,17 @@ Request::Constructor(const GlobalObject&
+     if (window) {
+       nsCOMPtr<nsIDocument> doc;
+       doc = window->GetExtantDoc();
+       if (doc) {
+         request->SetEnvironmentReferrerPolicy(doc->GetReferrerPolicy());
+       }
+     }
+   } else {
+-    workers::WorkerPrivate* worker = workers::GetCurrentThreadWorkerPrivate();
++    WorkerPrivate* worker = GetCurrentThreadWorkerPrivate();
+     if (worker) {
+       worker->AssertIsOnWorkerThread();
+       request->SetEnvironmentReferrerPolicy(worker->GetReferrerPolicy());
+     }
+   }
+ 
+   if (mode != RequestMode::EndGuard_) {
+     request->SetMode(mode);
+diff --git a/dom/fetch/Response.cpp b/dom/fetch/Response.cpp
+--- a/dom/fetch/Response.cpp
++++ b/dom/fetch/Response.cpp
+@@ -114,17 +114,17 @@ Response::Redirect(const GlobalObject& a
+     nsAutoCString spec;
+     aRv = resolvedURI->GetSpec(spec);
+     if (NS_WARN_IF(aRv.Failed())) {
+       return nullptr;
+     }
+ 
+     CopyUTF8toUTF16(spec, parsedURL);
+   } else {
+-    workers::WorkerPrivate* worker = workers::GetCurrentThreadWorkerPrivate();
++    WorkerPrivate* worker = GetCurrentThreadWorkerPrivate();
+     MOZ_ASSERT(worker);
+     worker->AssertIsOnWorkerThread();
+ 
+     NS_ConvertUTF8toUTF16 baseURL(worker->GetLocationInfo().mHref);
+     RefPtr<URL> url = URL::WorkerConstructor(aGlobal, aUrl, baseURL, aRv);
+     if (aRv.Failed()) {
+       return nullptr;
+     }
+@@ -199,17 +199,17 @@ Response::Constructor(const GlobalObject
+       nsIDocument* doc = window->GetExtantDoc();
+       MOZ_ASSERT(doc);
+       info.InitFromDocument(doc);
+     } else {
+       info.InitFromChromeGlobal(global);
+     }
+     internalResponse->InitChannelInfo(info);
+   } else {
+-    workers::WorkerPrivate* worker = workers::GetCurrentThreadWorkerPrivate();
++    WorkerPrivate* worker = GetCurrentThreadWorkerPrivate();
+     MOZ_ASSERT(worker);
+     internalResponse->InitChannelInfo(worker->GetChannelInfo());
+   }
+ 
+   RefPtr<Response> r = new Response(global, internalResponse, nullptr);
+ 
+   if (aInit.mHeaders.WasPassed()) {
+     internalResponse->Headers()->Clear();
+diff --git a/dom/file/FileBlobImpl.cpp b/dom/file/FileBlobImpl.cpp
+--- a/dom/file/FileBlobImpl.cpp
++++ b/dom/file/FileBlobImpl.cpp
+@@ -13,18 +13,16 @@
+ #include "nsIFileStreams.h"
+ #include "nsIMIMEService.h"
+ #include "nsNetUtil.h"
+ #include "nsStreamUtils.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+-using namespace workers;
+-
+ NS_IMPL_ISUPPORTS_INHERITED0(FileBlobImpl, BlobImpl)
+ 
+ FileBlobImpl::FileBlobImpl(nsIFile* aFile)
+   : BaseBlobImpl(EmptyString(), EmptyString(), UINT64_MAX, INT64_MAX)
+   , mFile(aFile)
+   , mWholeFile(true)
+   , mFileId(-1)
+ {
+diff --git a/dom/file/FileReader.cpp b/dom/file/FileReader.cpp
+--- a/dom/file/FileReader.cpp
++++ b/dom/file/FileReader.cpp
+@@ -28,18 +28,16 @@
+ #include "xpcpublic.h"
+ 
+ #include "WorkerPrivate.h"
+ #include "WorkerScope.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+-using namespace workers;
+-
+ #define ABORT_STR "abort"
+ #define LOAD_STR "load"
+ #define LOADSTART_STR "loadstart"
+ #define LOADEND_STR "loadend"
+ #define ERROR_STR "error"
+ #define PROGRESS_STR "progress"
+ 
+ const uint64_t kUnknownSize = uint64_t(-1);
+diff --git a/dom/file/FileReader.h b/dom/file/FileReader.h
+--- a/dom/file/FileReader.h
++++ b/dom/file/FileReader.h
+@@ -23,20 +23,17 @@
+ class nsITimer;
+ class nsIEventTarget;
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+ class Blob;
+ class DOMException;
+-
+-namespace workers {
+ class WorkerPrivate;
+-}
+ 
+ extern const uint64_t kUnknownSize;
+ 
+ class FileReaderDecreaseBusyCounter;
+ 
+ class FileReader final : public DOMEventTargetHelper,
+                          public nsIInterfaceRequestor,
+                          public nsSupportsWeakReference,
+@@ -44,17 +41,17 @@ class FileReader final : public DOMEvent
+                          public nsITimerCallback,
+                          public nsINamed,
+                          public WorkerHolder
+ {
+   friend class FileReaderDecreaseBusyCounter;
+ 
+ public:
+   FileReader(nsIGlobalObject* aGlobal,
+-             workers::WorkerPrivate* aWorkerPrivate);
++             WorkerPrivate* aWorkerPrivate);
+ 
+   NS_DECL_ISUPPORTS_INHERITED
+ 
+   NS_DECL_NSITIMERCALLBACK
+   NS_DECL_NSIINPUTSTREAMCALLBACK
+   NS_DECL_NSIINTERFACEREQUESTOR
+   NS_DECL_NSINAMED
+ 
+@@ -196,15 +193,15 @@ private:
+   uint64_t mTotal;
+   uint64_t mTransferred;
+ 
+   nsCOMPtr<nsIEventTarget> mTarget;
+ 
+   uint64_t mBusyCount;
+ 
+   // Kept alive with a WorkerHolder.
+-  workers::WorkerPrivate* mWorkerPrivate;
++  WorkerPrivate* mWorkerPrivate;
+ };
+ 
+ } // dom namespace
+ } // mozilla namespace
+ 
+ #endif // mozilla_dom_FileReader_h
+diff --git a/dom/file/FileReaderSync.cpp b/dom/file/FileReaderSync.cpp
+--- a/dom/file/FileReaderSync.cpp
++++ b/dom/file/FileReaderSync.cpp
+@@ -28,17 +28,16 @@
+ #include "nsIAsyncInputStream.h"
+ #include "WorkerPrivate.h"
+ #include "WorkerRunnable.h"
+ 
+ #include "RuntimeService.h"
+ 
+ using namespace mozilla;
+ using namespace mozilla::dom;
+-using namespace mozilla::dom::workers;
+ using mozilla::dom::Optional;
+ using mozilla::dom::GlobalObject;
+ 
+ // static
+ already_AddRefed<FileReaderSync>
+ FileReaderSync::Constructor(const GlobalObject& aGlobal, ErrorResult& aRv)
+ {
+   RefPtr<FileReaderSync> frs = new FileReaderSync();
+diff --git a/dom/network/Connection.cpp b/dom/network/Connection.cpp
+--- a/dom/network/Connection.cpp
++++ b/dom/network/Connection.cpp
+@@ -15,18 +15,16 @@
+  * We have to use macros here because our leak analysis tool things we are
+  * leaking strings when we have |static const nsString|. Sad :(
+  */
+ #define CHANGE_EVENT_NAME NS_LITERAL_STRING("typechange")
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+-using namespace workers;
+-
+ namespace network {
+ 
+ NS_IMPL_QUERY_INTERFACE_INHERITED(Connection, DOMEventTargetHelper,
+                                   nsINetworkProperties)
+ 
+ // Don't use |Connection| alone, since that confuses nsTraceRefcnt since
+ // we're not the only class with that name.
+ NS_IMPL_ADDREF_INHERITED(dom::network::Connection, DOMEventTargetHelper)
+@@ -107,17 +105,17 @@ Connection::Update(ConnectionType aType,
+ /* static */ Connection*
+ Connection::CreateForWindow(nsPIDOMWindowInner* aWindow)
+ {
+   MOZ_ASSERT(aWindow);
+   return new ConnectionMainThread(aWindow);
+ }
+ 
+ /* static */ already_AddRefed<Connection>
+-Connection::CreateForWorker(workers::WorkerPrivate* aWorkerPrivate,
++Connection::CreateForWorker(WorkerPrivate* aWorkerPrivate,
+                             ErrorResult& aRv)
+ {
+   MOZ_ASSERT(aWorkerPrivate);
+   aWorkerPrivate->AssertIsOnWorkerThread();
+   return ConnectionWorker::Create(aWorkerPrivate, aRv);
+ }
+ 
+ } // namespace network
+diff --git a/dom/network/Connection.h b/dom/network/Connection.h
+--- a/dom/network/Connection.h
++++ b/dom/network/Connection.h
+@@ -16,19 +16,17 @@
+ namespace mozilla {
+ 
+ namespace hal {
+ class NetworkInformation;
+ } // namespace hal
+ 
+ namespace dom {
+ 
+-namespace workers {
+ class WorkerPrivate;
+-} // namespace workers
+ 
+ namespace network {
+ 
+ class Connection : public DOMEventTargetHelper
+                  , public nsINetworkProperties
+ {
+ public:
+   NS_DECL_ISUPPORTS_INHERITED
+@@ -36,17 +34,17 @@ public:
+   NS_DECL_OWNINGTHREAD
+ 
+   NS_REALLY_FORWARD_NSIDOMEVENTTARGET(DOMEventTargetHelper)
+ 
+   static Connection*
+   CreateForWindow(nsPIDOMWindowInner* aWindow);
+ 
+   static already_AddRefed<Connection>
+-  CreateForWorker(workers::WorkerPrivate* aWorkerPrivate,
++  CreateForWorker(WorkerPrivate* aWorkerPrivate,
+                   ErrorResult& aRv);
+ 
+   void Shutdown();
+ 
+   // WebIDL
+ 
+   virtual JSObject* WrapObject(JSContext* aCx,
+                                JS::Handle<JSObject*> aGivenProto) override;
+diff --git a/dom/network/ConnectionWorker.h b/dom/network/ConnectionWorker.h
+--- a/dom/network/ConnectionWorker.h
++++ b/dom/network/ConnectionWorker.h
+@@ -18,25 +18,25 @@ namespace network {
+ class ConnectionProxy;
+ 
+ class ConnectionWorker final : public Connection
+ {
+   friend class ConnectionProxy;
+ 
+ public:
+   static already_AddRefed<ConnectionWorker>
+-  Create(workers::WorkerPrivate* aWorkerPrivate, ErrorResult& aRv);
++  Create(WorkerPrivate* aWorkerPrivate, ErrorResult& aRv);
+ 
+ private:
+-  explicit ConnectionWorker(workers::WorkerPrivate* aWorkerPrivate);
++  explicit ConnectionWorker(WorkerPrivate* aWorkerPrivate);
+   ~ConnectionWorker();
+ 
+   virtual void ShutdownInternal() override;
+ 
+-  workers::WorkerPrivate* mWorkerPrivate;
++  WorkerPrivate* mWorkerPrivate;
+   RefPtr<ConnectionProxy> mProxy;
+ };
+ 
+ } // namespace network
+ } // namespace dom
+ } // namespace mozilla
+ 
+ #endif // mozilla_dom_network_ConnectionWorker_h
+diff --git a/dom/notification/Notification.cpp b/dom/notification/Notification.cpp
+--- a/dom/notification/Notification.cpp
++++ b/dom/notification/Notification.cpp
+@@ -54,17 +54,17 @@
+ #include "nsXULAppAPI.h"
+ #include "WorkerPrivate.h"
+ #include "WorkerRunnable.h"
+ #include "WorkerScope.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+-using namespace workers;
++using workers::AssertIsOnMainThread;
+ 
+ struct NotificationStrings
+ {
+   const nsString mID;
+   const nsString mTitle;
+   const nsString mDir;
+   const nsString mLang;
+   const nsString mBody;
+diff --git a/dom/notification/Notification.h b/dom/notification/Notification.h
+--- a/dom/notification/Notification.h
++++ b/dom/notification/Notification.h
+@@ -24,20 +24,17 @@ class nsIPrincipal;
+ class nsIVariant;
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+ class NotificationRef;
+ class WorkerNotificationObserver;
+ class Promise;
+-
+-namespace workers {
+-  class WorkerPrivate;
+-} // namespace workers
++class WorkerPrivate;
+ 
+ class Notification;
+ class NotificationWorkerHolder final : public WorkerHolder
+ {
+   // Since the feature is strongly held by a Notification, it is ok to hold
+   // a raw pointer here.
+   Notification* mNotification;
+ 
+@@ -215,17 +212,17 @@ public:
+       const GetNotificationOptions& aFilter,
+       const nsAString& aScope,
+       ErrorResult& aRv);
+ 
+   static already_AddRefed<Promise> Get(const GlobalObject& aGlobal,
+                                        const GetNotificationOptions& aFilter,
+                                        ErrorResult& aRv);
+ 
+-  static already_AddRefed<Promise> WorkerGet(workers::WorkerPrivate* aWorkerPrivate,
++  static already_AddRefed<Promise> WorkerGet(WorkerPrivate* aWorkerPrivate,
+                                              const GetNotificationOptions& aFilter,
+                                              const nsAString& aScope,
+                                              ErrorResult& aRv);
+ 
+   // Notification implementation of
+   // ServiceWorkerRegistration.showNotification.
+   //
+   //
+@@ -258,17 +255,17 @@ public:
+ 
+   void AssertIsOnTargetThread() const
+   {
+     MOZ_ASSERT(IsTargetThread());
+   }
+ 
+   // Initialized on the worker thread, never unset, and always used in
+   // a read-only capacity. Used on any thread.
+-  workers::WorkerPrivate* mWorkerPrivate;
++  WorkerPrivate* mWorkerPrivate;
+ 
+   // Main thread only.
+   WorkerNotificationObserver* mObserver;
+ 
+   // The NotificationTask calls ShowInternal()/CloseInternal() on the
+   // Notification. At this point the task has ownership of the Notification. It
+   // passes this on to the Notification itself via mTempRef so that
+   // ShowInternal()/CloseInternal() may pass it along appropriately (or release
+diff --git a/dom/performance/Performance.cpp b/dom/performance/Performance.cpp
+--- a/dom/performance/Performance.cpp
++++ b/dom/performance/Performance.cpp
+@@ -19,30 +19,28 @@
+ #include "mozilla/ErrorResult.h"
+ #include "mozilla/dom/PerformanceBinding.h"
+ #include "mozilla/dom/PerformanceEntryEvent.h"
+ #include "mozilla/dom/PerformanceNavigationBinding.h"
+ #include "mozilla/dom/PerformanceObserverBinding.h"
+ #include "mozilla/dom/PerformanceNavigationTiming.h"
+ #include "mozilla/IntegerPrintfMacros.h"
+ #include "mozilla/Preferences.h"
+-#include "WorkerPrivate.h"
+-#include "WorkerRunnable.h"
++#include "mozilla/dom/WorkerPrivate.h"
++#include "mozilla/dom/WorkerRunnable.h"
+ 
+ #ifdef MOZ_GECKO_PROFILER
+ #include "ProfilerMarkerPayload.h"
+ #endif
+ 
+ #define PERFLOG(msg, ...) printf_stderr(msg, ##__VA_ARGS__)
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+-using namespace workers;
+-
+ namespace {
+ 
+ class PrefEnabledRunnable final
+   : public WorkerCheckAPIExposureOnMainThreadRunnable
+ {
+ public:
+   PrefEnabledRunnable(WorkerPrivate* aWorkerPrivate,
+                       const nsCString& aPrefName)
+@@ -89,17 +87,17 @@ Performance::CreateForMainThread(nsPIDOM
+   MOZ_ASSERT(NS_IsMainThread());
+ 
+   RefPtr<Performance> performance =
+     new PerformanceMainThread(aWindow, aDOMTiming, aChannel);
+   return performance.forget();
+ }
+ 
+ /* static */ already_AddRefed<Performance>
+-Performance::CreateForWorker(workers::WorkerPrivate* aWorkerPrivate)
++Performance::CreateForWorker(WorkerPrivate* aWorkerPrivate)
+ {
+   MOZ_ASSERT(aWorkerPrivate);
+   aWorkerPrivate->AssertIsOnWorkerThread();
+ 
+   RefPtr<Performance> performance = new PerformanceWorker(aWorkerPrivate);
+   return performance.forget();
+ }
+ 
+diff --git a/dom/performance/Performance.h b/dom/performance/Performance.h
+--- a/dom/performance/Performance.h
++++ b/dom/performance/Performance.h
+@@ -21,20 +21,17 @@ class ErrorResult;
+ namespace dom {
+ 
+ class PerformanceEntry;
+ class PerformanceNavigation;
+ class PerformanceObserver;
+ class PerformanceService;
+ class PerformanceStorage;
+ class PerformanceTiming;
+-
+-namespace workers {
+ class WorkerPrivate;
+-}
+ 
+ // Base class for main-thread and worker Performance API
+ class Performance : public DOMEventTargetHelper
+ {
+ public:
+   NS_DECL_ISUPPORTS_INHERITED
+   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(Performance,
+                                            DOMEventTargetHelper)
+@@ -42,17 +39,17 @@ public:
+   static bool IsObserverEnabled(JSContext* aCx, JSObject* aGlobal);
+ 
+   static already_AddRefed<Performance>
+   CreateForMainThread(nsPIDOMWindowInner* aWindow,
+                       nsDOMNavigationTiming* aDOMTiming,
+                       nsITimedChannel* aChannel);
+ 
+   static already_AddRefed<Performance>
+-  CreateForWorker(workers::WorkerPrivate* aWorkerPrivate);
++  CreateForWorker(WorkerPrivate* aWorkerPrivate);
+ 
+   JSObject* WrapObject(JSContext *cx,
+                        JS::Handle<JSObject*> aGivenProto) override;
+ 
+   virtual void GetEntries(nsTArray<RefPtr<PerformanceEntry>>& aRetval);
+ 
+   virtual void GetEntriesByType(const nsAString& aEntryType,
+                                 nsTArray<RefPtr<PerformanceEntry>>& aRetval);
+diff --git a/dom/performance/PerformanceObserver.cpp b/dom/performance/PerformanceObserver.cpp
+--- a/dom/performance/PerformanceObserver.cpp
++++ b/dom/performance/PerformanceObserver.cpp
+@@ -5,27 +5,26 @@
+  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+ 
+ #include "PerformanceObserver.h"
+ 
+ #include "mozilla/dom/Performance.h"
+ #include "mozilla/dom/PerformanceBinding.h"
+ #include "mozilla/dom/PerformanceEntryBinding.h"
+ #include "mozilla/dom/PerformanceObserverBinding.h"
++#include "mozilla/dom/WorkerPrivate.h"
++#include "mozilla/dom/WorkerScope.h"
+ #include "nsPIDOMWindow.h"
+ #include "nsQueryObject.h"
+ #include "nsString.h"
+ #include "PerformanceEntry.h"
+ #include "PerformanceObserverEntryList.h"
+-#include "WorkerPrivate.h"
+-#include "WorkerScope.h"
+ 
+ using namespace mozilla;
+ using namespace mozilla::dom;
+-using namespace mozilla::dom::workers;
+ 
+ NS_IMPL_CYCLE_COLLECTION_CLASS(PerformanceObserver)
+ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(PerformanceObserver)
+   tmp->Disconnect();
+   NS_IMPL_CYCLE_COLLECTION_UNLINK(mCallback)
+   NS_IMPL_CYCLE_COLLECTION_UNLINK(mPerformance)
+   NS_IMPL_CYCLE_COLLECTION_UNLINK(mOwner)
+   NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
+diff --git a/dom/performance/PerformanceObserver.h b/dom/performance/PerformanceObserver.h
+--- a/dom/performance/PerformanceObserver.h
++++ b/dom/performance/PerformanceObserver.h
+@@ -22,36 +22,34 @@ class ErrorResult;
+ 
+ namespace dom {
+ 
+ class GlobalObject;
+ class Performance;
+ class PerformanceEntry;
+ class PerformanceObserverCallback;
+ struct PerformanceObserverInit;
+-namespace workers {
+ class WorkerPrivate;
+-} // namespace workers
+ 
+ class PerformanceObserver final : public nsISupports,
+                                   public nsWrapperCache
+ {
+ public:
+   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
+   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(PerformanceObserver)
+ 
+   static already_AddRefed<PerformanceObserver>
+   Constructor(const GlobalObject& aGlobal,
+               PerformanceObserverCallback& aCb,
+               ErrorResult& aRv);
+ 
+   PerformanceObserver(nsPIDOMWindowInner* aOwner,
+                       PerformanceObserverCallback& aCb);
+ 
+-  PerformanceObserver(workers::WorkerPrivate* aWorkerPrivate,
++  PerformanceObserver(WorkerPrivate* aWorkerPrivate,
+                       PerformanceObserverCallback& aCb);
+ 
+   virtual JSObject* WrapObject(JSContext* aCx,
+                                JS::Handle<JSObject*> aGivenProto) override;
+ 
+   nsISupports* GetParentObject() const { return mOwner; }
+ 
+   void Observe(const PerformanceObserverInit& aOptions,
+diff --git a/dom/performance/PerformanceStorageWorker.cpp b/dom/performance/PerformanceStorageWorker.cpp
+--- a/dom/performance/PerformanceStorageWorker.cpp
++++ b/dom/performance/PerformanceStorageWorker.cpp
+@@ -1,23 +1,21 @@
+ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+ /* vim: set ts=8 sts=2 et sw=2 tw=80: */
+ /* 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 "PerformanceStorageWorker.h"
+-#include "WorkerPrivate.h"
+-#include "WorkerHolder.h"
++#include "mozilla/dom/WorkerHolder.h"
++#include "mozilla/dom/WorkerPrivate.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+-using namespace workers;
+-
+ class PerformanceProxyData
+ {
+ public:
+   PerformanceProxyData(UniquePtr<PerformanceTimingData>&& aData,
+                        const nsAString& aInitiatorType,
+                        const nsAString& aEntryName)
+     : mData(Move(aData))
+     , mInitiatorType(aInitiatorType)
+diff --git a/dom/performance/PerformanceStorageWorker.h b/dom/performance/PerformanceStorageWorker.h
+--- a/dom/performance/PerformanceStorageWorker.h
++++ b/dom/performance/PerformanceStorageWorker.h
+@@ -8,50 +8,47 @@
+ #define mozilla_dom_PerformanceStorageWorker_h
+ 
+ #include "PerformanceStorage.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+ class WorkerHolder;
+-
+-namespace workers {
+ class WorkerPrivate;
+-}
+ 
+ class PerformanceProxyData;
+ 
+ class PerformanceStorageWorker final : public PerformanceStorage
+ {
+ public:
+   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(PerformanceStorageWorker, override)
+ 
+   static already_AddRefed<PerformanceStorageWorker>
+-  Create(workers::WorkerPrivate* aWorkerPrivate);
++  Create(WorkerPrivate* aWorkerPrivate);
+ 
+   void InitializeOnWorker();
+ 
+   void ShutdownOnWorker();
+ 
+   void AddEntry(nsIHttpChannel* aChannel,
+                 nsITimedChannel* aTimedChannel) override;
+ 
+   void AddEntryOnWorker(UniquePtr<PerformanceProxyData>&& aData);
+ 
+ private:
+-  explicit PerformanceStorageWorker(workers::WorkerPrivate* aWorkerPrivate);
++  explicit PerformanceStorageWorker(WorkerPrivate* aWorkerPrivate);
+   ~PerformanceStorageWorker();
+ 
+   Mutex mMutex;
+ 
+   // Protected by mutex.
+   // This raw pointer is nullified when the WorkerHolder communicates the
+   // shutting down of the worker thread.
+-  workers::WorkerPrivate* mWorkerPrivate;
++  WorkerPrivate* mWorkerPrivate;
+ 
+   // Protected by mutex.
+   enum {
+     eInitializing,
+     eReady,
+     eTerminated,
+   } mState;
+ 
+diff --git a/dom/performance/PerformanceWorker.cpp b/dom/performance/PerformanceWorker.cpp
+--- a/dom/performance/PerformanceWorker.cpp
++++ b/dom/performance/PerformanceWorker.cpp
+@@ -1,23 +1,21 @@
+ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+ /* vim: set ts=8 sts=2 et sw=2 tw=80: */
+ /* 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 "PerformanceWorker.h"
+ #include "mozilla/dom/DOMPrefs.h"
+-#include "WorkerPrivate.h"
++#include "mozilla/dom/WorkerPrivate.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+-using namespace workers;
+-
+ PerformanceWorker::PerformanceWorker(WorkerPrivate* aWorkerPrivate)
+   : mWorkerPrivate(aWorkerPrivate)
+ {
+   mWorkerPrivate->AssertIsOnWorkerThread();
+ }
+ 
+ PerformanceWorker::~PerformanceWorker()
+ {
+diff --git a/dom/performance/PerformanceWorker.h b/dom/performance/PerformanceWorker.h
+--- a/dom/performance/PerformanceWorker.h
++++ b/dom/performance/PerformanceWorker.h
+@@ -7,24 +7,22 @@
+ #ifndef mozilla_dom_PerformanceWorker_h
+ #define mozilla_dom_PerformanceWorker_h
+ 
+ #include "Performance.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+-namespace workers {
+ class WorkerPrivate;
+-}
+ 
+ class PerformanceWorker final : public Performance
+ {
+ public:
+-  explicit PerformanceWorker(workers::WorkerPrivate* aWorkerPrivate);
++  explicit PerformanceWorker(WorkerPrivate* aWorkerPrivate);
+ 
+   PerformanceStorage* AsPerformanceStorage() override
+   {
+     MOZ_CRASH("This should not be called on workers.");
+     return nullptr;
+   }
+ 
+   virtual PerformanceTiming* Timing() override
+@@ -67,15 +65,15 @@ protected:
+   void InsertUserEntry(PerformanceEntry* aEntry) override;
+ 
+   void DispatchBufferFullEvent() override
+   {
+     // Nothing to do here. See bug 1432758.
+   }
+ 
+ private:
+-  workers::WorkerPrivate* mWorkerPrivate;
++  WorkerPrivate* mWorkerPrivate;
+ };
+ 
+ } // namespace dom
+ } // namespace mozilla
+ 
+ #endif // mozilla_dom_PerformanceWorker_h
+diff --git a/dom/performance/moz.build b/dom/performance/moz.build
+--- a/dom/performance/moz.build
++++ b/dom/performance/moz.build
+@@ -35,15 +35,11 @@ UNIFIED_SOURCES += [
+     'PerformanceObserverEntryList.cpp',
+     'PerformanceResourceTiming.cpp',
+     'PerformanceService.cpp',
+     'PerformanceStorageWorker.cpp',
+     'PerformanceTiming.cpp',
+     'PerformanceWorker.cpp',
+ ]
+ 
+-LOCAL_INCLUDES += [
+-    '/dom/workers',
+-]
+-
+ MOCHITEST_MANIFESTS += [ 'tests/mochitest.ini' ]
+ 
+ FINAL_LIBRARY = 'xul'
+diff --git a/dom/promise/Promise.cpp b/dom/promise/Promise.cpp
+--- a/dom/promise/Promise.cpp
++++ b/dom/promise/Promise.cpp
+@@ -40,18 +40,16 @@
+ namespace mozilla {
+ namespace dom {
+ 
+ namespace {
+ // Generator used by Promise::GetID.
+ Atomic<uintptr_t> gIDGenerator(0);
+ } // namespace
+ 
+-using namespace workers;
+-
+ // Promise
+ 
+ NS_IMPL_CYCLE_COLLECTION_CLASS(Promise)
+ 
+ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(Promise)
+   NS_IMPL_CYCLE_COLLECTION_UNLINK(mGlobal)
+   tmp->mPromiseObj = nullptr;
+ NS_IMPL_CYCLE_COLLECTION_UNLINK_END
+diff --git a/dom/promise/PromiseDebugging.h b/dom/promise/PromiseDebugging.h
+--- a/dom/promise/PromiseDebugging.h
++++ b/dom/promise/PromiseDebugging.h
+@@ -11,25 +11,22 @@
+ #include "nsTArray.h"
+ #include "mozilla/RefPtr.h"
+ 
+ namespace mozilla {
+ 
+ class ErrorResult;
+ 
+ namespace dom {
+-namespace workers {
+-class WorkerPrivate;
+-} // namespace workers
+-
+ class Promise;
+ struct PromiseDebuggingStateHolder;
+ class GlobalObject;
+ class UncaughtRejectionObserver;
+ class FlushRejections;
++class WorkerPrivate;
+ 
+ void TriggerFlushRejections();
+ 
+ class PromiseDebugging
+ {
+ public:
+   static void Init();
+   static void Shutdown();
+@@ -65,17 +62,17 @@ public:
+   static void AddConsumedRejection(JS::HandleObject);
+   // Propagate the informations from AddUncaughtRejection
+   // and AddConsumedRejection to observers.
+   static void FlushUncaughtRejections();
+ 
+ protected:
+   static void FlushUncaughtRejectionsInternal();
+   friend class FlushRejections;
+-  friend class mozilla::dom::workers::WorkerPrivate;
++  friend class mozilla::dom::WorkerPrivate;
+ private:
+   // Identity of the process.
+   // This property is:
+   // - set during initialization of the layout module,
+   // prior to any Worker using it;
+   // - read by both the main thread and the Workers;
+   // - unset during shutdown of the layout module,
+   // after any Worker has been shutdown.
+diff --git a/dom/promise/PromiseWorkerProxy.h b/dom/promise/PromiseWorkerProxy.h
+--- a/dom/promise/PromiseWorkerProxy.h
++++ b/dom/promise/PromiseWorkerProxy.h
+@@ -15,20 +15,17 @@
+ #include "nsProxyRelease.h"
+ 
+ #include "WorkerRunnable.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+ class Promise;
+-
+-namespace workers {
+ class WorkerPrivate;
+-} // namespace workers
+ 
+ // A proxy to (eventually) mirror a resolved/rejected Promise's result from the
+ // main thread to a Promise on the worker thread.
+ //
+ // How to use:
+ //
+ //   1. Create a Promise on the worker thread and return it to the content
+ //      script:
+@@ -129,24 +126,24 @@ public:
+ 
+   struct PromiseWorkerProxyStructuredCloneCallbacks
+   {
+     ReadCallbackOp Read;
+     WriteCallbackOp Write;
+   };
+ 
+   static already_AddRefed<PromiseWorkerProxy>
+-  Create(workers::WorkerPrivate* aWorkerPrivate,
++  Create(WorkerPrivate* aWorkerPrivate,
+          Promise* aWorkerPromise,
+          const PromiseWorkerProxyStructuredCloneCallbacks* aCallbacks = nullptr);
+ 
+   // Main thread callers must hold Lock() and check CleanUp() before calling this.
+   // Worker thread callers, this will assert that the proxy has not been cleaned
+   // up.
+-  workers::WorkerPrivate* GetWorkerPrivate() const;
++  WorkerPrivate* GetWorkerPrivate() const;
+ 
+   // This should only be used within WorkerRunnable::WorkerRun() running on the
+   // worker thread! Do not call this after calling CleanUp().
+   Promise* WorkerPromise() const;
+ 
+   // Worker thread only. Calling this invalidates several assumptions, so be
+   // sure this is the last thing you do.
+   // 1. WorkerPrivate() will no longer return a valid worker.
+@@ -178,17 +175,17 @@ public:
+ protected:
+   virtual void ResolvedCallback(JSContext* aCx,
+                                 JS::Handle<JS::Value> aValue) override;
+ 
+   virtual void RejectedCallback(JSContext* aCx,
+                                 JS::Handle<JS::Value> aValue) override;
+ 
+ private:
+-  PromiseWorkerProxy(workers::WorkerPrivate* aWorkerPrivate,
++  PromiseWorkerProxy(WorkerPrivate* aWorkerPrivate,
+                      Promise* aWorkerPromise,
+                      const PromiseWorkerProxyStructuredCloneCallbacks* aCallbacks = nullptr);
+ 
+   virtual ~PromiseWorkerProxy();
+ 
+   bool AddRefObject();
+ 
+   // If not called from Create(), be sure to hold Lock().
+@@ -198,17 +195,17 @@ private:
+   typedef void (Promise::*RunCallbackFunc)(JSContext*,
+                                            JS::Handle<JS::Value>);
+ 
+   void RunCallback(JSContext* aCx,
+                    JS::Handle<JS::Value> aValue,
+                    RunCallbackFunc aFunc);
+ 
+   // Any thread with appropriate checks.
+-  workers::WorkerPrivate* mWorkerPrivate;
++  WorkerPrivate* mWorkerPrivate;
+ 
+   // Worker thread only.
+   RefPtr<Promise> mWorkerPromise;
+ 
+   // Modified on the worker thread.
+   // It is ok to *read* this without a lock on the worker.
+   // Main thread must always acquire a lock.
+   bool mCleanedUp; // To specify if the cleanUp() has been done.
+diff --git a/dom/push/PushManager.cpp b/dom/push/PushManager.cpp
+--- a/dom/push/PushManager.cpp
++++ b/dom/push/PushManager.cpp
+@@ -28,17 +28,17 @@
+ 
+ #include "WorkerRunnable.h"
+ #include "WorkerPrivate.h"
+ #include "WorkerScope.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+-using namespace workers;
++using workers::AssertIsOnMainThread;
+ 
+ namespace {
+ 
+ nsresult
+ GetPermissionState(nsIPrincipal* aPrincipal,
+                    PushPermissionState& aState)
+ {
+   nsCOMPtr<nsIPermissionManager> permManager =
+diff --git a/dom/push/PushManager.h b/dom/push/PushManager.h
+--- a/dom/push/PushManager.h
++++ b/dom/push/PushManager.h
+@@ -38,24 +38,21 @@
+ #include "mozilla/RefPtr.h"
+ 
+ class nsIGlobalObject;
+ class nsIPrincipal;
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+-namespace workers {
+-class WorkerPrivate;
+-}
+-
+ class OwningArrayBufferViewOrArrayBufferOrString;
+ class Promise;
+ class PushManagerImpl;
+ struct PushSubscriptionOptionsInit;
++class WorkerPrivate;
+ 
+ class PushManager final : public nsISupports
+                         , public nsWrapperCache
+ {
+ public:
+   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
+   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(PushManager)
+ 
+diff --git a/dom/push/PushSubscription.cpp b/dom/push/PushSubscription.cpp
+--- a/dom/push/PushSubscription.cpp
++++ b/dom/push/PushSubscription.cpp
+@@ -18,18 +18,16 @@
+ #include "mozilla/dom/PushUtil.h"
+ #include "mozilla/dom/WorkerPrivate.h"
+ #include "mozilla/dom/WorkerScope.h"
+ #include "mozilla/dom/workers/WorkerCommon.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+-using namespace workers;
+-
+ namespace {
+ 
+ class UnsubscribeResultCallback final : public nsIUnsubscribeResultCallback
+ {
+ public:
+   NS_DECL_ISUPPORTS
+ 
+   explicit UnsubscribeResultCallback(Promise* aPromise)
+diff --git a/dom/push/PushSubscription.h b/dom/push/PushSubscription.h
+--- a/dom/push/PushSubscription.h
++++ b/dom/push/PushSubscription.h
+@@ -21,20 +21,16 @@
+ #include "mozilla/dom/PushSubscriptionOptionsBinding.h"
+ #include "mozilla/dom/TypedArray.h"
+ 
+ class nsIGlobalObject;
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+-namespace workers {
+-class WorkerPrivate;
+-}
+-
+ class Promise;
+ 
+ class PushSubscription final : public nsISupports
+                              , public nsWrapperCache
+ {
+ public:
+   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
+   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(PushSubscription)
+diff --git a/dom/script/ScriptSettings.cpp b/dom/script/ScriptSettings.cpp
+--- a/dom/script/ScriptSettings.cpp
++++ b/dom/script/ScriptSettings.cpp
+@@ -539,17 +539,17 @@ WarningOnlyErrorReporter(JSContext* aCx,
+   if (!NS_IsMainThread()) {
+     // Reporting a warning on workers is a bit complicated because we have to
+     // climb our parent chain until we get to the main thread.  So go ahead and
+     // just go through the worker ReportError codepath here.
+     //
+     // That said, it feels like we should be able to short-circuit things a bit
+     // here by posting an appropriate runnable to the main thread directly...
+     // Worth looking into sometime.
+-    workers::WorkerPrivate* worker = workers::GetWorkerPrivateFromContext(aCx);
++    WorkerPrivate* worker = GetWorkerPrivateFromContext(aCx);
+     MOZ_ASSERT(worker);
+ 
+     worker->ReportError(aCx, JS::ConstUTF8CharsZ(), aRep);
+     return;
+   }
+ 
+   RefPtr<xpc::ErrorReport> xpcReport = new xpc::ErrorReport();
+   nsGlobalWindow* win = xpc::CurrentWindowOrNull(aCx);
+@@ -576,17 +576,17 @@ AutoJSAPI::ReportException()
+   // requires us to be in a compartment when we fetch the pending exception.
+   // In this case, we enter the privileged junk scope and don't dispatch any
+   // error events.
+   JS::Rooted<JSObject*> errorGlobal(cx(), JS::CurrentGlobalOrNull(cx()));
+   if (!errorGlobal) {
+     if (mIsMainThread) {
+       errorGlobal = xpc::PrivilegedJunkScope();
+     } else {
+-      errorGlobal = workers::GetCurrentThreadWorkerGlobal();
++      errorGlobal = GetCurrentThreadWorkerGlobal();
+     }
+   }
+   JSAutoCompartment ac(cx(), errorGlobal);
+   JS::Rooted<JS::Value> exn(cx());
+   js::ErrorReport jsReport(cx());
+   if (StealException(&exn) &&
+       jsReport.init(cx(), exn, js::ErrorReport::WithSideEffects)) {
+     if (mIsMainThread) {
+@@ -612,17 +612,17 @@ AutoJSAPI::ReportException()
+           xpc::FindExceptionStackForConsoleReport(inner, exn));
+         xpcReport->LogToConsoleWithStack(stack);
+       }
+     } else {
+       // On a worker, we just use the worker error reporting mechanism and don't
+       // bother with xpc::ErrorReport.  This will ensure that all the right
+       // events (which are a lot more complicated than in the window case) get
+       // fired.
+-      workers::WorkerPrivate* worker = workers::GetCurrentThreadWorkerPrivate();
++      WorkerPrivate* worker = GetCurrentThreadWorkerPrivate();
+       MOZ_ASSERT(worker);
+       MOZ_ASSERT(worker->GetJSContext() == cx());
+       // Before invoking ReportError, put the exception back on the context,
+       // because it may want to put it in its error events and has no other way
+       // to get hold of it.  After we invoke ReportError, clear the exception on
+       // cx(), just in case ReportError didn't.
+       JS_SetPendingException(cx(), exn);
+       worker->ReportError(cx(), jsReport.toStringResult(), jsReport.report());
+diff --git a/dom/serviceworkers/ServiceWorkerPrivate.h b/dom/serviceworkers/ServiceWorkerPrivate.h
+--- a/dom/serviceworkers/ServiceWorkerPrivate.h
++++ b/dom/serviceworkers/ServiceWorkerPrivate.h
+@@ -206,17 +206,17 @@ private:
+   // The info object owns us. It is possible to outlive it for a brief period
+   // of time if there are pending waitUntil promises, in which case it
+   // will be null and |SpawnWorkerIfNeeded| will always fail.
+   ServiceWorkerInfo* MOZ_NON_OWNING_REF mInfo;
+ 
+   // The WorkerPrivate object can only be closed by this class or by the
+   // RuntimeService class if gecko is shutting down. Closing the worker
+   // multiple times is OK, since the second attempt will be a no-op.
+-  RefPtr<workers::WorkerPrivate> mWorkerPrivate;
++  RefPtr<WorkerPrivate> mWorkerPrivate;
+ 
+   nsCOMPtr<nsITimer> mIdleWorkerTimer;
+ 
+   // We keep a token for |dom.serviceWorkers.idle_timeout| seconds to give the
+   // worker a grace period after each event.
+   RefPtr<KeepAliveToken> mIdleKeepAliveToken;
+ 
+   uint64_t mDebuggerCount;
+diff --git a/dom/serviceworkers/ServiceWorkerRegistration.h b/dom/serviceworkers/ServiceWorkerRegistration.h
+--- a/dom/serviceworkers/ServiceWorkerRegistration.h
++++ b/dom/serviceworkers/ServiceWorkerRegistration.h
+@@ -56,17 +56,17 @@ public:
+ 
+   IMPL_EVENT_HANDLER(updatefound)
+ 
+   static already_AddRefed<ServiceWorkerRegistration>
+   CreateForMainThread(nsPIDOMWindowInner* aWindow,
+                       const nsAString& aScope);
+ 
+   static already_AddRefed<ServiceWorkerRegistration>
+-  CreateForWorker(workers::WorkerPrivate* aWorkerPrivate,
++  CreateForWorker(WorkerPrivate* aWorkerPrivate,
+                   const nsAString& aScope);
+ 
+   JSObject*
+   WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
+ 
+   virtual already_AddRefed<ServiceWorker>
+   GetInstalling() = 0;
+ 
+diff --git a/dom/url/URLWorker.cpp b/dom/url/URLWorker.cpp
+--- a/dom/url/URLWorker.cpp
++++ b/dom/url/URLWorker.cpp
+@@ -15,17 +15,17 @@
+ #include "nsURLHelper.h"
+ 
+ namespace mozilla {
+ 
+ using net::nsStandardURL;
+ 
+ namespace dom {
+ 
+-using namespace workers;
++using workers::AssertIsOnMainThread;
+ 
+ // Proxy class to forward all the requests to a URLMainThread object.
+ class URLWorker::URLProxy final
+ {
+ public:
+   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(URLProxy)
+ 
+   explicit URLProxy(already_AddRefed<URLMainThread> aURL)
+diff --git a/dom/url/URLWorker.h b/dom/url/URLWorker.h
+--- a/dom/url/URLWorker.h
++++ b/dom/url/URLWorker.h
+@@ -13,19 +13,17 @@
+ namespace mozilla {
+ 
+ namespace net {
+ class nsStandardURL;
+ }
+ 
+ namespace dom {
+ 
+-namespace workers {
+ class WorkerPrivate;
+-}
+ 
+ // URLWorker implements the URL object in workers.
+ class URLWorker final : public URL
+ {
+ public:
+   class URLProxy;
+ 
+   static already_AddRefed<URLWorker>
+@@ -43,17 +41,17 @@ public:
+   static void
+   RevokeObjectURL(const GlobalObject& aGlobal, const nsAString& aUrl,
+                   ErrorResult& aRv);
+ 
+   static bool
+   IsValidURL(const GlobalObject& aGlobal, const nsAString& aUrl,
+              ErrorResult& aRv);
+ 
+-  explicit URLWorker(workers::WorkerPrivate* aWorkerPrivate);
++  explicit URLWorker(WorkerPrivate* aWorkerPrivate);
+ 
+   void
+   Init(const nsAString& aURL, const Optional<nsAString>& aBase,
+        ErrorResult& aRv);
+ 
+   virtual void
+   GetHref(nsAString& aHref, ErrorResult& aRv) const override;
+ 
+@@ -117,17 +115,17 @@ public:
+   virtual void UpdateURLSearchParams() override;
+ 
+   virtual void
+   SetSearchInternal(const nsAString& aSearch, ErrorResult& aRv) override;
+ 
+ private:
+   ~URLWorker();
+ 
+-  workers::WorkerPrivate* mWorkerPrivate;
++  WorkerPrivate* mWorkerPrivate;
+   RefPtr<URLProxy> mURLProxy;
+   RefPtr<net::nsStandardURL> mStdURL;
+ };
+ 
+ } // namespace dom
+ } // namespace mozilla
+ 
+ #endif // mozilla_dom_URLWorker_h
+diff --git a/dom/webidl/Worker.webidl b/dom/webidl/Worker.webidl
+--- a/dom/webidl/Worker.webidl
++++ b/dom/webidl/Worker.webidl
+@@ -8,17 +8,17 @@
+  *
+  * © Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and Opera
+  * Software ASA.
+  * You are granted a license to use, reproduce and create derivative works of
+  * this document.
+  */
+ 
+ [Constructor(USVString scriptURL, optional WorkerOptions options),
+- Func="mozilla::dom::workers::WorkerPrivate::WorkerAvailable",
++ Func="mozilla::dom::WorkerPrivate::WorkerAvailable",
+  Exposed=(Window,DedicatedWorker,SharedWorker,System)]
+ interface Worker : EventTarget {
+   void terminate();
+ 
+   [Throws]
+   void postMessage(any message, optional sequence<object> transfer = []);
+ 
+   attribute EventHandler onmessage;
+@@ -29,12 +29,12 @@ Worker implements AbstractWorker;
+ 
+ dictionary WorkerOptions {
+   // WorkerType type = "classic"; TODO: Bug 1247687
+   // RequestCredentials credentials = "omit"; // credentials is only used if type is "module" TODO: Bug 1247687
+   DOMString name = "";
+ };
+ 
+ [Constructor(USVString scriptURL),
+- Func="mozilla::dom::workers::ChromeWorkerPrivate::WorkerAvailable",
++ Func="mozilla::dom::ChromeWorkerPrivate::WorkerAvailable",
+  Exposed=(Window,DedicatedWorker,SharedWorker,System)]
+ interface ChromeWorker : Worker {
+ };
+diff --git a/dom/workers/MessageEventRunnable.cpp b/dom/workers/MessageEventRunnable.cpp
+--- a/dom/workers/MessageEventRunnable.cpp
++++ b/dom/workers/MessageEventRunnable.cpp
+@@ -12,18 +12,16 @@
+ #include "mozilla/WorkerTimelineMarker.h"
+ #include "nsQueryObject.h"
+ #include "WorkerPrivate.h"
+ #include "WorkerScope.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+-using namespace workers;
+-
+ MessageEventRunnable::MessageEventRunnable(WorkerPrivate* aWorkerPrivate,
+                                            TargetAndBusyBehavior aBehavior)
+   : WorkerRunnable(aWorkerPrivate, aBehavior)
+   , StructuredCloneHolder(CloningSupported, TransferringSupported,
+                           StructuredCloneScope::SameProcessDifferentThread)
+ {
+ }
+ 
+diff --git a/dom/workers/MessageEventRunnable.h b/dom/workers/MessageEventRunnable.h
+--- a/dom/workers/MessageEventRunnable.h
++++ b/dom/workers/MessageEventRunnable.h
+@@ -16,26 +16,26 @@ namespace mozilla {
+ class DOMEventTargetHelper;
+ 
+ namespace dom {
+ 
+ class MessageEventRunnable final : public WorkerRunnable
+                                  , public StructuredCloneHolder
+ {
+ public:
+-  MessageEventRunnable(workers::WorkerPrivate* aWorkerPrivate,
++  MessageEventRunnable(WorkerPrivate* aWorkerPrivate,
+                        TargetAndBusyBehavior aBehavior);
+ 
+   bool
+-  DispatchDOMEvent(JSContext* aCx, workers::WorkerPrivate* aWorkerPrivate,
++  DispatchDOMEvent(JSContext* aCx, WorkerPrivate* aWorkerPrivate,
+                    DOMEventTargetHelper* aTarget, bool aIsMainThread);
+ 
+ private:
+   bool
+-  WorkerRun(JSContext* aCx, workers::WorkerPrivate* aWorkerPrivate) override;
++  WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate) override;
+ 
+   void
+   DispatchError(JSContext* aCx, DOMEventTargetHelper* aTarget);
+ };
+ 
+ } // dom namespace
+ } // mozilla namespace
+ 
+diff --git a/dom/workers/Principal.cpp b/dom/workers/Principal.cpp
+--- a/dom/workers/Principal.cpp
++++ b/dom/workers/Principal.cpp
+@@ -31,17 +31,17 @@ GetWorkerPrincipal()
+    * the first time, decrement it again. This avoids the need for
+    * synchronization.
+    */
+   int32_t prevRefcount = sPrincipal.refcount++;
+   if (prevRefcount > 0) {
+     --sPrincipal.refcount;
+   } else {
+ #ifdef DEBUG
+-    sPrincipal.debugToken = kJSPrincipalsDebugToken;
++    sPrincipal.debugToken = workers::kJSPrincipalsDebugToken;
+ #endif
+   }
+ 
+   return &sPrincipal;
+ }
+ 
+ void
+ DestroyWorkerPrincipals(JSPrincipals* aPrincipals)
+diff --git a/dom/workers/Queue.h b/dom/workers/Queue.h
+--- a/dom/workers/Queue.h
++++ b/dom/workers/Queue.h
+@@ -2,17 +2,17 @@
+ /* vim: set ts=8 sts=2 et sw=2 tw=80: */
+ /* 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/. */
+ 
+ #ifndef mozilla_dom_workers_queue_h__
+ #define mozilla_dom_workers_queue_h__
+ 
+-#include "WorkerCommon.h"
++#include "mozilla/dom/workers/WorkerCommon.h"
+ 
+ #include "mozilla/Mutex.h"
+ #include "nsTArray.h"
+ 
+ BEGIN_WORKERS_NAMESPACE
+ 
+ template <typename T, int TCount>
+ struct StorageWithTArray
+diff --git a/dom/workers/RuntimeService.cpp b/dom/workers/RuntimeService.cpp
+--- a/dom/workers/RuntimeService.cpp
++++ b/dom/workers/RuntimeService.cpp
+@@ -1308,16 +1308,21 @@ ResumeWorkersForWindow(nsPIDOMWindowInne
+ {
+   AssertIsOnMainThread();
+   RuntimeService* runtime = RuntimeService::GetService();
+   if (runtime) {
+     runtime->ResumeWorkersForWindow(aWindow);
+   }
+ }
+ 
++END_WORKERS_NAMESPACE
++
++namespace mozilla {
++namespace dom {
++
+ WorkerPrivate*
+ GetWorkerPrivateFromContext(JSContext* aCx)
+ {
+   MOZ_ASSERT(!NS_IsMainThread());
+   MOZ_ASSERT(aCx);
+ 
+   void* cxPrivate = JS_GetContextPrivate(aCx);
+   if (!cxPrivate) {
+@@ -1373,17 +1378,18 @@ GetCurrentThreadWorkerGlobal()
+   }
+   WorkerGlobalScope* scope = wp->GlobalScope();
+   if (!scope) {
+     return nullptr;
+   }
+   return scope->GetGlobalJSObject();
+ }
+ 
+-END_WORKERS_NAMESPACE
++} // dom namespace
++} // mozilla namespace
+ 
+ struct RuntimeService::IdleThreadInfo
+ {
+   RefPtr<WorkerThread> mThread;
+   mozilla::TimeStamp mExpirationTime;
+ };
+ 
+ // This is only touched on the main thread. Initialized in Init() below.
+diff --git a/dom/workers/ScriptLoader.cpp b/dom/workers/ScriptLoader.cpp
+--- a/dom/workers/ScriptLoader.cpp
++++ b/dom/workers/ScriptLoader.cpp
+@@ -77,18 +77,16 @@ USING_WORKERS_NAMESPACE
+ 
+ using mozilla::dom::cache::Cache;
+ using mozilla::dom::cache::CacheStorage;
+ using mozilla::ipc::PrincipalInfo;
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+-using namespace workers;
+-
+ namespace {
+ 
+ nsIURI*
+ GetBaseURI(bool aIsMainScript, WorkerPrivate* aWorkerPrivate)
+ {
+   MOZ_ASSERT(aWorkerPrivate);
+   nsIURI* baseURI;
+   WorkerPrivate* parentWorker = aWorkerPrivate->GetParent();
+diff --git a/dom/workers/ScriptLoader.h b/dom/workers/ScriptLoader.h
+--- a/dom/workers/ScriptLoader.h
++++ b/dom/workers/ScriptLoader.h
+@@ -18,21 +18,18 @@ class nsILoadGroup;
+ class nsIChannel;
+ 
+ namespace mozilla {
+ 
+ class ErrorResult;
+ 
+ namespace dom {
+ 
+-namespace workers {
++struct WorkerLoadInfo;
+ class WorkerPrivate;
+-}
+-
+-struct WorkerLoadInfo;
+ 
+ enum WorkerScriptType {
+   WorkerScript,
+   DebuggerScript
+ };
+ 
+ namespace workerinternals {
+ 
+@@ -44,29 +41,29 @@ ChannelFromScriptURLMainThread(nsIPrinci
+                                const nsAString& aScriptURL,
+                                const Maybe<ClientInfo>& aClientInfo,
+                                nsContentPolicyType aContentPolicyType,
+                                bool aDefaultURIEncoding,
+                                nsIChannel** aChannel);
+ 
+ nsresult
+ ChannelFromScriptURLWorkerThread(JSContext* aCx,
+-                                 workers::WorkerPrivate* aParent,
++                                 WorkerPrivate* aParent,
+                                  const nsAString& aScriptURL,
+                                  WorkerLoadInfo& aLoadInfo);
+ 
+ void ReportLoadError(ErrorResult& aRv, nsresult aLoadResult,
+                      const nsAString& aScriptURL);
+ 
+-void LoadMainScript(workers::WorkerPrivate* aWorkerPrivate,
++void LoadMainScript(WorkerPrivate* aWorkerPrivate,
+                     const nsAString& aScriptURL,
+                     WorkerScriptType aWorkerScriptType,
+                     ErrorResult& aRv);
+ 
+-void Load(workers::WorkerPrivate* aWorkerPrivate,
++void Load(WorkerPrivate* aWorkerPrivate,
+           const nsTArray<nsString>& aScriptURLs,
+           WorkerScriptType aWorkerScriptType,
+           ErrorResult& aRv);
+ 
+ } // namespace workerinternals
+ 
+ } // dom namespace
+ } // namespace mozilla
+diff --git a/dom/workers/SharedWorker.cpp b/dom/workers/SharedWorker.cpp
+--- a/dom/workers/SharedWorker.cpp
++++ b/dom/workers/SharedWorker.cpp
+@@ -25,17 +25,16 @@
+ #undef PostMessage
+ #endif
+ 
+ using mozilla::dom::Optional;
+ using mozilla::dom::Sequence;
+ using mozilla::dom::MessagePort;
+ using namespace mozilla;
+ using namespace mozilla::dom;
+-using namespace mozilla::dom::workers;
+ 
+ SharedWorker::SharedWorker(nsPIDOMWindowInner* aWindow,
+                            WorkerPrivate* aWorkerPrivate,
+                            MessagePort* aMessagePort)
+   : DOMEventTargetHelper(aWindow)
+   , mWorkerPrivate(aWorkerPrivate)
+   , mMessagePort(aMessagePort)
+   , mFrozen(false)
+diff --git a/dom/workers/SharedWorker.h b/dom/workers/SharedWorker.h
+--- a/dom/workers/SharedWorker.h
++++ b/dom/workers/SharedWorker.h
+@@ -20,30 +20,30 @@ class nsIDOMEvent;
+ class nsPIDOMWindowInner;
+ 
+ namespace mozilla {
+ class EventChainPreVisitor;
+ 
+ namespace dom {
+ class MessagePort;
+ class StringOrWorkerOptions;
++class WorkerPrivate;
+ 
+ namespace workers {
+ class RuntimeService;
+-class WorkerPrivate;
+ }
+ 
+ class SharedWorker final : public DOMEventTargetHelper
+ {
+   friend class workers::RuntimeService;
+ 
+   typedef mozilla::ErrorResult ErrorResult;
+   typedef mozilla::dom::GlobalObject GlobalObject;
+ 
+-  RefPtr<workers::WorkerPrivate> mWorkerPrivate;
++  RefPtr<WorkerPrivate> mWorkerPrivate;
+   RefPtr<MessagePort> mMessagePort;
+   nsTArray<nsCOMPtr<nsIDOMEvent>> mFrozenEvents;
+   bool mFrozen;
+ 
+ public:
+   static already_AddRefed<SharedWorker>
+   Constructor(const GlobalObject& aGlobal, const nsAString& aScriptURL,
+               const StringOrWorkerOptions& aOptions, ErrorResult& aRv);
+@@ -75,26 +75,26 @@ public:
+   IMPL_EVENT_HANDLER(error)
+ 
+   virtual JSObject*
+   WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
+ 
+   virtual nsresult
+   GetEventTargetParent(EventChainPreVisitor& aVisitor) override;
+ 
+-  workers::WorkerPrivate*
++  WorkerPrivate*
+   GetWorkerPrivate() const
+   {
+     return mWorkerPrivate;
+   }
+ 
+ private:
+   // This class can only be created from the RuntimeService.
+   SharedWorker(nsPIDOMWindowInner* aWindow,
+-               workers::WorkerPrivate* aWorkerPrivate,
++               WorkerPrivate* aWorkerPrivate,
+                MessagePort* aMessagePort);
+ 
+   // This class is reference-counted and will be destroyed from Release().
+   ~SharedWorker();
+ 
+   // Only called by MessagePort.
+   void
+   PostMessage(JSContext* aCx, JS::Handle<JS::Value> aMessage,
+diff --git a/dom/workers/WorkerCommon.h b/dom/workers/WorkerCommon.h
+--- a/dom/workers/WorkerCommon.h
++++ b/dom/workers/WorkerCommon.h
+@@ -35,23 +35,23 @@ namespace dom {
+ // be updated too.
+ enum WorkerType
+ {
+   WorkerTypeDedicated,
+   WorkerTypeShared,
+   WorkerTypeService
+ };
+ 
++class WorkerPrivate;
++
+ } // namespace dom
+ } // namespace mozilla
+ 
+ BEGIN_WORKERS_NAMESPACE
+ 
+-class WorkerPrivate;
+-
+ struct PrivatizableBase
+ { };
+ 
+ #ifdef DEBUG
+ void
+ AssertIsOnMainThread();
+ #else
+ inline void
+diff --git a/dom/workers/WorkerDebugger.cpp b/dom/workers/WorkerDebugger.cpp
+--- a/dom/workers/WorkerDebugger.cpp
++++ b/dom/workers/WorkerDebugger.cpp
+@@ -16,18 +16,16 @@
+ #include "WorkerError.h"
+ #include "WorkerPrivate.h"
+ #include "WorkerRunnable.h"
+ #include "WorkerScope.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+-using namespace workers;
+-
+ namespace {
+ 
+ class DebuggerMessageEventRunnable : public WorkerDebuggerRunnable
+ {
+   nsString mMessage;
+ 
+ public:
+   DebuggerMessageEventRunnable(WorkerPrivate* aWorkerPrivate,
+diff --git a/dom/workers/WorkerDebugger.h b/dom/workers/WorkerDebugger.h
+--- a/dom/workers/WorkerDebugger.h
++++ b/dom/workers/WorkerDebugger.h
+@@ -8,31 +8,29 @@
+ #define mozilla_dom_workers_WorkerDebugger_h
+ 
+ #include "mozilla/dom/workers/WorkerCommon.h"
+ #include "nsIWorkerDebugger.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+-namespace workers {
+ class WorkerPrivate;
+-}
+ 
+ class WorkerDebugger : public nsIWorkerDebugger
+ {
+   class ReportDebuggerErrorRunnable;
+   class PostDebuggerMessageRunnable;
+ 
+-  workers::WorkerPrivate* mWorkerPrivate;
++  WorkerPrivate* mWorkerPrivate;
+   bool mIsInitialized;
+   nsTArray<nsCOMPtr<nsIWorkerDebuggerListener>> mListeners;
+ 
+ public:
+-  explicit WorkerDebugger(workers::WorkerPrivate* aWorkerPrivate);
++  explicit WorkerDebugger(WorkerPrivate* aWorkerPrivate);
+ 
+   NS_DECL_ISUPPORTS
+   NS_DECL_NSIWORKERDEBUGGER
+ 
+   void
+   AssertIsOnParentThread();
+ 
+   void
+diff --git a/dom/workers/WorkerDebuggerManager.cpp b/dom/workers/WorkerDebuggerManager.cpp
+--- a/dom/workers/WorkerDebuggerManager.cpp
++++ b/dom/workers/WorkerDebuggerManager.cpp
+@@ -12,18 +12,16 @@
+ #include "mozilla/StaticPtr.h"
+ 
+ #include "WorkerDebugger.h"
+ #include "WorkerPrivate.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+-using namespace workers;
+-
+ namespace {
+ 
+ class RegisterDebuggerMainThreadRunnable final : public mozilla::Runnable
+ {
+   WorkerPrivate* mWorkerPrivate;
+   bool mNotifyListeners;
+ 
+ public:
+diff --git a/dom/workers/WorkerDebuggerManager.h b/dom/workers/WorkerDebuggerManager.h
+--- a/dom/workers/WorkerDebuggerManager.h
++++ b/dom/workers/WorkerDebuggerManager.h
+@@ -20,21 +20,18 @@
+   { 0x62ec8731, 0x55ad, 0x4246, \
+     { 0xb2, 0xea, 0xf2, 0x6c, 0x1f, 0xe1, 0x9d, 0x2d } }
+ #define WORKERDEBUGGERMANAGER_CONTRACTID \
+   "@mozilla.org/dom/workers/workerdebuggermanager;1"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+-namespace workers {
++class WorkerDebugger;
+ class WorkerPrivate;
+-}
+-
+-class WorkerDebugger;
+ 
+ class WorkerDebuggerManager final : public nsIObserver,
+                                     public nsIWorkerDebuggerManager
+ {
+   Mutex mMutex;
+ 
+   // Protected by mMutex.
+   nsTArray<nsCOMPtr<nsIWorkerDebuggerManagerListener>> mListeners;
+@@ -60,34 +57,34 @@ public:
+ 
+   nsresult
+   Init();
+ 
+   void
+   Shutdown();
+ 
+   void
+-  RegisterDebugger(workers::WorkerPrivate* aWorkerPrivate);
++  RegisterDebugger(WorkerPrivate* aWorkerPrivate);
+ 
+   void
+-  RegisterDebuggerMainThread(workers::WorkerPrivate* aWorkerPrivate,
++  RegisterDebuggerMainThread(WorkerPrivate* aWorkerPrivate,
+                              bool aNotifyListeners);
+ 
+   void
+-  UnregisterDebugger(workers::WorkerPrivate* aWorkerPrivate);
++  UnregisterDebugger(WorkerPrivate* aWorkerPrivate);
+ 
+   void
+-  UnregisterDebuggerMainThread(workers::WorkerPrivate* aWorkerPrivate);
++  UnregisterDebuggerMainThread(WorkerPrivate* aWorkerPrivate);
+ 
+ private:
+   virtual ~WorkerDebuggerManager();
+ };
+ 
+ inline nsresult
+-RegisterWorkerDebugger(workers::WorkerPrivate* aWorkerPrivate)
++RegisterWorkerDebugger(WorkerPrivate* aWorkerPrivate)
+ {
+   WorkerDebuggerManager* manager;
+ 
+   if (NS_IsMainThread()) {
+     manager = WorkerDebuggerManager::GetOrCreate();
+     if (!manager) {
+       NS_WARNING("Failed to create worker debugger manager!");
+       return NS_ERROR_FAILURE;
+@@ -97,17 +94,17 @@ RegisterWorkerDebugger(workers::WorkerPr
+     manager = WorkerDebuggerManager::Get();
+   }
+ 
+   manager->RegisterDebugger(aWorkerPrivate);
+   return NS_OK;
+ }
+ 
+ inline nsresult
+-UnregisterWorkerDebugger(workers::WorkerPrivate* aWorkerPrivate)
++UnregisterWorkerDebugger(WorkerPrivate* aWorkerPrivate)
+ {
+   WorkerDebuggerManager* manager;
+ 
+   if (NS_IsMainThread()) {
+     manager = WorkerDebuggerManager::GetOrCreate();
+     if (!manager) {
+       NS_WARNING("Failed to create worker debugger manager!");
+       return NS_ERROR_FAILURE;
+diff --git a/dom/workers/WorkerError.cpp b/dom/workers/WorkerError.cpp
+--- a/dom/workers/WorkerError.cpp
++++ b/dom/workers/WorkerError.cpp
+@@ -18,18 +18,16 @@
+ #include "nsScriptError.h"
+ #include "WorkerRunnable.h"
+ #include "WorkerPrivate.h"
+ #include "WorkerScope.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+-using namespace workers;
+-
+ namespace {
+ 
+ class ReportErrorRunnable final : public WorkerRunnable
+ {
+   WorkerErrorReport mReport;
+ 
+ public:
+   // aWorkerPrivate is the worker thread we're on (or the main thread, if null)
+diff --git a/dom/workers/WorkerError.h b/dom/workers/WorkerError.h
+--- a/dom/workers/WorkerError.h
++++ b/dom/workers/WorkerError.h
+@@ -35,19 +35,17 @@ public:
+ };
+ 
+ class WorkerErrorNote : public WorkerErrorBase
+ {
+ public:
+   void AssignErrorNote(JSErrorNotes::Note* aNote);
+ };
+ 
+-namespace workers {
+ class WorkerPrivate;
+-}
+ 
+ class WorkerErrorReport : public WorkerErrorBase
+ {
+ public:
+   nsString mLine;
+   uint32_t mFlags;
+   JSExnType mExnType;
+   bool mMutedError;
+@@ -60,17 +58,17 @@ public:
+   { }
+ 
+   void AssignErrorReport(JSErrorReport* aReport);
+ 
+   // aWorkerPrivate is the worker thread we're on (or the main thread, if null)
+   // aTarget is the worker object that we are going to fire an error at
+   // (if any).
+   static void
+-  ReportError(JSContext* aCx, workers::WorkerPrivate* aWorkerPrivate,
++  ReportError(JSContext* aCx, WorkerPrivate* aWorkerPrivate,
+               bool aFireAtScope, DOMEventTargetHelper* aTarget,
+               const WorkerErrorReport& aReport, uint64_t aInnerWindowId,
+               JS::Handle<JS::Value> aException = JS::NullHandleValue);
+ 
+   static void
+   LogErrorToConsole(const WorkerErrorReport& aReport, uint64_t aInnerWindowId);
+ 
+ };
+diff --git a/dom/workers/WorkerEventTarget.cpp b/dom/workers/WorkerEventTarget.cpp
+--- a/dom/workers/WorkerEventTarget.cpp
++++ b/dom/workers/WorkerEventTarget.cpp
+@@ -4,18 +4,16 @@
+  * 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 "WorkerEventTarget.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+-using namespace workers;
+-
+ namespace {
+ 
+ class WrappedControlRunnable final : public WorkerControlRunnable
+ {
+   nsCOMPtr<nsIRunnable> mInner;
+ 
+   ~WrappedControlRunnable()
+   {
+diff --git a/dom/workers/WorkerEventTarget.h b/dom/workers/WorkerEventTarget.h
+--- a/dom/workers/WorkerEventTarget.h
++++ b/dom/workers/WorkerEventTarget.h
+@@ -8,19 +8,17 @@
+ #define mozilla_dom_WorkerEventTarget_h
+ 
+ #include "nsISerialEventTarget.h"
+ #include "mozilla/Mutex.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+-namespace workers {
+ class WorkerPrivate;
+-}
+ 
+ class WorkerEventTarget final : public nsISerialEventTarget
+ {
+ public:
+   // The WorkerEventTarget supports different dispatch behaviors:
+   //
+   // * Hybrid targets will attempt to dispatch as a normal runnable,
+   //   but fallback to a control runnable if that fails.  This is
+@@ -31,27 +29,26 @@ public:
+   // * ControlOnly targets will simply dispatch a control runnable.
+   enum class Behavior : uint8_t {
+     Hybrid,
+     ControlOnly
+   };
+ 
+ private:
+   mozilla::Mutex mMutex;
+-  workers::WorkerPrivate* mWorkerPrivate;
++  WorkerPrivate* mWorkerPrivate;
+   const Behavior mBehavior;
+ 
+   ~WorkerEventTarget() = default;
+ 
+ public:
+-  WorkerEventTarget(workers::WorkerPrivate* aWorkerPrivate,
+-                    Behavior aBehavior);
++  WorkerEventTarget(WorkerPrivate* aWorkerPrivate, Behavior aBehavior);
+ 
+   void
+-  ForgetWorkerPrivate(workers::WorkerPrivate* aWorkerPrivate);
++  ForgetWorkerPrivate(WorkerPrivate* aWorkerPrivate);
+ 
+   NS_DECL_THREADSAFE_ISUPPORTS
+   NS_DECL_NSIEVENTTARGET
+   NS_DECL_NSISERIALEVENTTARGET
+ };
+ 
+ } // dom namespace
+ } // mozilla namespace
+diff --git a/dom/workers/WorkerHolder.h b/dom/workers/WorkerHolder.h
+--- a/dom/workers/WorkerHolder.h
++++ b/dom/workers/WorkerHolder.h
+@@ -7,19 +7,17 @@
+ #ifndef mozilla_dom_workers_WorkerHolder_h
+ #define mozilla_dom_workers_WorkerHolder_h
+ 
+ #include "mozilla/dom/workers/WorkerCommon.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+-namespace workers {
+ class WorkerPrivate;
+-}
+ 
+ /**
+  * Use this chart to help figure out behavior during each of the closing
+  * statuses. Details below.
+  *
+  * +==============================================================+
+  * |                       Closing Statuses                       |
+  * +=============+=============+=================+================+
+@@ -81,34 +79,33 @@ public:
+     AllowIdleShutdownStart,
+     PreventIdleShutdownStart,
+   };
+ 
+   explicit WorkerHolder(const char* aName,
+                         Behavior aBehavior = PreventIdleShutdownStart);
+   virtual ~WorkerHolder();
+ 
+-  bool HoldWorker(workers::WorkerPrivate* aWorkerPrivate,
+-                  WorkerStatus aFailStatus);
++  bool HoldWorker(WorkerPrivate* aWorkerPrivate, WorkerStatus aFailStatus);
+   void ReleaseWorker();
+ 
+   virtual bool Notify(WorkerStatus aStatus) = 0;
+ 
+   Behavior GetBehavior() const;
+ 
+   const char*
+   Name() const
+   {
+     return mName;
+   }
+ 
+ protected:
+   void ReleaseWorkerInternal();
+ 
+-  workers::WorkerPrivate* MOZ_NON_OWNING_REF mWorkerPrivate;
++  WorkerPrivate* MOZ_NON_OWNING_REF mWorkerPrivate;
+ 
+ private:
+   void AssertIsOwningThread() const;
+ 
+   const Behavior mBehavior;
+ 
+   // For debugging only.
+   void* mThread;
+diff --git a/dom/workers/WorkerHolderToken.cpp b/dom/workers/WorkerHolderToken.cpp
+--- a/dom/workers/WorkerHolderToken.cpp
++++ b/dom/workers/WorkerHolderToken.cpp
+@@ -6,18 +6,16 @@
+ 
+ #include "WorkerHolderToken.h"
+ 
+ #include "WorkerPrivate.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+-using namespace workers;
+-
+ // static
+ already_AddRefed<WorkerHolderToken>
+ WorkerHolderToken::Create(WorkerPrivate* aWorkerPrivate,
+                           WorkerStatus aShutdownStatus,
+                           Behavior aBehavior)
+ {
+   MOZ_DIAGNOSTIC_ASSERT(aWorkerPrivate);
+   aWorkerPrivate->AssertIsOnWorkerThread();
+diff --git a/dom/workers/WorkerHolderToken.h b/dom/workers/WorkerHolderToken.h
+--- a/dom/workers/WorkerHolderToken.h
++++ b/dom/workers/WorkerHolderToken.h
+@@ -9,19 +9,17 @@
+ 
+ #include "nsISupportsImpl.h"
+ #include "nsTObserverArray.h"
+ #include "WorkerHolder.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+-namespace workers {
+ class WorkerPrivate;
+-}
+ 
+ // This is a ref-counted WorkerHolder implementation.  If you wish
+ // to be notified of worker shutdown beginning, then you can implement
+ // the Listener interface and call AddListener().
+ //
+ // This is purely a convenience class to avoid requiring code to
+ // extend WorkerHolder all the time.
+ class WorkerHolderToken final : public WorkerHolder
+@@ -35,17 +33,17 @@ public:
+     virtual void
+     WorkerShuttingDown() = 0;
+   };
+ 
+   // Attempt to create a WorkerHolderToken().  If the shutdown has already
+   // passed the given shutdown phase or fails for another reason then
+   // nullptr is returned.
+   static already_AddRefed<WorkerHolderToken>
+-  Create(workers::WorkerPrivate* aWorkerPrivate,
++  Create(WorkerPrivate* aWorkerPrivate,
+          WorkerStatus aShutdownStatus,
+          Behavior aBehavior = PreventIdleShutdownStart);
+ 
+   // Add a listener to the token.  Note, this does not hold a strong
+   // reference to the listener.  You must call RemoveListener() before
+   // the listener is destroyed.  This can only be called on the owning
+   // worker thread.
+   void
+@@ -54,17 +52,17 @@ public:
+   // Remove a previously added listener.  This can only be called on the
+   // owning worker thread.
+   void
+   RemoveListener(Listener* aListener);
+ 
+   bool
+   IsShuttingDown() const;
+ 
+-  workers::WorkerPrivate*
++  WorkerPrivate*
+   GetWorkerPrivate() const;
+ 
+ private:
+   WorkerHolderToken(WorkerStatus aShutdownStatus, Behavior aBehavior);
+ 
+   ~WorkerHolderToken();
+ 
+   // WorkerHolder methods
+diff --git a/dom/workers/WorkerLoadInfo.cpp b/dom/workers/WorkerLoadInfo.cpp
+--- a/dom/workers/WorkerLoadInfo.cpp
++++ b/dom/workers/WorkerLoadInfo.cpp
+@@ -19,18 +19,16 @@
+ #include "nsNetUtil.h"
+ 
+ namespace mozilla {
+ 
+ using namespace ipc;
+ 
+ namespace dom {
+ 
+-using namespace workers;
+-
+ namespace {
+ 
+ class MainThreadReleaseRunnable final : public Runnable
+ {
+   nsTArray<nsCOMPtr<nsISupports>> mDoomed;
+   nsCOMPtr<nsILoadGroup> mLoadGroupToCancel;
+ 
+ public:
+diff --git a/dom/workers/WorkerLoadInfo.h b/dom/workers/WorkerLoadInfo.h
+--- a/dom/workers/WorkerLoadInfo.h
++++ b/dom/workers/WorkerLoadInfo.h
+@@ -29,19 +29,17 @@ class nsPIDOMWindowInner;
+ namespace mozilla {
+ 
+ namespace ipc {
+ class PrincipalInfo;
+ } // namespace ipc
+ 
+ namespace dom {
+ 
+-namespace workers {
+ class WorkerPrivate;
+-}
+ 
+ struct WorkerLoadInfo
+ {
+   // All of these should be released in WorkerPrivateParent::ForgetMainThreadObjects.
+   nsCOMPtr<nsIURI> mBaseURI;
+   nsCOMPtr<nsIURI> mResolvedScriptURI;
+ 
+   // This is the principal of the global (parent worker or a window) loading
+@@ -135,19 +133,19 @@ struct WorkerLoadInfo
+   bool
+   PrincipalIsValid() const;
+ 
+   bool
+   PrincipalURIMatchesScriptURL();
+ #endif
+ 
+   bool
+-  ProxyReleaseMainThreadObjects(workers::WorkerPrivate* aWorkerPrivate);
++  ProxyReleaseMainThreadObjects(WorkerPrivate* aWorkerPrivate);
+ 
+   bool
+-  ProxyReleaseMainThreadObjects(workers::WorkerPrivate* aWorkerPrivate,
++  ProxyReleaseMainThreadObjects(WorkerPrivate* aWorkerPrivate,
+                                 nsCOMPtr<nsILoadGroup>& aLoadGroupToCancel);
+ };
+ 
+ } // dom namespace
+ } // mozilla namespace
+ 
+ #endif // mozilla_dom_workers_WorkerLoadInfo_h
+diff --git a/dom/workers/WorkerLocation.cpp b/dom/workers/WorkerLocation.cpp
+--- a/dom/workers/WorkerLocation.cpp
++++ b/dom/workers/WorkerLocation.cpp
+@@ -12,17 +12,17 @@ namespace mozilla {
+ namespace dom {
+ 
+ NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(WorkerLocation)
+ 
+ NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(WorkerLocation, AddRef)
+ NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(WorkerLocation, Release)
+ 
+ /* static */ already_AddRefed<WorkerLocation>
+-WorkerLocation::Create(workers::WorkerPrivate::LocationInfo& aInfo)
++WorkerLocation::Create(WorkerPrivate::LocationInfo& aInfo)
+ {
+   RefPtr<WorkerLocation> location =
+     new WorkerLocation(NS_ConvertUTF8toUTF16(aInfo.mHref),
+                        NS_ConvertUTF8toUTF16(aInfo.mProtocol),
+                        NS_ConvertUTF8toUTF16(aInfo.mHost),
+                        NS_ConvertUTF8toUTF16(aInfo.mHostname),
+                        NS_ConvertUTF8toUTF16(aInfo.mPort),
+                        NS_ConvertUTF8toUTF16(aInfo.mPathname),
+diff --git a/dom/workers/WorkerLocation.h b/dom/workers/WorkerLocation.h
+--- a/dom/workers/WorkerLocation.h
++++ b/dom/workers/WorkerLocation.h
+@@ -54,17 +54,17 @@ class WorkerLocation final : public nsWr
+   }
+ 
+ public:
+ 
+   NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WorkerLocation)
+   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WorkerLocation)
+ 
+   static already_AddRefed<WorkerLocation>
+-  Create(workers::WorkerPrivate::LocationInfo& aInfo);
++  Create(WorkerPrivate::LocationInfo& aInfo);
+ 
+   virtual JSObject*
+   WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
+ 
+   nsISupports* GetParentObject() const {
+     return nullptr;
+   }
+ 
+diff --git a/dom/workers/WorkerNavigator.cpp b/dom/workers/WorkerNavigator.cpp
+--- a/dom/workers/WorkerNavigator.cpp
++++ b/dom/workers/WorkerNavigator.cpp
+@@ -23,18 +23,16 @@
+ #include "WorkerRunnable.h"
+ #include "WorkerScope.h"
+ 
+ #include "mozilla/dom/Navigator.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+-using namespace mozilla::dom::workers;
+-
+ NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(WorkerNavigator, mStorageManager,
+                                       mConnection);
+ 
+ NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(WorkerNavigator, AddRef)
+ NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(WorkerNavigator, Release)
+ 
+ WorkerNavigator::WorkerNavigator(const NavigatorProperties& aProperties,
+                                  bool aOnline)
+diff --git a/dom/workers/WorkerPrivate.cpp b/dom/workers/WorkerPrivate.cpp
+--- a/dom/workers/WorkerPrivate.cpp
++++ b/dom/workers/WorkerPrivate.cpp
+@@ -91,18 +91,16 @@ TimeoutsLog()
+ }
+ 
+ #define LOG(log, _args) MOZ_LOG(log, LogLevel::Debug, _args);
+ 
+ using namespace mozilla;
+ using namespace mozilla::dom;
+ using namespace mozilla::ipc;
+ 
+-USING_WORKERS_NAMESPACE
+-
+ MOZ_DEFINE_MALLOC_SIZE_OF(JsWorkerMallocSizeOf)
+ 
+ #ifdef DEBUG
+ 
+ BEGIN_WORKERS_NAMESPACE
+ 
+ void
+ AssertIsOnMainThread()
+@@ -251,17 +249,17 @@ private:
+ 
+   virtual bool
+   WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate) override
+   {
+     if (!mFinishedWorker->ProxyReleaseMainThreadObjects()) {
+       NS_WARNING("Failed to dispatch, going to leak!");
+     }
+ 
+-    RuntimeService* runtime = RuntimeService::GetService();
++    workers::RuntimeService* runtime = workers::RuntimeService::GetService();
+     NS_ASSERTION(runtime, "This should never be null!");
+ 
+     mFinishedWorker->DisableDebugger();
+ 
+     runtime->UnregisterWorker(mFinishedWorker);
+ 
+     mFinishedWorker->ClearSelfRef();
+     return true;
+@@ -283,19 +281,19 @@ public:
+   NS_DECL_ISUPPORTS_INHERITED
+ 
+ private:
+   ~TopLevelWorkerFinishedRunnable() {}
+ 
+   NS_IMETHOD
+   Run() override
+   {
+-    AssertIsOnMainThread();
+-
+-    RuntimeService* runtime = RuntimeService::GetService();
++    workers::AssertIsOnMainThread();
++
++    workers::RuntimeService* runtime = workers::RuntimeService::GetService();
+     MOZ_ASSERT(runtime);
+ 
+     mFinishedWorker->DisableDebugger();
+ 
+     runtime->UnregisterWorker(mFinishedWorker);
+ 
+     if (!mFinishedWorker->ProxyReleaseMainThreadObjects()) {
+       NS_WARNING("Failed to dispatch, going to leak!");
+@@ -565,17 +563,17 @@ class ReportErrorToConsoleRunnable final
+ public:
+   // aWorkerPrivate is the worker thread we're on (or the main thread, if null)
+   static void
+   Report(WorkerPrivate* aWorkerPrivate, const char* aMessage)
+   {
+     if (aWorkerPrivate) {
+       aWorkerPrivate->AssertIsOnWorkerThread();
+     } else {
+-      AssertIsOnMainThread();
++      workers::AssertIsOnMainThread();
+     }
+ 
+     // Now fire a runnable to do the same on the parent's thread if we can.
+     if (aWorkerPrivate) {
+       RefPtr<ReportErrorToConsoleRunnable> runnable =
+         new ReportErrorToConsoleRunnable(aWorkerPrivate, aMessage);
+       runnable->Dispatch();
+       return;
+@@ -1032,22 +1030,22 @@ private:
+   { }
+ };
+ 
+ struct WorkerPrivate::TimeoutInfo
+ {
+   TimeoutInfo()
+   : mId(0), mIsInterval(false), mCanceled(false)
+   {
+-    MOZ_COUNT_CTOR(mozilla::dom::workers::WorkerPrivate::TimeoutInfo);
++    MOZ_COUNT_CTOR(mozilla::dom::WorkerPrivate::TimeoutInfo);
+   }
+ 
+   ~TimeoutInfo()
+   {
+-    MOZ_COUNT_DTOR(mozilla::dom::workers::WorkerPrivate::TimeoutInfo);
++    MOZ_COUNT_DTOR(mozilla::dom::WorkerPrivate::TimeoutInfo);
+   }
+ 
+   bool operator==(const TimeoutInfo& aOther)
+   {
+     return mTargetTime == aOther.mTargetTime;
+   }
+ 
+   bool operator<(const TimeoutInfo& aOther)
+@@ -1223,17 +1221,17 @@ private:
+     {
+       mSuccess = success;
+     }
+ 
+   private:
+     ~FinishCollectRunnable()
+     {
+       // mHandleReport and mHandlerData are released on the main thread.
+-      AssertIsOnMainThread();
++      workers::AssertIsOnMainThread();
+     }
+ 
+     FinishCollectRunnable(const FinishCollectRunnable&) = delete;
+     FinishCollectRunnable& operator=(const FinishCollectRunnable&) = delete;
+     FinishCollectRunnable& operator=(const FinishCollectRunnable&&) = delete;
+   };
+ 
+   ~MemoryReporter()
+@@ -1257,17 +1255,17 @@ private:
+ 
+ NS_IMPL_ISUPPORTS(WorkerPrivate::MemoryReporter, nsIMemoryReporter)
+ 
+ NS_IMETHODIMP
+ WorkerPrivate::MemoryReporter::CollectReports(nsIHandleReportCallback* aHandleReport,
+                                               nsISupports* aData,
+                                               bool aAnonymize)
+ {
+-  AssertIsOnMainThread();
++  workers::AssertIsOnMainThread();
+ 
+   RefPtr<CollectReportsRunnable> runnable;
+ 
+   {
+     MutexAutoLock lock(mMutex);
+ 
+     if (!mWorkerPrivate) {
+       // This will effectively report 0 memory.
+@@ -1309,17 +1307,17 @@ WorkerPrivate::MemoryReporter::CollectRe
+   }
+ 
+   return NS_OK;
+ }
+ 
+ void
+ WorkerPrivate::MemoryReporter::TryToMapAddon(nsACString &path)
+ {
+-  AssertIsOnMainThread();
++  workers::AssertIsOnMainThread();
+   mMutex.AssertCurrentThreadOwns();
+ 
+   if (mAlreadyMappedToAddon || !mWorkerPrivate) {
+     return;
+   }
+ 
+   nsCOMPtr<nsIURI> scriptURI;
+   if (NS_FAILED(NS_NewURI(getter_AddRefs(scriptURI),
+@@ -1385,31 +1383,30 @@ WorkerPrivate::MemoryReporter::CollectRe
+   return true;
+ }
+ 
+ WorkerPrivate::MemoryReporter::FinishCollectRunnable::FinishCollectRunnable(
+   nsIHandleReportCallback* aHandleReport,
+   nsISupports* aHandlerData,
+   bool aAnonymize,
+   const nsACString& aPath)
+-  : mozilla::Runnable(
+-      "dom::workers::WorkerPrivate::MemoryReporter::FinishCollectRunnable")
++  : mozilla::Runnable("dom::WorkerPrivate::MemoryReporter::FinishCollectRunnable")
+   , mHandleReport(aHandleReport)
+   , mHandlerData(aHandlerData)
+   , mPerformanceUserEntries(0)
+   , mPerformanceResourceEntries(0)
+   , mAnonymize(aAnonymize)
+   , mSuccess(false)
+   , mCxStats(aPath)
+ { }
+ 
+ NS_IMETHODIMP
+ WorkerPrivate::MemoryReporter::FinishCollectRunnable::Run()
+ {
+-  AssertIsOnMainThread();
++  workers::AssertIsOnMainThread();
+ 
+   nsCOMPtr<nsIMemoryReporterManager> manager =
+     do_GetService("@mozilla.org/memory-reporter-manager;1");
+ 
+   if (!manager)
+     return NS_OK;
+ 
+   if (mSuccess) {
+@@ -1452,17 +1449,17 @@ WorkerPrivate::SyncLoopInfo::SyncLoopInf
+ #endif
+ {
+ }
+ 
+ template <class Derived>
+ nsIDocument*
+ WorkerPrivateParent<Derived>::GetDocument() const
+ {
+-  AssertIsOnMainThread();
++  workers::AssertIsOnMainThread();
+   if (mLoadInfo.mWindow) {
+     return mLoadInfo.mWindow->GetExtantDoc();
+   }
+   // if we don't have a document, we should query the document
+   // from the parent in case of a nested worker
+   WorkerPrivate* parent = mParent;
+   while (parent) {
+     if (parent->mLoadInfo.mWindow) {
+@@ -1473,31 +1470,31 @@ WorkerPrivateParent<Derived>::GetDocumen
+   // couldn't query a document, give up and return nullptr
+   return nullptr;
+ }
+ 
+ template <class Derived>
+ void
+ WorkerPrivateParent<Derived>::SetCSP(nsIContentSecurityPolicy* aCSP)
+ {
+-  AssertIsOnMainThread();
++  workers::AssertIsOnMainThread();
+   if (!aCSP) {
+     return;
+   }
+   WorkerPrivate* self = ParentAsWorkerPrivate();
+   aCSP->EnsureEventTarget(self->mMainThreadEventTarget);
+   mLoadInfo.mCSP = aCSP;
+ }
+ 
+ template <class Derived>
+ nsresult
+ WorkerPrivateParent<Derived>::SetCSPFromHeaderValues(const nsACString& aCSPHeaderValue,
+                                                      const nsACString& aCSPReportOnlyHeaderValue)
+ {
+-  AssertIsOnMainThread();
++  workers::AssertIsOnMainThread();
+   MOZ_DIAGNOSTIC_ASSERT(!mLoadInfo.mCSP);
+ 
+   NS_ConvertASCIItoUTF16 cspHeaderValue(aCSPHeaderValue);
+   NS_ConvertASCIItoUTF16 cspROHeaderValue(aCSPReportOnlyHeaderValue);
+ 
+   nsCOMPtr<nsIContentSecurityPolicy> csp;
+   nsresult rv = mLoadInfo.mPrincipal->EnsureCSP(nullptr, getter_AddRefs(csp));
+   if (!csp) {
+@@ -1587,17 +1584,17 @@ WorkerPrivateParent<Derived>::WorkerPriv
+   mIsChromeWorker(aIsChromeWorker), mMainThreadObjectsForgotten(false),
+   mIsSecureContext(false), mWorkerType(aWorkerType),
+   mCreationTimeStamp(TimeStamp::Now()),
+   mCreationTimeHighRes((double)PR_Now() / PR_USEC_PER_MSEC)
+ {
+   MOZ_ASSERT_IF(!IsDedicatedWorker(), NS_IsMainThread());
+ 
+   if (aLoadInfo.mWindow) {
+-    AssertIsOnMainThread();
++    workers::AssertIsOnMainThread();
+     MOZ_ASSERT(aLoadInfo.mWindow->IsInnerWindow(),
+                "Should have inner window here!");
+     BindToOwner(aLoadInfo.mWindow);
+   }
+ 
+   mLoadInfo.StealFrom(aLoadInfo);
+ 
+   if (aParent) {
+@@ -1613,19 +1610,19 @@ WorkerPrivateParent<Derived>::WorkerPriv
+ 
+     MOZ_ASSERT(IsDedicatedWorker());
+ 
+     if (aParent->mParentFrozen) {
+       Freeze(nullptr);
+     }
+   }
+   else {
+-    AssertIsOnMainThread();
+-
+-    RuntimeService::GetDefaultJSSettings(mJSSettings);
++    workers::AssertIsOnMainThread();
++
++    workers::RuntimeService::GetDefaultJSSettings(mJSSettings);
+ 
+     // Our secure context state depends on the kind of worker we have.
+     if (UsesSystemPrincipal() || IsServiceWorker()) {
+       mIsSecureContext = true;
+     } else if (mLoadInfo.mWindow) {
+       // Shared and dedicated workers both inherit the loading window's secure
+       // context state.  Shared workers then prevent windows with a different
+       // secure context state from attaching to them.
+@@ -1879,17 +1876,17 @@ WorkerPrivateParent<Derived>::NotifyPriv
+       return true;
+     }
+ 
+     pending = mParentStatus == Pending;
+     mParentStatus = aStatus;
+   }
+ 
+   if (IsSharedWorker()) {
+-    RuntimeService* runtime = RuntimeService::GetService();
++    workers::RuntimeService* runtime = workers::RuntimeService::GetService();
+     MOZ_ASSERT(runtime);
+ 
+     runtime->ForgetSharedWorker(ParentAsWorkerPrivate());
+   }
+ 
+   if (pending) {
+     WorkerPrivate* self = ParentAsWorkerPrivate();
+ 
+@@ -1927,17 +1924,17 @@ bool
+ WorkerPrivateParent<Derived>::Freeze(nsPIDOMWindowInner* aWindow)
+ {
+   AssertIsOnParentThread();
+ 
+   // Shared workers are only frozen if all of their owning documents are
+   // frozen. It can happen that mSharedWorkers is empty but this thread has
+   // not been unregistered yet.
+   if ((IsSharedWorker() || IsServiceWorker()) && !mSharedWorkers.IsEmpty()) {
+-    AssertIsOnMainThread();
++    workers::AssertIsOnMainThread();
+ 
+     bool allFrozen = true;
+ 
+     for (uint32_t i = 0; i < mSharedWorkers.Length(); ++i) {
+       if (aWindow && mSharedWorkers[i]->GetOwner() == aWindow) {
+         // Calling Freeze() may change the refcount, ensure that the worker
+         // outlives this call.
+         RefPtr<SharedWorker> kungFuDeathGrip = mSharedWorkers[i];
+@@ -1986,17 +1983,17 @@ WorkerPrivateParent<Derived>::Thaw(nsPID
+   AssertIsOnParentThread();
+ 
+   MOZ_ASSERT(mParentFrozen);
+ 
+   // Shared workers are resumed if any of their owning documents are thawed.
+   // It can happen that mSharedWorkers is empty but this thread has not been
+   // unregistered yet.
+   if ((IsSharedWorker() || IsServiceWorker()) && !mSharedWorkers.IsEmpty()) {
+-    AssertIsOnMainThread();
++    workers::AssertIsOnMainThread();
+ 
+     bool anyRunning = false;
+ 
+     for (uint32_t i = 0; i < mSharedWorkers.Length(); ++i) {
+       if (aWindow && mSharedWorkers[i]->GetOwner() == aWindow) {
+         // Calling Thaw() may change the refcount, ensure that the worker
+         // outlives this call.
+         RefPtr<SharedWorker> kungFuDeathGrip = mSharedWorkers[i];
+@@ -2053,26 +2050,26 @@ WorkerPrivateParent<Derived>::Thaw(nsPID
+ 
+   return true;
+ }
+ 
+ template <class Derived>
+ void
+ WorkerPrivateParent<Derived>::ParentWindowPaused()
+ {
+-  AssertIsOnMainThread();
++  workers::AssertIsOnMainThread();
+   MOZ_ASSERT_IF(IsDedicatedWorker(), mParentWindowPausedDepth == 0);
+   mParentWindowPausedDepth += 1;
+ }
+ 
+ template <class Derived>
+ void
+ WorkerPrivateParent<Derived>::ParentWindowResumed()
+ {
+-  AssertIsOnMainThread();
++  workers::AssertIsOnMainThread();
+ 
+   MOZ_ASSERT(mParentWindowPausedDepth > 0);
+   MOZ_ASSERT_IF(IsDedicatedWorker(), mParentWindowPausedDepth == 1);
+   mParentWindowPausedDepth -= 1;
+   if (mParentWindowPausedDepth > 0) {
+     return;
+   }
+ 
+@@ -2398,17 +2395,17 @@ WorkerPrivateParent<Derived>::MemoryPres
+   Unused << NS_WARN_IF(!runnable->Dispatch());
+ }
+ 
+ template <class Derived>
+ bool
+ WorkerPrivateParent<Derived>::RegisterSharedWorker(SharedWorker* aSharedWorker,
+                                                    MessagePort* aPort)
+ {
+-  AssertIsOnMainThread();
++  workers::AssertIsOnMainThread();
+   MOZ_ASSERT(aSharedWorker);
+   MOZ_ASSERT(IsSharedWorker());
+   MOZ_ASSERT(!mSharedWorkers.Contains(aSharedWorker));
+ 
+   if (IsSharedWorker()) {
+     RefPtr<MessagePortRunnable> runnable =
+       new MessagePortRunnable(ParentAsWorkerPrivate(), aPort);
+     if (!runnable->Dispatch()) {
+@@ -2429,17 +2426,17 @@ WorkerPrivateParent<Derived>::RegisterSh
+ 
+ template <class Derived>
+ void
+ WorkerPrivateParent<Derived>::BroadcastErrorToSharedWorkers(
+                                                     JSContext* aCx,
+                                                     const WorkerErrorReport* aReport,
+                                                     bool aIsErrorEvent)
+ {
+-  AssertIsOnMainThread();
++  workers::AssertIsOnMainThread();
+ 
+   if (aIsErrorEvent && JSREPORT_IS_WARNING(aReport->mFlags)) {
+     // Don't fire any events anywhere.  Just log to console.
+     // XXXbz should we log to all the consoles of all the relevant windows?
+     MOZ_ASSERT(aReport);
+     WorkerErrorReport::LogErrorToConsole(*aReport, 0);
+     return;
+   }
+@@ -2563,34 +2560,34 @@ WorkerPrivateParent<Derived>::BroadcastE
+   }
+ }
+ 
+ template <class Derived>
+ void
+ WorkerPrivateParent<Derived>::GetAllSharedWorkers(
+                                nsTArray<RefPtr<SharedWorker>>& aSharedWorkers)
+ {
+-  AssertIsOnMainThread();
++  workers::AssertIsOnMainThread();
+   MOZ_ASSERT(IsSharedWorker() || IsServiceWorker());
+ 
+   if (!aSharedWorkers.IsEmpty()) {
+     aSharedWorkers.Clear();
+   }
+ 
+   for (uint32_t i = 0; i < mSharedWorkers.Length(); ++i) {
+     aSharedWorkers.AppendElement(mSharedWorkers[i]);
+   }
+ }
+ 
+ template <class Derived>
+ void
+ WorkerPrivateParent<Derived>::CloseSharedWorkersForWindow(
+                                                     nsPIDOMWindowInner* aWindow)
+ {
+-  AssertIsOnMainThread();
++  workers::AssertIsOnMainThread();
+   MOZ_ASSERT(IsSharedWorker() || IsServiceWorker());
+   MOZ_ASSERT(aWindow);
+ 
+   bool someRemoved = false;
+ 
+   for (uint32_t i = 0; i < mSharedWorkers.Length();) {
+     if (mSharedWorkers[i]->GetOwner() == aWindow) {
+       mSharedWorkers[i]->Close();
+@@ -2617,46 +2614,46 @@ WorkerPrivateParent<Derived>::CloseShare
+     Cancel();
+   }
+ }
+ 
+ template <class Derived>
+ void
+ WorkerPrivateParent<Derived>::CloseAllSharedWorkers()
+ {
+-  AssertIsOnMainThread();
++  workers::AssertIsOnMainThread();
+   MOZ_ASSERT(IsSharedWorker() || IsServiceWorker());
+ 
+   for (uint32_t i = 0; i < mSharedWorkers.Length(); ++i) {
+     mSharedWorkers[i]->Close();
+   }
+ 
+   mSharedWorkers.Clear();
+ 
+   Cancel();
+ }
+ 
+ template <class Derived>
+ void
+ WorkerPrivateParent<Derived>::WorkerScriptLoaded()
+ {
+-  AssertIsOnMainThread();
++  workers::AssertIsOnMainThread();
+ 
+   if (IsSharedWorker() || IsServiceWorker()) {
+     // No longer need to hold references to the window or document we came from.
+     mLoadInfo.mWindow = nullptr;
+     mLoadInfo.mScriptContext = nullptr;
+   }
+ }
+ 
+ template <class Derived>
+ void
+ WorkerPrivateParent<Derived>::SetBaseURI(nsIURI* aBaseURI)
+ {
+-  AssertIsOnMainThread();
++  workers::AssertIsOnMainThread();
+ 
+   if (!mLoadInfo.mBaseURI) {
+     NS_ASSERTION(GetParent(), "Shouldn't happen without a parent!");
+     mLoadInfo.mResolvedScriptURI = aBaseURI;
+   }
+ 
+   mLoadInfo.mBaseURI = aBaseURI;
+ 
+@@ -2740,28 +2737,28 @@ WorkerPrivateParent<Derived>::PrincipalU
+   return mLoadInfo.PrincipalURIMatchesScriptURL();
+ }
+ #endif
+ 
+ template <class Derived>
+ void
+ WorkerPrivateParent<Derived>::UpdateOverridenLoadGroup(nsILoadGroup* aBaseLoadGroup)
+ {
+-  AssertIsOnMainThread();
++  workers::AssertIsOnMainThread();
+ 
+   // The load group should have been overriden at init time.
+   mLoadInfo.mInterfaceRequestor->MaybeAddTabChild(aBaseLoadGroup);
+ }
+ 
+ template <class Derived>
+ void
+ WorkerPrivateParent<Derived>::FlushReportsToSharedWorkers(
+                                            nsIConsoleReportCollector* aReporter)
+ {
+-  AssertIsOnMainThread();
++  workers::AssertIsOnMainThread();
+ 
+   AutoTArray<RefPtr<SharedWorker>, 10> sharedWorkers;
+   AutoTArray<WindowAction, 10> windowActions;
+   GetAllSharedWorkers(sharedWorkers);
+ 
+   // First find out all the shared workers' window.
+   for (size_t index = 0; index < sharedWorkers.Length(); index++) {
+     RefPtr<SharedWorker>& sharedWorker = sharedWorkers[index];
+@@ -2844,32 +2841,32 @@ NS_IMPL_CYCLE_COLLECTION_TRACE_END
+ template <class Derived>
+ void
+ WorkerPrivateParent<Derived>::AssertIsOnParentThread() const
+ {
+   if (GetParent()) {
+     GetParent()->AssertIsOnWorkerThread();
+   }
+   else {
+-    AssertIsOnMainThread();
++    workers::AssertIsOnMainThread();
+   }
+ }
+ 
+ template <class Derived>
+ void
+ WorkerPrivateParent<Derived>::AssertInnerWindowIsCorrect() const
+ {
+   AssertIsOnParentThread();
+ 
+   // Only care about top level workers from windows.
+   if (mParent || !mLoadInfo.mWindow) {
+     return;
+   }
+ 
+-  AssertIsOnMainThread();
++  workers::AssertIsOnMainThread();
+ 
+   nsPIDOMWindowOuter* outer = mLoadInfo.mWindow->GetOuterWindow();
+   NS_ASSERTION(outer && outer->GetCurrentInnerWindow() == mLoadInfo.mWindow,
+                "Inner window no longer correct!");
+ }
+ 
+ #endif
+ 
+@@ -2917,17 +2914,17 @@ WorkerPrivate::WorkerPrivate(WorkerPriva
+   , mFetchHandlerWasAdded(false)
+   , mOnLine(false)
+ {
+   if (aParent) {
+     aParent->AssertIsOnWorkerThread();
+     mOnLine = aParent->OnLine();
+   }
+   else {
+-    AssertIsOnMainThread();
++    workers::AssertIsOnMainThread();
+     mOnLine = !NS_IsOffline();
+   }
+ 
+   nsCOMPtr<nsISerialEventTarget> target;
+ 
+   // A child worker just inherits the parent workers ThrottledEventQueue
+   // and main thread target for now.  This is mainly due to the restriction
+   // that ThrottledEventQueue can only be created on the main thread at the
+@@ -3061,17 +3058,17 @@ WorkerPrivate::Constructor(JSContext* aC
+     parent->AssertIsOnWorkerThread();
+ 
+     holder.reset(new SimpleWorkerHolder());
+     if (!holder->HoldWorker(parent, Canceling)) {
+       aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
+       return nullptr;
+     }
+   } else {
+-    AssertIsOnMainThread();
++    workers::AssertIsOnMainThread();
+   }
+ 
+   Maybe<WorkerLoadInfo> stackLoadInfo;
+   if (!aLoadInfo) {
+     stackLoadInfo.emplace();
+ 
+     nsresult rv = GetLoadInfo(aCx, nullptr, parent, aScriptURL,
+                               aIsChromeWorker, InheritLoadGroup,
+@@ -3083,27 +3080,27 @@ WorkerPrivate::Constructor(JSContext* aC
+     }
+ 
+     aLoadInfo = stackLoadInfo.ptr();
+   }
+ 
+   // NB: This has to be done before creating the WorkerPrivate, because it will
+   // attempt to use static variables that are initialized in the RuntimeService
+   // constructor.
+-  RuntimeService* runtimeService;
++  workers::RuntimeService* runtimeService;
+ 
+   if (!parent) {
+-    runtimeService = RuntimeService::GetOrCreateService();
++    runtimeService = workers::RuntimeService::GetOrCreateService();
+     if (!runtimeService) {
+       aRv.Throw(NS_ERROR_FAILURE);
+       return nullptr;
+     }
+   }
+   else {
+-    runtimeService = RuntimeService::GetService();
++    runtimeService = workers::RuntimeService::GetService();
+   }
+ 
+   MOZ_ASSERT(runtimeService);
+ 
+   RefPtr<WorkerPrivate> worker =
+     new WorkerPrivate(parent, aScriptURL, aIsChromeWorker,
+                       aWorkerType, aWorkerName, aServiceWorkerScope,
+                       *aLoadInfo);
+@@ -3151,17 +3148,17 @@ WorkerPrivate::GetLoadInfo(JSContext* aC
+                            WorkerLoadInfo* aLoadInfo)
+ {
+   using namespace mozilla::dom::workerinternals;
+ 
+   MOZ_ASSERT(aCx);
+   MOZ_ASSERT_IF(NS_IsMainThread(), aCx == nsContentUtils::GetCurrentJSContext());
+ 
+   if (aWindow) {
+-    AssertIsOnMainThread();
++    workers::AssertIsOnMainThread();
+   }
+ 
+   WorkerLoadInfo loadInfo;
+   nsresult rv;
+ 
+   if (aParent) {
+     aParent->AssertIsOnWorkerThread();
+ 
+@@ -3201,17 +3198,17 @@ WorkerPrivate::GetLoadInfo(JSContext* aC
+     loadInfo.mFromWindow = aParent->IsFromWindow();
+     loadInfo.mWindowID = aParent->WindowID();
+     loadInfo.mStorageAllowed = aParent->IsStorageAllowed();
+     loadInfo.mOriginAttributes = aParent->GetOriginAttributes();
+     loadInfo.mServiceWorkersTestingInWindow =
+       aParent->ServiceWorkersTestingInWindow();
+     loadInfo.mParentController = aParent->GetController();
+   } else {
+-    AssertIsOnMainThread();
++    workers::AssertIsOnMainThread();
+ 
+     // Make sure that the IndexedDatabaseManager is set up
+     Unused << NS_WARN_IF(!IndexedDatabaseManager::GetOrCreate());
+ 
+     nsIScriptSecurityManager* ssm = nsContentUtils::GetSecurityManager();
+     MOZ_ASSERT(ssm);
+ 
+     bool isChrome = nsContentUtils::IsSystemCaller(aCx);
+@@ -3838,23 +3835,23 @@ WorkerPrivate::SetGCTimerMode(GCTimerMod
+   int16_t type = nsITimer::TYPE_ONE_SHOT;
+   nsTimerCallbackFunc callback = nullptr;
+   const char* name = nullptr;
+ 
+   if (aMode == PeriodicTimer) {
+     delay = PERIODIC_GC_TIMER_DELAY_SEC * 1000;
+     type = nsITimer::TYPE_REPEATING_SLACK;
+     callback = PeriodicGCTimerCallback;
+-    name = "dom::workers::PeriodicGCTimerCallback";
++    name = "dom::PeriodicGCTimerCallback";
+   }
+   else {
+     delay = IDLE_GC_TIMER_DELAY_SEC * 1000;
+     type = nsITimer::TYPE_ONE_SHOT;
+     callback = IdleGCTimerCallback;
+-    name = "dom::workers::IdleGCTimerCallback";
++    name = "dom::IdleGCTimerCallback";
+   }
+ 
+   MOZ_ALWAYS_SUCCEEDS(mGCTimer->SetTarget(mWorkerControlEventTarget));
+   MOZ_ALWAYS_SUCCEEDS(
+     mGCTimer->InitWithNamedFuncCallback(callback, this, delay, type, name));
+ 
+   if (aMode == PeriodicTimer) {
+     LOG(WorkerLog(), ("Worker %p scheduled periodic GC timer\n", this));
+@@ -5548,17 +5545,17 @@ WorkerPrivate::DumpCrashInformation(nsAC
+     aString.Append("|");
+     aString.Append(holder->Name());
+   }
+ }
+ 
+ PerformanceStorage*
+ WorkerPrivate::GetPerformanceStorage()
+ {
+-  AssertIsOnMainThread();
++  workers::AssertIsOnMainThread();
+ 
+   if (!mPerformanceStorage) {
+     mPerformanceStorage = PerformanceStorageWorker::Create(this);
+   }
+ 
+   return mPerformanceStorage;
+ }
+ 
+@@ -5671,14 +5668,10 @@ EventTarget::IsOnCurrentThreadInfallible
+   if (!mWorkerPrivate) {
+     NS_WARNING("A worker's event target was used after the worker has !");
+     return false;
+   }
+ 
+   return mWorkerPrivate->IsOnCurrentThread();
+ }
+ 
+-BEGIN_WORKERS_NAMESPACE
+-
+ // Force instantiation.
+ template class WorkerPrivateParent<WorkerPrivate>;
+-
+-END_WORKERS_NAMESPACE
+diff --git a/dom/workers/WorkerPrivate.h b/dom/workers/WorkerPrivate.h
+--- a/dom/workers/WorkerPrivate.h
++++ b/dom/workers/WorkerPrivate.h
+@@ -2,28 +2,28 @@
+ /* vim: set ts=8 sts=2 et sw=2 tw=80: */
+ /* 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/. */
+ 
+ #ifndef mozilla_dom_workers_workerprivate_h__
+ #define mozilla_dom_workers_workerprivate_h__
+ 
+-#include "WorkerCommon.h"
++#include "mozilla/dom/workers/WorkerCommon.h"
+ #include "mozilla/CondVar.h"
+ #include "mozilla/DOMEventTargetHelper.h"
+ #include "nsDOMNavigationTiming.h"
+ #include "nsIContentSecurityPolicy.h"
+ #include "nsIEventTarget.h"
+ #include "nsThreadUtils.h"
+ #include "nsTObserverArray.h"
+ 
+-#include "Queue.h"
+-#include "WorkerHolder.h"
+-#include "WorkerLoadInfo.h"
++#include "mozilla/dom/WorkerHolder.h"
++#include "mozilla/dom/WorkerLoadInfo.h"
++#include "mozilla/dom/workers/Queue.h"
+ 
+ #ifdef XP_WIN
+ #undef PostMessage
+ #endif
+ 
+ class nsIConsoleReportCollector;
+ class nsIThreadInternal;
+ 
+@@ -42,21 +42,16 @@ class WorkerDebugger;
+ class WorkerDebuggerGlobalScope;
+ class WorkerErrorReport;
+ class WorkerEventTarget;
+ class WorkerGlobalScope;
+ struct WorkerOptions;
+ class WorkerRunnable;
+ class WorkerThread;
+ 
+-} // dom namespace
+-} // mozilla namespace
+-
+-BEGIN_WORKERS_NAMESPACE
+-
+ // SharedMutex is a small wrapper around an (internal) reference-counted Mutex
+ // object. It exists to avoid changing a lot of code to use Mutex* instead of
+ // Mutex&.
+ class SharedMutex
+ {
+   typedef mozilla::Mutex Mutex;
+ 
+   class RefCountedMutex final : public Mutex
+@@ -144,17 +139,17 @@ private:
+   WorkerLoadInfo mLoadInfo;
+ 
+   Atomic<bool> mLoadingWorkerScript;
+ 
+   // Only used for top level workers.
+   nsTArray<nsCOMPtr<nsIRunnable>> mQueuedRunnables;
+ 
+   // Protected by mMutex.
+-  JSSettings mJSSettings;
++  workers::JSSettings mJSSettings;
+ 
+   // Only touched on the parent thread (currently this is always the main
+   // thread as SharedWorkers are always top-level).
+   nsTArray<RefPtr<SharedWorker>> mSharedWorkers;
+ 
+   // This is touched on parent thread only, but it can be read on a different
+   // thread before crashing because hanging.
+   Atomic<uint64_t> mBusyCount;
+@@ -398,17 +393,17 @@ public:
+   {
+     mMutex.AssertCurrentThreadOwns();
+     return mParentStatus;
+   }
+ 
+   nsIScriptContext*
+   GetScriptContext() const
+   {
+-    AssertIsOnMainThread();
++    workers::AssertIsOnMainThread();
+     return mLoadInfo.mScriptContext;
+   }
+ 
+   const nsString&
+   ScriptURL() const
+   {
+     return mScriptURL;
+   }
+@@ -447,35 +442,35 @@ public:
+   ServiceWorkerScope() const
+   {
+     return GetServiceWorkerDescriptor().Scope();
+   }
+ 
+   nsIURI*
+   GetBaseURI() const
+   {
+-    AssertIsOnMainThread();
++    workers::AssertIsOnMainThread();
+     return mLoadInfo.mBaseURI;
+   }
+ 
+   void
+   SetBaseURI(nsIURI* aBaseURI);
+ 
+   nsIURI*
+   GetResolvedScriptURI() const
+   {
+-    AssertIsOnMainThread();
++    workers::AssertIsOnMainThread();
+     return mLoadInfo.mResolvedScriptURI;
+   }
+ 
+   const nsString&
+   ServiceWorkerCacheName() const
+   {
+     MOZ_DIAGNOSTIC_ASSERT(IsServiceWorker());
+-    AssertIsOnMainThread();
++    workers::AssertIsOnMainThread();
+     return mLoadInfo.mServiceWorkerCacheName;
+   }
+ 
+   const ServiceWorkerDescriptor&
+   GetServiceWorkerDescriptor() const
+   {
+     MOZ_DIAGNOSTIC_ASSERT(IsServiceWorker());
+     MOZ_DIAGNOSTIC_ASSERT(mLoadInfo.mServiceWorkerDescriptor.isSome());
+@@ -500,17 +495,17 @@ public:
+   GetChannelInfo() const
+   {
+     return mLoadInfo.mChannelInfo;
+   }
+ 
+   void
+   SetChannelInfo(const ChannelInfo& aChannelInfo)
+   {
+-    AssertIsOnMainThread();
++    workers::AssertIsOnMainThread();
+     MOZ_ASSERT(!mLoadInfo.mChannelInfo.IsInitialized());
+     MOZ_ASSERT(aChannelInfo.IsInitialized());
+     mLoadInfo.mChannelInfo = aChannelInfo;
+   }
+ 
+   void
+   InitChannelInfo(nsIChannel* aChannel)
+   {
+@@ -561,36 +556,36 @@ public:
+     MOZ_ASSERT(!aTimeStamp.IsNull());
+     TimeDuration duration = aTimeStamp - mCreationTimeStamp;
+     return duration.ToMilliseconds();
+   }
+ 
+   nsIPrincipal*
+   GetPrincipal() const
+   {
+-    AssertIsOnMainThread();
++    workers::AssertIsOnMainThread();
+     return mLoadInfo.mPrincipal;
+   }
+ 
+   nsIPrincipal*
+   GetLoadingPrincipal() const
+   {
+-    AssertIsOnMainThread();
++    workers::AssertIsOnMainThread();
+     return mLoadInfo.mLoadingPrincipal;
+   }
+ 
+   const nsAString& Origin() const
+   {
+     return mLoadInfo.mOrigin;
+   }
+ 
+   nsILoadGroup*
+   GetLoadGroup() const
+   {
+-    AssertIsOnMainThread();
++    workers::AssertIsOnMainThread();
+     return mLoadInfo.mLoadGroup;
+   }
+ 
+   // This method allows the principal to be retrieved off the main thread.
+   // Principals are main-thread objects so the caller must ensure that all
+   // access occurs on the main thread.
+   nsIPrincipal*
+   GetPrincipalDontAssertMainThread() const
+@@ -622,33 +617,33 @@ public:
+   GetPrincipalInfo() const
+   {
+     return *mLoadInfo.mPrincipalInfo;
+   }
+ 
+   already_AddRefed<nsIChannel>
+   ForgetWorkerChannel()
+   {
+-    AssertIsOnMainThread();
++    workers::AssertIsOnMainThread();
+     return mLoadInfo.mChannel.forget();
+   }
+ 
+   nsIDocument* GetDocument() const;
+ 
+   nsPIDOMWindowInner*
+   GetWindow()
+   {
+-    AssertIsOnMainThread();
++    workers::AssertIsOnMainThread();
+     return mLoadInfo.mWindow;
+   }
+ 
+   nsIContentSecurityPolicy*
+   GetCSP() const
+   {
+-    AssertIsOnMainThread();
++    workers::AssertIsOnMainThread();
+     return mLoadInfo.mCSP;
+   }
+ 
+   void
+   SetCSP(nsIContentSecurityPolicy* aCSP);
+ 
+   nsresult
+   SetCSPFromHeaderValues(const nsACString& aCSPHeaderValue,
+@@ -707,17 +702,17 @@ public:
+ 
+   LocationInfo&
+   GetLocationInfo()
+   {
+     return mLocationInfo;
+   }
+ 
+   void
+-  CopyJSSettings(JSSettings& aSettings)
++  CopyJSSettings(workers::JSSettings& aSettings)
+   {
+     mozilla::MutexAutoLock lock(mMutex);
+     aSettings = mJSSettings;
+   }
+ 
+   void
+   CopyJSCompartmentOptions(JS::CompartmentOptions& aOptions)
+   {
+@@ -889,18 +884,18 @@ class WorkerPrivate : public WorkerPriva
+     PeriodicTimer = 0,
+     IdleTimer,
+     NoTimer
+   };
+ 
+   bool mDebuggerRegistered;
+   WorkerDebugger* mDebugger;
+ 
+-  Queue<WorkerControlRunnable*, 4> mControlQueue;
+-  Queue<WorkerRunnable*, 4> mDebuggerQueue;
++  workers::Queue<WorkerControlRunnable*, 4> mControlQueue;
++  workers::Queue<WorkerRunnable*, 4> mDebuggerQueue;
+ 
+   // Touched on multiple threads, protected with mMutex.
+   JSContext* mJSContext;
+   RefPtr<WorkerThread> mThread;
+   PRThread* mPRThread;
+ 
+   // Things touched on worker thread only.
+   RefPtr<WorkerGlobalScope> mScope;
+@@ -1002,26 +997,26 @@ public:
+   // ServiceWorker and the loading principal for any other type.
+   static void
+   OverrideLoadInfoLoadGroup(WorkerLoadInfo& aLoadInfo,
+                             nsIPrincipal* aPrincipal);
+ 
+   bool
+   IsDebuggerRegistered()
+   {
+-    AssertIsOnMainThread();
++    workers::AssertIsOnMainThread();
+ 
+     // No need to lock here since this is only ever modified by the same thread.
+     return mDebuggerRegistered;
+   }
+ 
+   void
+   SetIsDebuggerRegistered(bool aDebuggerRegistered)
+   {
+-    AssertIsOnMainThread();
++    workers::AssertIsOnMainThread();
+ 
+     MutexAutoLock lock(mMutex);
+ 
+     MOZ_ASSERT(mDebuggerRegistered != aDebuggerRegistered);
+     mDebuggerRegistered = aDebuggerRegistered;
+ 
+     mCondVar.Notify();
+   }
+@@ -1038,26 +1033,26 @@ public:
+     while (mDebuggerRegistered != aDebuggerRegistered) {
+       mCondVar.Wait();
+     }
+   }
+ 
+   WorkerDebugger*
+   Debugger() const
+   {
+-    AssertIsOnMainThread();
++    workers::AssertIsOnMainThread();
+ 
+     MOZ_ASSERT(mDebugger);
+     return mDebugger;
+   }
+ 
+   void
+   SetDebugger(WorkerDebugger* aDebugger)
+   {
+-    AssertIsOnMainThread();
++    workers::AssertIsOnMainThread();
+ 
+     MOZ_ASSERT(mDebugger != aDebugger);
+     mDebugger = aDebugger;
+   }
+ 
+   JS::UniqueChars
+   AdoptDefaultLocale()
+   {
+@@ -1565,11 +1560,12 @@ public:
+   nsIEventTarget*
+   GetEventTarget() const
+   {
+     // This can be null if CreateNewSyncLoop() fails.
+     return mTarget;
+   }
+ };
+ 
+-END_WORKERS_NAMESPACE
++} // dom namespace
++} // mozilla namespace
+ 
+ #endif /* mozilla_dom_workers_workerprivate_h__ */
+diff --git a/dom/workers/WorkerRunnable.cpp b/dom/workers/WorkerRunnable.cpp
+--- a/dom/workers/WorkerRunnable.cpp
++++ b/dom/workers/WorkerRunnable.cpp
+@@ -21,18 +21,16 @@
+ #include "js/Value.h"
+ 
+ #include "WorkerPrivate.h"
+ #include "WorkerScope.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+-using namespace workers;
+-
+ namespace {
+ 
+ const nsIID kWorkerRunnableIID = {
+   0x320cc0b5, 0xef12, 0x4084, { 0x88, 0x6e, 0xca, 0x6a, 0x81, 0xe4, 0x1d, 0x68 }
+ };
+ 
+ } // namespace
+ 
+@@ -470,17 +468,17 @@ MainThreadWorkerSyncRunnable::PostDispat
+ }
+ 
+ MainThreadStopSyncLoopRunnable::MainThreadStopSyncLoopRunnable(
+                                WorkerPrivate* aWorkerPrivate,
+                                already_AddRefed<nsIEventTarget>&& aSyncLoopTarget,
+                                bool aResult)
+ : WorkerSyncRunnable(aWorkerPrivate, Move(aSyncLoopTarget)), mResult(aResult)
+ {
+-  AssertIsOnMainThread();
++  workers::AssertIsOnMainThread();
+ #ifdef DEBUG
+   mWorkerPrivate->AssertValidSyncLoop(mSyncLoopTarget);
+ #endif
+ }
+ 
+ nsresult
+ MainThreadStopSyncLoopRunnable::Cancel()
+ {
+@@ -560,17 +558,17 @@ WorkerControlRunnable::DispatchInternal(
+   return NS_SUCCEEDED(mWorkerPrivate->DispatchToMainThread(runnable.forget()));
+ }
+ 
+ NS_IMPL_ISUPPORTS_INHERITED0(WorkerControlRunnable, WorkerRunnable)
+ 
+ WorkerMainThreadRunnable::WorkerMainThreadRunnable(
+   WorkerPrivate* aWorkerPrivate,
+   const nsACString& aTelemetryKey)
+-  : mozilla::Runnable("dom::workers::WorkerMainThreadRunnable")
++  : mozilla::Runnable("dom::WorkerMainThreadRunnable")
+   , mWorkerPrivate(aWorkerPrivate)
+   , mTelemetryKey(aTelemetryKey)
+ {
+   mWorkerPrivate->AssertIsOnWorkerThread();
+ }
+ 
+ void
+ WorkerMainThreadRunnable::Dispatch(WorkerStatus aFailStatus,
+@@ -604,17 +602,17 @@ WorkerMainThreadRunnable::Dispatch(Worke
+   if (!success) {
+     aRv.ThrowUncatchableException();
+   }
+ }
+ 
+ NS_IMETHODIMP
+ WorkerMainThreadRunnable::Run()
+ {
+-  AssertIsOnMainThread();
++  workers::AssertIsOnMainThread();
+ 
+   bool runResult = MainThreadRun();
+ 
+   RefPtr<MainThreadStopSyncLoopRunnable> response =
+     new MainThreadStopSyncLoopRunnable(mWorkerPrivate,
+                                        mSyncLoopTarget.forget(),
+                                        runResult);
+ 
+@@ -664,17 +662,17 @@ WorkerSameThreadRunnable::PostDispatch(W
+     // Should never fail since if this thread is still running, so should the
+     // parent and it should be able to process a control runnable.
+     MOZ_ASSERT(willIncrement);
+   }
+ }
+ 
+ WorkerProxyToMainThreadRunnable::WorkerProxyToMainThreadRunnable(
+   WorkerPrivate* aWorkerPrivate)
+-  : mozilla::Runnable("dom::workers::WorkerProxyToMainThreadRunnable")
++  : mozilla::Runnable("dom::WorkerProxyToMainThreadRunnable")
+   , mWorkerPrivate(aWorkerPrivate)
+ {
+   MOZ_ASSERT(mWorkerPrivate);
+   mWorkerPrivate->AssertIsOnWorkerThread();
+ }
+ 
+ WorkerProxyToMainThreadRunnable::~WorkerProxyToMainThreadRunnable()
+ {}
+@@ -696,17 +694,17 @@ WorkerProxyToMainThreadRunnable::Dispatc
+   }
+ 
+   return true;
+ }
+ 
+ NS_IMETHODIMP
+ WorkerProxyToMainThreadRunnable::Run()
+ {
+-  AssertIsOnMainThread();
++  workers::AssertIsOnMainThread();
+   RunOnMainThread();
+   PostDispatchOnMainThread();
+   return NS_OK;
+ }
+ 
+ void
+ WorkerProxyToMainThreadRunnable::PostDispatchOnMainThread()
+ {
+@@ -728,17 +726,17 @@ WorkerProxyToMainThreadRunnable::PostDis
+     nsresult
+     Cancel() override
+     {
+       WorkerRun(nullptr, mWorkerPrivate);
+       return MainThreadWorkerControlRunnable::Cancel();
+     }
+ 
+     virtual bool
+-    WorkerRun(JSContext* aCx, workers::WorkerPrivate* aWorkerPrivate) override
++    WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate) override
+     {
+       MOZ_ASSERT(aWorkerPrivate);
+       aWorkerPrivate->AssertIsOnWorkerThread();
+ 
+       if (mRunnable) {
+         mRunnable->RunBackOnWorkerThreadForCleanup();
+ 
+         // Let's release the worker thread.
+diff --git a/dom/workers/WorkerRunnable.h b/dom/workers/WorkerRunnable.h
+--- a/dom/workers/WorkerRunnable.h
++++ b/dom/workers/WorkerRunnable.h
+@@ -2,37 +2,35 @@
+ /* vim: set ts=8 sts=2 et sw=2 tw=80: */
+ /* 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/. */
+ 
+ #ifndef mozilla_dom_workers_workerrunnable_h__
+ #define mozilla_dom_workers_workerrunnable_h__
+ 
+-#include "WorkerCommon.h"
+-#include "WorkerHolder.h"
++#include "mozilla/dom/workers/WorkerCommon.h"
++#include "mozilla/dom/WorkerHolder.h"
+ 
+ #include "nsICancelableRunnable.h"
+ 
+ #include "mozilla/Atomics.h"
+ #include "nsISupportsImpl.h"
+ #include "nsThreadUtils.h" /* nsRunnable */
+ 
+ struct JSContext;
+ class nsIEventTarget;
+ 
+ namespace mozilla {
+ 
+ class ErrorResult;
+ 
+ namespace dom {
+ 
+-namespace workers {
+ class WorkerPrivate;
+-}
+ 
+ // Use this runnable to communicate from the worker to its parent or vice-versa.
+ // The busy count must be taken into consideration and declared at construction
+ // time.
+ class WorkerRunnable : public nsIRunnable,
+                        public nsICancelableRunnable
+ {
+ public:
+@@ -49,17 +47,17 @@ public:
+     // Target the thread where the worker event loop runs. The busy count will
+     // not be modified in any way. Besides worker-internal runnables this is
+     // almost always the wrong choice.
+     WorkerThreadUnchangedBusyCount
+   };
+ 
+ protected:
+   // The WorkerPrivate that this runnable is associated with.
+-  workers::WorkerPrivate* mWorkerPrivate;
++  WorkerPrivate* mWorkerPrivate;
+ 
+   // See above.
+   TargetAndBusyBehavior mBehavior;
+ 
+   // It's unclear whether or not Cancel() is supposed to work when called on any
+   // thread. To be safe we're using an atomic but it's likely overkill.
+   Atomic<uint32_t> mCanceled;
+ 
+@@ -89,17 +87,17 @@ public:
+   {
+     return mCanceled != 0;
+   }
+ 
+   static WorkerRunnable*
+   FromRunnable(nsIRunnable* aRunnable);
+ 
+ protected:
+-  WorkerRunnable(workers::WorkerPrivate* aWorkerPrivate,
++  WorkerRunnable(WorkerPrivate* aWorkerPrivate,
+                  TargetAndBusyBehavior aBehavior = WorkerThreadModifyBusyCount)
+ #ifdef DEBUG
+   ;
+ #else
+   : mWorkerPrivate(aWorkerPrivate), mBehavior(aBehavior), mCanceled(0),
+     mCallingCancelWithinRun(false)
+   { }
+ #endif
+@@ -116,32 +114,32 @@ protected:
+   nsIGlobalObject*
+   DefaultGlobalObject() const;
+ 
+   // By default asserts that Dispatch() is being called on the right thread
+   // (ParentThread if |mTarget| is WorkerThread, or WorkerThread otherwise).
+   // Also increments the busy count of |mWorkerPrivate| if targeting the
+   // WorkerThread.
+   virtual bool
+-  PreDispatch(workers::WorkerPrivate* aWorkerPrivate);
++  PreDispatch(WorkerPrivate* aWorkerPrivate);
+ 
+   // By default asserts that Dispatch() is being called on the right thread
+   // (ParentThread if |mTarget| is WorkerThread, or WorkerThread otherwise).
+   virtual void
+-  PostDispatch(workers::WorkerPrivate* aWorkerPrivate, bool aDispatchResult);
++  PostDispatch(WorkerPrivate* aWorkerPrivate, bool aDispatchResult);
+ 
+   // May be implemented by subclasses if desired if they need to do some sort of
+   // setup before we try to set up our JSContext and compartment for real.
+   // Typically the only thing that should go in here is creation of the worker's
+   // global.
+   //
+   // If false is returned, WorkerRun will not be called at all.  PostRun will
+   // still be called, with false passed for aRunResult.
+   virtual bool
+-  PreRun(workers::WorkerPrivate* aWorkerPrivate);
++  PreRun(WorkerPrivate* aWorkerPrivate);
+ 
+   // Must be implemented by subclasses. Called on the target thread.  The return
+   // value will be passed to PostRun().  The JSContext passed in here comes from
+   // an AutoJSAPI (or AutoEntryScript) that we set up on the stack.  If
+   // mBehavior is ParentThreadUnchangedBusyCount, it is in the compartment of
+   // mWorkerPrivate's reflector (i.e. the worker object in the parent thread),
+   // unless that reflector is null, in which case it's in the compartment of the
+   // parent global (which is the compartment reflector would have been in), or
+@@ -154,139 +152,139 @@ protected:
+   // sandbox compartment!).  If aCx wasn't in a compartment to start with, aCx
+   // will be in either the debugger global's compartment or the worker's
+   // global's compartment depending on whether IsDebuggerRunnable() is true.
+   //
+   // Immediately after WorkerRun returns, the caller will assert that either it
+   // returns false or there is no exception pending on aCx.  Then it will report
+   // any pending exceptions on aCx.
+   virtual bool
+-  WorkerRun(JSContext* aCx, workers::WorkerPrivate* aWorkerPrivate) = 0;
++  WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate) = 0;
+ 
+   // By default asserts that Run() (and WorkerRun()) were called on the correct
+   // thread.  Also sends an asynchronous message to the ParentThread if the
+   // busy count was previously modified in PreDispatch().
+   //
+   // The aCx passed here is the same one as was passed to WorkerRun and is
+   // still in the same compartment.  PostRun implementations must NOT leave an
+   // exception on the JSContext and must not run script, because the incoming
+   // JSContext may be in the null compartment.
+   virtual void
+-  PostRun(JSContext* aCx, workers::WorkerPrivate* aWorkerPrivate,
++  PostRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate,
+           bool aRunResult);
+ 
+   virtual bool
+   DispatchInternal();
+ 
+   // Calling Run() directly is not supported. Just call Dispatch() and
+   // WorkerRun() will be called on the correct thread automatically.
+   NS_DECL_NSIRUNNABLE
+ };
+ 
+ // This runnable is used to send a message to a worker debugger.
+ class WorkerDebuggerRunnable : public WorkerRunnable
+ {
+ protected:
+-  explicit WorkerDebuggerRunnable(workers::WorkerPrivate* aWorkerPrivate)
++  explicit WorkerDebuggerRunnable(WorkerPrivate* aWorkerPrivate)
+   : WorkerRunnable(aWorkerPrivate, WorkerThreadUnchangedBusyCount)
+   {
+   }
+ 
+   virtual ~WorkerDebuggerRunnable()
+   { }
+ 
+ private:
+   virtual bool
+   IsDebuggerRunnable() const override
+   {
+     return true;
+   }
+ 
+   virtual bool
+-  PreDispatch(workers::WorkerPrivate* aWorkerPrivate) override final
++  PreDispatch(WorkerPrivate* aWorkerPrivate) override final
+   {
+     workers::AssertIsOnMainThread();
+ 
+     return true;
+   }
+ 
+   virtual void
+-  PostDispatch(workers::WorkerPrivate* aWorkerPrivate,
++  PostDispatch(WorkerPrivate* aWorkerPrivate,
+                bool aDispatchResult) override;
+ };
+ 
+ // This runnable is used to send a message directly to a worker's sync loop.
+ class WorkerSyncRunnable : public WorkerRunnable
+ {
+ protected:
+   nsCOMPtr<nsIEventTarget> mSyncLoopTarget;
+ 
+   // Passing null for aSyncLoopTarget is allowed and will result in the behavior
+   // of a normal WorkerRunnable.
+-  WorkerSyncRunnable(workers::WorkerPrivate* aWorkerPrivate,
++  WorkerSyncRunnable(WorkerPrivate* aWorkerPrivate,
+                      nsIEventTarget* aSyncLoopTarget);
+ 
+-  WorkerSyncRunnable(workers::WorkerPrivate* aWorkerPrivate,
++  WorkerSyncRunnable(WorkerPrivate* aWorkerPrivate,
+                      already_AddRefed<nsIEventTarget>&& aSyncLoopTarget);
+ 
+   virtual ~WorkerSyncRunnable();
+ 
+   virtual bool
+   DispatchInternal() override;
+ };
+ 
+ // This runnable is identical to WorkerSyncRunnable except it is meant to be
+ // created on and dispatched from the main thread only.  Its WorkerRun/PostRun
+ // will run on the worker thread.
+ class MainThreadWorkerSyncRunnable : public WorkerSyncRunnable
+ {
+ protected:
+   // Passing null for aSyncLoopTarget is allowed and will result in the behavior
+   // of a normal WorkerRunnable.
+-  MainThreadWorkerSyncRunnable(workers::WorkerPrivate* aWorkerPrivate,
++  MainThreadWorkerSyncRunnable(WorkerPrivate* aWorkerPrivate,
+                                nsIEventTarget* aSyncLoopTarget)
+   : WorkerSyncRunnable(aWorkerPrivate, aSyncLoopTarget)
+   {
+     workers::AssertIsOnMainThread();
+   }
+ 
+-  MainThreadWorkerSyncRunnable(workers::WorkerPrivate* aWorkerPrivate,
++  MainThreadWorkerSyncRunnable(WorkerPrivate* aWorkerPrivate,
+                                already_AddRefed<nsIEventTarget>&& aSyncLoopTarget)
+   : WorkerSyncRunnable(aWorkerPrivate, Move(aSyncLoopTarget))
+   {
+     workers::AssertIsOnMainThread();
+   }
+ 
+   virtual ~MainThreadWorkerSyncRunnable()
+   { }
+ 
+ private:
+   virtual bool
+-  PreDispatch(workers::WorkerPrivate* aWorkerPrivate) override
++  PreDispatch(WorkerPrivate* aWorkerPrivate) override
+   {
+     workers::AssertIsOnMainThread();
+     return true;
+   }
+ 
+   virtual void
+-  PostDispatch(workers::WorkerPrivate* aWorkerPrivate,
++  PostDispatch(WorkerPrivate* aWorkerPrivate,
+                bool aDispatchResult) override;
+ };
+ 
+ // This runnable is processed as soon as it is received by the worker,
+ // potentially running before previously queued runnables and perhaps even with
+ // other JS code executing on the stack. These runnables must not alter the
+ // state of the JS runtime and should only twiddle state values. The busy count
+ // is never modified.
+ class WorkerControlRunnable : public WorkerRunnable
+ {
+-  friend class workers::WorkerPrivate;
++  friend class WorkerPrivate;
+ 
+ protected:
+-  WorkerControlRunnable(workers::WorkerPrivate* aWorkerPrivate,
++  WorkerControlRunnable(WorkerPrivate* aWorkerPrivate,
+                         TargetAndBusyBehavior aBehavior = WorkerThreadModifyBusyCount)
+ #ifdef DEBUG
+   ;
+ #else
+   : WorkerRunnable(aWorkerPrivate, aBehavior)
+   { }
+ #endif
+ 
+@@ -298,115 +296,115 @@ protected:
+ 
+ public:
+   NS_DECL_ISUPPORTS_INHERITED
+ 
+ private:
+   virtual bool
+   DispatchInternal() override;
+ 
+-  // Should only be called by workers::WorkerPrivate::DoRunLoop.
++  // Should only be called by WorkerPrivate::DoRunLoop.
+   using WorkerRunnable::Cancel;
+ };
+ 
+ // A convenience class for WorkerRunnables that are originated on the main
+ // thread.
+ class MainThreadWorkerRunnable : public WorkerRunnable
+ {
+ protected:
+-  explicit MainThreadWorkerRunnable(workers::WorkerPrivate* aWorkerPrivate)
++  explicit MainThreadWorkerRunnable(WorkerPrivate* aWorkerPrivate)
+   : WorkerRunnable(aWorkerPrivate, WorkerThreadUnchangedBusyCount)
+   {
+     workers::AssertIsOnMainThread();
+   }
+ 
+   virtual ~MainThreadWorkerRunnable()
+   {}
+ 
+   virtual bool
+-  PreDispatch(workers::WorkerPrivate* aWorkerPrivate) override
++  PreDispatch(WorkerPrivate* aWorkerPrivate) override
+   {
+     workers::AssertIsOnMainThread();
+     return true;
+   }
+ 
+   virtual void
+-  PostDispatch(workers::WorkerPrivate* aWorkerPrivate,
++  PostDispatch(WorkerPrivate* aWorkerPrivate,
+                bool aDispatchResult) override
+   {
+     workers::AssertIsOnMainThread();
+   }
+ };
+ 
+ // A convenience class for WorkerControlRunnables that originate on the main
+ // thread.
+ class MainThreadWorkerControlRunnable : public WorkerControlRunnable
+ {
+ protected:
+-  explicit MainThreadWorkerControlRunnable(workers::WorkerPrivate* aWorkerPrivate)
++  explicit MainThreadWorkerControlRunnable(WorkerPrivate* aWorkerPrivate)
+   : WorkerControlRunnable(aWorkerPrivate, WorkerThreadUnchangedBusyCount)
+   { }
+ 
+   virtual ~MainThreadWorkerControlRunnable()
+   { }
+ 
+   virtual bool
+-  PreDispatch(workers::WorkerPrivate* aWorkerPrivate) override
++  PreDispatch(WorkerPrivate* aWorkerPrivate) override
+   {
+     workers::AssertIsOnMainThread();
+     return true;
+   }
+ 
+   virtual void
+-  PostDispatch(workers::WorkerPrivate* aWorkerPrivate,
++  PostDispatch(WorkerPrivate* aWorkerPrivate,
+                bool aDispatchResult) override
+   {
+     workers::AssertIsOnMainThread();
+   }
+ };
+ 
+ // A WorkerRunnable that should be dispatched from the worker to itself for
+ // async tasks. This will increment the busy count PostDispatch() (only if
+ // dispatch was successful) and decrement it in PostRun().
+ //
+ // Async tasks will almost always want to use this since
+ // a WorkerSameThreadRunnable keeps the Worker from being GCed.
+ class WorkerSameThreadRunnable : public WorkerRunnable
+ {
+ protected:
+-  explicit WorkerSameThreadRunnable(workers::WorkerPrivate* aWorkerPrivate)
++  explicit WorkerSameThreadRunnable(WorkerPrivate* aWorkerPrivate)
+   : WorkerRunnable(aWorkerPrivate, WorkerThreadModifyBusyCount)
+   { }
+ 
+   virtual ~WorkerSameThreadRunnable()
+   { }
+ 
+   virtual bool
+-  PreDispatch(workers::WorkerPrivate* aWorkerPrivate) override;
++  PreDispatch(WorkerPrivate* aWorkerPrivate) override;
+ 
+   virtual void
+-  PostDispatch(workers::WorkerPrivate* aWorkerPrivate,
++  PostDispatch(WorkerPrivate* aWorkerPrivate,
+                bool aDispatchResult) override;
+ 
+   // We just delegate PostRun to WorkerRunnable, since it does exactly
+   // what we want.
+ };
+ 
+ // Base class for the runnable objects, which makes a synchronous call to
+ // dispatch the tasks from the worker thread to the main thread.
+ //
+ // Note that the derived class must override MainThreadRun.
+ class WorkerMainThreadRunnable : public Runnable
+ {
+ protected:
+-  workers::WorkerPrivate* mWorkerPrivate;
++  WorkerPrivate* mWorkerPrivate;
+   nsCOMPtr<nsIEventTarget> mSyncLoopTarget;
+   const nsCString mTelemetryKey;
+ 
+-  explicit WorkerMainThreadRunnable(workers::WorkerPrivate* aWorkerPrivate,
++  explicit WorkerMainThreadRunnable(WorkerPrivate* aWorkerPrivate,
+                                     const nsACString& aTelemetryKey);
+   ~WorkerMainThreadRunnable() {}
+ 
+   virtual bool MainThreadRun() = 0;
+ 
+ public:
+   // Dispatch the runnable to the main thread.  If dispatch to main thread
+   // fails, or if the worker is in a state equal or greater of aFailStatus, an
+@@ -427,17 +425,17 @@ private:
+ // says, only to release resources, no JS has to be executed, no timers, or
+ // other things. The reason of such limitations is that, in order to execute
+ // this method in any condition (also when the worker is shutting down), a
+ // Control Runnable is used, and, this could generate a reordering of existing
+ // runnables.
+ class WorkerProxyToMainThreadRunnable : public Runnable
+ {
+ protected:
+-  explicit WorkerProxyToMainThreadRunnable(workers::WorkerPrivate* aWorkerPrivate);
++  explicit WorkerProxyToMainThreadRunnable(WorkerPrivate* aWorkerPrivate);
+ 
+   virtual ~WorkerProxyToMainThreadRunnable();
+ 
+   // First this method is called on the main-thread.
+   virtual void RunOnMainThread() = 0;
+ 
+   // After this second method is called on the worker-thread.
+   virtual void RunBackOnWorkerThreadForCleanup() = 0;
+@@ -449,33 +447,33 @@ private:
+   NS_IMETHOD Run() override;
+ 
+   void PostDispatchOnMainThread();
+ 
+   bool HoldWorker();
+   void ReleaseWorker();
+ 
+ protected:
+-  workers::WorkerPrivate* mWorkerPrivate;
++  WorkerPrivate* mWorkerPrivate;
+   UniquePtr<WorkerHolder> mWorkerHolder;
+ };
+ 
+ // Class for checking API exposure.  This totally violates the "MUST" in the
+ // comments on WorkerMainThreadRunnable::Dispatch, because API exposure checks
+ // can't throw.  Maybe we should change it so they _could_ throw.  But for now
+ // we are bad people and should be ashamed of ourselves.  Let's hope none of
+ // them happen while a worker is shutting down.
+ //
+ // Do NOT copy what this class is doing elsewhere.  Just don't.
+ class WorkerCheckAPIExposureOnMainThreadRunnable
+   : public WorkerMainThreadRunnable
+ {
+ public:
+   explicit
+-  WorkerCheckAPIExposureOnMainThreadRunnable(workers::WorkerPrivate* aWorkerPrivate);
++  WorkerCheckAPIExposureOnMainThreadRunnable(WorkerPrivate* aWorkerPrivate);
+   virtual
+   ~WorkerCheckAPIExposureOnMainThreadRunnable();
+ 
+   // Returns whether the dispatch succeeded.  If this returns false, the API
+   // should not be exposed.
+   bool Dispatch();
+ };
+ 
+@@ -485,43 +483,43 @@ public:
+ // in any way.
+ class MainThreadStopSyncLoopRunnable : public WorkerSyncRunnable
+ {
+   bool mResult;
+ 
+ public:
+   // Passing null for aSyncLoopTarget is not allowed.
+   MainThreadStopSyncLoopRunnable(
+-                               workers::WorkerPrivate* aWorkerPrivate,
++                               WorkerPrivate* aWorkerPrivate,
+                                already_AddRefed<nsIEventTarget>&& aSyncLoopTarget,
+                                bool aResult);
+ 
+   // By default StopSyncLoopRunnables cannot be canceled since they could leave
+   // a sync loop spinning forever.
+   nsresult
+   Cancel() override;
+ 
+ protected:
+   virtual ~MainThreadStopSyncLoopRunnable()
+   { }
+ 
+ private:
+   virtual bool
+-  PreDispatch(workers::WorkerPrivate* aWorkerPrivate) override final
++  PreDispatch(WorkerPrivate* aWorkerPrivate) override final
+   {
+     workers::AssertIsOnMainThread();
+     return true;
+   }
+ 
+   virtual void
+-  PostDispatch(workers::WorkerPrivate* aWorkerPrivate,
++  PostDispatch(WorkerPrivate* aWorkerPrivate,
+                bool aDispatchResult) override;
+ 
+   virtual bool
+-  WorkerRun(JSContext* aCx, workers::WorkerPrivate* aWorkerPrivate) override;
++  WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate) override;
+ 
+   virtual bool
+   DispatchInternal() override final;
+ };
+ 
+ } // dom namespace
+ } // mozilla namespace
+ 
+diff --git a/dom/workers/WorkerScope.cpp b/dom/workers/WorkerScope.cpp
+--- a/dom/workers/WorkerScope.cpp
++++ b/dom/workers/WorkerScope.cpp
+@@ -52,24 +52,24 @@
+ #include "mozilla/dom/ServiceWorkerRegistration.h"
+ 
+ #ifdef XP_WIN
+ #undef PostMessage
+ #endif
+ 
+ extern already_AddRefed<nsIScriptTimeoutHandler>
+ NS_CreateJSTimeoutHandler(JSContext* aCx,
+-                          mozilla::dom::workers::WorkerPrivate* aWorkerPrivate,
++                          mozilla::dom::WorkerPrivate* aWorkerPrivate,
+                           mozilla::dom::Function& aFunction,
+                           const mozilla::dom::Sequence<JS::Value>& aArguments,
+                           mozilla::ErrorResult& aError);
+ 
+ extern already_AddRefed<nsIScriptTimeoutHandler>
+ NS_CreateJSTimeoutHandler(JSContext* aCx,
+-                          mozilla::dom::workers::WorkerPrivate* aWorkerPrivate,
++                          mozilla::dom::WorkerPrivate* aWorkerPrivate,
+                           const nsAString& aExpression);
+ 
+ using namespace mozilla;
+ using namespace mozilla::dom;
+ USING_WORKERS_NAMESPACE
+ 
+ using mozilla::dom::cache::CacheStorage;
+ using mozilla::ipc::PrincipalInfo;
+diff --git a/dom/workers/WorkerScope.h b/dom/workers/WorkerScope.h
+--- a/dom/workers/WorkerScope.h
++++ b/dom/workers/WorkerScope.h
+@@ -2,17 +2,17 @@
+ /* vim: set ts=8 sts=2 et sw=2 tw=80: */
+ /* 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/. */
+ 
+ #ifndef mozilla_dom_workerscope_h__
+ #define mozilla_dom_workerscope_h__
+ 
+-#include "WorkerCommon.h"
++#include "mozilla/dom/workers/WorkerCommon.h"
+ #include "mozilla/DOMEventTargetHelper.h"
+ #include "mozilla/dom/Headers.h"
+ #include "mozilla/dom/RequestBinding.h"
+ #include "nsWeakReference.h"
+ #include "mozilla/dom/ImageBitmapSource.h"
+ 
+ #ifdef XP_WIN
+ #undef PostMessage
+@@ -32,30 +32,25 @@ class Function;
+ class IDBFactory;
+ enum class ImageBitmapFormat : uint8_t;
+ class Performance;
+ class Promise;
+ class RequestOrUSVString;
+ class ServiceWorkerRegistration;
+ class WorkerLocation;
+ class WorkerNavigator;
++class WorkerPrivate;
+ enum class CallerType : uint32_t;
+ 
+ namespace cache {
+ 
+ class CacheStorage;
+ 
+ } // namespace cache
+ 
+-namespace workers {
+-
+-class WorkerPrivate;
+-
+-} // namespace workers
+-
+ class WorkerGlobalScope : public DOMEventTargetHelper,
+                           public nsIGlobalObject,
+                           public nsSupportsWeakReference
+ {
+   typedef mozilla::dom::IDBFactory IDBFactory;
+ 
+   RefPtr<Console> mConsole;
+   RefPtr<Crypto> mCrypto;
+@@ -64,17 +59,16 @@ class WorkerGlobalScope : public DOMEven
+   RefPtr<Performance> mPerformance;
+   RefPtr<IDBFactory> mIndexedDB;
+   RefPtr<cache::CacheStorage> mCacheStorage;
+   nsCOMPtr<nsISerialEventTarget> mSerialEventTarget;
+ 
+   uint32_t mWindowInteractionsAllowed;
+ 
+ protected:
+-  typedef mozilla::dom::workers::WorkerPrivate WorkerPrivate;
+   WorkerPrivate* mWorkerPrivate;
+ 
+   explicit WorkerGlobalScope(WorkerPrivate* aWorkerPrivate);
+   virtual ~WorkerGlobalScope();
+ 
+ public:
+   virtual JSObject*
+   WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
+@@ -350,18 +344,16 @@ public:
+                    const dom::AddEventListenerOptionsOrBoolean& aOptions,
+                    const dom::Nullable<bool>& aWantsUntrusted,
+                    ErrorResult& aRv) override;
+ };
+ 
+ class WorkerDebuggerGlobalScope final : public DOMEventTargetHelper,
+                                         public nsIGlobalObject
+ {
+-  typedef mozilla::dom::workers::WorkerPrivate WorkerPrivate;
+-
+   WorkerPrivate* mWorkerPrivate;
+   RefPtr<Console> mConsole;
+   nsCOMPtr<nsISerialEventTarget> mSerialEventTarget;
+ 
+ public:
+   explicit WorkerDebuggerGlobalScope(WorkerPrivate* aWorkerPrivate);
+ 
+   NS_DECL_ISUPPORTS_INHERITED
+diff --git a/dom/workers/WorkerThread.cpp b/dom/workers/WorkerThread.cpp
+--- a/dom/workers/WorkerThread.cpp
++++ b/dom/workers/WorkerThread.cpp
+@@ -14,20 +14,20 @@
+ #include "WorkerPrivate.h"
+ #include "WorkerRunnable.h"
+ 
+ #ifdef DEBUG
+ #include "nsThreadManager.h"
+ #endif
+ 
+ namespace mozilla {
+-namespace dom {
+ 
+-using namespace workers;
+-using namespace mozilla::ipc;
++using namespace ipc;
++
++namespace dom {
+ 
+ namespace {
+ 
+ // The C stack size. We use the same stack size on all platforms for
+ // consistency.
+ const uint32_t kWorkerStackSize = 256 * sizeof(size_t) * 1024;
+ 
+ } // namespace
+diff --git a/dom/workers/WorkerThread.h b/dom/workers/WorkerThread.h
+--- a/dom/workers/WorkerThread.h
++++ b/dom/workers/WorkerThread.h
+@@ -15,46 +15,46 @@
+ #include "nsThread.h"
+ 
+ class nsIRunnable;
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+ class WorkerRunnable;
++class WorkerPrivate;
++template <class> class WorkerPrivateParent;
+ 
+ namespace workers {
+ class RuntimeService;
+-class WorkerPrivate;
+-template <class> class WorkerPrivateParent;
+ }
+ 
+ // This class lets us restrict the public methods that can be called on
+ // WorkerThread to RuntimeService and WorkerPrivate without letting them gain
+ // full access to private methods (as would happen if they were simply friends).
+ class WorkerThreadFriendKey
+ {
+   friend class workers::RuntimeService;
+-  friend class workers::WorkerPrivate;
+-  friend class workers::WorkerPrivateParent<workers::WorkerPrivate>;
++  friend class WorkerPrivate;
++  friend class WorkerPrivateParent<WorkerPrivate>;
+ 
+   WorkerThreadFriendKey();
+   ~WorkerThreadFriendKey();
+ };
+ 
+ class WorkerThread final
+   : public nsThread
+ {
+   class Observer;
+ 
+   Mutex mLock;
+   CondVar mWorkerPrivateCondVar;
+ 
+   // Protected by nsThread::mLock.
+-  workers::WorkerPrivate* mWorkerPrivate;
++  WorkerPrivate* mWorkerPrivate;
+ 
+   // Only touched on the target thread.
+   RefPtr<Observer> mObserver;
+ 
+   // Protected by nsThread::mLock and waited on with mWorkerPrivateCondVar.
+   uint32_t mOtherThreadsDispatchingViaEventTarget;
+ 
+ #ifdef DEBUG
+@@ -63,17 +63,17 @@ class WorkerThread final
+ #endif
+ 
+ public:
+   static already_AddRefed<WorkerThread>
+   Create(const WorkerThreadFriendKey& aKey);
+ 
+   void
+   SetWorker(const WorkerThreadFriendKey& aKey,
+-            workers::WorkerPrivate* aWorkerPrivate);
++            WorkerPrivate* aWorkerPrivate);
+ 
+   nsresult
+   DispatchPrimaryRunnable(const WorkerThreadFriendKey& aKey,
+                           already_AddRefed<nsIRunnable> aRunnable);
+ 
+   nsresult
+   DispatchAnyThread(const WorkerThreadFriendKey& aKey,
+            already_AddRefed<WorkerRunnable> aWorkerRunnable);
+diff --git a/dom/workers/moz.build b/dom/workers/moz.build
+--- a/dom/workers/moz.build
++++ b/dom/workers/moz.build
+@@ -18,16 +18,17 @@ EXPORTS.mozilla.dom += [
+     'WorkerLocation.h',
+     'WorkerNavigator.h',
+     'WorkerPrivate.h',
+     'WorkerRunnable.h',
+     'WorkerScope.h',
+ ]
+ 
+ EXPORTS.mozilla.dom.workers += [
++    'Queue.h',
+     'RuntimeService.h',
+     'WorkerCommon.h',
+ ]
+ 
+ XPIDL_MODULE = 'dom_workers'
+ 
+ XPIDL_SOURCES += [
+     'nsIWorkerDebugger.idl',
+diff --git a/dom/xhr/XMLHttpRequestWorker.cpp b/dom/xhr/XMLHttpRequestWorker.cpp
+--- a/dom/xhr/XMLHttpRequestWorker.cpp
++++ b/dom/xhr/XMLHttpRequestWorker.cpp
+@@ -35,18 +35,16 @@
+ #include "WorkerRunnable.h"
+ #include "XMLHttpRequestUpload.h"
+ 
+ #include "mozilla/UniquePtr.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+-using namespace workers;
+-
+ /* static */ void
+ XMLHttpRequestWorker::StateData::trace(JSTracer *aTrc)
+ {
+   JS::TraceEdge(aTrc, &mResponse, "XMLHttpRequestWorker::StateData::mResponse");
+ }
+ 
+ /**
+  *  XMLHttpRequest in workers
+@@ -159,27 +157,27 @@ public:
+   Teardown(bool aSendUnpin);
+ 
+   bool
+   AddRemoveEventListeners(bool aUpload, bool aAdd);
+ 
+   void
+   Reset()
+   {
+-    AssertIsOnMainThread();
++    workers::AssertIsOnMainThread();
+ 
+     if (mUploadEventListenersAttached) {
+       AddRemoveEventListeners(true, false);
+     }
+   }
+ 
+   already_AddRefed<nsIEventTarget>
+   GetEventTarget()
+   {
+-    AssertIsOnMainThread();
++    workers::AssertIsOnMainThread();
+ 
+     nsCOMPtr<nsIEventTarget> target = mSyncEventResponseTarget ?
+                                       mSyncEventResponseTarget :
+                                       mSyncLoopTarget;
+     return target.forget();
+   }
+ 
+ private:
+@@ -370,17 +368,17 @@ public:
+ 
+ private:
+   ~AsyncTeardownRunnable()
+   { }
+ 
+   NS_IMETHOD
+   Run() override
+   {
+-    AssertIsOnMainThread();
++    workers::AssertIsOnMainThread();
+ 
+     // This means the XHR was GC'd, so we can't be pinned, and we don't need to
+     // try to unpin.
+     mProxy->Teardown(/* aSendUnpin */ false);
+     mProxy = nullptr;
+ 
+     return NS_OK;
+   }
+@@ -447,42 +445,42 @@ public:
+     : Runnable("dom::LoadStartDetectionRunnable")
+     , mWorkerPrivate(aProxy->mWorkerPrivate)
+     , mProxy(aProxy)
+     , mXHR(aProxy->mXHR)
+     , mXMLHttpRequestPrivate(aXHRPrivate)
+     , mChannelId(mProxy->mInnerChannelId)
+     , mReceivedLoadStart(false)
+   {
+-    AssertIsOnMainThread();
++    workers::AssertIsOnMainThread();
+     CopyASCIItoUTF16(sEventStrings[STRING_loadstart], mEventType);
+   }
+ 
+   NS_DECL_ISUPPORTS_INHERITED
+   NS_DECL_NSIRUNNABLE
+   NS_DECL_NSIDOMEVENTLISTENER
+ 
+   bool
+   RegisterAndDispatch()
+   {
+-    AssertIsOnMainThread();
++    workers::AssertIsOnMainThread();
+ 
+     if (NS_FAILED(mXHR->AddEventListener(mEventType, this, false, false, 2))) {
+       NS_WARNING("Failed to add event listener!");
+       return false;
+     }
+ 
+     return NS_SUCCEEDED(mWorkerPrivate->DispatchToMainThread(this));
+   }
+ 
+ private:
+   ~LoadStartDetectionRunnable()
+   {
+-    AssertIsOnMainThread();
+-    }
++    workers::AssertIsOnMainThread();
++  }
+ };
+ 
+ class EventRunnable final : public MainThreadProxyRunnable
+                           , public StructuredCloneHolder
+ {
+   nsString mType;
+   nsString mResponseType;
+   JS::Heap<JS::Value> mResponse;
+@@ -850,17 +848,17 @@ public:
+   }
+ };
+ 
+ } // namespace
+ 
+ bool
+ Proxy::Init()
+ {
+-  AssertIsOnMainThread();
++  workers::AssertIsOnMainThread();
+   MOZ_ASSERT(mWorkerPrivate);
+ 
+   if (mXHR) {
+     return true;
+   }
+ 
+   nsPIDOMWindowInner* ownerWindow = mWorkerPrivate->GetWindow();
+   if (ownerWindow && !ownerWindow->IsCurrentInnerWindow()) {
+@@ -893,17 +891,17 @@ Proxy::Init()
+   }
+ 
+   return true;
+ }
+ 
+ void
+ Proxy::Teardown(bool aSendUnpin)
+ {
+-  AssertIsOnMainThread();
++  workers::AssertIsOnMainThread();
+ 
+   if (mXHR) {
+     Reset();
+ 
+     // NB: We are intentionally dropping events coming from xhr.abort on the
+     // floor.
+     AddRemoveEventListeners(false, false);
+ 
+@@ -943,17 +941,17 @@ Proxy::Teardown(bool aSendUnpin)
+ 
+   MOZ_ASSERT(!mWorkerPrivate);
+   MOZ_ASSERT(!mSyncLoopTarget);
+ }
+ 
+ bool
+ Proxy::AddRemoveEventListeners(bool aUpload, bool aAdd)
+ {
+-  AssertIsOnMainThread();
++  workers::AssertIsOnMainThread();
+ 
+   NS_ASSERTION(!aUpload ||
+                (mUploadEventListenersAttached && !aAdd) ||
+                (!mUploadEventListenersAttached && aAdd),
+                "Messed up logic for upload listeners!");
+ 
+   nsCOMPtr<nsIDOMEventTarget> target =
+     aUpload ?
+@@ -983,17 +981,17 @@ Proxy::AddRemoveEventListeners(bool aUpl
+   return true;
+ }
+ 
+ NS_IMPL_ISUPPORTS(Proxy, nsIDOMEventListener)
+ 
+ NS_IMETHODIMP
+ Proxy::HandleEvent(nsIDOMEvent* aEvent)
+ {
+-  AssertIsOnMainThread();
++  workers::AssertIsOnMainThread();
+ 
+   if (!mWorkerPrivate || !mXMLHttpRequestPrivate) {
+     NS_ERROR("Shouldn't get here!");
+     return NS_OK;
+   }
+ 
+   nsString type;
+   if (NS_FAILED(aEvent->GetType(type))) {
+@@ -1064,17 +1062,17 @@ Proxy::HandleEvent(nsIDOMEvent* aEvent)
+ }
+ 
+ NS_IMPL_ISUPPORTS_INHERITED(LoadStartDetectionRunnable, Runnable,
+                                                         nsIDOMEventListener)
+ 
+ NS_IMETHODIMP
+ LoadStartDetectionRunnable::Run()
+ {
+-  AssertIsOnMainThread();
++  workers::AssertIsOnMainThread();
+ 
+   if (NS_FAILED(mXHR->RemoveEventListener(mEventType, this, false))) {
+     NS_WARNING("Failed to remove event listener!");
+   }
+ 
+   if (!mReceivedLoadStart) {
+     if (mProxy->mOutstandingSendCount > 1) {
+       mProxy->mOutstandingSendCount--;
+@@ -1096,17 +1094,17 @@ LoadStartDetectionRunnable::Run()
+   mXHR = nullptr;
+   mXMLHttpRequestPrivate = nullptr;
+   return NS_OK;
+ }
+ 
+ NS_IMETHODIMP
+ LoadStartDetectionRunnable::HandleEvent(nsIDOMEvent* aEvent)
+ {
+-  AssertIsOnMainThread();
++  workers::AssertIsOnMainThread();
+ 
+ #ifdef DEBUG
+   {
+     nsString type;
+     if (NS_SUCCEEDED(aEvent->GetType(type))) {
+       MOZ_ASSERT(type == mEventType);
+     }
+     else {
+@@ -1117,17 +1115,17 @@ LoadStartDetectionRunnable::HandleEvent(
+ 
+   mReceivedLoadStart = true;
+   return NS_OK;
+ }
+ 
+ bool
+ EventRunnable::PreDispatch(WorkerPrivate* /* unused */)
+ {
+-  AssertIsOnMainThread();
++  workers::AssertIsOnMainThread();
+ 
+   AutoJSAPI jsapi;
+   DebugOnly<bool> ok = jsapi.Init(xpc::NativeGlobal(mScopeObj));
+   MOZ_ASSERT(ok);
+   JSContext* cx = jsapi.cx();
+   // Now keep the mScopeObj alive for the duration
+   JS::Rooted<JSObject*> scopeObj(cx, mScopeObj);
+   // And reset mScopeObj now, before we have a chance to run its destructor on
+@@ -1372,17 +1370,17 @@ EventRunnable::WorkerRun(JSContext* aCx,
+   }
+ 
+   return true;
+ }
+ 
+ bool
+ WorkerThreadProxySyncRunnable::MainThreadRun()
+ {
+-  AssertIsOnMainThread();
++  workers::AssertIsOnMainThread();
+ 
+   nsCOMPtr<nsIEventTarget> tempTarget = mSyncLoopTarget;
+ 
+   mProxy->mSyncEventResponseTarget.swap(tempTarget);
+ 
+   ErrorResult rv;
+   RunOnMainThread(rv);
+   mErrorCode = rv.StealNSResult();
+diff --git a/dom/xhr/XMLHttpRequestWorker.h b/dom/xhr/XMLHttpRequestWorker.h
+--- a/dom/xhr/XMLHttpRequestWorker.h
++++ b/dom/xhr/XMLHttpRequestWorker.h
+@@ -13,20 +13,17 @@
+ #include "mozilla/dom/TypedArray.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+ class Proxy;
+ class SendRunnable;
+ class DOMString;
+-
+-namespace workers {
+ class WorkerPrivate;
+-}
+ 
+ class XMLHttpRequestWorker final : public XMLHttpRequest,
+                                    public WorkerHolder
+ {
+ public:
+   struct StateData
+   {
+     XMLHttpRequestStringSnapshot mResponseText;
+@@ -46,17 +43,17 @@ public:
+       mStatusResult(NS_OK), mResponseResult(NS_OK)
+     { }
+ 
+     void trace(JSTracer* trc);
+   };
+ 
+ private:
+   RefPtr<XMLHttpRequestUpload> mUpload;
+-  workers::WorkerPrivate* mWorkerPrivate;
++  WorkerPrivate* mWorkerPrivate;
+   RefPtr<Proxy> mProxy;
+   XMLHttpRequestResponseType mResponseType;
+   StateData mStateData;
+ 
+   uint32_t mTimeout;
+ 
+   bool mRooted;
+   bool mBackgroundRequest;
+@@ -280,17 +277,17 @@ public:
+ 
+   bool
+   SendInProgress() const
+   {
+     return mRooted;
+   }
+ 
+ private:
+-  explicit XMLHttpRequestWorker(workers::WorkerPrivate* aWorkerPrivate);
++  explicit XMLHttpRequestWorker(WorkerPrivate* aWorkerPrivate);
+   ~XMLHttpRequestWorker();
+ 
+   enum ReleaseType { Default, XHRIsGoingAway, WorkerIsGoingAway };
+ 
+   void
+   ReleaseProxy(ReleaseType aType = Default);
+ 
+   void
+diff --git a/gfx/thebes/gfxUtils.cpp b/gfx/thebes/gfxUtils.cpp
+--- a/gfx/thebes/gfxUtils.cpp
++++ b/gfx/thebes/gfxUtils.cpp
+@@ -1408,17 +1408,17 @@ gfxUtils::GetInputStream(gfx::DataSource
+                                              aSurface->GetSize().height,
+                                              imageBuffer.get(), format,
+                                              encoder, aEncoderOptions, outStream);
+ }
+ 
+ class GetFeatureStatusRunnable final : public dom::WorkerMainThreadRunnable
+ {
+ public:
+-    GetFeatureStatusRunnable(dom::workers::WorkerPrivate* workerPrivate,
++    GetFeatureStatusRunnable(dom::WorkerPrivate* workerPrivate,
+                              const nsCOMPtr<nsIGfxInfo>& gfxInfo,
+                              int32_t feature,
+                              nsACString& failureId,
+                              int32_t* status)
+       : WorkerMainThreadRunnable(workerPrivate,
+                                  NS_LITERAL_CSTRING("GFX :: GetFeatureStatus"))
+       , mGfxInfo(gfxInfo)
+       , mFeature(feature)
+@@ -1453,18 +1453,17 @@ private:
+ };
+ 
+ /* static */ nsresult
+ gfxUtils::ThreadSafeGetFeatureStatus(const nsCOMPtr<nsIGfxInfo>& gfxInfo,
+                                      int32_t feature, nsACString& failureId,
+                                      int32_t* status)
+ {
+   if (!NS_IsMainThread()) {
+-    dom::workers::WorkerPrivate* workerPrivate =
+-      dom::workers::GetCurrentThreadWorkerPrivate();
++    dom::WorkerPrivate* workerPrivate = dom::GetCurrentThreadWorkerPrivate();
+ 
+     RefPtr<GetFeatureStatusRunnable> runnable =
+       new GetFeatureStatusRunnable(workerPrivate, gfxInfo, feature, failureId,
+                                    status);
+ 
+     ErrorResult rv;
+     runnable->Dispatch(dom::WorkerStatus::Terminating, rv);
+     if (rv.Failed()) {
+diff --git a/ipc/glue/IPCStreamSource.cpp b/ipc/glue/IPCStreamSource.cpp
+--- a/ipc/glue/IPCStreamSource.cpp
++++ b/ipc/glue/IPCStreamSource.cpp
+@@ -8,18 +8,18 @@
+ #include "mozilla/webrender/WebRenderTypes.h"
+ #include "nsIAsyncInputStream.h"
+ #include "nsICancelableRunnable.h"
+ #include "nsIRunnable.h"
+ #include "nsISerialEventTarget.h"
+ #include "nsStreamUtils.h"
+ #include "nsThreadUtils.h"
+ 
+-using mozilla::dom::workers::GetCurrentThreadWorkerPrivate;
+-using mozilla::dom::workers::WorkerPrivate;
++using mozilla::dom::GetCurrentThreadWorkerPrivate;
++using mozilla::dom::WorkerPrivate;
+ using mozilla::dom::WorkerStatus;
+ using mozilla::wr::ByteBuffer;
+ 
+ namespace mozilla {
+ namespace ipc {
+ 
+ class IPCStreamSource::Callback final : public nsIInputStreamCallback
+                                       , public nsIRunnable
+diff --git a/ipc/glue/IPCStreamSource.h b/ipc/glue/IPCStreamSource.h
+--- a/ipc/glue/IPCStreamSource.h
++++ b/ipc/glue/IPCStreamSource.h
+@@ -132,17 +132,17 @@ private:
+   void OnStreamReady(Callback* aCallback);
+ 
+   nsCOMPtr<nsIAsyncInputStream> mStream;
+   RefPtr<Callback> mCallback;
+ 
+   // Raw pointer because this IPCStreamSource keeps the worker alive using a
+   // WorkerHolder. The worker is kept alive when the actor is created and,
+   // released when the actor is destroyed.
+-  dom::workers::WorkerPrivate* mWorkerPrivate;
++  dom::WorkerPrivate* mWorkerPrivate;
+ 
+ #ifdef DEBUG
+ protected:
+ #endif
+ 
+   enum {
+    ePending,
+    eActorConstructed,
+diff --git a/js/xpconnect/src/nsXPConnect.cpp b/js/xpconnect/src/nsXPConnect.cpp
+--- a/js/xpconnect/src/nsXPConnect.cpp
++++ b/js/xpconnect/src/nsXPConnect.cpp
+@@ -1321,27 +1321,25 @@ IsChromeOrXBL(JSContext* cx, JSObject* /
+     // compat and not security for remote XUL, we just always claim to be XBL.
+     //
+     // Note that, for performance, we don't check AllowXULXBLForPrincipal here,
+     // and instead rely on the fact that AllowContentXBLScope() only returns false in
+     // remote XUL situations.
+     return AccessCheck::isChrome(c) || IsContentXBLCompartment(c) || !AllowContentXBLScope(realm);
+ }
+ 
+-namespace workers {
+ extern bool IsCurrentThreadRunningChromeWorker();
+-} // namespace workers
+ 
+ bool
+ ThreadSafeIsChromeOrXBL(JSContext* cx, JSObject* obj)
+ {
+     if (NS_IsMainThread()) {
+         return IsChromeOrXBL(cx, obj);
+     }
+-    return workers::IsCurrentThreadRunningChromeWorker();
++    return IsCurrentThreadRunningChromeWorker();
+ }
+ 
+ } // namespace dom
+ } // namespace mozilla
+ 
+ void
+ xpc::CreateCooperativeContext()
+ {

+ 1186 - 0
mozilla-release/patches/1432963-15-60a1.patch

@@ -0,0 +1,1186 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1517383470 -3600
+# Node ID 7a858acf697e98a60921123fb4866a41834f0f87
+# Parent  af31f41a5011a76a5a387dadff483a06878bbdda
+Bug 1432963 - Fixing workers headers - part 15 - static function in a workers namespace, r=smaug
+
+diff --git a/dom/base/ImageEncoder.cpp b/dom/base/ImageEncoder.cpp
+--- a/dom/base/ImageEncoder.cpp
++++ b/dom/base/ImageEncoder.cpp
+@@ -84,17 +84,17 @@ public:
+   explicit EncodingCompleteEvent(EncodeCompleteCallback* aEncodeCompleteCallback)
+     : CancelableRunnable("EncodingCompleteEvent")
+     , mImgSize(0)
+     , mType()
+     , mImgData(nullptr)
+     , mEncodeCompleteCallback(aEncodeCompleteCallback)
+     , mFailed(false)
+   {
+-    if (!NS_IsMainThread() && GetCurrentThreadWorkerPrivate()) {
++    if (!NS_IsMainThread() && workers::GetCurrentThreadWorkerPrivate()) {
+       mCreationEventTarget = GetCurrentThreadEventTarget();
+     } else {
+       mCreationEventTarget = GetMainThreadEventTarget();
+     }
+   }
+ 
+   NS_IMETHOD Run() override
+   {
+diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp
+--- a/dom/base/nsContentUtils.cpp
++++ b/dom/base/nsContentUtils.cpp
+@@ -2512,17 +2512,17 @@ nsContentUtils::CalcRoundedWindowSizeFor
+   *aOutputHeight = resultHeight;
+ }
+ 
+ bool
+ nsContentUtils::ThreadsafeIsCallerChrome()
+ {
+   return NS_IsMainThread() ?
+     IsCallerChrome() :
+-    mozilla::dom::IsCurrentThreadRunningChromeWorker();
++    workers::IsCurrentThreadRunningChromeWorker();
+ }
+ 
+ bool
+ nsContentUtils::IsCallerContentXBL()
+ {
+   JSContext *cx = GetCurrentJSContext();
+   if (!cx)
+     return false;
+@@ -2551,17 +2551,17 @@ nsContentUtils::IsSystemCaller(JSContext
+ 
+ bool
+ nsContentUtils::ThreadsafeIsSystemCaller(JSContext* aCx)
+ {
+   if (NS_IsMainThread()) {
+     return IsSystemCaller(aCx);
+   }
+ 
+-  return GetWorkerPrivateFromContext(aCx)->UsesSystemPrincipal();
++  return workers::GetWorkerPrivateFromContext(aCx)->UsesSystemPrincipal();
+ }
+ 
+ // static
+ bool
+ nsContentUtils::LookupBindingMember(JSContext* aCx, nsIContent *aContent,
+                                     JS::Handle<jsid> aId,
+                                     JS::MutableHandle<JS::PropertyDescriptor> aDesc)
+ {
+@@ -6208,17 +6208,17 @@ nsContentUtils::GetCurrentJSContext()
+ /* static */
+ JSContext *
+ nsContentUtils::GetCurrentJSContextForThread()
+ {
+   MOZ_ASSERT(IsInitialized());
+   if (MOZ_LIKELY(NS_IsMainThread())) {
+     return GetCurrentJSContext();
+   }
+-  return GetCurrentThreadJSContext();
++  return workers::GetCurrentThreadJSContext();
+ }
+ 
+ template<typename StringType, typename CharType>
+ void
+ _ASCIIToLowerInSitu(StringType& aStr)
+ {
+   CharType* iter = aStr.BeginWriting();
+   CharType* end = aStr.EndWriting();
+diff --git a/dom/clients/api/Client.cpp b/dom/clients/api/Client.cpp
+--- a/dom/clients/api/Client.cpp
++++ b/dom/clients/api/Client.cpp
+@@ -14,16 +14,17 @@
+ #include "mozilla/dom/Promise.h"
+ #include "mozilla/dom/WorkerPrivate.h"
+ #include "mozilla/dom/WorkerScope.h"
+ #include "nsIGlobalObject.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
++using namespace workers;
+ using mozilla::dom::ipc::StructuredCloneData;
+ 
+ NS_IMPL_CYCLE_COLLECTING_ADDREF(mozilla::dom::Client);
+ NS_IMPL_CYCLE_COLLECTING_RELEASE(mozilla::dom::Client);
+ NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(mozilla::dom::Client, mGlobal);
+ 
+ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(mozilla::dom::Client)
+   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
+diff --git a/dom/clients/api/ClientDOMUtil.h b/dom/clients/api/ClientDOMUtil.h
+--- a/dom/clients/api/ClientDOMUtil.h
++++ b/dom/clients/api/ClientDOMUtil.h
+@@ -23,17 +23,18 @@ template<typename Func, typename Arg, ty
+ void
+ StartClientManagerOp(Func aFunc, const Arg& aArg, nsISerialEventTarget* aTarget,
+                      Resolve aResolve, Reject aReject)
+ {
+   using mozilla::dom::WorkerStatus::Closing;
+ 
+   RefPtr<WorkerHolderToken> token;
+   if (!NS_IsMainThread()) {
+-    token = WorkerHolderToken::Create(GetCurrentThreadWorkerPrivate(), Closing);
++    token = WorkerHolderToken::Create(workers::GetCurrentThreadWorkerPrivate(),
++                                      Closing);
+   }
+ 
+   RefPtr<ClientOpPromise> promise = aFunc(aArg, aTarget);
+   promise->Then(aTarget, __func__,
+     [aResolve, token](const ClientOpResult& aResult) {
+       if (token && token->IsShuttingDown()) {
+         return;
+       }
+diff --git a/dom/clients/api/Clients.cpp b/dom/clients/api/Clients.cpp
+--- a/dom/clients/api/Clients.cpp
++++ b/dom/clients/api/Clients.cpp
+@@ -16,16 +16,17 @@
+ #include "mozilla/dom/WorkerPrivate.h"
+ #include "mozilla/SystemGroup.h"
+ #include "nsIGlobalObject.h"
+ #include "nsString.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
++using namespace workers;
+ using mozilla::ipc::PrincipalInfo;
+ 
+ NS_IMPL_CYCLE_COLLECTING_ADDREF(Clients);
+ NS_IMPL_CYCLE_COLLECTING_RELEASE(Clients);
+ NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(Clients, mGlobal);
+ 
+ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(Clients)
+   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
+diff --git a/dom/clients/manager/ClientManager.cpp b/dom/clients/manager/ClientManager.cpp
+--- a/dom/clients/manager/ClientManager.cpp
++++ b/dom/clients/manager/ClientManager.cpp
+@@ -37,17 +37,17 @@ ClientManager::ClientManager()
+   PBackgroundChild* parentActor = BackgroundChild::GetOrCreateForCurrentThread();
+   if (NS_WARN_IF(!parentActor)) {
+     Shutdown();
+     return;
+   }
+ 
+   RefPtr<WorkerHolderToken> workerHolderToken;
+   if (!NS_IsMainThread()) {
+-    WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
++    WorkerPrivate* workerPrivate = workers::GetCurrentThreadWorkerPrivate();
+     MOZ_DIAGNOSTIC_ASSERT(workerPrivate);
+ 
+     workerHolderToken =
+       WorkerHolderToken::Create(workerPrivate, Closing,
+                                 WorkerHolderToken::AllowIdleShutdownStart);
+     if (NS_WARN_IF(!workerHolderToken)) {
+       Shutdown();
+       return;
+diff --git a/dom/crypto/WebCryptoTask.cpp b/dom/crypto/WebCryptoTask.cpp
+--- a/dom/crypto/WebCryptoTask.cpp
++++ b/dom/crypto/WebCryptoTask.cpp
+@@ -148,17 +148,17 @@ class WebCryptoTask::InternalWorkerHolde
+     // worker automatically.
+   }
+ 
+ public:
+   static already_AddRefed<InternalWorkerHolder>
+   Create()
+   {
+     MOZ_ASSERT(!NS_IsMainThread());
+-    WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
++    WorkerPrivate* workerPrivate = workers::GetCurrentThreadWorkerPrivate();
+     MOZ_ASSERT(workerPrivate);
+     RefPtr<InternalWorkerHolder> ref = new InternalWorkerHolder();
+     if (NS_WARN_IF(!ref->HoldWorker(workerPrivate, Canceling))) {
+       return nullptr;
+     }
+     return ref.forget();
+   }
+ 
+diff --git a/dom/events/Event.cpp b/dom/events/Event.cpp
+--- a/dom/events/Event.cpp
++++ b/dom/events/Event.cpp
+@@ -329,17 +329,17 @@ Event::SetTrusted(bool aTrusted)
+ {
+   mEvent->mFlags.mIsTrusted = aTrusted;
+ }
+ 
+ bool
+ Event::Init(mozilla::dom::EventTarget* aGlobal)
+ {
+   if (!mIsMainThreadEvent) {
+-    return IsCurrentThreadRunningChromeWorker();
++    return workers::IsCurrentThreadRunningChromeWorker();
+   }
+   bool trusted = false;
+   nsCOMPtr<nsPIDOMWindowInner> w = do_QueryInterface(aGlobal);
+   if (w) {
+     nsCOMPtr<nsIDocument> d = w->GetExtantDoc();
+     if (d) {
+       trusted = nsContentUtils::IsChromeDoc(d);
+       nsIPresShell* s = d->GetShell();
+@@ -1113,17 +1113,17 @@ Event::TimeStampImpl() const
+     Performance* perf = win->GetPerformance();
+     if (NS_WARN_IF(!perf)) {
+       return 0.0;
+     }
+ 
+     return perf->GetDOMTiming()->TimeStampToDOMHighRes(mEvent->mTimeStamp);
+   }
+ 
+-  WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
++  WorkerPrivate* workerPrivate = workers::GetCurrentThreadWorkerPrivate();
+   MOZ_ASSERT(workerPrivate);
+ 
+   return workerPrivate->TimeStampToDOMHighRes(mEvent->mTimeStamp);
+ }
+ 
+ double
+ Event::TimeStamp() const
+ {
+diff --git a/dom/events/EventDispatcher.cpp b/dom/events/EventDispatcher.cpp
+--- a/dom/events/EventDispatcher.cpp
++++ b/dom/events/EventDispatcher.cpp
+@@ -920,17 +920,17 @@ EventDispatcher::DispatchDOMEvent(nsISup
+       innerEvent->mOriginalTarget = nullptr;
+     } else {
+       aDOMEvent->GetIsTrusted(&dontResetTrusted);
+     }
+ 
+     if (!dontResetTrusted) {
+       //Check security state to determine if dispatcher is trusted
+       bool trusted = NS_IsMainThread() ? nsContentUtils::LegacyIsCallerChromeOrNativeCode()
+-                                       : mozilla::dom::IsCurrentThreadRunningChromeWorker();
++                                       : mozilla::dom::workers::IsCurrentThreadRunningChromeWorker();
+       aDOMEvent->SetTrusted(trusted);
+     }
+ 
+     return EventDispatcher::Dispatch(aTarget, aPresContext, innerEvent,
+                                      aDOMEvent, aEventStatus);
+   } else if (aEvent) {
+     return EventDispatcher::Dispatch(aTarget, aPresContext, aEvent,
+                                      aDOMEvent, aEventStatus);
+diff --git a/dom/events/JSEventHandler.cpp b/dom/events/JSEventHandler.cpp
+--- a/dom/events/JSEventHandler.cpp
++++ b/dom/events/JSEventHandler.cpp
+@@ -121,17 +121,17 @@ JSEventHandler::HandleEvent(nsIDOMEvent*
+ 
+   Event* event = aEvent->InternalDOMEvent();
+   bool isMainThread = event->IsMainThreadEvent();
+   bool isChromeHandler =
+     isMainThread ?
+       nsContentUtils::ObjectPrincipal(
+         GetTypedEventHandler().Ptr()->CallbackPreserveColor()) ==
+         nsContentUtils::GetSystemPrincipal() :
+-      mozilla::dom::IsCurrentThreadRunningChromeWorker();
++      mozilla::dom::workers::IsCurrentThreadRunningChromeWorker();
+ 
+   if (mTypedHandler.Type() == TypedEventHandler::eOnError) {
+     MOZ_ASSERT_IF(mEventName, mEventName == nsGkAtoms::onerror);
+ 
+     nsString errorMsg, file;
+     EventOrString msgOrEvent;
+     Optional<nsAString> fileName;
+     Optional<uint32_t> lineNumber;
+diff --git a/dom/file/FileBlobImpl.cpp b/dom/file/FileBlobImpl.cpp
+--- a/dom/file/FileBlobImpl.cpp
++++ b/dom/file/FileBlobImpl.cpp
+@@ -164,17 +164,17 @@ FileBlobImpl::GetType(nsAString& aType)
+ {
+   aType.Truncate();
+ 
+   if (mContentType.IsVoid()) {
+     MOZ_ASSERT(mWholeFile,
+                "Should only use lazy ContentType when using the whole file");
+ 
+     if (!NS_IsMainThread()) {
+-      WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
++      WorkerPrivate* workerPrivate = workers::GetCurrentThreadWorkerPrivate();
+       if (!workerPrivate) {
+         // I have no idea in which thread this method is called. We cannot
+         // return any valid value.
+         return;
+       }
+ 
+       RefPtr<GetTypeRunnable> runnable =
+         new GetTypeRunnable(workerPrivate, this);
+diff --git a/dom/file/FileReader.cpp b/dom/file/FileReader.cpp
+--- a/dom/file/FileReader.cpp
++++ b/dom/file/FileReader.cpp
+@@ -135,17 +135,17 @@ FileReader::~FileReader()
+ /* static */ already_AddRefed<FileReader>
+ FileReader::Constructor(const GlobalObject& aGlobal, ErrorResult& aRv)
+ {
+   nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(aGlobal.GetAsSupports());
+   WorkerPrivate* workerPrivate = nullptr;
+ 
+   if (!NS_IsMainThread()) {
+     JSContext* cx = aGlobal.Context();
+-    workerPrivate = GetWorkerPrivateFromContext(cx);
++    workerPrivate = workers::GetWorkerPrivateFromContext(cx);
+     MOZ_ASSERT(workerPrivate);
+   }
+ 
+   RefPtr<FileReader> fileReader = new FileReader(global, workerPrivate);
+ 
+   return fileReader.forget();
+ }
+ 
+diff --git a/dom/file/FileReaderSync.cpp b/dom/file/FileReaderSync.cpp
+--- a/dom/file/FileReaderSync.cpp
++++ b/dom/file/FileReaderSync.cpp
+@@ -438,17 +438,17 @@ FileReaderSync::SyncRead(nsIInputStream*
+   }
+ 
+   // We need to proceed async.
+   nsCOMPtr<nsIAsyncInputStream> asyncStream = do_QueryInterface(aStream);
+   if (!asyncStream) {
+     return rv;
+   }
+ 
+-  WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
++  WorkerPrivate* workerPrivate = workers::GetCurrentThreadWorkerPrivate();
+   MOZ_ASSERT(workerPrivate);
+ 
+   AutoSyncLoopHolder syncLoop(workerPrivate, Closing);
+ 
+   nsCOMPtr<nsIEventTarget> syncLoopTarget = syncLoop.GetEventTarget();
+   if (!syncLoopTarget) {
+     // SyncLoop creation can fail if the worker is shutting down.
+     return NS_ERROR_DOM_INVALID_STATE_ERR;
+diff --git a/dom/notification/Notification.cpp b/dom/notification/Notification.cpp
+--- a/dom/notification/Notification.cpp
++++ b/dom/notification/Notification.cpp
+@@ -54,17 +54,17 @@
+ #include "nsXULAppAPI.h"
+ #include "WorkerPrivate.h"
+ #include "WorkerRunnable.h"
+ #include "WorkerScope.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+-using workers::AssertIsOnMainThread;
++using namespace workers;
+ 
+ struct NotificationStrings
+ {
+   const nsString mID;
+   const nsString mTitle;
+   const nsString mDir;
+   const nsString mLang;
+   const nsString mBody;
+diff --git a/dom/performance/Performance.cpp b/dom/performance/Performance.cpp
+--- a/dom/performance/Performance.cpp
++++ b/dom/performance/Performance.cpp
+@@ -536,17 +536,17 @@ Performance::QueueEntry(PerformanceEntry
+ 
+ /* static */ bool
+ Performance::IsObserverEnabled(JSContext* aCx, JSObject* aGlobal)
+ {
+   if (NS_IsMainThread()) {
+     return Preferences::GetBool("dom.enable_performance_observer", false);
+   }
+ 
+-  WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
++  WorkerPrivate* workerPrivate = workers::GetCurrentThreadWorkerPrivate();
+   MOZ_ASSERT(workerPrivate);
+   workerPrivate->AssertIsOnWorkerThread();
+ 
+   RefPtr<PrefEnabledRunnable> runnable =
+     new PrefEnabledRunnable(workerPrivate,
+                             NS_LITERAL_CSTRING("dom.enable_performance_observer"));
+ 
+   return runnable->Dispatch() && runnable->IsEnabled();
+diff --git a/dom/performance/PerformanceObserver.cpp b/dom/performance/PerformanceObserver.cpp
+--- a/dom/performance/PerformanceObserver.cpp
++++ b/dom/performance/PerformanceObserver.cpp
+@@ -84,17 +84,17 @@ PerformanceObserver::Constructor(const G
+     MOZ_ASSERT(ownerWindow->IsInnerWindow());
+ 
+     RefPtr<PerformanceObserver> observer =
+       new PerformanceObserver(ownerWindow, aCb);
+     return observer.forget();
+   }
+ 
+   JSContext* cx = aGlobal.Context();
+-  WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(cx);
++  WorkerPrivate* workerPrivate = workers::GetWorkerPrivateFromContext(cx);
+   MOZ_ASSERT(workerPrivate);
+ 
+   RefPtr<PerformanceObserver> observer =
+     new PerformanceObserver(workerPrivate, aCb);
+   return observer.forget();
+ }
+ 
+ JSObject*
+diff --git a/dom/promise/Promise.cpp b/dom/promise/Promise.cpp
+--- a/dom/promise/Promise.cpp
++++ b/dom/promise/Promise.cpp
+@@ -492,17 +492,17 @@ Promise::ReportRejectedPromise(JSContext
+   if (!report.init(aCx, result, js::ErrorReport::NoSideEffects)) {
+     JS_ClearPendingException(aCx);
+     return;
+   }
+ 
+   RefPtr<xpc::ErrorReport> xpcReport = new xpc::ErrorReport();
+   bool isMainThread = MOZ_LIKELY(NS_IsMainThread());
+   bool isChrome = isMainThread ? nsContentUtils::IsSystemPrincipal(nsContentUtils::ObjectPrincipal(aPromise))
+-                               : GetCurrentThreadWorkerPrivate()->IsChromeWorker();
++                               : workers::GetCurrentThreadWorkerPrivate()->IsChromeWorker();
+   nsGlobalWindow* win = isMainThread ? xpc::WindowGlobalOrNull(aPromise) : nullptr;
+   xpcReport->Init(report.report(), report.toStringResult().c_str(), isChrome,
+                   win ? win->AsInner()->WindowID() : 0);
+ 
+   // Now post an event to do the real reporting async
+   NS_DispatchToMainThread(new AsyncErrorReporter(xpcReport));
+ }
+ 
+@@ -758,17 +758,17 @@ PromiseWorkerProxy::~PromiseWorkerProxy(
+   MOZ_ASSERT(!mWorkerPromise);
+   MOZ_ASSERT(!mWorkerPrivate);
+ }
+ 
+ void
+ PromiseWorkerProxy::CleanProperties()
+ {
+ #ifdef DEBUG
+-  WorkerPrivate* worker = GetCurrentThreadWorkerPrivate();
++  WorkerPrivate* worker = workers::GetCurrentThreadWorkerPrivate();
+   MOZ_ASSERT(worker);
+   worker->AssertIsOnWorkerThread();
+ #endif
+   // Ok to do this unprotected from Create().
+   // CleanUp() holds the lock before calling this.
+   mCleanedUp = true;
+   mWorkerPromise = nullptr;
+   mWorkerPrivate = nullptr;
+@@ -811,17 +811,17 @@ PromiseWorkerProxy::GetWorkerPrivate() c
+ 
+   return mWorkerPrivate;
+ }
+ 
+ Promise*
+ PromiseWorkerProxy::WorkerPromise() const
+ {
+ #ifdef DEBUG
+-  WorkerPrivate* worker = GetCurrentThreadWorkerPrivate();
++  WorkerPrivate* worker = workers::GetCurrentThreadWorkerPrivate();
+   MOZ_ASSERT(worker);
+   worker->AssertIsOnWorkerThread();
+ #endif
+   MOZ_ASSERT(mWorkerPromise);
+   return mWorkerPromise;
+ }
+ 
+ void
+diff --git a/dom/push/PushManager.cpp b/dom/push/PushManager.cpp
+--- a/dom/push/PushManager.cpp
++++ b/dom/push/PushManager.cpp
+@@ -28,16 +28,17 @@
+ 
+ #include "WorkerRunnable.h"
+ #include "WorkerPrivate.h"
+ #include "WorkerScope.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
++using namespace workers;
+ using workers::AssertIsOnMainThread;
+ 
+ namespace {
+ 
+ nsresult
+ GetPermissionState(nsIPrincipal* aPrincipal,
+                    PushPermissionState& aState)
+ {
+diff --git a/dom/push/PushSubscription.cpp b/dom/push/PushSubscription.cpp
+--- a/dom/push/PushSubscription.cpp
++++ b/dom/push/PushSubscription.cpp
+@@ -18,16 +18,18 @@
+ #include "mozilla/dom/PushUtil.h"
+ #include "mozilla/dom/WorkerPrivate.h"
+ #include "mozilla/dom/WorkerScope.h"
+ #include "mozilla/dom/workers/WorkerCommon.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
++using namespace workers;
++
+ namespace {
+ 
+ class UnsubscribeResultCallback final : public nsIUnsubscribeResultCallback
+ {
+ public:
+   NS_DECL_ISUPPORTS
+ 
+   explicit UnsubscribeResultCallback(Promise* aPromise)
+diff --git a/dom/url/URLWorker.cpp b/dom/url/URLWorker.cpp
+--- a/dom/url/URLWorker.cpp
++++ b/dom/url/URLWorker.cpp
+@@ -15,16 +15,17 @@
+ #include "nsURLHelper.h"
+ 
+ namespace mozilla {
+ 
+ using net::nsStandardURL;
+ 
+ namespace dom {
+ 
++using namespace workers;
+ using workers::AssertIsOnMainThread;
+ 
+ // Proxy class to forward all the requests to a URLMainThread object.
+ class URLWorker::URLProxy final
+ {
+ public:
+   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(URLProxy)
+ 
+diff --git a/dom/workers/MessageEventRunnable.cpp b/dom/workers/MessageEventRunnable.cpp
+--- a/dom/workers/MessageEventRunnable.cpp
++++ b/dom/workers/MessageEventRunnable.cpp
+@@ -125,17 +125,17 @@ MessageEventRunnable::WorkerRun(JSContex
+     }
+ 
+     aWorkerPrivate->AssertInnerWindowIsCorrect();
+ 
+     return DispatchDOMEvent(aCx, aWorkerPrivate, aWorkerPrivate,
+                             !aWorkerPrivate->GetParent());
+   }
+ 
+-  MOZ_ASSERT(aWorkerPrivate == GetWorkerPrivateFromContext(aCx));
++  MOZ_ASSERT(aWorkerPrivate == workers::GetWorkerPrivateFromContext(aCx));
+ 
+   return DispatchDOMEvent(aCx, aWorkerPrivate, aWorkerPrivate->GlobalScope(),
+                           false);
+ }
+ 
+ void
+ MessageEventRunnable::DispatchError(JSContext* aCx,
+                                     DOMEventTargetHelper* aTarget)
+diff --git a/dom/workers/Queue.h b/dom/workers/Queue.h
+--- a/dom/workers/Queue.h
++++ b/dom/workers/Queue.h
+@@ -7,17 +7,19 @@
+ #ifndef mozilla_dom_workers_queue_h__
+ #define mozilla_dom_workers_queue_h__
+ 
+ #include "mozilla/dom/workers/WorkerCommon.h"
+ 
+ #include "mozilla/Mutex.h"
+ #include "nsTArray.h"
+ 
+-BEGIN_WORKERS_NAMESPACE
++namespace mozilla {
++namespace dom {
++namespace workersinternals {
+ 
+ template <typename T, int TCount>
+ struct StorageWithTArray
+ {
+   typedef AutoTArray<T, TCount> StorageType;
+ 
+   static void Reverse(StorageType& aStorage)
+   {
+@@ -193,11 +195,13 @@ public:
+   }
+ 
+ private:
+   // Queue is not copyable.
+   Queue(const Queue&);
+   Queue & operator=(const Queue&);
+ };
+ 
+-END_WORKERS_NAMESPACE
++} // workersinternals namespace
++} // dom namespace
++} // mozilla namespace
+ 
+ #endif /* mozilla_dom_workers_queue_h__ */
+diff --git a/dom/workers/RegisterBindings.cpp b/dom/workers/RegisterBindings.cpp
+--- a/dom/workers/RegisterBindings.cpp
++++ b/dom/workers/RegisterBindings.cpp
+@@ -8,17 +8,16 @@
+ #include "ChromeWorkerScope.h"
+ #include "RuntimeService.h"
+ 
+ #include "jsapi.h"
+ #include "mozilla/dom/RegisterWorkerBindings.h"
+ #include "mozilla/dom/RegisterWorkerDebuggerBindings.h"
+ #include "mozilla/OSFileConstants.h"
+ 
+-USING_WORKERS_NAMESPACE
+ using namespace mozilla::dom;
+ 
+ bool
+ WorkerPrivate::RegisterBindings(JSContext* aCx, JS::Handle<JSObject*> aGlobal)
+ {
+   // Init Web IDL bindings
+   if (!RegisterWorkerBindings(aCx, aGlobal)) {
+     return false;
+diff --git a/dom/workers/RuntimeService.cpp b/dom/workers/RuntimeService.cpp
+--- a/dom/workers/RuntimeService.cpp
++++ b/dom/workers/RuntimeService.cpp
+@@ -73,25 +73,22 @@
+ #include "WorkerPrivate.h"
+ #include "WorkerRunnable.h"
+ #include "WorkerScope.h"
+ #include "WorkerThread.h"
+ #include "prsystem.h"
+ 
+ #define WORKERS_SHUTDOWN_TOPIC "web-workers-shutdown"
+ 
+-using namespace mozilla;
+-using namespace mozilla::dom;
+-using namespace mozilla::ipc;
+-
+-USING_WORKERS_NAMESPACE
+-
+-using mozilla::MutexAutoLock;
+-using mozilla::MutexAutoUnlock;
+-using mozilla::Preferences;
++namespace mozilla {
++
++using namespace ipc;
++
++namespace dom {
++namespace workers {
+ 
+ // The size of the worker runtime heaps in bytes. May be changed via pref.
+ #define WORKER_DEFAULT_RUNTIME_HEAPSIZE 32 * 1024 * 1024
+ 
+ // The size of the generational GC nursery for workers, in bytes.
+ #define WORKER_DEFAULT_NURSERY_SIZE 1 * 1024 * 1024
+ 
+ // The size of the worker JS allocation threshold in MB. May be changed via pref.
+@@ -1256,18 +1253,16 @@ PlatformOverrideChanged(const char* /* a
+   RuntimeService* runtime = RuntimeService::GetService();
+   if (runtime) {
+     runtime->UpdatePlatformOverridePreference(override);
+   }
+ }
+ 
+ } /* anonymous namespace */
+ 
+-BEGIN_WORKERS_NAMESPACE
+-
+ void
+ CancelWorkersForWindow(nsPIDOMWindowInner* aWindow)
+ {
+   AssertIsOnMainThread();
+   RuntimeService* runtime = RuntimeService::GetService();
+   if (runtime) {
+     runtime->CancelWorkersForWindow(aWindow);
+   }
+@@ -1308,21 +1303,16 @@ ResumeWorkersForWindow(nsPIDOMWindowInne
+ {
+   AssertIsOnMainThread();
+   RuntimeService* runtime = RuntimeService::GetService();
+   if (runtime) {
+     runtime->ResumeWorkersForWindow(aWindow);
+   }
+ }
+ 
+-END_WORKERS_NAMESPACE
+-
+-namespace mozilla {
+-namespace dom {
+-
+ WorkerPrivate*
+ GetWorkerPrivateFromContext(JSContext* aCx)
+ {
+   MOZ_ASSERT(!NS_IsMainThread());
+   MOZ_ASSERT(aCx);
+ 
+   void* cxPrivate = JS_GetContextPrivate(aCx);
+   if (!cxPrivate) {
+@@ -1378,18 +1368,25 @@ GetCurrentThreadWorkerGlobal()
+   }
+   WorkerGlobalScope* scope = wp->GlobalScope();
+   if (!scope) {
+     return nullptr;
+   }
+   return scope->GetGlobalJSObject();
+ }
+ 
+-} // dom namespace
+-} // mozilla namespace
++#ifdef DEBUG
++
++void
++AssertIsOnMainThread()
++{
++  MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!");
++}
++
++#endif
+ 
+ struct RuntimeService::IdleThreadInfo
+ {
+   RefPtr<WorkerThread> mThread;
+   mozilla::TimeStamp mExpirationTime;
+ };
+ 
+ // This is only touched on the main thread. Initialized in Init() below.
+@@ -2916,8 +2913,12 @@ WorkerThreadPrimaryRunnable::FinishedRun
+     rts->NoteIdleThread(thread);
+   }
+   else if (thread->ShutdownRequired()) {
+     MOZ_ALWAYS_SUCCEEDS(thread->Shutdown());
+   }
+ 
+   return NS_OK;
+ }
++
++} // workers namespace
++} // dom namespace
++} // mozilla namespace
+diff --git a/dom/workers/RuntimeService.h b/dom/workers/RuntimeService.h
+--- a/dom/workers/RuntimeService.h
++++ b/dom/workers/RuntimeService.h
+@@ -19,20 +19,18 @@
+ class nsITimer;
+ class nsPIDOMWindowInner;
+ 
+ namespace mozilla {
+ namespace dom {
+ class SharedWorker;
+ struct WorkerLoadInfo;
+ class WorkerThread;
+-}
+-}
+ 
+-BEGIN_WORKERS_NAMESPACE
++namespace workers {
+ 
+ class RuntimeService final : public nsIObserver
+ {
+   struct SharedWorkerInfo
+   {
+     WorkerPrivate* mWorkerPrivate;
+     nsCString mScriptSpec;
+     nsString mName;
+@@ -267,11 +265,13 @@ private:
+   nsresult
+   CreateSharedWorkerFromLoadInfo(JSContext* aCx,
+                                  WorkerLoadInfo* aLoadInfo,
+                                  const nsAString& aScriptURL,
+                                  const nsAString& aName,
+                                  SharedWorker** aSharedWorker);
+ };
+ 
+-END_WORKERS_NAMESPACE
++} // workers namespace
++} // dom namespace
++} // mozilla namespace
+ 
+ #endif /* mozilla_dom_workers_runtimeservice_h__ */
+diff --git a/dom/workers/ScriptLoader.cpp b/dom/workers/ScriptLoader.cpp
+--- a/dom/workers/ScriptLoader.cpp
++++ b/dom/workers/ScriptLoader.cpp
+@@ -68,25 +68,25 @@
+ #include "Principal.h"
+ #include "WorkerHolder.h"
+ #include "WorkerPrivate.h"
+ #include "WorkerRunnable.h"
+ #include "WorkerScope.h"
+ 
+ #define MAX_CONCURRENT_SCRIPTS 1000
+ 
+-USING_WORKERS_NAMESPACE
+-
+ using mozilla::dom::cache::Cache;
+ using mozilla::dom::cache::CacheStorage;
+ using mozilla::ipc::PrincipalInfo;
+ 
+ namespace mozilla {
+ namespace dom {
+ 
++using namespace workers;
++
+ namespace {
+ 
+ nsIURI*
+ GetBaseURI(bool aIsMainScript, WorkerPrivate* aWorkerPrivate)
+ {
+   MOZ_ASSERT(aWorkerPrivate);
+   nsIURI* baseURI;
+   WorkerPrivate* parentWorker = aWorkerPrivate->GetParent();
+diff --git a/dom/workers/SharedWorker.cpp b/dom/workers/SharedWorker.cpp
+--- a/dom/workers/SharedWorker.cpp
++++ b/dom/workers/SharedWorker.cpp
+@@ -53,17 +53,17 @@ SharedWorker::~SharedWorker()
+ already_AddRefed<SharedWorker>
+ SharedWorker::Constructor(const GlobalObject& aGlobal,
+                           const nsAString& aScriptURL,
+                           const StringOrWorkerOptions& aOptions,
+                           ErrorResult& aRv)
+ {
+   AssertIsOnMainThread();
+ 
+-  RuntimeService* rts = RuntimeService::GetOrCreateService();
++  workers::RuntimeService* rts = workers::RuntimeService::GetOrCreateService();
+   if (!rts) {
+     aRv = NS_ERROR_NOT_AVAILABLE;
+     return nullptr;
+   }
+ 
+   nsAutoString name;
+   if (aOptions.IsString()) {
+     name = aOptions.GetAsString();
+diff --git a/dom/workers/WorkerCommon.h b/dom/workers/WorkerCommon.h
+--- a/dom/workers/WorkerCommon.h
++++ b/dom/workers/WorkerCommon.h
+@@ -13,23 +13,16 @@
+ #include "mozilla/Mutex.h"
+ #include "nsAutoPtr.h"
+ #include "nsCOMPtr.h"
+ #include "nsString.h"
+ #include "nsTArray.h"
+ 
+ #include "mozilla/dom/ServiceWorkerDescriptor.h"
+ 
+-#define BEGIN_WORKERS_NAMESPACE \
+-  namespace mozilla { namespace dom { namespace workers {
+-#define END_WORKERS_NAMESPACE \
+-  } /* namespace workers */ } /* namespace dom */ } /* namespace mozilla */
+-#define USING_WORKERS_NAMESPACE \
+-  using namespace mozilla::dom::workers;
+-
+ class nsIGlobalObject;
+ class nsPIDOMWindowInner;
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+ // If you change this, the corresponding list in nsIWorkerDebugger.idl needs to
+ // be updated too.
+@@ -37,33 +30,21 @@ enum WorkerType
+ {
+   WorkerTypeDedicated,
+   WorkerTypeShared,
+   WorkerTypeService
+ };
+ 
+ class WorkerPrivate;
+ 
+-} // namespace dom
+-} // namespace mozilla
+-
+-BEGIN_WORKERS_NAMESPACE
++namespace workers {
+ 
+ struct PrivatizableBase
+ { };
+ 
+-#ifdef DEBUG
+-void
+-AssertIsOnMainThread();
+-#else
+-inline void
+-AssertIsOnMainThread()
+-{ }
+-#endif
+-
+ struct JSSettings
+ {
+   enum {
+     // All the GC parameters that we support.
+     JSSettings_JSGC_MAX_BYTES = 0,
+     JSSettings_JSGC_MAX_MALLOC_BYTES,
+     JSSettings_JSGC_HIGH_FREQUENCY_TIME_LIMIT,
+     JSSettings_JSGC_LOW_FREQUENCY_HEAP_GROWTH,
+@@ -163,38 +144,66 @@ struct JSSettings
+     }
+ 
+     return false;
+   }
+ };
+ 
+ // All of these are implemented in RuntimeService.cpp
+ 
++#ifdef DEBUG
++void
++AssertIsOnMainThread();
++#else
++inline void
++AssertIsOnMainThread()
++{ }
++#endif
++
++WorkerPrivate*
++GetWorkerPrivateFromContext(JSContext* aCx);
++
++WorkerPrivate*
++GetCurrentThreadWorkerPrivate();
++
++bool
++IsCurrentThreadRunningChromeWorker();
++
++JSContext*
++GetCurrentThreadJSContext();
++
++JSObject*
++GetCurrentThreadWorkerGlobal();
++
+ void
+ CancelWorkersForWindow(nsPIDOMWindowInner* aWindow);
+ 
+ void
+ FreezeWorkersForWindow(nsPIDOMWindowInner* aWindow);
+ 
+ void
+ ThawWorkersForWindow(nsPIDOMWindowInner* aWindow);
+ 
+ void
+ SuspendWorkersForWindow(nsPIDOMWindowInner* aWindow);
+ 
+ void
+ ResumeWorkersForWindow(nsPIDOMWindowInner* aWindow);
+ 
+-// Random unique constant to facilitate JSPrincipal debugging
+-const uint32_t kJSPrincipalsDebugToken = 0x7e2df9d2;
++// All of these are implemented in WorkerScope.cpp
+ 
+ bool
+ IsWorkerGlobal(JSObject* global);
+ 
+ bool
+ IsDebuggerGlobal(JSObject* global);
+ 
+ bool
+ IsDebuggerSandbox(JSObject* object);
+ 
+-END_WORKERS_NAMESPACE
++// Random unique constant to facilitate JSPrincipal debugging
++const uint32_t kJSPrincipalsDebugToken = 0x7e2df9d2;
++
++} // workers namespace
++} // dom namespace
++} // mozilla namespace
+ 
+ #endif // mozilla_dom_workers_WorkerCommon_h
+diff --git a/dom/workers/WorkerPrivate.cpp b/dom/workers/WorkerPrivate.cpp
+--- a/dom/workers/WorkerPrivate.cpp
++++ b/dom/workers/WorkerPrivate.cpp
+@@ -89,34 +89,21 @@ TimeoutsLog()
+ {
+   return sWorkerTimeoutsLog;
+ }
+ 
+ #define LOG(log, _args) MOZ_LOG(log, LogLevel::Debug, _args);
+ 
+ using namespace mozilla;
+ using namespace mozilla::dom;
++using namespace mozilla::dom::workers;
+ using namespace mozilla::ipc;
+ 
+ MOZ_DEFINE_MALLOC_SIZE_OF(JsWorkerMallocSizeOf)
+ 
+-#ifdef DEBUG
+-
+-BEGIN_WORKERS_NAMESPACE
+-
+-void
+-AssertIsOnMainThread()
+-{
+-  MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!");
+-}
+-
+-END_WORKERS_NAMESPACE
+-
+-#endif
+-
+ namespace {
+ 
+ #ifdef DEBUG
+ 
+ const nsIID kDEBUGWorkerEventTargetIID = {
+   0xccaba3fa, 0x5be2, 0x4de2, { 0xba, 0x87, 0x3b, 0x3b, 0x5b, 0x1d, 0x5, 0xfb }
+ };
+ 
+diff --git a/dom/workers/WorkerPrivate.h b/dom/workers/WorkerPrivate.h
+--- a/dom/workers/WorkerPrivate.h
++++ b/dom/workers/WorkerPrivate.h
+@@ -884,18 +884,18 @@ class WorkerPrivate : public WorkerPriva
+     PeriodicTimer = 0,
+     IdleTimer,
+     NoTimer
+   };
+ 
+   bool mDebuggerRegistered;
+   WorkerDebugger* mDebugger;
+ 
+-  workers::Queue<WorkerControlRunnable*, 4> mControlQueue;
+-  workers::Queue<WorkerRunnable*, 4> mDebuggerQueue;
++  workersinternals::Queue<WorkerControlRunnable*, 4> mControlQueue;
++  workersinternals::Queue<WorkerRunnable*, 4> mDebuggerQueue;
+ 
+   // Touched on multiple threads, protected with mMutex.
+   JSContext* mJSContext;
+   RefPtr<WorkerThread> mThread;
+   PRThread* mPRThread;
+ 
+   // Things touched on worker thread only.
+   RefPtr<WorkerGlobalScope> mScope;
+@@ -1500,31 +1500,16 @@ public:
+   WorkerAvailable(JSContext* aCx, JSObject* /* unused */);
+ 
+ private:
+   ChromeWorkerPrivate() = delete;
+   ChromeWorkerPrivate(const ChromeWorkerPrivate& aRHS) = delete;
+   ChromeWorkerPrivate& operator =(const ChromeWorkerPrivate& aRHS) = delete;
+ };
+ 
+-WorkerPrivate*
+-GetWorkerPrivateFromContext(JSContext* aCx);
+-
+-WorkerPrivate*
+-GetCurrentThreadWorkerPrivate();
+-
+-bool
+-IsCurrentThreadRunningChromeWorker();
+-
+-JSContext*
+-GetCurrentThreadJSContext();
+-
+-JSObject*
+-GetCurrentThreadWorkerGlobal();
+-
+ class AutoSyncLoopHolder
+ {
+   WorkerPrivate* mWorkerPrivate;
+   nsCOMPtr<nsIEventTarget> mTarget;
+   uint32_t mIndex;
+ 
+ public:
+   // See CreateNewSyncLoop() for more information about the correct value to use
+diff --git a/dom/workers/WorkerScope.cpp b/dom/workers/WorkerScope.cpp
+--- a/dom/workers/WorkerScope.cpp
++++ b/dom/workers/WorkerScope.cpp
+@@ -62,19 +62,18 @@ NS_CreateJSTimeoutHandler(JSContext* aCx
+                           const mozilla::dom::Sequence<JS::Value>& aArguments,
+                           mozilla::ErrorResult& aError);
+ 
+ extern already_AddRefed<nsIScriptTimeoutHandler>
+ NS_CreateJSTimeoutHandler(JSContext* aCx,
+                           mozilla::dom::WorkerPrivate* aWorkerPrivate,
+                           const nsAString& aExpression);
+ 
+-using namespace mozilla;
+-using namespace mozilla::dom;
+-USING_WORKERS_NAMESPACE
++namespace mozilla {
++namespace dom {
+ 
+ using mozilla::dom::cache::CacheStorage;
+ using mozilla::ipc::PrincipalInfo;
+ 
+ WorkerGlobalScope::WorkerGlobalScope(WorkerPrivate* aWorkerPrivate)
+ : mSerialEventTarget(aWorkerPrivate->HybridEventTarget())
+ , mWindowInteractionsAllowed(0)
+ , mWorkerPrivate(aWorkerPrivate)
+@@ -1113,17 +1112,17 @@ WorkerDebuggerGlobalScope::EventTargetFo
+ }
+ 
+ AbstractThread*
+ WorkerDebuggerGlobalScope::AbstractMainThreadFor(TaskCategory aCategory)
+ {
+   MOZ_CRASH("AbstractMainThreadFor not supported for workers.");
+ }
+ 
+-BEGIN_WORKERS_NAMESPACE
++namespace workers {
+ 
+ bool
+ IsWorkerGlobal(JSObject* object)
+ {
+   return IS_INSTANCE_OF(WorkerGlobalScope, object);
+ }
+ 
+ bool
+@@ -1134,9 +1133,11 @@ IsDebuggerGlobal(JSObject* object)
+ 
+ bool
+ IsDebuggerSandbox(JSObject* object)
+ {
+   return SimpleGlobalObject::SimpleGlobalType(object) ==
+     SimpleGlobalObject::GlobalType::WorkerDebuggerSandbox;
+ }
+ 
+-END_WORKERS_NAMESPACE
++} // workers namespace
++} // dom namespace
++} // mozilla namespace
+diff --git a/ipc/glue/IPCStreamSource.cpp b/ipc/glue/IPCStreamSource.cpp
+--- a/ipc/glue/IPCStreamSource.cpp
++++ b/ipc/glue/IPCStreamSource.cpp
+@@ -8,17 +8,16 @@
+ #include "mozilla/webrender/WebRenderTypes.h"
+ #include "nsIAsyncInputStream.h"
+ #include "nsICancelableRunnable.h"
+ #include "nsIRunnable.h"
+ #include "nsISerialEventTarget.h"
+ #include "nsStreamUtils.h"
+ #include "nsThreadUtils.h"
+ 
+-using mozilla::dom::GetCurrentThreadWorkerPrivate;
+ using mozilla::dom::WorkerPrivate;
+ using mozilla::dom::WorkerStatus;
+ using mozilla::wr::ByteBuffer;
+ 
+ namespace mozilla {
+ namespace ipc {
+ 
+ class IPCStreamSource::Callback final : public nsIInputStreamCallback
+@@ -133,17 +132,17 @@ IPCStreamSource::Initialize()
+   // A source can be used on any thread, but we only support IPCStream on
+   // main thread, Workers and PBackground thread right now.  This is due
+   // to the requirement  that the thread be guaranteed to live long enough to
+   // receive messages. We can enforce this guarantee with a WorkerHolder on
+   // worker threads, but not other threads. Main-thread and PBackground thread
+   // do not need anything special in order to be kept alive.
+   WorkerPrivate* workerPrivate = nullptr;
+   if (!NS_IsMainThread()) {
+-    workerPrivate = GetCurrentThreadWorkerPrivate();
++    workerPrivate = mozilla::dom::workers::GetCurrentThreadWorkerPrivate();
+     if (workerPrivate) {
+       bool result = HoldWorker(workerPrivate, WorkerStatus::Canceling);
+       if (!result) {
+         return false;
+       }
+ 
+       mWorkerPrivate = workerPrivate;
+     } else {
+diff --git a/layout/generic/WritingModes.h b/layout/generic/WritingModes.h
+--- a/layout/generic/WritingModes.h
++++ b/layout/generic/WritingModes.h
+@@ -601,25 +601,25 @@ public:
+    * @param aLogicalAxis The axis to compare from this WritingMode.
+    * @param aOther The other WritingMode (from which we'll choose the axis
+    *               that's parallel to this WritingMode's aLogicalAxis, for
+    *               comparison).
+    */
+   bool ParallelAxisStartsOnSameSide(LogicalAxis aLogicalAxis,
+                                     const WritingMode& aOther) const
+   {
+-    Side myStartSide =
++    mozilla::Side myStartSide =
+       this->PhysicalSide(MakeLogicalSide(aLogicalAxis,
+                                          eLogicalEdgeStart));
+ 
+     // Figure out which of aOther's axes is parallel to |this| WritingMode's
+     // aLogicalAxis, and get its physical start side as well.
+     LogicalAxis otherWMAxis = aOther.IsOrthogonalTo(*this) ?
+       GetOrthogonalAxis(aLogicalAxis) : aLogicalAxis;
+-    Side otherWMStartSide =
++    mozilla::Side otherWMStartSide =
+       aOther.PhysicalSide(MakeLogicalSide(otherWMAxis,
+                                           eLogicalEdgeStart));
+ 
+     NS_ASSERTION(myStartSide % 2 == otherWMStartSide % 2,
+                  "Should end up with sides in the same physical axis");
+     return myStartSide == otherWMStartSide;
+   }
+ 

+ 2072 - 0
mozilla-release/patches/1432963-16-60a1.patch

@@ -0,0 +1,2072 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1517383499 -3600
+# Node ID f82c8af2c1ea3c300292e2324bfe07ac24597551
+# Parent  3e05c6384895810051700a4c5cc270606fba38e5
+Bug 1432963 - Fixing workers headers - part 16 - JSSettings in a workerinternals namespace, r=smaug
+
+diff --git a/caps/nsJSPrincipals.cpp b/caps/nsJSPrincipals.cpp
+--- a/caps/nsJSPrincipals.cpp
++++ b/caps/nsJSPrincipals.cpp
+@@ -11,17 +11,17 @@
+ #include "plstr.h"
+ #include "nsCOMPtr.h"
+ #include "nsIServiceManager.h"
+ #include "nsMemory.h"
+ #include "nsStringBuffer.h"
+ 
+ #include "mozilla/dom/StructuredCloneTags.h"
+ // for mozilla::dom::workers::kJSPrincipalsDebugToken
+-#include "mozilla/dom/workers/WorkerCommon.h"
++#include "mozilla/dom/workerinternals/JSSettings.h"
+ #include "mozilla/ipc/BackgroundUtils.h"
+ 
+ using namespace mozilla;
+ using namespace mozilla::ipc;
+ 
+ NS_IMETHODIMP_(MozExternalRefCountType)
+ nsJSPrincipals::AddRef()
+ {
+@@ -85,17 +85,17 @@ nsJSPrincipals::Destroy(JSPrincipals *js
+ JS_PUBLIC_API(void)
+ JSPrincipals::dump()
+ {
+     if (debugToken == nsJSPrincipals::DEBUG_TOKEN) {
+       nsAutoCString str;
+       nsresult rv = static_cast<nsJSPrincipals *>(this)->GetScriptLocation(str);
+       fprintf(stderr, "nsIPrincipal (%p) = %s\n", static_cast<void*>(this),
+               NS_SUCCEEDED(rv) ? str.get() : "(unknown)");
+-    } else if (debugToken == dom::workers::kJSPrincipalsDebugToken) {
++    } else if (debugToken == dom::workerinternals::kJSPrincipalsDebugToken) {
+         fprintf(stderr, "Web Worker principal singleton (%p)\n", this);
+     } else {
+         fprintf(stderr,
+                 "!!! JSPrincipals (%p) is not nsJSPrincipals instance - bad token: "
+                 "actual=0x%x expected=0x%x\n",
+                 this, unsigned(debugToken), unsigned(nsJSPrincipals::DEBUG_TOKEN));
+     }
+ }
+diff --git a/dom/base/Navigator.cpp b/dom/base/Navigator.cpp
+--- a/dom/base/Navigator.cpp
++++ b/dom/base/Navigator.cpp
+@@ -38,17 +38,17 @@
+ #include "mozilla/dom/Permissions.h"
+ #include "mozilla/dom/ServiceWorkerContainer.h"
+ #include "mozilla/dom/StorageManager.h"
+ #include "mozilla/dom/TCPSocket.h"
+ #include "mozilla/dom/URLSearchParams.h"
+ #include "mozilla/dom/VRDisplay.h"
+ #include "mozilla/dom/VRDisplayEvent.h"
+ #include "mozilla/dom/VRServiceTest.h"
+-#include "mozilla/dom/workers/RuntimeService.h"
++#include "mozilla/dom/workerinternals/RuntimeService.h"
+ #include "mozilla/Hal.h"
+ #include "mozilla/ClearOnShutdown.h"
+ #include "mozilla/SSE.h"
+ #include "mozilla/StaticPtr.h"
+ #include "Connection.h"
+ #include "mozilla/dom/Event.h" // for nsIDOMEvent::InternalDOMEvent()
+ #include "nsGlobalWindow.h"
+ #include "nsIIdleObserver.h"
+@@ -653,17 +653,18 @@ Navigator::GetDoNotTrack(nsAString &aRes
+   }
+ 
+   return NS_OK;
+ }
+ 
+ uint64_t
+ Navigator::HardwareConcurrency()
+ {
+-  workers::RuntimeService* rts = workers::RuntimeService::GetOrCreateService();
++  workerinternals::RuntimeService* rts =
++    workerinternals::RuntimeService::GetOrCreateService();
+   if (!rts) {
+     return 1;
+   }
+ 
+   return rts->ClampedHardwareConcurrency();
+ }
+ 
+ bool
+diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp
+--- a/dom/base/nsGlobalWindow.cpp
++++ b/dom/base/nsGlobalWindow.cpp
+@@ -80,17 +80,17 @@
+ #include "mozilla/Sprintf.h"
+ #include "mozilla/Unused.h"
+ 
+ // Other Classes
+ #include "mozilla/dom/BarProps.h"
+ #include "nsContentCID.h"
+ #include "nsLayoutStatics.h"
+ #include "nsCCUncollectableMarker.h"
+-#include "mozilla/dom/workers/WorkerCommon.h"
++#include "mozilla/dom/WorkerCommon.h"
+ #include "mozilla/dom/ToJSValue.h"
+ #include "nsJSPrincipals.h"
+ #include "mozilla/Attributes.h"
+ #include "mozilla/Debug.h"
+ #include "mozilla/EventListenerManager.h"
+ #include "mozilla/EventStates.h"
+ #include "mozilla/MouseEvents.h"
+ #include "mozilla/ProcessHangMonitor.h"
+diff --git a/dom/fetch/FetchDriver.cpp b/dom/fetch/FetchDriver.cpp
+--- a/dom/fetch/FetchDriver.cpp
++++ b/dom/fetch/FetchDriver.cpp
+@@ -27,17 +27,17 @@
+ #include "nsPrintfCString.h"
+ #include "nsProxyRelease.h"
+ #include "nsStreamUtils.h"
+ #include "nsStringStream.h"
+ #include "nsHttpChannel.h"
+ 
+ #include "mozilla/dom/File.h"
+ #include "mozilla/dom/PerformanceStorage.h"
+-#include "mozilla/dom/workers/WorkerCommon.h"
++#include "mozilla/dom/WorkerCommon.h"
+ #include "mozilla/EventStateManager.h"
+ #include "mozilla/ipc/PBackgroundSharedTypes.h"
+ #include "mozilla/Unused.h"
+ 
+ #include "Fetch.h"
+ #include "FetchUtil.h"
+ #include "InternalRequest.h"
+ #include "InternalResponse.h"
+diff --git a/dom/fetch/InternalRequest.cpp b/dom/fetch/InternalRequest.cpp
+--- a/dom/fetch/InternalRequest.cpp
++++ b/dom/fetch/InternalRequest.cpp
+@@ -8,19 +8,19 @@
+ 
+ #include "nsIContentPolicy.h"
+ #include "nsIDocument.h"
+ #include "nsStreamUtils.h"
+ 
+ #include "mozilla/ErrorResult.h"
+ #include "mozilla/dom/FetchTypes.h"
+ #include "mozilla/dom/ScriptSettings.h"
+-#include "mozilla/dom/workers/WorkerCommon.h"
+ 
+-#include "WorkerPrivate.h"
++#include "mozilla/dom/WorkerCommon.h"
++#include "mozilla/dom/WorkerPrivate.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ // The global is used to extract the principal.
+ already_AddRefed<InternalRequest>
+ InternalRequest::GetRequestConstructorCopy(nsIGlobalObject* aGlobal, ErrorResult& aRv) const
+ {
+   MOZ_RELEASE_ASSERT(!mURLList.IsEmpty(), "Internal Request's urlList should not be empty when copied from constructor.");
+diff --git a/dom/notification/NotificationEvent.h b/dom/notification/NotificationEvent.h
+--- a/dom/notification/NotificationEvent.h
++++ b/dom/notification/NotificationEvent.h
+@@ -5,17 +5,17 @@
+  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+ 
+ #ifndef mozilla_dom_workers_notificationevent_h__
+ #define mozilla_dom_workers_notificationevent_h__
+ 
+ #include "mozilla/dom/Event.h"
+ #include "mozilla/dom/NotificationEventBinding.h"
+ #include "mozilla/dom/ServiceWorkerEvents.h"
+-#include "mozilla/dom/workers/WorkerCommon.h"
++#include "mozilla/dom/WorkerCommon.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+ class ServiceWorker;
+ class ServiceWorkerClient;
+ 
+ class NotificationEvent final : public ExtendableEvent
+diff --git a/dom/push/PushSubscription.cpp b/dom/push/PushSubscription.cpp
+--- a/dom/push/PushSubscription.cpp
++++ b/dom/push/PushSubscription.cpp
+@@ -11,19 +11,19 @@
+ 
+ #include "mozilla/Base64.h"
+ #include "mozilla/Unused.h"
+ 
+ #include "mozilla/dom/Promise.h"
+ #include "mozilla/dom/PromiseWorkerProxy.h"
+ #include "mozilla/dom/PushSubscriptionOptions.h"
+ #include "mozilla/dom/PushUtil.h"
++#include "mozilla/dom/WorkerCommon.h"
+ #include "mozilla/dom/WorkerPrivate.h"
+ #include "mozilla/dom/WorkerScope.h"
+-#include "mozilla/dom/workers/WorkerCommon.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+ using namespace workers;
+ 
+ namespace {
+ 
+diff --git a/dom/serviceworkers/ServiceWorkerEvents.h b/dom/serviceworkers/ServiceWorkerEvents.h
+--- a/dom/serviceworkers/ServiceWorkerEvents.h
++++ b/dom/serviceworkers/ServiceWorkerEvents.h
+@@ -10,17 +10,17 @@
+ #include "mozilla/dom/DOMPrefs.h"
+ #include "mozilla/dom/Event.h"
+ #include "mozilla/dom/ExtendableEventBinding.h"
+ #include "mozilla/dom/ExtendableMessageEventBinding.h"
+ #include "mozilla/dom/FetchEventBinding.h"
+ #include "mozilla/dom/File.h"
+ #include "mozilla/dom/Promise.h"
+ #include "mozilla/dom/Response.h"
+-#include "mozilla/dom/workers/WorkerCommon.h"
++#include "mozilla/dom/WorkerCommon.h"
+ 
+ #include "nsProxyRelease.h"
+ #include "nsContentUtils.h"
+ 
+ class nsIInterceptedChannel;
+ 
+ namespace mozilla {
+ namespace dom {
+diff --git a/dom/serviceworkers/ServiceWorkerInfo.h b/dom/serviceworkers/ServiceWorkerInfo.h
+--- a/dom/serviceworkers/ServiceWorkerInfo.h
++++ b/dom/serviceworkers/ServiceWorkerInfo.h
+@@ -4,17 +4,17 @@
+  * 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/. */
+ 
+ #ifndef mozilla_dom_serviceworkerinfo_h
+ #define mozilla_dom_serviceworkerinfo_h
+ 
+ #include "MainThreadUtils.h"
+ #include "mozilla/dom/ServiceWorkerBinding.h" // For ServiceWorkerState
+-#include "mozilla/dom/workers/WorkerCommon.h"
++#include "mozilla/dom/WorkerCommon.h"
+ #include "mozilla/OriginAttributes.h"
+ #include "nsIServiceWorkerManager.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+ class ServiceWorker;
+ class ServiceWorkerPrivate;
+diff --git a/dom/workers/JSSettings.h b/dom/workers/JSSettings.h
+new file mode 100644
+--- /dev/null
++++ b/dom/workers/JSSettings.h
+@@ -0,0 +1,132 @@
++/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
++/* vim: set ts=8 sts=2 et sw=2 tw=80: */
++/* 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/. */
++
++#ifndef mozilla_dom_workerinternals_JSSettings_h
++#define mozilla_dom_workerinternals_JSSettings_h
++
++#include "jsapi.h"
++#include "mozilla/Maybe.h"
++#include "nsString.h"
++#include "nsTArray.h"
++
++namespace mozilla {
++namespace dom {
++namespace workerinternals {
++
++// Random unique constant to facilitate JSPrincipal debugging
++const uint32_t kJSPrincipalsDebugToken = 0x7e2df9d2;
++
++struct JSSettings
++{
++  enum {
++    // All the GC parameters that we support.
++    JSSettings_JSGC_MAX_BYTES = 0,
++    JSSettings_JSGC_MAX_MALLOC_BYTES,
++    JSSettings_JSGC_HIGH_FREQUENCY_TIME_LIMIT,
++    JSSettings_JSGC_LOW_FREQUENCY_HEAP_GROWTH,
++    JSSettings_JSGC_HIGH_FREQUENCY_HEAP_GROWTH_MIN,
++    JSSettings_JSGC_HIGH_FREQUENCY_HEAP_GROWTH_MAX,
++    JSSettings_JSGC_HIGH_FREQUENCY_LOW_LIMIT,
++    JSSettings_JSGC_HIGH_FREQUENCY_HIGH_LIMIT,
++    JSSettings_JSGC_ALLOCATION_THRESHOLD,
++    JSSettings_JSGC_SLICE_TIME_BUDGET,
++    JSSettings_JSGC_DYNAMIC_HEAP_GROWTH,
++    JSSettings_JSGC_DYNAMIC_MARK_SLICE,
++    // JSGC_MODE not supported
++
++    // This must be last so that we get an accurate count.
++    kGCSettingsArraySize
++  };
++
++  struct JSGCSetting
++  {
++    mozilla::Maybe<JSGCParamKey> key;
++    uint32_t value;
++
++    JSGCSetting()
++    : key(), value(0)
++    { }
++  };
++
++  // There are several settings that we know we need so it makes sense to
++  // preallocate here.
++  typedef JSGCSetting JSGCSettingsArray[kGCSettingsArraySize];
++
++  // Settings that change based on chrome/content context.
++  struct JSContentChromeSettings
++  {
++    JS::CompartmentOptions compartmentOptions;
++    int32_t maxScriptRuntime;
++
++    JSContentChromeSettings()
++    : compartmentOptions(), maxScriptRuntime(0)
++    { }
++  };
++
++  JSContentChromeSettings chrome;
++  JSContentChromeSettings content;
++  JSGCSettingsArray gcSettings;
++  JS::ContextOptions contextOptions;
++
++#ifdef JS_GC_ZEAL
++  uint8_t gcZeal;
++  uint32_t gcZealFrequency;
++#endif
++
++  JSSettings()
++#ifdef JS_GC_ZEAL
++  : gcZeal(0), gcZealFrequency(0)
++#endif
++  {
++    for (uint32_t index = 0; index < ArrayLength(gcSettings); index++) {
++      new (gcSettings + index) JSGCSetting();
++    }
++  }
++
++  bool
++  ApplyGCSetting(JSGCParamKey aKey, uint32_t aValue)
++  {
++    JSSettings::JSGCSetting* firstEmptySetting = nullptr;
++    JSSettings::JSGCSetting* foundSetting = nullptr;
++
++    for (uint32_t index = 0; index < ArrayLength(gcSettings); index++) {
++      JSSettings::JSGCSetting& setting = gcSettings[index];
++      if (setting.key.isSome() && *setting.key == aKey) {
++        foundSetting = &setting;
++        break;
++      }
++      if (!firstEmptySetting && setting.key.isNothing()) {
++        firstEmptySetting = &setting;
++      }
++    }
++
++    if (aValue) {
++      if (!foundSetting) {
++        foundSetting = firstEmptySetting;
++        if (!foundSetting) {
++          NS_ERROR("Not enough space for this value!");
++          return false;
++        }
++      }
++      foundSetting->key = mozilla::Some(aKey);
++      foundSetting->value = aValue;
++      return true;
++    }
++
++    if (foundSetting) {
++      foundSetting->key.reset();
++      return true;
++    }
++
++    return false;
++  }
++};
++
++} // workerinternals namespace
++} // dom namespace
++} // mozilla namespace
++
++#endif // mozilla_dom_workerinternals_JSSettings_h
+diff --git a/dom/workers/Principal.cpp b/dom/workers/Principal.cpp
+--- a/dom/workers/Principal.cpp
++++ b/dom/workers/Principal.cpp
+@@ -31,17 +31,17 @@ GetWorkerPrincipal()
+    * the first time, decrement it again. This avoids the need for
+    * synchronization.
+    */
+   int32_t prevRefcount = sPrincipal.refcount++;
+   if (prevRefcount > 0) {
+     --sPrincipal.refcount;
+   } else {
+ #ifdef DEBUG
+-    sPrincipal.debugToken = workers::kJSPrincipalsDebugToken;
++    sPrincipal.debugToken = workerinternals::kJSPrincipalsDebugToken;
+ #endif
+   }
+ 
+   return &sPrincipal;
+ }
+ 
+ void
+ DestroyWorkerPrincipals(JSPrincipals* aPrincipals)
+diff --git a/dom/workers/Queue.h b/dom/workers/Queue.h
+--- a/dom/workers/Queue.h
++++ b/dom/workers/Queue.h
+@@ -1,25 +1,25 @@
+ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+ /* vim: set ts=8 sts=2 et sw=2 tw=80: */
+ /* 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/. */
+ 
+-#ifndef mozilla_dom_workers_queue_h__
+-#define mozilla_dom_workers_queue_h__
++#ifndef mozilla_dom_workerinternal_Queue_h
++#define mozilla_dom_workerinternal_Queue_h
+ 
+-#include "mozilla/dom/workers/WorkerCommon.h"
++#include "mozilla/dom/WorkerCommon.h"
+ 
+ #include "mozilla/Mutex.h"
+ #include "nsTArray.h"
+ 
+ namespace mozilla {
+ namespace dom {
+-namespace workersinternals {
++namespace workerinternals {
+ 
+ template <typename T, int TCount>
+ struct StorageWithTArray
+ {
+   typedef AutoTArray<T, TCount> StorageType;
+ 
+   static void Reverse(StorageType& aStorage)
+   {
+@@ -195,13 +195,13 @@ public:
+   }
+ 
+ private:
+   // Queue is not copyable.
+   Queue(const Queue&);
+   Queue & operator=(const Queue&);
+ };
+ 
+-} // workersinternals namespace
++} // workerinternals namespace
+ } // dom namespace
+ } // mozilla namespace
+ 
+-#endif /* mozilla_dom_workers_queue_h__ */
++#endif /* mozilla_dom_workerinternals_Queue_h*/
+diff --git a/dom/workers/RuntimeService.cpp b/dom/workers/RuntimeService.cpp
+--- a/dom/workers/RuntimeService.cpp
++++ b/dom/workers/RuntimeService.cpp
+@@ -78,17 +78,21 @@
+ 
+ #define WORKERS_SHUTDOWN_TOPIC "web-workers-shutdown"
+ 
+ namespace mozilla {
+ 
+ using namespace ipc;
+ 
+ namespace dom {
+-namespace workers {
++
++using namespace workers;
++using namespace workerinternals;
++
++namespace workerinternals {
+ 
+ // The size of the worker runtime heaps in bytes. May be changed via pref.
+ #define WORKER_DEFAULT_RUNTIME_HEAPSIZE 32 * 1024 * 1024
+ 
+ // The size of the generational GC nursery for workers, in bytes.
+ #define WORKER_DEFAULT_NURSERY_SIZE 1 * 1024 * 1024
+ 
+ // The size of the worker JS allocation threshold in MB. May be changed via pref.
+@@ -1244,141 +1248,16 @@ PlatformOverrideChanged(const char* /* a
+   RuntimeService* runtime = RuntimeService::GetService();
+   if (runtime) {
+     runtime->UpdatePlatformOverridePreference(override);
+   }
+ }
+ 
+ } /* anonymous namespace */
+ 
+-void
+-CancelWorkersForWindow(nsPIDOMWindowInner* aWindow)
+-{
+-  AssertIsOnMainThread();
+-  RuntimeService* runtime = RuntimeService::GetService();
+-  if (runtime) {
+-    runtime->CancelWorkersForWindow(aWindow);
+-  }
+-}
+-
+-void
+-FreezeWorkersForWindow(nsPIDOMWindowInner* aWindow)
+-{
+-  AssertIsOnMainThread();
+-  RuntimeService* runtime = RuntimeService::GetService();
+-  if (runtime) {
+-    runtime->FreezeWorkersForWindow(aWindow);
+-  }
+-}
+-
+-void
+-ThawWorkersForWindow(nsPIDOMWindowInner* aWindow)
+-{
+-  AssertIsOnMainThread();
+-  RuntimeService* runtime = RuntimeService::GetService();
+-  if (runtime) {
+-    runtime->ThawWorkersForWindow(aWindow);
+-  }
+-}
+-
+-void
+-SuspendWorkersForWindow(nsPIDOMWindowInner* aWindow)
+-{
+-  AssertIsOnMainThread();
+-  RuntimeService* runtime = RuntimeService::GetService();
+-  if (runtime) {
+-    runtime->SuspendWorkersForWindow(aWindow);
+-  }
+-}
+-
+-void
+-ResumeWorkersForWindow(nsPIDOMWindowInner* aWindow)
+-{
+-  AssertIsOnMainThread();
+-  RuntimeService* runtime = RuntimeService::GetService();
+-  if (runtime) {
+-    runtime->ResumeWorkersForWindow(aWindow);
+-  }
+-}
+-
+-WorkerPrivate*
+-GetWorkerPrivateFromContext(JSContext* aCx)
+-{
+-  MOZ_ASSERT(!NS_IsMainThread());
+-  MOZ_ASSERT(aCx);
+-
+-  void* cxPrivate = JS_GetContextPrivate(aCx);
+-  if (!cxPrivate) {
+-    return nullptr;
+-  }
+-
+-  return
+-    static_cast<WorkerThreadContextPrivate*>(cxPrivate)->GetWorkerPrivate();
+-}
+-
+-WorkerPrivate*
+-GetCurrentThreadWorkerPrivate()
+-{
+-  MOZ_ASSERT(!NS_IsMainThread());
+-
+-  CycleCollectedJSContext* ccjscx = CycleCollectedJSContext::Get();
+-  if (!ccjscx) {
+-    return nullptr;
+-  }
+-
+-  JSContext* cx = ccjscx->Context();
+-  MOZ_ASSERT(cx);
+-
+-  // Note that we can return nullptr if the nsCycleCollector_shutdown() in
+-  // ~WorkerJSContext() triggers any calls to GetCurrentThreadWorkerPrivate().
+-  // At this stage CycleCollectedJSContext::Get() will still return a context,
+-  // but the context private has already been cleared.
+-  return GetWorkerPrivateFromContext(cx);
+-}
+-
+-bool
+-IsCurrentThreadRunningChromeWorker()
+-{
+-  return GetCurrentThreadWorkerPrivate()->UsesSystemPrincipal();
+-}
+-
+-JSContext*
+-GetCurrentThreadJSContext()
+-{
+-  WorkerPrivate* wp = GetCurrentThreadWorkerPrivate();
+-  if (!wp) {
+-    return nullptr;
+-  }
+-  return wp->GetJSContext();
+-}
+-
+-JSObject*
+-GetCurrentThreadWorkerGlobal()
+-{
+-  WorkerPrivate* wp = GetCurrentThreadWorkerPrivate();
+-  if (!wp) {
+-    return nullptr;
+-  }
+-  WorkerGlobalScope* scope = wp->GlobalScope();
+-  if (!scope) {
+-    return nullptr;
+-  }
+-  return scope->GetGlobalJSObject();
+-}
+-
+-#ifdef DEBUG
+-
+-void
+-AssertIsOnMainThread()
+-{
+-  MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!");
+-}
+-
+-#endif
+-
+ struct RuntimeService::IdleThreadInfo
+ {
+   RefPtr<WorkerThread> mThread;
+   mozilla::TimeStamp mExpirationTime;
+ };
+ 
+ // This is only touched on the main thread. Initialized in Init() below.
+ JSSettings RuntimeService::sDefaultJSSettings;
+@@ -2905,11 +2784,141 @@ WorkerThreadPrimaryRunnable::FinishedRun
+   }
+   else if (thread->ShutdownRequired()) {
+     MOZ_ALWAYS_SUCCEEDS(thread->Shutdown());
+   }
+ 
+   return NS_OK;
+ }
+ 
++} // workerinternals namespace
++
++namespace workers {
++
++void
++CancelWorkersForWindow(nsPIDOMWindowInner* aWindow)
++{
++  AssertIsOnMainThread();
++  RuntimeService* runtime = RuntimeService::GetService();
++  if (runtime) {
++    runtime->CancelWorkersForWindow(aWindow);
++  }
++}
++
++void
++FreezeWorkersForWindow(nsPIDOMWindowInner* aWindow)
++{
++  AssertIsOnMainThread();
++  RuntimeService* runtime = RuntimeService::GetService();
++  if (runtime) {
++    runtime->FreezeWorkersForWindow(aWindow);
++  }
++}
++
++void
++ThawWorkersForWindow(nsPIDOMWindowInner* aWindow)
++{
++  AssertIsOnMainThread();
++  RuntimeService* runtime = RuntimeService::GetService();
++  if (runtime) {
++    runtime->ThawWorkersForWindow(aWindow);
++  }
++}
++
++void
++SuspendWorkersForWindow(nsPIDOMWindowInner* aWindow)
++{
++  AssertIsOnMainThread();
++  RuntimeService* runtime = RuntimeService::GetService();
++  if (runtime) {
++    runtime->SuspendWorkersForWindow(aWindow);
++  }
++}
++
++void
++ResumeWorkersForWindow(nsPIDOMWindowInner* aWindow)
++{
++  AssertIsOnMainThread();
++  RuntimeService* runtime = RuntimeService::GetService();
++  if (runtime) {
++    runtime->ResumeWorkersForWindow(aWindow);
++  }
++}
++
++WorkerPrivate*
++GetWorkerPrivateFromContext(JSContext* aCx)
++{
++  MOZ_ASSERT(!NS_IsMainThread());
++  MOZ_ASSERT(aCx);
++
++  void* cxPrivate = JS_GetContextPrivate(aCx);
++  if (!cxPrivate) {
++    return nullptr;
++  }
++
++  return
++    static_cast<WorkerThreadContextPrivate*>(cxPrivate)->GetWorkerPrivate();
++}
++
++WorkerPrivate*
++GetCurrentThreadWorkerPrivate()
++{
++  MOZ_ASSERT(!NS_IsMainThread());
++
++  CycleCollectedJSContext* ccjscx = CycleCollectedJSContext::Get();
++  if (!ccjscx) {
++    return nullptr;
++  }
++
++  JSContext* cx = ccjscx->Context();
++  MOZ_ASSERT(cx);
++
++  // Note that we can return nullptr if the nsCycleCollector_shutdown() in
++  // ~WorkerJSContext() triggers any calls to GetCurrentThreadWorkerPrivate().
++  // At this stage CycleCollectedJSContext::Get() will still return a context,
++  // but the context private has already been cleared.
++  return GetWorkerPrivateFromContext(cx);
++}
++
++bool
++IsCurrentThreadRunningChromeWorker()
++{
++  return GetCurrentThreadWorkerPrivate()->UsesSystemPrincipal();
++}
++
++JSContext*
++GetCurrentThreadJSContext()
++{
++  WorkerPrivate* wp = GetCurrentThreadWorkerPrivate();
++  if (!wp) {
++    return nullptr;
++  }
++  return wp->GetJSContext();
++}
++
++JSObject*
++GetCurrentThreadWorkerGlobal()
++{
++  WorkerPrivate* wp = GetCurrentThreadWorkerPrivate();
++  if (!wp) {
++    return nullptr;
++  }
++  WorkerGlobalScope* scope = wp->GlobalScope();
++  if (!scope) {
++    return nullptr;
++  }
++  return scope->GetGlobalJSObject();
++}
++
++#ifdef DEBUG
++
++void
++AssertIsOnMainThread()
++{
++  MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!");
++}
++
++#endif
++
+ } // workers namespace
++
+ } // dom namespace
+ } // mozilla namespace
+diff --git a/dom/workers/RuntimeService.h b/dom/workers/RuntimeService.h
+--- a/dom/workers/RuntimeService.h
++++ b/dom/workers/RuntimeService.h
+@@ -7,30 +7,31 @@
+ #ifndef mozilla_dom_workers_runtimeservice_h__
+ #define mozilla_dom_workers_runtimeservice_h__
+ 
+ #include "WorkerCommon.h"
+ 
+ #include "nsIObserver.h"
+ 
+ #include "mozilla/dom/BindingDeclarations.h"
++#include "mozilla/dom/workerinternals/JSSettings.h"
+ #include "nsClassHashtable.h"
+ #include "nsHashKeys.h"
+ #include "nsTArray.h"
+ 
+ class nsITimer;
+ class nsPIDOMWindowInner;
+ 
+ namespace mozilla {
+ namespace dom {
+ class SharedWorker;
+ struct WorkerLoadInfo;
+ class WorkerThread;
+ 
+-namespace workers {
++namespace workerinternals {
+ 
+ class RuntimeService final : public nsIObserver
+ {
+   struct SharedWorkerInfo
+   {
+     WorkerPrivate* mWorkerPrivate;
+     nsCString mScriptSpec;
+     nsString mName;
+@@ -88,17 +89,17 @@ class RuntimeService final : public nsIO
+ 
+   // *Not* protected by mMutex.
+   nsClassHashtable<nsPtrHashKey<nsPIDOMWindowInner>,
+                    nsTArray<WorkerPrivate*> > mWindowMap;
+ 
+   // Only used on the main thread.
+   nsCOMPtr<nsITimer> mIdleThreadTimer;
+ 
+-  static JSSettings sDefaultJSSettings;
++  static workerinternals::JSSettings sDefaultJSSettings;
+ 
+ public:
+   struct NavigatorProperties
+   {
+     nsString mAppName;
+     nsString mAppNameOverridden;
+     nsString mAppVersion;
+     nsString mAppVersionOverridden;
+@@ -164,26 +165,26 @@ public:
+   {
+     return mNavigatorProperties;
+   }
+ 
+   void
+   NoteIdleThread(WorkerThread* aThread);
+ 
+   static void
+-  GetDefaultJSSettings(JSSettings& aSettings)
++  GetDefaultJSSettings(workerinternals::JSSettings& aSettings)
+   {
+-    AssertIsOnMainThread();
++    workers::AssertIsOnMainThread();
+     aSettings = sDefaultJSSettings;
+   }
+ 
+   static void
+   SetDefaultContextOptions(const JS::ContextOptions& aContextOptions)
+   {
+-    AssertIsOnMainThread();
++    workers::AssertIsOnMainThread();
+     sDefaultJSSettings.contextOptions = aContextOptions;
+   }
+ 
+   void
+   UpdateAppNameOverridePreference(const nsAString& aValue);
+ 
+   void
+   UpdateAppVersionOverridePreference(const nsAString& aValue);
+@@ -195,28 +196,28 @@ public:
+   UpdateAllWorkerContextOptions();
+ 
+   void
+   UpdateAllWorkerLanguages(const nsTArray<nsString>& aLanguages);
+ 
+   static void
+   SetDefaultJSGCSettings(JSGCParamKey aKey, uint32_t aValue)
+   {
+-    AssertIsOnMainThread();
++    workers::AssertIsOnMainThread();
+     sDefaultJSSettings.ApplyGCSetting(aKey, aValue);
+   }
+ 
+   void
+   UpdateAllWorkerMemoryParameter(JSGCParamKey aKey, uint32_t aValue);
+ 
+ #ifdef JS_GC_ZEAL
+   static void
+   SetDefaultGCZeal(uint8_t aGCZeal, uint32_t aFrequency)
+   {
+-    AssertIsOnMainThread();
++    workers::AssertIsOnMainThread();
+     sDefaultJSSettings.gcZeal = aGCZeal;
+     sDefaultJSSettings.gcZealFrequency = aFrequency;
+   }
+ 
+   void
+   UpdateAllWorkerGCZeal();
+ #endif
+ 
+@@ -265,13 +266,13 @@ private:
+   nsresult
+   CreateSharedWorkerFromLoadInfo(JSContext* aCx,
+                                  WorkerLoadInfo* aLoadInfo,
+                                  const nsAString& aScriptURL,
+                                  const nsAString& aName,
+                                  SharedWorker** aSharedWorker);
+ };
+ 
+-} // workers namespace
++} // workerinternals namespace
+ } // dom namespace
+ } // mozilla namespace
+ 
+ #endif /* mozilla_dom_workers_runtimeservice_h__ */
+diff --git a/dom/workers/SharedWorker.cpp b/dom/workers/SharedWorker.cpp
+--- a/dom/workers/SharedWorker.cpp
++++ b/dom/workers/SharedWorker.cpp
+@@ -53,17 +53,18 @@ SharedWorker::~SharedWorker()
+ already_AddRefed<SharedWorker>
+ SharedWorker::Constructor(const GlobalObject& aGlobal,
+                           const nsAString& aScriptURL,
+                           const StringOrWorkerOptions& aOptions,
+                           ErrorResult& aRv)
+ {
+   AssertIsOnMainThread();
+ 
+-  workers::RuntimeService* rts = workers::RuntimeService::GetOrCreateService();
++  workerinternals::RuntimeService* rts =
++    workerinternals::RuntimeService::GetOrCreateService();
+   if (!rts) {
+     aRv = NS_ERROR_NOT_AVAILABLE;
+     return nullptr;
+   }
+ 
+   nsAutoString name;
+   if (aOptions.IsString()) {
+     name = aOptions.GetAsString();
+diff --git a/dom/workers/SharedWorker.h b/dom/workers/SharedWorker.h
+--- a/dom/workers/SharedWorker.h
++++ b/dom/workers/SharedWorker.h
+@@ -22,23 +22,23 @@ class nsPIDOMWindowInner;
+ namespace mozilla {
+ class EventChainPreVisitor;
+ 
+ namespace dom {
+ class MessagePort;
+ class StringOrWorkerOptions;
+ class WorkerPrivate;
+ 
+-namespace workers {
++namespace workerinternals {
+ class RuntimeService;
+ }
+ 
+ class SharedWorker final : public DOMEventTargetHelper
+ {
+-  friend class workers::RuntimeService;
++  friend class workerinternals::RuntimeService;
+ 
+   typedef mozilla::ErrorResult ErrorResult;
+   typedef mozilla::dom::GlobalObject GlobalObject;
+ 
+   RefPtr<WorkerPrivate> mWorkerPrivate;
+   RefPtr<MessagePort> mMessagePort;
+   nsTArray<nsCOMPtr<nsIDOMEvent>> mFrozenEvents;
+   bool mFrozen;
+diff --git a/dom/workers/WorkerCommon.h b/dom/workers/WorkerCommon.h
+--- a/dom/workers/WorkerCommon.h
++++ b/dom/workers/WorkerCommon.h
+@@ -32,125 +32,16 @@ enum WorkerType
+   WorkerTypeShared,
+   WorkerTypeService
+ };
+ 
+ class WorkerPrivate;
+ 
+ namespace workers {
+ 
+-struct PrivatizableBase
+-{ };
+-
+-struct JSSettings
+-{
+-  enum {
+-    // All the GC parameters that we support.
+-    JSSettings_JSGC_MAX_BYTES = 0,
+-    JSSettings_JSGC_MAX_MALLOC_BYTES,
+-    JSSettings_JSGC_HIGH_FREQUENCY_TIME_LIMIT,
+-    JSSettings_JSGC_LOW_FREQUENCY_HEAP_GROWTH,
+-    JSSettings_JSGC_HIGH_FREQUENCY_HEAP_GROWTH_MIN,
+-    JSSettings_JSGC_HIGH_FREQUENCY_HEAP_GROWTH_MAX,
+-    JSSettings_JSGC_HIGH_FREQUENCY_LOW_LIMIT,
+-    JSSettings_JSGC_HIGH_FREQUENCY_HIGH_LIMIT,
+-    JSSettings_JSGC_ALLOCATION_THRESHOLD,
+-    JSSettings_JSGC_SLICE_TIME_BUDGET,
+-    JSSettings_JSGC_DYNAMIC_HEAP_GROWTH,
+-    JSSettings_JSGC_DYNAMIC_MARK_SLICE,
+-    // JSGC_MODE not supported
+-
+-    // This must be last so that we get an accurate count.
+-    kGCSettingsArraySize
+-  };
+-
+-  struct JSGCSetting
+-  {
+-    mozilla::Maybe<JSGCParamKey> key;
+-    uint32_t value;
+-
+-    JSGCSetting()
+-    : key(), value(0)
+-    { }
+-  };
+-
+-  // There are several settings that we know we need so it makes sense to
+-  // preallocate here.
+-  typedef JSGCSetting JSGCSettingsArray[kGCSettingsArraySize];
+-
+-  // Settings that change based on chrome/content context.
+-  struct JSContentChromeSettings
+-  {
+-    JS::CompartmentOptions compartmentOptions;
+-    int32_t maxScriptRuntime;
+-
+-    JSContentChromeSettings()
+-    : compartmentOptions(), maxScriptRuntime(0)
+-    { }
+-  };
+-
+-  JSContentChromeSettings chrome;
+-  JSContentChromeSettings content;
+-  JSGCSettingsArray gcSettings;
+-  JS::ContextOptions contextOptions;
+-
+-#ifdef JS_GC_ZEAL
+-  uint8_t gcZeal;
+-  uint32_t gcZealFrequency;
+-#endif
+-
+-  JSSettings()
+-#ifdef JS_GC_ZEAL
+-  : gcZeal(0), gcZealFrequency(0)
+-#endif
+-  {
+-    for (uint32_t index = 0; index < ArrayLength(gcSettings); index++) {
+-      new (gcSettings + index) JSGCSetting();
+-    }
+-  }
+-
+-  bool
+-  ApplyGCSetting(JSGCParamKey aKey, uint32_t aValue)
+-  {
+-    JSSettings::JSGCSetting* firstEmptySetting = nullptr;
+-    JSSettings::JSGCSetting* foundSetting = nullptr;
+-
+-    for (uint32_t index = 0; index < ArrayLength(gcSettings); index++) {
+-      JSSettings::JSGCSetting& setting = gcSettings[index];
+-      if (setting.key.isSome() && *setting.key == aKey) {
+-        foundSetting = &setting;
+-        break;
+-      }
+-      if (!firstEmptySetting && setting.key.isNothing()) {
+-        firstEmptySetting = &setting;
+-      }
+-    }
+-
+-    if (aValue) {
+-      if (!foundSetting) {
+-        foundSetting = firstEmptySetting;
+-        if (!foundSetting) {
+-          NS_ERROR("Not enough space for this value!");
+-          return false;
+-        }
+-      }
+-      foundSetting->key = mozilla::Some(aKey);
+-      foundSetting->value = aValue;
+-      return true;
+-    }
+-
+-    if (foundSetting) {
+-      foundSetting->key.reset();
+-      return true;
+-    }
+-
+-    return false;
+-  }
+-};
+-
+ // All of these are implemented in RuntimeService.cpp
+ 
+ #ifdef DEBUG
+ void
+ AssertIsOnMainThread();
+ #else
+ inline void
+ AssertIsOnMainThread()
+@@ -193,16 +84,13 @@ bool
+ IsWorkerGlobal(JSObject* global);
+ 
+ bool
+ IsDebuggerGlobal(JSObject* global);
+ 
+ bool
+ IsDebuggerSandbox(JSObject* object);
+ 
+-// Random unique constant to facilitate JSPrincipal debugging
+-const uint32_t kJSPrincipalsDebugToken = 0x7e2df9d2;
+-
+ } // workers namespace
+ } // dom namespace
+ } // mozilla namespace
+ 
+ #endif // mozilla_dom_workers_WorkerCommon_h
+diff --git a/dom/workers/WorkerDebugger.h b/dom/workers/WorkerDebugger.h
+--- a/dom/workers/WorkerDebugger.h
++++ b/dom/workers/WorkerDebugger.h
+@@ -2,17 +2,17 @@
+ /* vim: set ts=8 sts=2 et sw=2 tw=80: */
+ /* 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/. */
+ 
+ #ifndef mozilla_dom_workers_WorkerDebugger_h
+ #define mozilla_dom_workers_WorkerDebugger_h
+ 
+-#include "mozilla/dom/workers/WorkerCommon.h"
++#include "mozilla/dom/WorkerCommon.h"
+ #include "nsIWorkerDebugger.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+ class WorkerPrivate;
+ 
+ class WorkerDebugger : public nsIWorkerDebugger
+diff --git a/dom/workers/WorkerDebuggerManager.h b/dom/workers/WorkerDebuggerManager.h
+--- a/dom/workers/WorkerDebuggerManager.h
++++ b/dom/workers/WorkerDebuggerManager.h
+@@ -2,17 +2,17 @@
+ /* vim: set ts=8 sts=2 et sw=2 tw=80: */
+ /* 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/. */
+ 
+ #ifndef mozilla_dom_workers_workerdebuggermanager_h
+ #define mozilla_dom_workers_workerdebuggermanager_h
+ 
+-#include "mozilla/dom/workers/WorkerCommon.h"
++#include "mozilla/dom/WorkerCommon.h"
+ 
+ #include "nsIObserver.h"
+ #include "nsIWorkerDebuggerManager.h"
+ 
+ #include "nsServiceManagerUtils.h"
+ #include "nsTArray.h"
+ #include "nsThreadUtils.h"
+ 
+diff --git a/dom/workers/WorkerHolder.h b/dom/workers/WorkerHolder.h
+--- a/dom/workers/WorkerHolder.h
++++ b/dom/workers/WorkerHolder.h
+@@ -2,17 +2,17 @@
+ /* vim: set ts=8 sts=2 et sw=2 tw=80: */
+ /* 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/. */
+ 
+ #ifndef mozilla_dom_workers_WorkerHolder_h
+ #define mozilla_dom_workers_WorkerHolder_h
+ 
+-#include "mozilla/dom/workers/WorkerCommon.h"
++#include "mozilla/dom/WorkerCommon.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+ class WorkerPrivate;
+ 
+ /**
+  * Use this chart to help figure out behavior during each of the closing
+diff --git a/dom/workers/WorkerLoadInfo.h b/dom/workers/WorkerLoadInfo.h
+--- a/dom/workers/WorkerLoadInfo.h
++++ b/dom/workers/WorkerLoadInfo.h
+@@ -3,17 +3,17 @@
+ /* 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/. */
+ 
+ #ifndef mozilla_dom_workers_WorkerLoadInfo_h
+ #define mozilla_dom_workers_WorkerLoadInfo_h
+ 
+ #include "mozilla/dom/ChannelInfo.h"
+-#include "mozilla/dom/workers/WorkerCommon.h"
++#include "mozilla/dom/WorkerCommon.h"
+ #include "mozilla/net/ReferrerPolicy.h"
+ #include "nsIInterfaceRequestor.h"
+ #include "nsILoadContext.h"
+ #include "nsIRequest.h"
+ #include "nsISupportsImpl.h"
+ #include "nsIWeakReferenceUtils.h"
+ 
+ class nsIChannel;
+diff --git a/dom/workers/WorkerNavigator.h b/dom/workers/WorkerNavigator.h
+--- a/dom/workers/WorkerNavigator.h
++++ b/dom/workers/WorkerNavigator.h
+@@ -20,17 +20,17 @@ class Promise;
+ class StorageManager;
+ 
+ namespace network {
+ class Connection;
+ } // namespace network
+ 
+ class WorkerNavigator final : public nsWrapperCache
+ {
+-  typedef struct workers::RuntimeService::NavigatorProperties NavigatorProperties;
++  typedef struct workerinternals::RuntimeService::NavigatorProperties NavigatorProperties;
+ 
+   NavigatorProperties mProperties;
+   RefPtr<StorageManager> mStorageManager;
+   RefPtr<network::Connection> mConnection;
+   bool mOnline;
+ 
+   WorkerNavigator(const NavigatorProperties& aProperties, bool aOnline);
+   ~WorkerNavigator();
+diff --git a/dom/workers/WorkerPrivate.cpp b/dom/workers/WorkerPrivate.cpp
+--- a/dom/workers/WorkerPrivate.cpp
++++ b/dom/workers/WorkerPrivate.cpp
+@@ -90,16 +90,17 @@ TimeoutsLog()
+   return sWorkerTimeoutsLog;
+ }
+ 
+ #define LOG(log, _args) MOZ_LOG(log, LogLevel::Debug, _args);
+ 
+ using namespace mozilla;
+ using namespace mozilla::dom;
+ using namespace mozilla::dom::workers;
++using namespace mozilla::dom::workerinternals;
+ using namespace mozilla::ipc;
+ 
+ MOZ_DEFINE_MALLOC_SIZE_OF(JsWorkerMallocSizeOf)
+ 
+ namespace {
+ 
+ #ifdef DEBUG
+ 
+@@ -236,17 +237,17 @@ private:
+ 
+   virtual bool
+   WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate) override
+   {
+     if (!mFinishedWorker->ProxyReleaseMainThreadObjects()) {
+       NS_WARNING("Failed to dispatch, going to leak!");
+     }
+ 
+-    workers::RuntimeService* runtime = workers::RuntimeService::GetService();
++    RuntimeService* runtime = RuntimeService::GetService();
+     NS_ASSERTION(runtime, "This should never be null!");
+ 
+     mFinishedWorker->DisableDebugger();
+ 
+     runtime->UnregisterWorker(mFinishedWorker);
+ 
+     mFinishedWorker->ClearSelfRef();
+     return true;
+@@ -268,19 +269,19 @@ public:
+   NS_DECL_ISUPPORTS_INHERITED
+ 
+ private:
+   ~TopLevelWorkerFinishedRunnable() {}
+ 
+   NS_IMETHOD
+   Run() override
+   {
+-    workers::AssertIsOnMainThread();
+-
+-    workers::RuntimeService* runtime = workers::RuntimeService::GetService();
++    AssertIsOnMainThread();
++
++    RuntimeService* runtime = RuntimeService::GetService();
+     MOZ_ASSERT(runtime);
+ 
+     mFinishedWorker->DisableDebugger();
+ 
+     runtime->UnregisterWorker(mFinishedWorker);
+ 
+     if (!mFinishedWorker->ProxyReleaseMainThreadObjects()) {
+       NS_WARNING("Failed to dispatch, going to leak!");
+@@ -550,17 +551,17 @@ class ReportErrorToConsoleRunnable final
+ public:
+   // aWorkerPrivate is the worker thread we're on (or the main thread, if null)
+   static void
+   Report(WorkerPrivate* aWorkerPrivate, const char* aMessage)
+   {
+     if (aWorkerPrivate) {
+       aWorkerPrivate->AssertIsOnWorkerThread();
+     } else {
+-      workers::AssertIsOnMainThread();
++      AssertIsOnMainThread();
+     }
+ 
+     // Now fire a runnable to do the same on the parent's thread if we can.
+     if (aWorkerPrivate) {
+       RefPtr<ReportErrorToConsoleRunnable> runnable =
+         new ReportErrorToConsoleRunnable(aWorkerPrivate, aMessage);
+       runnable->Dispatch();
+       return;
+@@ -1208,17 +1209,17 @@ private:
+     {
+       mSuccess = success;
+     }
+ 
+   private:
+     ~FinishCollectRunnable()
+     {
+       // mHandleReport and mHandlerData are released on the main thread.
+-      workers::AssertIsOnMainThread();
++      AssertIsOnMainThread();
+     }
+ 
+     FinishCollectRunnable(const FinishCollectRunnable&) = delete;
+     FinishCollectRunnable& operator=(const FinishCollectRunnable&) = delete;
+     FinishCollectRunnable& operator=(const FinishCollectRunnable&&) = delete;
+   };
+ 
+   ~MemoryReporter()
+@@ -1242,17 +1243,17 @@ private:
+ 
+ NS_IMPL_ISUPPORTS(WorkerPrivate::MemoryReporter, nsIMemoryReporter)
+ 
+ NS_IMETHODIMP
+ WorkerPrivate::MemoryReporter::CollectReports(nsIHandleReportCallback* aHandleReport,
+                                               nsISupports* aData,
+                                               bool aAnonymize)
+ {
+-  workers::AssertIsOnMainThread();
++  AssertIsOnMainThread();
+ 
+   RefPtr<CollectReportsRunnable> runnable;
+ 
+   {
+     MutexAutoLock lock(mMutex);
+ 
+     if (!mWorkerPrivate) {
+       // This will effectively report 0 memory.
+@@ -1294,17 +1295,17 @@ WorkerPrivate::MemoryReporter::CollectRe
+   }
+ 
+   return NS_OK;
+ }
+ 
+ void
+ WorkerPrivate::MemoryReporter::TryToMapAddon(nsACString &path)
+ {
+-  workers::AssertIsOnMainThread();
++  AssertIsOnMainThread();
+   mMutex.AssertCurrentThreadOwns();
+ 
+   if (mAlreadyMappedToAddon || !mWorkerPrivate) {
+     return;
+   }
+ 
+   nsCOMPtr<nsIURI> scriptURI;
+   if (NS_FAILED(NS_NewURI(getter_AddRefs(scriptURI),
+@@ -1383,17 +1384,17 @@ WorkerPrivate::MemoryReporter::FinishCol
+   , mAnonymize(aAnonymize)
+   , mSuccess(false)
+   , mCxStats(aPath)
+ { }
+ 
+ NS_IMETHODIMP
+ WorkerPrivate::MemoryReporter::FinishCollectRunnable::Run()
+ {
+-  workers::AssertIsOnMainThread();
++  AssertIsOnMainThread();
+ 
+   nsCOMPtr<nsIMemoryReporterManager> manager =
+     do_GetService("@mozilla.org/memory-reporter-manager;1");
+ 
+   if (!manager)
+     return NS_OK;
+ 
+   if (mSuccess) {
+@@ -1436,17 +1437,17 @@ WorkerPrivate::SyncLoopInfo::SyncLoopInf
+ #endif
+ {
+ }
+ 
+ template <class Derived>
+ nsIDocument*
+ WorkerPrivateParent<Derived>::GetDocument() const
+ {
+-  workers::AssertIsOnMainThread();
++  AssertIsOnMainThread();
+   if (mLoadInfo.mWindow) {
+     return mLoadInfo.mWindow->GetExtantDoc();
+   }
+   // if we don't have a document, we should query the document
+   // from the parent in case of a nested worker
+   WorkerPrivate* parent = mParent;
+   while (parent) {
+     if (parent->mLoadInfo.mWindow) {
+@@ -1457,31 +1458,31 @@ WorkerPrivateParent<Derived>::GetDocumen
+   // couldn't query a document, give up and return nullptr
+   return nullptr;
+ }
+ 
+ template <class Derived>
+ void
+ WorkerPrivateParent<Derived>::SetCSP(nsIContentSecurityPolicy* aCSP)
+ {
+-  workers::AssertIsOnMainThread();
++  AssertIsOnMainThread();
+   if (!aCSP) {
+     return;
+   }
+   WorkerPrivate* self = ParentAsWorkerPrivate();
+   aCSP->EnsureEventTarget(self->mMainThreadEventTarget);
+   mLoadInfo.mCSP = aCSP;
+ }
+ 
+ template <class Derived>
+ nsresult
+ WorkerPrivateParent<Derived>::SetCSPFromHeaderValues(const nsACString& aCSPHeaderValue,
+                                                      const nsACString& aCSPReportOnlyHeaderValue)
+ {
+-  workers::AssertIsOnMainThread();
++  AssertIsOnMainThread();
+   MOZ_DIAGNOSTIC_ASSERT(!mLoadInfo.mCSP);
+ 
+   NS_ConvertASCIItoUTF16 cspHeaderValue(aCSPHeaderValue);
+   NS_ConvertASCIItoUTF16 cspROHeaderValue(aCSPReportOnlyHeaderValue);
+ 
+   nsCOMPtr<nsIContentSecurityPolicy> csp;
+   nsresult rv = mLoadInfo.mPrincipal->EnsureCSP(nullptr, getter_AddRefs(csp));
+   if (!csp) {
+@@ -1571,17 +1572,17 @@ WorkerPrivateParent<Derived>::WorkerPriv
+   mIsChromeWorker(aIsChromeWorker), mMainThreadObjectsForgotten(false),
+   mIsSecureContext(false), mWorkerType(aWorkerType),
+   mCreationTimeStamp(TimeStamp::Now()),
+   mCreationTimeHighRes((double)PR_Now() / PR_USEC_PER_MSEC)
+ {
+   MOZ_ASSERT_IF(!IsDedicatedWorker(), NS_IsMainThread());
+ 
+   if (aLoadInfo.mWindow) {
+-    workers::AssertIsOnMainThread();
++    AssertIsOnMainThread();
+     MOZ_ASSERT(aLoadInfo.mWindow->IsInnerWindow(),
+                "Should have inner window here!");
+     BindToOwner(aLoadInfo.mWindow);
+   }
+ 
+   mLoadInfo.StealFrom(aLoadInfo);
+ 
+   if (aParent) {
+@@ -1597,19 +1598,19 @@ WorkerPrivateParent<Derived>::WorkerPriv
+ 
+     MOZ_ASSERT(IsDedicatedWorker());
+ 
+     if (aParent->mParentFrozen) {
+       Freeze(nullptr);
+     }
+   }
+   else {
+-    workers::AssertIsOnMainThread();
+-
+-    workers::RuntimeService::GetDefaultJSSettings(mJSSettings);
++    AssertIsOnMainThread();
++
++    RuntimeService::GetDefaultJSSettings(mJSSettings);
+ 
+     // Our secure context state depends on the kind of worker we have.
+     if (UsesSystemPrincipal() || IsServiceWorker()) {
+       mIsSecureContext = true;
+     } else if (mLoadInfo.mWindow) {
+       // Shared and dedicated workers both inherit the loading window's secure
+       // context state.  Shared workers then prevent windows with a different
+       // secure context state from attaching to them.
+@@ -1863,17 +1864,17 @@ WorkerPrivateParent<Derived>::NotifyPriv
+       return true;
+     }
+ 
+     pending = mParentStatus == Pending;
+     mParentStatus = aStatus;
+   }
+ 
+   if (IsSharedWorker()) {
+-    workers::RuntimeService* runtime = workers::RuntimeService::GetService();
++    RuntimeService* runtime = RuntimeService::GetService();
+     MOZ_ASSERT(runtime);
+ 
+     runtime->ForgetSharedWorker(ParentAsWorkerPrivate());
+   }
+ 
+   if (pending) {
+     WorkerPrivate* self = ParentAsWorkerPrivate();
+ 
+@@ -1911,17 +1912,17 @@ bool
+ WorkerPrivateParent<Derived>::Freeze(nsPIDOMWindowInner* aWindow)
+ {
+   AssertIsOnParentThread();
+ 
+   // Shared workers are only frozen if all of their owning documents are
+   // frozen. It can happen that mSharedWorkers is empty but this thread has
+   // not been unregistered yet.
+   if ((IsSharedWorker() || IsServiceWorker()) && !mSharedWorkers.IsEmpty()) {
+-    workers::AssertIsOnMainThread();
++    AssertIsOnMainThread();
+ 
+     bool allFrozen = true;
+ 
+     for (uint32_t i = 0; i < mSharedWorkers.Length(); ++i) {
+       if (aWindow && mSharedWorkers[i]->GetOwner() == aWindow) {
+         // Calling Freeze() may change the refcount, ensure that the worker
+         // outlives this call.
+         RefPtr<SharedWorker> kungFuDeathGrip = mSharedWorkers[i];
+@@ -1970,17 +1971,17 @@ WorkerPrivateParent<Derived>::Thaw(nsPID
+   AssertIsOnParentThread();
+ 
+   MOZ_ASSERT(mParentFrozen);
+ 
+   // Shared workers are resumed if any of their owning documents are thawed.
+   // It can happen that mSharedWorkers is empty but this thread has not been
+   // unregistered yet.
+   if ((IsSharedWorker() || IsServiceWorker()) && !mSharedWorkers.IsEmpty()) {
+-    workers::AssertIsOnMainThread();
++    AssertIsOnMainThread();
+ 
+     bool anyRunning = false;
+ 
+     for (uint32_t i = 0; i < mSharedWorkers.Length(); ++i) {
+       if (aWindow && mSharedWorkers[i]->GetOwner() == aWindow) {
+         // Calling Thaw() may change the refcount, ensure that the worker
+         // outlives this call.
+         RefPtr<SharedWorker> kungFuDeathGrip = mSharedWorkers[i];
+@@ -2037,26 +2038,26 @@ WorkerPrivateParent<Derived>::Thaw(nsPID
+ 
+   return true;
+ }
+ 
+ template <class Derived>
+ void
+ WorkerPrivateParent<Derived>::ParentWindowPaused()
+ {
+-  workers::AssertIsOnMainThread();
++  AssertIsOnMainThread();
+   MOZ_ASSERT_IF(IsDedicatedWorker(), mParentWindowPausedDepth == 0);
+   mParentWindowPausedDepth += 1;
+ }
+ 
+ template <class Derived>
+ void
+ WorkerPrivateParent<Derived>::ParentWindowResumed()
+ {
+-  workers::AssertIsOnMainThread();
++  AssertIsOnMainThread();
+ 
+   MOZ_ASSERT(mParentWindowPausedDepth > 0);
+   MOZ_ASSERT_IF(IsDedicatedWorker(), mParentWindowPausedDepth == 1);
+   mParentWindowPausedDepth -= 1;
+   if (mParentWindowPausedDepth > 0) {
+     return;
+   }
+ 
+@@ -2382,17 +2383,17 @@ WorkerPrivateParent<Derived>::MemoryPres
+   Unused << NS_WARN_IF(!runnable->Dispatch());
+ }
+ 
+ template <class Derived>
+ bool
+ WorkerPrivateParent<Derived>::RegisterSharedWorker(SharedWorker* aSharedWorker,
+                                                    MessagePort* aPort)
+ {
+-  workers::AssertIsOnMainThread();
++  AssertIsOnMainThread();
+   MOZ_ASSERT(aSharedWorker);
+   MOZ_ASSERT(IsSharedWorker());
+   MOZ_ASSERT(!mSharedWorkers.Contains(aSharedWorker));
+ 
+   if (IsSharedWorker()) {
+     RefPtr<MessagePortRunnable> runnable =
+       new MessagePortRunnable(ParentAsWorkerPrivate(), aPort);
+     if (!runnable->Dispatch()) {
+@@ -2413,17 +2414,17 @@ WorkerPrivateParent<Derived>::RegisterSh
+ 
+ template <class Derived>
+ void
+ WorkerPrivateParent<Derived>::BroadcastErrorToSharedWorkers(
+                                                     JSContext* aCx,
+                                                     const WorkerErrorReport* aReport,
+                                                     bool aIsErrorEvent)
+ {
+-  workers::AssertIsOnMainThread();
++  AssertIsOnMainThread();
+ 
+   if (aIsErrorEvent && JSREPORT_IS_WARNING(aReport->mFlags)) {
+     // Don't fire any events anywhere.  Just log to console.
+     // XXXbz should we log to all the consoles of all the relevant windows?
+     MOZ_ASSERT(aReport);
+     WorkerErrorReport::LogErrorToConsole(*aReport, 0);
+     return;
+   }
+@@ -2547,34 +2548,34 @@ WorkerPrivateParent<Derived>::BroadcastE
+   }
+ }
+ 
+ template <class Derived>
+ void
+ WorkerPrivateParent<Derived>::GetAllSharedWorkers(
+                                nsTArray<RefPtr<SharedWorker>>& aSharedWorkers)
+ {
+-  workers::AssertIsOnMainThread();
++  AssertIsOnMainThread();
+   MOZ_ASSERT(IsSharedWorker() || IsServiceWorker());
+ 
+   if (!aSharedWorkers.IsEmpty()) {
+     aSharedWorkers.Clear();
+   }
+ 
+   for (uint32_t i = 0; i < mSharedWorkers.Length(); ++i) {
+     aSharedWorkers.AppendElement(mSharedWorkers[i]);
+   }
+ }
+ 
+ template <class Derived>
+ void
+ WorkerPrivateParent<Derived>::CloseSharedWorkersForWindow(
+                                                     nsPIDOMWindowInner* aWindow)
+ {
+-  workers::AssertIsOnMainThread();
++  AssertIsOnMainThread();
+   MOZ_ASSERT(IsSharedWorker() || IsServiceWorker());
+   MOZ_ASSERT(aWindow);
+ 
+   bool someRemoved = false;
+ 
+   for (uint32_t i = 0; i < mSharedWorkers.Length();) {
+     if (mSharedWorkers[i]->GetOwner() == aWindow) {
+       mSharedWorkers[i]->Close();
+@@ -2601,46 +2602,46 @@ WorkerPrivateParent<Derived>::CloseShare
+     Cancel();
+   }
+ }
+ 
+ template <class Derived>
+ void
+ WorkerPrivateParent<Derived>::CloseAllSharedWorkers()
+ {
+-  workers::AssertIsOnMainThread();
++  AssertIsOnMainThread();
+   MOZ_ASSERT(IsSharedWorker() || IsServiceWorker());
+ 
+   for (uint32_t i = 0; i < mSharedWorkers.Length(); ++i) {
+     mSharedWorkers[i]->Close();
+   }
+ 
+   mSharedWorkers.Clear();
+ 
+   Cancel();
+ }
+ 
+ template <class Derived>
+ void
+ WorkerPrivateParent<Derived>::WorkerScriptLoaded()
+ {
+-  workers::AssertIsOnMainThread();
++  AssertIsOnMainThread();
+ 
+   if (IsSharedWorker() || IsServiceWorker()) {
+     // No longer need to hold references to the window or document we came from.
+     mLoadInfo.mWindow = nullptr;
+     mLoadInfo.mScriptContext = nullptr;
+   }
+ }
+ 
+ template <class Derived>
+ void
+ WorkerPrivateParent<Derived>::SetBaseURI(nsIURI* aBaseURI)
+ {
+-  workers::AssertIsOnMainThread();
++  AssertIsOnMainThread();
+ 
+   if (!mLoadInfo.mBaseURI) {
+     NS_ASSERTION(GetParent(), "Shouldn't happen without a parent!");
+     mLoadInfo.mResolvedScriptURI = aBaseURI;
+   }
+ 
+   mLoadInfo.mBaseURI = aBaseURI;
+ 
+@@ -2724,28 +2725,28 @@ WorkerPrivateParent<Derived>::PrincipalU
+   return mLoadInfo.PrincipalURIMatchesScriptURL();
+ }
+ #endif
+ 
+ template <class Derived>
+ void
+ WorkerPrivateParent<Derived>::UpdateOverridenLoadGroup(nsILoadGroup* aBaseLoadGroup)
+ {
+-  workers::AssertIsOnMainThread();
++  AssertIsOnMainThread();
+ 
+   // The load group should have been overriden at init time.
+   mLoadInfo.mInterfaceRequestor->MaybeAddTabChild(aBaseLoadGroup);
+ }
+ 
+ template <class Derived>
+ void
+ WorkerPrivateParent<Derived>::FlushReportsToSharedWorkers(
+                                            nsIConsoleReportCollector* aReporter)
+ {
+-  workers::AssertIsOnMainThread();
++  AssertIsOnMainThread();
+ 
+   AutoTArray<RefPtr<SharedWorker>, 10> sharedWorkers;
+   AutoTArray<WindowAction, 10> windowActions;
+   GetAllSharedWorkers(sharedWorkers);
+ 
+   // First find out all the shared workers' window.
+   for (size_t index = 0; index < sharedWorkers.Length(); index++) {
+     RefPtr<SharedWorker>& sharedWorker = sharedWorkers[index];
+@@ -2828,32 +2829,32 @@ NS_IMPL_CYCLE_COLLECTION_TRACE_END
+ template <class Derived>
+ void
+ WorkerPrivateParent<Derived>::AssertIsOnParentThread() const
+ {
+   if (GetParent()) {
+     GetParent()->AssertIsOnWorkerThread();
+   }
+   else {
+-    workers::AssertIsOnMainThread();
++    AssertIsOnMainThread();
+   }
+ }
+ 
+ template <class Derived>
+ void
+ WorkerPrivateParent<Derived>::AssertInnerWindowIsCorrect() const
+ {
+   AssertIsOnParentThread();
+ 
+   // Only care about top level workers from windows.
+   if (mParent || !mLoadInfo.mWindow) {
+     return;
+   }
+ 
+-  workers::AssertIsOnMainThread();
++  AssertIsOnMainThread();
+ 
+   nsPIDOMWindowOuter* outer = mLoadInfo.mWindow->GetOuterWindow();
+   NS_ASSERTION(outer && outer->GetCurrentInnerWindow() == mLoadInfo.mWindow,
+                "Inner window no longer correct!");
+ }
+ 
+ #endif
+ 
+@@ -2901,17 +2902,17 @@ WorkerPrivate::WorkerPrivate(WorkerPriva
+   , mFetchHandlerWasAdded(false)
+   , mOnLine(false)
+ {
+   if (aParent) {
+     aParent->AssertIsOnWorkerThread();
+     mOnLine = aParent->OnLine();
+   }
+   else {
+-    workers::AssertIsOnMainThread();
++    AssertIsOnMainThread();
+     mOnLine = !NS_IsOffline();
+   }
+ 
+   nsCOMPtr<nsISerialEventTarget> target;
+ 
+   // A child worker just inherits the parent workers ThrottledEventQueue
+   // and main thread target for now.  This is mainly due to the restriction
+   // that ThrottledEventQueue can only be created on the main thread at the
+@@ -3045,17 +3046,17 @@ WorkerPrivate::Constructor(JSContext* aC
+     parent->AssertIsOnWorkerThread();
+ 
+     holder.reset(new SimpleWorkerHolder());
+     if (!holder->HoldWorker(parent, Canceling)) {
+       aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
+       return nullptr;
+     }
+   } else {
+-    workers::AssertIsOnMainThread();
++    AssertIsOnMainThread();
+   }
+ 
+   Maybe<WorkerLoadInfo> stackLoadInfo;
+   if (!aLoadInfo) {
+     stackLoadInfo.emplace();
+ 
+     nsresult rv = GetLoadInfo(aCx, nullptr, parent, aScriptURL,
+                               aIsChromeWorker, InheritLoadGroup,
+@@ -3067,27 +3068,27 @@ WorkerPrivate::Constructor(JSContext* aC
+     }
+ 
+     aLoadInfo = stackLoadInfo.ptr();
+   }
+ 
+   // NB: This has to be done before creating the WorkerPrivate, because it will
+   // attempt to use static variables that are initialized in the RuntimeService
+   // constructor.
+-  workers::RuntimeService* runtimeService;
++  RuntimeService* runtimeService;
+ 
+   if (!parent) {
+-    runtimeService = workers::RuntimeService::GetOrCreateService();
++    runtimeService = RuntimeService::GetOrCreateService();
+     if (!runtimeService) {
+       aRv.Throw(NS_ERROR_FAILURE);
+       return nullptr;
+     }
+   }
+   else {
+-    runtimeService = workers::RuntimeService::GetService();
++    runtimeService = RuntimeService::GetService();
+   }
+ 
+   MOZ_ASSERT(runtimeService);
+ 
+   RefPtr<WorkerPrivate> worker =
+     new WorkerPrivate(parent, aScriptURL, aIsChromeWorker,
+                       aWorkerType, aWorkerName, aServiceWorkerScope,
+                       *aLoadInfo);
+@@ -3135,17 +3136,17 @@ WorkerPrivate::GetLoadInfo(JSContext* aC
+                            WorkerLoadInfo* aLoadInfo)
+ {
+   using namespace mozilla::dom::workerinternals;
+ 
+   MOZ_ASSERT(aCx);
+   MOZ_ASSERT_IF(NS_IsMainThread(), aCx == nsContentUtils::GetCurrentJSContext());
+ 
+   if (aWindow) {
+-    workers::AssertIsOnMainThread();
++    AssertIsOnMainThread();
+   }
+ 
+   WorkerLoadInfo loadInfo;
+   nsresult rv;
+ 
+   if (aParent) {
+     aParent->AssertIsOnWorkerThread();
+ 
+@@ -3185,17 +3186,17 @@ WorkerPrivate::GetLoadInfo(JSContext* aC
+     loadInfo.mFromWindow = aParent->IsFromWindow();
+     loadInfo.mWindowID = aParent->WindowID();
+     loadInfo.mStorageAllowed = aParent->IsStorageAllowed();
+     loadInfo.mOriginAttributes = aParent->GetOriginAttributes();
+     loadInfo.mServiceWorkersTestingInWindow =
+       aParent->ServiceWorkersTestingInWindow();
+     loadInfo.mParentController = aParent->GetController();
+   } else {
+-    workers::AssertIsOnMainThread();
++    AssertIsOnMainThread();
+ 
+     // Make sure that the IndexedDatabaseManager is set up
+     Unused << NS_WARN_IF(!IndexedDatabaseManager::GetOrCreate());
+ 
+     nsIScriptSecurityManager* ssm = nsContentUtils::GetSecurityManager();
+     MOZ_ASSERT(ssm);
+ 
+     bool isChrome = nsContentUtils::IsSystemCaller(aCx);
+@@ -5532,17 +5533,17 @@ WorkerPrivate::DumpCrashInformation(nsAC
+     aString.Append("|");
+     aString.Append(holder->Name());
+   }
+ }
+ 
+ PerformanceStorage*
+ WorkerPrivate::GetPerformanceStorage()
+ {
+-  workers::AssertIsOnMainThread();
++  AssertIsOnMainThread();
+ 
+   if (!mPerformanceStorage) {
+     mPerformanceStorage = PerformanceStorageWorker::Create(this);
+   }
+ 
+   return mPerformanceStorage;
+ }
+ 
+diff --git a/dom/workers/WorkerPrivate.h b/dom/workers/WorkerPrivate.h
+--- a/dom/workers/WorkerPrivate.h
++++ b/dom/workers/WorkerPrivate.h
+@@ -2,28 +2,29 @@
+ /* vim: set ts=8 sts=2 et sw=2 tw=80: */
+ /* 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/. */
+ 
+ #ifndef mozilla_dom_workers_workerprivate_h__
+ #define mozilla_dom_workers_workerprivate_h__
+ 
+-#include "mozilla/dom/workers/WorkerCommon.h"
++#include "mozilla/dom/WorkerCommon.h"
+ #include "mozilla/CondVar.h"
+ #include "mozilla/DOMEventTargetHelper.h"
+ #include "nsDOMNavigationTiming.h"
+ #include "nsIContentSecurityPolicy.h"
+ #include "nsIEventTarget.h"
+ #include "nsThreadUtils.h"
+ #include "nsTObserverArray.h"
+ 
+ #include "mozilla/dom/WorkerHolder.h"
+ #include "mozilla/dom/WorkerLoadInfo.h"
+-#include "mozilla/dom/workers/Queue.h"
++#include "mozilla/dom/workerinternals/JSSettings.h"
++#include "mozilla/dom/workerinternals/Queue.h"
+ 
+ #ifdef XP_WIN
+ #undef PostMessage
+ #endif
+ 
+ class nsIConsoleReportCollector;
+ class nsIThreadInternal;
+ 
+@@ -139,17 +140,17 @@ private:
+   WorkerLoadInfo mLoadInfo;
+ 
+   Atomic<bool> mLoadingWorkerScript;
+ 
+   // Only used for top level workers.
+   nsTArray<nsCOMPtr<nsIRunnable>> mQueuedRunnables;
+ 
+   // Protected by mMutex.
+-  workers::JSSettings mJSSettings;
++  workerinternals::JSSettings mJSSettings;
+ 
+   // Only touched on the parent thread (currently this is always the main
+   // thread as SharedWorkers are always top-level).
+   nsTArray<RefPtr<SharedWorker>> mSharedWorkers;
+ 
+   // This is touched on parent thread only, but it can be read on a different
+   // thread before crashing because hanging.
+   Atomic<uint64_t> mBusyCount;
+@@ -702,17 +703,17 @@ public:
+ 
+   LocationInfo&
+   GetLocationInfo()
+   {
+     return mLocationInfo;
+   }
+ 
+   void
+-  CopyJSSettings(workers::JSSettings& aSettings)
++  CopyJSSettings(workerinternals::JSSettings& aSettings)
+   {
+     mozilla::MutexAutoLock lock(mMutex);
+     aSettings = mJSSettings;
+   }
+ 
+   void
+   CopyJSCompartmentOptions(JS::CompartmentOptions& aOptions)
+   {
+@@ -884,18 +885,18 @@ class WorkerPrivate : public WorkerPriva
+     PeriodicTimer = 0,
+     IdleTimer,
+     NoTimer
+   };
+ 
+   bool mDebuggerRegistered;
+   WorkerDebugger* mDebugger;
+ 
+-  workersinternals::Queue<WorkerControlRunnable*, 4> mControlQueue;
+-  workersinternals::Queue<WorkerRunnable*, 4> mDebuggerQueue;
++  workerinternals::Queue<WorkerControlRunnable*, 4> mControlQueue;
++  workerinternals::Queue<WorkerRunnable*, 4> mDebuggerQueue;
+ 
+   // Touched on multiple threads, protected with mMutex.
+   JSContext* mJSContext;
+   RefPtr<WorkerThread> mThread;
+   PRThread* mPRThread;
+ 
+   // Things touched on worker thread only.
+   RefPtr<WorkerGlobalScope> mScope;
+diff --git a/dom/workers/WorkerRunnable.h b/dom/workers/WorkerRunnable.h
+--- a/dom/workers/WorkerRunnable.h
++++ b/dom/workers/WorkerRunnable.h
+@@ -2,17 +2,17 @@
+ /* vim: set ts=8 sts=2 et sw=2 tw=80: */
+ /* 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/. */
+ 
+ #ifndef mozilla_dom_workers_workerrunnable_h__
+ #define mozilla_dom_workers_workerrunnable_h__
+ 
+-#include "mozilla/dom/workers/WorkerCommon.h"
++#include "mozilla/dom/WorkerCommon.h"
+ #include "mozilla/dom/WorkerHolder.h"
+ 
+ #include "nsICancelableRunnable.h"
+ 
+ #include "mozilla/Atomics.h"
+ #include "nsISupportsImpl.h"
+ #include "nsThreadUtils.h" /* nsRunnable */
+ 
+diff --git a/dom/workers/WorkerScope.h b/dom/workers/WorkerScope.h
+--- a/dom/workers/WorkerScope.h
++++ b/dom/workers/WorkerScope.h
+@@ -2,17 +2,17 @@
+ /* vim: set ts=8 sts=2 et sw=2 tw=80: */
+ /* 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/. */
+ 
+ #ifndef mozilla_dom_workerscope_h__
+ #define mozilla_dom_workerscope_h__
+ 
+-#include "mozilla/dom/workers/WorkerCommon.h"
++#include "mozilla/dom/WorkerCommon.h"
+ #include "mozilla/DOMEventTargetHelper.h"
+ #include "mozilla/dom/Headers.h"
+ #include "mozilla/dom/RequestBinding.h"
+ #include "nsWeakReference.h"
+ #include "mozilla/dom/ImageBitmapSource.h"
+ 
+ #ifdef XP_WIN
+ #undef PostMessage
+diff --git a/dom/workers/WorkerThread.h b/dom/workers/WorkerThread.h
+--- a/dom/workers/WorkerThread.h
++++ b/dom/workers/WorkerThread.h
+@@ -18,26 +18,26 @@ class nsIRunnable;
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+ class WorkerRunnable;
+ class WorkerPrivate;
+ template <class> class WorkerPrivateParent;
+ 
+-namespace workers {
++namespace workerinternals {
+ class RuntimeService;
+ }
+ 
+ // This class lets us restrict the public methods that can be called on
+ // WorkerThread to RuntimeService and WorkerPrivate without letting them gain
+ // full access to private methods (as would happen if they were simply friends).
+ class WorkerThreadFriendKey
+ {
+-  friend class workers::RuntimeService;
++  friend class workerinternals::RuntimeService;
+   friend class WorkerPrivate;
+   friend class WorkerPrivateParent<WorkerPrivate>;
+ 
+   WorkerThreadFriendKey();
+   ~WorkerThreadFriendKey();
+ };
+ 
+ class WorkerThread final
+diff --git a/dom/workers/moz.build b/dom/workers/moz.build
+--- a/dom/workers/moz.build
++++ b/dom/workers/moz.build
+@@ -5,32 +5,34 @@
+ # file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ 
+ with Files("**"):
+     BUG_COMPONENT = ("Core", "DOM: Workers")
+ 
+ # Public stuff.
+ EXPORTS.mozilla.dom += [
+     'SharedWorker.h',
++    'WorkerCommon.h',
+     'WorkerDebugger.h',
+     'WorkerDebuggerManager.h',
+     'WorkerHolder.h',
+     'WorkerHolderToken.h',
+     'WorkerLoadInfo.h',
+     'WorkerLocation.h',
+     'WorkerNavigator.h',
+     'WorkerPrivate.h',
+     'WorkerRunnable.h',
+     'WorkerScope.h',
+ ]
+ 
+-EXPORTS.mozilla.dom.workers += [
++# Private stuff.
++EXPORTS.mozilla.dom.workerinternals += [
++    'JSSettings.h',
+     'Queue.h',
+     'RuntimeService.h',
+-    'WorkerCommon.h',
+ ]
+ 
+ XPIDL_MODULE = 'dom_workers'
+ 
+ XPIDL_SOURCES += [
+     'nsIWorkerDebugger.idl',
+     'nsIWorkerDebuggerManager.idl',
+ ]

+ 2425 - 0
mozilla-release/patches/1432963-17-60a1.patch

@@ -0,0 +1,2425 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1517383530 -3600
+# Node ID 001c306fa281dccbd1c5aed5a3dda5cede58a6b8
+# Parent  0dee444931081f74b4bff7388308e0c696ad6d94
+Bug 1432963 - Fixing workers headers - part 17 - no LIBS=[workers] in moz.build files, r=smaug
+
+diff --git a/dom/abort/AbortController.cpp b/dom/abort/AbortController.cpp
+--- a/dom/abort/AbortController.cpp
++++ b/dom/abort/AbortController.cpp
+@@ -2,17 +2,17 @@
+ /* vim: set ts=8 sts=2 et sw=2 tw=80: */
+ /* 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 "AbortController.h"
+ #include "AbortSignal.h"
+ #include "mozilla/dom/AbortControllerBinding.h"
+-#include "WorkerPrivate.h"
++#include "mozilla/dom/WorkerPrivate.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+ NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(AbortController, mGlobal, mSignal)
+ 
+ NS_IMPL_CYCLE_COLLECTING_ADDREF(AbortController)
+ NS_IMPL_CYCLE_COLLECTING_RELEASE(AbortController)
+diff --git a/dom/abort/moz.build b/dom/abort/moz.build
+--- a/dom/abort/moz.build
++++ b/dom/abort/moz.build
+@@ -14,13 +14,9 @@ EXPORTS.mozilla.dom += [
+     'AbortSignal.h',
+ ]
+ 
+ UNIFIED_SOURCES += [
+     'AbortController.cpp',
+     'AbortSignal.cpp',
+ ]
+ 
+-LOCAL_INCLUDES += [
+-    '../workers',
+-]
+-
+ FINAL_LIBRARY = 'xul'
+diff --git a/dom/base/ImageEncoder.cpp b/dom/base/ImageEncoder.cpp
+--- a/dom/base/ImageEncoder.cpp
++++ b/dom/base/ImageEncoder.cpp
+@@ -1,27 +1,27 @@
+ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+ /* vim: set ts=8 sts=2 et sw=2 tw=80: */
+ /* 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 "ImageEncoder.h"
+ #include "mozilla/dom/CanvasRenderingContext2D.h"
++#include "mozilla/dom/WorkerPrivate.h"
+ #include "mozilla/gfx/2D.h"
+ #include "mozilla/gfx/DataSurfaceHelpers.h"
+ #include "mozilla/layers/AsyncCanvasRenderer.h"
+ #include "mozilla/RefPtr.h"
+ #include "mozilla/SyncRunnable.h"
+ #include "mozilla/Unused.h"
+ #include "gfxUtils.h"
+ #include "nsIThreadPool.h"
+ #include "nsNetUtil.h"
+ #include "nsXPCOMCIDInternal.h"
+-#include "WorkerPrivate.h"
+ #include "YCbCrUtils.h"
+ 
+ using namespace mozilla::gfx;
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+ // This class should be placed inside GetBRGADataSourceSurfaceSync(). However,
+diff --git a/dom/base/Navigator.cpp b/dom/base/Navigator.cpp
+--- a/dom/base/Navigator.cpp
++++ b/dom/base/Navigator.cpp
+@@ -75,18 +75,18 @@
+ 
+ #include "mozilla/dom/NavigatorBinding.h"
+ #include "mozilla/dom/Promise.h"
+ 
+ #include "nsIUploadChannel2.h"
+ #include "mozilla/dom/FormData.h"
+ #include "nsIDocShell.h"
+ 
+-#include "WorkerPrivate.h"
+-#include "WorkerRunnable.h"
++#include "mozilla/dom/WorkerPrivate.h"
++#include "mozilla/dom/WorkerRunnable.h"
+ 
+ #if defined(XP_LINUX)
+ #include "mozilla/Hal.h"
+ #endif
+ #include "mozilla/dom/ContentChild.h"
+ 
+ #include "mozilla/EMEUtils.h"
+ #include "mozilla/DetailedPromise.h"
+diff --git a/dom/base/moz.build b/dom/base/moz.build
+--- a/dom/base/moz.build
++++ b/dom/base/moz.build
+@@ -433,17 +433,16 @@ LOCAL_INCLUDES += [
+     '/dom/base',
+     '/dom/file',
+     '/dom/geolocation',
+     '/dom/html',
+     '/dom/ipc',
+     '/dom/storage',
+     '/dom/svg',
+     '/dom/u2f',
+-    '/dom/workers',
+     '/dom/xbl',
+     '/dom/xml',
+     '/dom/xslt/xpath',
+     '/dom/xul',
+     '/gfx/2d',
+     '/image',
+     '/js/xpconnect/loader',
+     '/js/xpconnect/src',
+diff --git a/dom/base/nsJSTimeoutHandler.cpp b/dom/base/nsJSTimeoutHandler.cpp
+--- a/dom/base/nsJSTimeoutHandler.cpp
++++ b/dom/base/nsJSTimeoutHandler.cpp
+@@ -5,26 +5,26 @@
+  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+ 
+ #include <algorithm>
+ 
+ #include "mozilla/Attributes.h"
+ #include "mozilla/Likely.h"
+ #include "mozilla/Maybe.h"
+ #include "mozilla/dom/FunctionBinding.h"
++#include "mozilla/dom/WorkerPrivate.h"
+ #include "nsCOMPtr.h"
+ #include "nsContentUtils.h"
+ #include "nsError.h"
+ #include "nsGlobalWindow.h"
+ #include "nsIContentSecurityPolicy.h"
+ #include "nsIDocument.h"
+ #include "nsIScriptTimeoutHandler.h"
+ #include "nsIXPConnect.h"
+ #include "nsJSUtils.h"
+-#include "WorkerPrivate.h"
+ 
+ using namespace mozilla;
+ using namespace mozilla::dom;
+ using namespace mozilla::dom::workers;
+ 
+ // Our JS nsIScriptTimeoutHandler implementation.
+ class nsJSScriptTimeoutHandler final : public nsIScriptTimeoutHandler
+ {
+diff --git a/dom/bindings/moz.build b/dom/bindings/moz.build
+--- a/dom/bindings/moz.build
++++ b/dom/bindings/moz.build
+@@ -71,17 +71,16 @@ LOCAL_INCLUDES += [
+     '/dom/base',
+     '/dom/canvas',
+     '/dom/geolocation',
+     '/dom/html',
+     '/dom/indexedDB',
+     '/dom/media/webaudio',
+     '/dom/media/webspeech/recognition',
+     '/dom/svg',
+-    '/dom/workers',
+     '/dom/xbl',
+     '/dom/xml',
+     '/dom/xslt/base',
+     '/dom/xslt/xpath',
+     '/dom/xul',
+     '/js/xpconnect/src',
+     '/js/xpconnect/wrappers',
+     '/layout/generic',
+diff --git a/dom/broadcastchannel/BroadcastChannel.cpp b/dom/broadcastchannel/BroadcastChannel.cpp
+--- a/dom/broadcastchannel/BroadcastChannel.cpp
++++ b/dom/broadcastchannel/BroadcastChannel.cpp
+@@ -6,22 +6,22 @@
+ 
+ #include "BroadcastChannel.h"
+ #include "BroadcastChannelChild.h"
+ #include "mozilla/dom/BroadcastChannelBinding.h"
+ #include "mozilla/dom/Navigator.h"
+ #include "mozilla/dom/File.h"
+ #include "mozilla/dom/StructuredCloneHolder.h"
+ #include "mozilla/dom/ipc/StructuredCloneData.h"
++#include "mozilla/dom/WorkerPrivate.h"
++#include "mozilla/dom/WorkerRunnable.h"
+ #include "mozilla/ipc/BackgroundChild.h"
+ #include "mozilla/ipc/BackgroundUtils.h"
+ #include "mozilla/ipc/PBackgroundChild.h"
+ #include "nsContentUtils.h"
+-#include "WorkerPrivate.h"
+-#include "WorkerRunnable.h"
+ 
+ #include "nsIBFCacheEntry.h"
+ #include "nsIDocument.h"
+ #include "nsISupportsPrimitives.h"
+ 
+ #ifdef XP_WIN
+ #undef PostMessage
+ #endif
+diff --git a/dom/broadcastchannel/BroadcastChannelChild.cpp b/dom/broadcastchannel/BroadcastChannelChild.cpp
+--- a/dom/broadcastchannel/BroadcastChannelChild.cpp
++++ b/dom/broadcastchannel/BroadcastChannelChild.cpp
+@@ -10,17 +10,17 @@
+ #include "mozilla/dom/File.h"
+ #include "mozilla/dom/MessageEvent.h"
+ #include "mozilla/dom/MessageEventBinding.h"
+ #include "mozilla/dom/WorkerPrivate.h"
+ #include "mozilla/dom/WorkerScope.h"
+ #include "mozilla/dom/ScriptSettings.h"
+ #include "mozilla/ipc/PBackgroundChild.h"
+ #include "mozilla/dom/ipc/StructuredCloneData.h"
+-#include "WorkerPrivate.h"
++#include "mozilla/dom/WorkerPrivate.h"
+ 
+ namespace mozilla {
+ 
+ using namespace ipc;
+ 
+ namespace dom {
+ 
+ using namespace workers;
+diff --git a/dom/broadcastchannel/moz.build b/dom/broadcastchannel/moz.build
+--- a/dom/broadcastchannel/moz.build
++++ b/dom/broadcastchannel/moz.build
+@@ -17,18 +17,14 @@ UNIFIED_SOURCES += [
+     'BroadcastChannelParent.cpp',
+     'BroadcastChannelService.cpp',
+ ]
+ 
+ IPDL_SOURCES += [
+     'PBroadcastChannel.ipdl',
+ ]
+ 
+-LOCAL_INCLUDES += [
+-    '../workers',
+-]
+-
+ MOCHITEST_MANIFESTS += ['tests/mochitest.ini']
+ BROWSER_CHROME_MANIFESTS += ['tests/browser.ini']
+ 
+ include('/ipc/chromium/chromium-config.mozbuild')
+ 
+ FINAL_LIBRARY = 'xul'
+diff --git a/dom/cache/CacheStorage.cpp b/dom/cache/CacheStorage.cpp
+--- a/dom/cache/CacheStorage.cpp
++++ b/dom/cache/CacheStorage.cpp
+@@ -16,26 +16,26 @@
+ #include "mozilla/dom/cache/AutoUtils.h"
+ #include "mozilla/dom/cache/Cache.h"
+ #include "mozilla/dom/cache/CacheChild.h"
+ #include "mozilla/dom/cache/CacheStorageChild.h"
+ #include "mozilla/dom/cache/CacheWorkerHolder.h"
+ #include "mozilla/dom/cache/PCacheChild.h"
+ #include "mozilla/dom/cache/ReadStream.h"
+ #include "mozilla/dom/cache/TypeUtils.h"
++#include "mozilla/dom/WorkerPrivate.h"
+ #include "mozilla/ipc/BackgroundChild.h"
+ #include "mozilla/ipc/BackgroundUtils.h"
+ #include "mozilla/ipc/PBackgroundChild.h"
+ #include "mozilla/ipc/PBackgroundSharedTypes.h"
+ #include "nsContentUtils.h"
+ #include "nsIDocument.h"
+ #include "nsIGlobalObject.h"
+ #include "nsIScriptSecurityManager.h"
+ #include "nsURLParsers.h"
+-#include "WorkerPrivate.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ namespace cache {
+ 
+ using mozilla::Unused;
+ using mozilla::ErrorResult;
+ using mozilla::ipc::BackgroundChild;
+diff --git a/dom/cache/CacheWorkerHolder.cpp b/dom/cache/CacheWorkerHolder.cpp
+--- a/dom/cache/CacheWorkerHolder.cpp
++++ b/dom/cache/CacheWorkerHolder.cpp
+@@ -2,17 +2,17 @@
+ /* vim: set ts=8 sts=2 et sw=2 tw=80: */
+ /* 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 "mozilla/dom/cache/CacheWorkerHolder.h"
+ 
+ #include "mozilla/dom/cache/ActorChild.h"
+-#include "WorkerPrivate.h"
++#include "mozilla/dom/WorkerPrivate.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ namespace cache {
+ 
+ // static
+ already_AddRefed<CacheWorkerHolder>
+ CacheWorkerHolder::Create(WorkerPrivate* aWorkerPrivate, Behavior aBehavior)
+diff --git a/dom/cache/CacheWorkerHolder.h b/dom/cache/CacheWorkerHolder.h
+--- a/dom/cache/CacheWorkerHolder.h
++++ b/dom/cache/CacheWorkerHolder.h
+@@ -4,17 +4,17 @@
+  * 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/. */
+ 
+ #ifndef mozilla_dom_cache_CacheWorkerHolder_h
+ #define mozilla_dom_cache_CacheWorkerHolder_h
+ 
+ #include "nsISupportsImpl.h"
+ #include "nsTArray.h"
+-#include "WorkerHolder.h"
++#include "mozilla/dom/WorkerHolder.h"
+ 
+ namespace mozilla {
+ 
+ class WorkerPrivate;
+ 
+ namespace dom {
+ namespace cache {
+ 
+diff --git a/dom/cache/moz.build b/dom/cache/moz.build
+--- a/dom/cache/moz.build
++++ b/dom/cache/moz.build
+@@ -77,20 +77,16 @@ IPDL_SOURCES += [
+     'PCache.ipdl',
+     'PCacheOp.ipdl',
+     'PCacheStorage.ipdl',
+     'PCacheStreamControl.ipdl',
+ ]
+ 
+ include('/ipc/chromium/chromium-config.mozbuild')
+ 
+-LOCAL_INCLUDES += [
+-    '../workers',
+-]
+-
+ FINAL_LIBRARY = 'xul'
+ 
+ MOCHITEST_MANIFESTS += [
+     'test/mochitest/mochitest.ini',
+ ]
+ 
+ BROWSER_CHROME_MANIFESTS += [
+     'test/mochitest/browser.ini',
+diff --git a/dom/canvas/moz.build b/dom/canvas/moz.build
+--- a/dom/canvas/moz.build
++++ b/dom/canvas/moz.build
+@@ -191,17 +191,16 @@ LOCAL_INCLUDES += [
+ 
+ include('/ipc/chromium/chromium-config.mozbuild')
+ 
+ 
+ USE_LIBS += [ 'translator' ] # Grab the Angle shader translator.
+ 
+ FINAL_LIBRARY = 'xul'
+ LOCAL_INCLUDES += [
+-    '../workers',
+     '/dom/base',
+     '/dom/html',
+     '/dom/svg',
+     '/dom/workers',
+     '/dom/xul',
+     '/gfx/angle/checkout/include',
+     '/gfx/gl',
+     '/image',
+diff --git a/dom/clients/api/ClientDOMUtil.h b/dom/clients/api/ClientDOMUtil.h
+--- a/dom/clients/api/ClientDOMUtil.h
++++ b/dom/clients/api/ClientDOMUtil.h
+@@ -19,22 +19,20 @@ namespace dom {
+ // Utility method to properly execute a ClientManager operation.  It
+ // will properly hold a worker thread alive and avoid executing callbacks
+ // if the thread is shutting down.
+ template<typename Func, typename Arg, typename Resolve, typename Reject>
+ void
+ StartClientManagerOp(Func aFunc, const Arg& aArg, nsISerialEventTarget* aTarget,
+                      Resolve aResolve, Reject aReject)
+ {
+-  using mozilla::dom::WorkerStatus::Closing;
+-
+   RefPtr<WorkerHolderToken> token;
+   if (!NS_IsMainThread()) {
+     token = WorkerHolderToken::Create(workers::GetCurrentThreadWorkerPrivate(),
+-                                      Closing);
++                                      mozilla::dom::WorkerStatus::Closing);
+   }
+ 
+   RefPtr<ClientOpPromise> promise = aFunc(aArg, aTarget);
+   promise->Then(aTarget, __func__,
+     [aResolve, token](const ClientOpResult& aResult) {
+       if (token && token->IsShuttingDown()) {
+         return;
+       }
+diff --git a/dom/clients/api/moz.build b/dom/clients/api/moz.build
+--- a/dom/clients/api/moz.build
++++ b/dom/clients/api/moz.build
+@@ -11,20 +11,16 @@ EXPORTS.mozilla.dom += [
+ 
+ UNIFIED_SOURCES += [
+   'Client.cpp',
+   'Clients.cpp',
+ ]
+ 
+ include('/ipc/chromium/chromium-config.mozbuild')
+ 
+-LOCAL_INCLUDES += [
+-  '/dom/workers',
+-]
+-
+ FINAL_LIBRARY = 'xul'
+ 
+ MOCHITEST_MANIFESTS += [
+ ]
+ 
+ BROWSER_CHROME_MANIFESTS += [
+ ]
+ 
+diff --git a/dom/clients/manager/moz.build b/dom/clients/manager/moz.build
+--- a/dom/clients/manager/moz.build
++++ b/dom/clients/manager/moz.build
+@@ -58,20 +58,16 @@ IPDL_SOURCES += [
+   'PClientNavigateOp.ipdl',
+   'PClientOpenWindowOp.ipdl',
+   'PClientSource.ipdl',
+   'PClientSourceOp.ipdl',
+ ]
+ 
+ include('/ipc/chromium/chromium-config.mozbuild')
+ 
+-LOCAL_INCLUDES += [
+-  '/dom/workers',
+-]
+-
+ FINAL_LIBRARY = 'xul'
+ 
+ MOCHITEST_MANIFESTS += [
+ ]
+ 
+ BROWSER_CHROME_MANIFESTS += [
+ ]
+ 
+diff --git a/dom/console/Console.cpp b/dom/console/Console.cpp
+--- a/dom/console/Console.cpp
++++ b/dom/console/Console.cpp
+@@ -12,27 +12,27 @@
+ #include "mozilla/dom/BlobBinding.h"
+ #include "mozilla/dom/Exceptions.h"
+ #include "mozilla/dom/File.h"
+ #include "mozilla/dom/FunctionBinding.h"
+ #include "mozilla/dom/Performance.h"
+ #include "mozilla/dom/ScriptSettings.h"
+ #include "mozilla/dom/StructuredCloneHolder.h"
+ #include "mozilla/dom/ToJSValue.h"
++#include "mozilla/dom/WorkerPrivate.h"
++#include "mozilla/dom/WorkerRunnable.h"
++#include "mozilla/dom/WorkerScope.h"
+ #include "mozilla/dom/WorkletGlobalScope.h"
+ #include "mozilla/Maybe.h"
+ #include "nsCycleCollectionParticipant.h"
+ #include "nsDocument.h"
+ #include "nsDOMNavigationTiming.h"
+ #include "nsGlobalWindow.h"
+ #include "nsJSUtils.h"
+ #include "nsNetUtil.h"
+-#include "WorkerPrivate.h"
+-#include "WorkerRunnable.h"
+-#include "WorkerScope.h"
+ #include "xpcpublic.h"
+ #include "nsContentUtils.h"
+ #include "nsDocShell.h"
+ #include "nsProxyRelease.h"
+ #include "mozilla/ConsoleTimelineMarker.h"
+ #include "mozilla/TimestampTimelineMarker.h"
+ 
+ #include "nsIConsoleAPIStorage.h"
+diff --git a/dom/console/moz.build b/dom/console/moz.build
+--- a/dom/console/moz.build
++++ b/dom/console/moz.build
+@@ -37,17 +37,16 @@ UNIFIED_SOURCES += [
+ EXTRA_COMPONENTS += [
+     'ConsoleAPI.manifest',
+     'ConsoleAPIStorage.js',
+ ]
+ 
+ LOCAL_INCLUDES += [
+     '/docshell/base',
+     '/dom/base',
+-    '/dom/workers',
+     '/js/xpconnect/src',
+ ]
+ 
+ MOCHITEST_MANIFESTS += [ 'tests/mochitest.ini' ]
+ MOCHITEST_CHROME_MANIFESTS += [ 'tests/chrome.ini' ]
+ XPCSHELL_TESTS_MANIFESTS += ['tests/xpcshell/xpcshell.ini']
+ 
+ FINAL_LIBRARY = 'xul'
+diff --git a/dom/crypto/moz.build b/dom/crypto/moz.build
+--- a/dom/crypto/moz.build
++++ b/dom/crypto/moz.build
+@@ -24,14 +24,13 @@ UNIFIED_SOURCES += [
+     'WebCryptoThreadPool.cpp',
+ ]
+ 
+ include('/ipc/chromium/chromium-config.mozbuild')
+ 
+ FINAL_LIBRARY = 'xul'
+ 
+ LOCAL_INCLUDES += [
+-    '/dom/workers',
+     '/security/manager/ssl',
+     '/xpcom/build',
+ ]
+ 
+ MOCHITEST_MANIFESTS += ['test/mochitest.ini']
+diff --git a/dom/events/Event.cpp b/dom/events/Event.cpp
+--- a/dom/events/Event.cpp
++++ b/dom/events/Event.cpp
+@@ -9,16 +9,17 @@
+ #include "ipc/IPCMessageUtils.h"
+ #include "mozilla/dom/Event.h"
+ #include "mozilla/dom/ShadowRoot.h"
+ #include "mozilla/ContentEvents.h"
+ #include "mozilla/DOMEventTargetHelper.h"
+ #include "mozilla/EventStateManager.h"
+ #include "mozilla/InternalMutationEvent.h"
+ #include "mozilla/dom/Performance.h"
++#include "mozilla/dom/WorkerPrivate.h"
+ #include "mozilla/MiscEvents.h"
+ #include "mozilla/MouseEvents.h"
+ #include "mozilla/Preferences.h"
+ #include "mozilla/TextEvents.h"
+ #include "mozilla/TouchEvents.h"
+ #include "nsContentUtils.h"
+ #include "nsCOMPtr.h"
+ #include "nsDeviceContext.h"
+@@ -28,17 +29,16 @@
+ #include "nsIContent.h"
+ #include "nsIDocument.h"
+ #include "nsIPresShell.h"
+ #include "nsIScrollableFrame.h"
+ #include "nsJSEnvironment.h"
+ #include "nsLayoutUtils.h"
+ #include "nsPIWindowRoot.h"
+ #include "nsRFPService.h"
+-#include "WorkerPrivate.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+ static char *sPopupAllowedEvents;
+ 
+ static bool sReturnHighResTimeStamp = false;
+ static bool sReturnHighResTimeStampIsSet = false;
+diff --git a/dom/events/JSEventHandler.cpp b/dom/events/JSEventHandler.cpp
+--- a/dom/events/JSEventHandler.cpp
++++ b/dom/events/JSEventHandler.cpp
+@@ -12,23 +12,23 @@
+ #include "nsIXPConnect.h"
+ #include "nsIMutableArray.h"
+ #include "nsVariant.h"
+ #include "nsIDOMBeforeUnloadEvent.h"
+ #include "nsGkAtoms.h"
+ #include "xpcpublic.h"
+ #include "nsJSEnvironment.h"
+ #include "nsDOMJSUtils.h"
+-#include "WorkerPrivate.h"
+ #include "mozilla/ContentEvents.h"
+ #include "mozilla/CycleCollectedJSContext.h"
+ #include "mozilla/HoldDropJSObjects.h"
+ #include "mozilla/JSEventHandler.h"
+ #include "mozilla/Likely.h"
+ #include "mozilla/dom/ErrorEvent.h"
++#include "mozilla/dom/WorkerPrivate.h"
+ 
+ namespace mozilla {
+ 
+ using namespace dom;
+ 
+ JSEventHandler::JSEventHandler(nsISupports* aTarget,
+                                nsIAtom* aType,
+                                const TypedEventHandler& aTypedHandler)
+diff --git a/dom/events/moz.build b/dom/events/moz.build
+--- a/dom/events/moz.build
++++ b/dom/events/moz.build
+@@ -144,17 +144,16 @@ include('/ipc/chromium/chromium-config.m
+ 
+ FINAL_LIBRARY = 'xul'
+ LOCAL_INCLUDES += [
+     '/docshell/base',
+     '/dom/base',
+     '/dom/html',
+     '/dom/storage',
+     '/dom/svg',
+-    '/dom/workers',
+     '/dom/xml',
+     '/dom/xul',
+     '/js/xpconnect/wrappers',
+     '/layout/generic',
+     '/layout/xul',
+     '/layout/xul/tree/',
+ ]
+ 
+diff --git a/dom/fetch/Fetch.cpp b/dom/fetch/Fetch.cpp
+--- a/dom/fetch/Fetch.cpp
++++ b/dom/fetch/Fetch.cpp
+@@ -39,20 +39,20 @@
+ #include "mozilla/dom/ScriptSettings.h"
+ #include "mozilla/dom/URLSearchParams.h"
+ 
+ #include "BodyExtractor.h"
+ #include "FetchObserver.h"
+ #include "InternalRequest.h"
+ #include "InternalResponse.h"
+ 
+-#include "WorkerCommon.h"
+-#include "WorkerPrivate.h"
+-#include "WorkerRunnable.h"
+-#include "WorkerScope.h"
++#include "mozilla/dom/WorkerCommon.h"
++#include "mozilla/dom/WorkerPrivate.h"
++#include "mozilla/dom/WorkerRunnable.h"
++#include "mozilla/dom/WorkerScope.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+ using namespace workers;
+ 
+ namespace {
+ 
+diff --git a/dom/fetch/FetchConsumer.cpp b/dom/fetch/FetchConsumer.cpp
+--- a/dom/fetch/FetchConsumer.cpp
++++ b/dom/fetch/FetchConsumer.cpp
+@@ -2,23 +2,23 @@
+ /* vim: set ts=8 sts=2 et sw=2 tw=80: */
+ /* 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 "Fetch.h"
+ #include "FetchConsumer.h"
+ 
++#include "mozilla/dom/WorkerCommon.h"
++#include "mozilla/dom/WorkerPrivate.h"
++#include "mozilla/dom/WorkerRunnable.h"
++#include "mozilla/dom/WorkerScope.h"
+ #include "mozilla/ipc/PBackgroundSharedTypes.h"
+ #include "nsIInputStreamPump.h"
+ #include "nsProxyRelease.h"
+-#include "WorkerCommon.h"
+-#include "WorkerPrivate.h"
+-#include "WorkerRunnable.h"
+-#include "WorkerScope.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+ using namespace workers;
+ 
+ namespace {
+ 
+diff --git a/dom/fetch/FetchStream.cpp b/dom/fetch/FetchStream.cpp
+--- a/dom/fetch/FetchStream.cpp
++++ b/dom/fetch/FetchStream.cpp
+@@ -1,21 +1,21 @@
+ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+ /* vim: set ts=8 sts=2 et sw=2 tw=80: */
+ /* 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 "FetchStream.h"
+ #include "mozilla/dom/DOMException.h"
++#include "mozilla/dom/WorkerCommon.h"
++#include "mozilla/dom/WorkerPrivate.h"
+ #include "nsITransport.h"
+ #include "nsIStreamTransportService.h"
+ #include "nsProxyRelease.h"
+-#include "WorkerCommon.h"
+-#include "WorkerPrivate.h"
+ 
+ #define FETCH_STREAM_FLAG 0
+ 
+ static NS_DEFINE_CID(kStreamTransportServiceCID,
+                      NS_STREAMTRANSPORTSERVICE_CID);
+ 
+ namespace mozilla {
+ namespace dom {
+diff --git a/dom/fetch/Request.cpp b/dom/fetch/Request.cpp
+--- a/dom/fetch/Request.cpp
++++ b/dom/fetch/Request.cpp
+@@ -13,18 +13,16 @@
+ #include "mozilla/dom/Headers.h"
+ #include "mozilla/dom/Fetch.h"
+ #include "mozilla/dom/FetchUtil.h"
+ #include "mozilla/dom/Promise.h"
+ #include "mozilla/dom/URL.h"
+ #include "mozilla/dom/WorkerPrivate.h"
+ #include "mozilla/Unused.h"
+ 
+-#include "WorkerPrivate.h"
+-
+ namespace mozilla {
+ namespace dom {
+ 
+ NS_IMPL_CYCLE_COLLECTING_ADDREF(Request)
+ NS_IMPL_CYCLE_COLLECTING_RELEASE(Request)
+ 
+ NS_IMPL_CYCLE_COLLECTION_CLASS(Request)
+ 
+diff --git a/dom/fetch/Response.cpp b/dom/fetch/Response.cpp
+--- a/dom/fetch/Response.cpp
++++ b/dom/fetch/Response.cpp
+@@ -12,24 +12,24 @@
+ #include "nsPIDOMWindow.h"
+ 
+ #include "mozilla/ErrorResult.h"
+ #include "mozilla/dom/FetchBinding.h"
+ #include "mozilla/dom/ResponseBinding.h"
+ #include "mozilla/dom/Headers.h"
+ #include "mozilla/dom/Promise.h"
+ #include "mozilla/dom/URL.h"
++#include "mozilla/dom/WorkerPrivate.h"
+ 
+ #include "nsDOMString.h"
+ 
+ #include "BodyExtractor.h"
+ #include "FetchStream.h"
+ #include "FetchStreamReader.h"
+ #include "InternalResponse.h"
+-#include "WorkerPrivate.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+ NS_IMPL_CYCLE_COLLECTING_ADDREF(Response)
+ NS_IMPL_CYCLE_COLLECTING_RELEASE(Response)
+ 
+ NS_IMPL_CYCLE_COLLECTION_CLASS(Response)
+diff --git a/dom/fetch/moz.build b/dom/fetch/moz.build
+--- a/dom/fetch/moz.build
++++ b/dom/fetch/moz.build
+@@ -43,17 +43,16 @@ UNIFIED_SOURCES += [
+ ]
+ 
+ IPDL_SOURCES += [
+     'ChannelInfo.ipdlh',
+     'FetchTypes.ipdlh',
+ ]
+ 
+ LOCAL_INCLUDES += [
+-    '../workers',
+     # For HttpBaseChannel.h dependencies
+     '/netwerk/base',
+     # For nsDataHandler.h
+     '/netwerk/protocol/data',
+     # For HttpBaseChannel.h
+     '/netwerk/protocol/http',
+ ]
+ 
+diff --git a/dom/file/FileReader.cpp b/dom/file/FileReader.cpp
+--- a/dom/file/FileReader.cpp
++++ b/dom/file/FileReader.cpp
+@@ -13,28 +13,27 @@
+ #include "nsIStreamTransportService.h"
+ 
+ #include "mozilla/Base64.h"
+ #include "mozilla/CheckedInt.h"
+ #include "mozilla/dom/DOMException.h"
+ #include "mozilla/dom/File.h"
+ #include "mozilla/dom/FileReaderBinding.h"
+ #include "mozilla/dom/ProgressEvent.h"
++#include "mozilla/dom/WorkerPrivate.h"
++#include "mozilla/dom/WorkerScope.h"
+ #include "mozilla/Encoding.h"
+ #include "nsAlgorithm.h"
+ #include "nsCycleCollectionParticipant.h"
+ #include "nsDOMJSUtils.h"
+ #include "nsError.h"
+ #include "nsNetCID.h"
+ #include "nsNetUtil.h"
+ #include "xpcpublic.h"
+ 
+-#include "WorkerPrivate.h"
+-#include "WorkerScope.h"
+-
+ namespace mozilla {
+ namespace dom {
+ 
+ #define ABORT_STR "abort"
+ #define LOAD_STR "load"
+ #define LOADSTART_STR "loadstart"
+ #define LOADEND_STR "loadend"
+ #define ERROR_STR "error"
+diff --git a/dom/file/FileReader.h b/dom/file/FileReader.h
+--- a/dom/file/FileReader.h
++++ b/dom/file/FileReader.h
+@@ -4,24 +4,24 @@
+  * 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/. */
+ 
+ #ifndef mozilla_dom_FileReader_h
+ #define mozilla_dom_FileReader_h
+ 
+ #include "mozilla/Attributes.h"
+ #include "mozilla/DOMEventTargetHelper.h"
++#include "mozilla/dom/WorkerHolder.h"
+ 
+ #include "nsIAsyncInputStream.h"
+ #include "nsIInterfaceRequestor.h"
+ #include "nsINamed.h"
+ #include "nsCOMPtr.h"
+ #include "nsString.h"
+ #include "nsWeakReference.h"
+-#include "WorkerHolder.h"
+ 
+ #define NS_PROGRESS_EVENT_INTERVAL 50
+ 
+ class nsITimer;
+ class nsIEventTarget;
+ 
+ namespace mozilla {
+ namespace dom {
+diff --git a/dom/file/FileReaderSync.cpp b/dom/file/FileReaderSync.cpp
+--- a/dom/file/FileReaderSync.cpp
++++ b/dom/file/FileReaderSync.cpp
+@@ -21,20 +21,18 @@
+ #include "nsIInputStream.h"
+ #include "nsIMultiplexInputStream.h"
+ #include "nsStreamUtils.h"
+ #include "nsStringStream.h"
+ #include "nsISupportsImpl.h"
+ #include "nsNetUtil.h"
+ #include "nsServiceManagerUtils.h"
+ #include "nsIAsyncInputStream.h"
+-#include "WorkerPrivate.h"
+-#include "WorkerRunnable.h"
+-
+-#include "RuntimeService.h"
++#include "mozilla/dom/WorkerPrivate.h"
++#include "mozilla/dom/WorkerRunnable.h"
+ 
+ using namespace mozilla;
+ using namespace mozilla::dom;
+ using mozilla::dom::Optional;
+ using mozilla::dom::GlobalObject;
+ 
+ // static
+ already_AddRefed<FileReaderSync>
+diff --git a/dom/file/FileReaderSync.h b/dom/file/FileReaderSync.h
+--- a/dom/file/FileReaderSync.h
++++ b/dom/file/FileReaderSync.h
+@@ -2,17 +2,17 @@
+ /* vim: set ts=8 sts=2 et sw=2 tw=80: */
+ /* 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/. */
+ 
+ #ifndef mozilla_dom_filereadersync_h__
+ #define mozilla_dom_filereadersync_h__
+ 
+-#include "WorkerCommon.h"
++#include "mozilla/dom/WorkerCommon.h"
+ 
+ class nsIInputStream;
+ 
+ namespace mozilla {
+ class ErrorResult;
+ 
+ namespace dom {
+ class Blob;
+diff --git a/dom/file/MutableBlobStorage.cpp b/dom/file/MutableBlobStorage.cpp
+--- a/dom/file/MutableBlobStorage.cpp
++++ b/dom/file/MutableBlobStorage.cpp
+@@ -3,25 +3,25 @@
+ /* 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 "MutableBlobStorage.h"
+ #include "MemoryBlobImpl.h"
+ #include "mozilla/CheckedInt.h"
+ #include "mozilla/dom/ipc/TemporaryIPCBlobChild.h"
++#include "mozilla/dom/WorkerPrivate.h"
+ #include "mozilla/ipc/BackgroundChild.h"
+ #include "mozilla/ipc/PBackgroundChild.h"
+ #include "mozilla/Preferences.h"
+ #include "mozilla/TaskQueue.h"
+ #include "File.h"
+ #include "nsAnonymousTemporaryFile.h"
+ #include "nsNetCID.h"
+ #include "nsProxyRelease.h"
+-#include "WorkerPrivate.h"
+ 
+ #define BLOB_MEMORY_TEMPORARY_FILE 1048576
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+ namespace {
+ 
+diff --git a/dom/file/ipc/IPCBlobInputStreamChild.cpp b/dom/file/ipc/IPCBlobInputStreamChild.cpp
+--- a/dom/file/ipc/IPCBlobInputStreamChild.cpp
++++ b/dom/file/ipc/IPCBlobInputStreamChild.cpp
+@@ -3,19 +3,19 @@
+ /* 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 "IPCBlobInputStreamChild.h"
+ #include "IPCBlobInputStreamThread.h"
+ 
+ #include "mozilla/ipc/IPCStreamUtils.h"
+-#include "WorkerHolder.h"
+-#include "WorkerPrivate.h"
+-#include "WorkerRunnable.h"
++#include "mozilla/dom/WorkerHolder.h"
++#include "mozilla/dom/WorkerPrivate.h"
++#include "mozilla/dom/WorkerRunnable.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+ using namespace workers;
+ 
+ namespace {
+ 
+diff --git a/dom/file/ipc/moz.build b/dom/file/ipc/moz.build
+--- a/dom/file/ipc/moz.build
++++ b/dom/file/ipc/moz.build
+@@ -38,17 +38,16 @@ IPDL_SOURCES += [
+     'PIPCBlobInputStream.ipdl',
+     'PPendingIPCBlob.ipdl',
+     'PTemporaryIPCBlob.ipdl',
+ ]
+ 
+ LOCAL_INCLUDES += [
+     '/dom/file',
+     '/dom/ipc',
+-    '/dom/workers',
+     '/xpcom/build',
+ ]
+ 
+ include('/ipc/chromium/chromium-config.mozbuild')
+ 
+ FINAL_LIBRARY = 'xul'
+ 
+ CXXFLAGS += CONFIG['TK_CFLAGS']
+diff --git a/dom/file/moz.build b/dom/file/moz.build
+--- a/dom/file/moz.build
++++ b/dom/file/moz.build
+@@ -59,17 +59,16 @@ UNIFIED_SOURCES += [
+     'nsHostObjectURI.cpp',
+     'StreamBlobImpl.cpp',
+     'StringBlobImpl.cpp',
+     'TemporaryFileBlobImpl.cpp',
+ ]
+ 
+ LOCAL_INCLUDES += [
+     '/dom/file/ipc',
+-    '/dom/workers',
+ ]
+ 
+ MOCHITEST_MANIFESTS += ['tests/mochitest.ini']
+ 
+ XPCSHELL_TESTS_MANIFESTS += ['tests/xpcshell.ini']
+ 
+ include('/ipc/chromium/chromium-config.mozbuild')
+ 
+diff --git a/dom/filesystem/Directory.cpp b/dom/filesystem/Directory.cpp
+--- a/dom/filesystem/Directory.cpp
++++ b/dom/filesystem/Directory.cpp
+@@ -3,24 +3,24 @@
+ /* 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 "mozilla/dom/Directory.h"
+ 
+ #include "GetDirectoryListingTask.h"
+ #include "GetFilesTask.h"
+-#include "WorkerPrivate.h"
+ 
+ #include "nsCharSeparatedTokenizer.h"
+ #include "nsString.h"
+ #include "mozilla/dom/DirectoryBinding.h"
+ #include "mozilla/dom/FileSystemBase.h"
+ #include "mozilla/dom/FileSystemUtils.h"
+ #include "mozilla/dom/OSFileSystem.h"
++#include "mozilla/dom/WorkerPrivate.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+ NS_IMPL_CYCLE_COLLECTION_CLASS(Directory)
+ 
+ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(Directory)
+   if (tmp->mFileSystem) {
+diff --git a/dom/filesystem/moz.build b/dom/filesystem/moz.build
+--- a/dom/filesystem/moz.build
++++ b/dom/filesystem/moz.build
+@@ -42,10 +42,9 @@ IPDL_SOURCES += [
+     'PFileSystemParams.ipdlh',
+     'PFileSystemRequest.ipdl',
+ ]
+ 
+ include('/ipc/chromium/chromium-config.mozbuild')
+ 
+ LOCAL_INCLUDES += [
+     '/dom/base',
+-    '/dom/workers',
+ ]
+diff --git a/dom/indexedDB/ActorsChild.cpp b/dom/indexedDB/ActorsChild.cpp
+--- a/dom/indexedDB/ActorsChild.cpp
++++ b/dom/indexedDB/ActorsChild.cpp
+@@ -25,16 +25,18 @@
+ #include "mozilla/TypeTraits.h"
+ #include "mozilla/dom/Element.h"
+ #include "mozilla/dom/PermissionMessageUtils.h"
+ #include "mozilla/dom/TabChild.h"
+ #include "mozilla/dom/indexedDB/PBackgroundIDBDatabaseFileChild.h"
+ #include "mozilla/dom/indexedDB/PIndexedDBPermissionRequestChild.h"
+ #include "mozilla/dom/ipc/PendingIPCBlobChild.h"
+ #include "mozilla/dom/IPCBlobUtils.h"
++#include "mozilla/dom/WorkerPrivate.h"
++#include "mozilla/dom/WorkerRunnable.h"
+ #include "mozilla/Encoding.h"
+ #include "mozilla/ipc/BackgroundUtils.h"
+ #include "mozilla/TaskQueue.h"
+ #include "nsCOMPtr.h"
+ #include "nsContentUtils.h"
+ #include "nsIAsyncInputStream.h"
+ #include "nsIBFCacheEntry.h"
+ #include "nsIDocument.h"
+@@ -43,18 +45,16 @@
+ #include "nsIFileStreams.h"
+ #include "nsNetCID.h"
+ #include "nsPIDOMWindow.h"
+ #include "nsThreadUtils.h"
+ #include "nsTraceRefcnt.h"
+ #include "PermissionRequestBase.h"
+ #include "ProfilerHelpers.h"
+ #include "ReportInternalError.h"
+-#include "WorkerPrivate.h"
+-#include "WorkerRunnable.h"
+ 
+ #ifdef DEBUG
+ #include "IndexedDatabaseManager.h"
+ #endif
+ 
+ #define GC_ON_IPC_MESSAGES 0
+ 
+ #if defined(DEBUG) || GC_ON_IPC_MESSAGES
+diff --git a/dom/indexedDB/IDBObjectStore.cpp b/dom/indexedDB/IDBObjectStore.cpp
+--- a/dom/indexedDB/IDBObjectStore.cpp
++++ b/dom/indexedDB/IDBObjectStore.cpp
+@@ -38,27 +38,27 @@
+ #include "mozilla/dom/IDBMutableFileBinding.h"
+ #include "mozilla/dom/BlobBinding.h"
+ #include "mozilla/dom/IDBObjectStoreBinding.h"
+ #include "mozilla/dom/MemoryBlobImpl.h"
+ #include "mozilla/dom/StreamBlobImpl.h"
+ #include "mozilla/dom/StructuredCloneHolder.h"
+ #include "mozilla/dom/StructuredCloneTags.h"
+ #include "mozilla/dom/indexedDB/PBackgroundIDBSharedTypes.h"
++#include "mozilla/dom/WorkerPrivate.h"
++#include "mozilla/dom/WorkerScope.h"
+ #include "mozilla/ipc/BackgroundChild.h"
+ #include "mozilla/ipc/PBackgroundSharedTypes.h"
+ #include "mozilla/SystemGroup.h"
+ #include "nsCOMPtr.h"
+ #include "nsQueryObject.h"
+ #include "nsStreamUtils.h"
+ #include "nsStringStream.h"
+ #include "ProfilerHelpers.h"
+ #include "ReportInternalError.h"
+-#include "WorkerPrivate.h"
+-#include "WorkerScope.h"
+ 
+ // Include this last to avoid path problems on Windows.
+ #include "ActorsChild.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+ using namespace mozilla::dom::indexedDB;
+diff --git a/dom/indexedDB/IDBRequest.cpp b/dom/indexedDB/IDBRequest.cpp
+--- a/dom/indexedDB/IDBRequest.cpp
++++ b/dom/indexedDB/IDBRequest.cpp
+@@ -18,25 +18,25 @@
+ #include "mozilla/ContentEvents.h"
+ #include "mozilla/ErrorResult.h"
+ #include "mozilla/EventDispatcher.h"
+ #include "mozilla/Move.h"
+ #include "mozilla/dom/DOMException.h"
+ #include "mozilla/dom/ErrorEventBinding.h"
+ #include "mozilla/dom/IDBOpenDBRequestBinding.h"
+ #include "mozilla/dom/ScriptSettings.h"
++#include "mozilla/dom/WorkerHolder.h"
++#include "mozilla/dom/WorkerPrivate.h"
+ #include "nsCOMPtr.h"
+ #include "nsContentUtils.h"
+ #include "nsIScriptContext.h"
+ #include "nsJSUtils.h"
+ #include "nsPIDOMWindow.h"
+ #include "nsString.h"
+ #include "ReportInternalError.h"
+-#include "WorkerHolder.h"
+-#include "WorkerPrivate.h"
+ 
+ // Include this last to avoid path problems on Windows.
+ #include "ActorsChild.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+ using namespace mozilla::dom::indexedDB;
+diff --git a/dom/indexedDB/IDBTransaction.cpp b/dom/indexedDB/IDBTransaction.cpp
+--- a/dom/indexedDB/IDBTransaction.cpp
++++ b/dom/indexedDB/IDBTransaction.cpp
+@@ -10,26 +10,26 @@
+ #include "IDBDatabase.h"
+ #include "IDBEvents.h"
+ #include "IDBObjectStore.h"
+ #include "IDBRequest.h"
+ #include "mozilla/ErrorResult.h"
+ #include "mozilla/EventDispatcher.h"
+ #include "mozilla/dom/DOMException.h"
+ #include "mozilla/dom/DOMStringList.h"
++#include "mozilla/dom/WorkerHolder.h"
++#include "mozilla/dom/WorkerPrivate.h"
+ #include "mozilla/ipc/BackgroundChild.h"
+ #include "nsAutoPtr.h"
+ #include "nsPIDOMWindow.h"
+ #include "nsQueryObject.h"
+ #include "nsServiceManagerUtils.h"
+ #include "nsTHashtable.h"
+ #include "ProfilerHelpers.h"
+ #include "ReportInternalError.h"
+-#include "WorkerHolder.h"
+-#include "WorkerPrivate.h"
+ 
+ // Include this last to avoid path problems on Windows.
+ #include "ActorsChild.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+ using namespace mozilla::dom::indexedDB;
+diff --git a/dom/indexedDB/IndexedDatabaseManager.cpp b/dom/indexedDB/IndexedDatabaseManager.cpp
+--- a/dom/indexedDB/IndexedDatabaseManager.cpp
++++ b/dom/indexedDB/IndexedDatabaseManager.cpp
+@@ -20,34 +20,34 @@
+ #include "mozilla/ContentEvents.h"
+ #include "mozilla/EventDispatcher.h"
+ #include "mozilla/Preferences.h"
+ #include "mozilla/Services.h"
+ #include "mozilla/dom/DOMException.h"
+ #include "mozilla/dom/ErrorEvent.h"
+ #include "mozilla/dom/ErrorEventBinding.h"
+ #include "mozilla/dom/quota/QuotaManager.h"
++#include "mozilla/dom/WorkerScope.h"
++#include "mozilla/dom/WorkerPrivate.h"
+ #include "mozilla/ipc/BackgroundChild.h"
+ #include "mozilla/ipc/BackgroundParent.h"
+ #include "mozilla/ipc/PBackgroundChild.h"
+ #include "nsContentUtils.h"
+ #include "nsGlobalWindow.h"
+ #include "nsThreadUtils.h"
+ #include "mozilla/Logging.h"
+ 
+ #include "FileInfo.h"
+ #include "FileManager.h"
+ #include "IDBEvents.h"
+ #include "IDBFactory.h"
+ #include "IDBKeyRange.h"
+ #include "IDBRequest.h"
+ #include "ProfilerHelpers.h"
+ #include "ScriptErrorHelper.h"
+-#include "WorkerScope.h"
+-#include "WorkerPrivate.h"
+ #include "nsCharSeparatedTokenizer.h"
+ #include "unicode/locid.h"
+ 
+ // Bindings for ResolveConstructors
+ #include "mozilla/dom/IDBCursorBinding.h"
+ #include "mozilla/dom/IDBDatabaseBinding.h"
+ #include "mozilla/dom/IDBFactoryBinding.h"
+ #include "mozilla/dom/IDBIndexBinding.h"
+diff --git a/dom/indexedDB/moz.build b/dom/indexedDB/moz.build
+--- a/dom/indexedDB/moz.build
++++ b/dom/indexedDB/moz.build
+@@ -101,14 +101,13 @@ if CONFIG['CC_TYPE'] in ('clang', 'gcc')
+     # Suppress gcc warning about a comparison being always false due to the
+     # range of the data type
+     SOURCES['Key.cpp'].flags += ['-Wno-error=type-limits']
+     CXXFLAGS += ['-Wno-error=shadow']
+ 
+ LOCAL_INCLUDES += [
+     '/dom/base',
+     '/dom/storage',
+-    '/dom/workers',
+     '/ipc/glue',
+     '/third_party/sqlite3/src',
+     '/xpcom/build',
+     '/xpcom/threads',
+ ]
+diff --git a/dom/ipc/moz.build b/dom/ipc/moz.build
+--- a/dom/ipc/moz.build
++++ b/dom/ipc/moz.build
+@@ -120,17 +120,16 @@ LOCAL_INCLUDES += [
+     '/chrome',
+     '/docshell/base',
+     '/dom/base',
+     '/dom/events',
+     '/dom/filesystem',
+     '/dom/geolocation',
+     '/dom/media/webspeech/synth/ipc',
+     '/dom/security',
+-    '/dom/workers',
+     '/extensions/cookie',
+     '/extensions/spellcheck/src',
+     '/gfx/2d',
+     '/hal/sandbox',
+     '/layout/base',
+     '/media/webrtc',
+     '/netwerk/base',
+     '/toolkit/components/printingui/ipc',
+diff --git a/dom/messagechannel/moz.build b/dom/messagechannel/moz.build
+--- a/dom/messagechannel/moz.build
++++ b/dom/messagechannel/moz.build
+@@ -27,14 +27,13 @@ UNIFIED_SOURCES += [
+ 
+ IPDL_SOURCES += [
+     'PMessagePort.ipdl',
+ ]
+ 
+ LOCAL_INCLUDES += [
+     '../base',
+     '../events',
+-    '../workers',
+ ]
+ 
+ include('/ipc/chromium/chromium-config.mozbuild')
+ 
+ FINAL_LIBRARY = 'xul'
+diff --git a/dom/network/Connection.cpp b/dom/network/Connection.cpp
+--- a/dom/network/Connection.cpp
++++ b/dom/network/Connection.cpp
+@@ -4,17 +4,17 @@
+  * 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 "Connection.h"
+ #include "ConnectionMainThread.h"
+ #include "ConnectionWorker.h"
+ #include "nsIDOMClassInfo.h"
+ #include "Constants.h"
+-#include "WorkerPrivate.h"
++#include "mozilla/dom/WorkerPrivate.h"
+ 
+ /**
+  * We have to use macros here because our leak analysis tool things we are
+  * leaking strings when we have |static const nsString|. Sad :(
+  */
+ #define CHANGE_EVENT_NAME NS_LITERAL_STRING("typechange")
+ 
+ namespace mozilla {
+diff --git a/dom/network/ConnectionWorker.cpp b/dom/network/ConnectionWorker.cpp
+--- a/dom/network/ConnectionWorker.cpp
++++ b/dom/network/ConnectionWorker.cpp
+@@ -2,17 +2,17 @@
+ /* vim: set ts=8 sts=2 et sw=2 tw=80: */
+ /* 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 <limits>
+ #include "mozilla/Hal.h"
+ #include "ConnectionWorker.h"
+-#include "WorkerRunnable.h"
++#include "mozilla/dom/WorkerRunnable.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ namespace network {
+ 
+ class ConnectionProxy final : public NetworkObserver
+                             , public WorkerHolder
+ {
+diff --git a/dom/network/moz.build b/dom/network/moz.build
+--- a/dom/network/moz.build
++++ b/dom/network/moz.build
+@@ -46,18 +46,14 @@ UNIFIED_SOURCES += [
+ ]
+ 
+ IPDL_SOURCES += [
+     'PTCPServerSocket.ipdl',
+     'PTCPSocket.ipdl',
+     'PUDPSocket.ipdl',
+ ]
+ 
+-LOCAL_INCLUDES += [
+-    '../workers',
+-]
+-
+ include('/ipc/chromium/chromium-config.mozbuild')
+ 
+ FINAL_LIBRARY = 'xul'
+ 
+ if CONFIG['CC_TYPE'] in ('clang', 'gcc'):
+     CXXFLAGS += ['-Wno-error=shadow']
+diff --git a/dom/notification/Notification.cpp b/dom/notification/Notification.cpp
+--- a/dom/notification/Notification.cpp
++++ b/dom/notification/Notification.cpp
+@@ -19,16 +19,19 @@
+ #include "mozilla/dom/ContentChild.h"
+ #include "mozilla/dom/DOMPrefs.h"
+ #include "mozilla/dom/NotificationEvent.h"
+ #include "mozilla/dom/PermissionMessageUtils.h"
+ #include "mozilla/dom/Promise.h"
+ #include "mozilla/dom/PromiseWorkerProxy.h"
+ #include "mozilla/dom/ServiceWorkerGlobalScopeBinding.h"
+ #include "mozilla/dom/ServiceWorkerManager.h"
++#include "mozilla/dom/WorkerPrivate.h"
++#include "mozilla/dom/WorkerRunnable.h"
++#include "mozilla/dom/WorkerScope.h"
+ 
+ #include "nsAlertsUtils.h"
+ #include "nsComponentManagerUtils.h"
+ #include "nsContentPermissionHelper.h"
+ #include "nsContentUtils.h"
+ #include "nsCRTGlue.h"
+ #include "nsDOMJSUtils.h"
+ #include "nsGlobalWindow.h"
+@@ -47,19 +50,16 @@
+ #include "nsIXPConnect.h"
+ #include "nsNetUtil.h"
+ #include "nsProxyRelease.h"
+ #include "nsServiceManagerUtils.h"
+ #include "nsStructuredCloneContainer.h"
+ #include "nsThreadUtils.h"
+ #include "nsToolkitCompsCID.h"
+ #include "nsXULAppAPI.h"
+-#include "WorkerPrivate.h"
+-#include "WorkerRunnable.h"
+-#include "WorkerScope.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+ using namespace workers;
+ 
+ struct NotificationStrings
+ {
+diff --git a/dom/notification/moz.build b/dom/notification/moz.build
+--- a/dom/notification/moz.build
++++ b/dom/notification/moz.build
+@@ -27,17 +27,16 @@ UNIFIED_SOURCES += [
+ ]
+ 
+ include('/ipc/chromium/chromium-config.mozbuild')
+ 
+ FINAL_LIBRARY = 'xul'
+ LOCAL_INCLUDES += [
+     '/dom/base',
+     '/dom/ipc',
+-    '/dom/workers',
+ ]
+ 
+ BROWSER_CHROME_MANIFESTS += ['test/browser/browser.ini']
+ XPCSHELL_TESTS_MANIFESTS += ['test/unit/xpcshell.ini']
+ MOCHITEST_MANIFESTS += ['test/mochitest/mochitest.ini']
+ 
+ if CONFIG['CC_TYPE'] in ('clang', 'gcc'):
+     CXXFLAGS += ['-Wno-error=shadow']
+diff --git a/dom/promise/Promise.cpp b/dom/promise/Promise.cpp
+--- a/dom/promise/Promise.cpp
++++ b/dom/promise/Promise.cpp
+@@ -14,31 +14,31 @@
+ #include "mozilla/Preferences.h"
+ 
+ #include "mozilla/dom/BindingUtils.h"
+ #include "mozilla/dom/DOMException.h"
+ #include "mozilla/dom/DOMExceptionBinding.h"
+ #include "mozilla/dom/MediaStreamError.h"
+ #include "mozilla/dom/PromiseBinding.h"
+ #include "mozilla/dom/ScriptSettings.h"
++#include "mozilla/dom/WorkerPrivate.h"
++#include "mozilla/dom/WorkerRunnable.h"
+ 
+ #include "jsfriendapi.h"
+ #include "js/StructuredClone.h"
+ #include "nsContentUtils.h"
+ #include "nsGlobalWindow.h"
+ #include "nsIScriptObjectPrincipal.h"
+ #include "nsJSEnvironment.h"
+ #include "nsJSPrincipals.h"
+ #include "nsJSUtils.h"
+ #include "nsPIDOMWindow.h"
+ #include "PromiseDebugging.h"
+ #include "PromiseNativeHandler.h"
+ #include "PromiseWorkerProxy.h"
+-#include "WorkerPrivate.h"
+-#include "WorkerRunnable.h"
+ #include "WrapperFactory.h"
+ #include "xpcpublic.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+ namespace {
+ // Generator used by Promise::GetID.
+diff --git a/dom/promise/PromiseWorkerProxy.h b/dom/promise/PromiseWorkerProxy.h
+--- a/dom/promise/PromiseWorkerProxy.h
++++ b/dom/promise/PromiseWorkerProxy.h
+@@ -7,20 +7,19 @@
+ #ifndef mozilla_dom_PromiseWorkerProxy_h
+ #define mozilla_dom_PromiseWorkerProxy_h
+ 
+ // Required for Promise::PromiseTaskSync.
+ #include "mozilla/dom/Promise.h"
+ #include "mozilla/dom/PromiseNativeHandler.h"
+ #include "mozilla/dom/StructuredCloneHolder.h"
+ #include "mozilla/dom/WorkerHolder.h"
++#include "mozilla/dom/WorkerRunnable.h"
+ #include "nsProxyRelease.h"
+ 
+-#include "WorkerRunnable.h"
+-
+ namespace mozilla {
+ namespace dom {
+ 
+ class Promise;
+ class WorkerPrivate;
+ 
+ // A proxy to (eventually) mirror a resolved/rejected Promise's result from the
+ // main thread to a Promise on the worker thread.
+diff --git a/dom/promise/moz.build b/dom/promise/moz.build
+--- a/dom/promise/moz.build
++++ b/dom/promise/moz.build
+@@ -19,17 +19,16 @@ UNIFIED_SOURCES += [
+     'Promise.cpp',
+     'PromiseDebugging.cpp',
+     'PromiseWindowProxy.cpp',
+ ]
+ 
+ LOCAL_INCLUDES += [
+     '../base',
+     '../ipc',
+-    '../workers',
+ ]
+ 
+ include('/ipc/chromium/chromium-config.mozbuild')
+ 
+ FINAL_LIBRARY = 'xul'
+ 
+ MOCHITEST_MANIFESTS += ['tests/mochitest.ini']
+ 
+diff --git a/dom/push/PushManager.cpp b/dom/push/PushManager.cpp
+--- a/dom/push/PushManager.cpp
++++ b/dom/push/PushManager.cpp
+@@ -9,32 +9,31 @@
+ #include "mozilla/Base64.h"
+ #include "mozilla/Preferences.h"
+ #include "mozilla/Services.h"
+ #include "mozilla/Unused.h"
+ #include "mozilla/dom/PushManagerBinding.h"
+ #include "mozilla/dom/PushSubscription.h"
+ #include "mozilla/dom/PushSubscriptionOptionsBinding.h"
+ #include "mozilla/dom/PushUtil.h"
++#include "mozilla/dom/WorkerRunnable.h"
++#include "mozilla/dom/WorkerPrivate.h"
++#include "mozilla/dom/WorkerScope.h"
+ 
+ #include "mozilla/dom/Promise.h"
+ #include "mozilla/dom/PromiseWorkerProxy.h"
+ 
+ #include "nsIGlobalObject.h"
+ #include "nsIPermissionManager.h"
+ #include "nsIPrincipal.h"
+ #include "nsIPushService.h"
+ 
+ #include "nsComponentManagerUtils.h"
+ #include "nsContentUtils.h"
+ 
+-#include "WorkerRunnable.h"
+-#include "WorkerPrivate.h"
+-#include "WorkerScope.h"
+-
+ namespace mozilla {
+ namespace dom {
+ 
+ using namespace workers;
+ using workers::AssertIsOnMainThread;
+ 
+ namespace {
+ 
+diff --git a/dom/push/moz.build b/dom/push/moz.build
+--- a/dom/push/moz.build
++++ b/dom/push/moz.build
+@@ -47,12 +47,11 @@ UNIFIED_SOURCES += [
+ 
+ TEST_DIRS += ['test/xpcshell']
+ 
+ include('/ipc/chromium/chromium-config.mozbuild')
+ 
+ LOCAL_INCLUDES += [
+     '../base',
+     '../ipc',
+-    '../workers',
+ ]
+ 
+ FINAL_LIBRARY = 'xul'
+diff --git a/dom/quota/moz.build b/dom/quota/moz.build
+--- a/dom/quota/moz.build
++++ b/dom/quota/moz.build
+@@ -57,14 +57,13 @@ IPDL_SOURCES += [
+     'PQuotaRequest.ipdl',
+     'PQuotaUsageRequest.ipdl',
+ ]
+ 
+ include('/ipc/chromium/chromium-config.mozbuild')
+ 
+ FINAL_LIBRARY = 'xul'
+ LOCAL_INCLUDES += [
+-    '../workers',
+     '/caps',
+ ]
+ 
+ if CONFIG['CC_TYPE'] in ('clang', 'gcc'):
+     CXXFLAGS += ['-Wno-error=shadow']
+diff --git a/dom/script/ScriptSettings.cpp b/dom/script/ScriptSettings.cpp
+--- a/dom/script/ScriptSettings.cpp
++++ b/dom/script/ScriptSettings.cpp
+@@ -3,30 +3,30 @@
+ /* 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 "mozilla/dom/ScriptSettings.h"
+ #include "mozilla/ThreadLocal.h"
+ #include "mozilla/Assertions.h"
+ #include "mozilla/CycleCollectedJSContext.h"
++#include "mozilla/dom/WorkerPrivate.h"
+ 
+ #include "jsapi.h"
+ #include "xpcpublic.h"
+ #include "nsIGlobalObject.h"
+ #include "nsIDocShell.h"
+ #include "nsIScriptGlobalObject.h"
+ #include "nsIScriptContext.h"
+ #include "nsContentUtils.h"
+ #include "nsGlobalWindow.h"
+ #include "nsPIDOMWindow.h"
+ #include "nsTArray.h"
+ #include "nsJSUtils.h"
+ #include "nsDOMJSUtils.h"
+-#include "WorkerPrivate.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+ static MOZ_THREAD_LOCAL(ScriptSettingsStackEntry*) sScriptSettingsTLS;
+ static bool sScriptSettingsTLSInitialized;
+ 
+ class ScriptSettingsStack
+@@ -539,17 +539,17 @@ WarningOnlyErrorReporter(JSContext* aCx,
+   if (!NS_IsMainThread()) {
+     // Reporting a warning on workers is a bit complicated because we have to
+     // climb our parent chain until we get to the main thread.  So go ahead and
+     // just go through the worker ReportError codepath here.
+     //
+     // That said, it feels like we should be able to short-circuit things a bit
+     // here by posting an appropriate runnable to the main thread directly...
+     // Worth looking into sometime.
+-    WorkerPrivate* worker = GetWorkerPrivateFromContext(aCx);
++    WorkerPrivate* worker = workers::GetWorkerPrivateFromContext(aCx);
+     MOZ_ASSERT(worker);
+ 
+     worker->ReportError(aCx, JS::ConstUTF8CharsZ(), aRep);
+     return;
+   }
+ 
+   RefPtr<xpc::ErrorReport> xpcReport = new xpc::ErrorReport();
+   nsGlobalWindow* win = xpc::CurrentWindowOrNull(aCx);
+@@ -576,17 +576,17 @@ AutoJSAPI::ReportException()
+   // requires us to be in a compartment when we fetch the pending exception.
+   // In this case, we enter the privileged junk scope and don't dispatch any
+   // error events.
+   JS::Rooted<JSObject*> errorGlobal(cx(), JS::CurrentGlobalOrNull(cx()));
+   if (!errorGlobal) {
+     if (mIsMainThread) {
+       errorGlobal = xpc::PrivilegedJunkScope();
+     } else {
+-      errorGlobal = GetCurrentThreadWorkerGlobal();
++      errorGlobal = workers::GetCurrentThreadWorkerGlobal();
+     }
+   }
+   JSAutoCompartment ac(cx(), errorGlobal);
+   JS::Rooted<JS::Value> exn(cx());
+   js::ErrorReport jsReport(cx());
+   if (StealException(&exn) &&
+       jsReport.init(cx(), exn, js::ErrorReport::WithSideEffects)) {
+     if (mIsMainThread) {
+@@ -612,17 +612,17 @@ AutoJSAPI::ReportException()
+           xpc::FindExceptionStackForConsoleReport(inner, exn));
+         xpcReport->LogToConsoleWithStack(stack);
+       }
+     } else {
+       // On a worker, we just use the worker error reporting mechanism and don't
+       // bother with xpc::ErrorReport.  This will ensure that all the right
+       // events (which are a lot more complicated than in the window case) get
+       // fired.
+-      WorkerPrivate* worker = GetCurrentThreadWorkerPrivate();
++      WorkerPrivate* worker = workers::GetCurrentThreadWorkerPrivate();
+       MOZ_ASSERT(worker);
+       MOZ_ASSERT(worker->GetJSContext() == cx());
+       // Before invoking ReportError, put the exception back on the context,
+       // because it may want to put it in its error events and has no other way
+       // to get hold of it.  After we invoke ReportError, clear the exception on
+       // cx(), just in case ReportError didn't.
+       JS_SetPendingException(cx(), exn);
+       worker->ReportError(cx(), jsReport.toStringResult(), jsReport.report());
+diff --git a/dom/script/moz.build b/dom/script/moz.build
+--- a/dom/script/moz.build
++++ b/dom/script/moz.build
+@@ -32,14 +32,13 @@ UNIFIED_SOURCES += [
+     'ScriptLoadHandler.cpp',
+     'ScriptLoadRequest.cpp',
+     'ScriptSettings.cpp',
+     'ScriptTrace.cpp',
+ ]
+ 
+ LOCAL_INCLUDES += [
+     '/dom/base',
+-    '/dom/workers',
+ ]
+ 
+ include('/ipc/chromium/chromium-config.mozbuild')
+ 
+ FINAL_LIBRARY = 'xul'
+diff --git a/dom/serviceworkers/ServiceWorker.cpp b/dom/serviceworkers/ServiceWorker.cpp
+--- a/dom/serviceworkers/ServiceWorker.cpp
++++ b/dom/serviceworkers/ServiceWorker.cpp
+@@ -5,23 +5,23 @@
+  * You can obtain one at http://mozilla.org/MPL/2.0/. */
+ 
+ #include "ServiceWorker.h"
+ 
+ #include "nsIDocument.h"
+ #include "nsPIDOMWindow.h"
+ #include "ServiceWorkerManager.h"
+ #include "ServiceWorkerPrivate.h"
+-#include "WorkerPrivate.h"
+ 
+ #include "mozilla/dom/DOMPrefs.h"
+ #include "mozilla/dom/ClientIPCTypes.h"
+ #include "mozilla/dom/ClientState.h"
+ #include "mozilla/dom/Promise.h"
+ #include "mozilla/dom/ServiceWorkerGlobalScopeBinding.h"
++#include "mozilla/dom/WorkerPrivate.h"
+ 
+ #ifdef XP_WIN
+ #undef PostMessage
+ #endif
+ 
+ using mozilla::ErrorResult;
+ using namespace mozilla::dom;
+ 
+diff --git a/dom/serviceworkers/ServiceWorkerEvents.cpp b/dom/serviceworkers/ServiceWorkerEvents.cpp
+--- a/dom/serviceworkers/ServiceWorkerEvents.cpp
++++ b/dom/serviceworkers/ServiceWorkerEvents.cpp
+@@ -38,20 +38,20 @@
+ #include "mozilla/dom/PromiseNativeHandler.h"
+ #include "mozilla/dom/PushEventBinding.h"
+ #include "mozilla/dom/PushMessageDataBinding.h"
+ #include "mozilla/dom/PushUtil.h"
+ #include "mozilla/dom/Request.h"
+ #include "mozilla/dom/TypedArray.h"
+ #include "mozilla/dom/Response.h"
+ #include "mozilla/dom/WorkerScope.h"
++#include "mozilla/dom/WorkerPrivate.h"
+ 
+ #include "js/Conversions.h"
+ #include "js/TypeDecls.h"
+-#include "WorkerPrivate.h"
+ #include "xpcpublic.h"
+ 
+ using namespace mozilla;
+ using namespace mozilla::dom;
+ using namespace mozilla::dom::workers;
+ 
+ namespace {
+ 
+diff --git a/dom/serviceworkers/ServiceWorkerJob.cpp b/dom/serviceworkers/ServiceWorkerJob.cpp
+--- a/dom/serviceworkers/ServiceWorkerJob.cpp
++++ b/dom/serviceworkers/ServiceWorkerJob.cpp
+@@ -1,19 +1,19 @@
+ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+ /* vim: set ts=8 sts=2 et sw=2 tw=80: */
+ /* 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 "ServiceWorkerJob.h"
+ 
++#include "mozilla/dom/WorkerCommon.h"
+ #include "nsProxyRelease.h"
+ #include "nsThreadUtils.h"
+-#include "WorkerCommon.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+ ServiceWorkerJob::Type
+ ServiceWorkerJob::GetType() const
+ {
+   return mType;
+diff --git a/dom/serviceworkers/ServiceWorkerJobQueue.cpp b/dom/serviceworkers/ServiceWorkerJobQueue.cpp
+--- a/dom/serviceworkers/ServiceWorkerJobQueue.cpp
++++ b/dom/serviceworkers/ServiceWorkerJobQueue.cpp
+@@ -2,17 +2,17 @@
+ /* vim: set ts=8 sts=2 et sw=2 tw=80: */
+ /* 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 "ServiceWorkerJobQueue.h"
+ 
+ #include "ServiceWorkerJob.h"
+-#include "WorkerCommon.h"
++#include "mozilla/dom/WorkerCommon.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+ class ServiceWorkerJobQueue::Callback final : public ServiceWorkerJob::Callback
+ {
+   RefPtr<ServiceWorkerJobQueue> mQueue;
+ 
+diff --git a/dom/serviceworkers/ServiceWorkerManager.cpp b/dom/serviceworkers/ServiceWorkerManager.cpp
+--- a/dom/serviceworkers/ServiceWorkerManager.cpp
++++ b/dom/serviceworkers/ServiceWorkerManager.cpp
+@@ -47,50 +47,49 @@
+ #include "mozilla/dom/InternalHeaders.h"
+ #include "mozilla/dom/Navigator.h"
+ #include "mozilla/dom/NotificationEvent.h"
+ #include "mozilla/dom/PromiseNativeHandler.h"
+ #include "mozilla/dom/PromiseWindowProxy.h"
+ #include "mozilla/dom/Request.h"
+ #include "mozilla/dom/RootedDictionary.h"
+ #include "mozilla/dom/TypedArray.h"
++#include "mozilla/dom/SharedWorker.h"
++#include "mozilla/dom/WorkerPrivate.h"
++#include "mozilla/dom/WorkerRunnable.h"
++#include "mozilla/dom/WorkerScope.h"
+ #include "mozilla/ipc/BackgroundChild.h"
+ #include "mozilla/ipc/PBackgroundChild.h"
+ #include "mozilla/ipc/PBackgroundSharedTypes.h"
+ #include "mozilla/dom/ScriptLoader.h"
+ #include "mozilla/Unused.h"
+ #include "mozilla/EnumSet.h"
+ 
+ #include "nsContentPolicyUtils.h"
+ #include "nsContentSecurityManager.h"
+ #include "nsContentUtils.h"
+ #include "nsNetUtil.h"
+ #include "nsProxyRelease.h"
+ #include "nsQueryObject.h"
+ #include "nsTArray.h"
+ 
+-#include "RuntimeService.h"
+ #include "ServiceWorker.h"
+ #include "ServiceWorkerContainer.h"
+ #include "ServiceWorkerInfo.h"
+ #include "ServiceWorkerJobQueue.h"
+ #include "ServiceWorkerManagerChild.h"
+ #include "ServiceWorkerPrivate.h"
+ #include "ServiceWorkerRegisterJob.h"
+ #include "ServiceWorkerRegistrar.h"
+ #include "ServiceWorkerRegistration.h"
+ #include "ServiceWorkerScriptCache.h"
+ #include "ServiceWorkerEvents.h"
+ #include "ServiceWorkerUnregisterJob.h"
+ #include "ServiceWorkerUpdateJob.h"
+ #include "ServiceWorkerUpdaterChild.h"
+-#include "SharedWorker.h"
+-#include "WorkerPrivate.h"
+-#include "WorkerRunnable.h"
+-#include "WorkerScope.h"
+ 
+ #ifdef PostMessage
+ #undef PostMessage
+ #endif
+ 
+ using namespace mozilla;
+ using namespace mozilla::dom;
+ using namespace mozilla::ipc;
+diff --git a/dom/serviceworkers/ServiceWorkerPrivate.cpp b/dom/serviceworkers/ServiceWorkerPrivate.cpp
+--- a/dom/serviceworkers/ServiceWorkerPrivate.cpp
++++ b/dom/serviceworkers/ServiceWorkerPrivate.cpp
+@@ -17,30 +17,30 @@
+ #include "nsISupportsImpl.h"
+ #include "nsITimedChannel.h"
+ #include "nsIUploadChannel2.h"
+ #include "nsNetUtil.h"
+ #include "nsProxyRelease.h"
+ #include "nsQueryObject.h"
+ #include "nsStreamUtils.h"
+ #include "nsStringStream.h"
+-#include "WorkerDebugger.h"
+-#include "WorkerRunnable.h"
+-#include "WorkerScope.h"
+ #include "mozilla/Assertions.h"
+ #include "mozilla/dom/Client.h"
+ #include "mozilla/dom/ClientIPCTypes.h"
+ #include "mozilla/dom/DOMPrefs.h"
+ #include "mozilla/dom/FetchUtil.h"
+ #include "mozilla/dom/IndexedDatabaseManager.h"
+ #include "mozilla/dom/InternalHeaders.h"
+ #include "mozilla/dom/NotificationEvent.h"
+ #include "mozilla/dom/PromiseNativeHandler.h"
+ #include "mozilla/dom/PushEventBinding.h"
+ #include "mozilla/dom/RequestBinding.h"
++#include "mozilla/dom/WorkerDebugger.h"
++#include "mozilla/dom/WorkerRunnable.h"
++#include "mozilla/dom/WorkerScope.h"
+ #include "mozilla/Unused.h"
+ 
+ using namespace mozilla;
+ using namespace mozilla::dom;
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+diff --git a/dom/serviceworkers/ServiceWorkerPrivate.h b/dom/serviceworkers/ServiceWorkerPrivate.h
+--- a/dom/serviceworkers/ServiceWorkerPrivate.h
++++ b/dom/serviceworkers/ServiceWorkerPrivate.h
+@@ -3,17 +3,17 @@
+ /* 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/. */
+ 
+ #ifndef mozilla_dom_serviceworkerprivate_h
+ #define mozilla_dom_serviceworkerprivate_h
+ 
+ #include "nsCOMPtr.h"
+-#include "WorkerPrivate.h"
++#include "mozilla/dom/WorkerPrivate.h"
+ 
+ #define NOTIFICATION_CLICK_EVENT_NAME "notificationclick"
+ #define NOTIFICATION_CLOSE_EVENT_NAME "notificationclose"
+ 
+ class nsIInterceptedChannel;
+ 
+ namespace mozilla {
+ namespace dom {
+diff --git a/dom/serviceworkers/ServiceWorkerRegisterJob.cpp b/dom/serviceworkers/ServiceWorkerRegisterJob.cpp
+--- a/dom/serviceworkers/ServiceWorkerRegisterJob.cpp
++++ b/dom/serviceworkers/ServiceWorkerRegisterJob.cpp
+@@ -1,17 +1,17 @@
+ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+ /* vim: set ts=8 sts=2 et sw=2 tw=80: */
+ /* 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 "ServiceWorkerRegisterJob.h"
+ 
+-#include "WorkerCommon.h"
++#include "mozilla/dom/WorkerCommon.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+ ServiceWorkerRegisterJob::ServiceWorkerRegisterJob(
+     nsIPrincipal* aPrincipal,
+     const nsACString& aScope,
+     const nsACString& aScriptSpec,
+diff --git a/dom/serviceworkers/ServiceWorkerRegistration.cpp b/dom/serviceworkers/ServiceWorkerRegistration.cpp
+--- a/dom/serviceworkers/ServiceWorkerRegistration.cpp
++++ b/dom/serviceworkers/ServiceWorkerRegistration.cpp
+@@ -10,34 +10,33 @@
+ #include "mozilla/dom/DOMPrefs.h"
+ #include "mozilla/dom/Notification.h"
+ #include "mozilla/dom/Promise.h"
+ #include "mozilla/dom/PromiseWindowProxy.h"
+ #include "mozilla/dom/PromiseWorkerProxy.h"
+ #include "mozilla/dom/PushManagerBinding.h"
+ #include "mozilla/dom/PushManager.h"
+ #include "mozilla/dom/ServiceWorkerRegistrationBinding.h"
++#include "mozilla/dom/WorkerPrivate.h"
++#include "mozilla/dom/WorkerCommon.h"
++#include "mozilla/dom/WorkerScope.h"
+ #include "mozilla/Services.h"
+ #include "mozilla/Unused.h"
+ #include "nsCycleCollectionParticipant.h"
+ #include "nsNetUtil.h"
+ #include "nsServiceManagerUtils.h"
+ #include "ServiceWorker.h"
+ #include "ServiceWorkerManager.h"
+ 
+ #include "nsIDocument.h"
+ #include "nsIServiceWorkerManager.h"
+ #include "nsISupportsPrimitives.h"
+ #include "nsPIDOMWindow.h"
+ #include "nsContentUtils.h"
+ 
+-#include "WorkerPrivate.h"
+-#include "WorkerCommon.h"
+-#include "WorkerScope.h"
+-
+ using namespace mozilla::dom::workers;
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+ ////////////////////////////////////////////////////
+ // Main Thread implementation
+ 
+diff --git a/dom/serviceworkers/ServiceWorkerScriptCache.cpp b/dom/serviceworkers/ServiceWorkerScriptCache.cpp
+--- a/dom/serviceworkers/ServiceWorkerScriptCache.cpp
++++ b/dom/serviceworkers/ServiceWorkerScriptCache.cpp
+@@ -8,31 +8,31 @@
+ #include "mozilla/SystemGroup.h"
+ #include "mozilla/Unused.h"
+ #include "mozilla/dom/CacheBinding.h"
+ #include "mozilla/dom/cache/CacheStorage.h"
+ #include "mozilla/dom/cache/Cache.h"
+ #include "mozilla/dom/Promise.h"
+ #include "mozilla/dom/PromiseWorkerProxy.h"
+ #include "mozilla/dom/ScriptLoader.h"
++#include "mozilla/dom/WorkerCommon.h"
+ #include "mozilla/ipc/BackgroundUtils.h"
+ #include "mozilla/ipc/PBackgroundSharedTypes.h"
+ #include "nsICacheInfoChannel.h"
+ #include "nsIHttpChannelInternal.h"
+ #include "nsIStreamLoader.h"
+ #include "nsIThreadRetargetableRequest.h"
+ 
+ #include "nsIInputStreamPump.h"
+ #include "nsIPrincipal.h"
+ #include "nsIScriptError.h"
+ #include "nsIScriptSecurityManager.h"
+ #include "nsContentUtils.h"
+ #include "nsNetUtil.h"
+ #include "ServiceWorkerManager.h"
+-#include "WorkerCommon.h"
+ #include "nsStringStream.h"
+ 
+ using mozilla::dom::cache::Cache;
+ using mozilla::dom::cache::CacheStorage;
+ using mozilla::ipc::PrincipalInfo;
+ 
+ namespace mozilla {
+ namespace dom {
+diff --git a/dom/serviceworkers/ServiceWorkerUpdateJob.cpp b/dom/serviceworkers/ServiceWorkerUpdateJob.cpp
+--- a/dom/serviceworkers/ServiceWorkerUpdateJob.cpp
++++ b/dom/serviceworkers/ServiceWorkerUpdateJob.cpp
+@@ -4,17 +4,17 @@
+  * 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 "ServiceWorkerUpdateJob.h"
+ 
+ #include "nsIScriptError.h"
+ #include "nsIURL.h"
+ #include "ServiceWorkerScriptCache.h"
+-#include "WorkerCommon.h"
++#include "mozilla/dom/WorkerCommon.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+ namespace {
+ 
+ /**
+  * The spec mandates slightly different behaviors for computing the scope
+diff --git a/dom/serviceworkers/moz.build b/dom/serviceworkers/moz.build
+--- a/dom/serviceworkers/moz.build
++++ b/dom/serviceworkers/moz.build
+@@ -54,20 +54,16 @@ UNIFIED_SOURCES += [
+ 
+ IPDL_SOURCES += [
+     'IPCServiceWorkerDescriptor.ipdlh',
+     'PServiceWorkerManager.ipdl',
+     'PServiceWorkerUpdater.ipdl',
+     'ServiceWorkerRegistrarTypes.ipdlh',
+ ]
+ 
+-LOCAL_INCLUDES += [
+-    '/dom/workers',
+-]
+-
+ include('/ipc/chromium/chromium-config.mozbuild')
+ 
+ FINAL_LIBRARY = 'xul'
+ 
+ MOCHITEST_MANIFESTS += [
+     'test/mochitest.ini',
+ ]
+ 
+diff --git a/dom/url/URLWorker.cpp b/dom/url/URLWorker.cpp
+--- a/dom/url/URLWorker.cpp
++++ b/dom/url/URLWorker.cpp
+@@ -2,20 +2,20 @@
+ /* vim: set ts=8 sts=2 et sw=2 tw=80: */
+ /* 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 "URLWorker.h"
+ 
+ #include "mozilla/dom/Blob.h"
++#include "mozilla/dom/WorkerPrivate.h"
++#include "mozilla/dom/WorkerRunnable.h"
++#include "mozilla/dom/WorkerScope.h"
+ #include "nsHostObjectProtocolHandler.h"
+-#include "WorkerPrivate.h"
+-#include "WorkerRunnable.h"
+-#include "WorkerScope.h"
+ #include "nsStandardURL.h"
+ #include "nsURLHelper.h"
+ 
+ namespace mozilla {
+ 
+ using net::nsStandardURL;
+ 
+ namespace dom {
+diff --git a/dom/url/moz.build b/dom/url/moz.build
+--- a/dom/url/moz.build
++++ b/dom/url/moz.build
+@@ -15,17 +15,16 @@ EXPORTS.mozilla.dom += [
+ UNIFIED_SOURCES += [
+     'URL.cpp',
+     'URLMainThread.cpp',
+     'URLSearchParams.cpp',
+     'URLWorker.cpp',
+ ]
+ 
+ LOCAL_INCLUDES += [
+-    '../workers',
+     '/netwerk/base',
+ ]
+ 
+ MOCHITEST_MANIFESTS += ['tests/mochitest.ini']
+ MOCHITEST_CHROME_MANIFESTS += [ 'tests/chrome.ini' ]
+ BROWSER_CHROME_MANIFESTS += [ 'tests/browser.ini' ]
+ 
+ include('/ipc/chromium/chromium-config.mozbuild')
+diff --git a/dom/websocket/moz.build b/dom/websocket/moz.build
+--- a/dom/websocket/moz.build
++++ b/dom/websocket/moz.build
+@@ -12,17 +12,16 @@ EXPORTS.mozilla.dom += [
+ ]
+ 
+ UNIFIED_SOURCES += [
+     'WebSocket.cpp',
+ ]
+ 
+ LOCAL_INCLUDES += [
+     '/dom/base',
+-    '/dom/workers',
+ ]
+ 
+ MOCHITEST_CHROME_MANIFESTS += [
+     'tests/chrome.ini',
+ ]
+ 
+ MOCHITEST_MANIFESTS += [
+     'tests/mochitest.ini',
+diff --git a/dom/workers/RuntimeService.h b/dom/workers/RuntimeService.h
+--- a/dom/workers/RuntimeService.h
++++ b/dom/workers/RuntimeService.h
+@@ -2,17 +2,17 @@
+ /* vim: set ts=8 sts=2 et sw=2 tw=80: */
+ /* 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/. */
+ 
+ #ifndef mozilla_dom_workers_runtimeservice_h__
+ #define mozilla_dom_workers_runtimeservice_h__
+ 
+-#include "WorkerCommon.h"
++#include "mozilla/dom/WorkerCommon.h"
+ 
+ #include "nsIObserver.h"
+ 
+ #include "mozilla/dom/BindingDeclarations.h"
+ #include "mozilla/dom/workerinternals/JSSettings.h"
+ #include "nsClassHashtable.h"
+ #include "nsHashKeys.h"
+ #include "nsTArray.h"
+diff --git a/dom/workers/WorkerNavigator.h b/dom/workers/WorkerNavigator.h
+--- a/dom/workers/WorkerNavigator.h
++++ b/dom/workers/WorkerNavigator.h
+@@ -3,21 +3,21 @@
+ /* 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/. */
+ 
+ #ifndef mozilla_dom_workernavigator_h__
+ #define mozilla_dom_workernavigator_h__
+ 
+ #include "WorkerCommon.h"
+-#include "RuntimeService.h"
+ #include "nsString.h"
+ #include "nsWrapperCache.h"
+ #include "mozilla/dom/BindingDeclarations.h"
+ #include "mozilla/dom/StorageManager.h"
++#include "mozilla/dom/workerinternals/RuntimeService.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ class Promise;
+ class StorageManager;
+ 
+ namespace network {
+ class Connection;
+diff --git a/dom/workers/WorkerPrivate.cpp b/dom/workers/WorkerPrivate.cpp
+--- a/dom/workers/WorkerPrivate.cpp
++++ b/dom/workers/WorkerPrivate.cpp
+@@ -87,21 +87,24 @@ WorkerLog()
+ mozilla::LogModule*
+ TimeoutsLog()
+ {
+   return sWorkerTimeoutsLog;
+ }
+ 
+ #define LOG(log, _args) MOZ_LOG(log, LogLevel::Debug, _args);
+ 
+-using namespace mozilla;
+-using namespace mozilla::dom;
+-using namespace mozilla::dom::workers;
+-using namespace mozilla::dom::workerinternals;
+-using namespace mozilla::ipc;
++namespace mozilla {
++
++using namespace ipc;
++
++namespace dom {
++
++using namespace workers;
++using namespace workerinternals;
+ 
+ MOZ_DEFINE_MALLOC_SIZE_OF(JsWorkerMallocSizeOf)
+ 
+ namespace {
+ 
+ #ifdef DEBUG
+ 
+ const nsIID kDEBUGWorkerEventTargetIID = {
+@@ -5658,8 +5661,11 @@ EventTarget::IsOnCurrentThreadInfallible
+     return false;
+   }
+ 
+   return mWorkerPrivate->IsOnCurrentThread();
+ }
+ 
+ // Force instantiation.
+ template class WorkerPrivateParent<WorkerPrivate>;
++
++} // dom namespace
++} // mozilla namespace
+diff --git a/dom/xhr/XMLHttpRequestWorker.cpp b/dom/xhr/XMLHttpRequestWorker.cpp
+--- a/dom/xhr/XMLHttpRequestWorker.cpp
++++ b/dom/xhr/XMLHttpRequestWorker.cpp
+@@ -17,27 +17,26 @@
+ #include "js/GCPolicyAPI.h"
+ #include "mozilla/ArrayUtils.h"
+ #include "mozilla/dom/Exceptions.h"
+ #include "mozilla/dom/File.h"
+ #include "mozilla/dom/FormData.h"
+ #include "mozilla/dom/ProgressEvent.h"
+ #include "mozilla/dom/StructuredCloneHolder.h"
+ #include "mozilla/dom/URLSearchParams.h"
++#include "mozilla/dom/WorkerScope.h"
++#include "mozilla/dom/WorkerPrivate.h"
++#include "mozilla/dom/WorkerRunnable.h"
+ #include "mozilla/Telemetry.h"
+ #include "nsComponentManagerUtils.h"
+ #include "nsContentUtils.h"
+ #include "nsJSUtils.h"
+ #include "nsThreadUtils.h"
+ #include "nsVariant.h"
+ 
+-#include "RuntimeService.h"
+-#include "WorkerScope.h"
+-#include "WorkerPrivate.h"
+-#include "WorkerRunnable.h"
+ #include "XMLHttpRequestUpload.h"
+ 
+ #include "mozilla/UniquePtr.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+ /* static */ void
+@@ -1585,17 +1584,17 @@ NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INH
+ NS_IMPL_CYCLE_COLLECTION_TRACE_END
+ 
+ /* static */ already_AddRefed<XMLHttpRequest>
+ XMLHttpRequestWorker::Construct(const GlobalObject& aGlobal,
+                                 const MozXMLHttpRequestParameters& aParams,
+                                 ErrorResult& aRv)
+ {
+   JSContext* cx = aGlobal.Context();
+-  WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(cx);
++  WorkerPrivate* workerPrivate = workers::GetWorkerPrivateFromContext(cx);
+   MOZ_ASSERT(workerPrivate);
+ 
+   RefPtr<XMLHttpRequestWorker> xhr = new XMLHttpRequestWorker(workerPrivate);
+ 
+   if (workerPrivate->XHRParamsAllowed()) {
+     if (aParams.mMozSystem)
+       xhr->mMozAnon = true;
+     else
+diff --git a/dom/xhr/XMLHttpRequestWorker.h b/dom/xhr/XMLHttpRequestWorker.h
+--- a/dom/xhr/XMLHttpRequestWorker.h
++++ b/dom/xhr/XMLHttpRequestWorker.h
+@@ -2,20 +2,20 @@
+ /* vim: set ts=8 sts=2 et sw=2 tw=80: */
+ /* 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/. */
+ 
+ #ifndef mozilla_dom_XMLHttpRequestWorker_h
+ #define mozilla_dom_XMLHttpRequestWorker_h
+ 
+-#include "WorkerHolder.h"
+ #include "XMLHttpRequest.h"
+ #include "XMLHttpRequestString.h"
+ #include "mozilla/dom/TypedArray.h"
++#include "mozilla/dom/WorkerHolder.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+ class Proxy;
+ class SendRunnable;
+ class DOMString;
+ class WorkerPrivate;
+diff --git a/dom/xhr/moz.build b/dom/xhr/moz.build
+--- a/dom/xhr/moz.build
++++ b/dom/xhr/moz.build
+@@ -28,17 +28,16 @@ UNIFIED_SOURCES += [
+     'XMLHttpRequestString.cpp',
+     'XMLHttpRequestUpload.cpp',
+     'XMLHttpRequestWorker.cpp',
+ ]
+ 
+ LOCAL_INCLUDES += [
+     '/dom/base',
+     '/dom/file',
+-    '/dom/workers',
+     '/netwerk/base',
+ ]
+ 
+ MOCHITEST_MANIFESTS += [ 'tests/mochitest.ini' ]
+ 
+ BROWSER_CHROME_MANIFESTS += [ 'tests/browser.ini' ]
+ 
+ include('/ipc/chromium/chromium-config.mozbuild')
+diff --git a/gfx/thebes/gfxUtils.cpp b/gfx/thebes/gfxUtils.cpp
+--- a/gfx/thebes/gfxUtils.cpp
++++ b/gfx/thebes/gfxUtils.cpp
+@@ -1453,17 +1453,18 @@ private:
+ };
+ 
+ /* static */ nsresult
+ gfxUtils::ThreadSafeGetFeatureStatus(const nsCOMPtr<nsIGfxInfo>& gfxInfo,
+                                      int32_t feature, nsACString& failureId,
+                                      int32_t* status)
+ {
+   if (!NS_IsMainThread()) {
+-    dom::WorkerPrivate* workerPrivate = dom::GetCurrentThreadWorkerPrivate();
++    dom::WorkerPrivate* workerPrivate =
++      dom::workers::GetCurrentThreadWorkerPrivate();
+ 
+     RefPtr<GetFeatureStatusRunnable> runnable =
+       new GetFeatureStatusRunnable(workerPrivate, gfxInfo, feature, failureId,
+                                    status);
+ 
+     ErrorResult rv;
+     runnable->Dispatch(dom::WorkerStatus::Terminating, rv);
+     if (rv.Failed()) {
+diff --git a/gfx/thebes/moz.build b/gfx/thebes/moz.build
+--- a/gfx/thebes/moz.build
++++ b/gfx/thebes/moz.build
+@@ -243,17 +243,16 @@ USE_LIBS += [
+ ]
+ 
+ include('/ipc/chromium/chromium-config.mozbuild')
+ 
+ FINAL_LIBRARY = 'xul'
+ 
+ LOCAL_INCLUDES += [
+     '/dom/base',
+-    '/dom/workers',
+     '/dom/xml',
+ ]
+ 
+ if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('android', 'gtk3'):
+     DEFINES['MOZ_ENABLE_FREETYPE'] = True
+ 
+ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
+     for var in ('MOZ_ENABLE_D3D10_LAYER',):
+diff --git a/ipc/glue/moz.build b/ipc/glue/moz.build
+--- a/ipc/glue/moz.build
++++ b/ipc/glue/moz.build
+@@ -185,17 +185,16 @@ if CONFIG['CC_TYPE'] in ('msvc', 'clang-
+     SOURCES['BackgroundChildImpl.cpp'].flags += ['-wd4312']
+     SOURCES['BackgroundParentImpl.cpp'].flags += ['-wd4312']
+ 
+ LOCAL_INCLUDES += [
+     '/caps',
+     '/dom/broadcastchannel',
+     '/dom/indexedDB',
+     '/dom/storage',
+-    '/dom/workers',
+     '/media/webrtc/trunk',
+     '/xpcom/build',
+ ]
+ 
+ IPDL_SOURCES = [
+     'InputStreamParams.ipdlh',
+     'IPCStream.ipdlh',
+     'PBackground.ipdl',
+diff --git a/js/xpconnect/src/moz.build b/js/xpconnect/src/moz.build
+--- a/js/xpconnect/src/moz.build
++++ b/js/xpconnect/src/moz.build
+@@ -51,16 +51,15 @@ FINAL_LIBRARY = 'xul'
+ LOCAL_INCLUDES += [
+     '../loader',
+     '../wrappers',
+     '/caps',
+     '/dom/base',
+     '/dom/bindings',
+     '/dom/html',
+     '/dom/svg',
+-    '/dom/workers',
+     '/layout/base',
+     '/layout/style',
+     '/xpcom/reflect/xptinfo',
+ ]
+ 
+ if CONFIG['CC_TYPE'] in ('clang', 'gcc'):
+     CXXFLAGS += ['-Wno-shadow', '-Werror=format']
+diff --git a/js/xpconnect/src/nsXPConnect.cpp b/js/xpconnect/src/nsXPConnect.cpp
+--- a/js/xpconnect/src/nsXPConnect.cpp
++++ b/js/xpconnect/src/nsXPConnect.cpp
+@@ -1321,25 +1321,27 @@ IsChromeOrXBL(JSContext* cx, JSObject* /
+     // compat and not security for remote XUL, we just always claim to be XBL.
+     //
+     // Note that, for performance, we don't check AllowXULXBLForPrincipal here,
+     // and instead rely on the fact that AllowContentXBLScope() only returns false in
+     // remote XUL situations.
+     return AccessCheck::isChrome(c) || IsContentXBLCompartment(c) || !AllowContentXBLScope(realm);
+ }
+ 
++namespace workers {
+ extern bool IsCurrentThreadRunningChromeWorker();
++}
+ 
+ bool
+ ThreadSafeIsChromeOrXBL(JSContext* cx, JSObject* obj)
+ {
+     if (NS_IsMainThread()) {
+         return IsChromeOrXBL(cx, obj);
+     }
+-    return IsCurrentThreadRunningChromeWorker();
++    return workers::IsCurrentThreadRunningChromeWorker();
+ }
+ 
+ } // namespace dom
+ } // namespace mozilla
+ 
+ void
+ xpc::CreateCooperativeContext()
+ {
+diff --git a/toolkit/components/terminator/nsTerminator.cpp b/toolkit/components/terminator/nsTerminator.cpp
+--- a/toolkit/components/terminator/nsTerminator.cpp
++++ b/toolkit/components/terminator/nsTerminator.cpp
+@@ -44,17 +44,17 @@
+ #include "mozilla/DebugOnly.h"
+ #include "mozilla/MemoryChecking.h"
+ #include "mozilla/Preferences.h"
+ #include "mozilla/Services.h"
+ #include "mozilla/UniquePtr.h"
+ #include "mozilla/Unused.h"
+ #include "mozilla/Telemetry.h"
+ 
+-#include "mozilla/dom/workers/RuntimeService.h"
++#include "mozilla/dom/workerinternals/RuntimeService.h"
+ 
+ // Normally, the number of milliseconds that AsyncShutdown waits until
+ // it decides to crash is specified as a preference. We use the
+ // following value as a fallback if for some reason the preference is
+ // absent.
+ #define FALLBACK_ASYNCSHUTDOWN_CRASH_AFTER_MS 60000
+ 
+ // Additional number of milliseconds to wait until we decide to exit
+@@ -151,18 +151,18 @@ RunWatchdog(void* arg)
+ #else
+     usleep(1000000 /* usec */);
+ #endif
+ 
+     if (gHeartbeat++ < timeToLive) {
+       continue;
+     }
+ 
+-    mozilla::dom::workers::RuntimeService* runtimeService =
+-      mozilla::dom::workers::RuntimeService::GetService();
++    mozilla::dom::workerinternals::RuntimeService* runtimeService =
++      mozilla::dom::workerinternals::RuntimeService::GetService();
+     if (runtimeService) {
+      runtimeService->CrashIfHanging();
+     }
+ 
+     // Shutdown is apparently dead. Crash the process.
+     CrashReporter::SetMinidumpAnalysisAllThreads();
+ 
+     MOZ_CRASH("Shutdown too long, probably frozen, causing a crash.");

+ 2834 - 0
mozilla-release/patches/1435174-60a1.patch

@@ -0,0 +1,2834 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1517856907 -3600
+# Node ID 7818e2f5572c3e90c14d0d42881d793864baa2e4
+# Parent  999725e34730ef73d1cd899902f65ed93843d60c
+Bug 1435174 - Remove the renaming 'using namespace workers', r=bkelly
+
+diff --git a/caps/nsJSPrincipals.cpp b/caps/nsJSPrincipals.cpp
+--- a/caps/nsJSPrincipals.cpp
++++ b/caps/nsJSPrincipals.cpp
+@@ -10,17 +10,17 @@
+ #include "nsJSPrincipals.h"
+ #include "plstr.h"
+ #include "nsCOMPtr.h"
+ #include "nsIServiceManager.h"
+ #include "nsMemory.h"
+ #include "nsStringBuffer.h"
+ 
+ #include "mozilla/dom/StructuredCloneTags.h"
+-// for mozilla::dom::workers::kJSPrincipalsDebugToken
++// for mozilla::dom::workerinternals::kJSPrincipalsDebugToken
+ #include "mozilla/dom/workerinternals/JSSettings.h"
+ #include "mozilla/ipc/BackgroundUtils.h"
+ 
+ using namespace mozilla;
+ using namespace mozilla::ipc;
+ 
+ NS_IMETHODIMP_(MozExternalRefCountType)
+ nsJSPrincipals::AddRef()
+diff --git a/dom/base/EventSource.cpp b/dom/base/EventSource.cpp
+--- a/dom/base/EventSource.cpp
++++ b/dom/base/EventSource.cpp
+@@ -45,18 +45,16 @@
+ #include "nsWrapperCacheInlines.h"
+ #include "mozilla/Attributes.h"
+ #include "nsError.h"
+ #include "mozilla/Encoding.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+-using namespace workers;
+-
+ static LazyLogModule gEventSourceLog("EventSource");
+ 
+ #define SPACE_CHAR           (char16_t)0x0020
+ #define CR_CHAR              (char16_t)0x000D
+ #define LF_CHAR              (char16_t)0x000A
+ #define COLON_CHAR           (char16_t)0x003A
+ 
+ // Reconnection time related values in milliseconds. The default one is equal
+diff --git a/dom/base/ImageEncoder.cpp b/dom/base/ImageEncoder.cpp
+--- a/dom/base/ImageEncoder.cpp
++++ b/dom/base/ImageEncoder.cpp
+@@ -84,17 +84,17 @@ public:
+   explicit EncodingCompleteEvent(EncodeCompleteCallback* aEncodeCompleteCallback)
+     : CancelableRunnable("EncodingCompleteEvent")
+     , mImgSize(0)
+     , mType()
+     , mImgData(nullptr)
+     , mEncodeCompleteCallback(aEncodeCompleteCallback)
+     , mFailed(false)
+   {
+-    if (!NS_IsMainThread() && workers::GetCurrentThreadWorkerPrivate()) {
++    if (!NS_IsMainThread() && GetCurrentThreadWorkerPrivate()) {
+       mCreationEventTarget = GetCurrentThreadEventTarget();
+     } else {
+       mCreationEventTarget = GetMainThreadEventTarget();
+     }
+   }
+ 
+   NS_IMETHOD Run() override
+   {
+diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp
+--- a/dom/base/nsContentUtils.cpp
++++ b/dom/base/nsContentUtils.cpp
+@@ -2510,19 +2510,19 @@ nsContentUtils::CalcRoundedWindowSizeFor
+ 
+   *aOutputWidth = resultWidth;
+   *aOutputHeight = resultHeight;
+ }
+ 
+ bool
+ nsContentUtils::ThreadsafeIsCallerChrome()
+ {
+-  return NS_IsMainThread() ?
+-    IsCallerChrome() :
+-    workers::IsCurrentThreadRunningChromeWorker();
++  return NS_IsMainThread()
++           ? IsCallerChrome()
++           : IsCurrentThreadRunningChromeWorker();
+ }
+ 
+ bool
+ nsContentUtils::IsCallerContentXBL()
+ {
+   JSContext *cx = GetCurrentJSContext();
+   if (!cx)
+     return false;
+@@ -2551,17 +2551,17 @@ nsContentUtils::IsSystemCaller(JSContext
+ 
+ bool
+ nsContentUtils::ThreadsafeIsSystemCaller(JSContext* aCx)
+ {
+   if (NS_IsMainThread()) {
+     return IsSystemCaller(aCx);
+   }
+ 
+-  return workers::GetWorkerPrivateFromContext(aCx)->UsesSystemPrincipal();
++  return GetWorkerPrivateFromContext(aCx)->UsesSystemPrincipal();
+ }
+ 
+ // static
+ bool
+ nsContentUtils::LookupBindingMember(JSContext* aCx, nsIContent *aContent,
+                                     JS::Handle<jsid> aId,
+                                     JS::MutableHandle<JS::PropertyDescriptor> aDesc)
+ {
+@@ -6208,17 +6208,17 @@ nsContentUtils::GetCurrentJSContext()
+ /* static */
+ JSContext *
+ nsContentUtils::GetCurrentJSContextForThread()
+ {
+   MOZ_ASSERT(IsInitialized());
+   if (MOZ_LIKELY(NS_IsMainThread())) {
+     return GetCurrentJSContext();
+   }
+-  return workers::GetCurrentThreadJSContext();
++  return GetCurrentWorkerThreadJSContext();
+ }
+ 
+ template<typename StringType, typename CharType>
+ void
+ _ASCIIToLowerInSitu(StringType& aStr)
+ {
+   CharType* iter = aStr.BeginWriting();
+   CharType* end = aStr.EndWriting();
+diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp
+--- a/dom/base/nsGlobalWindow.cpp
++++ b/dom/base/nsGlobalWindow.cpp
+@@ -2055,17 +2055,17 @@ nsGlobalWindow::FreeInnerObjects()
+   NotifyDOMWindowDestroyed(this);
+   if (auto* reporter = nsWindowMemoryReporter::Get()) {
+     reporter->ObserveDOMWindowDetached(this);
+   }
+ 
+   mInnerObjectsFreed = true;
+ 
+   // Kill all of the workers for this window.
+-  mozilla::dom::workers::CancelWorkersForWindow(AsInner());
++  CancelWorkersForWindow(AsInner());
+ 
+   if (mTimeoutManager) {
+     mTimeoutManager->ClearAllTimeouts();
+   }
+ 
+   if (mIdleTimer) {
+     mIdleTimer->Cancel();
+     mIdleTimer = nullptr;
+@@ -12540,17 +12540,17 @@ nsGlobalWindow::Suspend()
+   nsCOMPtr<nsIDeviceSensors> ac = do_GetService(NS_DEVICE_SENSORS_CONTRACTID);
+   if (ac) {
+     for (uint32_t i = 0; i < mEnabledSensors.Length(); i++)
+       ac->RemoveWindowListener(mEnabledSensors[i], this);
+   }
+   DisableGamepadUpdates();
+   DisableVRUpdates();
+ 
+-  mozilla::dom::workers::SuspendWorkersForWindow(AsInner());
++  SuspendWorkersForWindow(AsInner());
+ 
+   SuspendIdleRequests();
+ 
+   mTimeoutManager->Suspend();
+ 
+   // Suspend all of the AudioContexts for this window
+   for (uint32_t i = 0; i < mAudioContexts.Length(); ++i) {
+     ErrorResult dummy;
+@@ -12603,17 +12603,17 @@ nsGlobalWindow::Resume()
+ 
+   mTimeoutManager->Resume();
+ 
+   ResumeIdleRequests();
+ 
+   // Resume all of the workers for this window.  We must do this
+   // after timeouts since workers may have queued events that can trigger
+   // a setTimeout().
+-  mozilla::dom::workers::ResumeWorkersForWindow(AsInner());
++  ResumeWorkersForWindow(AsInner());
+ }
+ 
+ bool
+ nsGlobalWindow::IsSuspended() const
+ {
+   MOZ_ASSERT(NS_IsMainThread());
+   // No inner means we are effectively suspended
+   if (IsOuterWindow()) {
+@@ -12644,17 +12644,17 @@ nsGlobalWindow::FreezeInternal()
+   CallOnChildren(&nsGlobalWindow::FreezeInternal);
+ 
+   mFreezeDepth += 1;
+   MOZ_ASSERT(mSuspendDepth >= mFreezeDepth);
+   if (mFreezeDepth != 1) {
+     return;
+   }
+ 
+-  mozilla::dom::workers::FreezeWorkersForWindow(AsInner());
++  FreezeWorkersForWindow(AsInner());
+ 
+   mTimeoutManager->Freeze();
+   if (mClientSource) {
+     mClientSource->Freeze();
+   }
+ 
+   NotifyDOMWindowFrozen(this);
+ }
+@@ -12684,17 +12684,17 @@ nsGlobalWindow::ThawInternal()
+     return;
+   }
+ 
+   if (mClientSource) {
+     mClientSource->Thaw();
+   }
+   mTimeoutManager->Thaw();
+ 
+-  mozilla::dom::workers::ThawWorkersForWindow(AsInner());
++  ThawWorkersForWindow(AsInner());
+ 
+   NotifyDOMWindowThawed(this);
+ }
+ 
+ bool
+ nsGlobalWindow::IsFrozen() const
+ {
+   MOZ_ASSERT(NS_IsMainThread());
+diff --git a/dom/base/nsJSTimeoutHandler.cpp b/dom/base/nsJSTimeoutHandler.cpp
+--- a/dom/base/nsJSTimeoutHandler.cpp
++++ b/dom/base/nsJSTimeoutHandler.cpp
+@@ -18,17 +18,16 @@
+ #include "nsIContentSecurityPolicy.h"
+ #include "nsIDocument.h"
+ #include "nsIScriptTimeoutHandler.h"
+ #include "nsIXPConnect.h"
+ #include "nsJSUtils.h"
+ 
+ using namespace mozilla;
+ using namespace mozilla::dom;
+-using namespace mozilla::dom::workers;
+ 
+ // Our JS nsIScriptTimeoutHandler implementation.
+ class nsJSScriptTimeoutHandler final : public nsIScriptTimeoutHandler
+ {
+ public:
+   // nsISupports
+   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
+   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsJSScriptTimeoutHandler)
+diff --git a/dom/bindings/BindingUtils.cpp b/dom/bindings/BindingUtils.cpp
+--- a/dom/bindings/BindingUtils.cpp
++++ b/dom/bindings/BindingUtils.cpp
+@@ -58,18 +58,16 @@
+ #include "ipc/ErrorIPCUtils.h"
+ #include "mozilla/UseCounter.h"
+ #include "mozilla/dom/DocGroup.h"
+ #include "nsXULElement.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+-using namespace workers;
+-
+ // Forward declare GetConstructorObject methods.
+ #define HTML_TAG(_tag, _classname, _interfacename)                             \
+ namespace HTML##_interfacename##ElementBinding {                               \
+   JSObject* GetConstructorObject(JSContext*);                                  \
+ }
+ #define HTML_OTHER(_tag)
+ #include "nsHTMLTagList.h"
+ #undef HTML_TAG
+diff --git a/dom/broadcastchannel/BroadcastChannel.cpp b/dom/broadcastchannel/BroadcastChannel.cpp
+--- a/dom/broadcastchannel/BroadcastChannel.cpp
++++ b/dom/broadcastchannel/BroadcastChannel.cpp
+@@ -27,17 +27,16 @@
+ #endif
+ 
+ namespace mozilla {
+ 
+ using namespace ipc;
+ 
+ namespace dom {
+ 
+-using namespace workers;
+ using namespace ipc;
+ 
+ class BroadcastChannelMessage final : public StructuredCloneDataNoTransfers
+ {
+ public:
+   NS_INLINE_DECL_REFCOUNTING(BroadcastChannelMessage)
+ 
+   BroadcastChannelMessage()
+diff --git a/dom/broadcastchannel/BroadcastChannelChild.cpp b/dom/broadcastchannel/BroadcastChannelChild.cpp
+--- a/dom/broadcastchannel/BroadcastChannelChild.cpp
++++ b/dom/broadcastchannel/BroadcastChannelChild.cpp
+@@ -18,18 +18,16 @@
+ #include "mozilla/dom/WorkerPrivate.h"
+ 
+ namespace mozilla {
+ 
+ using namespace ipc;
+ 
+ namespace dom {
+ 
+-using namespace workers;
+-
+ BroadcastChannelChild::BroadcastChannelChild(const nsACString& aOrigin)
+   : mBC(nullptr)
+   , mActorDestroyed(false)
+ {
+   CopyUTF8toUTF16(aOrigin, mOrigin);
+ }
+ 
+ BroadcastChannelChild::~BroadcastChannelChild()
+diff --git a/dom/canvas/ImageBitmap.cpp b/dom/canvas/ImageBitmap.cpp
+--- a/dom/canvas/ImageBitmap.cpp
++++ b/dom/canvas/ImageBitmap.cpp
+@@ -21,18 +21,16 @@
+ #include "imgTools.h"
+ 
+ using namespace mozilla::gfx;
+ using namespace mozilla::layers;
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+-using namespace workers;
+-
+ NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(ImageBitmap, mParent)
+ NS_IMPL_CYCLE_COLLECTING_ADDREF(ImageBitmap)
+ NS_IMPL_CYCLE_COLLECTING_RELEASE(ImageBitmap)
+ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ImageBitmap)
+   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
+   NS_INTERFACE_MAP_ENTRY(nsISupports)
+ NS_INTERFACE_MAP_END
+ 
+diff --git a/dom/canvas/ImageBitmap.h b/dom/canvas/ImageBitmap.h
+--- a/dom/canvas/ImageBitmap.h
++++ b/dom/canvas/ImageBitmap.h
+@@ -34,20 +34,16 @@ class SourceSurface;
+ 
+ namespace layers {
+ class Image;
+ }
+ 
+ namespace dom {
+ class OffscreenCanvas;
+ 
+-namespace workers {
+-class WorkerStructuredCloneClosure;
+-}
+-
+ class ArrayBufferViewOrArrayBuffer;
+ class CanvasRenderingContext2D;
+ struct ChannelPixelLayout;
+ class CreateImageBitmapFromBlob;
+ class CreateImageBitmapFromBlobTask;
+ class CreateImageBitmapFromBlobWorkerTask;
+ class File;
+ class HTMLCanvasElement;
+diff --git a/dom/clients/api/Client.cpp b/dom/clients/api/Client.cpp
+--- a/dom/clients/api/Client.cpp
++++ b/dom/clients/api/Client.cpp
+@@ -14,17 +14,16 @@
+ #include "mozilla/dom/Promise.h"
+ #include "mozilla/dom/WorkerPrivate.h"
+ #include "mozilla/dom/WorkerScope.h"
+ #include "nsIGlobalObject.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+-using namespace workers;
+ using mozilla::dom::ipc::StructuredCloneData;
+ 
+ NS_IMPL_CYCLE_COLLECTING_ADDREF(mozilla::dom::Client);
+ NS_IMPL_CYCLE_COLLECTING_RELEASE(mozilla::dom::Client);
+ NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(mozilla::dom::Client, mGlobal);
+ 
+ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(mozilla::dom::Client)
+   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
+diff --git a/dom/clients/api/ClientDOMUtil.h b/dom/clients/api/ClientDOMUtil.h
+--- a/dom/clients/api/ClientDOMUtil.h
++++ b/dom/clients/api/ClientDOMUtil.h
+@@ -21,18 +21,18 @@ namespace dom {
+ // if the thread is shutting down.
+ template<typename Func, typename Arg, typename Resolve, typename Reject>
+ void
+ StartClientManagerOp(Func aFunc, const Arg& aArg, nsISerialEventTarget* aTarget,
+                      Resolve aResolve, Reject aReject)
+ {
+   RefPtr<WorkerHolderToken> token;
+   if (!NS_IsMainThread()) {
+-    token = WorkerHolderToken::Create(workers::GetCurrentThreadWorkerPrivate(),
+-                                      mozilla::dom::WorkerStatus::Closing);
++    token = WorkerHolderToken::Create(GetCurrentThreadWorkerPrivate(),
++                                      WorkerStatus::Closing);
+   }
+ 
+   RefPtr<ClientOpPromise> promise = aFunc(aArg, aTarget);
+   promise->Then(aTarget, __func__,
+     [aResolve, token](const ClientOpResult& aResult) {
+       if (token && token->IsShuttingDown()) {
+         return;
+       }
+diff --git a/dom/clients/api/Clients.cpp b/dom/clients/api/Clients.cpp
+--- a/dom/clients/api/Clients.cpp
++++ b/dom/clients/api/Clients.cpp
+@@ -16,17 +16,16 @@
+ #include "mozilla/dom/WorkerPrivate.h"
+ #include "mozilla/SystemGroup.h"
+ #include "nsIGlobalObject.h"
+ #include "nsString.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+-using namespace workers;
+ using mozilla::ipc::PrincipalInfo;
+ 
+ NS_IMPL_CYCLE_COLLECTING_ADDREF(Clients);
+ NS_IMPL_CYCLE_COLLECTING_RELEASE(Clients);
+ NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(Clients, mGlobal);
+ 
+ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(Clients)
+   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
+diff --git a/dom/clients/manager/ClientManager.cpp b/dom/clients/manager/ClientManager.cpp
+--- a/dom/clients/manager/ClientManager.cpp
++++ b/dom/clients/manager/ClientManager.cpp
+@@ -37,17 +37,17 @@ ClientManager::ClientManager()
+   PBackgroundChild* parentActor = BackgroundChild::GetOrCreateForCurrentThread();
+   if (NS_WARN_IF(!parentActor)) {
+     Shutdown();
+     return;
+   }
+ 
+   RefPtr<WorkerHolderToken> workerHolderToken;
+   if (!NS_IsMainThread()) {
+-    WorkerPrivate* workerPrivate = workers::GetCurrentThreadWorkerPrivate();
++    WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
+     MOZ_DIAGNOSTIC_ASSERT(workerPrivate);
+ 
+     workerHolderToken =
+       WorkerHolderToken::Create(workerPrivate, Closing,
+                                 WorkerHolderToken::AllowIdleShutdownStart);
+     if (NS_WARN_IF(!workerHolderToken)) {
+       Shutdown();
+       return;
+diff --git a/dom/console/Console.cpp b/dom/console/Console.cpp
+--- a/dom/console/Console.cpp
++++ b/dom/console/Console.cpp
+@@ -59,17 +59,16 @@
+ // This tags are used in the Structured Clone Algorithm to move js values from
+ // worker thread to main thread
+ #define CONSOLE_TAG_BLOB   JS_SCTAG_USER_MIN
+ 
+ // This value is taken from ConsoleAPIStorage.js
+ #define STORAGE_MAX_EVENTS 1000
+ 
+ using namespace mozilla::dom::exceptions;
+-using namespace mozilla::dom::workers;
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+ struct
+ ConsoleStructuredCloneData
+ {
+   nsCOMPtr<nsISupports> mParent;
+diff --git a/dom/crypto/WebCryptoTask.cpp b/dom/crypto/WebCryptoTask.cpp
+--- a/dom/crypto/WebCryptoTask.cpp
++++ b/dom/crypto/WebCryptoTask.cpp
+@@ -148,17 +148,17 @@ class WebCryptoTask::InternalWorkerHolde
+     // worker automatically.
+   }
+ 
+ public:
+   static already_AddRefed<InternalWorkerHolder>
+   Create()
+   {
+     MOZ_ASSERT(!NS_IsMainThread());
+-    WorkerPrivate* workerPrivate = workers::GetCurrentThreadWorkerPrivate();
++    WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
+     MOZ_ASSERT(workerPrivate);
+     RefPtr<InternalWorkerHolder> ref = new InternalWorkerHolder();
+     if (NS_WARN_IF(!ref->HoldWorker(workerPrivate, Canceling))) {
+       return nullptr;
+     }
+     return ref.forget();
+   }
+ 
+diff --git a/dom/events/Event.cpp b/dom/events/Event.cpp
+--- a/dom/events/Event.cpp
++++ b/dom/events/Event.cpp
+@@ -329,17 +329,17 @@ Event::SetTrusted(bool aTrusted)
+ {
+   mEvent->mFlags.mIsTrusted = aTrusted;
+ }
+ 
+ bool
+ Event::Init(mozilla::dom::EventTarget* aGlobal)
+ {
+   if (!mIsMainThreadEvent) {
+-    return workers::IsCurrentThreadRunningChromeWorker();
++    return IsCurrentThreadRunningChromeWorker();
+   }
+   bool trusted = false;
+   nsCOMPtr<nsPIDOMWindowInner> w = do_QueryInterface(aGlobal);
+   if (w) {
+     nsCOMPtr<nsIDocument> d = w->GetExtantDoc();
+     if (d) {
+       trusted = nsContentUtils::IsChromeDoc(d);
+       nsIPresShell* s = d->GetShell();
+@@ -1113,17 +1113,17 @@ Event::TimeStampImpl() const
+     Performance* perf = win->GetPerformance();
+     if (NS_WARN_IF(!perf)) {
+       return 0.0;
+     }
+ 
+     return perf->GetDOMTiming()->TimeStampToDOMHighRes(mEvent->mTimeStamp);
+   }
+ 
+-  WorkerPrivate* workerPrivate = workers::GetCurrentThreadWorkerPrivate();
++  WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
+   MOZ_ASSERT(workerPrivate);
+ 
+   return workerPrivate->TimeStampToDOMHighRes(mEvent->mTimeStamp);
+ }
+ 
+ double
+ Event::TimeStamp() const
+ {
+diff --git a/dom/events/EventDispatcher.cpp b/dom/events/EventDispatcher.cpp
+--- a/dom/events/EventDispatcher.cpp
++++ b/dom/events/EventDispatcher.cpp
+@@ -920,17 +920,17 @@ EventDispatcher::DispatchDOMEvent(nsISup
+       innerEvent->mOriginalTarget = nullptr;
+     } else {
+       aDOMEvent->GetIsTrusted(&dontResetTrusted);
+     }
+ 
+     if (!dontResetTrusted) {
+       //Check security state to determine if dispatcher is trusted
+       bool trusted = NS_IsMainThread() ? nsContentUtils::LegacyIsCallerChromeOrNativeCode()
+-                                       : mozilla::dom::workers::IsCurrentThreadRunningChromeWorker();
++                                       : IsCurrentThreadRunningChromeWorker();
+       aDOMEvent->SetTrusted(trusted);
+     }
+ 
+     return EventDispatcher::Dispatch(aTarget, aPresContext, innerEvent,
+                                      aDOMEvent, aEventStatus);
+   } else if (aEvent) {
+     return EventDispatcher::Dispatch(aTarget, aPresContext, aEvent,
+                                      aDOMEvent, aEventStatus);
+diff --git a/dom/events/JSEventHandler.cpp b/dom/events/JSEventHandler.cpp
+--- a/dom/events/JSEventHandler.cpp
++++ b/dom/events/JSEventHandler.cpp
+@@ -121,17 +121,17 @@ JSEventHandler::HandleEvent(nsIDOMEvent*
+ 
+   Event* event = aEvent->InternalDOMEvent();
+   bool isMainThread = event->IsMainThreadEvent();
+   bool isChromeHandler =
+     isMainThread ?
+       nsContentUtils::ObjectPrincipal(
+         GetTypedEventHandler().Ptr()->CallbackPreserveColor()) ==
+         nsContentUtils::GetSystemPrincipal() :
+-      mozilla::dom::workers::IsCurrentThreadRunningChromeWorker();
++      mozilla::dom::IsCurrentThreadRunningChromeWorker();
+ 
+   if (mTypedHandler.Type() == TypedEventHandler::eOnError) {
+     MOZ_ASSERT_IF(mEventName, mEventName == nsGkAtoms::onerror);
+ 
+     nsString errorMsg, file;
+     EventOrString msgOrEvent;
+     Optional<nsAString> fileName;
+     Optional<uint32_t> lineNumber;
+diff --git a/dom/fetch/Fetch.cpp b/dom/fetch/Fetch.cpp
+--- a/dom/fetch/Fetch.cpp
++++ b/dom/fetch/Fetch.cpp
+@@ -47,18 +47,16 @@
+ #include "mozilla/dom/WorkerCommon.h"
+ #include "mozilla/dom/WorkerPrivate.h"
+ #include "mozilla/dom/WorkerRunnable.h"
+ #include "mozilla/dom/WorkerScope.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+-using namespace workers;
+-
+ namespace {
+ 
+ void
+ AbortStream(JSContext* aCx, JS::Handle<JSObject*> aStream)
+ {
+   if (!JS::ReadableStreamIsReadable(aStream)) {
+     return;
+   }
+diff --git a/dom/fetch/FetchConsumer.cpp b/dom/fetch/FetchConsumer.cpp
+--- a/dom/fetch/FetchConsumer.cpp
++++ b/dom/fetch/FetchConsumer.cpp
+@@ -13,18 +13,16 @@
+ #include "mozilla/dom/WorkerScope.h"
+ #include "mozilla/ipc/PBackgroundSharedTypes.h"
+ #include "nsIInputStreamPump.h"
+ #include "nsProxyRelease.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+-using namespace workers;
+-
+ namespace {
+ 
+ template <class Derived>
+ class FetchBodyWorkerHolder final : public WorkerHolder
+ {
+   RefPtr<FetchBodyConsumer<Derived>> mConsumer;
+   bool mWasNotified;
+ 
+diff --git a/dom/fetch/FetchDriver.cpp b/dom/fetch/FetchDriver.cpp
+--- a/dom/fetch/FetchDriver.cpp
++++ b/dom/fetch/FetchDriver.cpp
+@@ -193,17 +193,17 @@ AlternativeDataStreamListener::GetCacheI
+   nsCOMPtr<nsICacheInfoChannel> channel = mCacheInfoChannel;
+   return channel.forget();
+ }
+ 
+ NS_IMETHODIMP
+ AlternativeDataStreamListener::OnStartRequest(nsIRequest* aRequest,
+                                               nsISupports* aContext)
+ {
+-  workers::AssertIsOnMainThread();
++  AssertIsOnMainThread();
+   MOZ_ASSERT(!mAlternativeDataType.IsEmpty());
+   // Checking the alternative data type is the same between we asked and the
+   // saved in the channel.
+   nsAutoCString alternativeDataType;
+   nsCOMPtr<nsICacheInfoChannel> cic = do_QueryInterface(aRequest);
+   mStatus = AlternativeDataStreamListener::LOADING;
+   if (cic &&
+       NS_SUCCEEDED(cic->GetAlternativeDataType(alternativeDataType)) &&
+@@ -269,17 +269,17 @@ AlternativeDataStreamListener::OnDataAva
+   return NS_OK;
+ }
+ 
+ NS_IMETHODIMP
+ AlternativeDataStreamListener::OnStopRequest(nsIRequest* aRequest,
+                                              nsISupports* aContext,
+                                              nsresult aStatusCode)
+ {
+-  workers::AssertIsOnMainThread();
++  AssertIsOnMainThread();
+ 
+   // Alternative data loading is going to finish, breaking the reference cycle
+   // here by taking the ownership to a loacl variable.
+   RefPtr<FetchDriver> fetchDriver = mFetchDriver.forget();
+ 
+   if (mStatus == AlternativeDataStreamListener::CANCELED) {
+     // do nothing
+     return NS_OK;
+@@ -358,17 +358,17 @@ FetchDriver::~FetchDriver()
+   // We assert this since even on failures, we should call
+   // FailWithNetworkError().
+   MOZ_ASSERT(mResponseAvailableCalled);
+ }
+ 
+ nsresult
+ FetchDriver::Fetch(AbortSignal* aSignal, FetchDriverObserver* aObserver)
+ {
+-  workers::AssertIsOnMainThread();
++  AssertIsOnMainThread();
+ #ifdef DEBUG
+   MOZ_ASSERT(!mFetchCalled);
+   mFetchCalled = true;
+ #endif
+ 
+   mObserver = aObserver;
+ 
+   // FIXME(nsm): Deal with HSTS.
+@@ -763,17 +763,17 @@ FetchDriver::BeginAndGetFilteredResponse
+   }
+ 
+   return filteredResponse.forget();
+ }
+ 
+ void
+ FetchDriver::FailWithNetworkError(nsresult rv)
+ {
+-  workers::AssertIsOnMainThread();
++  AssertIsOnMainThread();
+   RefPtr<InternalResponse> error = InternalResponse::NetworkError(rv);
+   if (mObserver) {
+     mObserver->OnResponseAvailable(error);
+ #ifdef DEBUG
+     mResponseAvailableCalled = true;
+ #endif
+     mObserver->OnResponseEnd(FetchDriverObserver::eByNetworking);
+     mObserver = nullptr;
+@@ -781,17 +781,17 @@ FetchDriver::FailWithNetworkError(nsresu
+ 
+   mChannel = nullptr;
+ }
+ 
+ NS_IMETHODIMP
+ FetchDriver::OnStartRequest(nsIRequest* aRequest,
+                             nsISupports* aContext)
+ {
+-  workers::AssertIsOnMainThread();
++  AssertIsOnMainThread();
+ 
+   // Note, this can be called multiple times if we are doing an opaqueredirect.
+   // In that case we will get a simulated OnStartRequest() and then the real
+   // channel will call in with an errored OnStartRequest().
+ 
+   if (!mChannel) {
+     MOZ_ASSERT(!mObserver);
+     return NS_BINDING_ABORTED;
+@@ -1150,17 +1150,17 @@ FetchDriver::OnDataAvailable(nsIRequest*
+   return rv;
+ }
+ 
+ NS_IMETHODIMP
+ FetchDriver::OnStopRequest(nsIRequest* aRequest,
+                            nsISupports* aContext,
+                            nsresult aStatusCode)
+ {
+-  workers::AssertIsOnMainThread();
++  AssertIsOnMainThread();
+ 
+   MOZ_DIAGNOSTIC_ASSERT(!mOnStopRequestCalled);
+   mOnStopRequestCalled = true;
+ 
+   // main data loading is going to finish, breaking the reference cycle.
+   RefPtr<AlternativeDataStreamListener> altDataListener = mAltDataListener.forget();
+ 
+   // We need to check mObserver, which is nulled by FailWithNetworkError(),
+@@ -1216,17 +1216,17 @@ FetchDriver::OnStopRequest(nsIRequest* a
+   }
+ 
+   return FinishOnStopRequest(altDataListener);
+ }
+ 
+ nsresult
+ FetchDriver::FinishOnStopRequest(AlternativeDataStreamListener* aAltDataListener)
+ {
+-  workers::AssertIsOnMainThread();
++  AssertIsOnMainThread();
+   // OnStopRequest is not called from channel, that means the main data loading
+   // does not finish yet. Reaching here since alternative data loading finishes.
+   if (!mOnStopRequestCalled) {
+     return NS_OK;
+   }
+ 
+   MOZ_DIAGNOSTIC_ASSERT(!mAltDataListener);
+   // Wait for alternative data loading finish if we needed it.
+diff --git a/dom/fetch/FetchStream.cpp b/dom/fetch/FetchStream.cpp
+--- a/dom/fetch/FetchStream.cpp
++++ b/dom/fetch/FetchStream.cpp
+@@ -15,18 +15,16 @@
+ #define FETCH_STREAM_FLAG 0
+ 
+ static NS_DEFINE_CID(kStreamTransportServiceCID,
+                      NS_STREAMTRANSPORTSERVICE_CID);
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+-using namespace workers;
+-
+ namespace {
+ 
+ class FetchStreamWorkerHolder final : public WorkerHolder
+ {
+ public:
+   explicit FetchStreamWorkerHolder(FetchStream* aStream)
+     : WorkerHolder("FetchStreamWorkerHolder",
+                    WorkerHolder::Behavior::AllowIdleShutdownStart)
+diff --git a/dom/fetch/FetchStreamReader.cpp b/dom/fetch/FetchStreamReader.cpp
+--- a/dom/fetch/FetchStreamReader.cpp
++++ b/dom/fetch/FetchStreamReader.cpp
+@@ -11,18 +11,16 @@
+ #include "mozilla/TaskCategory.h"
+ #include "nsContentUtils.h"
+ #include "nsIScriptError.h"
+ #include "nsPIDOMWindow.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+-using namespace workers;
+-
+ namespace {
+ 
+ class FetchStreamReaderWorkerHolder final : public WorkerHolder
+ {
+ public:
+   explicit FetchStreamReaderWorkerHolder(FetchStreamReader* aReader)
+     : WorkerHolder("FetchStreamReaderWorkerHolder",
+                    WorkerHolder::Behavior::AllowIdleShutdownStart)
+diff --git a/dom/file/FileBlobImpl.cpp b/dom/file/FileBlobImpl.cpp
+--- a/dom/file/FileBlobImpl.cpp
++++ b/dom/file/FileBlobImpl.cpp
+@@ -164,17 +164,17 @@ FileBlobImpl::GetType(nsAString& aType)
+ {
+   aType.Truncate();
+ 
+   if (mContentType.IsVoid()) {
+     MOZ_ASSERT(mWholeFile,
+                "Should only use lazy ContentType when using the whole file");
+ 
+     if (!NS_IsMainThread()) {
+-      WorkerPrivate* workerPrivate = workers::GetCurrentThreadWorkerPrivate();
++      WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
+       if (!workerPrivate) {
+         // I have no idea in which thread this method is called. We cannot
+         // return any valid value.
+         return;
+       }
+ 
+       RefPtr<GetTypeRunnable> runnable =
+         new GetTypeRunnable(workerPrivate, this);
+diff --git a/dom/file/FileReader.cpp b/dom/file/FileReader.cpp
+--- a/dom/file/FileReader.cpp
++++ b/dom/file/FileReader.cpp
+@@ -134,17 +134,17 @@ FileReader::~FileReader()
+ /* static */ already_AddRefed<FileReader>
+ FileReader::Constructor(const GlobalObject& aGlobal, ErrorResult& aRv)
+ {
+   nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(aGlobal.GetAsSupports());
+   WorkerPrivate* workerPrivate = nullptr;
+ 
+   if (!NS_IsMainThread()) {
+     JSContext* cx = aGlobal.Context();
+-    workerPrivate = workers::GetWorkerPrivateFromContext(cx);
++    workerPrivate = GetWorkerPrivateFromContext(cx);
+     MOZ_ASSERT(workerPrivate);
+   }
+ 
+   RefPtr<FileReader> fileReader = new FileReader(global, workerPrivate);
+ 
+   return fileReader.forget();
+ }
+ 
+diff --git a/dom/file/FileReaderSync.cpp b/dom/file/FileReaderSync.cpp
+--- a/dom/file/FileReaderSync.cpp
++++ b/dom/file/FileReaderSync.cpp
+@@ -436,17 +436,17 @@ FileReaderSync::SyncRead(nsIInputStream*
+   }
+ 
+   // We need to proceed async.
+   nsCOMPtr<nsIAsyncInputStream> asyncStream = do_QueryInterface(aStream);
+   if (!asyncStream) {
+     return rv;
+   }
+ 
+-  WorkerPrivate* workerPrivate = workers::GetCurrentThreadWorkerPrivate();
++  WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
+   MOZ_ASSERT(workerPrivate);
+ 
+   AutoSyncLoopHolder syncLoop(workerPrivate, Closing);
+ 
+   nsCOMPtr<nsIEventTarget> syncLoopTarget = syncLoop.GetEventTarget();
+   if (!syncLoopTarget) {
+     // SyncLoop creation can fail if the worker is shutting down.
+     return NS_ERROR_DOM_INVALID_STATE_ERR;
+diff --git a/dom/file/ipc/IPCBlobInputStreamChild.cpp b/dom/file/ipc/IPCBlobInputStreamChild.cpp
+--- a/dom/file/ipc/IPCBlobInputStreamChild.cpp
++++ b/dom/file/ipc/IPCBlobInputStreamChild.cpp
+@@ -10,18 +10,16 @@
+ #include "mozilla/ipc/IPCStreamUtils.h"
+ #include "mozilla/dom/WorkerHolder.h"
+ #include "mozilla/dom/WorkerPrivate.h"
+ #include "mozilla/dom/WorkerRunnable.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+-using namespace workers;
+-
+ namespace {
+ 
+ // This runnable is used in case the last stream is forgotten on the 'wrong'
+ // thread.
+ class ShutdownRunnable final : public CancelableRunnable
+ {
+ public:
+   explicit ShutdownRunnable(IPCBlobInputStreamChild* aActor)
+diff --git a/dom/indexedDB/ActorsChild.cpp b/dom/indexedDB/ActorsChild.cpp
+--- a/dom/indexedDB/ActorsChild.cpp
++++ b/dom/indexedDB/ActorsChild.cpp
+@@ -67,18 +67,16 @@
+ #endif // DEBUG || GC_ON_IPC_MESSAGES
+ 
+ namespace mozilla {
+ 
+ using ipc::PrincipalInfo;
+ 
+ namespace dom {
+ 
+-using namespace workers;
+-
+ namespace indexedDB {
+ 
+ /*******************************************************************************
+  * ThreadLocal
+  ******************************************************************************/
+ 
+ ThreadLocal::ThreadLocal(const nsID& aBackgroundChildLoggingId)
+   : mLoggingInfo(aBackgroundChildLoggingId, 1, -1, 1)
+diff --git a/dom/indexedDB/IDBObjectStore.cpp b/dom/indexedDB/IDBObjectStore.cpp
+--- a/dom/indexedDB/IDBObjectStore.cpp
++++ b/dom/indexedDB/IDBObjectStore.cpp
+@@ -58,17 +58,16 @@
+ // Include this last to avoid path problems on Windows.
+ #include "ActorsChild.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+ using namespace mozilla::dom::indexedDB;
+ using namespace mozilla::dom::quota;
+-using namespace mozilla::dom::workers;
+ using namespace mozilla::ipc;
+ 
+ struct IDBObjectStore::StructuredCloneWriteInfo
+ {
+   JSAutoStructuredCloneBuffer mCloneBuffer;
+   nsTArray<StructuredCloneFile> mFiles;
+   IDBDatabase* mDatabase;
+   uint64_t mOffsetToKeyProp;
+diff --git a/dom/indexedDB/IDBRequest.cpp b/dom/indexedDB/IDBRequest.cpp
+--- a/dom/indexedDB/IDBRequest.cpp
++++ b/dom/indexedDB/IDBRequest.cpp
+@@ -35,17 +35,16 @@
+ 
+ // Include this last to avoid path problems on Windows.
+ #include "ActorsChild.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+ using namespace mozilla::dom::indexedDB;
+-using namespace mozilla::dom::workers;
+ using namespace mozilla::ipc;
+ 
+ namespace {
+ 
+ NS_DEFINE_IID(kIDBRequestIID, PRIVATE_IDBREQUEST_IID);
+ 
+ } // namespace
+ 
+diff --git a/dom/indexedDB/IDBTransaction.cpp b/dom/indexedDB/IDBTransaction.cpp
+--- a/dom/indexedDB/IDBTransaction.cpp
++++ b/dom/indexedDB/IDBTransaction.cpp
+@@ -28,17 +28,16 @@
+ 
+ // Include this last to avoid path problems on Windows.
+ #include "ActorsChild.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+ using namespace mozilla::dom::indexedDB;
+-using namespace mozilla::dom::workers;
+ using namespace mozilla::ipc;
+ 
+ class IDBTransaction::WorkerHolder final : public mozilla::dom::WorkerHolder
+ {
+   WorkerPrivate* mWorkerPrivate;
+ 
+   // The IDBTransaction owns this object so we only need a weak reference back
+   // to it.
+diff --git a/dom/indexedDB/IndexedDatabaseManager.cpp b/dom/indexedDB/IndexedDatabaseManager.cpp
+--- a/dom/indexedDB/IndexedDatabaseManager.cpp
++++ b/dom/indexedDB/IndexedDatabaseManager.cpp
+@@ -61,17 +61,16 @@
+ 
+ #define IDB_STR "indexedDB"
+ 
+ namespace mozilla {
+ namespace dom {
+ namespace indexedDB {
+ 
+ using namespace mozilla::dom::quota;
+-using namespace mozilla::dom::workers;
+ using namespace mozilla::ipc;
+ 
+ class FileManagerInfo
+ {
+ public:
+   already_AddRefed<FileManager>
+   GetFileManager(PersistenceType aPersistenceType,
+                  const nsAString& aName) const;
+diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp
+--- a/dom/ipc/ContentChild.cpp
++++ b/dom/ipc/ContentChild.cpp
+@@ -223,17 +223,16 @@
+ 
+ #ifdef MOZ_CODE_COVERAGE
+ #include "mozilla/CodeCoverageHandler.h"
+ #endif
+ 
+ using namespace mozilla;
+ using namespace mozilla::docshell;
+ using namespace mozilla::dom::ipc;
+-using namespace mozilla::dom::workers;
+ using namespace mozilla::media;
+ using namespace mozilla::embedding;
+ using namespace mozilla::gmp;
+ using namespace mozilla::hal_sandbox;
+ using namespace mozilla::ipc;
+ using namespace mozilla::intl;
+ using namespace mozilla::layers;
+ using namespace mozilla::layout;
+diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp
+--- a/dom/ipc/TabChild.cpp
++++ b/dom/ipc/TabChild.cpp
+@@ -134,17 +134,16 @@
+     NS_LITERAL_STRING("chrome://global/content/BrowserElementChild.js")
+ 
+ #define TABC_LOG(...)
+ // #define TABC_LOG(...) printf_stderr("TABC: " __VA_ARGS__)
+ 
+ using namespace mozilla;
+ using namespace mozilla::dom;
+ using namespace mozilla::dom::ipc;
+-using namespace mozilla::dom::workers;
+ using namespace mozilla::ipc;
+ using namespace mozilla::layers;
+ using namespace mozilla::layout;
+ using namespace mozilla::docshell;
+ using namespace mozilla::widget;
+ using namespace mozilla::jsipc;
+ using mozilla::layers::GeckoContentController;
+ 
+diff --git a/dom/messagechannel/MessagePort.cpp b/dom/messagechannel/MessagePort.cpp
+--- a/dom/messagechannel/MessagePort.cpp
++++ b/dom/messagechannel/MessagePort.cpp
+@@ -37,18 +37,16 @@
+ #include "nsIPresShell.h"
+ #include "nsISupportsPrimitives.h"
+ #include "nsServiceManagerUtils.h"
+ 
+ #ifdef XP_WIN
+ #undef PostMessage
+ #endif
+ 
+-using namespace mozilla::dom::workers;
+-
+ namespace mozilla {
+ namespace dom {
+ 
+ class PostMessageRunnable final : public CancelableRunnable
+ {
+   friend class MessagePort;
+ 
+ public:
+diff --git a/dom/notification/Notification.cpp b/dom/notification/Notification.cpp
+--- a/dom/notification/Notification.cpp
++++ b/dom/notification/Notification.cpp
+@@ -54,18 +54,16 @@
+ #include "nsStructuredCloneContainer.h"
+ #include "nsThreadUtils.h"
+ #include "nsToolkitCompsCID.h"
+ #include "nsXULAppAPI.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+-using namespace workers;
+-
+ struct NotificationStrings
+ {
+   const nsString mID;
+   const nsString mTitle;
+   const nsString mDir;
+   const nsString mLang;
+   const nsString mBody;
+   const nsString mTag;
+diff --git a/dom/notification/Notification.h b/dom/notification/Notification.h
+--- a/dom/notification/Notification.h
++++ b/dom/notification/Notification.h
+@@ -336,17 +336,17 @@ protected:
+     }
+     return NotificationDirection::Auto;
+   }
+ 
+   static nsresult GetOrigin(nsIPrincipal* aPrincipal, nsString& aOrigin);
+ 
+   void GetAlertName(nsAString& aRetval)
+   {
+-    workers::AssertIsOnMainThread();
++    AssertIsOnMainThread();
+     if (mAlertName.IsEmpty()) {
+       SetAlertName();
+     }
+     aRetval = mAlertName;
+   }
+ 
+   void GetScope(nsAString& aScope)
+   {
+diff --git a/dom/performance/Performance.cpp b/dom/performance/Performance.cpp
+--- a/dom/performance/Performance.cpp
++++ b/dom/performance/Performance.cpp
+@@ -536,17 +536,17 @@ Performance::QueueEntry(PerformanceEntry
+ 
+ /* static */ bool
+ Performance::IsObserverEnabled(JSContext* aCx, JSObject* aGlobal)
+ {
+   if (NS_IsMainThread()) {
+     return Preferences::GetBool("dom.enable_performance_observer", false);
+   }
+ 
+-  WorkerPrivate* workerPrivate = workers::GetCurrentThreadWorkerPrivate();
++  WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
+   MOZ_ASSERT(workerPrivate);
+   workerPrivate->AssertIsOnWorkerThread();
+ 
+   RefPtr<PrefEnabledRunnable> runnable =
+     new PrefEnabledRunnable(workerPrivate,
+                             NS_LITERAL_CSTRING("dom.enable_performance_observer"));
+ 
+   return runnable->Dispatch() && runnable->IsEnabled();
+diff --git a/dom/performance/PerformanceObserver.cpp b/dom/performance/PerformanceObserver.cpp
+--- a/dom/performance/PerformanceObserver.cpp
++++ b/dom/performance/PerformanceObserver.cpp
+@@ -84,17 +84,17 @@ PerformanceObserver::Constructor(const G
+     MOZ_ASSERT(ownerWindow->IsInnerWindow());
+ 
+     RefPtr<PerformanceObserver> observer =
+       new PerformanceObserver(ownerWindow, aCb);
+     return observer.forget();
+   }
+ 
+   JSContext* cx = aGlobal.Context();
+-  WorkerPrivate* workerPrivate = workers::GetWorkerPrivateFromContext(cx);
++  WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(cx);
+   MOZ_ASSERT(workerPrivate);
+ 
+   RefPtr<PerformanceObserver> observer =
+     new PerformanceObserver(workerPrivate, aCb);
+   return observer.forget();
+ }
+ 
+ JSObject*
+diff --git a/dom/promise/Promise.cpp b/dom/promise/Promise.cpp
+--- a/dom/promise/Promise.cpp
++++ b/dom/promise/Promise.cpp
+@@ -492,17 +492,17 @@ Promise::ReportRejectedPromise(JSContext
+   if (!report.init(aCx, result, js::ErrorReport::NoSideEffects)) {
+     JS_ClearPendingException(aCx);
+     return;
+   }
+ 
+   RefPtr<xpc::ErrorReport> xpcReport = new xpc::ErrorReport();
+   bool isMainThread = MOZ_LIKELY(NS_IsMainThread());
+   bool isChrome = isMainThread ? nsContentUtils::IsSystemPrincipal(nsContentUtils::ObjectPrincipal(aPromise))
+-                               : workers::GetCurrentThreadWorkerPrivate()->IsChromeWorker();
++                               : GetCurrentThreadWorkerPrivate()->IsChromeWorker();
+   nsGlobalWindow* win = isMainThread ? xpc::WindowGlobalOrNull(aPromise) : nullptr;
+   xpcReport->Init(report.report(), report.toStringResult().c_str(), isChrome,
+                   win ? win->AsInner()->WindowID() : 0);
+ 
+   // Now post an event to do the real reporting async
+   NS_DispatchToMainThread(new AsyncErrorReporter(xpcReport));
+ }
+ 
+@@ -758,17 +758,17 @@ PromiseWorkerProxy::~PromiseWorkerProxy(
+   MOZ_ASSERT(!mWorkerPromise);
+   MOZ_ASSERT(!mWorkerPrivate);
+ }
+ 
+ void
+ PromiseWorkerProxy::CleanProperties()
+ {
+ #ifdef DEBUG
+-  WorkerPrivate* worker = workers::GetCurrentThreadWorkerPrivate();
++  WorkerPrivate* worker = GetCurrentThreadWorkerPrivate();
+   MOZ_ASSERT(worker);
+   worker->AssertIsOnWorkerThread();
+ #endif
+   // Ok to do this unprotected from Create().
+   // CleanUp() holds the lock before calling this.
+   mCleanedUp = true;
+   mWorkerPromise = nullptr;
+   mWorkerPrivate = nullptr;
+@@ -811,17 +811,17 @@ PromiseWorkerProxy::GetWorkerPrivate() c
+ 
+   return mWorkerPrivate;
+ }
+ 
+ Promise*
+ PromiseWorkerProxy::WorkerPromise() const
+ {
+ #ifdef DEBUG
+-  WorkerPrivate* worker = workers::GetCurrentThreadWorkerPrivate();
++  WorkerPrivate* worker = GetCurrentThreadWorkerPrivate();
+   MOZ_ASSERT(worker);
+   worker->AssertIsOnWorkerThread();
+ #endif
+   MOZ_ASSERT(mWorkerPromise);
+   return mWorkerPromise;
+ }
+ 
+ void
+diff --git a/dom/push/PushManager.cpp b/dom/push/PushManager.cpp
+--- a/dom/push/PushManager.cpp
++++ b/dom/push/PushManager.cpp
+@@ -27,19 +27,16 @@
+ #include "nsIPushService.h"
+ 
+ #include "nsComponentManagerUtils.h"
+ #include "nsContentUtils.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+-using namespace workers;
+-using workers::AssertIsOnMainThread;
+-
+ namespace {
+ 
+ nsresult
+ GetPermissionState(nsIPrincipal* aPrincipal,
+                    PushPermissionState& aState)
+ {
+   nsCOMPtr<nsIPermissionManager> permManager =
+     mozilla::services::GetPermissionManager();
+diff --git a/dom/push/PushNotifier.cpp b/dom/push/PushNotifier.cpp
+--- a/dom/push/PushNotifier.cpp
++++ b/dom/push/PushNotifier.cpp
+@@ -19,18 +19,16 @@
+ 
+ #include "mozilla/dom/BodyUtil.h"
+ #include "mozilla/dom/ContentChild.h"
+ #include "mozilla/dom/ContentParent.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+-using workers::AssertIsOnMainThread;
+-
+ PushNotifier::PushNotifier()
+ {}
+ 
+ PushNotifier::~PushNotifier()
+ {}
+ 
+ NS_IMPL_CYCLE_COLLECTION_0(PushNotifier)
+ 
+diff --git a/dom/push/PushSubscription.cpp b/dom/push/PushSubscription.cpp
+--- a/dom/push/PushSubscription.cpp
++++ b/dom/push/PushSubscription.cpp
+@@ -18,18 +18,16 @@
+ #include "mozilla/dom/PushUtil.h"
+ #include "mozilla/dom/WorkerCommon.h"
+ #include "mozilla/dom/WorkerPrivate.h"
+ #include "mozilla/dom/WorkerScope.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+-using namespace workers;
+-
+ namespace {
+ 
+ class UnsubscribeResultCallback final : public nsIUnsubscribeResultCallback
+ {
+ public:
+   NS_DECL_ISUPPORTS
+ 
+   explicit UnsubscribeResultCallback(Promise* aPromise)
+diff --git a/dom/quota/StorageManager.cpp b/dom/quota/StorageManager.cpp
+--- a/dom/quota/StorageManager.cpp
++++ b/dom/quota/StorageManager.cpp
+@@ -13,18 +13,16 @@
+ #include "mozilla/dom/WorkerPrivate.h"
+ #include "mozilla/ErrorResult.h"
+ #include "mozilla/Telemetry.h"
+ #include "nsContentPermissionHelper.h"
+ #include "nsIQuotaCallbacks.h"
+ #include "nsIQuotaRequests.h"
+ #include "nsPIDOMWindow.h"
+ 
+-using namespace mozilla::dom::workers;
+-
+ namespace mozilla {
+ namespace dom {
+ 
+ namespace {
+ 
+ // This class is used to get quota usage, request persist and check persisted
+ // status callbacks.
+ class RequestResolver final
+diff --git a/dom/script/ScriptSettings.cpp b/dom/script/ScriptSettings.cpp
+--- a/dom/script/ScriptSettings.cpp
++++ b/dom/script/ScriptSettings.cpp
+@@ -539,17 +539,17 @@ WarningOnlyErrorReporter(JSContext* aCx,
+   if (!NS_IsMainThread()) {
+     // Reporting a warning on workers is a bit complicated because we have to
+     // climb our parent chain until we get to the main thread.  So go ahead and
+     // just go through the worker ReportError codepath here.
+     //
+     // That said, it feels like we should be able to short-circuit things a bit
+     // here by posting an appropriate runnable to the main thread directly...
+     // Worth looking into sometime.
+-    WorkerPrivate* worker = workers::GetWorkerPrivateFromContext(aCx);
++    WorkerPrivate* worker = GetWorkerPrivateFromContext(aCx);
+     MOZ_ASSERT(worker);
+ 
+     worker->ReportError(aCx, JS::ConstUTF8CharsZ(), aRep);
+     return;
+   }
+ 
+   RefPtr<xpc::ErrorReport> xpcReport = new xpc::ErrorReport();
+   nsGlobalWindow* win = xpc::CurrentWindowOrNull(aCx);
+@@ -576,17 +576,17 @@ AutoJSAPI::ReportException()
+   // requires us to be in a compartment when we fetch the pending exception.
+   // In this case, we enter the privileged junk scope and don't dispatch any
+   // error events.
+   JS::Rooted<JSObject*> errorGlobal(cx(), JS::CurrentGlobalOrNull(cx()));
+   if (!errorGlobal) {
+     if (mIsMainThread) {
+       errorGlobal = xpc::PrivilegedJunkScope();
+     } else {
+-      errorGlobal = workers::GetCurrentThreadWorkerGlobal();
++      errorGlobal = GetCurrentThreadWorkerGlobal();
+     }
+   }
+   JSAutoCompartment ac(cx(), errorGlobal);
+   JS::Rooted<JS::Value> exn(cx());
+   js::ErrorReport jsReport(cx());
+   if (StealException(&exn) &&
+       jsReport.init(cx(), exn, js::ErrorReport::WithSideEffects)) {
+     if (mIsMainThread) {
+@@ -612,17 +612,17 @@ AutoJSAPI::ReportException()
+           xpc::FindExceptionStackForConsoleReport(inner, exn));
+         xpcReport->LogToConsoleWithStack(stack);
+       }
+     } else {
+       // On a worker, we just use the worker error reporting mechanism and don't
+       // bother with xpc::ErrorReport.  This will ensure that all the right
+       // events (which are a lot more complicated than in the window case) get
+       // fired.
+-      WorkerPrivate* worker = workers::GetCurrentThreadWorkerPrivate();
++      WorkerPrivate* worker = GetCurrentThreadWorkerPrivate();
+       MOZ_ASSERT(worker);
+       MOZ_ASSERT(worker->GetJSContext() == cx());
+       // Before invoking ReportError, put the exception back on the context,
+       // because it may want to put it in its error events and has no other way
+       // to get hold of it.  After we invoke ReportError, clear the exception on
+       // cx(), just in case ReportError didn't.
+       JS_SetPendingException(cx(), exn);
+       worker->ReportError(cx(), jsReport.toStringResult(), jsReport.report());
+diff --git a/dom/serviceworkers/ServiceWorkerEvents.cpp b/dom/serviceworkers/ServiceWorkerEvents.cpp
+--- a/dom/serviceworkers/ServiceWorkerEvents.cpp
++++ b/dom/serviceworkers/ServiceWorkerEvents.cpp
+@@ -46,17 +46,16 @@
+ #include "mozilla/dom/WorkerPrivate.h"
+ 
+ #include "js/Conversions.h"
+ #include "js/TypeDecls.h"
+ #include "xpcpublic.h"
+ 
+ using namespace mozilla;
+ using namespace mozilla::dom;
+-using namespace mozilla::dom::workers;
+ 
+ namespace {
+ 
+ void
+ AsyncLog(nsIInterceptedChannel *aInterceptedChannel,
+          const nsACString& aRespondWithScriptSpec,
+          uint32_t aRespondWithLineNumber, uint32_t aRespondWithColumnNumber,
+          const nsACString& aMessageName, const nsTArray<nsString>& aParams)
+diff --git a/dom/serviceworkers/ServiceWorkerRegistration.cpp b/dom/serviceworkers/ServiceWorkerRegistration.cpp
+--- a/dom/serviceworkers/ServiceWorkerRegistration.cpp
++++ b/dom/serviceworkers/ServiceWorkerRegistration.cpp
+@@ -27,18 +27,16 @@
+ #include "ServiceWorkerManager.h"
+ 
+ #include "nsIDocument.h"
+ #include "nsIServiceWorkerManager.h"
+ #include "nsISupportsPrimitives.h"
+ #include "nsPIDOMWindow.h"
+ #include "nsContentUtils.h"
+ 
+-using namespace mozilla::dom::workers;
+-
+ namespace mozilla {
+ namespace dom {
+ 
+ ////////////////////////////////////////////////////
+ // Main Thread implementation
+ 
+ class ServiceWorkerRegistrationMainThread final : public ServiceWorkerRegistration,
+                                                   public ServiceWorkerRegistrationListener
+diff --git a/dom/url/URLWorker.cpp b/dom/url/URLWorker.cpp
+--- a/dom/url/URLWorker.cpp
++++ b/dom/url/URLWorker.cpp
+@@ -15,19 +15,16 @@
+ #include "nsURLHelper.h"
+ 
+ namespace mozilla {
+ 
+ using net::nsStandardURL;
+ 
+ namespace dom {
+ 
+-using namespace workers;
+-using workers::AssertIsOnMainThread;
+-
+ // Proxy class to forward all the requests to a URLMainThread object.
+ class URLWorker::URLProxy final
+ {
+ public:
+   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(URLProxy)
+ 
+   explicit URLProxy(already_AddRefed<URLMainThread> aURL)
+     : mURL(aURL)
+diff --git a/dom/websocket/WebSocket.cpp b/dom/websocket/WebSocket.cpp
+--- a/dom/websocket/WebSocket.cpp
++++ b/dom/websocket/WebSocket.cpp
+@@ -63,17 +63,16 @@
+ #include "nsWeakReference.h"
+ 
+ #define OPEN_EVENT_STRING NS_LITERAL_STRING("open")
+ #define MESSAGE_EVENT_STRING NS_LITERAL_STRING("message")
+ #define ERROR_EVENT_STRING NS_LITERAL_STRING("error")
+ #define CLOSE_EVENT_STRING NS_LITERAL_STRING("close")
+ 
+ using namespace mozilla::net;
+-using namespace mozilla::dom::workers;
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+ class WebSocketImpl final : public nsIInterfaceRequestor
+                           , public nsIWebSocketListener
+                           , public nsIObserver
+                           , public nsSupportsWeakReference
+diff --git a/dom/workers/MessageEventRunnable.cpp b/dom/workers/MessageEventRunnable.cpp
+--- a/dom/workers/MessageEventRunnable.cpp
++++ b/dom/workers/MessageEventRunnable.cpp
+@@ -125,17 +125,17 @@ MessageEventRunnable::WorkerRun(JSContex
+     }
+ 
+     aWorkerPrivate->AssertInnerWindowIsCorrect();
+ 
+     return DispatchDOMEvent(aCx, aWorkerPrivate, aWorkerPrivate,
+                             !aWorkerPrivate->GetParent());
+   }
+ 
+-  MOZ_ASSERT(aWorkerPrivate == workers::GetWorkerPrivateFromContext(aCx));
++  MOZ_ASSERT(aWorkerPrivate == GetWorkerPrivateFromContext(aCx));
+ 
+   return DispatchDOMEvent(aCx, aWorkerPrivate, aWorkerPrivate->GlobalScope(),
+                           false);
+ }
+ 
+ void
+ MessageEventRunnable::DispatchError(JSContext* aCx,
+                                     DOMEventTargetHelper* aTarget)
+diff --git a/dom/workers/RuntimeService.cpp b/dom/workers/RuntimeService.cpp
+--- a/dom/workers/RuntimeService.cpp
++++ b/dom/workers/RuntimeService.cpp
+@@ -79,17 +79,16 @@
+ #define WORKERS_SHUTDOWN_TOPIC "web-workers-shutdown"
+ 
+ namespace mozilla {
+ 
+ using namespace ipc;
+ 
+ namespace dom {
+ 
+-using namespace workers;
+ using namespace workerinternals;
+ 
+ namespace workerinternals {
+ 
+ // The size of the worker runtime heaps in bytes. May be changed via pref.
+ #define WORKER_DEFAULT_RUNTIME_HEAPSIZE 32 * 1024 * 1024
+ 
+ // The size of the generational GC nursery for workers, in bytes.
+@@ -130,17 +129,17 @@ static_assert(MAX_WORKERS_PER_DOMAIN >= 
+ #define GC_REQUEST_OBSERVER_TOPIC "child-gc-request"
+ #define CC_REQUEST_OBSERVER_TOPIC "child-cc-request"
+ #define MEMORY_PRESSURE_OBSERVER_TOPIC "memory-pressure"
+ 
+ #define BROADCAST_ALL_WORKERS(_func, ...)                                      \
+   PR_BEGIN_MACRO                                                               \
+     AssertIsOnMainThread();                                                    \
+                                                                                \
+-    AutoTArray<WorkerPrivate*, 100> workers;                                 \
++    AutoTArray<WorkerPrivate*, 100> workers;                                   \
+     {                                                                          \
+       MutexAutoLock lock(mMutex);                                              \
+                                                                                \
+       AddAllTopLevelWorkersToArray(workers);                                   \
+     }                                                                          \
+                                                                                \
+     if (!workers.IsEmpty()) {                                                  \
+       for (uint32_t index = 0; index < workers.Length(); index++) {            \
+@@ -930,24 +929,26 @@ PreserveWrapper(JSContext *cx, JSObject 
+ 
+     return mozilla::dom::TryPreserveWrapper(obj);
+ }
+ 
+ JSObject*
+ Wrap(JSContext *cx, JS::HandleObject existing, JS::HandleObject obj)
+ {
+   JSObject* targetGlobal = JS::CurrentGlobalOrNull(cx);
+-  if (!IsDebuggerGlobal(targetGlobal) && !IsDebuggerSandbox(targetGlobal)) {
++  if (!IsWorkerDebuggerGlobal(targetGlobal) &&
++      !IsWorkerDebuggerSandbox(targetGlobal)) {
+     MOZ_CRASH("There should be no edges from the debuggee to the debugger.");
+   }
+ 
+   JSObject* originGlobal = js::GetGlobalForObjectCrossCompartment(obj);
+ 
+   const js::Wrapper* wrapper = nullptr;
+-  if (IsDebuggerGlobal(originGlobal) || IsDebuggerSandbox(originGlobal)) {
++  if (IsWorkerDebuggerGlobal(originGlobal) ||
++      IsWorkerDebuggerSandbox(originGlobal)) {
+     wrapper = &js::CrossCompartmentWrapper::singleton;
+   } else {
+     wrapper = &js::OpaqueCrossCompartmentWrapper::singleton;
+   }
+ 
+   if (existing) {
+     js::Wrapper::Renew(existing, obj, wrapper);
+   }
+@@ -1116,30 +1117,31 @@ public:
+   {
+     RefPtr<nsIRunnable> runnable(aRunnable);
+ 
+     MOZ_ASSERT(!NS_IsMainThread());
+     MOZ_ASSERT(runnable);
+ 
+     std::queue<nsCOMPtr<nsIRunnable>>* microTaskQueue = nullptr;
+ 
+-    JSContext* cx = GetCurrentThreadJSContext();
++    JSContext* cx = GetCurrentWorkerThreadJSContext();
+     NS_ASSERTION(cx, "This should never be null!");
+ 
+     JS::Rooted<JSObject*> global(cx, JS::CurrentGlobalOrNull(cx));
+     NS_ASSERTION(global, "This should never be null!");
+ 
+     // On worker threads, if the current global is the worker global, we use the
+     // main promise micro task queue. Otherwise, the current global must be
+     // either the debugger global or a debugger sandbox, and we use the debugger
+     // promise micro task queue instead.
+     if (IsWorkerGlobal(global)) {
+       microTaskQueue = &mPromiseMicroTaskQueue;
+     } else {
+-      MOZ_ASSERT(IsDebuggerGlobal(global) || IsDebuggerSandbox(global));
++      MOZ_ASSERT(IsWorkerDebuggerGlobal(global) ||
++                 IsWorkerDebuggerSandbox(global));
+ 
+       microTaskQueue = &mDebuggerPromiseMicroTaskQueue;
+     }
+ 
+     microTaskQueue->push(runnable.forget());
+   }
+ 
+ private:
+@@ -2786,18 +2788,16 @@ WorkerThreadPrimaryRunnable::FinishedRun
+     MOZ_ALWAYS_SUCCEEDS(thread->Shutdown());
+   }
+ 
+   return NS_OK;
+ }
+ 
+ } // workerinternals namespace
+ 
+-namespace workers {
+-
+ void
+ CancelWorkersForWindow(nsPIDOMWindowInner* aWindow)
+ {
+   AssertIsOnMainThread();
+   RuntimeService* runtime = RuntimeService::GetService();
+   if (runtime) {
+     runtime->CancelWorkersForWindow(aWindow);
+   }
+@@ -2880,17 +2880,17 @@ GetCurrentThreadWorkerPrivate()
+ 
+ bool
+ IsCurrentThreadRunningChromeWorker()
+ {
+   return GetCurrentThreadWorkerPrivate()->UsesSystemPrincipal();
+ }
+ 
+ JSContext*
+-GetCurrentThreadJSContext()
++GetCurrentWorkerThreadJSContext()
+ {
+   WorkerPrivate* wp = GetCurrentThreadWorkerPrivate();
+   if (!wp) {
+     return nullptr;
+   }
+   return wp->GetJSContext();
+ }
+ 
+@@ -2903,22 +2903,10 @@ GetCurrentThreadWorkerGlobal()
+   }
+   WorkerGlobalScope* scope = wp->GlobalScope();
+   if (!scope) {
+     return nullptr;
+   }
+   return scope->GetGlobalJSObject();
+ }
+ 
+-#ifdef DEBUG
+-
+-void
+-AssertIsOnMainThread()
+-{
+-  MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!");
+-}
+-
+-#endif
+-
+-} // workers namespace
+-
+ } // dom namespace
+ } // mozilla namespace
+diff --git a/dom/workers/RuntimeService.h b/dom/workers/RuntimeService.h
+--- a/dom/workers/RuntimeService.h
++++ b/dom/workers/RuntimeService.h
+@@ -168,24 +168,24 @@ public:
+   }
+ 
+   void
+   NoteIdleThread(WorkerThread* aThread);
+ 
+   static void
+   GetDefaultJSSettings(workerinternals::JSSettings& aSettings)
+   {
+-    workers::AssertIsOnMainThread();
++    AssertIsOnMainThread();
+     aSettings = sDefaultJSSettings;
+   }
+ 
+   static void
+   SetDefaultContextOptions(const JS::ContextOptions& aContextOptions)
+   {
+-    workers::AssertIsOnMainThread();
++    AssertIsOnMainThread();
+     sDefaultJSSettings.contextOptions = aContextOptions;
+   }
+ 
+   void
+   UpdateAppNameOverridePreference(const nsAString& aValue);
+ 
+   void
+   UpdateAppVersionOverridePreference(const nsAString& aValue);
+@@ -197,28 +197,28 @@ public:
+   UpdateAllWorkerContextOptions();
+ 
+   void
+   UpdateAllWorkerLanguages(const nsTArray<nsString>& aLanguages);
+ 
+   static void
+   SetDefaultJSGCSettings(JSGCParamKey aKey, uint32_t aValue)
+   {
+-    workers::AssertIsOnMainThread();
++    AssertIsOnMainThread();
+     sDefaultJSSettings.ApplyGCSetting(aKey, aValue);
+   }
+ 
+   void
+   UpdateAllWorkerMemoryParameter(JSGCParamKey aKey, uint32_t aValue);
+ 
+ #ifdef JS_GC_ZEAL
+   static void
+   SetDefaultGCZeal(uint8_t aGCZeal, uint32_t aFrequency)
+   {
+-    workers::AssertIsOnMainThread();
++    AssertIsOnMainThread();
+     sDefaultJSSettings.gcZeal = aGCZeal;
+     sDefaultJSSettings.gcZealFrequency = aFrequency;
+   }
+ 
+   void
+   UpdateAllWorkerGCZeal();
+ #endif
+ 
+diff --git a/dom/workers/ScriptLoader.cpp b/dom/workers/ScriptLoader.cpp
+--- a/dom/workers/ScriptLoader.cpp
++++ b/dom/workers/ScriptLoader.cpp
+@@ -75,18 +75,16 @@
+ 
+ using mozilla::dom::cache::Cache;
+ using mozilla::dom::cache::CacheStorage;
+ using mozilla::ipc::PrincipalInfo;
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+-using namespace workers;
+-
+ namespace {
+ 
+ nsIURI*
+ GetBaseURI(bool aIsMainScript, WorkerPrivate* aWorkerPrivate)
+ {
+   MOZ_ASSERT(aWorkerPrivate);
+   nsIURI* baseURI;
+   WorkerPrivate* parentWorker = aWorkerPrivate->GetParent();
+diff --git a/dom/workers/WorkerCommon.h b/dom/workers/WorkerCommon.h
+--- a/dom/workers/WorkerCommon.h
++++ b/dom/workers/WorkerCommon.h
+@@ -13,40 +13,29 @@
+ 
+ class nsPIDOMWindowInner;
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+ class WorkerPrivate;
+ 
+-namespace workers {
+-
+ // All of these are implemented in RuntimeService.cpp
+ 
+-#ifdef DEBUG
+-void
+-AssertIsOnMainThread();
+-#else
+-inline void
+-AssertIsOnMainThread()
+-{ }
+-#endif
+-
+ WorkerPrivate*
+ GetWorkerPrivateFromContext(JSContext* aCx);
+ 
+ WorkerPrivate*
+ GetCurrentThreadWorkerPrivate();
+ 
+ bool
+ IsCurrentThreadRunningChromeWorker();
+ 
+ JSContext*
+-GetCurrentThreadJSContext();
++GetCurrentWorkerThreadJSContext();
+ 
+ JSObject*
+ GetCurrentThreadWorkerGlobal();
+ 
+ void
+ CancelWorkersForWindow(nsPIDOMWindowInner* aWindow);
+ 
+ void
+@@ -62,18 +51,17 @@ void
+ ResumeWorkersForWindow(nsPIDOMWindowInner* aWindow);
+ 
+ // All of these are implemented in WorkerScope.cpp
+ 
+ bool
+ IsWorkerGlobal(JSObject* global);
+ 
+ bool
+-IsDebuggerGlobal(JSObject* global);
++IsWorkerDebuggerGlobal(JSObject* global);
+ 
+ bool
+-IsDebuggerSandbox(JSObject* object);
++IsWorkerDebuggerSandbox(JSObject* object);
+ 
+-} // workers namespace
+ } // dom namespace
+ } // mozilla namespace
+ 
+ #endif // mozilla_dom_workers_WorkerCommon_h
+diff --git a/dom/workers/WorkerError.cpp b/dom/workers/WorkerError.cpp
+--- a/dom/workers/WorkerError.cpp
++++ b/dom/workers/WorkerError.cpp
+@@ -95,17 +95,17 @@ public:
+           WorkerGlobalScope* globalScope = nullptr;
+           UNWRAP_OBJECT(WorkerGlobalScope, &global, globalScope);
+ 
+           if (!globalScope) {
+             WorkerDebuggerGlobalScope* globalScope = nullptr;
+             UNWRAP_OBJECT(WorkerDebuggerGlobalScope, &global, globalScope);
+ 
+             MOZ_ASSERT_IF(globalScope, globalScope->GetWrapperPreserveColor() == global);
+-            if (globalScope || IsDebuggerSandbox(global)) {
++            if (globalScope || IsWorkerDebuggerSandbox(global)) {
+               aWorkerPrivate->ReportErrorToDebugger(aReport.mFilename, aReport.mLineNumber,
+                                                     aReport.mMessage);
+               return;
+             }
+ 
+             MOZ_ASSERT(SimpleGlobalObject::SimpleGlobalType(global) ==
+                          SimpleGlobalObject::GlobalType::BindingDetail);
+             // XXXbz We should really log this to console, but unwinding out of
+@@ -351,17 +351,17 @@ WorkerErrorReport::ReportError(JSContext
+         WorkerGlobalScope* globalScope = nullptr;
+         UNWRAP_OBJECT(WorkerGlobalScope, &global, globalScope);
+ 
+         if (!globalScope) {
+           WorkerDebuggerGlobalScope* globalScope = nullptr;
+           UNWRAP_OBJECT(WorkerDebuggerGlobalScope, &global, globalScope);
+ 
+           MOZ_ASSERT_IF(globalScope, globalScope->GetWrapperPreserveColor() == global);
+-          if (globalScope || IsDebuggerSandbox(global)) {
++          if (globalScope || IsWorkerDebuggerSandbox(global)) {
+             aWorkerPrivate->ReportErrorToDebugger(aReport.mFilename, aReport.mLineNumber,
+                                                   aReport.mMessage);
+             return;
+           }
+ 
+           MOZ_ASSERT(SimpleGlobalObject::SimpleGlobalType(global) ==
+                        SimpleGlobalObject::GlobalType::BindingDetail);
+           // XXXbz We should really log this to console, but unwinding out of
+diff --git a/dom/workers/WorkerPrivate.cpp b/dom/workers/WorkerPrivate.cpp
+--- a/dom/workers/WorkerPrivate.cpp
++++ b/dom/workers/WorkerPrivate.cpp
+@@ -93,17 +93,16 @@ TimeoutsLog()
+ #define LOG(log, _args) MOZ_LOG(log, LogLevel::Debug, _args);
+ 
+ namespace mozilla {
+ 
+ using namespace ipc;
+ 
+ namespace dom {
+ 
+-using namespace workers;
+ using namespace workerinternals;
+ 
+ MOZ_DEFINE_MALLOC_SIZE_OF(JsWorkerMallocSizeOf)
+ 
+ namespace {
+ 
+ #ifdef DEBUG
+ 
+diff --git a/dom/workers/WorkerPrivate.h b/dom/workers/WorkerPrivate.h
+--- a/dom/workers/WorkerPrivate.h
++++ b/dom/workers/WorkerPrivate.h
+@@ -401,17 +401,17 @@ public:
+   {
+     mMutex.AssertCurrentThreadOwns();
+     return mParentStatus;
+   }
+ 
+   nsIScriptContext*
+   GetScriptContext() const
+   {
+-    workers::AssertIsOnMainThread();
++    AssertIsOnMainThread();
+     return mLoadInfo.mScriptContext;
+   }
+ 
+   const nsString&
+   ScriptURL() const
+   {
+     return mScriptURL;
+   }
+@@ -450,35 +450,35 @@ public:
+   ServiceWorkerScope() const
+   {
+     return GetServiceWorkerDescriptor().Scope();
+   }
+ 
+   nsIURI*
+   GetBaseURI() const
+   {
+-    workers::AssertIsOnMainThread();
++    AssertIsOnMainThread();
+     return mLoadInfo.mBaseURI;
+   }
+ 
+   void
+   SetBaseURI(nsIURI* aBaseURI);
+ 
+   nsIURI*
+   GetResolvedScriptURI() const
+   {
+-    workers::AssertIsOnMainThread();
++    AssertIsOnMainThread();
+     return mLoadInfo.mResolvedScriptURI;
+   }
+ 
+   const nsString&
+   ServiceWorkerCacheName() const
+   {
+     MOZ_DIAGNOSTIC_ASSERT(IsServiceWorker());
+-    workers::AssertIsOnMainThread();
++    AssertIsOnMainThread();
+     return mLoadInfo.mServiceWorkerCacheName;
+   }
+ 
+   const ServiceWorkerDescriptor&
+   GetServiceWorkerDescriptor() const
+   {
+     MOZ_DIAGNOSTIC_ASSERT(IsServiceWorker());
+     MOZ_DIAGNOSTIC_ASSERT(mLoadInfo.mServiceWorkerDescriptor.isSome());
+@@ -503,17 +503,17 @@ public:
+   GetChannelInfo() const
+   {
+     return mLoadInfo.mChannelInfo;
+   }
+ 
+   void
+   SetChannelInfo(const ChannelInfo& aChannelInfo)
+   {
+-    workers::AssertIsOnMainThread();
++    AssertIsOnMainThread();
+     MOZ_ASSERT(!mLoadInfo.mChannelInfo.IsInitialized());
+     MOZ_ASSERT(aChannelInfo.IsInitialized());
+     mLoadInfo.mChannelInfo = aChannelInfo;
+   }
+ 
+   void
+   InitChannelInfo(nsIChannel* aChannel)
+   {
+@@ -564,36 +564,36 @@ public:
+     MOZ_ASSERT(!aTimeStamp.IsNull());
+     TimeDuration duration = aTimeStamp - mCreationTimeStamp;
+     return duration.ToMilliseconds();
+   }
+ 
+   nsIPrincipal*
+   GetPrincipal() const
+   {
+-    workers::AssertIsOnMainThread();
++    AssertIsOnMainThread();
+     return mLoadInfo.mPrincipal;
+   }
+ 
+   nsIPrincipal*
+   GetLoadingPrincipal() const
+   {
+-    workers::AssertIsOnMainThread();
++    AssertIsOnMainThread();
+     return mLoadInfo.mLoadingPrincipal;
+   }
+ 
+   const nsAString& Origin() const
+   {
+     return mLoadInfo.mOrigin;
+   }
+ 
+   nsILoadGroup*
+   GetLoadGroup() const
+   {
+-    workers::AssertIsOnMainThread();
++    AssertIsOnMainThread();
+     return mLoadInfo.mLoadGroup;
+   }
+ 
+   // This method allows the principal to be retrieved off the main thread.
+   // Principals are main-thread objects so the caller must ensure that all
+   // access occurs on the main thread.
+   nsIPrincipal*
+   GetPrincipalDontAssertMainThread() const
+@@ -625,33 +625,33 @@ public:
+   GetPrincipalInfo() const
+   {
+     return *mLoadInfo.mPrincipalInfo;
+   }
+ 
+   already_AddRefed<nsIChannel>
+   ForgetWorkerChannel()
+   {
+-    workers::AssertIsOnMainThread();
++    AssertIsOnMainThread();
+     return mLoadInfo.mChannel.forget();
+   }
+ 
+   nsIDocument* GetDocument() const;
+ 
+   nsPIDOMWindowInner*
+   GetWindow()
+   {
+-    workers::AssertIsOnMainThread();
++    AssertIsOnMainThread();
+     return mLoadInfo.mWindow;
+   }
+ 
+   nsIContentSecurityPolicy*
+   GetCSP() const
+   {
+-    workers::AssertIsOnMainThread();
++    AssertIsOnMainThread();
+     return mLoadInfo.mCSP;
+   }
+ 
+   void
+   SetCSP(nsIContentSecurityPolicy* aCSP);
+ 
+   nsresult
+   SetCSPFromHeaderValues(const nsACString& aCSPHeaderValue,
+@@ -1005,26 +1005,26 @@ public:
+   // ServiceWorker and the loading principal for any other type.
+   static void
+   OverrideLoadInfoLoadGroup(WorkerLoadInfo& aLoadInfo,
+                             nsIPrincipal* aPrincipal);
+ 
+   bool
+   IsDebuggerRegistered()
+   {
+-    workers::AssertIsOnMainThread();
++    AssertIsOnMainThread();
+ 
+     // No need to lock here since this is only ever modified by the same thread.
+     return mDebuggerRegistered;
+   }
+ 
+   void
+   SetIsDebuggerRegistered(bool aDebuggerRegistered)
+   {
+-    workers::AssertIsOnMainThread();
++    AssertIsOnMainThread();
+ 
+     MutexAutoLock lock(mMutex);
+ 
+     MOZ_ASSERT(mDebuggerRegistered != aDebuggerRegistered);
+     mDebuggerRegistered = aDebuggerRegistered;
+ 
+     mCondVar.Notify();
+   }
+@@ -1041,26 +1041,26 @@ public:
+     while (mDebuggerRegistered != aDebuggerRegistered) {
+       mCondVar.Wait();
+     }
+   }
+ 
+   WorkerDebugger*
+   Debugger() const
+   {
+-    workers::AssertIsOnMainThread();
++    AssertIsOnMainThread();
+ 
+     MOZ_ASSERT(mDebugger);
+     return mDebugger;
+   }
+ 
+   void
+   SetDebugger(WorkerDebugger* aDebugger)
+   {
+-    workers::AssertIsOnMainThread();
++    AssertIsOnMainThread();
+ 
+     MOZ_ASSERT(mDebugger != aDebugger);
+     mDebugger = aDebugger;
+   }
+ 
+   JS::UniqueChars
+   AdoptDefaultLocale()
+   {
+diff --git a/dom/workers/WorkerRunnable.cpp b/dom/workers/WorkerRunnable.cpp
+--- a/dom/workers/WorkerRunnable.cpp
++++ b/dom/workers/WorkerRunnable.cpp
+@@ -279,17 +279,17 @@ WorkerRunnable::Run()
+   }
+ 
+   // Track down the appropriate global, if any, to use for the AutoEntryScript.
+   nsCOMPtr<nsIGlobalObject> globalObject;
+   bool isMainThread = !targetIsWorkerThread && !mWorkerPrivate->GetParent();
+   MOZ_ASSERT(isMainThread == NS_IsMainThread());
+   RefPtr<WorkerPrivate> kungFuDeathGrip;
+   if (targetIsWorkerThread) {
+-    JSContext* cx = GetCurrentThreadJSContext();
++    JSContext* cx = GetCurrentWorkerThreadJSContext();
+     if (NS_WARN_IF(!cx)) {
+       return NS_ERROR_FAILURE;
+     }
+ 
+     JSObject* global = JS::CurrentGlobalOrNull(cx);
+     if (global) {
+       globalObject = xpc::NativeGlobal(global);
+     } else {
+@@ -468,17 +468,17 @@ MainThreadWorkerSyncRunnable::PostDispat
+ }
+ 
+ MainThreadStopSyncLoopRunnable::MainThreadStopSyncLoopRunnable(
+                                WorkerPrivate* aWorkerPrivate,
+                                already_AddRefed<nsIEventTarget>&& aSyncLoopTarget,
+                                bool aResult)
+ : WorkerSyncRunnable(aWorkerPrivate, Move(aSyncLoopTarget)), mResult(aResult)
+ {
+-  workers::AssertIsOnMainThread();
++  AssertIsOnMainThread();
+ #ifdef DEBUG
+   mWorkerPrivate->AssertValidSyncLoop(mSyncLoopTarget);
+ #endif
+ }
+ 
+ nsresult
+ MainThreadStopSyncLoopRunnable::Cancel()
+ {
+@@ -602,17 +602,17 @@ WorkerMainThreadRunnable::Dispatch(Worke
+   if (!success) {
+     aRv.ThrowUncatchableException();
+   }
+ }
+ 
+ NS_IMETHODIMP
+ WorkerMainThreadRunnable::Run()
+ {
+-  workers::AssertIsOnMainThread();
++  AssertIsOnMainThread();
+ 
+   bool runResult = MainThreadRun();
+ 
+   RefPtr<MainThreadStopSyncLoopRunnable> response =
+     new MainThreadStopSyncLoopRunnable(mWorkerPrivate,
+                                        mSyncLoopTarget.forget(),
+                                        runResult);
+ 
+@@ -694,17 +694,17 @@ WorkerProxyToMainThreadRunnable::Dispatc
+   }
+ 
+   return true;
+ }
+ 
+ NS_IMETHODIMP
+ WorkerProxyToMainThreadRunnable::Run()
+ {
+-  workers::AssertIsOnMainThread();
++  AssertIsOnMainThread();
+   RunOnMainThread();
+   PostDispatchOnMainThread();
+   return NS_OK;
+ }
+ 
+ void
+ WorkerProxyToMainThreadRunnable::PostDispatchOnMainThread()
+ {
+diff --git a/dom/workers/WorkerRunnable.h b/dom/workers/WorkerRunnable.h
+--- a/dom/workers/WorkerRunnable.h
++++ b/dom/workers/WorkerRunnable.h
+@@ -140,23 +140,24 @@ protected:
+   // value will be passed to PostRun().  The JSContext passed in here comes from
+   // an AutoJSAPI (or AutoEntryScript) that we set up on the stack.  If
+   // mBehavior is ParentThreadUnchangedBusyCount, it is in the compartment of
+   // mWorkerPrivate's reflector (i.e. the worker object in the parent thread),
+   // unless that reflector is null, in which case it's in the compartment of the
+   // parent global (which is the compartment reflector would have been in), or
+   // in the null compartment if there is no parent global.  For other mBehavior
+   // values, we're running on the worker thread and aCx is in whatever
+-  // compartment GetCurrentThreadJSContext() was in when nsIRunnable::Run() got
+-  // called.  This is actually important for cases when a runnable spins a
+-  // syncloop and wants everything that happens during the syncloop to happen in
+-  // the compartment that runnable set up (which may, for example, be a debugger
+-  // sandbox compartment!).  If aCx wasn't in a compartment to start with, aCx
+-  // will be in either the debugger global's compartment or the worker's
+-  // global's compartment depending on whether IsDebuggerRunnable() is true.
++  // compartment GetCurrentWorkerThreadJSContext() was in when
++  // nsIRunnable::Run() got called.  This is actually important for cases when a
++  // runnable spins a syncloop and wants everything that happens during the
++  // syncloop to happen in the compartment that runnable set up (which may, for
++  // example, be a debugger sandbox compartment!).  If aCx wasn't in a
++  // compartment to start with, aCx will be in either the debugger global's
++  // compartment or the worker's global's compartment depending on whether
++  // IsDebuggerRunnable() is true.
+   //
+   // Immediately after WorkerRun returns, the caller will assert that either it
+   // returns false or there is no exception pending on aCx.  Then it will report
+   // any pending exceptions on aCx.
+   virtual bool
+   WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate) = 0;
+ 
+   // By default asserts that Run() (and WorkerRun()) were called on the correct
+@@ -196,17 +197,17 @@ private:
+   IsDebuggerRunnable() const override
+   {
+     return true;
+   }
+ 
+   virtual bool
+   PreDispatch(WorkerPrivate* aWorkerPrivate) override final
+   {
+-    workers::AssertIsOnMainThread();
++    AssertIsOnMainThread();
+ 
+     return true;
+   }
+ 
+   virtual void
+   PostDispatch(WorkerPrivate* aWorkerPrivate,
+                bool aDispatchResult) override;
+ };
+@@ -238,34 +239,34 @@ class MainThreadWorkerSyncRunnable : pub
+ {
+ protected:
+   // Passing null for aSyncLoopTarget is allowed and will result in the behavior
+   // of a normal WorkerRunnable.
+   MainThreadWorkerSyncRunnable(WorkerPrivate* aWorkerPrivate,
+                                nsIEventTarget* aSyncLoopTarget)
+   : WorkerSyncRunnable(aWorkerPrivate, aSyncLoopTarget)
+   {
+-    workers::AssertIsOnMainThread();
++    AssertIsOnMainThread();
+   }
+ 
+   MainThreadWorkerSyncRunnable(WorkerPrivate* aWorkerPrivate,
+                                already_AddRefed<nsIEventTarget>&& aSyncLoopTarget)
+   : WorkerSyncRunnable(aWorkerPrivate, Move(aSyncLoopTarget))
+   {
+-    workers::AssertIsOnMainThread();
++    AssertIsOnMainThread();
+   }
+ 
+   virtual ~MainThreadWorkerSyncRunnable()
+   { }
+ 
+ private:
+   virtual bool
+   PreDispatch(WorkerPrivate* aWorkerPrivate) override
+   {
+-    workers::AssertIsOnMainThread();
++    AssertIsOnMainThread();
+     return true;
+   }
+ 
+   virtual void
+   PostDispatch(WorkerPrivate* aWorkerPrivate,
+                bool aDispatchResult) override;
+ };
+ 
+@@ -308,34 +309,34 @@ private:
+ // A convenience class for WorkerRunnables that are originated on the main
+ // thread.
+ class MainThreadWorkerRunnable : public WorkerRunnable
+ {
+ protected:
+   explicit MainThreadWorkerRunnable(WorkerPrivate* aWorkerPrivate)
+   : WorkerRunnable(aWorkerPrivate, WorkerThreadUnchangedBusyCount)
+   {
+-    workers::AssertIsOnMainThread();
++    AssertIsOnMainThread();
+   }
+ 
+   virtual ~MainThreadWorkerRunnable()
+   {}
+ 
+   virtual bool
+   PreDispatch(WorkerPrivate* aWorkerPrivate) override
+   {
+-    workers::AssertIsOnMainThread();
++    AssertIsOnMainThread();
+     return true;
+   }
+ 
+   virtual void
+   PostDispatch(WorkerPrivate* aWorkerPrivate,
+                bool aDispatchResult) override
+   {
+-    workers::AssertIsOnMainThread();
++    AssertIsOnMainThread();
+   }
+ };
+ 
+ // A convenience class for WorkerControlRunnables that originate on the main
+ // thread.
+ class MainThreadWorkerControlRunnable : public WorkerControlRunnable
+ {
+ protected:
+@@ -344,25 +345,25 @@ protected:
+   { }
+ 
+   virtual ~MainThreadWorkerControlRunnable()
+   { }
+ 
+   virtual bool
+   PreDispatch(WorkerPrivate* aWorkerPrivate) override
+   {
+-    workers::AssertIsOnMainThread();
++    AssertIsOnMainThread();
+     return true;
+   }
+ 
+   virtual void
+   PostDispatch(WorkerPrivate* aWorkerPrivate,
+                bool aDispatchResult) override
+   {
+-    workers::AssertIsOnMainThread();
++    AssertIsOnMainThread();
+   }
+ };
+ 
+ // A WorkerRunnable that should be dispatched from the worker to itself for
+ // async tasks. This will increment the busy count PostDispatch() (only if
+ // dispatch was successful) and decrement it in PostRun().
+ //
+ // Async tasks will almost always want to use this since
+@@ -500,17 +501,17 @@ public:
+ protected:
+   virtual ~MainThreadStopSyncLoopRunnable()
+   { }
+ 
+ private:
+   virtual bool
+   PreDispatch(WorkerPrivate* aWorkerPrivate) override final
+   {
+-    workers::AssertIsOnMainThread();
++    AssertIsOnMainThread();
+     return true;
+   }
+ 
+   virtual void
+   PostDispatch(WorkerPrivate* aWorkerPrivate,
+                bool aDispatchResult) override;
+ 
+   virtual bool
+diff --git a/dom/workers/WorkerScope.cpp b/dom/workers/WorkerScope.cpp
+--- a/dom/workers/WorkerScope.cpp
++++ b/dom/workers/WorkerScope.cpp
+@@ -979,17 +979,17 @@ WorkerDebuggerGlobalScope::LoadSubScript
+                                          const Optional<JS::Handle<JSObject*>>& aSandbox,
+                                          ErrorResult& aRv)
+ {
+   mWorkerPrivate->AssertIsOnWorkerThread();
+ 
+   Maybe<JSAutoCompartment> ac;
+   if (aSandbox.WasPassed()) {
+     JS::Rooted<JSObject*> sandbox(aCx, js::CheckedUnwrap(aSandbox.Value()));
+-    if (!IsDebuggerSandbox(sandbox)) {
++    if (!IsWorkerDebuggerSandbox(sandbox)) {
+       aRv.Throw(NS_ERROR_INVALID_ARG);
+       return;
+     }
+ 
+     ac.emplace(aCx, sandbox);
+   }
+ 
+   nsTArray<nsString> urls;
+@@ -1112,32 +1112,29 @@ WorkerDebuggerGlobalScope::EventTargetFo
+ }
+ 
+ AbstractThread*
+ WorkerDebuggerGlobalScope::AbstractMainThreadFor(TaskCategory aCategory)
+ {
+   MOZ_CRASH("AbstractMainThreadFor not supported for workers.");
+ }
+ 
+-namespace workers {
+-
+ bool
+ IsWorkerGlobal(JSObject* object)
+ {
+   return IS_INSTANCE_OF(WorkerGlobalScope, object);
+ }
+ 
+ bool
+-IsDebuggerGlobal(JSObject* object)
++IsWorkerDebuggerGlobal(JSObject* object)
+ {
+   return IS_INSTANCE_OF(WorkerDebuggerGlobalScope, object);
+ }
+ 
+ bool
+-IsDebuggerSandbox(JSObject* object)
++IsWorkerDebuggerSandbox(JSObject* object)
+ {
+   return SimpleGlobalObject::SimpleGlobalType(object) ==
+     SimpleGlobalObject::GlobalType::WorkerDebuggerSandbox;
+ }
+ 
+-} // workers namespace
+ } // dom namespace
+ } // mozilla namespace
+diff --git a/dom/xhr/XMLHttpRequestWorker.cpp b/dom/xhr/XMLHttpRequestWorker.cpp
+--- a/dom/xhr/XMLHttpRequestWorker.cpp
++++ b/dom/xhr/XMLHttpRequestWorker.cpp
+@@ -156,27 +156,27 @@ public:
+   Teardown(bool aSendUnpin);
+ 
+   bool
+   AddRemoveEventListeners(bool aUpload, bool aAdd);
+ 
+   void
+   Reset()
+   {
+-    workers::AssertIsOnMainThread();
++    AssertIsOnMainThread();
+ 
+     if (mUploadEventListenersAttached) {
+       AddRemoveEventListeners(true, false);
+     }
+   }
+ 
+   already_AddRefed<nsIEventTarget>
+   GetEventTarget()
+   {
+-    workers::AssertIsOnMainThread();
++    AssertIsOnMainThread();
+ 
+     nsCOMPtr<nsIEventTarget> target = mSyncEventResponseTarget ?
+                                       mSyncEventResponseTarget :
+                                       mSyncLoopTarget;
+     return target.forget();
+   }
+ 
+ private:
+@@ -367,17 +367,17 @@ public:
+ 
+ private:
+   ~AsyncTeardownRunnable()
+   { }
+ 
+   NS_IMETHOD
+   Run() override
+   {
+-    workers::AssertIsOnMainThread();
++    AssertIsOnMainThread();
+ 
+     // This means the XHR was GC'd, so we can't be pinned, and we don't need to
+     // try to unpin.
+     mProxy->Teardown(/* aSendUnpin */ false);
+     mProxy = nullptr;
+ 
+     return NS_OK;
+   }
+@@ -444,41 +444,41 @@ public:
+     : Runnable("dom::LoadStartDetectionRunnable")
+     , mWorkerPrivate(aProxy->mWorkerPrivate)
+     , mProxy(aProxy)
+     , mXHR(aProxy->mXHR)
+     , mXMLHttpRequestPrivate(aXHRPrivate)
+     , mChannelId(mProxy->mInnerChannelId)
+     , mReceivedLoadStart(false)
+   {
+-    workers::AssertIsOnMainThread();
++    AssertIsOnMainThread();
+     CopyASCIItoUTF16(sEventStrings[STRING_loadstart], mEventType);
+   }
+ 
+   NS_DECL_ISUPPORTS_INHERITED
+   NS_DECL_NSIRUNNABLE
+   NS_DECL_NSIDOMEVENTLISTENER
+ 
+   bool
+   RegisterAndDispatch()
+   {
+-    workers::AssertIsOnMainThread();
++    AssertIsOnMainThread();
+ 
+     if (NS_FAILED(mXHR->AddEventListener(mEventType, this, false, false, 2))) {
+       NS_WARNING("Failed to add event listener!");
+       return false;
+     }
+ 
+     return NS_SUCCEEDED(mWorkerPrivate->DispatchToMainThread(this));
+   }
+ 
+ private:
+   ~LoadStartDetectionRunnable()
+   {
+-    workers::AssertIsOnMainThread();
++    AssertIsOnMainThread();
+   }
+ };
+ 
+ class EventRunnable final : public MainThreadProxyRunnable
+                           , public StructuredCloneHolder
+ {
+   nsString mType;
+   nsString mResponseType;
+@@ -847,17 +847,17 @@ public:
+   }
+ };
+ 
+ } // namespace
+ 
+ bool
+ Proxy::Init()
+ {
+-  workers::AssertIsOnMainThread();
++  AssertIsOnMainThread();
+   MOZ_ASSERT(mWorkerPrivate);
+ 
+   if (mXHR) {
+     return true;
+   }
+ 
+   nsPIDOMWindowInner* ownerWindow = mWorkerPrivate->GetWindow();
+   if (ownerWindow && !ownerWindow->IsCurrentInnerWindow()) {
+@@ -890,17 +890,17 @@ Proxy::Init()
+   }
+ 
+   return true;
+ }
+ 
+ void
+ Proxy::Teardown(bool aSendUnpin)
+ {
+-  workers::AssertIsOnMainThread();
++  AssertIsOnMainThread();
+ 
+   if (mXHR) {
+     Reset();
+ 
+     // NB: We are intentionally dropping events coming from xhr.abort on the
+     // floor.
+     AddRemoveEventListeners(false, false);
+ 
+@@ -940,17 +940,17 @@ Proxy::Teardown(bool aSendUnpin)
+ 
+   MOZ_ASSERT(!mWorkerPrivate);
+   MOZ_ASSERT(!mSyncLoopTarget);
+ }
+ 
+ bool
+ Proxy::AddRemoveEventListeners(bool aUpload, bool aAdd)
+ {
+-  workers::AssertIsOnMainThread();
++  AssertIsOnMainThread();
+ 
+   NS_ASSERTION(!aUpload ||
+                (mUploadEventListenersAttached && !aAdd) ||
+                (!mUploadEventListenersAttached && aAdd),
+                "Messed up logic for upload listeners!");
+ 
+   nsCOMPtr<nsIDOMEventTarget> target =
+     aUpload ?
+@@ -980,17 +980,17 @@ Proxy::AddRemoveEventListeners(bool aUpl
+   return true;
+ }
+ 
+ NS_IMPL_ISUPPORTS(Proxy, nsIDOMEventListener)
+ 
+ NS_IMETHODIMP
+ Proxy::HandleEvent(nsIDOMEvent* aEvent)
+ {
+-  workers::AssertIsOnMainThread();
++  AssertIsOnMainThread();
+ 
+   if (!mWorkerPrivate || !mXMLHttpRequestPrivate) {
+     NS_ERROR("Shouldn't get here!");
+     return NS_OK;
+   }
+ 
+   nsString type;
+   if (NS_FAILED(aEvent->GetType(type))) {
+@@ -1061,17 +1061,17 @@ Proxy::HandleEvent(nsIDOMEvent* aEvent)
+ }
+ 
+ NS_IMPL_ISUPPORTS_INHERITED(LoadStartDetectionRunnable, Runnable,
+                                                         nsIDOMEventListener)
+ 
+ NS_IMETHODIMP
+ LoadStartDetectionRunnable::Run()
+ {
+-  workers::AssertIsOnMainThread();
++  AssertIsOnMainThread();
+ 
+   if (NS_FAILED(mXHR->RemoveEventListener(mEventType, this, false))) {
+     NS_WARNING("Failed to remove event listener!");
+   }
+ 
+   if (!mReceivedLoadStart) {
+     if (mProxy->mOutstandingSendCount > 1) {
+       mProxy->mOutstandingSendCount--;
+@@ -1093,17 +1093,17 @@ LoadStartDetectionRunnable::Run()
+   mXHR = nullptr;
+   mXMLHttpRequestPrivate = nullptr;
+   return NS_OK;
+ }
+ 
+ NS_IMETHODIMP
+ LoadStartDetectionRunnable::HandleEvent(nsIDOMEvent* aEvent)
+ {
+-  workers::AssertIsOnMainThread();
++  AssertIsOnMainThread();
+ 
+ #ifdef DEBUG
+   {
+     nsString type;
+     if (NS_SUCCEEDED(aEvent->GetType(type))) {
+       MOZ_ASSERT(type == mEventType);
+     }
+     else {
+@@ -1114,17 +1114,17 @@ LoadStartDetectionRunnable::HandleEvent(
+ 
+   mReceivedLoadStart = true;
+   return NS_OK;
+ }
+ 
+ bool
+ EventRunnable::PreDispatch(WorkerPrivate* /* unused */)
+ {
+-  workers::AssertIsOnMainThread();
++  AssertIsOnMainThread();
+ 
+   AutoJSAPI jsapi;
+   DebugOnly<bool> ok = jsapi.Init(xpc::NativeGlobal(mScopeObj));
+   MOZ_ASSERT(ok);
+   JSContext* cx = jsapi.cx();
+   // Now keep the mScopeObj alive for the duration
+   JS::Rooted<JSObject*> scopeObj(cx, mScopeObj);
+   // And reset mScopeObj now, before we have a chance to run its destructor on
+@@ -1369,17 +1369,17 @@ EventRunnable::WorkerRun(JSContext* aCx,
+   }
+ 
+   return true;
+ }
+ 
+ bool
+ WorkerThreadProxySyncRunnable::MainThreadRun()
+ {
+-  workers::AssertIsOnMainThread();
++  AssertIsOnMainThread();
+ 
+   nsCOMPtr<nsIEventTarget> tempTarget = mSyncLoopTarget;
+ 
+   mProxy->mSyncEventResponseTarget.swap(tempTarget);
+ 
+   ErrorResult rv;
+   RunOnMainThread(rv);
+   mErrorCode = rv.StealNSResult();
+@@ -1584,17 +1584,17 @@ NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INH
+ NS_IMPL_CYCLE_COLLECTION_TRACE_END
+ 
+ /* static */ already_AddRefed<XMLHttpRequest>
+ XMLHttpRequestWorker::Construct(const GlobalObject& aGlobal,
+                                 const MozXMLHttpRequestParameters& aParams,
+                                 ErrorResult& aRv)
+ {
+   JSContext* cx = aGlobal.Context();
+-  WorkerPrivate* workerPrivate = workers::GetWorkerPrivateFromContext(cx);
++  WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(cx);
+   MOZ_ASSERT(workerPrivate);
+ 
+   RefPtr<XMLHttpRequestWorker> xhr = new XMLHttpRequestWorker(workerPrivate);
+ 
+   if (workerPrivate->XHRParamsAllowed()) {
+     if (aParams.mMozSystem)
+       xhr->mMozAnon = true;
+     else
+diff --git a/gfx/thebes/gfxUtils.cpp b/gfx/thebes/gfxUtils.cpp
+--- a/gfx/thebes/gfxUtils.cpp
++++ b/gfx/thebes/gfxUtils.cpp
+@@ -1453,18 +1453,17 @@ private:
+ };
+ 
+ /* static */ nsresult
+ gfxUtils::ThreadSafeGetFeatureStatus(const nsCOMPtr<nsIGfxInfo>& gfxInfo,
+                                      int32_t feature, nsACString& failureId,
+                                      int32_t* status)
+ {
+   if (!NS_IsMainThread()) {
+-    dom::WorkerPrivate* workerPrivate =
+-      dom::workers::GetCurrentThreadWorkerPrivate();
++    dom::WorkerPrivate* workerPrivate = dom::GetCurrentThreadWorkerPrivate();
+ 
+     RefPtr<GetFeatureStatusRunnable> runnable =
+       new GetFeatureStatusRunnable(workerPrivate, gfxInfo, feature, failureId,
+                                    status);
+ 
+     ErrorResult rv;
+     runnable->Dispatch(dom::WorkerStatus::Terminating, rv);
+     if (rv.Failed()) {
+diff --git a/ipc/glue/BackgroundParentImpl.cpp b/ipc/glue/BackgroundParentImpl.cpp
+--- a/ipc/glue/BackgroundParentImpl.cpp
++++ b/ipc/glue/BackgroundParentImpl.cpp
+@@ -65,25 +65,20 @@ using mozilla::dom::cache::PCacheParent;
+ using mozilla::dom::cache::PCacheStorageParent;
+ using mozilla::dom::cache::PCacheStreamControlParent;
+ using mozilla::dom::FileSystemBase;
+ using mozilla::dom::FileSystemRequestParent;
+ using mozilla::dom::MessagePortParent;
+ using mozilla::dom::PMessagePortParent;
+ using mozilla::dom::UDPSocketParent;
+ using mozilla::dom::WebAuthnTransactionParent;
++using mozilla::AssertIsOnMainThread;
+ 
+ namespace {
+ 
+-void
+-AssertIsOnMainThread()
+-{
+-  MOZ_ASSERT(NS_IsMainThread());
+-}
+-
+ class TestParent final : public mozilla::ipc::PBackgroundTestParent
+ {
+   friend class mozilla::ipc::BackgroundParentImpl;
+ 
+   TestParent()
+   {
+     MOZ_COUNT_CTOR(TestParent);
+   }
+diff --git a/ipc/glue/IPCStreamSource.cpp b/ipc/glue/IPCStreamSource.cpp
+--- a/ipc/glue/IPCStreamSource.cpp
++++ b/ipc/glue/IPCStreamSource.cpp
+@@ -132,17 +132,17 @@ IPCStreamSource::Initialize()
+   // A source can be used on any thread, but we only support IPCStream on
+   // main thread, Workers and PBackground thread right now.  This is due
+   // to the requirement  that the thread be guaranteed to live long enough to
+   // receive messages. We can enforce this guarantee with a WorkerHolder on
+   // worker threads, but not other threads. Main-thread and PBackground thread
+   // do not need anything special in order to be kept alive.
+   WorkerPrivate* workerPrivate = nullptr;
+   if (!NS_IsMainThread()) {
+-    workerPrivate = mozilla::dom::workers::GetCurrentThreadWorkerPrivate();
++    workerPrivate = mozilla::dom::GetCurrentThreadWorkerPrivate();
+     if (workerPrivate) {
+       bool result = HoldWorker(workerPrivate, WorkerStatus::Canceling);
+       if (!result) {
+         return false;
+       }
+ 
+       mWorkerPrivate = workerPrivate;
+     } else {
+diff --git a/js/src/devtools/rootAnalysis/annotations.js b/js/src/devtools/rootAnalysis/annotations.js
+--- a/js/src/devtools/rootAnalysis/annotations.js
++++ b/js/src/devtools/rootAnalysis/annotations.js
+@@ -221,17 +221,17 @@ var ignoreFunctions = {
+ 
+     // This calls any JSObjectMovedOp for the tenured object via an indirect call.
+     "JSObject* js::TenuringTracer::moveToTenuredSlow(JSObject*)" : true,
+ 
+     "void js::Nursery::freeMallocedBuffers()" : true,
+ 
+     "void js::AutoEnterOOMUnsafeRegion::crash(uint64, int8*)" : true,
+ 
+-    "void mozilla::dom::workers::WorkerPrivate::AssertIsOnWorkerThread() const" : true,
++    "void mozilla::dom::WorkerPrivate::AssertIsOnWorkerThread() const" : true,
+ 
+     // It would be cool to somehow annotate that nsTHashtable<T> will use
+     // nsTHashtable<T>::s_MatchEntry for its matchEntry function pointer, but
+     // there is no mechanism for that. So we will just annotate a particularly
+     // troublesome logging-related usage.
+     "EntryType* nsTHashtable<EntryType>::PutEntry(nsTHashtable<EntryType>::KeyType, const fallible_t&) [with EntryType = nsBaseHashtableET<nsCharPtrHashKey, nsAutoPtr<mozilla::LogModule> >; nsTHashtable<EntryType>::KeyType = const char*; nsTHashtable<EntryType>::fallible_t = mozilla::fallible_t]" : true,
+     "EntryType* nsTHashtable<EntryType>::GetEntry(nsTHashtable<EntryType>::KeyType) const [with EntryType = nsBaseHashtableET<nsCharPtrHashKey, nsAutoPtr<mozilla::LogModule> >; nsTHashtable<EntryType>::KeyType = const char*]" : true,
+     "EntryType* nsTHashtable<EntryType>::PutEntry(nsTHashtable<EntryType>::KeyType) [with EntryType = nsBaseHashtableET<nsPtrHashKey<const mozilla::BlockingResourceBase>, nsAutoPtr<mozilla::DeadlockDetector<mozilla::BlockingResourceBase>::OrderingEntry> >; nsTHashtable<EntryType>::KeyType = const mozilla::BlockingResourceBase*]" : true,
+diff --git a/js/xpconnect/src/nsXPConnect.cpp b/js/xpconnect/src/nsXPConnect.cpp
+--- a/js/xpconnect/src/nsXPConnect.cpp
++++ b/js/xpconnect/src/nsXPConnect.cpp
+@@ -1314,27 +1314,25 @@ IsChromeOrXBL(JSContext* cx, JSObject* /
+     // compat and not security for remote XUL, we just always claim to be XBL.
+     //
+     // Note that, for performance, we don't check AllowXULXBLForPrincipal here,
+     // and instead rely on the fact that AllowContentXBLScope() only returns false in
+     // remote XUL situations.
+     return AccessCheck::isChrome(c) || IsContentXBLCompartment(c) || !AllowContentXBLScope(realm);
+ }
+ 
+-namespace workers {
+ extern bool IsCurrentThreadRunningChromeWorker();
+-}
+ 
+ bool
+ ThreadSafeIsChromeOrXBL(JSContext* cx, JSObject* obj)
+ {
+     if (NS_IsMainThread()) {
+         return IsChromeOrXBL(cx, obj);
+     }
+-    return workers::IsCurrentThreadRunningChromeWorker();
++    return IsCurrentThreadRunningChromeWorker();
+ }
+ 
+ } // namespace dom
+ } // namespace mozilla
+ 
+ void
+ xpc::CreateCooperativeContext()
+ {
+diff --git a/xpcom/threads/MainThreadUtils.h b/xpcom/threads/MainThreadUtils.h
+--- a/xpcom/threads/MainThreadUtils.h
++++ b/xpcom/threads/MainThreadUtils.h
+@@ -25,11 +25,25 @@ extern nsresult NS_GetMainThread(nsIThre
+ // AddRef it.  Otherwise, you should only consider this pointer valid from code
+ // running on the current thread.
+ extern nsIThread* NS_GetCurrentThread();
+ #endif
+ 
+ #ifdef MOZILLA_INTERNAL_API
+ bool NS_IsMainThreadTLSInitialized();
+ bool NS_IsMainThread();
++
++namespace mozilla {
++
++#ifdef DEBUG
++void
++AssertIsOnMainThread();
++#else
++inline void
++AssertIsOnMainThread()
++{ }
++#endif
++
++} // mozilla namespace
++
+ #endif
+ 
+ #endif // MainThreadUtils_h_
+diff --git a/xpcom/threads/nsThreadManager.cpp b/xpcom/threads/nsThreadManager.cpp
+--- a/xpcom/threads/nsThreadManager.cpp
++++ b/xpcom/threads/nsThreadManager.cpp
+@@ -71,16 +71,30 @@ NS_UnsetMainThread()
+ {
+   MOZ_ASSERT(Scheduler::IsCooperativeThread());
+ 
+   sTLSIsMainThread.set(false);
+   MOZ_ASSERT(!NS_IsMainThread());
+   gTlsCurrentVirtualThread.set(nullptr);
+ }
+ 
++#ifdef DEBUG
++
++namespace mozilla {
++
++void
++AssertIsOnMainThread()
++{
++  MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!");
++}
++
++} // mozilla namespace
++
++#endif
++
+ typedef nsTArray<NotNull<RefPtr<nsThread>>> nsThreadArray;
+ 
+ //-----------------------------------------------------------------------------
+ 
+ static void
+ ReleaseObject(void* aData)
+ {
+   static_cast<nsISupports*>(aData)->Release();

+ 144 - 0
mozilla-release/patches/1435197-60a1.patch

@@ -0,0 +1,144 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1517589328 -3600
+# Node ID d4054ba468780794d9c207715f3d27a3fe12c6bb
+# Parent  adf271d16489c3d096b98c69115652853ad23df6
+Bug 1435197 - Reduce the number of headers included in WorkerCommon.h, r=smaug
+
+diff --git a/dom/serviceworkers/ServiceWorkerDescriptor.h b/dom/serviceworkers/ServiceWorkerDescriptor.h
+--- a/dom/serviceworkers/ServiceWorkerDescriptor.h
++++ b/dom/serviceworkers/ServiceWorkerDescriptor.h
+@@ -1,16 +1,18 @@
+ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+ /* vim: set ts=8 sts=2 et sw=2 tw=80: */
+ /* 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/. */
+ #ifndef _mozilla_dom_ServiceWorkerDescriptor_h
+ #define _mozilla_dom_ServiceWorkerDescriptor_h
+ 
++#include "nsString.h"
++
+ class nsIPrincipal;
+ 
+ namespace mozilla {
+ 
+ namespace ipc {
+ class PrincipalInfo;
+ } // namespace ipc
+ 
+diff --git a/dom/workers/RuntimeService.h b/dom/workers/RuntimeService.h
+--- a/dom/workers/RuntimeService.h
++++ b/dom/workers/RuntimeService.h
+@@ -8,16 +8,17 @@
+ #define mozilla_dom_workers_runtimeservice_h__
+ 
+ #include "mozilla/dom/WorkerCommon.h"
+ 
+ #include "nsIObserver.h"
+ 
+ #include "mozilla/dom/BindingDeclarations.h"
+ #include "mozilla/dom/workerinternals/JSSettings.h"
++#include "mozilla/Mutex.h"
+ #include "nsClassHashtable.h"
+ #include "nsHashKeys.h"
+ #include "nsTArray.h"
+ 
+ class nsITimer;
+ class nsPIDOMWindowInner;
+ 
+ namespace mozilla {
+diff --git a/dom/workers/WorkerCommon.h b/dom/workers/WorkerCommon.h
+--- a/dom/workers/WorkerCommon.h
++++ b/dom/workers/WorkerCommon.h
+@@ -4,40 +4,23 @@
+  * 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/. */
+ 
+ #ifndef mozilla_dom_workers_WorkerCommon_h
+ #define mozilla_dom_workers_WorkerCommon_h
+ 
+ #include "jsapi.h"
+ #include "mozilla/Attributes.h"
+-#include "mozilla/Maybe.h"
+-#include "mozilla/Mutex.h"
+-#include "nsAutoPtr.h"
+-#include "nsCOMPtr.h"
+-#include "nsString.h"
+-#include "nsTArray.h"
+-
+ #include "mozilla/dom/ServiceWorkerDescriptor.h"
+ 
+-class nsIGlobalObject;
+ class nsPIDOMWindowInner;
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+-// If you change this, the corresponding list in nsIWorkerDebugger.idl needs to
+-// be updated too.
+-enum WorkerType
+-{
+-  WorkerTypeDedicated,
+-  WorkerTypeShared,
+-  WorkerTypeService
+-};
+-
+ class WorkerPrivate;
+ 
+ namespace workers {
+ 
+ // All of these are implemented in RuntimeService.cpp
+ 
+ #ifdef DEBUG
+ void
+diff --git a/dom/workers/WorkerPrivate.h b/dom/workers/WorkerPrivate.h
+--- a/dom/workers/WorkerPrivate.h
++++ b/dom/workers/WorkerPrivate.h
+@@ -5,20 +5,18 @@
+  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+ 
+ #ifndef mozilla_dom_workers_workerprivate_h__
+ #define mozilla_dom_workers_workerprivate_h__
+ 
+ #include "mozilla/dom/WorkerCommon.h"
+ #include "mozilla/CondVar.h"
+ #include "mozilla/DOMEventTargetHelper.h"
+-#include "nsDOMNavigationTiming.h"
+ #include "nsIContentSecurityPolicy.h"
+ #include "nsIEventTarget.h"
+-#include "nsThreadUtils.h"
+ #include "nsTObserverArray.h"
+ 
+ #include "mozilla/dom/WorkerHolder.h"
+ #include "mozilla/dom/WorkerLoadInfo.h"
+ #include "mozilla/dom/workerinternals/JSSettings.h"
+ #include "mozilla/dom/workerinternals/Queue.h"
+ 
+ #ifdef XP_WIN
+@@ -26,16 +24,25 @@
+ #endif
+ 
+ class nsIConsoleReportCollector;
+ class nsIThreadInternal;
+ 
+ namespace mozilla {
+ namespace dom {
+ 
++// If you change this, the corresponding list in nsIWorkerDebugger.idl needs
++// to be updated too.
++enum WorkerType
++{
++  WorkerTypeDedicated,
++  WorkerTypeShared,
++  WorkerTypeService
++};
++
+ class ClientInfo;
+ class ClientSource;
+ class Function;
+ class MessagePort;
+ class MessagePortIdentifier;
+ class PerformanceStorage;
+ class SharedWorker;
+ class WorkerControlRunnable;

+ 34 - 34
mozilla-release/patches/1437554-60a1.patch

@@ -2,7 +2,7 @@
 # User Jon Coppeard <jcoppeard@mozilla.com>
 # Date 1518605653 0
 # Node ID af441cafff7086ffdd0ea8c4700f738fdf3261b9
-# Parent  5692078fecc8d44aa1d8176549d6fbbe8caa5a1d
+# Parent  62cf943c1d23a1b6a71757466d137dd253aeb9f6
 Bug 1437554 - Release the exclusive access lock when not collecting the atoms zone r=sfink
 
 diff --git a/js/src/gc/GCInternals.h b/js/src/gc/GCInternals.h
@@ -41,7 +41,7 @@ diff --git a/js/src/gc/GCInternals.h b/js/src/gc/GCInternals.h
 diff --git a/js/src/gc/GCRuntime.h b/js/src/gc/GCRuntime.h
 --- a/js/src/gc/GCRuntime.h
 +++ b/js/src/gc/GCRuntime.h
-@@ -796,18 +796,18 @@ class GCRuntime
+@@ -788,18 +788,18 @@ class GCRuntime
  
      void runDebugGC();
      void notifyRootsRemoved();
@@ -55,14 +55,14 @@ diff --git a/js/src/gc/GCRuntime.h b/js/src/gc/GCRuntime.h
 +    void traceRuntime(JSTracer* trc, AutoTraceSession& session);
 +    void traceRuntimeForMinorGC(JSTracer* trc, AutoTraceSession& session);
  
-     void notifyDidPaint();
      void shrinkBuffers();
      void onOutOfMallocMemory();
      void onOutOfMallocMemory(const AutoLockGC& lock);
  
  #ifdef JS_GC_ZEAL
      const void* addressOfZealModeBits() { return &zealModeBits; }
-@@ -1061,113 +1061,113 @@ class GCRuntime
+     void getZealBits(uint32_t* zealBits, uint32_t* frequency, uint32_t* nextScheduled);
+@@ -1052,113 +1052,113 @@ class GCRuntime
  
      friend class BackgroundAllocTask;
      bool wantBackgroundAllocation(const AutoLockGC& lock) const;
@@ -223,7 +223,7 @@ diff --git a/js/src/gc/Iteration-inl.h b/js/src/gc/Iteration-inl.h
 diff --git a/js/src/gc/Nursery.cpp b/js/src/gc/Nursery.cpp
 --- a/js/src/gc/Nursery.cpp
 +++ b/js/src/gc/Nursery.cpp
-@@ -803,17 +803,17 @@ js::Nursery::doCollection(JS::gcreason::
+@@ -806,17 +806,17 @@ js::Nursery::doCollection(JS::gcreason::
      sb.traceWholeCells(mover);
      endProfile(ProfileKey::TraceWholeCells);
  
@@ -658,7 +658,7 @@ diff --git a/js/src/gc/Zone.h b/js/src/gc/Zone.h
 diff --git a/js/src/jsfriendapi.cpp b/js/src/jsfriendapi.cpp
 --- a/js/src/jsfriendapi.cpp
 +++ b/js/src/jsfriendapi.cpp
-@@ -1220,17 +1220,17 @@ js::DumpHeap(JSContext* cx, FILE* fp, js
+@@ -1224,17 +1224,17 @@ js::DumpHeap(JSContext* cx, FILE* fp, js
  
      DumpHeapTracer dtrc(fp, cx);
  
@@ -680,7 +680,7 @@ diff --git a/js/src/jsfriendapi.cpp b/js/src/jsfriendapi.cpp
 diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp
 --- a/js/src/jsgc.cpp
 +++ b/js/src/jsgc.cpp
-@@ -2866,17 +2866,17 @@ GCRuntime::updateAllCellPointers(MovingT
+@@ -2851,17 +2851,17 @@ GCRuntime::updateAllCellPointers(MovingT
  /*
   * Update pointers to relocated cells in a single zone by doing a traversal of
   * that zone's arenas and calling per-zone sweep hooks.
@@ -699,7 +699,7 @@ diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp
      MovingTracer trc(rt);
  
      zone->fixupAfterMovingGC();
-@@ -2907,28 +2907,28 @@ GCRuntime::updateZonePointersToRelocated
+@@ -2892,28 +2892,28 @@ GCRuntime::updateZonePointersToRelocated
      for (CompartmentsInZoneIter comp(zone); !comp.done(); comp.next())
          callWeakPointerCompartmentCallbacks(comp);
  }
@@ -730,7 +730,7 @@ diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp
          Debugger::traceIncomingCrossCompartmentEdges(&trc);
  
          // Mark all gray roots, making sure we call the trace callback to get the
-@@ -3975,17 +3975,17 @@ class MOZ_RAII js::gc::AutoRunParallelTa
+@@ -3960,17 +3960,17 @@ class MOZ_RAII js::gc::AutoRunParallelTa
      }
  
      ~AutoRunParallelTask() {
@@ -749,7 +749,7 @@ diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp
  
      for (GCZonesIter zone(rt); !zone.done(); zone.next()) {
          zone->atomCache().clearAndShrink();
-@@ -4295,26 +4295,32 @@ UnmarkCollectedZones(GCParallelTask* tas
+@@ -4280,26 +4280,32 @@ UnmarkCollectedZones(GCParallelTask* tas
  
  static void
  BufferGrayRoots(GCParallelTask* task)
@@ -785,7 +785,7 @@ diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp
          for (GCZonesIter zone(rt); !zone.done(); zone.next())
              zone->arenas.prepareForIncrementalGC();
      }
-@@ -4368,24 +4374,24 @@ GCRuntime::beginMarkPhase(JS::gcreason::
+@@ -4353,24 +4359,24 @@ GCRuntime::beginMarkPhase(JS::gcreason::
           * We must purge the runtime at the beginning of an incremental GC. The
           * danger if we purge later is that the snapshot invariant of
           * incremental GC will be broken, as follows. If some object is
@@ -812,7 +812,7 @@ diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp
  
      /*
       * Process any queued source compressions during the start of a major
-@@ -4575,17 +4581,17 @@ struct GCChunkHasher {
+@@ -4560,17 +4566,17 @@ struct GCChunkHasher {
      }
  };
  
@@ -831,7 +831,7 @@ diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp
  
      typedef HashMap<Chunk*, ChunkBitmap*, GCChunkHasher, SystemAllocPolicy> BitmapMap;
      BitmapMap map;
-@@ -4601,17 +4607,17 @@ js::gc::MarkingValidator::~MarkingValida
+@@ -4586,17 +4592,17 @@ js::gc::MarkingValidator::~MarkingValida
      if (!map.initialized())
          return;
  
@@ -850,7 +850,7 @@ diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp
       * Currently this does not validate gray marking.
       */
  
-@@ -4695,17 +4701,17 @@ js::gc::MarkingValidator::nonIncremental
+@@ -4680,17 +4686,17 @@ js::gc::MarkingValidator::nonIncremental
              for (auto chunk = gc->allNonEmptyChunks(lock); !chunk.done(); chunk.next())
                  chunk->bitmap.clear();
          }
@@ -869,7 +869,7 @@ diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp
  
      gc->incrementalState = State::Sweep;
      {
-@@ -4816,24 +4822,24 @@ js::gc::MarkingValidator::validate()
+@@ -4801,24 +4807,24 @@ js::gc::MarkingValidator::validate()
              }
          }
      }
@@ -896,7 +896,7 @@ diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp
  {
  #ifdef JS_GC_ZEAL
      if (markingValidator)
-@@ -4924,20 +4930,20 @@ JSCompartment::findOutgoingEdges(ZoneCom
+@@ -4909,20 +4915,20 @@ JSCompartment::findOutgoingEdges(ZoneCom
  
  void
  Zone::findOutgoingEdges(ZoneComponentFinder& finder)
@@ -921,7 +921,7 @@ diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp
          if (r.front()->isGCMarking())
              finder.addEdgeTo(r.front());
      }
-@@ -4962,25 +4968,26 @@ GCRuntime::findInterZoneEdges()
+@@ -4947,25 +4953,26 @@ GCRuntime::findInterZoneEdges()
          if (!WeakMapBase::findInterZoneEdges(zone))
              return false;
      }
@@ -950,7 +950,7 @@ diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp
      if (isIncremental && reason == JS::gcreason::DEBUG_GC &&
          hasZealMode(ZealMode::IncrementalSweepThenFinish))
      {
-@@ -5795,45 +5802,45 @@ GCRuntime::endSweepingSweepGroup(FreeOp*
+@@ -5780,45 +5787,45 @@ GCRuntime::endSweepingSweepGroup(FreeOp*
          arenasAllocatedDuringSweep = arena->getNextAllocDuringSweep();
          arena->unsetAllocDuringSweep();
      }
@@ -999,7 +999,7 @@ diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp
      safeToYield = false;
  }
  
-@@ -6497,17 +6504,17 @@ GCRuntime::initSweepActions()
+@@ -6482,17 +6489,17 @@ GCRuntime::initSweepActions()
                          Call(&GCRuntime::sweepShapeTree),
                          Call(&GCRuntime::releaseSweptEmptyArenas))),
                  Call(&GCRuntime::endSweepingSweepGroup)));
@@ -1018,7 +1018,7 @@ diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp
  
      // Drain the mark stack, except in the first sweep slice where we must not
      // yield to the mutator until we've starting sweeping a sweep group.
-@@ -6548,17 +6555,17 @@ GCRuntime::allCCVisibleZonesWereCollecte
+@@ -6533,17 +6540,17 @@ GCRuntime::allCCVisibleZonesWereCollecte
              return false;
          }
      }
@@ -1037,7 +1037,7 @@ diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp
      gcstats::AutoPhase ap(stats(), gcstats::PhaseKind::SWEEP);
      FreeOp fop(rt);
  
-@@ -6638,17 +6645,17 @@ GCRuntime::beginCompactPhase()
+@@ -6623,17 +6630,17 @@ GCRuntime::beginCompactPhase()
      }
  
      MOZ_ASSERT(!relocatedArenasToRelease);
@@ -1056,7 +1056,7 @@ diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp
  
      // TODO: JSScripts can move. If the sampler interrupts the GC in the
      // middle of relocating an arena, invalid JSScript pointers may be
-@@ -6662,28 +6669,28 @@ GCRuntime::compactPhase(JS::gcreason::Re
+@@ -6647,28 +6654,28 @@ GCRuntime::compactPhase(JS::gcreason::Re
  
          Zone* zone = zonesToMaybeCompact.ref().front();
          zonesToMaybeCompact.ref().removeFront();
@@ -1087,7 +1087,7 @@ diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp
          }
          while (!relocatedZones.isEmpty());
      }
-@@ -6764,24 +6771,27 @@ AllNurseriesAreEmpty(JSRuntime* rt)
+@@ -6749,24 +6756,27 @@ AllNurseriesAreEmpty(JSRuntime* rt)
              return false;
      }
      return true;
@@ -1117,7 +1117,7 @@ diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp
      MOZ_ASSERT(JS::CurrentThreadIsHeapBusy());
      TlsContext.get()->heapState = prevState;
  }
-@@ -6802,17 +6812,17 @@ GCRuntime::canChangeActiveContext(JSCont
+@@ -6787,17 +6797,17 @@ GCRuntime::canChangeActiveContext(JSCont
          && !cx->suppressGC
          && !cx->inUnsafeRegion
          && !cx->generationalDisabled
@@ -1136,7 +1136,7 @@ diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp
            return IncrementalResult::Ok;
  
        case State::MarkRoots:
-@@ -6851,17 +6861,17 @@ GCRuntime::resetIncrementalGC(gc::AbortR
+@@ -6836,17 +6846,17 @@ GCRuntime::resetIncrementalGC(gc::AbortR
          /* Finish sweeping the current sweep group, then abort. */
          abortSweepAfterCurrentGroup = true;
  
@@ -1155,7 +1155,7 @@ diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp
              rt->gc.waitBackgroundSweepOrAllocEnd();
          }
          break;
-@@ -6872,40 +6882,40 @@ GCRuntime::resetIncrementalGC(gc::AbortR
+@@ -6857,40 +6867,40 @@ GCRuntime::resetIncrementalGC(gc::AbortR
              gcstats::AutoPhase ap(stats(), gcstats::PhaseKind::WAIT_BACKGROUND_THREAD);
              rt->gc.waitBackgroundSweepOrAllocEnd();
          }
@@ -1199,7 +1199,7 @@ diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp
  
  #ifdef DEBUG
      assertBackgroundSweepingFinished();
-@@ -6987,18 +6997,25 @@ ShouldCleanUpEverything(JS::gcreason::Re
+@@ -6972,18 +6982,25 @@ ShouldCleanUpEverything(JS::gcreason::Re
      // During shutdown, we must clean everything up, for the sake of leak
      // detection. When a runtime has no contexts, or we're doing a GC before a
      // shutdown CC, those are strong indications that we're shutting down.
@@ -1227,7 +1227,7 @@ diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp
  
  #ifdef JS_GC_ZEAL
      /*
-@@ -7033,17 +7050,17 @@ GCRuntime::incrementalCollectSlice(Slice
+@@ -7018,17 +7035,17 @@ GCRuntime::incrementalCollectSlice(Slice
          lastMarkSlice = false;
          rootsRemoved = false;
  
@@ -1246,7 +1246,7 @@ diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp
              pushZealSelectedObjects();
  
          incrementalState = State::Mark;
-@@ -7087,25 +7104,25 @@ GCRuntime::incrementalCollectSlice(Slice
+@@ -7072,25 +7089,25 @@ GCRuntime::incrementalCollectSlice(Slice
               (useZeal && hasZealMode(ZealMode::IncrementalMarkAllThenFinish))))
          {
              lastMarkSlice = true;
@@ -1275,7 +1275,7 @@ diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp
        case State::Finalize:
          {
              gcstats::AutoPhase ap(stats(), gcstats::PhaseKind::WAIT_BACKGROUND_THREAD);
-@@ -7140,17 +7157,17 @@ GCRuntime::incrementalCollectSlice(Slice
+@@ -7125,17 +7142,17 @@ GCRuntime::incrementalCollectSlice(Slice
  
          MOZ_FALLTHROUGH;
  
@@ -1294,7 +1294,7 @@ diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp
          startDecommit();
          incrementalState = State::Decommit;
  
-@@ -7208,50 +7225,50 @@ CheckZoneIsScheduled(Zone* zone, JS::gcr
+@@ -7193,50 +7210,50 @@ CheckZoneIsScheduled(Zone* zone, JS::gcr
      }
      fflush(stderr);
      MOZ_CRASH("Zone not scheduled");
@@ -1349,7 +1349,7 @@ diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp
      }
  
      bool reset = false;
-@@ -7271,17 +7288,17 @@ GCRuntime::budgetIncrementalGC(bool noni
+@@ -7256,17 +7273,17 @@ GCRuntime::budgetIncrementalGC(bool noni
              stats().nonincremental(AbortReason::MallocBytesTrigger);
          }
  
@@ -1368,7 +1368,7 @@ diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp
  
  class AutoScheduleZonesForGC
  {
-@@ -7418,27 +7435,27 @@ GCRuntime::gcCycle(bool nonincrementalBy
+@@ -7402,27 +7419,27 @@ GCRuntime::gcCycle(bool nonincrementalBy
          // for it at the start of every slice.
          allocTask.cancel(GCParallelTask::CancelAndWait);
      }
@@ -1401,7 +1401,7 @@ diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp
 diff --git a/js/src/vm/HelperThreads.cpp b/js/src/vm/HelperThreads.cpp
 --- a/js/src/vm/HelperThreads.cpp
 +++ b/js/src/vm/HelperThreads.cpp
-@@ -2151,18 +2151,26 @@ js::StartOffThreadPromiseHelperTask(Prom
+@@ -2086,18 +2086,26 @@ js::StartOffThreadPromiseHelperTask(Prom
      if (!HelperThreadState().promiseHelperTasks(lock).append(task))
          return false;
  

+ 3 - 3
mozilla-release/patches/1440816-2-60a1.patch

@@ -2,7 +2,7 @@
 # User Kris Maglione <maglione.k@gmail.com>
 # Date 1519435309 28800
 # Node ID b93a9c630a0c9ce75b5fc1a0ab91f3a9adbbab87
-# Parent  ecc9a4c889cf8d5f0c289d09eaa4633f778408e0
+# Parent  6d3615d6bfadde314da283f1de4bb4267b33451b
 Bug 1440816: Part 2 - Clone stacks when sending console messages to the parent process. r=baku
 
 MozReview-Commit-ID: FqK2eZ3JoB2
@@ -80,7 +80,7 @@ diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp
  #include "PreallocatedProcessManager.h"
  #include "ProcessPriorityManager.h"
  #include "SandboxHal.h"
-@@ -3774,24 +3775,80 @@ mozilla::ipc::IPCResult
+@@ -3786,24 +3787,80 @@ mozilla::ipc::IPCResult
  ContentParent::RecvScriptError(const nsString& aMessage,
                                 const nsString& aSourceName,
                                 const nsString& aSourceLine,
@@ -245,6 +245,6 @@ diff --git a/dom/ipc/moz.build b/dom/ipc/moz.build
      '/dom/geolocation',
      '/dom/media/webspeech/synth/ipc',
      '/dom/security',
-     '/dom/workers',
      '/extensions/cookie',
      '/extensions/spellcheck/src',
+     '/gfx/2d',

+ 2 - 2
mozilla-release/patches/1447409-61a1.patch

@@ -2,7 +2,7 @@
 # User Andrea Marchesini <amarchesini@mozilla.com>
 # Date 1521613479 -3600
 # Node ID 93cd9d50d653ab87e0dd8251950176e574c86c8e
-# Parent  a8d0c5801780c5d0d255407b00025dc18aa33d7e
+# Parent  c64b48cff10efb5c39c134a2dbfd4c65b389846a
 Bug 1447409 - DOMPrefs.h must be included in WorkerScope, r=qdot
 
 diff --git a/dom/workers/WorkerScope.h b/dom/workers/WorkerScope.h
@@ -15,7 +15,7 @@ diff --git a/dom/workers/WorkerScope.h b/dom/workers/WorkerScope.h
  #ifndef mozilla_dom_workerscope_h__
  #define mozilla_dom_workerscope_h__
  
- #include "WorkerCommon.h"
+ #include "mozilla/dom/WorkerCommon.h"
  #include "mozilla/DOMEventTargetHelper.h"
 +#include "mozilla/dom/DOMPrefs.h"
  #include "mozilla/dom/Headers.h"

+ 12 - 39
mozilla-release/patches/1449135-3-61a1.patch

@@ -2,7 +2,7 @@
 # User Jan de Mooij <jdemooij@mozilla.com>
 # Date 1522166427 -7200
 # Node ID 678d0894d29131576a16ff9376b6e77479ba98f5
-# Parent  725ed3aedb957d93501728d46616f95c46b45651
+# Parent  4d6b4e68fc246b94d645b3cc6aafa909fcc411e9
 Bug 1449135 part 3 - Remove cooperative scheduling; bake in JSContext* in JIT code. r=luke
 
 diff --git a/js/public/RootingAPI.h b/js/public/RootingAPI.h
@@ -1559,7 +1559,7 @@ diff --git a/js/src/jsfriendapi.cpp b/js/src/jsfriendapi.cpp
 diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp
 --- a/js/src/jsgc.cpp
 +++ b/js/src/jsgc.cpp
-@@ -3285,17 +3285,17 @@ GCRuntime::triggerGC(JS::gcreason::Reaso
+@@ -3270,17 +3270,17 @@ GCRuntime::triggerGC(JS::gcreason::Reaso
       */
      if (!CurrentThreadCanAccessRuntime(rt))
          return false;
@@ -1578,7 +1578,7 @@ diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp
  GCRuntime::maybeAllocTriggerZoneGC(Zone* zone, const AutoLockGC& lock)
  {
      MOZ_ASSERT(!JS::CurrentThreadIsHeapCollecting());
-@@ -3382,17 +3382,17 @@ GCRuntime::triggerZoneGC(Zone* zone, JS:
+@@ -3367,17 +3367,17 @@ GCRuntime::triggerZoneGC(Zone* zone, JS:
  
  void
  GCRuntime::maybeGC(Zone* zone)
@@ -1597,7 +1597,7 @@ diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp
      if (gcIfRequested())
          return;
  
-@@ -3987,21 +3987,20 @@ GCRuntime::purgeRuntime()
+@@ -3972,21 +3972,20 @@ GCRuntime::purgeRuntime()
          comp->purge();
  
      for (GCZonesIter zone(rt); !zone.done(); zone.next()) {
@@ -1623,7 +1623,7 @@ diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp
      if (rt->caches().evalCache.initialized())
          rt->caches().evalCache.clear();
  
-@@ -7065,18 +7064,17 @@ GCRuntime::incrementalCollectSlice(Slice
+@@ -7050,18 +7049,17 @@ GCRuntime::incrementalCollectSlice(Slice
          incrementalState = State::Mark;
  
          if (isIncremental && useZeal && hasZealMode(ZealMode::IncrementalRootsThenFinish))
@@ -1643,7 +1643,7 @@ diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp
              stats().nonincremental(AbortReason::GrayRootBufferingFailed);
          }
  
-@@ -7520,17 +7518,17 @@ GCRuntime::maybeDoCycleCollection()
+@@ -7504,17 +7502,17 @@ GCRuntime::maybeDoCycleCollection()
      for (CompartmentsIter c(rt, SkipAtoms); !c.done(); c.next()) {
          ++compartmentsTotal;
          GlobalObject* global = c->unsafeUnbarrieredMaybeGlobal();
@@ -1662,7 +1662,7 @@ diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp
      MOZ_RELEASE_ASSERT(CurrentThreadCanAccessRuntime(rt));
  
      /* If we attempt to invoke the GC while we are running in the GC, assert. */
-@@ -7608,17 +7606,17 @@ GCRuntime::collect(bool nonincrementalBy
+@@ -7592,17 +7590,17 @@ GCRuntime::collect(bool nonincrementalBy
           *    not collected (see the large comment in beginMarkPhase)
           */
          repeat = false;
@@ -1681,34 +1681,7 @@ diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp
              }
           }
      } while (repeat);
-@@ -7719,24 +7717,24 @@ GCRuntime::notifyDidPaint()
- {
-     MOZ_ASSERT(CurrentThreadCanAccessRuntime(rt));
- 
- #ifdef JS_GC_ZEAL
-     if (hasZealMode(ZealMode::FrameVerifierPre))
-         verifyPreBarriers();
- 
-     if (hasZealMode(ZealMode::FrameGC)) {
--        JS::PrepareForFullGC(rt->activeContextFromOwnThread());
-+        JS::PrepareForFullGC(rt->mainContextFromOwnThread());
-         gc(GC_NORMAL, JS::gcreason::REFRESH_FRAME);
-         return;
-     }
- #endif
- 
-     if (isIncrementalGCInProgress() && !interFrameGC && tunables.areRefreshFrameSlicesEnabled()) {
--        JS::PrepareForIncrementalGC(rt->activeContextFromOwnThread());
-+        JS::PrepareForIncrementalGC(rt->mainContextFromOwnThread());
-         gcSlice(JS::gcreason::REFRESH_FRAME);
-     }
- 
-     interFrameGC = false;
- }
- 
- static bool
- ZonesSelected(JSRuntime* rt)
-@@ -7748,36 +7746,36 @@ ZonesSelected(JSRuntime* rt)
+@@ -7708,36 +7706,36 @@ ZonesSelected(JSRuntime* rt)
      return false;
  }
  
@@ -1748,7 +1721,7 @@ diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp
      // Stop allocating new chunks.
      allocTask.cancel(GCParallelTask::CancelAndWait);
  
-@@ -7940,20 +7938,17 @@ js::NewCompartment(JSContext* cx, JSPrin
+@@ -7900,20 +7898,17 @@ js::NewCompartment(JSContext* cx, JSPrin
          group = rt->gc.systemZoneGroup;
          break;
        case JS::NewZoneInExistingZoneGroup:
@@ -1770,7 +1743,7 @@ diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp
          groupHolder.reset(group);
  
          if (!group->init()) {
-@@ -8013,23 +8008,21 @@ js::NewCompartment(JSContext* cx, JSPrin
+@@ -7973,23 +7968,21 @@ js::NewCompartment(JSContext* cx, JSPrin
              ReportOutOfMemory(cx);
              return nullptr;
          }
@@ -1794,7 +1767,7 @@ diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp
  {
      JSRuntime* rt = source->runtimeFromActiveCooperatingThread();
      rt->gc.mergeCompartments(source, target);
-@@ -8048,17 +8041,17 @@ GCRuntime::mergeCompartments(JSCompartme
+@@ -8008,17 +8001,17 @@ GCRuntime::mergeCompartments(JSCompartme
  
      MOZ_ASSERT(source->creationOptions().addonIdOrNull() ==
                 target->creationOptions().addonIdOrNull());
@@ -1813,7 +1786,7 @@ diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp
  
      // Cleanup tables and other state in the source compartment that will be
      // meaningless after merging into the target compartment.
-@@ -8309,17 +8302,16 @@ void PreventGCDuringInteractiveDebug()
+@@ -8269,17 +8262,16 @@ void PreventGCDuringInteractiveDebug()
  
  #endif
  

File diff suppressed because it is too large
+ 113 - 113
mozilla-release/patches/1465585-3-std-62a1.patch


+ 7 - 7
mozilla-release/patches/1485216-1-66a1.patch

@@ -2,7 +2,7 @@
 # User Nathan Froyd <froydnj@mozilla.com>
 # Date 1548206216 18000
 # Node ID d9cde93070b09b7f78a2d01208ed78cde55db092
-# Parent  e9d49ef7842bdf099a0ccea15d8c48549b01a001
+# Parent  109d05c5693355e44f2165b5e2cd7c28eb29a759
 Bug 1485216 - remove Scheduler and related code from xpcom/threads; r=mccr8
 
 Quantum DOM is no longer a priority, and the extra code it introduces to
@@ -172,7 +172,7 @@ diff --git a/dom/ipc/ContentProcess.cpp b/dom/ipc/ContentProcess.cpp
 diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js
 --- a/modules/libpref/init/all.js
 +++ b/modules/libpref/init/all.js
-@@ -3410,23 +3410,16 @@ pref("dom.ipc.processCount", 4);
+@@ -3411,23 +3411,16 @@ pref("dom.ipc.processCount", 4);
  pref("dom.ipc.processCount.file", 1);
  
  // WebExtensions only support a single extension process.
@@ -1462,10 +1462,10 @@ diff --git a/xpcom/threads/nsThreadManager.cpp b/xpcom/threads/nsThreadManager.c
    gTlsCurrentVirtualThread.set(nullptr);
  }
  
- typedef nsTArray<NotNull<RefPtr<nsThread>>> nsThreadArray;
+ #ifdef DEBUG
  
- //-----------------------------------------------------------------------------
-@@ -121,18 +115,16 @@ nsThreadManager::Init()
+ namespace mozilla {
+@@ -135,18 +129,16 @@ nsThreadManager::Init()
    if (mInitialized) {
      return NS_OK;
    }
@@ -1484,7 +1484,7 @@ diff --git a/xpcom/threads/nsThreadManager.cpp b/xpcom/threads/nsThreadManager.c
  #ifdef MOZ_CANARY
    const int flags = O_WRONLY | O_APPEND | O_CREAT | O_NONBLOCK;
    const mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
-@@ -140,27 +132,19 @@ nsThreadManager::Init()
+@@ -154,27 +146,19 @@ nsThreadManager::Init()
    sCanaryOutputFD =
      env_var_flag ? (env_var_flag[0] ? open(env_var_flag, flags, mode) :
                                        STDERR_FILENO) :
@@ -1515,7 +1515,7 @@ diff --git a/xpcom/threads/nsThreadManager.cpp b/xpcom/threads/nsThreadManager.c
    }
  
    // We need to keep a pointer to the current thread, so we can satisfy
-@@ -168,19 +152,16 @@ nsThreadManager::Init()
+@@ -182,19 +166,16 @@ nsThreadManager::Init()
    mMainThread->GetPRThread(&mMainPRThread);
  
    // Init AbstractThread.

+ 3 - 3
mozilla-release/patches/1575420-70a1.patch

@@ -2,7 +2,7 @@
 # User Mike Hommey <mh+mozilla@glandium.org>
 # Date 1566390342 0
 # Node ID 51bf6a97396d96ddb82fa91c2cf9bd9f5bc9ae06
-# Parent  a1c073995cf932056f6a4ce6eff6fe9e617e4355
+# Parent  4096cc17a03e213a3e13580a6b28c385a62b9a5e
 Bug 1575420 - Replace MOZ_WIDGET_TOOLKIT value of "gtk3" with "gtk". r=froydnj
 
 Differential Revision: https://phabricator.services.mozilla.com/D42765
@@ -956,12 +956,12 @@ diff --git a/gfx/thebes/moz.build b/gfx/thebes/moz.build
      EXPORTS.mozilla.gfx += [
          'PrintTargetPDF.h',
          'PrintTargetPS.h',
-@@ -240,33 +240,33 @@ include('/ipc/chromium/chromium-config.m
+@@ -239,33 +239,33 @@ include('/ipc/chromium/chromium-config.m
+ 
  FINAL_LIBRARY = 'xul'
  
  LOCAL_INCLUDES += [
      '/dom/base',
-     '/dom/workers',
      '/dom/xml',
  ]
  

+ 25 - 0
mozilla-release/patches/series

@@ -57,6 +57,8 @@ NOBUG-20170803-promisehelper-57a1.patch
 1394554-3-57a1.patch
 1396798-1-57a1.patch
 1396798-2-57a1.patch
+1397152-1-57a1.patch
+1397152-2-57a1.patch
 1398691-57a1.patch
 1399699-57a1.patch
 1398692-1-57a1.patch
@@ -71,6 +73,7 @@ NOBUG-20170803-promisehelper-57a1.patch
 1401187-1-58a1.patch
 1401187-2-58a1.patch
 1401146-58a1.patch
+1402504-fix-58a1.patch
 1250832-58a1.patch
 1394559-58a1.patch
 1304328-58a1.patch
@@ -557,6 +560,8 @@ NOBUG-20170803-promisehelper-57a1.patch
 1419301-59a1.patch
 1345433-1-59a1.patch
 1345433-2-59a1.patch
+1421355-5-59a1.patch
+1421355-6-59a1.patch
 1422314-59a1.patch
 1420594-1-59a1.patch
 1420594-2-59a1.patch
@@ -778,6 +783,7 @@ NOBUG-20170803-promisehelper-57a1.patch
 1428447-59a1.patch
 1396434-59a1.patch
 1404853-59a1.patch
+1421358-59a1.patch
 1306892-1-59a1.patch
 1428394-1-59a1.patch
 1428394-2-59a1.patch
@@ -1464,6 +1470,23 @@ servo-19902-60a1.patch
 1425583-1-60a1.patch
 1425583-2-60a1.patch
 1425583-3-60a1.patch
+1432963-01-60a1.patch
+1432963-02-60a1.patch
+1432963-03-60a1.patch
+1432963-04-60a1.patch
+1432963-05-60a1.patch
+1432963-06-60a1.patch
+1432963-07-60a1.patch
+1432963-08-60a1.patch
+1432963-09-60a1.patch
+1432963-10-60a1.patch
+1432963-11-60a1.patch
+1432963-12-60a1.patch
+1432963-13-60a1.patch
+1432963-14-60a1.patch
+1432963-15-60a1.patch
+1432963-16-60a1.patch
+1432963-17-60a1.patch
 1434628-60a1.patch
 1433579-60a1.patch
 servo-19465-60a1.patch
@@ -1618,6 +1641,7 @@ servo-19927-60a1.patch
 1434689-3-60a1.patch
 1434689-4-60a1.patch
 1435219-60a1.patch
+1435197-60a1.patch
 1435262-60a1.patch
 1435015-60a1.patch
 1435200-60a1.patch
@@ -1660,6 +1684,7 @@ NOBUG-20180206-jsgdb-60a1.patch
 1435220-60a1.patch
 1435293-60a1.patch
 1422036-60a1.patch
+1435174-60a1.patch
 1435673-1-60a1.patch
 1435673-2-60a1.patch
 1435673-3-60a1.patch

Some files were not shown because too many files changed in this diff