Browse Source

sync with release and backports

Frank-Rainer Grahl 7 months ago
parent
commit
768abd4658
100 changed files with 8574 additions and 3331 deletions
  1. 7 7
      frg/work-js/mozilla-release/patches/1033916-1-63a1.patch
  2. 66 62
      frg/work-js/mozilla-release/patches/1317481-63a1.patch
  3. 7 7
      frg/work-js/mozilla-release/patches/1414825-2-60a1.patch
  4. 621 0
      frg/work-js/mozilla-release/patches/1419771-01-59a1.patch
  5. 222 0
      frg/work-js/mozilla-release/patches/1419771-02-59a1.patch
  6. 299 0
      frg/work-js/mozilla-release/patches/1419771-03-59a1.patch
  7. 92 0
      frg/work-js/mozilla-release/patches/1419771-04-59a1.patch
  8. 251 0
      frg/work-js/mozilla-release/patches/1419771-05-59a1.patch
  9. 230 0
      frg/work-js/mozilla-release/patches/1419771-06-59a1.patch
  10. 180 0
      frg/work-js/mozilla-release/patches/1419771-07-59a1.patch
  11. 317 0
      frg/work-js/mozilla-release/patches/1419771-08-59a1.patch
  12. 209 0
      frg/work-js/mozilla-release/patches/1419771-09-59a1.patch
  13. 204 0
      frg/work-js/mozilla-release/patches/1419771-10-59a1.patch
  14. 168 0
      frg/work-js/mozilla-release/patches/1419771-11-59a1.patch
  15. 378 0
      frg/work-js/mozilla-release/patches/1419771-12-59a1.patch
  16. 169 0
      frg/work-js/mozilla-release/patches/1419771-13-59a1.patch
  17. 170 0
      frg/work-js/mozilla-release/patches/1419771-14-59a1.patch
  18. 228 0
      frg/work-js/mozilla-release/patches/1419771-15-59a1.patch
  19. 443 0
      frg/work-js/mozilla-release/patches/1419771-16-59a1.patch
  20. 175 0
      frg/work-js/mozilla-release/patches/1419771-17-59a1.patch
  21. 191 0
      frg/work-js/mozilla-release/patches/1419771-18-59a1.patch
  22. 227 0
      frg/work-js/mozilla-release/patches/1419771-19-59a1.patch
  23. 185 0
      frg/work-js/mozilla-release/patches/1419771-20-59a1.patch
  24. 577 0
      frg/work-js/mozilla-release/patches/1419771-21-59a1.patch
  25. 417 0
      frg/work-js/mozilla-release/patches/1419771-22-59a1.patch
  26. 28 0
      frg/work-js/mozilla-release/patches/1419771-24-59a1.patch
  27. 3 3
      frg/work-js/mozilla-release/patches/1425965-1-59a1.patch
  28. 18 18
      frg/work-js/mozilla-release/patches/1428685-59a1.patch
  29. 3 3
      frg/work-js/mozilla-release/patches/1439063-1-60a1.patch
  30. 28 0
      frg/work-js/mozilla-release/patches/1447409-61a1.patch
  31. 0 0
      frg/work-js/mozilla-release/patches/1458382-1-61a1.patch
  32. 0 0
      frg/work-js/mozilla-release/patches/1461386-63a1.patch
  33. 1 1
      frg/work-js/mozilla-release/patches/1465585-2-std-62a1.patch
  34. 54 54
      frg/work-js/mozilla-release/patches/1465585-3-std-62a1.patch
  35. 0 0
      frg/work-js/mozilla-release/patches/1469965-63a1.patch
  36. 0 0
      frg/work-js/mozilla-release/patches/1473523-1-63a1.patch
  37. 0 0
      frg/work-js/mozilla-release/patches/1473523-2-63a1.patch
  38. 0 0
      frg/work-js/mozilla-release/patches/1475446-63a1.patch
  39. 0 0
      frg/work-js/mozilla-release/patches/1476417-63a1.patch
  40. 0 0
      frg/work-js/mozilla-release/patches/1478126-63a1.patch
  41. 1 1
      frg/work-js/mozilla-release/patches/1478393-1-63a1.patch
  42. 1 1
      frg/work-js/mozilla-release/patches/1478393-2-63a1.patch
  43. 48 76
      frg/work-js/mozilla-release/patches/1478404-63a1.patch
  44. 0 0
      frg/work-js/mozilla-release/patches/1478854-63a1.patch
  45. 0 0
      frg/work-js/mozilla-release/patches/1478879-1-63a1.patch
  46. 449 0
      frg/work-js/mozilla-release/patches/1478879-2-63a1.patch
  47. 217 0
      frg/work-js/mozilla-release/patches/1478879-3-63a1.patch
  48. 0 0
      frg/work-js/mozilla-release/patches/1478879-4-63a1.patch
  49. 229 0
      frg/work-js/mozilla-release/patches/1478879-5-63a1.patch
  50. 32 0
      frg/work-js/mozilla-release/patches/1478879-7-63a1.patch
  51. 0 0
      frg/work-js/mozilla-release/patches/1478879-8-63a1.patch
  52. 4 4
      frg/work-js/mozilla-release/patches/1478879-9-63a1.patch
  53. 586 182
      frg/work-js/mozilla-release/patches/1478896-63a1.patch
  54. 0 0
      frg/work-js/mozilla-release/patches/1478902-1-63a1.patch
  55. 0 0
      frg/work-js/mozilla-release/patches/1478902-2-63a1.patch
  56. 0 0
      frg/work-js/mozilla-release/patches/1478902-3-63a1.patch
  57. 0 0
      frg/work-js/mozilla-release/patches/1479360-63a1.patch
  58. 1 1
      frg/work-js/mozilla-release/patches/1479388-63a1.patch
  59. 0 0
      frg/work-js/mozilla-release/patches/1479718-63a1.patch
  60. 6 6
      frg/work-js/mozilla-release/patches/1479900-2-63a1.patch
  61. 0 0
      frg/work-js/mozilla-release/patches/1479954-63a1.patch
  62. 0 0
      frg/work-js/mozilla-release/patches/1480012-63a1.patch
  63. 0 0
      frg/work-js/mozilla-release/patches/1480018-63a1.patch
  64. 0 0
      frg/work-js/mozilla-release/patches/1480020-63a1.patch
  65. 0 0
      frg/work-js/mozilla-release/patches/1480077-63a1.patch
  66. 0 0
      frg/work-js/mozilla-release/patches/1480233-63a1.patch
  67. 0 0
      frg/work-js/mozilla-release/patches/1480991-63a1.patch
  68. 2 2
      frg/work-js/mozilla-release/patches/1482931-1-63a1.patch
  69. 6 6
      frg/work-js/mozilla-release/patches/1483275-1-63a1.patch
  70. 4 4
      frg/work-js/mozilla-release/patches/1484421-63a1.patch
  71. 5 4
      frg/work-js/mozilla-release/patches/1486577-6-63a1.patch
  72. 2 2
      frg/work-js/mozilla-release/patches/1486577-8-63a1.patch
  73. 7 7
      frg/work-js/mozilla-release/patches/1486730-63a1.patch
  74. 377 78
      frg/work-js/mozilla-release/patches/1488698-7-WIP-64a1.patch
  75. 5 17
      frg/work-js/mozilla-release/patches/1489698-5-65a1.patch
  76. 72 0
      frg/work-js/mozilla-release/patches/1495573-64a1.patch
  77. 256 0
      frg/work-js/mozilla-release/patches/1502889-65a1.patch
  78. 30 0
      frg/work-js/mozilla-release/patches/1517237-66a1.patch
  79. 4 4
      frg/work-js/mozilla-release/patches/1730156-913.patch
  80. 46 0
      frg/work-js/mozilla-release/patches/1871112-124a1.patch
  81. 5 5
      frg/work-js/mozilla-release/patches/888600-1only-61a1.patch
  82. 0 0
      frg/work-js/mozilla-release/patches/NOBUG-20180731-jorendb-63a1.patch
  83. 10 10
      frg/work-js/mozilla-release/patches/TOP-NOBUG-JSFIXUPS-25319.patch
  84. 1 1
      frg/work-js/mozilla-release/patches/mozilla-central-push_427183.patch
  85. 0 70
      frg/work-js/mozilla-release/patches/mozilla-central-push_429300.patch
  86. 0 56
      frg/work-js/mozilla-release/patches/mozilla-central-push_429301.patch
  87. 0 30
      frg/work-js/mozilla-release/patches/mozilla-central-push_429302.patch
  88. 0 157
      frg/work-js/mozilla-release/patches/mozilla-central-push_429303.patch
  89. 0 92
      frg/work-js/mozilla-release/patches/mozilla-central-push_429304.patch
  90. 0 30
      frg/work-js/mozilla-release/patches/mozilla-central-push_429305.patch
  91. 0 45
      frg/work-js/mozilla-release/patches/mozilla-central-push_429307.patch
  92. 0 364
      frg/work-js/mozilla-release/patches/mozilla-central-push_429308.patch
  93. 0 32
      frg/work-js/mozilla-release/patches/mozilla-central-push_429309.patch
  94. 0 142
      frg/work-js/mozilla-release/patches/mozilla-central-push_429310.patch
  95. 0 90
      frg/work-js/mozilla-release/patches/mozilla-central-push_429314.patch
  96. 0 91
      frg/work-js/mozilla-release/patches/mozilla-central-push_429315.patch
  97. 0 818
      frg/work-js/mozilla-release/patches/mozilla-central-push_429316.patch
  98. 0 263
      frg/work-js/mozilla-release/patches/mozilla-central-push_429317.patch
  99. 0 72
      frg/work-js/mozilla-release/patches/mozilla-central-push_429318.patch
  100. 0 413
      frg/work-js/mozilla-release/patches/mozilla-central-push_429320.patch

+ 7 - 7
frg/work-js/mozilla-release/patches/1033916-1-63a1.patch

@@ -2,7 +2,7 @@
 # User Jeff Walden <jwalden@mit.edu>
 # Date 1534776368 25200
 # Node ID 67d5039dcbc2522e187bcf3dbec1c6e92bd32167
-# Parent  b7c1999a90c62bac529b6e8122428b84d0ed60e8
+# Parent  4747226f3acc079743e8d98e52d29fd32ca528e9
 Bug 1033916 - Move JSAutoByteString out of jsapi.h into js/public/AutoByteString.h, incidentally breaking the jsfriendapi.h -> jsapi.h dependency.  r=jandem
 
 diff --git a/dom/base/ChromeUtils.cpp b/dom/base/ChromeUtils.cpp
@@ -510,7 +510,7 @@ diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp
 diff --git a/js/src/jsapi.h b/js/src/jsapi.h
 --- a/js/src/jsapi.h
 +++ b/js/src/jsapi.h
-@@ -4514,29 +4514,16 @@ JS_ConcatStrings(JSContext* cx, JS::Hand
+@@ -4542,29 +4542,16 @@ JS_ConcatStrings(JSContext* cx, JS::Hand
   * NB: This function does not store an additional zero byte or char16_t after the
   * transcoded string.
   */
@@ -540,7 +540,7 @@ diff --git a/js/src/jsapi.h b/js/src/jsapi.h
  JS_GetStringEncodingLength(JSContext* cx, JSString* str);
  
  /**
-@@ -4545,85 +4532,16 @@ JS_GetStringEncodingLength(JSContext* cx
+@@ -4573,85 +4560,16 @@ JS_GetStringEncodingLength(JSContext* cx
   * encoded into bytes with no error reported. Otherwise it returns the number
   * of bytes that are necessary to encode the string. If that exceeds the
   * length parameter, the string will be cut and only length bytes will be
@@ -885,9 +885,9 @@ diff --git a/js/src/vm/ErrorObject.cpp b/js/src/vm/ErrorObject.cpp
 diff --git a/js/src/vm/Interpreter.cpp b/js/src/vm/Interpreter.cpp
 --- a/js/src/vm/Interpreter.cpp
 +++ b/js/src/vm/Interpreter.cpp
-@@ -25,16 +25,17 @@
- #include "builtin/Eval.h"
+@@ -26,16 +26,17 @@
  #include "builtin/ModuleObject.h"
+ #include "builtin/Promise.h"
  #include "builtin/String.h"
  #include "jit/AtomicOperations.h"
  #include "jit/BaselineJIT.h"
@@ -1096,7 +1096,7 @@ diff --git a/js/src/vm/SelfHosting.cpp b/js/src/vm/SelfHosting.cpp
 diff --git a/js/src/vm/StringType.cpp b/js/src/vm/StringType.cpp
 --- a/js/src/vm/StringType.cpp
 +++ b/js/src/vm/StringType.cpp
-@@ -14,16 +14,17 @@
+@@ -15,16 +15,17 @@
  #include "mozilla/RangedPtr.h"
  #include "mozilla/TextUtils.h"
  #include "mozilla/TypeTraits.h"
@@ -1180,7 +1180,7 @@ diff --git a/js/src/vm/Xdr.h b/js/src/vm/Xdr.h
 diff --git a/js/src/wasm/AsmJS.cpp b/js/src/wasm/AsmJS.cpp
 --- a/js/src/wasm/AsmJS.cpp
 +++ b/js/src/wasm/AsmJS.cpp
-@@ -27,16 +27,17 @@
+@@ -28,16 +28,17 @@
  
  #include "jsmath.h"
  #include "jsutil.h"

+ 66 - 62
frg/work-js/mozilla-release/patches/mozilla-central-push_429848.patch → frg/work-js/mozilla-release/patches/1317481-63a1.patch

@@ -3,17 +3,17 @@
 # Date 1533193917 -32400
 #      Thu Aug 02 16:11:57 2018 +0900
 # Node ID 4c59bddb1d688cdb22523317833df797c1a20ccd
-# Parent  c459ea4efa8de9509f43a6b341a6ca86f0f708de
+# Parent  714793fd44b5300514fa1abcb78833fb334d2003
 Bug 1317481 - Optimize away Generator/Promise handling for await in the topmost JS frame with already resolved/rejected Promise. r=anba,smaug
 
 diff --git a/dom/workers/RuntimeService.cpp b/dom/workers/RuntimeService.cpp
 --- a/dom/workers/RuntimeService.cpp
 +++ b/dom/workers/RuntimeService.cpp
-@@ -1134,16 +1134,17 @@ public:
+@@ -1155,16 +1155,17 @@ public:
+     if (IsWorkerGlobal(global)) {
        microTaskQueue = &GetMicroTaskQueue();
      } else {
-       MOZ_ASSERT(IsWorkerDebuggerGlobal(global) ||
-                  IsWorkerDebuggerSandbox(global));
+       MOZ_ASSERT(IsDebuggerGlobal(global) || IsDebuggerSandbox(global));
  
        microTaskQueue = &GetDebuggerMicroTaskQueue();
      }
@@ -22,47 +22,51 @@ diff --git a/dom/workers/RuntimeService.cpp b/dom/workers/RuntimeService.cpp
      microTaskQueue->push(runnable.forget());
    }
  
-   bool IsSystemCaller() const override
-   {
-     return mWorkerPrivate->UsesSystemPrincipal();
-   }
- 
-diff --git a/dom/worklet/WorkletThread.cpp b/dom/worklet/WorkletThread.cpp
---- a/dom/worklet/WorkletThread.cpp
-+++ b/dom/worklet/WorkletThread.cpp
-@@ -166,30 +166,31 @@ public:
-     return NS_OK;
-   }
- 
-   void
-   DispatchToMicroTask(already_AddRefed<MicroTaskRunnable> aRunnable) override
-   {
-     RefPtr<MicroTaskRunnable> runnable(aRunnable);
- 
--#ifdef DEBUG
-     MOZ_ASSERT(!NS_IsMainThread());
-     MOZ_ASSERT(runnable);
- 
-     WorkletThread* workletThread = WorkletThread::Get();
-     MOZ_ASSERT(workletThread);
- 
-     JSContext* cx = workletThread->GetJSContext();
-     MOZ_ASSERT(cx);
- 
-+#ifdef DEBUG
-     JS::Rooted<JSObject*> global(cx, JS::CurrentGlobalOrNull(cx));
-     MOZ_ASSERT(global);
- #endif
- 
-+    JS::JobQueueMayNotBeEmpty(cx);
-     GetMicroTaskQueue().push(runnable.forget());
-   }
- 
-   WorkletThread* GetWorkletThread() const
-   {
-     return mWorkletThread;
-   }
+ private:
+   WorkerPrivate* mWorkerPrivate;
+ };
  
+ class WorkerThreadPrimaryRunnable final : public Runnable
+diff --git a/dom/worklet/WorkletThread.cpp.1317481.later b/dom/worklet/WorkletThread.cpp.1317481.later
+new file mode 100644
+--- /dev/null
++++ b/dom/worklet/WorkletThread.cpp.1317481.later
+@@ -0,0 +1,35 @@
++--- WorkletThread.cpp
+++++ WorkletThread.cpp
++@@ -166,30 +166,31 @@ public:
++     return NS_OK;
++   }
++ 
++   void
++   DispatchToMicroTask(already_AddRefed<MicroTaskRunnable> aRunnable) override
++   {
++     RefPtr<MicroTaskRunnable> runnable(aRunnable);
++ 
++-#ifdef DEBUG
++     MOZ_ASSERT(!NS_IsMainThread());
++     MOZ_ASSERT(runnable);
++ 
++     WorkletThread* workletThread = WorkletThread::Get();
++     MOZ_ASSERT(workletThread);
++ 
++     JSContext* cx = workletThread->GetJSContext();
++     MOZ_ASSERT(cx);
++ 
+++#ifdef DEBUG
++     JS::Rooted<JSObject*> global(cx, JS::CurrentGlobalOrNull(cx));
++     MOZ_ASSERT(global);
++ #endif
++ 
+++    JS::JobQueueMayNotBeEmpty(cx);
++     GetMicroTaskQueue().push(runnable.forget());
++   }
++ 
++   WorkletThread* GetWorkletThread() const
++   {
++     return mWorkletThread;
++   }
++ 
 diff --git a/js/public/Value.h b/js/public/Value.h
 --- a/js/public/Value.h
 +++ b/js/public/Value.h
@@ -108,7 +112,7 @@ diff --git a/js/src/builtin/Promise.cpp b/js/src/builtin/Promise.cpp
  
  using namespace js;
  
-@@ -4385,16 +4387,107 @@ js::PromiseLookup::isDefaultInstance(JSC
+@@ -4367,16 +4369,107 @@ js::PromiseLookup::isDefaultInstance(JSC
      // Promise and Promise.prototype must be in their default states.
      if (!ensureInitialized(cx, reinitialize))
          return false;
@@ -245,7 +249,7 @@ diff --git a/js/src/builtin/Promise.h b/js/src/builtin/Promise.h
 diff --git a/js/src/frontend/BytecodeEmitter.cpp b/js/src/frontend/BytecodeEmitter.cpp
 --- a/js/src/frontend/BytecodeEmitter.cpp
 +++ b/js/src/frontend/BytecodeEmitter.cpp
-@@ -6063,20 +6063,36 @@ BytecodeEmitter::emitAwaitInInnermostSco
+@@ -6067,20 +6067,36 @@ BytecodeEmitter::emitAwaitInInnermostSco
      if (!emitTree(pn->pn_kid))
          return false;
      return emitAwaitInInnermostScope();
@@ -288,7 +292,7 @@ diff --git a/js/src/frontend/BytecodeEmitter.cpp b/js/src/frontend/BytecodeEmitt
 diff --git a/js/src/jit/BaselineCompiler.cpp b/js/src/jit/BaselineCompiler.cpp
 --- a/js/src/jit/BaselineCompiler.cpp
 +++ b/js/src/jit/BaselineCompiler.cpp
-@@ -1027,17 +1027,16 @@ BaselineCompiler::emitBody()
+@@ -1016,17 +1016,16 @@ BaselineCompiler::emitBody()
          switch (op) {
            // ===== NOT Yet Implemented =====
            case JSOP_FORCEINTERPRETER:
@@ -306,7 +310,7 @@ diff --git a/js/src/jit/BaselineCompiler.cpp b/js/src/jit/BaselineCompiler.cpp
              return Method_CantCompile;
  
  #define EMIT_OP(OP)                            \
-@@ -4117,16 +4116,48 @@ BaselineCompiler::emit_JSOP_TOASYNCITER(
+@@ -4102,16 +4101,48 @@ BaselineCompiler::emit_JSOP_TOASYNCITER(
          return false;
  
      masm.tagValue(JSVAL_TYPE_OBJECT, ReturnReg, R0);
@@ -379,7 +383,7 @@ diff --git a/js/src/jit/BaselineCompiler.h b/js/src/jit/BaselineCompiler.h
 diff --git a/js/src/jit/IonBuilder.cpp b/js/src/jit/IonBuilder.cpp
 --- a/js/src/jit/IonBuilder.cpp
 +++ b/js/src/jit/IonBuilder.cpp
-@@ -2448,16 +2448,17 @@ IonBuilder::inspectOpcode(JSOp op)
+@@ -2431,16 +2431,17 @@ IonBuilder::inspectOpcode(JSOp op)
        case JSOP_THROWING:
        case JSOP_ISGENCLOSING:
        case JSOP_INITIALYIELD:
@@ -397,7 +401,7 @@ diff --git a/js/src/jit/IonBuilder.cpp b/js/src/jit/IonBuilder.cpp
        case JSOP_GETRVAL:
        case JSOP_GOSUB:
        case JSOP_RETSUB:
-@@ -2469,17 +2470,16 @@ IonBuilder::inspectOpcode(JSOp op)
+@@ -2452,17 +2453,16 @@ IonBuilder::inspectOpcode(JSOp op)
          break;
  
        case JSOP_FORCEINTERPRETER:
@@ -490,7 +494,7 @@ diff --git a/js/src/jit/VMFunctions.h b/js/src/jit/VMFunctions.h
 diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp
 --- a/js/src/jsapi.cpp
 +++ b/js/src/jsapi.cpp
-@@ -4990,16 +4990,28 @@ JS::SetEnqueuePromiseJobCallback(JSConte
+@@ -4932,16 +4932,28 @@ JS::SetEnqueuePromiseJobCallback(JSConte
  extern JS_PUBLIC_API(void)
  JS::SetPromiseRejectionTrackerCallback(JSContext* cx, JSPromiseRejectionTrackerCallback callback,
                                         void* data /* = nullptr */)
@@ -522,7 +526,7 @@ diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp
 diff --git a/js/src/jsapi.h b/js/src/jsapi.h
 --- a/js/src/jsapi.h
 +++ b/js/src/jsapi.h
-@@ -4056,16 +4056,44 @@ SetEnqueuePromiseJobCallback(JSContext* 
+@@ -3993,16 +3993,44 @@ SetEnqueuePromiseJobCallback(JSContext* 
   * a rejection handler, and when a Promise that was previously rejected
   * without a handler gets a handler attached.
   */
@@ -606,7 +610,7 @@ diff --git a/js/src/vm/Interpreter.cpp b/js/src/vm/Interpreter.cpp
  
  CASE(JSOP_TRY)
  CASE(JSOP_JUMPTARGET)
-@@ -3823,16 +3823,34 @@ CASE(JSOP_TOASYNCITER)
+@@ -3821,16 +3821,34 @@ CASE(JSOP_TOASYNCITER)
      if (!asyncIter)
          goto error;
  
@@ -644,7 +648,7 @@ diff --git a/js/src/vm/Interpreter.cpp b/js/src/vm/Interpreter.cpp
 diff --git a/js/src/vm/JSContext.cpp b/js/src/vm/JSContext.cpp
 --- a/js/src/vm/JSContext.cpp
 +++ b/js/src/vm/JSContext.cpp
-@@ -1040,16 +1040,17 @@ JSContext::recoverFromOutOfMemory()
+@@ -1038,16 +1038,17 @@ JSContext::recoverFromOutOfMemory()
  }
  
  static bool
@@ -662,7 +666,7 @@ diff --git a/js/src/vm/JSContext.cpp b/js/src/vm/JSContext.cpp
  }
  
  namespace {
-@@ -1093,16 +1094,17 @@ js::UseInternalJobQueues(JSContext* cx)
+@@ -1091,16 +1092,17 @@ js::UseInternalJobQueues(JSContext* cx)
  
      return true;
  }
@@ -680,7 +684,7 @@ diff --git a/js/src/vm/JSContext.cpp b/js/src/vm/JSContext.cpp
      return true;
  }
  
-@@ -1148,16 +1150,22 @@ js::RunJobs(JSContext* cx)
+@@ -1146,16 +1148,22 @@ js::RunJobs(JSContext* cx)
              // It's possible that queue draining was interrupted prematurely,
              // leaving the queue partly processed. In that case, slots for
              // already-executed entries will contain nullptrs, which we should
@@ -703,7 +707,7 @@ diff --git a/js/src/vm/JSContext.cpp b/js/src/vm/JSContext.cpp
                          continue;
                      RootedValue exn(cx);
                      if (cx->getPendingException(&exn)) {
-@@ -1291,16 +1299,17 @@ JSContext::JSContext(JSRuntime* runtime,
+@@ -1289,16 +1297,17 @@ JSContext::JSContext(JSRuntime* runtime,
      jitStackLimit(UINTPTR_MAX),
      jitStackLimitNoInterrupt(UINTPTR_MAX),
      getIncumbentGlobalCallback(nullptr),
@@ -724,7 +728,7 @@ diff --git a/js/src/vm/JSContext.cpp b/js/src/vm/JSContext.cpp
 diff --git a/js/src/vm/JSContext.h b/js/src/vm/JSContext.h
 --- a/js/src/vm/JSContext.h
 +++ b/js/src/vm/JSContext.h
-@@ -914,16 +914,17 @@ struct JSContext : public JS::RootingCon
+@@ -910,16 +910,17 @@ struct JSContext : public JS::RootingCon
      js::ThreadData<void*> enqueuePromiseJobCallbackData;
  
      // Queue of pending jobs as described in ES2016 section 8.4.
@@ -745,7 +749,7 @@ diff --git a/js/src/vm/JSContext.h b/js/src/vm/JSContext.h
 diff --git a/js/src/vm/Opcodes.h b/js/src/vm/Opcodes.h
 --- a/js/src/vm/Opcodes.h
 +++ b/js/src/vm/Opcodes.h
-@@ -2263,17 +2263,28 @@ 1234567890123456789012345678901234567890
+@@ -2272,17 +2272,28 @@ 1234567890123456789012345678901234567890
      /*
       * NOP opcode to hint to IonBuilder that the value on top of the stack is
       * the (likely string) key in a for-in loop.
@@ -796,7 +800,7 @@ diff --git a/xpcom/base/CycleCollectedJSContext.cpp b/xpcom/base/CycleCollectedJ
  #include "nsCycleCollectionParticipant.h"
  #include "nsCycleCollector.h"
  #include "nsDOMJSUtils.h"
-@@ -482,16 +483,17 @@ void
+@@ -462,16 +463,17 @@ void
  CycleCollectedJSContext::DispatchToMicroTask(
      already_AddRefed<MicroTaskRunnable> aRunnable)
  {
@@ -814,7 +818,7 @@ diff --git a/xpcom/base/CycleCollectedJSContext.cpp b/xpcom/base/CycleCollectedJ
  public:
    AsyncMutationHandler() : mozilla::Runnable("AsyncMutationHandler") {}
  
-@@ -552,18 +554,23 @@ CycleCollectedJSContext::PerformMicroTas
+@@ -532,18 +534,23 @@ CycleCollectedJSContext::PerformMicroTas
        break;
      }
  
@@ -838,7 +842,7 @@ diff --git a/xpcom/base/CycleCollectedJSContext.cpp b/xpcom/base/CycleCollectedJ
    // Put back the suppressed microtasks so that they will be run later.
    // Note, it is possible that we end up keeping these suppressed tasks around
    // for some time, but no longer than spinning the event loop nestedly
-@@ -592,14 +599,18 @@ CycleCollectedJSContext::PerformDebugger
+@@ -572,14 +579,18 @@ CycleCollectedJSContext::PerformDebugger
        break;
      }
  

+ 7 - 7
frg/work-js/mozilla-release/patches/1414825-2-60a1.patch

@@ -2,13 +2,13 @@
 # User Timothy Nikkel <tnikkel@gmail.com>
 # Date 1517907201 21600
 # Node ID 67a2b6b463e61e096dad2a5313c6307a6e42a8f1
-# Parent  3351c2e735a054e9124dc13f4823335d8071546e
+# Parent  3e33664bd5d10ca12191307d373ad56d05f14593
 Bug 1414825. Clear mDataWrapper on ImageBitmap::Close because it holds gfx resources alive. r=nical
 
 diff --git a/dom/canvas/ImageBitmap.cpp b/dom/canvas/ImageBitmap.cpp
 --- a/dom/canvas/ImageBitmap.cpp
 +++ b/dom/canvas/ImageBitmap.cpp
-@@ -544,16 +544,17 @@ ImageBitmap::WrapObject(JSContext* aCx, 
+@@ -545,16 +545,17 @@ ImageBitmap::WrapObject(JSContext* aCx, 
    return ImageBitmapBinding::Wrap(aCx, this, aGivenProto);
  }
  
@@ -26,8 +26,8 @@ diff --git a/dom/canvas/ImageBitmap.cpp b/dom/canvas/ImageBitmap.cpp
  {
    mShutdownObserver = nullptr;
  
-@@ -1580,17 +1581,20 @@ ImageBitmap::ExtensionsEnabled(JSContext
-   }
+@@ -1569,17 +1570,20 @@ ImageBitmap::WriteStructuredClone(JSStru
+   return true;
  }
  
  // ImageBitmap extensions.
@@ -48,7 +48,7 @@ diff --git a/dom/canvas/ImageBitmap.cpp b/dom/canvas/ImageBitmap.cpp
      return platformFormat;
    } else {
      // If no matching is found, FindBestMatchingFromat() returns
-@@ -1604,17 +1608,20 @@ ImageBitmap::FindOptimalFormat(const Opt
+@@ -1593,17 +1597,20 @@ ImageBitmap::FindOptimalFormat(const Opt
  
      return optimalFormat;
    }
@@ -70,7 +70,7 @@ diff --git a/dom/canvas/ImageBitmap.cpp b/dom/canvas/ImageBitmap.cpp
    }
  }
  
-@@ -1640,16 +1647,22 @@ protected:
+@@ -1629,16 +1636,22 @@ protected:
    }
  
    virtual ~MapDataIntoBufferSource() = default;
@@ -93,7 +93,7 @@ diff --git a/dom/canvas/ImageBitmap.cpp b/dom/canvas/ImageBitmap.cpp
        js::GetArrayBufferLengthAndData(mBuffer, &bufferLength, &isSharedMemory, &bufferData);
      } else if (JS_IsArrayBufferViewObject(mBuffer)) {
        js::GetArrayBufferViewLengthAndData(mBuffer, &bufferLength, &isSharedMemory, &bufferData);
-@@ -1792,25 +1805,30 @@ void AsyncMapDataIntoBufferSource(JSCont
+@@ -1781,25 +1794,30 @@ void AsyncMapDataIntoBufferSource(JSCont
  }
  
  already_AddRefed<Promise>

+ 621 - 0
frg/work-js/mozilla-release/patches/1419771-01-59a1.patch

@@ -0,0 +1,621 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1515416703 -3600
+# Node ID 83a53b3e6edccd6e59d379d243122675d46a262d
+# Parent  fba81155b0e2b9dcf2aef033b209e7aea45b0507
+Bug 1419771 - Introduce DOMPrefs, a thread-safe access to preferences for DOM - part 1 - dump enabled, r=asuth
+
+diff --git a/dom/base/DOMPrefs.cpp b/dom/base/DOMPrefs.cpp
+new file mode 100644
+--- /dev/null
++++ b/dom/base/DOMPrefs.cpp
+@@ -0,0 +1,51 @@
++/* -*- 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 "DOMPrefs.h"
++#include "mozilla/Atomics.h"
++#include "mozilla/Preferences.h"
++
++namespace mozilla {
++namespace dom {
++
++#define PREF(name, pref)                                             \
++  /* static */ bool                                                  \
++  DOMPrefs::name()                                                   \
++  {                                                                  \
++    static bool initialized = false;                                 \
++    static Atomic<bool> cachedValue;                                 \
++    if (!initialized) {                                              \
++      initialized = true;                                            \
++      Preferences::AddAtomicBoolVarCache(&cachedValue, pref, false); \
++    }                                                                \
++    return cachedValue;                                              \
++  }
++
++#if !(defined(DEBUG) || defined(MOZ_ENABLE_JS_DUMP))
++PREF(DumpEnabled, "browser.dom.window.dump.enabled")
++#else
++/* static */ bool
++DOMPrefs::DumpEnabled()
++{
++  return true;
++}
++#endif
++
++#undef PREF
++
++#define PREF_WEBIDL(name)                        \
++  /* static */ bool                              \
++  DOMPrefs::name(JSContext* aCx, JSObject* aObj) \
++  {                                              \
++    return DOMPrefs::name();                     \
++  }
++
++// It will be useful, eventually.
++
++#undef PREF_WEBIDL
++
++} // dom namespace
++} // mozilla namespace
+diff --git a/dom/base/DOMPrefs.h b/dom/base/DOMPrefs.h
+new file mode 100644
+--- /dev/null
++++ b/dom/base/DOMPrefs.h
+@@ -0,0 +1,23 @@
++/* -*- 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_DOMPrefs_h
++#define mozilla_dom_DOMPrefs_h
++
++namespace mozilla {
++namespace dom {
++
++class DOMPrefs final
++{
++public:
++  // Returns true if the browser.dom.window.dump.enabled pref is set.
++  static bool DumpEnabled();
++};
++
++} // dom namespace
++} // mozilla namespace
++
++#endif // mozilla_dom_DOMPrefs_h
+diff --git a/dom/base/moz.build b/dom/base/moz.build
+--- a/dom/base/moz.build
++++ b/dom/base/moz.build
+@@ -168,16 +168,17 @@ EXPORTS.mozilla.dom += [
+     'DocumentType.h',
+     'DOMCursor.h',
+     'DOMException.h',
+     'DOMImplementation.h',
+     'DOMIntersectionObserver.h',
+     'DOMMatrix.h',
+     'DOMParser.h',
+     'DOMPoint.h',
++    'DOMPrefs.h',
+     'DOMQuad.h',
+     'DOMRect.h',
+     'DOMRequest.h',
+     'DOMStringList.h',
+     'DOMTokenListSupportedTokens.h',
+     'Element.h',
+     'ElementInlines.h',
+     'EventSource.h',
+@@ -245,16 +246,17 @@ UNIFIED_SOURCES += [
+     'DocumentOrShadowRoot.cpp',
+     'DocumentType.cpp',
+     'DOMCursor.cpp',
+     'DOMException.cpp',
+     'DOMImplementation.cpp',
+     'DOMMatrix.cpp',
+     'DOMParser.cpp',
+     'DOMPoint.cpp',
++    'DOMPrefs.cpp',
+     'DOMQuad.cpp',
+     'DOMRect.cpp',
+     'DOMRequest.cpp',
+     'DOMStringList.cpp',
+     'Element.cpp',
+     'EventSource.cpp',
+     'FormData.cpp',
+     'FragmentOrElement.cpp',
+diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp
+--- a/dom/base/nsContentUtils.cpp
++++ b/dom/base/nsContentUtils.cpp
+@@ -331,20 +331,16 @@ uint32_t nsContentUtils::sCookiesLifetim
+ uint32_t nsContentUtils::sCookiesBehavior = nsICookieService::BEHAVIOR_ACCEPT;
+ 
+ nsHtml5StringParser* nsContentUtils::sHTMLFragmentParser = nullptr;
+ nsIParser* nsContentUtils::sXMLFragmentParser = nullptr;
+ nsIFragmentContentSink* nsContentUtils::sXMLFragmentSink = nullptr;
+ bool nsContentUtils::sFragmentParsingActive = false;
+ nsISerialEventTarget* nsContentUtils::sStableStateEventTarget = nullptr;
+ 
+-#if !(defined(DEBUG) || defined(MOZ_ENABLE_JS_DUMP))
+-bool nsContentUtils::sDOMWindowDumpEnabled;
+-#endif
+-
+ bool nsContentUtils::sDoNotTrackEnabled = false;
+ 
+ mozilla::LazyLogModule nsContentUtils::sDOMDumpLog("Dump");
+ 
+ PopupControlState nsContentUtils::sPopupControlState = openAbused;
+ 
+ // Subset of http://www.whatwg.org/specs/web-apps/current-work/#autofill-field-name
+ enum AutocompleteUnsupportedFieldName : uint8_t
+@@ -735,21 +731,16 @@ nsContentUtils::Init()
+   Preferences::AddUintVarCache(&sCookiesLifetimePolicy,
+                                "network.cookie.lifetimePolicy",
+                                nsICookieService::ACCEPT_NORMALLY);
+ 
+   Preferences::AddUintVarCache(&sCookiesBehavior,
+                                "network.cookie.cookieBehavior",
+                                nsICookieService::BEHAVIOR_ACCEPT);
+ 
+-#if !(defined(DEBUG) || defined(MOZ_ENABLE_JS_DUMP))
+-  Preferences::AddBoolVarCache(&sDOMWindowDumpEnabled,
+-                               "browser.dom.window.dump.enabled");
+-#endif
+-
+   Preferences::AddBoolVarCache(&sDoNotTrackEnabled,
+                                "privacy.donottrackheader.enabled", false);
+ 
+   Preferences::AddBoolVarCache(&sUseActivityCursor,
+                                "ui.use_activity_cursor", false);
+ 
+   Preferences::AddBoolVarCache(&sAnimationsAPICoreEnabled,
+                                "dom.animations-api.core.enabled", false);
+@@ -7737,29 +7728,16 @@ nsContentUtils::IsAllowedNonCorsLanguage
+       continue;
+     }
+     return false;
+   }
+   return true;
+ }
+ 
+ bool
+-nsContentUtils::DOMWindowDumpEnabled()
+-{
+-#if !(defined(DEBUG) || defined(MOZ_ENABLE_JS_DUMP))
+-  // In optimized builds we check a pref that controls if we should
+-  // enable output from dump() or not, in debug builds it's always
+-  // enabled.
+-  return nsContentUtils::sDOMWindowDumpEnabled;
+-#else
+-  return true;
+-#endif
+-}
+-
+-bool
+ nsContentUtils::DoNotTrackEnabled()
+ {
+   return nsContentUtils::sDoNotTrackEnabled;
+ }
+ 
+ mozilla::LogModule*
+ nsContentUtils::DOMDumpLog()
+ {
+diff --git a/dom/base/nsContentUtils.h b/dom/base/nsContentUtils.h
+--- a/dom/base/nsContentUtils.h
++++ b/dom/base/nsContentUtils.h
+@@ -2720,21 +2720,16 @@ public:
+    * Returns pointer to HTML editor instance for the aPresContext when there is.
+    * The HTML editor is shared by contenteditable elements or used in
+    * designMode.  When there are no contenteditable elements and the document
+    * is not in designMode, this returns nullptr.
+    */
+   static mozilla::HTMLEditor* GetHTMLEditor(nsPresContext* aPresContext);
+ 
+   /**
+-   * Returns true if the browser.dom.window.dump.enabled pref is set.
+-   */
+-  static bool DOMWindowDumpEnabled();
+-
+-  /**
+    * Returns true if the privacy.donottrackheader.enabled pref is set.
+    */
+   static bool DoNotTrackEnabled();
+ 
+   /**
+    * Returns a LogModule that dump calls from content script are logged to.
+    * This can be enabled with the 'Dump' module, and is useful for synchronizing
+    * content JS to other logging modules.
+@@ -3508,19 +3503,16 @@ private:
+   static nsString* sOSText;
+   static nsString* sAltText;
+   static nsString* sModifierSeparator;
+ 
+   // Alternate data mime type, used by the ScriptLoader to register and read the
+   // bytecode out of the nsCacheInfoChannel.
+   static nsCString* sJSBytecodeMimeType;
+ 
+-#if !(defined(DEBUG) || defined(MOZ_ENABLE_JS_DUMP))
+-  static bool sDOMWindowDumpEnabled;
+-#endif
+   static bool sDoNotTrackEnabled;
+   static mozilla::LazyLogModule sDOMDumpLog;
+ 
+   static PopupControlState sPopupControlState;
+ };
+ 
+ /* static */ inline
+ nsContentPolicyType
+diff --git a/dom/base/nsFrameMessageManager.cpp b/dom/base/nsFrameMessageManager.cpp
+--- a/dom/base/nsFrameMessageManager.cpp
++++ b/dom/base/nsFrameMessageManager.cpp
+@@ -31,16 +31,17 @@
+ #include "nsIScriptSecurityManager.h"
+ #include "nsIDOMClassInfo.h"
+ #include "xpcpublic.h"
+ #include "mozilla/CycleCollectedJSContext.h"
+ #include "mozilla/IntentionalCrash.h"
+ #include "mozilla/Preferences.h"
+ #include "mozilla/ScriptPreloader.h"
+ #include "mozilla/Telemetry.h"
++#include "mozilla/dom/DOMPrefs.h"
+ #include "mozilla/dom/File.h"
+ #include "mozilla/dom/MessagePort.h"
+ #include "mozilla/dom/ContentParent.h"
+ #include "mozilla/dom/PermissionMessageUtils.h"
+ #include "mozilla/dom/ProcessGlobal.h"
+ #include "mozilla/dom/SameProcessMessageQueue.h"
+ #include "mozilla/dom/ScriptSettings.h"
+ #include "mozilla/dom/ipc/StructuredCloneData.h"
+@@ -800,17 +801,17 @@ nsFrameMessageManager::ReleaseCachedProc
+   return NS_OK;
+ }
+ 
+ // nsIContentFrameMessageManager
+ 
+ NS_IMETHODIMP
+ nsFrameMessageManager::Dump(const nsAString& aStr)
+ {
+-  if (!nsContentUtils::DOMWindowDumpEnabled()) {
++  if (!DOMPrefs::DumpEnabled()) {
+     return NS_OK;
+   }
+ 
+ #ifdef ANDROID
+   __android_log_print(ANDROID_LOG_INFO, "Gecko", "%s", NS_ConvertUTF16toUTF8(aStr).get());
+ #endif
+ #ifdef XP_WIN
+   if (IsDebuggerPresent()) {
+diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp
+--- a/dom/base/nsGlobalWindow.cpp
++++ b/dom/base/nsGlobalWindow.cpp
+@@ -15,16 +15,17 @@
+ #include "nsContentSecurityManager.h"
+ #include "nsScreen.h"
+ #include "nsHistory.h"
+ #include "nsDOMNavigationTiming.h"
+ #include "nsIDOMStorageManager.h"
+ #include "mozilla/dom/ClientManager.h"
+ #include "mozilla/dom/ClientSource.h"
+ #include "mozilla/dom/ClientState.h"
++#include "mozilla/dom/DOMPrefs.h"
+ #include "mozilla/dom/LocalStorage.h"
+ #include "mozilla/dom/Storage.h"
+ #include "mozilla/dom/IdleRequest.h"
+ #include "mozilla/dom/Performance.h"
+ #include "mozilla/dom/StorageEvent.h"
+ #include "mozilla/dom/StorageEventBinding.h"
+ #include "mozilla/dom/StorageNotifierService.h"
+ #include "mozilla/dom/StorageUtils.h"
+@@ -7618,17 +7619,17 @@ nsGlobalWindow::GetFullScreen()
+   bool fullscreen = GetFullScreen(dummy);
+   dummy.SuppressException();
+   return fullscreen;
+ }
+ 
+ void
+ nsGlobalWindow::Dump(const nsAString& aStr)
+ {
+-  if (!nsContentUtils::DOMWindowDumpEnabled()) {
++  if (!DOMPrefs::DumpEnabled()) {
+     return;
+   }
+ 
+   char *cstr = ToNewUTF8String(aStr);
+ 
+ #if defined(XP_MACOSX)
+   // have to convert \r to \n so that printing to the console works
+   char *c = cstr, *cEnd = cstr + strlen(cstr);
+diff --git a/dom/workers/WorkerPrefs.h b/dom/workers/WorkerPrefs.h
+--- a/dom/workers/WorkerPrefs.h
++++ b/dom/workers/WorkerPrefs.h
+@@ -16,19 +16,16 @@
+ //     macro in Workers.h.
+ //   * The name of the function that updates the new value of a pref.
+ //
+ //   WORKER_PREF("foo.bar", UpdaterFunction)
+ //
+ //   * First argument is the name of the pref.
+ //   * The name of the function that updates the new value of a pref.
+ 
+-#if !(defined(DEBUG) || defined(MOZ_ENABLE_JS_DUMP))
+-WORKER_SIMPLE_PREF("browser.dom.window.dump.enabled", DumpEnabled, DUMP)
+-#endif
+ WORKER_SIMPLE_PREF("canvas.imagebitmap_extensions.enabled", ImageBitmapExtensionsEnabled, IMAGEBITMAP_EXTENSIONS_ENABLED)
+ WORKER_SIMPLE_PREF("dom.caches.enabled", DOMCachesEnabled, DOM_CACHES)
+ WORKER_SIMPLE_PREF("dom.caches.testing.enabled", DOMCachesTestingEnabled, DOM_CACHES_TESTING)
+ WORKER_SIMPLE_PREF("dom.performance.enable_user_timing_logging", PerformanceLoggingEnabled, PERFORMANCE_LOGGING_ENABLED)
+ WORKER_SIMPLE_PREF("dom.webnotifications.enabled", DOMWorkerNotificationEnabled, DOM_WORKERNOTIFICATION)
+ WORKER_SIMPLE_PREF("dom.webnotifications.serviceworker.enabled", DOMServiceWorkerNotificationEnabled, DOM_SERVICEWORKERNOTIFICATION)
+ WORKER_SIMPLE_PREF("dom.webnotifications.requireinteraction.enabled", DOMWorkerNotificationRIEnabled, DOM_WORKERNOTIFICATIONRI)
+ WORKER_SIMPLE_PREF("dom.serviceWorkers.enabled", ServiceWorkersEnabled, SERVICEWORKERS_ENABLED)
+diff --git a/dom/workers/WorkerScope.cpp b/dom/workers/WorkerScope.cpp
+--- a/dom/workers/WorkerScope.cpp
++++ b/dom/workers/WorkerScope.cpp
+@@ -7,16 +7,17 @@
+ #include "WorkerScope.h"
+ 
+ #include "jsapi.h"
+ #include "mozilla/EventListenerManager.h"
+ #include "mozilla/dom/BindingDeclarations.h"
+ #include "mozilla/dom/Clients.h"
+ #include "mozilla/dom/Console.h"
+ #include "mozilla/dom/DedicatedWorkerGlobalScopeBinding.h"
++#include "mozilla/dom/DOMPrefs.h"
+ #include "mozilla/dom/Fetch.h"
+ #include "mozilla/dom/FunctionBinding.h"
+ #include "mozilla/dom/IDBFactory.h"
+ #include "mozilla/dom/ImageBitmap.h"
+ #include "mozilla/dom/ImageBitmapBinding.h"
+ #include "mozilla/dom/Performance.h"
+ #include "mozilla/dom/Promise.h"
+ #include "mozilla/dom/PromiseWorkerProxy.h"
+@@ -366,17 +367,17 @@ WorkerGlobalScope::Dump(const Optional<n
+ {
+   mWorkerPrivate->AssertIsOnWorkerThread();
+ 
+   if (!aString.WasPassed()) {
+     return;
+   }
+ 
+ #if !(defined(DEBUG) || defined(MOZ_ENABLE_JS_DUMP))
+-  if (!mWorkerPrivate->DumpEnabled()) {
++  if (!DOMPrefs::DumpEnabled()) {
+     return;
+   }
+ #endif
+ 
+   NS_ConvertUTF16toUTF8 str(aString.Value());
+ 
+   MOZ_LOG(nsContentUtils::DOMDumpLog(), LogLevel::Debug, ("[Worker.Dump] %s", str.get()));
+ #ifdef ANDROID
+diff --git a/dom/worklet/WorkletGlobalScope.cpp b/dom/worklet/WorkletGlobalScope.cpp
+--- a/dom/worklet/WorkletGlobalScope.cpp
++++ b/dom/worklet/WorkletGlobalScope.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 "WorkletGlobalScope.h"
+ #include "mozilla/dom/WorkletGlobalScopeBinding.h"
+ #include "mozilla/dom/Console.h"
+-#include "nsContentUtils.h"
++#include "mozilla/dom/DOMPrefs.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+ NS_IMPL_CYCLE_COLLECTION_CLASS(WorkletGlobalScope)
+ 
+ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(WorkletGlobalScope)
+   NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
+@@ -66,17 +66,17 @@ WorkletGlobalScope::GetConsole(ErrorResu
+ 
+   RefPtr<Console> console = mConsole;
+   return console.forget();
+ }
+ 
+ void
+ WorkletGlobalScope::Dump(const Optional<nsAString>& aString) const
+ {
+-  if (!nsContentUtils::DOMWindowDumpEnabled()) {
++  if (!DOMPrefs::DumpEnabled()) {
+     return;
+   }
+ 
+   if (!aString.WasPassed()) {
+     return;
+   }
+ 
+   NS_ConvertUTF16toUTF8 str(aString.Value());
+diff --git a/js/xpconnect/loader/mozJSComponentLoader.cpp b/js/xpconnect/loader/mozJSComponentLoader.cpp
+--- a/js/xpconnect/loader/mozJSComponentLoader.cpp
++++ b/js/xpconnect/loader/mozJSComponentLoader.cpp
+@@ -45,16 +45,17 @@
+ #include "ScriptPreloader-inl.h"
+ 
+ #include "mozilla/AddonPathService.h"
+ #include "mozilla/scache/StartupCache.h"
+ #include "mozilla/scache/StartupCacheUtils.h"
+ #include "mozilla/MacroForEach.h"
+ #include "mozilla/Preferences.h"
+ #include "mozilla/ScriptPreloader.h"
++#include "mozilla/dom/DOMPrefs.h"
+ #include "mozilla/dom/ScriptSettings.h"
+ #include "mozilla/ResultExtensions.h"
+ #include "mozilla/UniquePtrExtensions.h"
+ #include "mozilla/Unused.h"
+ 
+ using namespace mozilla;
+ using namespace mozilla::scache;
+ using namespace mozilla::loader;
+@@ -84,17 +85,17 @@ static LazyLogModule gJSCLLog("JSCompone
+ #define ERROR_GETTING_ARRAY_LENGTH "%s - Error getting array length of EXPORTED_SYMBOLS."
+ #define ERROR_ARRAY_ELEMENT "%s - EXPORTED_SYMBOLS[%d] is not a string."
+ #define ERROR_GETTING_SYMBOL "%s - Could not get symbol '%s'."
+ #define ERROR_SETTING_SYMBOL "%s - Could not set symbol '%s' on target object."
+ 
+ static bool
+ Dump(JSContext* cx, unsigned argc, Value* vp)
+ {
+-    if (!nsContentUtils::DOMWindowDumpEnabled()) {
++    if (!mozilla::dom::DOMPrefs::DumpEnabled()) {
+         return true;
+     }
+ 
+     CallArgs args = CallArgsFromVp(argc, vp);
+ 
+     if (args.length() == 0)
+         return true;
+ 
+diff --git a/js/xpconnect/src/Sandbox.cpp b/js/xpconnect/src/Sandbox.cpp
+--- a/js/xpconnect/src/Sandbox.cpp
++++ b/js/xpconnect/src/Sandbox.cpp
+@@ -28,16 +28,17 @@
+ #include "XPCWrapper.h"
+ #include "XrayWrapper.h"
+ #include "Crypto.h"
+ #include "mozilla/dom/BindingUtils.h"
+ #include "mozilla/dom/BlobBinding.h"
+ #include "mozilla/dom/cache/CacheStorage.h"
+ #include "mozilla/dom/CSSBinding.h"
+ #include "mozilla/dom/DirectoryBinding.h"
++#include "mozilla/dom/DOMPrefs.h"
+ #include "mozilla/dom/IndexedDatabaseManager.h"
+ #include "mozilla/dom/Fetch.h"
+ #include "mozilla/dom/FileBinding.h"
+ #include "mozilla/dom/MessageChannelBinding.h"
+ #include "mozilla/dom/MessagePortBinding.h"
+ #include "mozilla/dom/PromiseBinding.h"
+ #include "mozilla/dom/RequestBinding.h"
+ #include "mozilla/dom/ResponseBinding.h"
+@@ -110,17 +111,17 @@ xpc::NewSandboxConstructor()
+     nsCOMPtr<nsIXPCComponents_utils_Sandbox> sbConstructor =
+         new nsXPCComponents_utils_Sandbox();
+     return sbConstructor.forget();
+ }
+ 
+ static bool
+ SandboxDump(JSContext* cx, unsigned argc, Value* vp)
+ {
+-    if (!nsContentUtils::DOMWindowDumpEnabled()) {
++    if (!DOMPrefs::DumpEnabled()) {
+         return true;
+     }
+ 
+     CallArgs args = CallArgsFromVp(argc, vp);
+ 
+     if (args.length() == 0)
+         return true;
+ 
+diff --git a/js/xpconnect/src/XPCWrappedJSClass.cpp b/js/xpconnect/src/XPCWrappedJSClass.cpp
+--- a/js/xpconnect/src/XPCWrappedJSClass.cpp
++++ b/js/xpconnect/src/XPCWrappedJSClass.cpp
+@@ -4,27 +4,27 @@
+  * 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/. */
+ 
+ /* Sharable code and data for wrapper around JSObjects. */
+ 
+ #include "xpcprivate.h"
+ #include "jsprf.h"
+ #include "nsArrayEnumerator.h"
+-#include "nsContentUtils.h"
+ #include "nsINamed.h"
+ #include "nsIScriptError.h"
+ #include "nsWrapperCache.h"
+ #include "AccessCheck.h"
+ #include "nsJSUtils.h"
+ #include "nsPrintfCString.h"
+ #include "mozilla/Attributes.h"
+ #include "mozilla/dom/BindingUtils.h"
+ #include "mozilla/dom/DOMException.h"
+ #include "mozilla/dom/DOMExceptionBinding.h"
++#include "mozilla/dom/DOMPrefs.h"
+ #include "mozilla/jsipc/CrossProcessObjectWrappers.h"
+ 
+ #include "jsapi.h"
+ #include "jsfriendapi.h"
+ 
+ using namespace xpc;
+ using namespace JS;
+ using namespace mozilla;
+@@ -940,17 +940,17 @@ nsXPCWrappedJSClass::CheckForException(X
+             // just so that we can tell the JS engine to pass it back to us via the
+             // error reporting callback. This is all very dumb.
+             JS_SetPendingException(cx, js_exception);
+             aes.ReportException();
+             reportable = false;
+         }
+ 
+         if (reportable) {
+-            if (nsContentUtils::DOMWindowDumpEnabled()) {
++            if (DOMPrefs::DumpEnabled()) {
+                 static const char line[] =
+                     "************************************************************\n";
+                 static const char preamble[] =
+                     "* Call to xpconnect wrapped JSObject produced this error:  *\n";
+                 static const char cant_get_text[] =
+                     "FAILED TO GET TEXT FROM EXCEPTION\n";
+ 
+                 fputs(line, stdout);
+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
+@@ -18,16 +18,17 @@
+ #include "nsThreadUtils.h"
+ #include "nsDOMJSUtils.h"
+ 
+ #include "WrapperFactory.h"
+ #include "AccessCheck.h"
+ 
+ #include "mozilla/dom/BindingUtils.h"
+ #include "mozilla/dom/DOMException.h"
++#include "mozilla/dom/DOMPrefs.h"
+ #include "mozilla/dom/Exceptions.h"
+ #include "mozilla/dom/Promise.h"
+ 
+ #include "nsDOMMutationObserver.h"
+ #include "nsICycleCollectorListener.h"
+ #include "mozilla/XPTInterfaceInfoManager.h"
+ #include "nsIObjectInputStream.h"
+ #include "nsIObjectOutputStream.h"
+@@ -265,31 +266,31 @@ xpc::ErrorBase::AppendErrorDetailsTo(nsC
+     error.AppendInt(mLineNumber, 10);
+     error.AppendLiteral(": ");
+     error.Append(NS_LossyConvertUTF16toASCII(mErrorMsg));
+ }
+ 
+ void
+ xpc::ErrorNote::LogToStderr()
+ {
+-    if (!nsContentUtils::DOMWindowDumpEnabled())
++    if (!DOMPrefs::DumpEnabled())
+         return;
+ 
+     nsAutoCString error;
+     error.AssignLiteral("JavaScript note: ");
+     AppendErrorDetailsTo(error);
+ 
+     fprintf(stderr, "%s\n", error.get());
+     fflush(stderr);
+ }
+ 
+ void
+ xpc::ErrorReport::LogToStderr()
+ {
+-    if (!nsContentUtils::DOMWindowDumpEnabled())
++    if (!DOMPrefs::DumpEnabled())
+         return;
+ 
+     nsAutoCString error;
+     error.AssignLiteral("JavaScript ");
+     if (JSREPORT_IS_STRICT(mFlags))
+         error.AppendLiteral("strict ");
+     if (JSREPORT_IS_WARNING(mFlags))
+         error.AppendLiteral("warning: ");

+ 222 - 0
frg/work-js/mozilla-release/patches/1419771-02-59a1.patch

@@ -0,0 +1,222 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1515416703 -3600
+# Node ID c0ab6f8f55cd25b9ceb21aa40b64e8057ccf0942
+# Parent  3514e10c194e61055eb0e037b522ed36db0bd51e
+Bug 1419771 - Introduce DOMPrefs, a thread-safe access to preferences for DOM - part 2 - image bitmap, r=asuth
+
+diff --git a/dom/base/DOMPrefs.cpp b/dom/base/DOMPrefs.cpp
+--- a/dom/base/DOMPrefs.cpp
++++ b/dom/base/DOMPrefs.cpp
+@@ -29,23 +29,25 @@ PREF(DumpEnabled, "browser.dom.window.du
+ #else
+ /* static */ bool
+ DOMPrefs::DumpEnabled()
+ {
+   return true;
+ }
+ #endif
+ 
++PREF(ImageBitmapExtensionsEnabled, "canvas.imagebitmap_extensions.enabled")
++
+ #undef PREF
+ 
+ #define PREF_WEBIDL(name)                        \
+   /* static */ bool                              \
+   DOMPrefs::name(JSContext* aCx, JSObject* aObj) \
+   {                                              \
+     return DOMPrefs::name();                     \
+   }
+ 
+-// It will be useful, eventually.
++PREF_WEBIDL(ImageBitmapExtensionsEnabled)
+ 
+ #undef PREF_WEBIDL
+ 
+ } // dom namespace
+ } // mozilla namespace
+diff --git a/dom/base/DOMPrefs.h b/dom/base/DOMPrefs.h
+--- a/dom/base/DOMPrefs.h
++++ b/dom/base/DOMPrefs.h
+@@ -10,14 +10,18 @@
+ namespace mozilla {
+ namespace dom {
+ 
+ class DOMPrefs final
+ {
+ public:
+   // Returns true if the browser.dom.window.dump.enabled pref is set.
+   static bool DumpEnabled();
++
++  // Returns true if the canvas.imagebitmap_extensions.enabled pref is set.
++  static bool ImageBitmapExtensionsEnabled();
++  static bool ImageBitmapExtensionsEnabled(JSContext* aCx, JSObject* aObj);
+ };
+ 
+ } // dom namespace
+ } // mozilla namespace
+ 
+ #endif // mozilla_dom_DOMPrefs_h
+diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp
+--- a/dom/base/nsGlobalWindow.cpp
++++ b/dom/base/nsGlobalWindow.cpp
+@@ -15005,17 +15005,17 @@ nsGlobalWindow::CreateImageBitmap(JSCont
+ already_AddRefed<mozilla::dom::Promise>
+ nsGlobalWindow::CreateImageBitmap(JSContext* aCx,
+                                   const ImageBitmapSource& aImage,
+                                   int32_t aOffset, int32_t aLength,
+                                   ImageBitmapFormat aFormat,
+                                   const Sequence<ChannelPixelLayout>& aLayout,
+                                   ErrorResult& aRv)
+ {
+-  if (!ImageBitmap::ExtensionsEnabled(aCx)) {
++  if (!DOMPrefs::ImageBitmapExtensionsEnabled()) {
+     aRv.Throw(NS_ERROR_TYPE_ERR);
+     return nullptr;
+   }
+   if (aImage.IsArrayBuffer() || aImage.IsArrayBufferView()) {
+     return ImageBitmap::Create(this, aImage, aOffset, aLength, aFormat, aLayout,
+                                aRv);
+   }
+   aRv.Throw(NS_ERROR_TYPE_ERR);
+diff --git a/dom/canvas/ImageBitmap.cpp b/dom/canvas/ImageBitmap.cpp
+--- a/dom/canvas/ImageBitmap.cpp
++++ b/dom/canvas/ImageBitmap.cpp
+@@ -1,16 +1,17 @@
+ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+ /* vim:set ts=2 sw=2 sts=2 et cindent: */
+ /* 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/ImageBitmap.h"
+ #include "mozilla/CheckedInt.h"
++#include "mozilla/dom/DOMPrefs.h"
+ #include "mozilla/dom/ImageBitmapBinding.h"
+ #include "mozilla/dom/Promise.h"
+ #include "mozilla/dom/StructuredCloneTags.h"
+ #include "mozilla/dom/WorkerPrivate.h"
+ #include "mozilla/dom/WorkerRunnable.h"
+ #include "mozilla/gfx/2D.h"
+ #include "mozilla/gfx/Swizzle.h"
+ #include "mozilla/Mutex.h"
+@@ -1434,28 +1435,16 @@ ImageBitmap::WriteStructuredClone(JSStru
+   if (NS_WARN_IF(!dstDataSurface)) {
+     return false;
+   }
+   Factory::CopyDataSourceSurface(snapshot, dstDataSurface);
+   aClonedSurfaces.AppendElement(dstDataSurface);
+   return true;
+ }
+ 
+-/*static*/ bool
+-ImageBitmap::ExtensionsEnabled(JSContext* aCx, JSObject*)
+-{
+-  if (NS_IsMainThread()) {
+-    return Preferences::GetBool("canvas.imagebitmap_extensions.enabled");
+-  } else {
+-    WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(aCx);
+-    MOZ_ASSERT(workerPrivate);
+-    return workerPrivate->ImageBitmapExtensionsEnabled();
+-  }
+-}
+-
+ // ImageBitmap extensions.
+ ImageBitmapFormat
+ ImageBitmap::FindOptimalFormat(const Optional<Sequence<ImageBitmapFormat>>& aPossibleFormats,
+                                ErrorResult& aRv)
+ {
+   MOZ_ASSERT(mDataWrapper, "No ImageBitmapFormatUtils functionalities.");
+ 
+   ImageBitmapFormat platformFormat = mDataWrapper->GetFormat();
+diff --git a/dom/canvas/ImageBitmap.h b/dom/canvas/ImageBitmap.h
+--- a/dom/canvas/ImageBitmap.h
++++ b/dom/canvas/ImageBitmap.h
+@@ -147,22 +147,16 @@ public:
+                       const nsTArray<RefPtr<gfx::DataSourceSurface>>& aClonedSurfaces,
+                       uint32_t aIndex);
+ 
+   static bool
+   WriteStructuredClone(JSStructuredCloneWriter* aWriter,
+                        nsTArray<RefPtr<gfx::DataSourceSurface>>& aClonedSurfaces,
+                        ImageBitmap* aImageBitmap);
+ 
+-  // Mozilla Extensions
+-  // aObj is an optional argument that isn't used by ExtensionsEnabled() and
+-  // only exists because the bindings layer insists on passing it to us.  All
+-  // other consumers of this function should only call it passing one argument.
+-  static bool ExtensionsEnabled(JSContext* aCx, JSObject* aObj = nullptr);
+-
+   friend CreateImageBitmapFromBlob;
+   friend CreateImageBitmapFromBlobTask;
+   friend CreateImageBitmapFromBlobWorkerTask;
+ 
+   template<typename T>
+   friend class MapDataIntoBufferSource;
+ 
+   // Mozilla Extensions
+diff --git a/dom/webidl/ImageBitmap.webidl b/dom/webidl/ImageBitmap.webidl
+--- a/dom/webidl/ImageBitmap.webidl
++++ b/dom/webidl/ImageBitmap.webidl
+@@ -398,15 +398,15 @@ dictionary ChannelPixelLayout {
+     required ChannelPixelLayoutDataType dataType;
+     required unsigned long              stride;
+     required unsigned long              skip;
+ };
+ 
+ typedef sequence<ChannelPixelLayout> ImagePixelLayout;
+ 
+ partial interface ImageBitmap {
+-    [Throws, Func="mozilla::dom::ImageBitmap::ExtensionsEnabled"]
++    [Throws, Func="mozilla::dom::DOMPrefs::ImageBitmapExtensionsEnabled"]
+     ImageBitmapFormat               findOptimalFormat (optional sequence<ImageBitmapFormat> aPossibleFormats);
+-    [Throws, Func="mozilla::dom::ImageBitmap::ExtensionsEnabled"]
++    [Throws, Func="mozilla::dom::DOMPrefs::ImageBitmapExtensionsEnabled"]
+     long                            mappedDataLength (ImageBitmapFormat aFormat);
+-    [Throws, Func="mozilla::dom::ImageBitmap::ExtensionsEnabled"]
++    [Throws, Func="mozilla::dom::DOMPrefs::ImageBitmapExtensionsEnabled"]
+     Promise<ImagePixelLayout> mapDataInto (ImageBitmapFormat aFormat, BufferSource aBuffer, long aOffset);
+ };
+diff --git a/dom/workers/WorkerPrefs.h b/dom/workers/WorkerPrefs.h
+--- a/dom/workers/WorkerPrefs.h
++++ b/dom/workers/WorkerPrefs.h
+@@ -16,17 +16,16 @@
+ //     macro in Workers.h.
+ //   * The name of the function that updates the new value of a pref.
+ //
+ //   WORKER_PREF("foo.bar", UpdaterFunction)
+ //
+ //   * First argument is the name of the pref.
+ //   * The name of the function that updates the new value of a pref.
+ 
+-WORKER_SIMPLE_PREF("canvas.imagebitmap_extensions.enabled", ImageBitmapExtensionsEnabled, IMAGEBITMAP_EXTENSIONS_ENABLED)
+ WORKER_SIMPLE_PREF("dom.caches.enabled", DOMCachesEnabled, DOM_CACHES)
+ WORKER_SIMPLE_PREF("dom.caches.testing.enabled", DOMCachesTestingEnabled, DOM_CACHES_TESTING)
+ WORKER_SIMPLE_PREF("dom.performance.enable_user_timing_logging", PerformanceLoggingEnabled, PERFORMANCE_LOGGING_ENABLED)
+ WORKER_SIMPLE_PREF("dom.webnotifications.enabled", DOMWorkerNotificationEnabled, DOM_WORKERNOTIFICATION)
+ WORKER_SIMPLE_PREF("dom.webnotifications.serviceworker.enabled", DOMServiceWorkerNotificationEnabled, DOM_SERVICEWORKERNOTIFICATION)
+ WORKER_SIMPLE_PREF("dom.webnotifications.requireinteraction.enabled", DOMWorkerNotificationRIEnabled, DOM_WORKERNOTIFICATIONRI)
+ WORKER_SIMPLE_PREF("dom.serviceWorkers.enabled", ServiceWorkersEnabled, SERVICEWORKERS_ENABLED)
+ WORKER_SIMPLE_PREF("dom.serviceWorkers.testing.enabled", ServiceWorkersTestingEnabled, SERVICEWORKERS_TESTING_ENABLED)
+diff --git a/dom/workers/WorkerScope.cpp b/dom/workers/WorkerScope.cpp
+--- a/dom/workers/WorkerScope.cpp
++++ b/dom/workers/WorkerScope.cpp
+@@ -476,17 +476,17 @@ WorkerGlobalScope::CreateImageBitmap(JSC
+ already_AddRefed<mozilla::dom::Promise>
+ WorkerGlobalScope::CreateImageBitmap(JSContext* aCx,
+                                      const ImageBitmapSource& aImage,
+                                      int32_t aOffset, int32_t aLength,
+                                      ImageBitmapFormat aFormat,
+                                      const Sequence<ChannelPixelLayout>& aLayout,
+                                      ErrorResult& aRv)
+ {
+-  if (!ImageBitmap::ExtensionsEnabled(aCx)) {
++  if (!DOMPrefs::ImageBitmapExtensionsEnabled()) {
+     aRv.Throw(NS_ERROR_TYPE_ERR);
+     return nullptr;
+   }
+ 
+   if (aImage.IsArrayBuffer() || aImage.IsArrayBufferView()) {
+     return ImageBitmap::Create(this, aImage, aOffset, aLength, aFormat, aLayout,
+                                aRv);
+   } else {

+ 299 - 0
frg/work-js/mozilla-release/patches/1419771-03-59a1.patch

@@ -0,0 +1,299 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1515416703 -3600
+# Node ID 035af44209d00e69d3829b61a52718a6557b8800
+# Parent  32e11b1e554ea3aa009fae1bfe522d7528319e5e
+Bug 1419771 - Introduce DOMPrefs, a thread-safe access to preferences for DOM - part 3 - DOM Caches enabled, r=asuth
+
+diff --git a/dom/base/DOMPrefs.cpp b/dom/base/DOMPrefs.cpp
+--- a/dom/base/DOMPrefs.cpp
++++ b/dom/base/DOMPrefs.cpp
+@@ -30,24 +30,26 @@ PREF(DumpEnabled, "browser.dom.window.du
+ /* static */ bool
+ DOMPrefs::DumpEnabled()
+ {
+   return true;
+ }
+ #endif
+ 
+ PREF(ImageBitmapExtensionsEnabled, "canvas.imagebitmap_extensions.enabled")
++PREF(DOMCachesEnabled, "dom.caches.enabled")
+ 
+ #undef PREF
+ 
+ #define PREF_WEBIDL(name)                        \
+   /* static */ bool                              \
+   DOMPrefs::name(JSContext* aCx, JSObject* aObj) \
+   {                                              \
+     return DOMPrefs::name();                     \
+   }
+ 
+ PREF_WEBIDL(ImageBitmapExtensionsEnabled)
++PREF_WEBIDL(DOMCachesEnabled)
+ 
+ #undef PREF_WEBIDL
+ 
+ } // dom namespace
+ } // mozilla namespace
+diff --git a/dom/base/DOMPrefs.h b/dom/base/DOMPrefs.h
+--- a/dom/base/DOMPrefs.h
++++ b/dom/base/DOMPrefs.h
+@@ -14,14 +14,18 @@ class DOMPrefs final
+ {
+ public:
+   // Returns true if the browser.dom.window.dump.enabled pref is set.
+   static bool DumpEnabled();
+ 
+   // Returns true if the canvas.imagebitmap_extensions.enabled pref is set.
+   static bool ImageBitmapExtensionsEnabled();
+   static bool ImageBitmapExtensionsEnabled(JSContext* aCx, JSObject* aObj);
++
++  // Returns true if the dom.caches.enabled pref is set.
++  static bool DOMCachesEnabled();
++  static bool DOMCachesEnabled(JSContext* aCx, JSObject* aObj);
+ };
+ 
+ } // dom namespace
+ } // mozilla namespace
+ 
+ #endif // mozilla_dom_DOMPrefs_h
+diff --git a/dom/base/nsGlobalWindow.h b/dom/base/nsGlobalWindow.h
+--- a/dom/base/nsGlobalWindow.h
++++ b/dom/base/nsGlobalWindow.h
+@@ -31,16 +31,17 @@
+ #include "nsIScriptGlobalObject.h"
+ #include "nsIScriptObjectPrincipal.h"
+ #include "nsITimer.h"
+ #include "mozilla/EventListenerManager.h"
+ #include "nsIPrincipal.h"
+ #include "nsSize.h"
+ #include "mozilla/FlushType.h"
+ #include "prclist.h"
++#include "mozilla/dom/DOMPrefs.h"
+ #include "mozilla/dom/BindingDeclarations.h"
+ #include "mozilla/dom/StorageEvent.h"
+ #include "mozilla/dom/StorageEventBinding.h"
+ #include "mozilla/dom/UnionTypes.h"
+ #include "mozilla/ErrorResult.h"
+ #include "nsFrameMessageManager.h"
+ #include "mozilla/Attributes.h"
+ #include "mozilla/GuardObjects.h"
+diff --git a/dom/cache/Cache.cpp b/dom/cache/Cache.cpp
+--- a/dom/cache/Cache.cpp
++++ b/dom/cache/Cache.cpp
+@@ -12,16 +12,17 @@
+ #include "mozilla/dom/PromiseNativeHandler.h"
+ #include "mozilla/dom/Response.h"
+ #include "mozilla/dom/WorkerPrivate.h"
+ #include "mozilla/dom/CacheBinding.h"
+ #include "mozilla/dom/cache/AutoUtils.h"
+ #include "mozilla/dom/cache/CacheChild.h"
+ #include "mozilla/dom/cache/CacheWorkerHolder.h"
+ #include "mozilla/dom/cache/ReadStream.h"
++#include "mozilla/dom/DOMPrefs.h"
+ #include "mozilla/ErrorResult.h"
+ #include "mozilla/Preferences.h"
+ #include "mozilla/Unused.h"
+ #include "nsIGlobalObject.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ namespace cache {
+@@ -512,39 +513,16 @@ Cache::Keys(JSContext* aCx, const Option
+     if (NS_WARN_IF(aRv.Failed())) {
+       return nullptr;
+     }
+   }
+ 
+   return ExecuteOp(args, aRv);
+ }
+ 
+-// static
+-bool
+-Cache::PrefEnabled(JSContext* aCx, JSObject* aObj)
+-{
+-  using mozilla::dom::workers::WorkerPrivate;
+-  using mozilla::dom::workers::GetWorkerPrivateFromContext;
+-
+-  // If we're on the main thread, then check the pref directly.
+-  if (NS_IsMainThread()) {
+-    bool enabled = false;
+-    Preferences::GetBool("dom.caches.enabled", &enabled);
+-    return enabled;
+-  }
+-
+-  // Otherwise check the pref via the work private helper
+-  WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(aCx);
+-  if (!workerPrivate) {
+-    return false;
+-  }
+-
+-  return workerPrivate->DOMCachesEnabled();
+-}
+-
+ nsISupports*
+ Cache::GetParentObject() const
+ {
+   return mGlobal;
+ }
+ 
+ JSObject*
+ Cache::WrapObject(JSContext* aContext, JS::Handle<JSObject*> aGivenProto)
+diff --git a/dom/cache/Cache.h b/dom/cache/Cache.h
+--- a/dom/cache/Cache.h
++++ b/dom/cache/Cache.h
+@@ -63,18 +63,16 @@ public:
+   already_AddRefed<Promise>
+   Delete(JSContext* aCx, const RequestOrUSVString& aRequest,
+          const CacheQueryOptions& aOptions, ErrorResult& aRv);
+   already_AddRefed<Promise>
+   Keys(JSContext* aCx, const Optional<RequestOrUSVString>& aRequest,
+        const CacheQueryOptions& aParams, ErrorResult& aRv);
+ 
+   // binding methods
+-  static bool PrefEnabled(JSContext* aCx, JSObject* aObj);
+-
+   nsISupports* GetParentObject() const;
+   virtual JSObject* WrapObject(JSContext* aContext, JS::Handle<JSObject*> aGivenProto) override;
+ 
+   // Called when CacheChild actor is being destroyed
+   void DestroyInternal(CacheChild* aActor);
+ 
+   // TypeUtils methods
+   virtual nsIGlobalObject*
+diff --git a/dom/cache/CacheStorage.cpp b/dom/cache/CacheStorage.cpp
+--- a/dom/cache/CacheStorage.cpp
++++ b/dom/cache/CacheStorage.cpp
+@@ -440,23 +440,16 @@ CacheStorage::Keys(ErrorResult& aRv)
+   entry->mArgs = StorageKeysArgs();
+ 
+   RunRequest(Move(entry));
+ 
+   return promise.forget();
+ }
+ 
+ // static
+-bool
+-CacheStorage::PrefEnabled(JSContext* aCx, JSObject* aObj)
+-{
+-  return Cache::PrefEnabled(aCx, aObj);
+-}
+-
+-// static
+ already_AddRefed<CacheStorage>
+ CacheStorage::Constructor(const GlobalObject& aGlobal,
+                           CacheStorageNamespace aNamespace,
+                           nsIPrincipal* aPrincipal, ErrorResult& aRv)
+ {
+   if (NS_WARN_IF(!NS_IsMainThread())) {
+     aRv.Throw(NS_ERROR_FAILURE);
+     return nullptr;
+diff --git a/dom/cache/CacheStorage.h b/dom/cache/CacheStorage.h
+--- a/dom/cache/CacheStorage.h
++++ b/dom/cache/CacheStorage.h
+@@ -68,18 +68,16 @@ public:
+   already_AddRefed<Promise> Keys(ErrorResult& aRv);
+ 
+   // chrome-only webidl interface methods
+   static already_AddRefed<CacheStorage>
+   Constructor(const GlobalObject& aGlobal, CacheStorageNamespace aNamespace,
+               nsIPrincipal* aPrincipal, ErrorResult& aRv);
+ 
+   // binding methods
+-  static bool PrefEnabled(JSContext* aCx, JSObject* aObj);
+-
+   nsISupports* GetParentObject() const;
+   virtual JSObject* WrapObject(JSContext* aContext, JS::Handle<JSObject*> aGivenProto) override;
+ 
+   // Called when CacheStorageChild actor is being destroyed
+   void DestroyInternal(CacheStorageChild* aActor);
+ 
+   // TypeUtils methods
+   virtual nsIGlobalObject* GetGlobalObject() const override;
+diff --git a/dom/webidl/Cache.webidl b/dom/webidl/Cache.webidl
+--- a/dom/webidl/Cache.webidl
++++ b/dom/webidl/Cache.webidl
+@@ -6,17 +6,17 @@
+  * The origin of this IDL file is
+  * http://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html
+  *
+  */
+ 
+ // https://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html#cache
+ 
+ [Exposed=(Window,Worker),
+- Func="mozilla::dom::cache::Cache::PrefEnabled"]
++ Func="mozilla::dom::DOMPrefs::DOMCachesEnabled"]
+ interface Cache {
+   [NewObject]
+   Promise<Response> match(RequestInfo request, optional CacheQueryOptions options);
+   [NewObject]
+   Promise<sequence<Response>> matchAll(optional RequestInfo request, optional CacheQueryOptions options);
+   [NewObject, NeedsCallerType]
+   Promise<void> add(RequestInfo request);
+   [NewObject, NeedsCallerType]
+diff --git a/dom/webidl/CacheStorage.webidl b/dom/webidl/CacheStorage.webidl
+--- a/dom/webidl/CacheStorage.webidl
++++ b/dom/webidl/CacheStorage.webidl
+@@ -9,17 +9,17 @@
+  */
+ 
+ // https://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html#cache-storage
+ 
+ interface Principal;
+ 
+ [Exposed=(Window,Worker),
+  ChromeConstructor(CacheStorageNamespace namespace, Principal principal),
+- Func="mozilla::dom::cache::CacheStorage::PrefEnabled"]
++ Func="mozilla::dom::DOMPrefs::DOMCachesEnabled"]
+ interface CacheStorage {
+   [NewObject]
+   Promise<Response> match(RequestInfo request, optional CacheQueryOptions options);
+   [NewObject]
+   Promise<boolean> has(DOMString cacheName);
+   [NewObject]
+   Promise<Cache> open(DOMString cacheName);
+   [NewObject]
+diff --git a/dom/webidl/WindowOrWorkerGlobalScope.webidl b/dom/webidl/WindowOrWorkerGlobalScope.webidl
+--- a/dom/webidl/WindowOrWorkerGlobalScope.webidl
++++ b/dom/webidl/WindowOrWorkerGlobalScope.webidl
+@@ -57,17 +57,17 @@ partial interface WindowOrWorkerGlobalSc
+ partial interface WindowOrWorkerGlobalScope {
+    // readonly attribute IDBFactory indexedDB;
+    [Throws]
+    readonly attribute IDBFactory? indexedDB;
+ };
+ 
+ // https://w3c.github.io/ServiceWorker/#self-caches
+ partial interface WindowOrWorkerGlobalScope {
+-  [Throws, Func="mozilla::dom::cache::CacheStorage::PrefEnabled", SameObject]
++  [Throws, Func="mozilla::dom::DOMPrefs::DOMCachesEnabled", SameObject]
+   readonly attribute CacheStorage caches;
+ };
+ 
+ // Mozilla extensions
+ partial interface WindowOrWorkerGlobalScope {
+   // Extensions to ImageBitmap bits.
+   // Bug 1141979 - [FoxEye] Extend ImageBitmap with interfaces to access its
+   // underlying image data
+diff --git a/dom/workers/WorkerPrefs.h b/dom/workers/WorkerPrefs.h
+--- a/dom/workers/WorkerPrefs.h
++++ b/dom/workers/WorkerPrefs.h
+@@ -16,17 +16,16 @@
+ //     macro in Workers.h.
+ //   * The name of the function that updates the new value of a pref.
+ //
+ //   WORKER_PREF("foo.bar", UpdaterFunction)
+ //
+ //   * First argument is the name of the pref.
+ //   * The name of the function that updates the new value of a pref.
+ 
+-WORKER_SIMPLE_PREF("dom.caches.enabled", DOMCachesEnabled, DOM_CACHES)
+ WORKER_SIMPLE_PREF("dom.caches.testing.enabled", DOMCachesTestingEnabled, DOM_CACHES_TESTING)
+ WORKER_SIMPLE_PREF("dom.performance.enable_user_timing_logging", PerformanceLoggingEnabled, PERFORMANCE_LOGGING_ENABLED)
+ WORKER_SIMPLE_PREF("dom.webnotifications.enabled", DOMWorkerNotificationEnabled, DOM_WORKERNOTIFICATION)
+ WORKER_SIMPLE_PREF("dom.webnotifications.serviceworker.enabled", DOMServiceWorkerNotificationEnabled, DOM_SERVICEWORKERNOTIFICATION)
+ WORKER_SIMPLE_PREF("dom.webnotifications.requireinteraction.enabled", DOMWorkerNotificationRIEnabled, DOM_WORKERNOTIFICATIONRI)
+ WORKER_SIMPLE_PREF("dom.serviceWorkers.enabled", ServiceWorkersEnabled, SERVICEWORKERS_ENABLED)
+ WORKER_SIMPLE_PREF("dom.serviceWorkers.testing.enabled", ServiceWorkersTestingEnabled, SERVICEWORKERS_TESTING_ENABLED)
+ WORKER_SIMPLE_PREF("dom.storageManager.enabled", StorageManagerEnabled, STORAGEMANAGER_ENABLED)

+ 92 - 0
frg/work-js/mozilla-release/patches/1419771-04-59a1.patch

@@ -0,0 +1,92 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1515416704 -3600
+# Node ID 5f29519f40bae9aeb9a5f36ed03964ceb4ddb447
+# Parent  ab8d6cfea1d2f9fc5670e13de0cf20edc85703d4
+Bug 1419771 - Introduce DOMPrefs, a thread-safe access to preferences for DOM - part 4 - DOM Cache testing enabled, r=asuth
+
+diff --git a/dom/base/DOMPrefs.cpp b/dom/base/DOMPrefs.cpp
+--- a/dom/base/DOMPrefs.cpp
++++ b/dom/base/DOMPrefs.cpp
+@@ -31,16 +31,17 @@ PREF(DumpEnabled, "browser.dom.window.du
+ DOMPrefs::DumpEnabled()
+ {
+   return true;
+ }
+ #endif
+ 
+ PREF(ImageBitmapExtensionsEnabled, "canvas.imagebitmap_extensions.enabled")
+ PREF(DOMCachesEnabled, "dom.caches.enabled")
++PREF(DOMCachesTestingEnabled, "dom.caches.testing.enabled")
+ 
+ #undef PREF
+ 
+ #define PREF_WEBIDL(name)                        \
+   /* static */ bool                              \
+   DOMPrefs::name(JSContext* aCx, JSObject* aObj) \
+   {                                              \
+     return DOMPrefs::name();                     \
+diff --git a/dom/base/DOMPrefs.h b/dom/base/DOMPrefs.h
+--- a/dom/base/DOMPrefs.h
++++ b/dom/base/DOMPrefs.h
+@@ -18,14 +18,17 @@ public:
+ 
+   // Returns true if the canvas.imagebitmap_extensions.enabled pref is set.
+   static bool ImageBitmapExtensionsEnabled();
+   static bool ImageBitmapExtensionsEnabled(JSContext* aCx, JSObject* aObj);
+ 
+   // Returns true if the dom.caches.enabled pref is set.
+   static bool DOMCachesEnabled();
+   static bool DOMCachesEnabled(JSContext* aCx, JSObject* aObj);
++
++  // Returns true if the dom.caches.testing.enabled pref is set.
++  static bool DOMCachesTestingEnabled();
+ };
+ 
+ } // dom namespace
+ } // mozilla namespace
+ 
+ #endif // mozilla_dom_DOMPrefs_h
+diff --git a/dom/cache/CacheStorage.cpp b/dom/cache/CacheStorage.cpp
+--- a/dom/cache/CacheStorage.cpp
++++ b/dom/cache/CacheStorage.cpp
+@@ -214,17 +214,17 @@ CacheStorage::CreateOnWorker(Namespace a
+   //    is mainly because most sites using SWs will expect Cache to work if
+   //    SWs are enabled.
+   // 3) If the window that created this worker has the devtools SW testing
+   //    option enabled.  Same reasoning as (2).
+   // 4) If the worker itself is a ServiceWorker, then we always skip the
+   //    origin checks.  The ServiceWorker has its own trusted origin checks
+   //    that are better than ours.  In addition, we don't have information
+   //    about the window any more, so we can't do our own checks.
+-  bool testingEnabled = aWorkerPrivate->DOMCachesTestingEnabled() ||
++  bool testingEnabled = DOMPrefs::DOMCachesTestingEnabled() ||
+                         aWorkerPrivate->ServiceWorkersTestingEnabled() ||
+                         aWorkerPrivate->ServiceWorkersTestingInWindow() ||
+                         aWorkerPrivate->IsServiceWorker();
+ 
+   if (!IsTrusted(principalInfo, testingEnabled)) {
+     NS_WARNING("CacheStorage not supported on untrusted origins.");
+     RefPtr<CacheStorage> ref = new CacheStorage(NS_ERROR_DOM_SECURITY_ERR);
+     return ref.forget();
+diff --git a/dom/workers/WorkerPrefs.h b/dom/workers/WorkerPrefs.h
+--- a/dom/workers/WorkerPrefs.h
++++ b/dom/workers/WorkerPrefs.h
+@@ -16,17 +16,16 @@
+ //     macro in Workers.h.
+ //   * The name of the function that updates the new value of a pref.
+ //
+ //   WORKER_PREF("foo.bar", UpdaterFunction)
+ //
+ //   * First argument is the name of the pref.
+ //   * The name of the function that updates the new value of a pref.
+ 
+-WORKER_SIMPLE_PREF("dom.caches.testing.enabled", DOMCachesTestingEnabled, DOM_CACHES_TESTING)
+ WORKER_SIMPLE_PREF("dom.performance.enable_user_timing_logging", PerformanceLoggingEnabled, PERFORMANCE_LOGGING_ENABLED)
+ WORKER_SIMPLE_PREF("dom.webnotifications.enabled", DOMWorkerNotificationEnabled, DOM_WORKERNOTIFICATION)
+ WORKER_SIMPLE_PREF("dom.webnotifications.serviceworker.enabled", DOMServiceWorkerNotificationEnabled, DOM_SERVICEWORKERNOTIFICATION)
+ WORKER_SIMPLE_PREF("dom.webnotifications.requireinteraction.enabled", DOMWorkerNotificationRIEnabled, DOM_WORKERNOTIFICATIONRI)
+ WORKER_SIMPLE_PREF("dom.serviceWorkers.enabled", ServiceWorkersEnabled, SERVICEWORKERS_ENABLED)
+ WORKER_SIMPLE_PREF("dom.serviceWorkers.testing.enabled", ServiceWorkersTestingEnabled, SERVICEWORKERS_TESTING_ENABLED)
+ WORKER_SIMPLE_PREF("dom.storageManager.enabled", StorageManagerEnabled, STORAGEMANAGER_ENABLED)
+ WORKER_SIMPLE_PREF("dom.promise_rejection_events.enabled", PromiseRejectionEventsEnabled, PROMISE_REJECTION_EVENTS_ENABLED)

+ 251 - 0
frg/work-js/mozilla-release/patches/1419771-05-59a1.patch

@@ -0,0 +1,251 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1515416704 -3600
+# Node ID c00691ea962f9e0b6c0786d1d6dc0e0540fd7428
+# Parent  59e6a9ded052293aac96f0c24dd4aefd161ad178
+Bug 1419771 - Introduce DOMPrefs, a thread-safe access to preferences for DOM - part 5 - Performance logging enabled, r=asuth
+
+diff --git a/dom/base/DOMPrefs.cpp b/dom/base/DOMPrefs.cpp
+--- a/dom/base/DOMPrefs.cpp
++++ b/dom/base/DOMPrefs.cpp
+@@ -32,16 +32,17 @@ DOMPrefs::DumpEnabled()
+ {
+   return true;
+ }
+ #endif
+ 
+ PREF(ImageBitmapExtensionsEnabled, "canvas.imagebitmap_extensions.enabled")
+ PREF(DOMCachesEnabled, "dom.caches.enabled")
+ PREF(DOMCachesTestingEnabled, "dom.caches.testing.enabled")
++PREF(PerformanceLoggingEnabled, "dom.performance.enable_user_timing_logging")
+ 
+ #undef PREF
+ 
+ #define PREF_WEBIDL(name)                        \
+   /* static */ bool                              \
+   DOMPrefs::name(JSContext* aCx, JSObject* aObj) \
+   {                                              \
+     return DOMPrefs::name();                     \
+diff --git a/dom/base/DOMPrefs.h b/dom/base/DOMPrefs.h
+--- a/dom/base/DOMPrefs.h
++++ b/dom/base/DOMPrefs.h
+@@ -21,14 +21,17 @@ public:
+   static bool ImageBitmapExtensionsEnabled(JSContext* aCx, JSObject* aObj);
+ 
+   // Returns true if the dom.caches.enabled pref is set.
+   static bool DOMCachesEnabled();
+   static bool DOMCachesEnabled(JSContext* aCx, JSObject* aObj);
+ 
+   // Returns true if the dom.caches.testing.enabled pref is set.
+   static bool DOMCachesTestingEnabled();
++
++  // Returns true if the dom.performance.enable_user_timing_logging pref is set.
++  static bool PerformanceLoggingEnabled();
+ };
+ 
+ } // dom namespace
+ } // mozilla namespace
+ 
+ #endif // mozilla_dom_DOMPrefs_h
+diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp
+--- a/dom/base/nsContentUtils.cpp
++++ b/dom/base/nsContentUtils.cpp
+@@ -288,17 +288,16 @@ bool nsContentUtils::sInitialized = fals
+ bool nsContentUtils::sIsFullScreenApiEnabled = false;
+ bool nsContentUtils::sIsUnprefixedFullscreenApiEnabled = false;
+ bool nsContentUtils::sTrustedFullScreenOnly = true;
+ bool nsContentUtils::sIsCutCopyAllowed = true;
+ bool nsContentUtils::sIsFrameTimingPrefEnabled = false;
+ bool nsContentUtils::sIsPerformanceTimingEnabled = false;
+ bool nsContentUtils::sIsResourceTimingEnabled = false;
+ bool nsContentUtils::sIsPerformanceNavigationTimingEnabled = false;
+-bool nsContentUtils::sIsUserTimingLoggingEnabled = false;
+ bool nsContentUtils::sIsFormAutofillAutocompleteEnabled = false;
+ bool nsContentUtils::sIsWebComponentsEnabled = false;
+ bool nsContentUtils::sIsCustomElementsEnabled = false;
+ bool nsContentUtils::sDevToolsEnabled = false;
+ bool nsContentUtils::sSendPerformanceTimingNotifications = false;
+ bool nsContentUtils::sUseActivityCursor = false;
+ bool nsContentUtils::sAnimationsAPICoreEnabled = false;
+ bool nsContentUtils::sAnimationsAPIElementAnimateEnabled = false;
+@@ -690,19 +689,16 @@ nsContentUtils::Init()
+                                "dom.enable_performance", true);
+ 
+   Preferences::AddBoolVarCache(&sIsResourceTimingEnabled,
+                                "dom.enable_resource_timing", true);
+ 
+   Preferences::AddBoolVarCache(&sIsPerformanceNavigationTimingEnabled,
+                                "dom.enable_performance_navigation_timing", true);
+ 
+-  Preferences::AddBoolVarCache(&sIsUserTimingLoggingEnabled,
+-                               "dom.performance.enable_user_timing_logging", false);
+-
+   Preferences::AddBoolVarCache(&sIsFrameTimingPrefEnabled,
+                                "dom.enable_frame_timing", false);
+ 
+   Preferences::AddBoolVarCache(&sIsFormAutofillAutocompleteEnabled,
+                                "dom.forms.autocomplete.formautofill", false);
+ 
+   Preferences::AddBoolVarCache(&sIsWebComponentsEnabled,
+                                "dom.webcomponents.enabled", false);
+diff --git a/dom/base/nsContentUtils.h b/dom/base/nsContentUtils.h
+--- a/dom/base/nsContentUtils.h
++++ b/dom/base/nsContentUtils.h
+@@ -2311,24 +2311,16 @@ public:
+    * Returns true if the performance timing APIs are enabled.
+    */
+   static bool IsPerformanceTimingEnabled()
+   {
+     return sIsPerformanceTimingEnabled;
+   }
+ 
+   /*
+-   * Returns true if user timing API should print to console.
+-   */
+-  static bool IsUserTimingLoggingEnabled()
+-  {
+-    return sIsUserTimingLoggingEnabled;
+-  }
+-
+-  /*
+    * Returns true if the performance timing APIs are enabled.
+    */
+   static bool IsResourceTimingEnabled()
+   {
+     return sIsResourceTimingEnabled;
+   }
+ 
+   /*
+@@ -3447,17 +3439,16 @@ private:
+   static bool sIsFullScreenApiEnabled;
+   static bool sIsUnprefixedFullscreenApiEnabled;
+   static bool sTrustedFullScreenOnly;
+   static bool sIsCutCopyAllowed;
+   static uint32_t sHandlingInputTimeout;
+   static bool sIsPerformanceTimingEnabled;
+   static bool sIsResourceTimingEnabled;
+   static bool sIsPerformanceNavigationTimingEnabled;
+-  static bool sIsUserTimingLoggingEnabled;
+   static bool sIsFrameTimingPrefEnabled;
+   static bool sIsFormAutofillAutocompleteEnabled;
+   static bool sIsWebComponentsEnabled;
+   static bool sIsCustomElementsEnabled;
+   static bool sDevToolsEnabled;
+   static bool sSendPerformanceTimingNotifications;
+   static bool sUseActivityCursor;
+   static bool sAnimationsAPICoreEnabled;
+diff --git a/dom/performance/PerformanceMainThread.cpp b/dom/performance/PerformanceMainThread.cpp
+--- a/dom/performance/PerformanceMainThread.cpp
++++ b/dom/performance/PerformanceMainThread.cpp
+@@ -1,16 +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 "PerformanceMainThread.h"
+ #include "PerformanceNavigation.h"
++#include "mozilla/dom/DOMPrefs.h"
+ #include "nsICacheInfoChannel.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+ NS_IMPL_CYCLE_COLLECTION_CLASS(PerformanceMainThread)
+ 
+ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(PerformanceMainThread,
+@@ -266,31 +267,31 @@ PerformanceMainThread::GetPerformanceTim
+ void
+ PerformanceMainThread::InsertUserEntry(PerformanceEntry* aEntry)
+ {
+   MOZ_ASSERT(NS_IsMainThread());
+ 
+   nsAutoCString uri;
+   uint64_t markCreationEpoch = 0;
+ 
+-  if (nsContentUtils::IsUserTimingLoggingEnabled() ||
++  if (DOMPrefs::PerformanceLoggingEnabled() ||
+       nsContentUtils::SendPerformanceTimingNotifications()) {
+     nsresult rv = NS_ERROR_FAILURE;
+     nsCOMPtr<nsPIDOMWindowInner> owner = GetOwner();
+     if (owner && owner->GetDocumentURI()) {
+       rv = owner->GetDocumentURI()->GetHost(uri);
+     }
+ 
+     if(NS_FAILED(rv)) {
+       // If we have no URI, just put in "none".
+       uri.AssignLiteral("none");
+     }
+     markCreationEpoch = static_cast<uint64_t>(PR_Now() / PR_USEC_PER_MSEC);
+ 
+-    if (nsContentUtils::IsUserTimingLoggingEnabled()) {
++    if (DOMPrefs::PerformanceLoggingEnabled()) {
+       Performance::LogEntry(aEntry, uri);
+     }
+   }
+ 
+   if (nsContentUtils::SendPerformanceTimingNotifications()) {
+     TimingNotification(aEntry, uri, markCreationEpoch);
+   }
+ 
+diff --git a/dom/performance/PerformanceWorker.cpp b/dom/performance/PerformanceWorker.cpp
+--- a/dom/performance/PerformanceWorker.cpp
++++ b/dom/performance/PerformanceWorker.cpp
+@@ -1,15 +1,16 @@
+ /* -*- 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"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+ using namespace workers;
+ 
+ PerformanceWorker::PerformanceWorker(WorkerPrivate* aWorkerPrivate)
+@@ -21,17 +22,17 @@ PerformanceWorker::PerformanceWorker(Wor
+ PerformanceWorker::~PerformanceWorker()
+ {
+   mWorkerPrivate->AssertIsOnWorkerThread();
+ }
+ 
+ void
+ PerformanceWorker::InsertUserEntry(PerformanceEntry* aEntry)
+ {
+-  if (mWorkerPrivate->PerformanceLoggingEnabled()) {
++  if (DOMPrefs::PerformanceLoggingEnabled()) {
+     nsAutoCString uri;
+     nsCOMPtr<nsIURI> scriptURI = mWorkerPrivate->GetResolvedScriptURI();
+     if (!scriptURI || NS_FAILED(scriptURI->GetHost(uri))) {
+       // If we have no URI, just put in "none".
+       uri.AssignLiteral("none");
+     }
+     Performance::LogEntry(aEntry, uri);
+   }
+diff --git a/dom/workers/WorkerPrefs.h b/dom/workers/WorkerPrefs.h
+--- a/dom/workers/WorkerPrefs.h
++++ b/dom/workers/WorkerPrefs.h
+@@ -16,17 +16,16 @@
+ //     macro in Workers.h.
+ //   * The name of the function that updates the new value of a pref.
+ //
+ //   WORKER_PREF("foo.bar", UpdaterFunction)
+ //
+ //   * First argument is the name of the pref.
+ //   * The name of the function that updates the new value of a pref.
+ 
+-WORKER_SIMPLE_PREF("dom.performance.enable_user_timing_logging", PerformanceLoggingEnabled, PERFORMANCE_LOGGING_ENABLED)
+ WORKER_SIMPLE_PREF("dom.webnotifications.enabled", DOMWorkerNotificationEnabled, DOM_WORKERNOTIFICATION)
+ WORKER_SIMPLE_PREF("dom.webnotifications.serviceworker.enabled", DOMServiceWorkerNotificationEnabled, DOM_SERVICEWORKERNOTIFICATION)
+ WORKER_SIMPLE_PREF("dom.webnotifications.requireinteraction.enabled", DOMWorkerNotificationRIEnabled, DOM_WORKERNOTIFICATIONRI)
+ WORKER_SIMPLE_PREF("dom.serviceWorkers.enabled", ServiceWorkersEnabled, SERVICEWORKERS_ENABLED)
+ WORKER_SIMPLE_PREF("dom.serviceWorkers.testing.enabled", ServiceWorkersTestingEnabled, SERVICEWORKERS_TESTING_ENABLED)
+ WORKER_SIMPLE_PREF("dom.storageManager.enabled", StorageManagerEnabled, STORAGEMANAGER_ENABLED)
+ WORKER_SIMPLE_PREF("dom.promise_rejection_events.enabled", PromiseRejectionEventsEnabled, PROMISE_REJECTION_EVENTS_ENABLED)
+ WORKER_SIMPLE_PREF("dom.push.enabled", PushEnabled, PUSH_ENABLED)

+ 230 - 0
frg/work-js/mozilla-release/patches/1419771-06-59a1.patch

@@ -0,0 +1,230 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1515416704 -3600
+# Node ID bf04487d746a19a6d0c70f92a4f0a698f62335cf
+# Parent  88985b6497da673c521f3c220729d89b8ffb046f
+Bug 1419771 - Introduce DOMPrefs, a thread-safe access to preferences for DOM - part 6 - Notification API enabled, r=asuth
+
+diff --git a/dom/base/DOMPrefs.cpp b/dom/base/DOMPrefs.cpp
+--- a/dom/base/DOMPrefs.cpp
++++ b/dom/base/DOMPrefs.cpp
+@@ -33,25 +33,28 @@ DOMPrefs::DumpEnabled()
+   return true;
+ }
+ #endif
+ 
+ PREF(ImageBitmapExtensionsEnabled, "canvas.imagebitmap_extensions.enabled")
+ PREF(DOMCachesEnabled, "dom.caches.enabled")
+ PREF(DOMCachesTestingEnabled, "dom.caches.testing.enabled")
+ PREF(PerformanceLoggingEnabled, "dom.performance.enable_user_timing_logging")
++PREF(NotificationEnabled, "dom.webnotifications.enabled")
++PREF(NotificationEnabledInServiceWorkers, "dom.webnotifications.serviceworker.enabled")
+ 
+ #undef PREF
+ 
+ #define PREF_WEBIDL(name)                        \
+   /* static */ bool                              \
+   DOMPrefs::name(JSContext* aCx, JSObject* aObj) \
+   {                                              \
+     return DOMPrefs::name();                     \
+   }
+ 
+ PREF_WEBIDL(ImageBitmapExtensionsEnabled)
+ PREF_WEBIDL(DOMCachesEnabled)
++PREF_WEBIDL(NotificationEnabledInServiceWorkers)
+ 
+ #undef PREF_WEBIDL
+ 
+ } // dom namespace
+ } // mozilla namespace
+diff --git a/dom/base/DOMPrefs.h b/dom/base/DOMPrefs.h
+--- a/dom/base/DOMPrefs.h
++++ b/dom/base/DOMPrefs.h
+@@ -24,14 +24,24 @@ public:
+   static bool DOMCachesEnabled();
+   static bool DOMCachesEnabled(JSContext* aCx, JSObject* aObj);
+ 
+   // Returns true if the dom.caches.testing.enabled pref is set.
+   static bool DOMCachesTestingEnabled();
+ 
+   // Returns true if the dom.performance.enable_user_timing_logging pref is set.
+   static bool PerformanceLoggingEnabled();
++
++  // Returns true if the dom.webnotifications.enabled pref is set.
++  // Note that you should use NotificationEnabledInServiceWorkers if you need to
++  // enable Notification API for ServiceWorkers
++  static bool NotificationEnabled();
++
++  // Returns true if the dom.webnotifications.serviceworker.enabled pref is set.
++  static bool NotificationEnabledInServiceWorkers();
++  static bool NotificationEnabledInServiceWorkers(JSContext* aCx,
++                                                  JSObject* aObj);
+ };
+ 
+ } // dom namespace
+ } // mozilla namespace
+ 
+ #endif // mozilla_dom_DOMPrefs_h
+diff --git a/dom/notification/Notification.cpp b/dom/notification/Notification.cpp
+--- a/dom/notification/Notification.cpp
++++ b/dom/notification/Notification.cpp
+@@ -12,16 +12,17 @@
+ #include "mozilla/OwningNonNull.h"
+ #include "mozilla/Preferences.h"
+ #include "mozilla/Services.h"
+ #include "mozilla/Unused.h"
+ 
+ #include "mozilla/dom/AppNotificationServiceOptionsBinding.h"
+ #include "mozilla/dom/BindingUtils.h"
+ #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 "nsAlertsUtils.h"
+ #include "nsComponentManagerUtils.h"
+@@ -757,30 +758,28 @@ Notification::RequireInteractionEnabled(
+ 
+   return workerPrivate->DOMWorkerNotificationRIEnabled();
+ }
+ 
+ // static
+ bool
+ Notification::PrefEnabled(JSContext* aCx, JSObject* aObj)
+ {
+-  if (NS_IsMainThread()) {
+-    return Preferences::GetBool("dom.webnotifications.enabled", false);
++  if (!NS_IsMainThread()) {
++    WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(aCx);
++    if (!workerPrivate) {
++      return false;
++    }
++
++    if (workerPrivate->IsServiceWorker()) {
++      return DOMPrefs::NotificationEnabledInServiceWorkers();
++    }
+   }
+ 
+-  WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(aCx);
+-  if (!workerPrivate) {
+-    return false;
+-  }
+-
+-  if (workerPrivate->IsServiceWorker()) {
+-    return workerPrivate->DOMServiceWorkerNotificationEnabled();
+-  }
+-
+-  return workerPrivate->DOMWorkerNotificationEnabled();
++  return DOMPrefs::NotificationEnabled();
+ }
+ 
+ // static
+ bool
+ Notification::IsGetEnabled(JSContext* aCx, JSObject* aObj)
+ {
+   return NS_IsMainThread();
+ }
+diff --git a/dom/webidl/ServiceWorkerRegistration.webidl b/dom/webidl/ServiceWorkerRegistration.webidl
+--- a/dom/webidl/ServiceWorkerRegistration.webidl
++++ b/dom/webidl/ServiceWorkerRegistration.webidl
+@@ -39,13 +39,13 @@ enum ServiceWorkerUpdateViaCache {
+ // https://w3c.github.io/push-api/
+ partial interface ServiceWorkerRegistration {
+   [Throws, Exposed=(Window,Worker), Func="nsContentUtils::PushEnabled"]
+   readonly attribute PushManager pushManager;
+ };
+ 
+ // https://notifications.spec.whatwg.org/
+ partial interface ServiceWorkerRegistration {
+-  [Throws, Func="mozilla::dom::ServiceWorkerRegistration::NotificationAPIVisible"]
++  [Throws, Func="mozilla::dom::DOMPrefs::NotificationEnabledInServiceWorkers"]
+   Promise<void> showNotification(DOMString title, optional NotificationOptions options);
+-  [Throws, Func="mozilla::dom::ServiceWorkerRegistration::NotificationAPIVisible"]
++  [Throws, Func="mozilla::dom::DOMPrefs::NotificationEnabledInServiceWorkers"]
+   Promise<sequence<Notification>> getNotifications(optional GetNotificationOptions filter);
+ };
+diff --git a/dom/workers/ServiceWorkerRegistration.cpp b/dom/workers/ServiceWorkerRegistration.cpp
+--- a/dom/workers/ServiceWorkerRegistration.cpp
++++ b/dom/workers/ServiceWorkerRegistration.cpp
+@@ -49,32 +49,16 @@ ServiceWorkerRegistration::Visible(JSCon
+   WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(aCx);
+   if (!workerPrivate) {
+     return false;
+   }
+ 
+   return workerPrivate->ServiceWorkersEnabled();
+ }
+ 
+-/* static */ bool
+-ServiceWorkerRegistration::NotificationAPIVisible(JSContext* aCx, JSObject* aObj)
+-{
+-  if (NS_IsMainThread()) {
+-    return Preferences::GetBool("dom.webnotifications.serviceworker.enabled", false);
+-  }
+-
+-  // Otherwise check the pref via the work private helper
+-  WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(aCx);
+-  if (!workerPrivate) {
+-    return false;
+-  }
+-
+-  return workerPrivate->DOMServiceWorkerNotificationEnabled();
+-}
+-
+ ////////////////////////////////////////////////////
+ // Main Thread implementation
+ 
+ class ServiceWorkerRegistrationMainThread final : public ServiceWorkerRegistration,
+                                                   public ServiceWorkerRegistrationListener
+ {
+   friend nsPIDOMWindowInner;
+ public:
+diff --git a/dom/workers/ServiceWorkerRegistration.h b/dom/workers/ServiceWorkerRegistration.h
+--- a/dom/workers/ServiceWorkerRegistration.h
++++ b/dom/workers/ServiceWorkerRegistration.h
+@@ -59,20 +59,16 @@ class ServiceWorkerRegistration : public
+ public:
+   NS_DECL_ISUPPORTS_INHERITED
+ 
+   IMPL_EVENT_HANDLER(updatefound)
+ 
+   static bool
+   Visible(JSContext* aCx, JSObject* aObj);
+ 
+-  static bool
+-  NotificationAPIVisible(JSContext* aCx, JSObject* aObj);
+-
+-
+   static already_AddRefed<ServiceWorkerRegistration>
+   CreateForMainThread(nsPIDOMWindowInner* aWindow,
+                       const nsAString& aScope);
+ 
+   static already_AddRefed<ServiceWorkerRegistration>
+   CreateForWorker(workers::WorkerPrivate* aWorkerPrivate,
+                   const nsAString& aScope);
+ 
+diff --git a/dom/workers/WorkerPrefs.h b/dom/workers/WorkerPrefs.h
+--- a/dom/workers/WorkerPrefs.h
++++ b/dom/workers/WorkerPrefs.h
+@@ -16,18 +16,16 @@
+ //     macro in Workers.h.
+ //   * The name of the function that updates the new value of a pref.
+ //
+ //   WORKER_PREF("foo.bar", UpdaterFunction)
+ //
+ //   * First argument is the name of the pref.
+ //   * The name of the function that updates the new value of a pref.
+ 
+-WORKER_SIMPLE_PREF("dom.webnotifications.enabled", DOMWorkerNotificationEnabled, DOM_WORKERNOTIFICATION)
+-WORKER_SIMPLE_PREF("dom.webnotifications.serviceworker.enabled", DOMServiceWorkerNotificationEnabled, DOM_SERVICEWORKERNOTIFICATION)
+ WORKER_SIMPLE_PREF("dom.webnotifications.requireinteraction.enabled", DOMWorkerNotificationRIEnabled, DOM_WORKERNOTIFICATIONRI)
+ WORKER_SIMPLE_PREF("dom.serviceWorkers.enabled", ServiceWorkersEnabled, SERVICEWORKERS_ENABLED)
+ WORKER_SIMPLE_PREF("dom.serviceWorkers.testing.enabled", ServiceWorkersTestingEnabled, SERVICEWORKERS_TESTING_ENABLED)
+ WORKER_SIMPLE_PREF("dom.storageManager.enabled", StorageManagerEnabled, STORAGEMANAGER_ENABLED)
+ WORKER_SIMPLE_PREF("dom.promise_rejection_events.enabled", PromiseRejectionEventsEnabled, PROMISE_REJECTION_EVENTS_ENABLED)
+ WORKER_SIMPLE_PREF("dom.push.enabled", PushEnabled, PUSH_ENABLED)
+ WORKER_SIMPLE_PREF("dom.streams.enabled", StreamsEnabled, STREAMS_ENABLED)
+ WORKER_SIMPLE_PREF("dom.requestcontext.enabled", RequestContextEnabled, REQUESTCONTEXT_ENABLED)

+ 180 - 0
frg/work-js/mozilla-release/patches/1419771-07-59a1.patch

@@ -0,0 +1,180 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1515416704 -3600
+# Node ID 33ef0d8ca138dc21c98784da48ea094d0d878714
+# Parent  34186d2fb4430e5264b1fb8dc9399f4121861485
+Bug 1419771 - Introduce DOMPrefs, a thread-safe access to preferences for DOM - part 7 - Notification Request-Interaction enabled, r=asuth
+
+diff --git a/dom/base/DOMPrefs.cpp b/dom/base/DOMPrefs.cpp
+--- a/dom/base/DOMPrefs.cpp
++++ b/dom/base/DOMPrefs.cpp
+@@ -35,26 +35,28 @@ DOMPrefs::DumpEnabled()
+ #endif
+ 
+ PREF(ImageBitmapExtensionsEnabled, "canvas.imagebitmap_extensions.enabled")
+ PREF(DOMCachesEnabled, "dom.caches.enabled")
+ PREF(DOMCachesTestingEnabled, "dom.caches.testing.enabled")
+ PREF(PerformanceLoggingEnabled, "dom.performance.enable_user_timing_logging")
+ PREF(NotificationEnabled, "dom.webnotifications.enabled")
+ PREF(NotificationEnabledInServiceWorkers, "dom.webnotifications.serviceworker.enabled")
++PREF(NotificationRIEnabled, "dom.webnotifications.requireinteraction.enabled")
+ 
+ #undef PREF
+ 
+ #define PREF_WEBIDL(name)                        \
+   /* static */ bool                              \
+   DOMPrefs::name(JSContext* aCx, JSObject* aObj) \
+   {                                              \
+     return DOMPrefs::name();                     \
+   }
+ 
+ PREF_WEBIDL(ImageBitmapExtensionsEnabled)
+ PREF_WEBIDL(DOMCachesEnabled)
+ PREF_WEBIDL(NotificationEnabledInServiceWorkers)
++PREF_WEBIDL(NotificationRIEnabled)
+ 
+ #undef PREF_WEBIDL
+ 
+ } // dom namespace
+ } // mozilla namespace
+diff --git a/dom/base/DOMPrefs.h b/dom/base/DOMPrefs.h
+--- a/dom/base/DOMPrefs.h
++++ b/dom/base/DOMPrefs.h
+@@ -34,14 +34,19 @@ public:
+   // Note that you should use NotificationEnabledInServiceWorkers if you need to
+   // enable Notification API for ServiceWorkers
+   static bool NotificationEnabled();
+ 
+   // Returns true if the dom.webnotifications.serviceworker.enabled pref is set.
+   static bool NotificationEnabledInServiceWorkers();
+   static bool NotificationEnabledInServiceWorkers(JSContext* aCx,
+                                                   JSObject* aObj);
++
++  // Returns true if the dom.webnotifications.requireinteraction.enabled pref is
++  // set.
++  static bool NotificationRIEnabled();
++  static bool NotificationRIEnabled(JSContext* aCx, JSObject* aObj);
+ };
+ 
+ } // dom namespace
+ } // mozilla namespace
+ 
+ #endif // mozilla_dom_DOMPrefs_h
+diff --git a/dom/notification/Notification.cpp b/dom/notification/Notification.cpp
+--- a/dom/notification/Notification.cpp
++++ b/dom/notification/Notification.cpp
+@@ -739,31 +739,16 @@ NotificationTask::Run()
+   } else {
+     MOZ_CRASH("Invalid action");
+   }
+ 
+   MOZ_ASSERT(!mNotificationRef);
+   return NS_OK;
+ }
+ 
+-bool
+-Notification::RequireInteractionEnabled(JSContext* aCx, JSObject* aOjb)
+-{
+-  if (NS_IsMainThread()) {
+-    return Preferences::GetBool("dom.webnotifications.requireinteraction.enabled", false);
+-  }
+-
+-  WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(aCx);
+-  if (!workerPrivate) {
+-    return false;
+-  }
+-
+-  return workerPrivate->DOMWorkerNotificationRIEnabled();
+-}
+-
+ // static
+ bool
+ Notification::PrefEnabled(JSContext* aCx, JSObject* aObj)
+ {
+   if (!NS_IsMainThread()) {
+     WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(aCx);
+     if (!workerPrivate) {
+       return false;
+@@ -1568,17 +1553,17 @@ Notification::ShowInternal()
+ 
+   // In the case of IPC, the parent process uses the cookie to map to
+   // nsIObserver. Thus the cookie must be unique to differentiate observers.
+   nsString uniqueCookie = NS_LITERAL_STRING("notification:");
+   uniqueCookie.AppendInt(sCount++);
+   bool inPrivateBrowsing = IsInPrivateBrowsing();
+ 
+   bool requireInteraction = mRequireInteraction;
+-  if (!Preferences::GetBool("dom.webnotifications.requireinteraction.enabled", false)) {
++  if (!DOMPrefs::NotificationRIEnabled()) {
+     requireInteraction = false;
+   }
+ 
+   nsAutoString alertName;
+   GetAlertName(alertName);
+   nsCOMPtr<nsIAlertNotification> alert =
+     do_CreateInstance(ALERT_NOTIFICATION_CONTRACTID);
+   NS_ENSURE_TRUE_VOID(alert);
+diff --git a/dom/notification/Notification.h b/dom/notification/Notification.h
+--- a/dom/notification/Notification.h
++++ b/dom/notification/Notification.h
+@@ -118,17 +118,16 @@ public:
+   IMPL_EVENT_HANDLER(show)
+   IMPL_EVENT_HANDLER(error)
+   IMPL_EVENT_HANDLER(close)
+ 
+   NS_DECL_ISUPPORTS_INHERITED
+   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(Notification, DOMEventTargetHelper)
+   NS_DECL_NSIOBSERVER
+ 
+-  static bool RequireInteractionEnabled(JSContext* aCx, JSObject* aObj);
+   static bool PrefEnabled(JSContext* aCx, JSObject* aObj);
+   // Returns if Notification.get() is allowed for the current global.
+   static bool IsGetEnabled(JSContext* aCx, JSObject* aObj);
+ 
+   static already_AddRefed<Notification> Constructor(const GlobalObject& aGlobal,
+                                                     const nsAString& aTitle,
+                                                     const NotificationOptions& aOption,
+                                                     ErrorResult& aRv);
+diff --git a/dom/webidl/Notification.webidl b/dom/webidl/Notification.webidl
+--- a/dom/webidl/Notification.webidl
++++ b/dom/webidl/Notification.webidl
+@@ -45,17 +45,17 @@ interface Notification : EventTarget {
+   readonly attribute DOMString? body;
+ 
+   [Constant]
+   readonly attribute DOMString? tag;
+ 
+   [Pure]
+   readonly attribute DOMString? icon;
+ 
+-  [Constant, Func="mozilla::dom::Notification::RequireInteractionEnabled"]
++  [Constant, Func="mozilla::dom::DOMPrefs::NotificationRIEnabled"]
+   readonly attribute boolean requireInteraction;
+ 
+   [Constant]
+   readonly attribute any data;
+ 
+   void close();
+ };
+ 
+diff --git a/dom/workers/WorkerPrefs.h b/dom/workers/WorkerPrefs.h
+--- a/dom/workers/WorkerPrefs.h
++++ b/dom/workers/WorkerPrefs.h
+@@ -16,17 +16,16 @@
+ //     macro in Workers.h.
+ //   * The name of the function that updates the new value of a pref.
+ //
+ //   WORKER_PREF("foo.bar", UpdaterFunction)
+ //
+ //   * First argument is the name of the pref.
+ //   * The name of the function that updates the new value of a pref.
+ 
+-WORKER_SIMPLE_PREF("dom.webnotifications.requireinteraction.enabled", DOMWorkerNotificationRIEnabled, DOM_WORKERNOTIFICATIONRI)
+ WORKER_SIMPLE_PREF("dom.serviceWorkers.enabled", ServiceWorkersEnabled, SERVICEWORKERS_ENABLED)
+ WORKER_SIMPLE_PREF("dom.serviceWorkers.testing.enabled", ServiceWorkersTestingEnabled, SERVICEWORKERS_TESTING_ENABLED)
+ WORKER_SIMPLE_PREF("dom.storageManager.enabled", StorageManagerEnabled, STORAGEMANAGER_ENABLED)
+ WORKER_SIMPLE_PREF("dom.promise_rejection_events.enabled", PromiseRejectionEventsEnabled, PROMISE_REJECTION_EVENTS_ENABLED)
+ WORKER_SIMPLE_PREF("dom.push.enabled", PushEnabled, PUSH_ENABLED)
+ WORKER_SIMPLE_PREF("dom.streams.enabled", StreamsEnabled, STREAMS_ENABLED)
+ WORKER_SIMPLE_PREF("dom.requestcontext.enabled", RequestContextEnabled, REQUESTCONTEXT_ENABLED)
+ WORKER_SIMPLE_PREF("gfx.offscreencanvas.enabled", OffscreenCanvasEnabled, OFFSCREENCANVAS_ENABLED)

+ 317 - 0
frg/work-js/mozilla-release/patches/1419771-08-59a1.patch

@@ -0,0 +1,317 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1515416704 -3600
+# Node ID 0763044fef05cbd9e93cb37cac0ddd54eb98d7c2
+# Parent  52d225c7dd470de5485af11bdfc990a42a0b84af
+Bug 1419771 - Introduce DOMPrefs, a thread-safe access to preferences for DOM - part 8 - ServiceWorkers enabled, r=asuth
+
+diff --git a/dom/base/DOMPrefs.cpp b/dom/base/DOMPrefs.cpp
+--- a/dom/base/DOMPrefs.cpp
++++ b/dom/base/DOMPrefs.cpp
+@@ -36,27 +36,29 @@ DOMPrefs::DumpEnabled()
+ 
+ PREF(ImageBitmapExtensionsEnabled, "canvas.imagebitmap_extensions.enabled")
+ PREF(DOMCachesEnabled, "dom.caches.enabled")
+ PREF(DOMCachesTestingEnabled, "dom.caches.testing.enabled")
+ PREF(PerformanceLoggingEnabled, "dom.performance.enable_user_timing_logging")
+ PREF(NotificationEnabled, "dom.webnotifications.enabled")
+ PREF(NotificationEnabledInServiceWorkers, "dom.webnotifications.serviceworker.enabled")
+ PREF(NotificationRIEnabled, "dom.webnotifications.requireinteraction.enabled")
++PREF(ServiceWorkersEnabled, "dom.serviceWorkers.enabled")
+ 
+ #undef PREF
+ 
+ #define PREF_WEBIDL(name)                        \
+   /* static */ bool                              \
+   DOMPrefs::name(JSContext* aCx, JSObject* aObj) \
+   {                                              \
+     return DOMPrefs::name();                     \
+   }
+ 
+ PREF_WEBIDL(ImageBitmapExtensionsEnabled)
+ PREF_WEBIDL(DOMCachesEnabled)
+ PREF_WEBIDL(NotificationEnabledInServiceWorkers)
+ PREF_WEBIDL(NotificationRIEnabled)
++PREF_WEBIDL(ServiceWorkersEnabled)
+ 
+ #undef PREF_WEBIDL
+ 
+ } // dom namespace
+ } // mozilla namespace
+diff --git a/dom/base/DOMPrefs.h b/dom/base/DOMPrefs.h
+--- a/dom/base/DOMPrefs.h
++++ b/dom/base/DOMPrefs.h
+@@ -39,14 +39,18 @@ public:
+   static bool NotificationEnabledInServiceWorkers();
+   static bool NotificationEnabledInServiceWorkers(JSContext* aCx,
+                                                   JSObject* aObj);
+ 
+   // Returns true if the dom.webnotifications.requireinteraction.enabled pref is
+   // set.
+   static bool NotificationRIEnabled();
+   static bool NotificationRIEnabled(JSContext* aCx, JSObject* aObj);
++
++  // Returns true if the dom.serviceWorkers.enabled pref is set.
++  static bool ServiceWorkersEnabled();
++  static bool ServiceWorkersEnabled(JSContext* aCx, JSObject* aObj);
+ };
+ 
+ } // dom namespace
+ } // mozilla namespace
+ 
+ #endif // mozilla_dom_DOMPrefs_h
+diff --git a/dom/ipc/TabContext.cpp b/dom/ipc/TabContext.cpp
+--- a/dom/ipc/TabContext.cpp
++++ b/dom/ipc/TabContext.cpp
+@@ -3,16 +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/. */
+ 
+ #include "mozilla/dom/TabContext.h"
+ #include "mozilla/dom/PTabContext.h"
+ #include "mozilla/dom/TabParent.h"
+ #include "mozilla/dom/TabChild.h"
++#include "mozilla/dom/DOMPrefs.h"
+ #include "nsIScriptSecurityManager.h"
+ #include "nsServiceManagerUtils.h"
+ 
+ #define NO_APP_ID (nsIScriptSecurityManager::NO_APP_ID)
+ 
+ using namespace mozilla::dom::ipc;
+ using namespace mozilla::layout;
+ 
+@@ -235,17 +236,17 @@ MaybeInvalidTabContext::MaybeInvalidTabC
+       originAttributes = ipcContext.originAttributes();
+       break;
+     }
+     case IPCTabContext::TUnsafeIPCTabContext: {
+       // XXXcatalinb: This used *only* by ServiceWorkerClients::OpenWindow.
+       // It is meant as a temporary solution until service workers can
+       // provide a TabChild equivalent. Don't allow this on b2g since
+       // it might be used to escalate privileges.
+-      if (!Preferences::GetBool("dom.serviceWorkers.enabled", false)) {
++      if (!DOMPrefs::ServiceWorkersEnabled()) {
+         mInvalidReason = "ServiceWorkers should be enabled.";
+         return;
+       }
+ 
+       break;
+     }
+     default: {
+       MOZ_CRASH();
+diff --git a/dom/webidl/ServiceWorkerRegistration.webidl b/dom/webidl/ServiceWorkerRegistration.webidl
+--- a/dom/webidl/ServiceWorkerRegistration.webidl
++++ b/dom/webidl/ServiceWorkerRegistration.webidl
+@@ -4,17 +4,17 @@
+  * You can obtain one at http://mozilla.org/MPL/2.0/.
+  *
+  * The origin of this IDL file is
+  * http://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html
+  * https://w3c.github.io/push-api/
+  * https://notifications.spec.whatwg.org/
+  */
+ 
+-[Func="mozilla::dom::ServiceWorkerRegistration::Visible",
++[Func="mozilla::dom::DOMPrefs::ServiceWorkersEnabled",
+  Exposed=(Window,Worker)]
+ interface ServiceWorkerRegistration : EventTarget {
+   [Unforgeable] readonly attribute ServiceWorker? installing;
+   [Unforgeable] readonly attribute ServiceWorker? waiting;
+   [Unforgeable] readonly attribute ServiceWorker? active;
+ 
+   readonly attribute USVString scope;
+   [Throws]
+diff --git a/dom/workers/ServiceWorker.cpp b/dom/workers/ServiceWorker.cpp
+--- a/dom/workers/ServiceWorker.cpp
++++ b/dom/workers/ServiceWorker.cpp
+@@ -7,17 +7,17 @@
+ #include "ServiceWorker.h"
+ 
+ #include "nsIDocument.h"
+ #include "nsPIDOMWindow.h"
+ #include "ServiceWorkerManager.h"
+ #include "ServiceWorkerPrivate.h"
+ #include "WorkerPrivate.h"
+ 
+-#include "mozilla/Preferences.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"
+ 
+ #ifdef XP_WIN
+ #undef PostMessage
+ #endif
+@@ -28,17 +28,17 @@ using namespace mozilla::dom;
+ namespace mozilla {
+ namespace dom {
+ namespace workers {
+ 
+ bool
+ ServiceWorkerVisible(JSContext* aCx, JSObject* aObj)
+ {
+   if (NS_IsMainThread()) {
+-    return Preferences::GetBool("dom.serviceWorkers.enabled", false);
++    return DOMPrefs::ServiceWorkersEnabled();
+   }
+ 
+   return IS_INSTANCE_OF(ServiceWorkerGlobalScope, aObj);
+ }
+ 
+ ServiceWorker::ServiceWorker(nsPIDOMWindowInner* aWindow,
+                              ServiceWorkerInfo* aInfo)
+   : DOMEventTargetHelper(aWindow),
+diff --git a/dom/workers/ServiceWorkerContainer.cpp b/dom/workers/ServiceWorkerContainer.cpp
+--- a/dom/workers/ServiceWorkerContainer.cpp
++++ b/dom/workers/ServiceWorkerContainer.cpp
+@@ -7,22 +7,22 @@
+ #include "ServiceWorkerContainer.h"
+ 
+ #include "nsContentUtils.h"
+ #include "nsIDocument.h"
+ #include "nsIServiceWorkerManager.h"
+ #include "nsIURL.h"
+ #include "nsNetUtil.h"
+ #include "nsPIDOMWindow.h"
+-#include "mozilla/Preferences.h"
+ #include "mozilla/Services.h"
+ 
+ #include "nsCycleCollectionParticipant.h"
+ #include "nsServiceManagerUtils.h"
+ 
++#include "mozilla/dom/DOMPrefs.h"
+ #include "mozilla/dom/Navigator.h"
+ #include "mozilla/dom/Promise.h"
+ #include "mozilla/dom/ServiceWorkerContainerBinding.h"
+ #include "mozilla/dom/workers/bindings/ServiceWorker.h"
+ 
+ #include "ServiceWorker.h"
+ 
+ namespace mozilla {
+@@ -48,17 +48,17 @@ ServiceWorkerContainer::IsEnabled(JSCont
+     return false;
+   }
+ 
+   nsIDocument* doc = window->GetExtantDoc();
+   if (!doc || nsContentUtils::IsInPrivateBrowsing(doc)) {
+     return false;
+   }
+ 
+-  return Preferences::GetBool("dom.serviceWorkers.enabled", false);
++  return DOMPrefs::ServiceWorkersEnabled();
+ }
+ 
+ ServiceWorkerContainer::ServiceWorkerContainer(nsPIDOMWindowInner* aWindow)
+   : DOMEventTargetHelper(aWindow)
+ {
+ }
+ 
+ ServiceWorkerContainer::~ServiceWorkerContainer()
+diff --git a/dom/workers/ServiceWorkerRegistration.cpp b/dom/workers/ServiceWorkerRegistration.cpp
+--- a/dom/workers/ServiceWorkerRegistration.cpp
++++ b/dom/workers/ServiceWorkerRegistration.cpp
+@@ -2,24 +2,24 @@
+ /* 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 "ServiceWorkerRegistration.h"
+ 
+ #include "ipc/ErrorIPCUtils.h"
++#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/Preferences.h"
+ #include "mozilla/Services.h"
+ #include "mozilla/Unused.h"
+ #include "nsCycleCollectionParticipant.h"
+ #include "nsNetUtil.h"
+ #include "nsServiceManagerUtils.h"
+ #include "ServiceWorker.h"
+ #include "ServiceWorkerManager.h"
+ 
+@@ -33,32 +33,16 @@
+ #include "Workers.h"
+ #include "WorkerScope.h"
+ 
+ using namespace mozilla::dom::workers;
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+-/* static */ bool
+-ServiceWorkerRegistration::Visible(JSContext* aCx, JSObject* aObj)
+-{
+-  if (NS_IsMainThread()) {
+-    return Preferences::GetBool("dom.serviceWorkers.enabled", false);
+-  }
+-
+-  // Otherwise check the pref via the work private helper
+-  WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(aCx);
+-  if (!workerPrivate) {
+-    return false;
+-  }
+-
+-  return workerPrivate->ServiceWorkersEnabled();
+-}
+-
+ ////////////////////////////////////////////////////
+ // Main Thread implementation
+ 
+ class ServiceWorkerRegistrationMainThread final : public ServiceWorkerRegistration,
+                                                   public ServiceWorkerRegistrationListener
+ {
+   friend nsPIDOMWindowInner;
+ public:
+diff --git a/dom/workers/ServiceWorkerRegistration.h b/dom/workers/ServiceWorkerRegistration.h
+--- a/dom/workers/ServiceWorkerRegistration.h
++++ b/dom/workers/ServiceWorkerRegistration.h
+@@ -56,19 +56,16 @@ public:
+ 
+ class ServiceWorkerRegistration : public DOMEventTargetHelper
+ {
+ public:
+   NS_DECL_ISUPPORTS_INHERITED
+ 
+   IMPL_EVENT_HANDLER(updatefound)
+ 
+-  static bool
+-  Visible(JSContext* aCx, JSObject* aObj);
+-
+   static already_AddRefed<ServiceWorkerRegistration>
+   CreateForMainThread(nsPIDOMWindowInner* aWindow,
+                       const nsAString& aScope);
+ 
+   static already_AddRefed<ServiceWorkerRegistration>
+   CreateForWorker(workers::WorkerPrivate* aWorkerPrivate,
+                   const nsAString& aScope);
+ 
+diff --git a/dom/workers/WorkerPrefs.h b/dom/workers/WorkerPrefs.h
+--- a/dom/workers/WorkerPrefs.h
++++ b/dom/workers/WorkerPrefs.h
+@@ -16,17 +16,16 @@
+ //     macro in Workers.h.
+ //   * The name of the function that updates the new value of a pref.
+ //
+ //   WORKER_PREF("foo.bar", UpdaterFunction)
+ //
+ //   * First argument is the name of the pref.
+ //   * The name of the function that updates the new value of a pref.
+ 
+-WORKER_SIMPLE_PREF("dom.serviceWorkers.enabled", ServiceWorkersEnabled, SERVICEWORKERS_ENABLED)
+ WORKER_SIMPLE_PREF("dom.serviceWorkers.testing.enabled", ServiceWorkersTestingEnabled, SERVICEWORKERS_TESTING_ENABLED)
+ WORKER_SIMPLE_PREF("dom.storageManager.enabled", StorageManagerEnabled, STORAGEMANAGER_ENABLED)
+ WORKER_SIMPLE_PREF("dom.promise_rejection_events.enabled", PromiseRejectionEventsEnabled, PROMISE_REJECTION_EVENTS_ENABLED)
+ WORKER_SIMPLE_PREF("dom.push.enabled", PushEnabled, PUSH_ENABLED)
+ WORKER_SIMPLE_PREF("dom.streams.enabled", StreamsEnabled, STREAMS_ENABLED)
+ WORKER_SIMPLE_PREF("dom.requestcontext.enabled", RequestContextEnabled, REQUESTCONTEXT_ENABLED)
+ WORKER_SIMPLE_PREF("gfx.offscreencanvas.enabled", OffscreenCanvasEnabled, OFFSCREENCANVAS_ENABLED)
+ WORKER_SIMPLE_PREF("dom.webkitBlink.dirPicker.enabled", WebkitBlinkDirectoryPickerEnabled, DOM_WEBKITBLINK_DIRPICKER_WEBKITBLINK)

+ 209 - 0
frg/work-js/mozilla-release/patches/1419771-09-59a1.patch

@@ -0,0 +1,209 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1515416704 -3600
+# Node ID 785e52d7a0fe18043aaa701b2b14429183388015
+# Parent  f6a9318eba63e6aa57766effd3848ed6738d96a9
+Bug 1419771 - Introduce DOMPrefs, a thread-safe access to preferences for DOM - part 9 - ServiceWorker testing enabled, r=asuth
+
+diff --git a/dom/base/DOMPrefs.cpp b/dom/base/DOMPrefs.cpp
+--- a/dom/base/DOMPrefs.cpp
++++ b/dom/base/DOMPrefs.cpp
+@@ -37,16 +37,17 @@ DOMPrefs::DumpEnabled()
+ PREF(ImageBitmapExtensionsEnabled, "canvas.imagebitmap_extensions.enabled")
+ PREF(DOMCachesEnabled, "dom.caches.enabled")
+ PREF(DOMCachesTestingEnabled, "dom.caches.testing.enabled")
+ PREF(PerformanceLoggingEnabled, "dom.performance.enable_user_timing_logging")
+ PREF(NotificationEnabled, "dom.webnotifications.enabled")
+ PREF(NotificationEnabledInServiceWorkers, "dom.webnotifications.serviceworker.enabled")
+ PREF(NotificationRIEnabled, "dom.webnotifications.requireinteraction.enabled")
+ PREF(ServiceWorkersEnabled, "dom.serviceWorkers.enabled")
++PREF(ServiceWorkersTestingEnabled, "dom.serviceWorkers.testing.enabled")
+ 
+ #undef PREF
+ 
+ #define PREF_WEBIDL(name)                        \
+   /* static */ bool                              \
+   DOMPrefs::name(JSContext* aCx, JSObject* aObj) \
+   {                                              \
+     return DOMPrefs::name();                     \
+diff --git a/dom/base/DOMPrefs.h b/dom/base/DOMPrefs.h
+--- a/dom/base/DOMPrefs.h
++++ b/dom/base/DOMPrefs.h
+@@ -43,14 +43,17 @@ public:
+   // Returns true if the dom.webnotifications.requireinteraction.enabled pref is
+   // set.
+   static bool NotificationRIEnabled();
+   static bool NotificationRIEnabled(JSContext* aCx, JSObject* aObj);
+ 
+   // Returns true if the dom.serviceWorkers.enabled pref is set.
+   static bool ServiceWorkersEnabled();
+   static bool ServiceWorkersEnabled(JSContext* aCx, JSObject* aObj);
++
++  // Returns true if the dom.serviceWorkers.testing.enabled pref is set.
++  static bool ServiceWorkersTestingEnabled();
+ };
+ 
+ } // dom namespace
+ } // mozilla namespace
+ 
+ #endif // mozilla_dom_DOMPrefs_h
+diff --git a/dom/cache/CacheStorage.cpp b/dom/cache/CacheStorage.cpp
+--- a/dom/cache/CacheStorage.cpp
++++ b/dom/cache/CacheStorage.cpp
+@@ -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/. */
+ 
+ #include "mozilla/dom/cache/CacheStorage.h"
+ 
+ #include "mozilla/Unused.h"
+ #include "mozilla/dom/CacheBinding.h"
+ #include "mozilla/dom/CacheStorageBinding.h"
++#include "mozilla/dom/DOMPrefs.h"
+ #include "mozilla/dom/InternalRequest.h"
+ #include "mozilla/dom/Promise.h"
+ #include "mozilla/dom/Response.h"
+ #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"
+@@ -156,17 +157,17 @@ CacheStorage::CreateOnMainThread(Namespa
+   nsresult rv = PrincipalToPrincipalInfo(aPrincipal, &principalInfo);
+   if (NS_WARN_IF(NS_FAILED(rv))) {
+     aRv.Throw(rv);
+     return nullptr;
+   }
+ 
+   bool testingEnabled = aForceTrustedOrigin ||
+     Preferences::GetBool("dom.caches.testing.enabled", false) ||
+-    Preferences::GetBool("dom.serviceWorkers.testing.enabled", false);
++    DOMPrefs::ServiceWorkersTestingEnabled();
+ 
+   if (!IsTrusted(principalInfo, testingEnabled)) {
+     NS_WARNING("CacheStorage not supported on untrusted origins.");
+     RefPtr<CacheStorage> ref = new CacheStorage(NS_ERROR_DOM_SECURITY_ERR);
+     return ref.forget();
+   }
+ 
+   RefPtr<CacheStorage> ref = new CacheStorage(aNamespace, aGlobal,
+@@ -215,17 +216,17 @@ CacheStorage::CreateOnWorker(Namespace a
+   //    SWs are enabled.
+   // 3) If the window that created this worker has the devtools SW testing
+   //    option enabled.  Same reasoning as (2).
+   // 4) If the worker itself is a ServiceWorker, then we always skip the
+   //    origin checks.  The ServiceWorker has its own trusted origin checks
+   //    that are better than ours.  In addition, we don't have information
+   //    about the window any more, so we can't do our own checks.
+   bool testingEnabled = DOMPrefs::DOMCachesTestingEnabled() ||
+-                        aWorkerPrivate->ServiceWorkersTestingEnabled() ||
++                        DOMPrefs::ServiceWorkersTestingEnabled() ||
+                         aWorkerPrivate->ServiceWorkersTestingInWindow() ||
+                         aWorkerPrivate->IsServiceWorker();
+ 
+   if (!IsTrusted(principalInfo, testingEnabled)) {
+     NS_WARNING("CacheStorage not supported on untrusted origins.");
+     RefPtr<CacheStorage> ref = new CacheStorage(NS_ERROR_DOM_SECURITY_ERR);
+     return ref.forget();
+   }
+diff --git a/dom/workers/ServiceWorkerManager.cpp b/dom/workers/ServiceWorkerManager.cpp
+--- a/dom/workers/ServiceWorkerManager.cpp
++++ b/dom/workers/ServiceWorkerManager.cpp
+@@ -35,16 +35,17 @@
+ #include "mozilla/ErrorNames.h"
+ #include "mozilla/LoadContext.h"
+ #include "mozilla/SystemGroup.h"
+ #include "mozilla/Telemetry.h"
+ #include "mozilla/dom/BindingUtils.h"
+ #include "mozilla/dom/ClientHandle.h"
+ #include "mozilla/dom/ClientManager.h"
+ #include "mozilla/dom/ContentParent.h"
++#include "mozilla/dom/DOMPrefs.h"
+ #include "mozilla/dom/ErrorEvent.h"
+ #include "mozilla/dom/Headers.h"
+ #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"
+@@ -820,17 +821,17 @@ ServiceWorkerManager::Register(mozIDOMWi
+     return NS_ERROR_DOM_SECURITY_ERR;
+   }
+ 
+   nsCOMPtr<nsPIDOMWindowOuter> outerWindow = window->GetOuterWindow();
+   bool serviceWorkersTestingEnabled =
+     outerWindow->GetServiceWorkersTestingEnabled();
+ 
+   bool authenticatedOrigin;
+-  if (Preferences::GetBool("dom.serviceWorkers.testing.enabled") ||
++  if (DOMPrefs::ServiceWorkersTestingEnabled() ||
+       serviceWorkersTestingEnabled) {
+     authenticatedOrigin = true;
+   } else {
+     authenticatedOrigin = IsFromAuthenticatedOrigin(doc);
+   }
+ 
+   if (!authenticatedOrigin) {
+     NS_WARNING("ServiceWorker registration from insecure websites is not allowed.");
+diff --git a/dom/workers/ServiceWorkerPrivate.cpp b/dom/workers/ServiceWorkerPrivate.cpp
+--- a/dom/workers/ServiceWorkerPrivate.cpp
++++ b/dom/workers/ServiceWorkerPrivate.cpp
+@@ -21,16 +21,17 @@
+ #include "nsQueryObject.h"
+ #include "nsStreamUtils.h"
+ #include "nsStringStream.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/Unused.h"
+@@ -1929,17 +1930,17 @@ ServiceWorkerPrivate::RemoveISupports(ns
+ void
+ ServiceWorkerPrivate::TerminateWorker()
+ {
+   AssertIsOnMainThread();
+ 
+   mIdleWorkerTimer->Cancel();
+   mIdleKeepAliveToken = nullptr;
+   if (mWorkerPrivate) {
+-    if (Preferences::GetBool("dom.serviceWorkers.testing.enabled")) {
++    if (DOMPrefs::ServiceWorkersTestingEnabled()) {
+       nsCOMPtr<nsIObserverService> os = services::GetObserverService();
+       if (os) {
+         os->NotifyObservers(nullptr, "service-worker-shutdown", nullptr);
+       }
+     }
+ 
+     Unused << NS_WARN_IF(!mWorkerPrivate->Terminate());
+     mWorkerPrivate = nullptr;
+diff --git a/dom/workers/WorkerPrefs.h b/dom/workers/WorkerPrefs.h
+--- a/dom/workers/WorkerPrefs.h
++++ b/dom/workers/WorkerPrefs.h
+@@ -16,17 +16,16 @@
+ //     macro in Workers.h.
+ //   * The name of the function that updates the new value of a pref.
+ //
+ //   WORKER_PREF("foo.bar", UpdaterFunction)
+ //
+ //   * First argument is the name of the pref.
+ //   * The name of the function that updates the new value of a pref.
+ 
+-WORKER_SIMPLE_PREF("dom.serviceWorkers.testing.enabled", ServiceWorkersTestingEnabled, SERVICEWORKERS_TESTING_ENABLED)
+ WORKER_SIMPLE_PREF("dom.storageManager.enabled", StorageManagerEnabled, STORAGEMANAGER_ENABLED)
+ WORKER_SIMPLE_PREF("dom.promise_rejection_events.enabled", PromiseRejectionEventsEnabled, PROMISE_REJECTION_EVENTS_ENABLED)
+ WORKER_SIMPLE_PREF("dom.push.enabled", PushEnabled, PUSH_ENABLED)
+ WORKER_SIMPLE_PREF("dom.streams.enabled", StreamsEnabled, STREAMS_ENABLED)
+ WORKER_SIMPLE_PREF("dom.requestcontext.enabled", RequestContextEnabled, REQUESTCONTEXT_ENABLED)
+ WORKER_SIMPLE_PREF("gfx.offscreencanvas.enabled", OffscreenCanvasEnabled, OFFSCREENCANVAS_ENABLED)
+ WORKER_SIMPLE_PREF("dom.webkitBlink.dirPicker.enabled", WebkitBlinkDirectoryPickerEnabled, DOM_WEBKITBLINK_DIRPICKER_WEBKITBLINK)
+ WORKER_SIMPLE_PREF("dom.netinfo.enabled", NetworkInformationEnabled, NETWORKINFORMATION_ENABLED)

+ 204 - 0
frg/work-js/mozilla-release/patches/1419771-10-59a1.patch

@@ -0,0 +1,204 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1515416704 -3600
+# Node ID ccb06ac64f582189c866ed8ab9834a6353b3cdd3
+# Parent  eef2d49ed76c0d4a8779882382d53f4a71310bdd
+Bug 1419771 - Introduce DOMPrefs, a thread-safe access to preferences for DOM - part 10 - StorageManager enabled, r=asuth
+
+diff --git a/dom/base/DOMPrefs.cpp b/dom/base/DOMPrefs.cpp
+--- a/dom/base/DOMPrefs.cpp
++++ b/dom/base/DOMPrefs.cpp
+@@ -38,28 +38,30 @@ PREF(ImageBitmapExtensionsEnabled, "canv
+ PREF(DOMCachesEnabled, "dom.caches.enabled")
+ PREF(DOMCachesTestingEnabled, "dom.caches.testing.enabled")
+ PREF(PerformanceLoggingEnabled, "dom.performance.enable_user_timing_logging")
+ PREF(NotificationEnabled, "dom.webnotifications.enabled")
+ PREF(NotificationEnabledInServiceWorkers, "dom.webnotifications.serviceworker.enabled")
+ PREF(NotificationRIEnabled, "dom.webnotifications.requireinteraction.enabled")
+ PREF(ServiceWorkersEnabled, "dom.serviceWorkers.enabled")
+ PREF(ServiceWorkersTestingEnabled, "dom.serviceWorkers.testing.enabled")
++PREF(StorageManagerEnabled, "dom.storageManager.enabled")
+ 
+ #undef PREF
+ 
+ #define PREF_WEBIDL(name)                        \
+   /* static */ bool                              \
+   DOMPrefs::name(JSContext* aCx, JSObject* aObj) \
+   {                                              \
+     return DOMPrefs::name();                     \
+   }
+ 
+ PREF_WEBIDL(ImageBitmapExtensionsEnabled)
+ PREF_WEBIDL(DOMCachesEnabled)
+ PREF_WEBIDL(NotificationEnabledInServiceWorkers)
+ PREF_WEBIDL(NotificationRIEnabled)
+ PREF_WEBIDL(ServiceWorkersEnabled)
++PREF_WEBIDL(StorageManagerEnabled)
+ 
+ #undef PREF_WEBIDL
+ 
+ } // dom namespace
+ } // mozilla namespace
+diff --git a/dom/base/DOMPrefs.h b/dom/base/DOMPrefs.h
+--- a/dom/base/DOMPrefs.h
++++ b/dom/base/DOMPrefs.h
+@@ -46,14 +46,18 @@ public:
+   static bool NotificationRIEnabled(JSContext* aCx, JSObject* aObj);
+ 
+   // Returns true if the dom.serviceWorkers.enabled pref is set.
+   static bool ServiceWorkersEnabled();
+   static bool ServiceWorkersEnabled(JSContext* aCx, JSObject* aObj);
+ 
+   // Returns true if the dom.serviceWorkers.testing.enabled pref is set.
+   static bool ServiceWorkersTestingEnabled();
++
++  // Returns true if the dom.storageManager.enabled pref is set.
++  static bool StorageManagerEnabled();
++  static bool StorageManagerEnabled(JSContext* aCx, JSObject* aObj);
+ };
+ 
+ } // dom namespace
+ } // mozilla namespace
+ 
+ #endif // mozilla_dom_DOMPrefs_h
+diff --git a/dom/quota/StorageManager.cpp b/dom/quota/StorageManager.cpp
+--- a/dom/quota/StorageManager.cpp
++++ b/dom/quota/StorageManager.cpp
+@@ -1,16 +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 "StorageManager.h"
+ 
++#include "mozilla/dom/DOMPrefs.h"
+ #include "mozilla/dom/PromiseWorkerProxy.h"
+ #include "mozilla/dom/quota/QuotaManagerService.h"
+ #include "mozilla/dom/StorageManagerBinding.h"
+ #include "mozilla/dom/WorkerPrivate.h"
+ #include "mozilla/ErrorResult.h"
+ #include "mozilla/Telemetry.h"
+ #include "nsContentPermissionHelper.h"
+ #include "nsIQuotaCallbacks.h"
+@@ -845,30 +846,16 @@ StorageManager::Estimate(ErrorResult& aR
+ 
+   Telemetry::ScalarAdd(Telemetry::ScalarID::NAVIGATOR_STORAGE_ESTIMATE_COUNT,
+                        1);
+   return ExecuteOpOnMainOrWorkerThread(mOwner,
+                                        RequestResolver::Type::Estimate,
+                                        aRv);
+ }
+ 
+-// static
+-bool
+-StorageManager::PrefEnabled(JSContext* aCx, JSObject* aObj)
+-{
+-  if (NS_IsMainThread()) {
+-    return Preferences::GetBool("dom.storageManager.enabled");
+-  }
+-
+-  WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(aCx);
+-  MOZ_ASSERT(workerPrivate);
+-
+-  return workerPrivate->StorageManagerEnabled();
+-}
+-
+ NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(StorageManager, mOwner)
+ 
+ NS_IMPL_CYCLE_COLLECTING_ADDREF(StorageManager)
+ NS_IMPL_CYCLE_COLLECTING_RELEASE(StorageManager)
+ 
+ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(StorageManager)
+   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
+   NS_INTERFACE_MAP_ENTRY(nsISupports)
+diff --git a/dom/quota/StorageManager.h b/dom/quota/StorageManager.h
+--- a/dom/quota/StorageManager.h
++++ b/dom/quota/StorageManager.h
+@@ -20,20 +20,16 @@ struct StorageEstimate;
+ 
+ class StorageManager final
+   : public nsISupports
+   , public nsWrapperCache
+ {
+   nsCOMPtr<nsIGlobalObject> mOwner;
+ 
+ public:
+-  // Return dom.quota.storageManager.enabled on main/worker thread.
+-  static bool
+-  PrefEnabled(JSContext* aCx, JSObject* aObj);
+-
+   explicit
+   StorageManager(nsIGlobalObject* aGlobal);
+ 
+   nsIGlobalObject*
+   GetParentObject() const
+   {
+     return mOwner;
+   }
+diff --git a/dom/webidl/Navigator.webidl b/dom/webidl/Navigator.webidl
+--- a/dom/webidl/Navigator.webidl
++++ b/dom/webidl/Navigator.webidl
+@@ -83,17 +83,17 @@ interface NavigatorContentUtils {
+   //DOMString isProtocolHandlerRegistered(DOMString scheme, DOMString url);
+   //DOMString isContentHandlerRegistered(DOMString mimeType, DOMString url);
+   //void unregisterProtocolHandler(DOMString scheme, DOMString url);
+   //void unregisterContentHandler(DOMString mimeType, DOMString url);
+ };
+ 
+ [SecureContext, NoInterfaceObject, Exposed=(Window,Worker)]
+ interface NavigatorStorage {
+-  [Func="mozilla::dom::StorageManager::PrefEnabled"]
++  [Func="mozilla::dom::DOMPrefs::StorageManagerEnabled"]
+   readonly attribute StorageManager storage;
+ };
+ 
+ [NoInterfaceObject]
+ interface NavigatorStorageUtils {
+   // NOT IMPLEMENTED
+   //void yieldForStorageUpdates();
+ };
+diff --git a/dom/webidl/StorageManager.webidl b/dom/webidl/StorageManager.webidl
+--- a/dom/webidl/StorageManager.webidl
++++ b/dom/webidl/StorageManager.webidl
+@@ -5,17 +5,17 @@
+  *
+  * The origin of this IDL file is
+  * https://storage.spec.whatwg.org/#storagemanager
+  *
+  */
+ 
+ [SecureContext,
+  Exposed=(Window,Worker),
+- Func="mozilla::dom::StorageManager::PrefEnabled"]
++ Func="mozilla::dom::DOMPrefs::StorageManagerEnabled"]
+ interface StorageManager {
+   [Throws]
+   Promise<boolean> persisted();
+ 
+   [Exposed=Window, Throws]
+   Promise<boolean> persist();
+ 
+   [Throws]
+diff --git a/dom/workers/WorkerPrefs.h b/dom/workers/WorkerPrefs.h
+--- a/dom/workers/WorkerPrefs.h
++++ b/dom/workers/WorkerPrefs.h
+@@ -16,17 +16,16 @@
+ //     macro in Workers.h.
+ //   * The name of the function that updates the new value of a pref.
+ //
+ //   WORKER_PREF("foo.bar", UpdaterFunction)
+ //
+ //   * First argument is the name of the pref.
+ //   * The name of the function that updates the new value of a pref.
+ 
+-WORKER_SIMPLE_PREF("dom.storageManager.enabled", StorageManagerEnabled, STORAGEMANAGER_ENABLED)
+ WORKER_SIMPLE_PREF("dom.promise_rejection_events.enabled", PromiseRejectionEventsEnabled, PROMISE_REJECTION_EVENTS_ENABLED)
+ WORKER_SIMPLE_PREF("dom.push.enabled", PushEnabled, PUSH_ENABLED)
+ WORKER_SIMPLE_PREF("dom.streams.enabled", StreamsEnabled, STREAMS_ENABLED)
+ WORKER_SIMPLE_PREF("dom.requestcontext.enabled", RequestContextEnabled, REQUESTCONTEXT_ENABLED)
+ WORKER_SIMPLE_PREF("gfx.offscreencanvas.enabled", OffscreenCanvasEnabled, OFFSCREENCANVAS_ENABLED)
+ WORKER_SIMPLE_PREF("dom.webkitBlink.dirPicker.enabled", WebkitBlinkDirectoryPickerEnabled, DOM_WEBKITBLINK_DIRPICKER_WEBKITBLINK)
+ WORKER_SIMPLE_PREF("dom.netinfo.enabled", NetworkInformationEnabled, NETWORKINFORMATION_ENABLED)
+ WORKER_SIMPLE_PREF("dom.fetchObserver.enabled", FetchObserverEnabled, FETCHOBSERVER_ENABLED)

+ 168 - 0
frg/work-js/mozilla-release/patches/1419771-11-59a1.patch

@@ -0,0 +1,168 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1515416704 -3600
+# Node ID 6b6ce0862fd4cd54d2b6fb142efed53cf4bb307e
+# Parent  bd92a839216f6de0b4056177dec04a4e79aeca99
+Bug 1419771 - Introduce DOMPrefs, a thread-safe access to preferences for DOM - part 11 - Promise Rejection Event enabled, r=asuth
+
+diff --git a/dom/base/DOMPrefs.cpp b/dom/base/DOMPrefs.cpp
+--- a/dom/base/DOMPrefs.cpp
++++ b/dom/base/DOMPrefs.cpp
+@@ -39,29 +39,31 @@ PREF(DOMCachesEnabled, "dom.caches.enabl
+ PREF(DOMCachesTestingEnabled, "dom.caches.testing.enabled")
+ PREF(PerformanceLoggingEnabled, "dom.performance.enable_user_timing_logging")
+ PREF(NotificationEnabled, "dom.webnotifications.enabled")
+ PREF(NotificationEnabledInServiceWorkers, "dom.webnotifications.serviceworker.enabled")
+ PREF(NotificationRIEnabled, "dom.webnotifications.requireinteraction.enabled")
+ PREF(ServiceWorkersEnabled, "dom.serviceWorkers.enabled")
+ PREF(ServiceWorkersTestingEnabled, "dom.serviceWorkers.testing.enabled")
+ PREF(StorageManagerEnabled, "dom.storageManager.enabled")
++PREF(PromiseRejectionEventsEnabled, "dom.promise_rejection_events.enabled")
+ 
+ #undef PREF
+ 
+ #define PREF_WEBIDL(name)                        \
+   /* static */ bool                              \
+   DOMPrefs::name(JSContext* aCx, JSObject* aObj) \
+   {                                              \
+     return DOMPrefs::name();                     \
+   }
+ 
+ PREF_WEBIDL(ImageBitmapExtensionsEnabled)
+ PREF_WEBIDL(DOMCachesEnabled)
+ PREF_WEBIDL(NotificationEnabledInServiceWorkers)
+ PREF_WEBIDL(NotificationRIEnabled)
+ PREF_WEBIDL(ServiceWorkersEnabled)
+ PREF_WEBIDL(StorageManagerEnabled)
++PREF_WEBIDL(PromiseRejectionEventsEnabled)
+ 
+ #undef PREF_WEBIDL
+ 
+ } // dom namespace
+ } // mozilla namespace
+diff --git a/dom/base/DOMPrefs.h b/dom/base/DOMPrefs.h
+--- a/dom/base/DOMPrefs.h
++++ b/dom/base/DOMPrefs.h
+@@ -50,14 +50,18 @@ public:
+   static bool ServiceWorkersEnabled(JSContext* aCx, JSObject* aObj);
+ 
+   // Returns true if the dom.serviceWorkers.testing.enabled pref is set.
+   static bool ServiceWorkersTestingEnabled();
+ 
+   // Returns true if the dom.storageManager.enabled pref is set.
+   static bool StorageManagerEnabled();
+   static bool StorageManagerEnabled(JSContext* aCx, JSObject* aObj);
++
++  // Returns true if the dom.promise_rejection_events.enabled pref is set.
++  static bool PromiseRejectionEventsEnabled();
++  static bool PromiseRejectionEventsEnabled(JSContext* aCx, JSObject* aObj);
+ };
+ 
+ } // dom namespace
+ } // mozilla namespace
+ 
+ #endif // mozilla_dom_DOMPrefs_h
+diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp
+--- a/dom/base/nsContentUtils.cpp
++++ b/dom/base/nsContentUtils.cpp
+@@ -9071,35 +9071,16 @@ nsContentUtils::GetReferrerPolicyFromHea
+       referrerPolicy = policy;
+     }
+   }
+   return referrerPolicy;
+ }
+ 
+ // static
+ bool
+-nsContentUtils::PromiseRejectionEventsEnabled(JSContext* aCx, JSObject* aObj)
+-{
+-  if (NS_IsMainThread()) {
+-    return Preferences::GetBool("dom.promise_rejection_events.enabled", false);
+-  }
+-
+-  using namespace workers;
+-
+-  // Otherwise, check the pref via the WorkerPrivate
+-  WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(aCx);
+-  if (!workerPrivate) {
+-    return false;
+-  }
+-
+-  return workerPrivate->PromiseRejectionEventsEnabled();
+-}
+-
+-// static
+-bool
+ nsContentUtils::PushEnabled(JSContext* aCx, JSObject* aObj)
+ {
+   if (NS_IsMainThread()) {
+     return Preferences::GetBool("dom.push.enabled", false);
+   }
+ 
+   using namespace workers;
+ 
+diff --git a/dom/base/nsContentUtils.h b/dom/base/nsContentUtils.h
+--- a/dom/base/nsContentUtils.h
++++ b/dom/base/nsContentUtils.h
+@@ -2952,18 +2952,16 @@ public:
+    * Parse a referrer policy from a Referrer-Policy header
+    * https://www.w3.org/TR/referrer-policy/#parse-referrer-policy-from-header
+    *
+    * @param aHeader the response's Referrer-Policy header to parse
+    * @return referrer policy from the response header.
+    */
+   static mozilla::net::ReferrerPolicy GetReferrerPolicyFromHeader(const nsAString& aHeader);
+ 
+-  static bool PromiseRejectionEventsEnabled(JSContext* aCx, JSObject* aObj);
+-
+   static bool PushEnabled(JSContext* aCx, JSObject* aObj);
+ 
+   static bool StreamsEnabled(JSContext* aCx, JSObject* aObj);
+ 
+   static bool IsNonSubresourceRequest(nsIChannel* aChannel);
+ 
+   static uint32_t CookiesBehavior()
+   {
+diff --git a/dom/webidl/PromiseRejectionEvent.webidl b/dom/webidl/PromiseRejectionEvent.webidl
+--- a/dom/webidl/PromiseRejectionEvent.webidl
++++ b/dom/webidl/PromiseRejectionEvent.webidl
+@@ -1,17 +1,17 @@
+ /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+ /* 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/.
+  */
+ 
+ [Constructor(DOMString type, PromiseRejectionEventInit eventInitDict),
+  Exposed=(Window,Worker),
+- Func="nsContentUtils::PromiseRejectionEventsEnabled"]
++ Func="mozilla::dom::DOMPrefs::PromiseRejectionEventsEnabled"]
+ interface PromiseRejectionEvent : Event
+ {
+   [BinaryName="rejectedPromise"]
+   readonly attribute Promise<any> promise;
+   readonly attribute any reason;
+ };
+ 
+ dictionary PromiseRejectionEventInit : EventInit {
+diff --git a/dom/workers/WorkerPrefs.h b/dom/workers/WorkerPrefs.h
+--- a/dom/workers/WorkerPrefs.h
++++ b/dom/workers/WorkerPrefs.h
+@@ -16,17 +16,16 @@
+ //     macro in Workers.h.
+ //   * The name of the function that updates the new value of a pref.
+ //
+ //   WORKER_PREF("foo.bar", UpdaterFunction)
+ //
+ //   * First argument is the name of the pref.
+ //   * The name of the function that updates the new value of a pref.
+ 
+-WORKER_SIMPLE_PREF("dom.promise_rejection_events.enabled", PromiseRejectionEventsEnabled, PROMISE_REJECTION_EVENTS_ENABLED)
+ WORKER_SIMPLE_PREF("dom.push.enabled", PushEnabled, PUSH_ENABLED)
+ WORKER_SIMPLE_PREF("dom.streams.enabled", StreamsEnabled, STREAMS_ENABLED)
+ WORKER_SIMPLE_PREF("dom.requestcontext.enabled", RequestContextEnabled, REQUESTCONTEXT_ENABLED)
+ WORKER_SIMPLE_PREF("gfx.offscreencanvas.enabled", OffscreenCanvasEnabled, OFFSCREENCANVAS_ENABLED)
+ WORKER_SIMPLE_PREF("dom.webkitBlink.dirPicker.enabled", WebkitBlinkDirectoryPickerEnabled, DOM_WEBKITBLINK_DIRPICKER_WEBKITBLINK)
+ WORKER_SIMPLE_PREF("dom.netinfo.enabled", NetworkInformationEnabled, NETWORKINFORMATION_ENABLED)
+ WORKER_SIMPLE_PREF("dom.fetchObserver.enabled", FetchObserverEnabled, FETCHOBSERVER_ENABLED)
+ WORKER_SIMPLE_PREF("privacy.resistFingerprinting", ResistFingerprintingEnabled, RESISTFINGERPRINTING_ENABLED)

+ 378 - 0
frg/work-js/mozilla-release/patches/1419771-12-59a1.patch

@@ -0,0 +1,378 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1515416705 -3600
+# Node ID c5c4104210b2315a8ed4de66cc7e16522a43deb5
+# Parent  ca65c2674345abeb070fb93fdab10049712b4378
+Bug 1419771 - Introduce DOMPrefs, a thread-safe access to preferences for DOM - part 12 - Push enabled, r=asuth
+
+diff --git a/dom/base/DOMPrefs.cpp b/dom/base/DOMPrefs.cpp
+--- a/dom/base/DOMPrefs.cpp
++++ b/dom/base/DOMPrefs.cpp
+@@ -40,16 +40,17 @@ PREF(DOMCachesTestingEnabled, "dom.cache
+ PREF(PerformanceLoggingEnabled, "dom.performance.enable_user_timing_logging")
+ PREF(NotificationEnabled, "dom.webnotifications.enabled")
+ PREF(NotificationEnabledInServiceWorkers, "dom.webnotifications.serviceworker.enabled")
+ PREF(NotificationRIEnabled, "dom.webnotifications.requireinteraction.enabled")
+ PREF(ServiceWorkersEnabled, "dom.serviceWorkers.enabled")
+ PREF(ServiceWorkersTestingEnabled, "dom.serviceWorkers.testing.enabled")
+ PREF(StorageManagerEnabled, "dom.storageManager.enabled")
+ PREF(PromiseRejectionEventsEnabled, "dom.promise_rejection_events.enabled")
++PREF(PushEnabled, "dom.push.enabled")
+ 
+ #undef PREF
+ 
+ #define PREF_WEBIDL(name)                        \
+   /* static */ bool                              \
+   DOMPrefs::name(JSContext* aCx, JSObject* aObj) \
+   {                                              \
+     return DOMPrefs::name();                     \
+@@ -57,13 +58,14 @@ PREF(PromiseRejectionEventsEnabled, "dom
+ 
+ PREF_WEBIDL(ImageBitmapExtensionsEnabled)
+ PREF_WEBIDL(DOMCachesEnabled)
+ PREF_WEBIDL(NotificationEnabledInServiceWorkers)
+ PREF_WEBIDL(NotificationRIEnabled)
+ PREF_WEBIDL(ServiceWorkersEnabled)
+ PREF_WEBIDL(StorageManagerEnabled)
+ PREF_WEBIDL(PromiseRejectionEventsEnabled)
++PREF_WEBIDL(PushEnabled)
+ 
+ #undef PREF_WEBIDL
+ 
+ } // dom namespace
+ } // mozilla namespace
+diff --git a/dom/base/DOMPrefs.h b/dom/base/DOMPrefs.h
+--- a/dom/base/DOMPrefs.h
++++ b/dom/base/DOMPrefs.h
+@@ -54,14 +54,18 @@ public:
+ 
+   // Returns true if the dom.storageManager.enabled pref is set.
+   static bool StorageManagerEnabled();
+   static bool StorageManagerEnabled(JSContext* aCx, JSObject* aObj);
+ 
+   // Returns true if the dom.promise_rejection_events.enabled pref is set.
+   static bool PromiseRejectionEventsEnabled();
+   static bool PromiseRejectionEventsEnabled(JSContext* aCx, JSObject* aObj);
++
++  // Returns true if the dom.push.enabled pref is set.
++  static bool PushEnabled();
++  static bool PushEnabled(JSContext* aCx, JSObject* aObj);
+ };
+ 
+ } // dom namespace
+ } // mozilla namespace
+ 
+ #endif // mozilla_dom_DOMPrefs_h
+diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp
+--- a/dom/base/nsContentUtils.cpp
++++ b/dom/base/nsContentUtils.cpp
+@@ -9071,35 +9071,16 @@ nsContentUtils::GetReferrerPolicyFromHea
+       referrerPolicy = policy;
+     }
+   }
+   return referrerPolicy;
+ }
+ 
+ // static
+ bool
+-nsContentUtils::PushEnabled(JSContext* aCx, JSObject* aObj)
+-{
+-  if (NS_IsMainThread()) {
+-    return Preferences::GetBool("dom.push.enabled", false);
+-  }
+-
+-  using namespace workers;
+-
+-  // Otherwise, check the pref via the WorkerPrivate
+-  WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(aCx);
+-  if (!workerPrivate) {
+-    return false;
+-  }
+-
+-  return workerPrivate->PushEnabled();
+-}
+-
+-// static
+-bool
+ nsContentUtils::StreamsEnabled(JSContext* aCx, JSObject* aObj)
+ {
+   if (NS_IsMainThread()) {
+     return Preferences::GetBool("dom.streams.enabled", false);
+   }
+ 
+   using namespace workers;
+ 
+diff --git a/dom/base/nsContentUtils.h b/dom/base/nsContentUtils.h
+--- a/dom/base/nsContentUtils.h
++++ b/dom/base/nsContentUtils.h
+@@ -2952,18 +2952,16 @@ public:
+    * Parse a referrer policy from a Referrer-Policy header
+    * https://www.w3.org/TR/referrer-policy/#parse-referrer-policy-from-header
+    *
+    * @param aHeader the response's Referrer-Policy header to parse
+    * @return referrer policy from the response header.
+    */
+   static mozilla::net::ReferrerPolicy GetReferrerPolicyFromHeader(const nsAString& aHeader);
+ 
+-  static bool PushEnabled(JSContext* aCx, JSObject* aObj);
+-
+   static bool StreamsEnabled(JSContext* aCx, JSObject* aObj);
+ 
+   static bool IsNonSubresourceRequest(nsIChannel* aChannel);
+ 
+   static uint32_t CookiesBehavior()
+   {
+     return sCookiesBehavior;
+   }
+diff --git a/dom/push/PushManager.h b/dom/push/PushManager.h
+--- a/dom/push/PushManager.h
++++ b/dom/push/PushManager.h
+@@ -27,19 +27,19 @@
+ #define mozilla_dom_PushManager_h
+ 
+ #include "nsWrapperCache.h"
+ 
+ #include "mozilla/AlreadyAddRefed.h"
+ #include "mozilla/ErrorResult.h"
+ #include "mozilla/dom/BindingDeclarations.h"
+ #include "mozilla/dom/TypedArray.h"
++#include "mozilla/dom/DOMPrefs.h"
+ 
+ #include "nsCOMPtr.h"
+-#include "nsContentUtils.h" // Required for nsContentUtils::PushEnabled
+ #include "mozilla/RefPtr.h"
+ 
+ class nsIGlobalObject;
+ class nsIPrincipal;
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+diff --git a/dom/push/PushSubscription.h b/dom/push/PushSubscription.h
+--- a/dom/push/PushSubscription.h
++++ b/dom/push/PushSubscription.h
+@@ -5,23 +5,23 @@
+  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+ 
+ #ifndef mozilla_dom_PushSubscription_h
+ #define mozilla_dom_PushSubscription_h
+ 
+ #include "jsapi.h"
+ #include "nsCOMPtr.h"
+ #include "nsWrapperCache.h"
+-#include "nsContentUtils.h" // Required for nsContentUtils::PushEnabled
+ 
+ #include "mozilla/AlreadyAddRefed.h"
+ #include "mozilla/ErrorResult.h"
+ #include "mozilla/RefPtr.h"
+ 
+ #include "mozilla/dom/BindingDeclarations.h"
++#include "mozilla/dom/DOMPrefs.h"
+ #include "mozilla/dom/PushSubscriptionBinding.h"
+ #include "mozilla/dom/PushSubscriptionOptionsBinding.h"
+ #include "mozilla/dom/TypedArray.h"
+ 
+ class nsIGlobalObject;
+ 
+ namespace mozilla {
+ namespace dom {
+diff --git a/dom/push/PushSubscriptionOptions.h b/dom/push/PushSubscriptionOptions.h
+--- a/dom/push/PushSubscriptionOptions.h
++++ b/dom/push/PushSubscriptionOptions.h
+@@ -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/. */
+ 
+ #ifndef mozilla_dom_PushSubscriptionOptions_h
+ #define mozilla_dom_PushSubscriptionOptions_h
+ 
+ #include "nsCycleCollectionParticipant.h"
+-#include "nsContentUtils.h" // Required for nsContentUtils::PushEnabled
+ #include "nsTArray.h"
+ #include "nsWrapperCache.h"
++#include "mozilla/dom/DOMPrefs.h"
+ 
+ class nsIGlobalObject;
+ 
+ namespace mozilla {
+ 
+ class ErrorResult;
+ 
+ namespace dom {
+diff --git a/dom/webidl/PushEvent.webidl b/dom/webidl/PushEvent.webidl
+--- a/dom/webidl/PushEvent.webidl
++++ b/dom/webidl/PushEvent.webidl
+@@ -3,17 +3,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/.
+  *
+  * The origin of this IDL file is
+  * https://w3c.github.io/push-api/
+  */
+ 
+ [Constructor(DOMString type, optional PushEventInit eventInitDict),
+- Func="nsContentUtils::PushEnabled",
++ Func="mozilla::dom::DOMPrefs::PushEnabled",
+  Exposed=ServiceWorker]
+ interface PushEvent : ExtendableEvent {
+   readonly attribute PushMessageData? data;
+ };
+ 
+ typedef (BufferSource or USVString) PushMessageDataInit;
+ 
+ dictionary PushEventInit : ExtendableEventInit {
+diff --git a/dom/webidl/PushManager.webidl b/dom/webidl/PushManager.webidl
+--- a/dom/webidl/PushManager.webidl
++++ b/dom/webidl/PushManager.webidl
+@@ -17,17 +17,17 @@ dictionary PushSubscriptionOptionsInit {
+ [JSImplementation="@mozilla.org/push/PushManager;1",
+  ChromeOnly, Constructor(DOMString scope)]
+ interface PushManagerImpl {
+   Promise<PushSubscription>    subscribe(optional PushSubscriptionOptionsInit options);
+   Promise<PushSubscription?>   getSubscription();
+   Promise<PushPermissionState> permissionState(optional PushSubscriptionOptionsInit options);
+ };
+ 
+-[Exposed=(Window,Worker), Func="nsContentUtils::PushEnabled",
++[Exposed=(Window,Worker), Func="mozilla::dom::DOMPrefs::PushEnabled",
+  ChromeConstructor(DOMString scope)]
+ interface PushManager {
+   [Throws, UseCounter]
+   Promise<PushSubscription>    subscribe(optional PushSubscriptionOptionsInit options);
+   [Throws]
+   Promise<PushSubscription?>   getSubscription();
+   [Throws]
+   Promise<PushPermissionState> permissionState(optional PushSubscriptionOptionsInit options);
+diff --git a/dom/webidl/PushMessageData.webidl b/dom/webidl/PushMessageData.webidl
+--- a/dom/webidl/PushMessageData.webidl
++++ b/dom/webidl/PushMessageData.webidl
+@@ -2,17 +2,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/.
+  *
+  * The origin of this IDL file is
+  * https://w3c.github.io/push-api/
+  */
+ 
+-[Func="nsContentUtils::PushEnabled",
++[Func="mozilla::dom::DOMPrefs::PushEnabled",
+  Exposed=ServiceWorker]
+ interface PushMessageData
+ {
+     [Throws]
+     ArrayBuffer arrayBuffer();
+     [Throws]
+     Blob        blob();
+     [Throws]
+diff --git a/dom/webidl/PushSubscription.webidl b/dom/webidl/PushSubscription.webidl
+--- a/dom/webidl/PushSubscription.webidl
++++ b/dom/webidl/PushSubscription.webidl
+@@ -31,17 +31,17 @@ dictionary PushSubscriptionInit
+ {
+   required USVString endpoint;
+   required USVString scope;
+   ArrayBuffer? p256dhKey;
+   ArrayBuffer? authSecret;
+   BufferSource? appServerKey;
+ };
+ 
+-[Exposed=(Window,Worker), Func="nsContentUtils::PushEnabled",
++[Exposed=(Window,Worker), Func="mozilla::dom::DOMPrefs::PushEnabled",
+  ChromeConstructor(PushSubscriptionInit initDict)]
+ interface PushSubscription
+ {
+   readonly attribute USVString endpoint;
+   readonly attribute PushSubscriptionOptions options;
+   [Throws]
+   ArrayBuffer? getKey(PushEncryptionKeyName name);
+   [Throws, UseCounter]
+diff --git a/dom/webidl/PushSubscriptionOptions.webidl b/dom/webidl/PushSubscriptionOptions.webidl
+--- a/dom/webidl/PushSubscriptionOptions.webidl
++++ b/dom/webidl/PushSubscriptionOptions.webidl
+@@ -2,14 +2,14 @@
+ /* 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/.
+ *
+ * The origin of this IDL file is
+ * https://w3c.github.io/push-api/
+ */
+ 
+-[Exposed=(Window,Worker), Func="nsContentUtils::PushEnabled"]
++[Exposed=(Window,Worker), Func="mozilla::dom::DOMPrefs::PushEnabled"]
+ interface PushSubscriptionOptions
+ {
+   [SameObject, Throws]
+   readonly attribute ArrayBuffer? applicationServerKey;
+ };
+diff --git a/dom/webidl/ServiceWorkerRegistration.webidl b/dom/webidl/ServiceWorkerRegistration.webidl
+--- a/dom/webidl/ServiceWorkerRegistration.webidl
++++ b/dom/webidl/ServiceWorkerRegistration.webidl
+@@ -33,17 +33,17 @@ interface ServiceWorkerRegistration : Ev
+ enum ServiceWorkerUpdateViaCache {
+   "imports",
+   "all",
+   "none"
+ };
+ 
+ // https://w3c.github.io/push-api/
+ partial interface ServiceWorkerRegistration {
+-  [Throws, Exposed=(Window,Worker), Func="nsContentUtils::PushEnabled"]
++  [Throws, Exposed=(Window,Worker), Func="mozilla::dom::DOMPrefs::PushEnabled"]
+   readonly attribute PushManager pushManager;
+ };
+ 
+ // https://notifications.spec.whatwg.org/
+ partial interface ServiceWorkerRegistration {
+   [Throws, Func="mozilla::dom::DOMPrefs::NotificationEnabledInServiceWorkers"]
+   Promise<void> showNotification(DOMString title, optional NotificationOptions options);
+   [Throws, Func="mozilla::dom::DOMPrefs::NotificationEnabledInServiceWorkers"]
+diff --git a/dom/workers/ServiceWorkerRegistration.h b/dom/workers/ServiceWorkerRegistration.h
+--- a/dom/workers/ServiceWorkerRegistration.h
++++ b/dom/workers/ServiceWorkerRegistration.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_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 "nsContentUtils.h" // Required for nsContentUtils::PushEnabled
+ 
+ // Support for Notification API extension.
+ #include "mozilla/dom/NotificationBinding.h"
+ 
+ class nsPIDOMWindowInner;
+ 
+ namespace mozilla {
+ namespace dom {
+diff --git a/dom/workers/WorkerPrefs.h b/dom/workers/WorkerPrefs.h
+--- a/dom/workers/WorkerPrefs.h
++++ b/dom/workers/WorkerPrefs.h
+@@ -16,17 +16,16 @@
+ //     macro in Workers.h.
+ //   * The name of the function that updates the new value of a pref.
+ //
+ //   WORKER_PREF("foo.bar", UpdaterFunction)
+ //
+ //   * First argument is the name of the pref.
+ //   * The name of the function that updates the new value of a pref.
+ 
+-WORKER_SIMPLE_PREF("dom.push.enabled", PushEnabled, PUSH_ENABLED)
+ WORKER_SIMPLE_PREF("dom.streams.enabled", StreamsEnabled, STREAMS_ENABLED)
+ WORKER_SIMPLE_PREF("dom.requestcontext.enabled", RequestContextEnabled, REQUESTCONTEXT_ENABLED)
+ WORKER_SIMPLE_PREF("gfx.offscreencanvas.enabled", OffscreenCanvasEnabled, OFFSCREENCANVAS_ENABLED)
+ WORKER_SIMPLE_PREF("dom.webkitBlink.dirPicker.enabled", WebkitBlinkDirectoryPickerEnabled, DOM_WEBKITBLINK_DIRPICKER_WEBKITBLINK)
+ WORKER_SIMPLE_PREF("dom.netinfo.enabled", NetworkInformationEnabled, NETWORKINFORMATION_ENABLED)
+ WORKER_SIMPLE_PREF("dom.fetchObserver.enabled", FetchObserverEnabled, FETCHOBSERVER_ENABLED)
+ WORKER_SIMPLE_PREF("privacy.resistFingerprinting", ResistFingerprintingEnabled, RESISTFINGERPRINTING_ENABLED)
+ WORKER_SIMPLE_PREF("devtools.enabled", DevToolsEnabled, DEVTOOLS_ENABLED)

+ 169 - 0
frg/work-js/mozilla-release/patches/1419771-13-59a1.patch

@@ -0,0 +1,169 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1515416705 -3600
+# Node ID ab06b612becfad4d44692aa78c7c20c6badb3e71
+# Parent  5dfdcabe1cd591cf75e00b032f38106457c334e4
+Bug 1419771 - Introduce DOMPrefs, a thread-safe access to preferences for DOM - part 13 - Streams API enabled, r=asuth
+
+diff --git a/dom/base/DOMPrefs.cpp b/dom/base/DOMPrefs.cpp
+--- a/dom/base/DOMPrefs.cpp
++++ b/dom/base/DOMPrefs.cpp
+@@ -41,16 +41,17 @@ PREF(PerformanceLoggingEnabled, "dom.per
+ PREF(NotificationEnabled, "dom.webnotifications.enabled")
+ PREF(NotificationEnabledInServiceWorkers, "dom.webnotifications.serviceworker.enabled")
+ PREF(NotificationRIEnabled, "dom.webnotifications.requireinteraction.enabled")
+ PREF(ServiceWorkersEnabled, "dom.serviceWorkers.enabled")
+ PREF(ServiceWorkersTestingEnabled, "dom.serviceWorkers.testing.enabled")
+ PREF(StorageManagerEnabled, "dom.storageManager.enabled")
+ PREF(PromiseRejectionEventsEnabled, "dom.promise_rejection_events.enabled")
+ PREF(PushEnabled, "dom.push.enabled")
++PREF(StreamsEnabled, "dom.streams.enabled")
+ 
+ #undef PREF
+ 
+ #define PREF_WEBIDL(name)                        \
+   /* static */ bool                              \
+   DOMPrefs::name(JSContext* aCx, JSObject* aObj) \
+   {                                              \
+     return DOMPrefs::name();                     \
+@@ -59,13 +60,14 @@ PREF(PushEnabled, "dom.push.enabled")
+ PREF_WEBIDL(ImageBitmapExtensionsEnabled)
+ PREF_WEBIDL(DOMCachesEnabled)
+ PREF_WEBIDL(NotificationEnabledInServiceWorkers)
+ PREF_WEBIDL(NotificationRIEnabled)
+ PREF_WEBIDL(ServiceWorkersEnabled)
+ PREF_WEBIDL(StorageManagerEnabled)
+ PREF_WEBIDL(PromiseRejectionEventsEnabled)
+ PREF_WEBIDL(PushEnabled)
++PREF_WEBIDL(StreamsEnabled)
+ 
+ #undef PREF_WEBIDL
+ 
+ } // dom namespace
+ } // mozilla namespace
+diff --git a/dom/base/DOMPrefs.h b/dom/base/DOMPrefs.h
+--- a/dom/base/DOMPrefs.h
++++ b/dom/base/DOMPrefs.h
+@@ -58,14 +58,18 @@ public:
+ 
+   // Returns true if the dom.promise_rejection_events.enabled pref is set.
+   static bool PromiseRejectionEventsEnabled();
+   static bool PromiseRejectionEventsEnabled(JSContext* aCx, JSObject* aObj);
+ 
+   // Returns true if the dom.push.enabled pref is set.
+   static bool PushEnabled();
+   static bool PushEnabled(JSContext* aCx, JSObject* aObj);
++
++  // Returns true if the dom.streams.enabled pref is set.
++  static bool StreamsEnabled();
++  static bool StreamsEnabled(JSContext* aCx, JSObject* aObj);
+ };
+ 
+ } // dom namespace
+ } // mozilla namespace
+ 
+ #endif // mozilla_dom_DOMPrefs_h
+diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp
+--- a/dom/base/nsContentUtils.cpp
++++ b/dom/base/nsContentUtils.cpp
+@@ -9071,35 +9071,16 @@ nsContentUtils::GetReferrerPolicyFromHea
+       referrerPolicy = policy;
+     }
+   }
+   return referrerPolicy;
+ }
+ 
+ // static
+ bool
+-nsContentUtils::StreamsEnabled(JSContext* aCx, JSObject* aObj)
+-{
+-  if (NS_IsMainThread()) {
+-    return Preferences::GetBool("dom.streams.enabled", false);
+-  }
+-
+-  using namespace workers;
+-
+-  // Otherwise, check the pref via the WorkerPrivate
+-  WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(aCx);
+-  if (!workerPrivate) {
+-    return false;
+-  }
+-
+-  return workerPrivate->StreamsEnabled();
+-}
+-
+-// static
+-bool
+ nsContentUtils::IsNonSubresourceRequest(nsIChannel* aChannel)
+ {
+   nsLoadFlags loadFlags = 0;
+   aChannel->GetLoadFlags(&loadFlags);
+   if (loadFlags & nsIChannel::LOAD_DOCUMENT_URI) {
+     return true;
+   }
+ 
+diff --git a/dom/base/nsContentUtils.h b/dom/base/nsContentUtils.h
+--- a/dom/base/nsContentUtils.h
++++ b/dom/base/nsContentUtils.h
+@@ -2952,18 +2952,16 @@ public:
+    * Parse a referrer policy from a Referrer-Policy header
+    * https://www.w3.org/TR/referrer-policy/#parse-referrer-policy-from-header
+    *
+    * @param aHeader the response's Referrer-Policy header to parse
+    * @return referrer policy from the response header.
+    */
+   static mozilla::net::ReferrerPolicy GetReferrerPolicyFromHeader(const nsAString& aHeader);
+ 
+-  static bool StreamsEnabled(JSContext* aCx, JSObject* aObj);
+-
+   static bool IsNonSubresourceRequest(nsIChannel* aChannel);
+ 
+   static uint32_t CookiesBehavior()
+   {
+     return sCookiesBehavior;
+   }
+ 
+   static uint32_t CookiesLifetimePolicy()
+diff --git a/dom/webidl/Response.webidl b/dom/webidl/Response.webidl
+--- a/dom/webidl/Response.webidl
++++ b/dom/webidl/Response.webidl
+@@ -30,17 +30,17 @@ interface Response {
+ 
+   [ChromeOnly, NewObject, Throws] Response cloneUnfiltered();
+ };
+ Response implements Body;
+ 
+ // This should be part of Body but we don't want to expose body to request yet.
+ // See bug 1387483.
+ partial interface Response {
+-  [GetterThrows, Func="nsContentUtils::StreamsEnabled"]
++  [GetterThrows, Func="mozilla::dom::DOMPrefs::StreamsEnabled"]
+   readonly attribute ReadableStream? body;
+ };
+ 
+ dictionary ResponseInit {
+   unsigned short status = 200;
+   ByteString statusText = "OK";
+   HeadersInit headers;
+ };
+diff --git a/dom/workers/WorkerPrefs.h b/dom/workers/WorkerPrefs.h
+--- a/dom/workers/WorkerPrefs.h
++++ b/dom/workers/WorkerPrefs.h
+@@ -16,17 +16,16 @@
+ //     macro in Workers.h.
+ //   * The name of the function that updates the new value of a pref.
+ //
+ //   WORKER_PREF("foo.bar", UpdaterFunction)
+ //
+ //   * First argument is the name of the pref.
+ //   * The name of the function that updates the new value of a pref.
+ 
+-WORKER_SIMPLE_PREF("dom.streams.enabled", StreamsEnabled, STREAMS_ENABLED)
+ WORKER_SIMPLE_PREF("dom.requestcontext.enabled", RequestContextEnabled, REQUESTCONTEXT_ENABLED)
+ WORKER_SIMPLE_PREF("gfx.offscreencanvas.enabled", OffscreenCanvasEnabled, OFFSCREENCANVAS_ENABLED)
+ WORKER_SIMPLE_PREF("dom.webkitBlink.dirPicker.enabled", WebkitBlinkDirectoryPickerEnabled, DOM_WEBKITBLINK_DIRPICKER_WEBKITBLINK)
+ WORKER_SIMPLE_PREF("dom.netinfo.enabled", NetworkInformationEnabled, NETWORKINFORMATION_ENABLED)
+ WORKER_SIMPLE_PREF("dom.fetchObserver.enabled", FetchObserverEnabled, FETCHOBSERVER_ENABLED)
+ WORKER_SIMPLE_PREF("privacy.resistFingerprinting", ResistFingerprintingEnabled, RESISTFINGERPRINTING_ENABLED)
+ WORKER_SIMPLE_PREF("devtools.enabled", DevToolsEnabled, DEVTOOLS_ENABLED)
+ WORKER_PREF("intl.accept_languages", PrefLanguagesChanged)

+ 170 - 0
frg/work-js/mozilla-release/patches/1419771-14-59a1.patch

@@ -0,0 +1,170 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1515416705 -3600
+# Node ID cf6aadebae4faf35298a9b41cd105ae9ad49e608
+# Parent  9c2b3d7f1bbc2c65d742d5bee7c6ed9f154f2788
+Bug 1419771 - Introduce DOMPrefs, a thread-safe access to preferences for DOM - part 14 - Request Context enabled, r=asuth
+
+diff --git a/dom/base/DOMPrefs.cpp b/dom/base/DOMPrefs.cpp
+--- a/dom/base/DOMPrefs.cpp
++++ b/dom/base/DOMPrefs.cpp
+@@ -42,16 +42,17 @@ PREF(NotificationEnabled, "dom.webnotifi
+ PREF(NotificationEnabledInServiceWorkers, "dom.webnotifications.serviceworker.enabled")
+ PREF(NotificationRIEnabled, "dom.webnotifications.requireinteraction.enabled")
+ PREF(ServiceWorkersEnabled, "dom.serviceWorkers.enabled")
+ PREF(ServiceWorkersTestingEnabled, "dom.serviceWorkers.testing.enabled")
+ PREF(StorageManagerEnabled, "dom.storageManager.enabled")
+ PREF(PromiseRejectionEventsEnabled, "dom.promise_rejection_events.enabled")
+ PREF(PushEnabled, "dom.push.enabled")
+ PREF(StreamsEnabled, "dom.streams.enabled")
++PREF(RequestContextEnabled, "dom.requestcontext.enabled")
+ 
+ #undef PREF
+ 
+ #define PREF_WEBIDL(name)                        \
+   /* static */ bool                              \
+   DOMPrefs::name(JSContext* aCx, JSObject* aObj) \
+   {                                              \
+     return DOMPrefs::name();                     \
+@@ -61,13 +62,14 @@ PREF_WEBIDL(ImageBitmapExtensionsEnabled
+ PREF_WEBIDL(DOMCachesEnabled)
+ PREF_WEBIDL(NotificationEnabledInServiceWorkers)
+ PREF_WEBIDL(NotificationRIEnabled)
+ PREF_WEBIDL(ServiceWorkersEnabled)
+ PREF_WEBIDL(StorageManagerEnabled)
+ PREF_WEBIDL(PromiseRejectionEventsEnabled)
+ PREF_WEBIDL(PushEnabled)
+ PREF_WEBIDL(StreamsEnabled)
++PREF_WEBIDL(RequestContextEnabled)
+ 
+ #undef PREF_WEBIDL
+ 
+ } // dom namespace
+ } // mozilla namespace
+diff --git a/dom/base/DOMPrefs.h b/dom/base/DOMPrefs.h
+--- a/dom/base/DOMPrefs.h
++++ b/dom/base/DOMPrefs.h
+@@ -62,14 +62,18 @@ public:
+ 
+   // Returns true if the dom.push.enabled pref is set.
+   static bool PushEnabled();
+   static bool PushEnabled(JSContext* aCx, JSObject* aObj);
+ 
+   // Returns true if the dom.streams.enabled pref is set.
+   static bool StreamsEnabled();
+   static bool StreamsEnabled(JSContext* aCx, JSObject* aObj);
++
++  // Returns true if the dom.requestcontext.enabled pref is set.
++  static bool RequestContextEnabled();
++  static bool RequestContextEnabled(JSContext* aCx, JSObject* aObj);
+ };
+ 
+ } // dom namespace
+ } // mozilla namespace
+ 
+ #endif // mozilla_dom_DOMPrefs_h
+diff --git a/dom/fetch/Request.cpp b/dom/fetch/Request.cpp
+--- a/dom/fetch/Request.cpp
++++ b/dom/fetch/Request.cpp
+@@ -72,35 +72,16 @@ Request::Request(nsIGlobalObject* aOwner
+     }
+   }
+ }
+ 
+ Request::~Request()
+ {
+ }
+ 
+-// static
+-bool
+-Request::RequestContextEnabled(JSContext* aCx, JSObject* aObj)
+-{
+-  if (NS_IsMainThread()) {
+-    return Preferences::GetBool("dom.requestcontext.enabled", false);
+-  }
+-
+-  using namespace workers;
+-
+-  // Otherwise, check the pref via the WorkerPrivate
+-  WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(aCx);
+-  if (!workerPrivate) {
+-    return false;
+-  }
+-
+-  return workerPrivate->RequestContextEnabled();
+-}
+-
+ already_AddRefed<InternalRequest>
+ Request::GetInternalRequest()
+ {
+   RefPtr<InternalRequest> r = mRequest;
+   return r.forget();
+ }
+ 
+ namespace {
+diff --git a/dom/fetch/Request.h b/dom/fetch/Request.h
+--- a/dom/fetch/Request.h
++++ b/dom/fetch/Request.h
+@@ -30,19 +30,16 @@ class Request final : public nsISupports
+ {
+   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
+   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Request)
+ 
+ public:
+   Request(nsIGlobalObject* aOwner, InternalRequest* aRequest,
+           AbortSignal* aSignal);
+ 
+-  static bool
+-  RequestContextEnabled(JSContext* aCx, JSObject* aObj);
+-
+   JSObject*
+   WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override
+   {
+     return RequestBinding::Wrap(aCx, this, aGivenProto);
+   }
+ 
+   void
+   GetUrl(nsAString& aUrl) const
+diff --git a/dom/webidl/Request.webidl b/dom/webidl/Request.webidl
+--- a/dom/webidl/Request.webidl
++++ b/dom/webidl/Request.webidl
+@@ -12,17 +12,17 @@ typedef unsigned long nsContentPolicyTyp
+ 
+ [Constructor(RequestInfo input, optional RequestInit init),
+  Exposed=(Window,Worker)]
+ interface Request {
+   readonly attribute ByteString method;
+   readonly attribute USVString url;
+   [SameObject] readonly attribute Headers headers;
+ 
+-  [Func="mozilla::dom::Request::RequestContextEnabled"]
++  [Func="mozilla::dom::DOMPrefs::RequestContextEnabled"]
+   readonly attribute RequestContext context;
+   readonly attribute USVString referrer;
+   readonly attribute ReferrerPolicy referrerPolicy;
+   readonly attribute RequestMode mode;
+   readonly attribute RequestCredentials credentials;
+   readonly attribute RequestCache cache;
+   readonly attribute RequestRedirect redirect;
+   readonly attribute DOMString integrity;
+diff --git a/dom/workers/WorkerPrefs.h b/dom/workers/WorkerPrefs.h
+--- a/dom/workers/WorkerPrefs.h
++++ b/dom/workers/WorkerPrefs.h
+@@ -16,17 +16,16 @@
+ //     macro in Workers.h.
+ //   * The name of the function that updates the new value of a pref.
+ //
+ //   WORKER_PREF("foo.bar", UpdaterFunction)
+ //
+ //   * First argument is the name of the pref.
+ //   * The name of the function that updates the new value of a pref.
+ 
+-WORKER_SIMPLE_PREF("dom.requestcontext.enabled", RequestContextEnabled, REQUESTCONTEXT_ENABLED)
+ WORKER_SIMPLE_PREF("gfx.offscreencanvas.enabled", OffscreenCanvasEnabled, OFFSCREENCANVAS_ENABLED)
+ WORKER_SIMPLE_PREF("dom.webkitBlink.dirPicker.enabled", WebkitBlinkDirectoryPickerEnabled, DOM_WEBKITBLINK_DIRPICKER_WEBKITBLINK)
+ WORKER_SIMPLE_PREF("dom.netinfo.enabled", NetworkInformationEnabled, NETWORKINFORMATION_ENABLED)
+ WORKER_SIMPLE_PREF("dom.fetchObserver.enabled", FetchObserverEnabled, FETCHOBSERVER_ENABLED)
+ WORKER_SIMPLE_PREF("privacy.resistFingerprinting", ResistFingerprintingEnabled, RESISTFINGERPRINTING_ENABLED)
+ WORKER_SIMPLE_PREF("devtools.enabled", DevToolsEnabled, DEVTOOLS_ENABLED)
+ WORKER_PREF("intl.accept_languages", PrefLanguagesChanged)
+ WORKER_PREF("general.appname.override", AppNameOverrideChanged)

+ 228 - 0
frg/work-js/mozilla-release/patches/1419771-15-59a1.patch

@@ -0,0 +1,228 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1515416705 -3600
+# Node ID cb1abb98a4c3437396ed5d30d5ac538309880002
+# Parent  96c006ff9d87087240c80e8db90646bc008368ea
+Bug 1419771 - Introduce DOMPrefs, a thread-safe access to preferences for DOM - part 15 - Offscreen Canvas enabled, r=asuth
+
+diff --git a/dom/base/DOMPrefs.cpp b/dom/base/DOMPrefs.cpp
+--- a/dom/base/DOMPrefs.cpp
++++ b/dom/base/DOMPrefs.cpp
+@@ -43,16 +43,17 @@ PREF(NotificationEnabledInServiceWorkers
+ PREF(NotificationRIEnabled, "dom.webnotifications.requireinteraction.enabled")
+ PREF(ServiceWorkersEnabled, "dom.serviceWorkers.enabled")
+ PREF(ServiceWorkersTestingEnabled, "dom.serviceWorkers.testing.enabled")
+ PREF(StorageManagerEnabled, "dom.storageManager.enabled")
+ PREF(PromiseRejectionEventsEnabled, "dom.promise_rejection_events.enabled")
+ PREF(PushEnabled, "dom.push.enabled")
+ PREF(StreamsEnabled, "dom.streams.enabled")
+ PREF(RequestContextEnabled, "dom.requestcontext.enabled")
++PREF(OffscreenCanvasEnabled, "gfx.offscreencanvas.enabled")
+ 
+ #undef PREF
+ 
+ #define PREF_WEBIDL(name)                        \
+   /* static */ bool                              \
+   DOMPrefs::name(JSContext* aCx, JSObject* aObj) \
+   {                                              \
+     return DOMPrefs::name();                     \
+@@ -63,13 +64,14 @@ PREF_WEBIDL(DOMCachesEnabled)
+ PREF_WEBIDL(NotificationEnabledInServiceWorkers)
+ PREF_WEBIDL(NotificationRIEnabled)
+ PREF_WEBIDL(ServiceWorkersEnabled)
+ PREF_WEBIDL(StorageManagerEnabled)
+ PREF_WEBIDL(PromiseRejectionEventsEnabled)
+ PREF_WEBIDL(PushEnabled)
+ PREF_WEBIDL(StreamsEnabled)
+ PREF_WEBIDL(RequestContextEnabled)
++PREF_WEBIDL(OffscreenCanvasEnabled)
+ 
+ #undef PREF_WEBIDL
+ 
+ } // dom namespace
+ } // mozilla namespace
+diff --git a/dom/base/DOMPrefs.h b/dom/base/DOMPrefs.h
+--- a/dom/base/DOMPrefs.h
++++ b/dom/base/DOMPrefs.h
+@@ -66,14 +66,18 @@ public:
+ 
+   // Returns true if the dom.streams.enabled pref is set.
+   static bool StreamsEnabled();
+   static bool StreamsEnabled(JSContext* aCx, JSObject* aObj);
+ 
+   // Returns true if the dom.requestcontext.enabled pref is set.
+   static bool RequestContextEnabled();
+   static bool RequestContextEnabled(JSContext* aCx, JSObject* aObj);
++
++  // Returns true if the gfx.offscreencanvas.enabled pref is set.
++  static bool OffscreenCanvasEnabled();
++  static bool OffscreenCanvasEnabled(JSContext* aCx, JSObject* aObj);
+ };
+ 
+ } // dom namespace
+ } // mozilla namespace
+ 
+ #endif // mozilla_dom_DOMPrefs_h
+diff --git a/dom/canvas/OffscreenCanvas.cpp b/dom/canvas/OffscreenCanvas.cpp
+--- a/dom/canvas/OffscreenCanvas.cpp
++++ b/dom/canvas/OffscreenCanvas.cpp
+@@ -1,16 +1,17 @@
+ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+ /* vim:set ts=2 sw=2 sts=2 et cindent: */
+ /* 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 "OffscreenCanvas.h"
+ 
++#include "mozilla/dom/DOMPrefs.h"
+ #include "mozilla/dom/OffscreenCanvasBinding.h"
+ #include "mozilla/dom/WorkerPrivate.h"
+ #include "mozilla/dom/WorkerScope.h"
+ #include "mozilla/layers/AsyncCanvasRenderer.h"
+ #include "mozilla/layers/CanvasClient.h"
+ #include "mozilla/layers/ImageBridgeChild.h"
+ #include "mozilla/Telemetry.h"
+ #include "CanvasRenderingContext2D.h"
+@@ -316,35 +317,23 @@ OffscreenCanvas::CreateFromCloneData(nsI
+                         aData->mCompositorBackendType, aData->mRenderer);
+   if (aData->mNeutered) {
+     wc->SetNeutered();
+   }
+   return wc.forget();
+ }
+ 
+ /* static */ bool
+-OffscreenCanvas::PrefEnabled(JSContext* aCx, JSObject* aObj)
+-{
+-  if (NS_IsMainThread()) {
+-    return Preferences::GetBool("gfx.offscreencanvas.enabled");
+-  } else {
+-    WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(aCx);
+-    MOZ_ASSERT(workerPrivate);
+-    return workerPrivate->OffscreenCanvasEnabled();
+-  }
+-}
+-
+-/* static */ bool
+ OffscreenCanvas::PrefEnabledOnWorkerThread(JSContext* aCx, JSObject* aObj)
+ {
+   if (NS_IsMainThread()) {
+     return true;
+   }
+ 
+-  return PrefEnabled(aCx, aObj);
++  return DOMPrefs::OffscreenCanvasEnabled(aCx, aObj);
+ }
+ 
+ NS_IMPL_CYCLE_COLLECTION_INHERITED(OffscreenCanvas, DOMEventTargetHelper, mCurrentContext)
+ 
+ NS_IMPL_ADDREF_INHERITED(OffscreenCanvas, DOMEventTargetHelper)
+ NS_IMPL_RELEASE_INHERITED(OffscreenCanvas, DOMEventTargetHelper)
+ 
+ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(OffscreenCanvas)
+diff --git a/dom/canvas/OffscreenCanvas.h b/dom/canvas/OffscreenCanvas.h
+--- a/dom/canvas/OffscreenCanvas.h
++++ b/dom/canvas/OffscreenCanvas.h
+@@ -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/. */
+ 
+ #ifndef MOZILLA_DOM_OFFSCREENCANVAS_H_
+ #define MOZILLA_DOM_OFFSCREENCANVAS_H_
+ 
+ #include "gfxTypes.h"
+ #include "mozilla/DOMEventTargetHelper.h"
++#include "mozilla/dom/DOMPrefs.h"
+ #include "mozilla/layers/LayersTypes.h"
+ #include "mozilla/RefPtr.h"
+ #include "CanvasRenderingContextHelper.h"
+ #include "nsCycleCollectionParticipant.h"
+ 
+ struct JSContext;
+ 
+ namespace mozilla {
+@@ -125,18 +126,16 @@ public:
+     return mCurrentContext;
+   }
+ 
+   already_AddRefed<gfx::SourceSurface> GetSurfaceSnapshot(gfxAlphaType* aOutAlphaType = nullptr);
+ 
+   static already_AddRefed<OffscreenCanvas>
+   CreateFromCloneData(nsIGlobalObject* aGlobal, OffscreenCanvasCloneData* aData);
+ 
+-  static bool PrefEnabled(JSContext* aCx, JSObject* aObj);
+-
+   // Return true on main-thread, and return gfx.offscreencanvas.enabled
+   // on worker thread.
+   static bool PrefEnabledOnWorkerThread(JSContext* aCx, JSObject* aObj);
+ 
+   OffscreenCanvasCloneData* ToCloneData();
+ 
+   void CommitFrameToCompositor();
+ 
+diff --git a/dom/webidl/OffscreenCanvas.webidl b/dom/webidl/OffscreenCanvas.webidl
+--- a/dom/webidl/OffscreenCanvas.webidl
++++ b/dom/webidl/OffscreenCanvas.webidl
+@@ -4,17 +4,17 @@
+  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+  *
+  * For more information on this interface, please see
+  * https://wiki.whatwg.org/wiki/OffscreenCanvas
+  */
+ 
+ [Constructor(unsigned long width, unsigned long height),
+  Exposed=(Window,Worker),
+- Func="mozilla::dom::OffscreenCanvas::PrefEnabled"]
++ Func="mozilla::dom::DOMPrefs::OffscreenCanvasEnabled"]
+ interface OffscreenCanvas : EventTarget {
+   [Pure, SetterThrows]
+   attribute unsigned long width;
+   [Pure, SetterThrows]
+   attribute unsigned long height;
+ 
+   [Throws]
+   nsISupports? getContext(DOMString contextId,
+diff --git a/dom/webidl/WebGLRenderingContext.webidl b/dom/webidl/WebGLRenderingContext.webidl
+--- a/dom/webidl/WebGLRenderingContext.webidl
++++ b/dom/webidl/WebGLRenderingContext.webidl
+@@ -798,17 +798,17 @@ interface WebGLRenderingContext {
+ };
+ 
+ WebGLRenderingContext implements WebGLRenderingContextBase;
+ 
+ // For OffscreenCanvas
+ // Reference: https://wiki.whatwg.org/wiki/OffscreenCanvas
+ [Exposed=(Window,Worker)]
+ partial interface WebGLRenderingContext {
+-    [Func="mozilla::dom::OffscreenCanvas::PrefEnabled"]
++    [Func="mozilla::dom::DOMPrefs::OffscreenCanvasEnabled"]
+     void commit();
+ };
+ 
+ ////////////////////////////////////////
+ // specific extension interfaces
+ 
+ [NoInterfaceObject]
+ interface WEBGL_compressed_texture_s3tc
+diff --git a/dom/workers/WorkerPrefs.h b/dom/workers/WorkerPrefs.h
+--- a/dom/workers/WorkerPrefs.h
++++ b/dom/workers/WorkerPrefs.h
+@@ -16,17 +16,16 @@
+ //     macro in Workers.h.
+ //   * The name of the function that updates the new value of a pref.
+ //
+ //   WORKER_PREF("foo.bar", UpdaterFunction)
+ //
+ //   * First argument is the name of the pref.
+ //   * The name of the function that updates the new value of a pref.
+ 
+-WORKER_SIMPLE_PREF("gfx.offscreencanvas.enabled", OffscreenCanvasEnabled, OFFSCREENCANVAS_ENABLED)
+ WORKER_SIMPLE_PREF("dom.webkitBlink.dirPicker.enabled", WebkitBlinkDirectoryPickerEnabled, DOM_WEBKITBLINK_DIRPICKER_WEBKITBLINK)
+ WORKER_SIMPLE_PREF("dom.netinfo.enabled", NetworkInformationEnabled, NETWORKINFORMATION_ENABLED)
+ WORKER_SIMPLE_PREF("dom.fetchObserver.enabled", FetchObserverEnabled, FETCHOBSERVER_ENABLED)
+ WORKER_SIMPLE_PREF("privacy.resistFingerprinting", ResistFingerprintingEnabled, RESISTFINGERPRINTING_ENABLED)
+ WORKER_SIMPLE_PREF("devtools.enabled", DevToolsEnabled, DEVTOOLS_ENABLED)
+ WORKER_PREF("intl.accept_languages", PrefLanguagesChanged)
+ WORKER_PREF("general.appname.override", AppNameOverrideChanged)
+ WORKER_PREF("general.appversion.override", AppVersionOverrideChanged)

+ 443 - 0
frg/work-js/mozilla-release/patches/1419771-16-59a1.patch

@@ -0,0 +1,443 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1515416705 -3600
+# Node ID 0918da01e55435aee12708d155e1832103dcd9f0
+# Parent  60d038987cde6efdc75849358e51e913a51981d3
+Bug 1419771 - Introduce DOMPrefs, a thread-safe access to preferences for DOM - part 16 - Webkit/Blink directory picker enabled, r=asuth
+
+diff --git a/dom/base/DOMPrefs.cpp b/dom/base/DOMPrefs.cpp
+--- a/dom/base/DOMPrefs.cpp
++++ b/dom/base/DOMPrefs.cpp
+@@ -44,16 +44,17 @@ PREF(NotificationRIEnabled, "dom.webnoti
+ PREF(ServiceWorkersEnabled, "dom.serviceWorkers.enabled")
+ PREF(ServiceWorkersTestingEnabled, "dom.serviceWorkers.testing.enabled")
+ PREF(StorageManagerEnabled, "dom.storageManager.enabled")
+ PREF(PromiseRejectionEventsEnabled, "dom.promise_rejection_events.enabled")
+ PREF(PushEnabled, "dom.push.enabled")
+ PREF(StreamsEnabled, "dom.streams.enabled")
+ PREF(RequestContextEnabled, "dom.requestcontext.enabled")
+ PREF(OffscreenCanvasEnabled, "gfx.offscreencanvas.enabled")
++PREF(WebkitBlinkDirectoryPickerEnabled, "dom.webkitBlink.dirPicker.enabled")
+ 
+ #undef PREF
+ 
+ #define PREF_WEBIDL(name)                        \
+   /* static */ bool                              \
+   DOMPrefs::name(JSContext* aCx, JSObject* aObj) \
+   {                                              \
+     return DOMPrefs::name();                     \
+@@ -65,13 +66,14 @@ PREF_WEBIDL(NotificationEnabledInService
+ PREF_WEBIDL(NotificationRIEnabled)
+ PREF_WEBIDL(ServiceWorkersEnabled)
+ PREF_WEBIDL(StorageManagerEnabled)
+ PREF_WEBIDL(PromiseRejectionEventsEnabled)
+ PREF_WEBIDL(PushEnabled)
+ PREF_WEBIDL(StreamsEnabled)
+ PREF_WEBIDL(RequestContextEnabled)
+ PREF_WEBIDL(OffscreenCanvasEnabled)
++PREF_WEBIDL(WebkitBlinkDirectoryPickerEnabled)
+ 
+ #undef PREF_WEBIDL
+ 
+ } // dom namespace
+ } // mozilla namespace
+diff --git a/dom/base/DOMPrefs.h b/dom/base/DOMPrefs.h
+--- a/dom/base/DOMPrefs.h
++++ b/dom/base/DOMPrefs.h
+@@ -70,14 +70,18 @@ public:
+ 
+   // Returns true if the dom.requestcontext.enabled pref is set.
+   static bool RequestContextEnabled();
+   static bool RequestContextEnabled(JSContext* aCx, JSObject* aObj);
+ 
+   // Returns true if the gfx.offscreencanvas.enabled pref is set.
+   static bool OffscreenCanvasEnabled();
+   static bool OffscreenCanvasEnabled(JSContext* aCx, JSObject* aObj);
++
++  // Returns true if the dom.webkitBlink.dirPicker.enabled pref is set.
++  static bool WebkitBlinkDirectoryPickerEnabled();
++  static bool WebkitBlinkDirectoryPickerEnabled(JSContext* aCx, JSObject* aObj);
+ };
+ 
+ } // dom namespace
+ } // mozilla namespace
+ 
+ #endif // mozilla_dom_DOMPrefs_h
+diff --git a/dom/filesystem/Directory.cpp b/dom/filesystem/Directory.cpp
+--- a/dom/filesystem/Directory.cpp
++++ b/dom/filesystem/Directory.cpp
+@@ -42,34 +42,16 @@ NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCA
+ 
+ NS_IMPL_CYCLE_COLLECTING_ADDREF(Directory)
+ NS_IMPL_CYCLE_COLLECTING_RELEASE(Directory)
+ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(Directory)
+   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
+   NS_INTERFACE_MAP_ENTRY(nsISupports)
+ NS_INTERFACE_MAP_END
+ 
+-/* static */ bool
+-Directory::WebkitBlinkDirectoryPickerEnabled(JSContext* aCx, JSObject* aObj)
+-{
+-  if (NS_IsMainThread()) {
+-    return Preferences::GetBool("dom.webkitBlink.dirPicker.enabled", false);
+-  }
+-
+-  // aCx can be null when this function is called by something else than WebIDL
+-  // binding code.
+-  workers::WorkerPrivate* workerPrivate =
+-    workers::GetCurrentThreadWorkerPrivate();
+-  if (!workerPrivate) {
+-    return false;
+-  }
+-
+-  return workerPrivate->WebkitBlinkDirectoryPickerEnabled();
+-}
+-
+ /* static */ already_AddRefed<Directory>
+ Directory::Constructor(const GlobalObject& aGlobal,
+                        const nsAString& aRealPath,
+                        ErrorResult& aRv)
+ {
+   nsCOMPtr<nsIFile> path;
+   aRv = NS_NewLocalFile(aRealPath, true, getter_AddRefs(path));
+   if (NS_WARN_IF(aRv.Failed())) {
+diff --git a/dom/filesystem/Directory.h b/dom/filesystem/Directory.h
+--- a/dom/filesystem/Directory.h
++++ b/dom/filesystem/Directory.h
+@@ -24,19 +24,16 @@ class StringOrFileOrDirectory;
+ class Directory final
+   : public nsISupports
+   , public nsWrapperCache
+ {
+ public:
+   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
+   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Directory)
+ 
+-  static bool
+-  WebkitBlinkDirectoryPickerEnabled(JSContext* aCx, JSObject* aObj);
+-
+   static already_AddRefed<Directory>
+   Constructor(const GlobalObject& aGlobal,
+               const nsAString& aRealPath,
+               ErrorResult& aRv);
+ 
+   static already_AddRefed<Directory>
+   Create(nsISupports* aParent, nsIFile* aDirectory,
+          FileSystemBase* aFileSystem = 0);
+diff --git a/dom/html/HTMLFormSubmission.cpp b/dom/html/HTMLFormSubmission.cpp
+--- a/dom/html/HTMLFormSubmission.cpp
++++ b/dom/html/HTMLFormSubmission.cpp
+@@ -32,16 +32,17 @@
+ #include "nsIConsoleService.h"
+ #include "nsIScriptError.h"
+ #include "nsIStringBundle.h"
+ #include "nsCExternalHandlerService.h"
+ #include "nsIFileStreams.h"
+ #include "nsContentUtils.h"
+ 
+ #include "mozilla/dom/Directory.h"
++#include "mozilla/dom/DOMPrefs.h"
+ #include "mozilla/dom/File.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+ namespace {
+ 
+ void
+@@ -487,17 +488,17 @@ FSMultipartFormData::AddNameBlobOrNullPa
+ 
+   if (aBlob) {
+     nsAutoString filename16;
+ 
+     RefPtr<File> file = aBlob->ToFile();
+     if (file) {
+       nsAutoString relativePath;
+       file->GetRelativePath(relativePath);
+-      if (Directory::WebkitBlinkDirectoryPickerEnabled(nullptr, nullptr) &&
++      if (DOMPrefs::WebkitBlinkDirectoryPickerEnabled() &&
+           !relativePath.IsEmpty()) {
+         filename16 = relativePath;
+       }
+ 
+       if (filename16.IsEmpty()) {
+         RetrieveFileName(aBlob, filename16);
+       }
+     }
+@@ -546,17 +547,17 @@ FSMultipartFormData::AddNameBlobOrNullPa
+   AddDataChunk(nameStr, filename, contentType, fileStream, size);
+   return NS_OK;
+ }
+ 
+ nsresult
+ FSMultipartFormData::AddNameDirectoryPair(const nsAString& aName,
+                                           Directory* aDirectory)
+ {
+-  if (!Directory::WebkitBlinkDirectoryPickerEnabled(nullptr, nullptr)) {
++  if (!DOMPrefs::WebkitBlinkDirectoryPickerEnabled()) {
+     return NS_OK;
+   }
+ 
+   // Encode the control name
+   nsAutoCString nameStr;
+   nsresult rv = EncodeVal(aName, nameStr, true);
+   NS_ENSURE_SUCCESS(rv, rv);
+ 
+diff --git a/dom/html/HTMLInputElement.cpp b/dom/html/HTMLInputElement.cpp
+--- a/dom/html/HTMLInputElement.cpp
++++ b/dom/html/HTMLInputElement.cpp
+@@ -6,16 +6,17 @@
+ 
+ #include "mozilla/dom/HTMLInputElement.h"
+ 
+ #include "mozilla/ArrayUtils.h"
+ #include "mozilla/AsyncEventDispatcher.h"
+ #include "mozilla/DebugOnly.h"
+ #include "mozilla/dom/Date.h"
+ #include "mozilla/dom/Directory.h"
++#include "mozilla/dom/DOMPrefs.h"
+ #include "mozilla/dom/HTMLFormSubmission.h"
+ #include "mozilla/dom/FileSystemUtils.h"
+ #include "mozilla/dom/GetFilesHelper.h"
+ #include "nsAttrValueInlines.h"
+ #include "nsCRTGlue.h"
+ 
+ #include "nsIDOMHTMLInputElement.h"
+ #include "nsITextControlElement.h"
+@@ -681,17 +682,17 @@ HTMLInputElement::nsFilePickerShownCallb
+   // The text control frame (if there is one) isn't going to send a change
+   // event because it will think this is done by a script.
+   // So, we can safely send one by ourself.
+   mInput->SetFilesOrDirectories(newFilesOrDirectories, true);
+ 
+   RefPtr<DispatchChangeEventCallback> dispatchChangeEventCallback =
+     new DispatchChangeEventCallback(mInput);
+ 
+-  if (IsWebkitDirPickerEnabled() &&
++  if (DOMPrefs::WebkitBlinkDirectoryPickerEnabled() &&
+       mInput->HasAttr(kNameSpaceID_None, nsGkAtoms::webkitdirectory)) {
+     ErrorResult error;
+     GetFilesHelper* helper = mInput->GetOrCreateGetFilesHelper(true, error);
+     if (NS_WARN_IF(error.Failed())) {
+       return error.StealNSResult();
+     }
+ 
+     helper->AddCallback(dispatchChangeEventCallback);
+@@ -2742,17 +2743,17 @@ HTMLInputElement::GetDisplayFileName(nsA
+     GetDOMFileOrDirectoryName(mFileData->mFilesOrDirectories[0], aValue);
+     return;
+   }
+ 
+   nsAutoString value;
+ 
+   if (mFileData->mFilesOrDirectories.IsEmpty()) {
+     if ((IsDirPickerEnabled() && Allowdirs()) ||
+-        (IsWebkitDirPickerEnabled() &&
++        (DOMPrefs::WebkitBlinkDirectoryPickerEnabled() &&
+          HasAttr(kNameSpaceID_None, nsGkAtoms::webkitdirectory))) {
+       nsContentUtils::GetLocalizedString(nsContentUtils::eFORMS_PROPERTIES,
+                                          "NoDirSelected", value);
+     } else if (HasAttr(kNameSpaceID_None, nsGkAtoms::multiple)) {
+       nsContentUtils::GetLocalizedString(nsContentUtils::eFORMS_PROPERTIES,
+                                          "NoFilesSelected", value);
+     } else {
+       nsContentUtils::GetLocalizedString(nsContentUtils::eFORMS_PROPERTIES,
+@@ -2835,17 +2836,17 @@ HTMLInputElement::MozSetDndFilesAndDirec
+ 
+   if (IsWebkitFileSystemEnabled()) {
+     UpdateEntries(aFilesOrDirectories);
+   }
+ 
+   RefPtr<DispatchChangeEventCallback> dispatchChangeEventCallback =
+     new DispatchChangeEventCallback(this);
+ 
+-  if (IsWebkitDirPickerEnabled() &&
++  if (DOMPrefs::WebkitBlinkDirectoryPickerEnabled() &&
+       HasAttr(kNameSpaceID_None, nsGkAtoms::webkitdirectory)) {
+     ErrorResult rv;
+     GetFilesHelper* helper = GetOrCreateGetFilesHelper(true /* recursionFlag */,
+                                                        rv);
+     if (NS_WARN_IF(rv.Failed())) {
+       rv.SuppressException();
+       return;
+     }
+@@ -2917,17 +2918,17 @@ HTMLInputElement::FireChangeEventIfNeede
+ FileList*
+ HTMLInputElement::GetFiles()
+ {
+   if (mType != NS_FORM_INPUT_FILE) {
+     return nullptr;
+   }
+ 
+   if (IsDirPickerEnabled() && Allowdirs() &&
+-      (!IsWebkitDirPickerEnabled() ||
++      (!DOMPrefs::WebkitBlinkDirectoryPickerEnabled() ||
+        !HasAttr(kNameSpaceID_None, nsGkAtoms::webkitdirectory))) {
+     return nullptr;
+   }
+ 
+   if (!mFileData->mFileList) {
+     mFileData->mFileList = new FileList(static_cast<nsIContent*>(this));
+     UpdateFileList();
+   }
+@@ -4169,17 +4170,17 @@ HTMLInputElement::MaybeInitPickers(Event
+     // If the user clicked on the "Choose folder..." button we open the
+     // directory picker, else we open the file picker.
+     FilePickerType type = FILE_PICKER_FILE;
+     nsCOMPtr<nsIContent> target =
+       do_QueryInterface(aVisitor.mEvent->mOriginalTarget);
+     if (target &&
+         target->FindFirstNonChromeOnlyAccessContent() == this &&
+         ((IsDirPickerEnabled() && Allowdirs()) ||
+-         (IsWebkitDirPickerEnabled() &&
++         (DOMPrefs::WebkitBlinkDirectoryPickerEnabled() &&
+           HasAttr(kNameSpaceID_None, nsGkAtoms::webkitdirectory)))) {
+       type = FILE_PICKER_DIRECTORY;
+     }
+     return InitFilePicker(type);
+   }
+   if (mType == NS_FORM_INPUT_COLOR) {
+     return InitColorPicker();
+   }
+@@ -5632,31 +5633,16 @@ HTMLInputElement::IsDateTimeTypeSupporte
+           (IsInputDateTimeEnabled() || IsExperimentalFormsEnabled())) ||
+          ((aDateTimeInputType == NS_FORM_INPUT_MONTH ||
+            aDateTimeInputType == NS_FORM_INPUT_WEEK ||
+            aDateTimeInputType == NS_FORM_INPUT_DATETIME_LOCAL) &&
+           IsInputDateTimeOthersEnabled());
+ }
+ 
+ /* static */ bool
+-HTMLInputElement::IsWebkitDirPickerEnabled()
+-{
+-  static bool sWebkitDirPickerEnabled = false;
+-  static bool sWebkitDirPickerPrefCached = false;
+-  if (!sWebkitDirPickerPrefCached) {
+-    sWebkitDirPickerPrefCached = true;
+-    Preferences::AddBoolVarCache(&sWebkitDirPickerEnabled,
+-                                 "dom.webkitBlink.dirPicker.enabled",
+-                                 false);
+-  }
+-
+-  return sWebkitDirPickerEnabled;
+-}
+-
+-/* static */ bool
+ HTMLInputElement::IsWebkitFileSystemEnabled()
+ {
+   static bool sWebkitFileSystemEnabled = false;
+   static bool sWebkitFileSystemPrefCached = false;
+   if (!sWebkitFileSystemPrefCached) {
+     sWebkitFileSystemPrefCached = true;
+     Preferences::AddBoolVarCache(&sWebkitFileSystemEnabled,
+                                  "dom.webkitBlink.filesystem.enabled",
+diff --git a/dom/html/HTMLInputElement.h b/dom/html/HTMLInputElement.h
+--- a/dom/html/HTMLInputElement.h
++++ b/dom/html/HTMLInputElement.h
+@@ -1723,23 +1723,16 @@ private:
+   /**
+    * Checks if aDateTimeInputType should be supported based on "dom.forms.datetime",
+    * and "dom.experimental_forms".
+    */
+   static bool
+   IsDateTimeTypeSupported(uint8_t aDateTimeInputType);
+ 
+   /**
+-   * Checks preference "dom.webkitBlink.dirPicker.enabled" to determine if
+-   * webkitdirectory should be supported.
+-   */
+-  static bool
+-  IsWebkitDirPickerEnabled();
+-
+-  /**
+    * Checks preference "dom.webkitBlink.filesystem.enabled" to determine if
+    * webkitEntries should be supported.
+    */
+   static bool
+   IsWebkitFileSystemEnabled();
+ 
+   /**
+    * Checks preference "dom.input.dirpicker" to determine if file and directory
+diff --git a/dom/webidl/File.webidl b/dom/webidl/File.webidl
+--- a/dom/webidl/File.webidl
++++ b/dom/webidl/File.webidl
+@@ -29,17 +29,17 @@ dictionary ChromeFilePropertyBag : FileP
+   boolean existenceCheck = true;
+ };
+ 
+ // Mozilla extensions
+ partial interface File {
+   [GetterThrows, Deprecated="FileLastModifiedDate"]
+   readonly attribute Date lastModifiedDate;
+ 
+-  [BinaryName="relativePath", Func="mozilla::dom::Directory::WebkitBlinkDirectoryPickerEnabled"]
++  [BinaryName="relativePath", Func="mozilla::dom::DOMPrefs::WebkitBlinkDirectoryPickerEnabled"]
+   readonly attribute USVString webkitRelativePath;
+ 
+   [GetterThrows, ChromeOnly, NeedsCallerType]
+   readonly attribute DOMString mozFullPath;
+ };
+ 
+ // Mozilla extensions
+ // These 2 methods can be used only in these conditions:
+diff --git a/dom/workers/WorkerPrefs.h b/dom/workers/WorkerPrefs.h
+--- a/dom/workers/WorkerPrefs.h
++++ b/dom/workers/WorkerPrefs.h
+@@ -16,17 +16,16 @@
+ //     macro in Workers.h.
+ //   * The name of the function that updates the new value of a pref.
+ //
+ //   WORKER_PREF("foo.bar", UpdaterFunction)
+ //
+ //   * First argument is the name of the pref.
+ //   * The name of the function that updates the new value of a pref.
+ 
+-WORKER_SIMPLE_PREF("dom.webkitBlink.dirPicker.enabled", WebkitBlinkDirectoryPickerEnabled, DOM_WEBKITBLINK_DIRPICKER_WEBKITBLINK)
+ WORKER_SIMPLE_PREF("dom.netinfo.enabled", NetworkInformationEnabled, NETWORKINFORMATION_ENABLED)
+ WORKER_SIMPLE_PREF("dom.fetchObserver.enabled", FetchObserverEnabled, FETCHOBSERVER_ENABLED)
+ WORKER_SIMPLE_PREF("privacy.resistFingerprinting", ResistFingerprintingEnabled, RESISTFINGERPRINTING_ENABLED)
+ WORKER_SIMPLE_PREF("devtools.enabled", DevToolsEnabled, DEVTOOLS_ENABLED)
+ WORKER_PREF("intl.accept_languages", PrefLanguagesChanged)
+ WORKER_PREF("general.appname.override", AppNameOverrideChanged)
+ WORKER_PREF("general.appversion.override", AppVersionOverrideChanged)
+ WORKER_PREF("general.platform.override", PlatformOverrideChanged)
+diff --git a/layout/forms/nsFileControlFrame.cpp b/layout/forms/nsFileControlFrame.cpp
+--- a/layout/forms/nsFileControlFrame.cpp
++++ b/layout/forms/nsFileControlFrame.cpp
+@@ -7,16 +7,17 @@
+ #include "nsFileControlFrame.h"
+ 
+ #include "nsGkAtoms.h"
+ #include "nsCOMPtr.h"
+ #include "nsIDocument.h"
+ #include "mozilla/dom/NodeInfo.h"
+ #include "mozilla/dom/Element.h"
+ #include "mozilla/dom/DataTransfer.h"
++#include "mozilla/dom/DOMPrefs.h"
+ #include "mozilla/dom/HTMLButtonElement.h"
+ #include "mozilla/dom/HTMLInputElement.h"
+ #include "mozilla/Preferences.h"
+ #include "nsNodeInfoManager.h"
+ #include "nsContentCreatorFunctions.h"
+ #include "nsContentUtils.h"
+ #include "mozilla/EventStates.h"
+ #include "mozilla/dom/DOMStringList.h"
+@@ -348,17 +349,17 @@ nsresult
+ nsFileControlFrame::DnDListener::GetBlobImplForWebkitDirectory(nsIDOMFileList* aFileList,
+                                                                BlobImpl** aBlobImpl)
+ {
+   *aBlobImpl = nullptr;
+ 
+   HTMLInputElement* inputElement =
+     HTMLInputElement::FromContent(mFrame->GetContent());
+   bool webkitDirPicker =
+-    Preferences::GetBool("dom.webkitBlink.dirPicker.enabled", false) &&
++    DOMPrefs::WebkitBlinkDirectoryPickerEnabled() &&
+     inputElement->HasAttr(kNameSpaceID_None, nsGkAtoms::webkitdirectory);
+   if (!webkitDirPicker) {
+     return NS_OK;
+   }
+ 
+   if (!aFileList) {
+     return NS_ERROR_FAILURE;
+   }

+ 175 - 0
frg/work-js/mozilla-release/patches/1419771-17-59a1.patch

@@ -0,0 +1,175 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1515416705 -3600
+# Node ID 676de682404300c568123e6790f7b0e9fdd2a87d
+# Parent  db6ea1f39d6e03f3d26b772f4663c7d1973e0396
+Bug 1419771 - Introduce DOMPrefs, a thread-safe access to preferences for DOM - part 17 - Network Information enabled, r=asuth
+
+diff --git a/dom/base/DOMPrefs.cpp b/dom/base/DOMPrefs.cpp
+--- a/dom/base/DOMPrefs.cpp
++++ b/dom/base/DOMPrefs.cpp
+@@ -45,16 +45,17 @@ PREF(ServiceWorkersEnabled, "dom.service
+ PREF(ServiceWorkersTestingEnabled, "dom.serviceWorkers.testing.enabled")
+ PREF(StorageManagerEnabled, "dom.storageManager.enabled")
+ PREF(PromiseRejectionEventsEnabled, "dom.promise_rejection_events.enabled")
+ PREF(PushEnabled, "dom.push.enabled")
+ PREF(StreamsEnabled, "dom.streams.enabled")
+ PREF(RequestContextEnabled, "dom.requestcontext.enabled")
+ PREF(OffscreenCanvasEnabled, "gfx.offscreencanvas.enabled")
+ PREF(WebkitBlinkDirectoryPickerEnabled, "dom.webkitBlink.dirPicker.enabled")
++PREF(NetworkInformationEnabled, "dom.netinfo.enabled")
+ 
+ #undef PREF
+ 
+ #define PREF_WEBIDL(name)                        \
+   /* static */ bool                              \
+   DOMPrefs::name(JSContext* aCx, JSObject* aObj) \
+   {                                              \
+     return DOMPrefs::name();                     \
+@@ -67,13 +68,14 @@ PREF_WEBIDL(NotificationRIEnabled)
+ PREF_WEBIDL(ServiceWorkersEnabled)
+ PREF_WEBIDL(StorageManagerEnabled)
+ PREF_WEBIDL(PromiseRejectionEventsEnabled)
+ PREF_WEBIDL(PushEnabled)
+ PREF_WEBIDL(StreamsEnabled)
+ PREF_WEBIDL(RequestContextEnabled)
+ PREF_WEBIDL(OffscreenCanvasEnabled)
+ PREF_WEBIDL(WebkitBlinkDirectoryPickerEnabled)
++PREF_WEBIDL(NetworkInformationEnabled)
+ 
+ #undef PREF_WEBIDL
+ 
+ } // dom namespace
+ } // mozilla namespace
+diff --git a/dom/base/DOMPrefs.h b/dom/base/DOMPrefs.h
+--- a/dom/base/DOMPrefs.h
++++ b/dom/base/DOMPrefs.h
+@@ -74,14 +74,18 @@ public:
+ 
+   // Returns true if the gfx.offscreencanvas.enabled pref is set.
+   static bool OffscreenCanvasEnabled();
+   static bool OffscreenCanvasEnabled(JSContext* aCx, JSObject* aObj);
+ 
+   // Returns true if the dom.webkitBlink.dirPicker.enabled pref is set.
+   static bool WebkitBlinkDirectoryPickerEnabled();
+   static bool WebkitBlinkDirectoryPickerEnabled(JSContext* aCx, JSObject* aObj);
++
++  // Returns true if the dom.netinfo.enabled pref is set.
++  static bool NetworkInformationEnabled();
++  static bool NetworkInformationEnabled(JSContext* aCx, JSObject* aObj);
+ };
+ 
+ } // dom namespace
+ } // mozilla namespace
+ 
+ #endif // mozilla_dom_DOMPrefs_h
+diff --git a/dom/network/Connection.cpp b/dom/network/Connection.cpp
+--- a/dom/network/Connection.cpp
++++ b/dom/network/Connection.cpp
+@@ -99,28 +99,16 @@ Connection::Update(ConnectionType aType,
+   mDHCPGateway = aDHCPGateway;
+ 
+   if (aNotify && previousType != aType &&
+       !nsContentUtils::ShouldResistFingerprinting()) {
+     DispatchTrustedEvent(CHANGE_EVENT_NAME);
+   }
+ }
+ 
+-/* static */ bool
+-Connection::IsEnabled(JSContext* aCx, JSObject* aObj)
+-{
+-  if (NS_IsMainThread()) {
+-    return Preferences::GetBool("dom.netinfo.enabled");
+-  }
+-
+-  WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(aCx);
+-  MOZ_ASSERT(workerPrivate);
+-  return workerPrivate->NetworkInformationEnabled();
+-}
+-
+ /* static */ Connection*
+ Connection::CreateForWindow(nsPIDOMWindowInner* aWindow)
+ {
+   MOZ_ASSERT(aWindow);
+   return new ConnectionMainThread(aWindow);
+ }
+ 
+ /* static */ already_AddRefed<Connection>
+diff --git a/dom/network/Connection.h b/dom/network/Connection.h
+--- a/dom/network/Connection.h
++++ b/dom/network/Connection.h
+@@ -32,18 +32,16 @@ class Connection : public DOMEventTarget
+ {
+ public:
+   NS_DECL_ISUPPORTS_INHERITED
+   NS_DECL_NSINETWORKPROPERTIES
+   NS_DECL_OWNINGTHREAD
+ 
+   NS_REALLY_FORWARD_NSIDOMEVENTTARGET(DOMEventTargetHelper)
+ 
+-  static bool IsEnabled(JSContext* aCx, JSObject* aObj);
+-
+   static Connection*
+   CreateForWindow(nsPIDOMWindowInner* aWindow);
+ 
+   static already_AddRefed<Connection>
+   CreateForWorker(workers::WorkerPrivate* aWorkerPrivate,
+                   ErrorResult& aRv);
+ 
+   void Shutdown();
+diff --git a/dom/webidl/NetworkInformation.webidl b/dom/webidl/NetworkInformation.webidl
+--- a/dom/webidl/NetworkInformation.webidl
++++ b/dom/webidl/NetworkInformation.webidl
+@@ -13,14 +13,14 @@ enum ConnectionType {
+     "bluetooth",
+     "ethernet",
+     "wifi",
+     "other",
+     "none",
+     "unknown"
+ };
+ 
+-[Func="mozilla::dom::network::Connection::IsEnabled",
++[Func="mozilla::dom::DOMPrefs::NetworkInformationEnabled",
+  Exposed=(Window,Worker)]
+ interface NetworkInformation : EventTarget {
+     readonly    attribute ConnectionType type;
+                 attribute EventHandler   ontypechange;
+ };
+diff --git a/dom/webidl/WorkerNavigator.webidl b/dom/webidl/WorkerNavigator.webidl
+--- a/dom/webidl/WorkerNavigator.webidl
++++ b/dom/webidl/WorkerNavigator.webidl
+@@ -11,11 +11,11 @@ WorkerNavigator implements NavigatorID;
+ WorkerNavigator implements NavigatorLanguage;
+ WorkerNavigator implements NavigatorOnLine;
+ WorkerNavigator implements NavigatorConcurrentHardware;
+ WorkerNavigator implements NavigatorStorage;
+ 
+ // http://wicg.github.io/netinfo/#extensions-to-the-navigator-interface
+ [Exposed=(Worker)]
+ partial interface WorkerNavigator {
+-    [Func="mozilla::dom::network::Connection::IsEnabled", Throws]
++    [Func="mozilla::dom::DOMPrefs::NetworkInformationEnabled", Throws]
+     readonly attribute NetworkInformation connection;
+ };
+diff --git a/dom/workers/WorkerPrefs.h b/dom/workers/WorkerPrefs.h
+--- a/dom/workers/WorkerPrefs.h
++++ b/dom/workers/WorkerPrefs.h
+@@ -16,17 +16,16 @@
+ //     macro in Workers.h.
+ //   * The name of the function that updates the new value of a pref.
+ //
+ //   WORKER_PREF("foo.bar", UpdaterFunction)
+ //
+ //   * First argument is the name of the pref.
+ //   * The name of the function that updates the new value of a pref.
+ 
+-WORKER_SIMPLE_PREF("dom.netinfo.enabled", NetworkInformationEnabled, NETWORKINFORMATION_ENABLED)
+ WORKER_SIMPLE_PREF("dom.fetchObserver.enabled", FetchObserverEnabled, FETCHOBSERVER_ENABLED)
+ WORKER_SIMPLE_PREF("privacy.resistFingerprinting", ResistFingerprintingEnabled, RESISTFINGERPRINTING_ENABLED)
+ WORKER_SIMPLE_PREF("devtools.enabled", DevToolsEnabled, DEVTOOLS_ENABLED)
+ WORKER_PREF("intl.accept_languages", PrefLanguagesChanged)
+ WORKER_PREF("general.appname.override", AppNameOverrideChanged)
+ WORKER_PREF("general.appversion.override", AppVersionOverrideChanged)
+ WORKER_PREF("general.platform.override", PlatformOverrideChanged)
+ #ifdef JS_GC_ZEAL

+ 191 - 0
frg/work-js/mozilla-release/patches/1419771-18-59a1.patch

@@ -0,0 +1,191 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1515416705 -3600
+# Node ID 0e377b6fb31692c6d62914c67bf513821c7d3163
+# Parent  ad049974aa82c58041b044e91dc911269c4941a4
+Bug 1419771 - Introduce DOMPrefs, a thread-safe access to preferences for DOM - part 18 - FetchObserver API enabled, r=asuth
+
+diff --git a/dom/base/DOMPrefs.cpp b/dom/base/DOMPrefs.cpp
+--- a/dom/base/DOMPrefs.cpp
++++ b/dom/base/DOMPrefs.cpp
+@@ -46,16 +46,17 @@ PREF(ServiceWorkersTestingEnabled, "dom.
+ PREF(StorageManagerEnabled, "dom.storageManager.enabled")
+ PREF(PromiseRejectionEventsEnabled, "dom.promise_rejection_events.enabled")
+ PREF(PushEnabled, "dom.push.enabled")
+ PREF(StreamsEnabled, "dom.streams.enabled")
+ PREF(RequestContextEnabled, "dom.requestcontext.enabled")
+ PREF(OffscreenCanvasEnabled, "gfx.offscreencanvas.enabled")
+ PREF(WebkitBlinkDirectoryPickerEnabled, "dom.webkitBlink.dirPicker.enabled")
+ PREF(NetworkInformationEnabled, "dom.netinfo.enabled")
++PREF(FetchObserverEnabled, "dom.fetchObserver.enabled")
+ 
+ #undef PREF
+ 
+ #define PREF_WEBIDL(name)                        \
+   /* static */ bool                              \
+   DOMPrefs::name(JSContext* aCx, JSObject* aObj) \
+   {                                              \
+     return DOMPrefs::name();                     \
+@@ -69,13 +70,14 @@ PREF_WEBIDL(ServiceWorkersEnabled)
+ PREF_WEBIDL(StorageManagerEnabled)
+ PREF_WEBIDL(PromiseRejectionEventsEnabled)
+ PREF_WEBIDL(PushEnabled)
+ PREF_WEBIDL(StreamsEnabled)
+ PREF_WEBIDL(RequestContextEnabled)
+ PREF_WEBIDL(OffscreenCanvasEnabled)
+ PREF_WEBIDL(WebkitBlinkDirectoryPickerEnabled)
+ PREF_WEBIDL(NetworkInformationEnabled)
++PREF_WEBIDL(FetchObserverEnabled)
+ 
+ #undef PREF_WEBIDL
+ 
+ } // dom namespace
+ } // mozilla namespace
+diff --git a/dom/base/DOMPrefs.h b/dom/base/DOMPrefs.h
+--- a/dom/base/DOMPrefs.h
++++ b/dom/base/DOMPrefs.h
+@@ -78,14 +78,18 @@ public:
+ 
+   // Returns true if the dom.webkitBlink.dirPicker.enabled pref is set.
+   static bool WebkitBlinkDirectoryPickerEnabled();
+   static bool WebkitBlinkDirectoryPickerEnabled(JSContext* aCx, JSObject* aObj);
+ 
+   // Returns true if the dom.netinfo.enabled pref is set.
+   static bool NetworkInformationEnabled();
+   static bool NetworkInformationEnabled(JSContext* aCx, JSObject* aObj);
++
++  // Returns true if the dom.fetchObserver.enabled pref is set.
++  static bool FetchObserverEnabled();
++  static bool FetchObserverEnabled(JSContext* aCx, JSObject* aObj);
+ };
+ 
+ } // dom namespace
+ } // mozilla namespace
+ 
+ #endif // mozilla_dom_DOMPrefs_h
+diff --git a/dom/fetch/FetchObserver.cpp b/dom/fetch/FetchObserver.cpp
+--- a/dom/fetch/FetchObserver.cpp
++++ b/dom/fetch/FetchObserver.cpp
+@@ -21,34 +21,16 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_IN
+ NS_IMPL_CYCLE_COLLECTION_UNLINK_END
+ 
+ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(FetchObserver)
+ NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
+ 
+ NS_IMPL_ADDREF_INHERITED(FetchObserver, DOMEventTargetHelper)
+ NS_IMPL_RELEASE_INHERITED(FetchObserver, DOMEventTargetHelper)
+ 
+-/* static */ bool
+-FetchObserver::IsEnabled(JSContext* aCx, JSObject* aGlobal)
+-{
+-  if (NS_IsMainThread()) {
+-    return Preferences::GetBool("dom.fetchObserver.enabled", false);
+-  }
+-
+-  using namespace workers;
+-
+-  // Otherwise, check the pref via the WorkerPrivate
+-  WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(aCx);
+-  if (!workerPrivate) {
+-    return false;
+-  }
+-
+-  return workerPrivate->FetchObserverEnabled();
+-}
+-
+ FetchObserver::FetchObserver(nsIGlobalObject* aGlobal,
+                              AbortSignal* aSignal)
+   : DOMEventTargetHelper(aGlobal)
+   , mState(FetchState::Requesting)
+ {
+   if (aSignal) {
+     Follow(aSignal);
+   }
+diff --git a/dom/fetch/FetchObserver.h b/dom/fetch/FetchObserver.h
+--- a/dom/fetch/FetchObserver.h
++++ b/dom/fetch/FetchObserver.h
+@@ -16,19 +16,16 @@ namespace dom {
+ 
+ class FetchObserver final : public DOMEventTargetHelper
+                           , public AbortFollower
+ {
+ public:
+   NS_DECL_ISUPPORTS_INHERITED
+   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(FetchObserver, DOMEventTargetHelper)
+ 
+-  static bool
+-  IsEnabled(JSContext* aCx, JSObject* aGlobal);
+-
+   FetchObserver(nsIGlobalObject* aGlobal, AbortSignal* aSignal);
+ 
+   JSObject*
+   WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
+ 
+   FetchState
+   State() const;
+ 
+diff --git a/dom/webidl/FetchObserver.webidl b/dom/webidl/FetchObserver.webidl
+--- a/dom/webidl/FetchObserver.webidl
++++ b/dom/webidl/FetchObserver.webidl
+@@ -11,17 +11,17 @@ callback interface ObserverCallback {
+ enum FetchState {
+   // Pending states
+   "requesting", "responding",
+   // Final states
+   "aborted", "errored", "complete"
+ };
+ 
+ [Exposed=(Window,Worker),
+- Func="FetchObserver::IsEnabled"]
++ Func="mozilla::dom::DOMPrefs::FetchObserverEnabled"]
+ interface FetchObserver : EventTarget {
+   readonly attribute FetchState state;
+ 
+   // Events
+   attribute EventHandler onstatechange;
+   attribute EventHandler onrequestprogress;
+   attribute EventHandler onresponseprogress;
+ };
+diff --git a/dom/webidl/Request.webidl b/dom/webidl/Request.webidl
+--- a/dom/webidl/Request.webidl
++++ b/dom/webidl/Request.webidl
+@@ -56,17 +56,17 @@ dictionary RequestInit {
+   RequestRedirect redirect;
+   DOMString integrity;
+ 
+   [ChromeOnly]
+   boolean mozErrors;
+ 
+   AbortSignal? signal;
+ 
+-  [Func="FetchObserver::IsEnabled"]
++  [Func="mozilla::dom::DOMPrefs::FetchObserverEnabled"]
+   ObserverCallback observe;
+ };
+ 
+ // Gecko currently does not ship RequestContext, so please don't use it in IDL
+ // that is exposed to script.
+ enum RequestContext {
+   "audio", "beacon", "cspreport", "download", "embed", "eventsource", "favicon", "fetch",
+   "font", "form", "frame", "hyperlink", "iframe", "image", "imageset", "import",
+diff --git a/dom/workers/WorkerPrefs.h b/dom/workers/WorkerPrefs.h
+--- a/dom/workers/WorkerPrefs.h
++++ b/dom/workers/WorkerPrefs.h
+@@ -16,17 +16,16 @@
+ //     macro in Workers.h.
+ //   * The name of the function that updates the new value of a pref.
+ //
+ //   WORKER_PREF("foo.bar", UpdaterFunction)
+ //
+ //   * First argument is the name of the pref.
+ //   * The name of the function that updates the new value of a pref.
+ 
+-WORKER_SIMPLE_PREF("dom.fetchObserver.enabled", FetchObserverEnabled, FETCHOBSERVER_ENABLED)
+ WORKER_SIMPLE_PREF("privacy.resistFingerprinting", ResistFingerprintingEnabled, RESISTFINGERPRINTING_ENABLED)
+ WORKER_SIMPLE_PREF("devtools.enabled", DevToolsEnabled, DEVTOOLS_ENABLED)
+ WORKER_PREF("intl.accept_languages", PrefLanguagesChanged)
+ WORKER_PREF("general.appname.override", AppNameOverrideChanged)
+ WORKER_PREF("general.appversion.override", AppVersionOverrideChanged)
+ WORKER_PREF("general.platform.override", PlatformOverrideChanged)
+ #ifdef JS_GC_ZEAL
+ WORKER_PREF("dom.workers.options.gcZeal", LoadGCZealOptions)

+ 227 - 0
frg/work-js/mozilla-release/patches/1419771-19-59a1.patch

@@ -0,0 +1,227 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1515416706 -3600
+# Node ID 1cf5ddac1e2078f55aab0ece9d2ce52443f5a29a
+# Parent  9b9191baa920d7c0542648363ef471da7c4930ec
+Bug 1419771 - Introduce DOMPrefs, a thread-safe access to preferences for DOM - part 19 - Resist finger-printing enabled, r=asuth
+
+diff --git a/dom/base/DOMPrefs.cpp b/dom/base/DOMPrefs.cpp
+--- a/dom/base/DOMPrefs.cpp
++++ b/dom/base/DOMPrefs.cpp
+@@ -47,16 +47,17 @@ PREF(StorageManagerEnabled, "dom.storage
+ PREF(PromiseRejectionEventsEnabled, "dom.promise_rejection_events.enabled")
+ PREF(PushEnabled, "dom.push.enabled")
+ PREF(StreamsEnabled, "dom.streams.enabled")
+ PREF(RequestContextEnabled, "dom.requestcontext.enabled")
+ PREF(OffscreenCanvasEnabled, "gfx.offscreencanvas.enabled")
+ PREF(WebkitBlinkDirectoryPickerEnabled, "dom.webkitBlink.dirPicker.enabled")
+ PREF(NetworkInformationEnabled, "dom.netinfo.enabled")
+ PREF(FetchObserverEnabled, "dom.fetchObserver.enabled")
++PREF(ResistFingerprintingEnabled, "privacy.resistFingerprinting")
+ 
+ #undef PREF
+ 
+ #define PREF_WEBIDL(name)                        \
+   /* static */ bool                              \
+   DOMPrefs::name(JSContext* aCx, JSObject* aObj) \
+   {                                              \
+     return DOMPrefs::name();                     \
+diff --git a/dom/base/DOMPrefs.h b/dom/base/DOMPrefs.h
+--- a/dom/base/DOMPrefs.h
++++ b/dom/base/DOMPrefs.h
+@@ -82,14 +82,17 @@ public:
+ 
+   // Returns true if the dom.netinfo.enabled pref is set.
+   static bool NetworkInformationEnabled();
+   static bool NetworkInformationEnabled(JSContext* aCx, JSObject* aObj);
+ 
+   // Returns true if the dom.fetchObserver.enabled pref is set.
+   static bool FetchObserverEnabled();
+   static bool FetchObserverEnabled(JSContext* aCx, JSObject* aObj);
++
++  // Returns true if the privacy.resistFingerprinting pref is set.
++  static bool ResistFingerprintingEnabled();
+ };
+ 
+ } // dom namespace
+ } // mozilla namespace
+ 
+ #endif // mozilla_dom_DOMPrefs_h
+diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp
+--- a/dom/base/nsContentUtils.cpp
++++ b/dom/base/nsContentUtils.cpp
+@@ -2419,27 +2419,17 @@ nsContentUtils::IsCallerChrome()
+   // If the check failed, look for UniversalXPConnect on the cx compartment.
+   return xpc::IsUniversalXPConnectEnabled(GetCurrentJSContext());
+ }
+ 
+ /* static */
+ bool
+ nsContentUtils::ShouldResistFingerprinting()
+ {
+-  if (NS_IsMainThread()) {
+-    return nsRFPService::IsResistFingerprintingEnabled();
+-  }
+-
+-  workers::WorkerPrivate* workerPrivate = workers::GetCurrentThreadWorkerPrivate();
+-  if (NS_WARN_IF(!workerPrivate)) {
+-    return false;
+-  }
+-  workerPrivate->AssertIsOnWorkerThread();
+-
+-  return workerPrivate->ResistFingerprintingEnabled();
++  return DOMPrefs::ResistFingerprintingEnabled();
+ }
+ 
+ bool
+ nsContentUtils::ShouldResistFingerprinting(nsIDocShell* aDocShell)
+ {
+   if (!aDocShell) {
+     return false;
+   }
+diff --git a/dom/html/ImageDocument.cpp b/dom/html/ImageDocument.cpp
+--- a/dom/html/ImageDocument.cpp
++++ b/dom/html/ImageDocument.cpp
+@@ -1,15 +1,16 @@
+ /* -*- 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 "ImageDocument.h"
++#include "mozilla/dom/DOMPrefs.h"
+ #include "mozilla/dom/ImageDocumentBinding.h"
+ #include "mozilla/dom/HTMLImageElement.h"
+ #include "nsRect.h"
+ #include "nsIImageLoadingContent.h"
+ #include "nsGenericHTMLElement.h"
+ #include "nsDocShell.h"
+ #include "nsIDocumentInlines.h"
+ #include "nsDOMTokenList.h"
+@@ -44,17 +45,17 @@
+ #include <algorithm>
+ 
+ #define AUTOMATIC_IMAGE_RESIZING_PREF "browser.enable_automatic_image_resizing"
+ #define CLICK_IMAGE_RESIZING_PREF "browser.enable_click_image_resizing"
+ 
+ //XXX A hack needed for Firefox's site specific zoom.
+ static bool IsSiteSpecific()
+ {
+-  return !mozilla::Preferences::GetBool("privacy.resistFingerprinting", false) &&
++  return !mozilla::dom::DOMPrefs::ResistFingerprintingEnabled() &&
+          mozilla::Preferences::GetBool("browser.zoom.siteSpecific", false);
+ }
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+ class ImageListener : public MediaDocumentStreamListener
+ {
+diff --git a/dom/workers/WorkerNavigator.cpp b/dom/workers/WorkerNavigator.cpp
+--- a/dom/workers/WorkerNavigator.cpp
++++ b/dom/workers/WorkerNavigator.cpp
+@@ -1,15 +1,16 @@
+ /* -*- 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 "mozilla/dom/BindingUtils.h"
++#include "mozilla/dom/DOMPrefs.h"
+ #include "mozilla/dom/Promise.h"
+ #include "mozilla/dom/PromiseWorkerProxy.h"
+ #include "mozilla/dom/StorageManager.h"
+ #include "mozilla/dom/WorkerNavigator.h"
+ #include "mozilla/dom/WorkerNavigatorBinding.h"
+ #include "mozilla/dom/network/Connection.h"
+ 
+ #include "nsProxyRelease.h"
+@@ -76,59 +77,59 @@ WorkerNavigator::SetLanguages(const nsTA
+ 
+ void
+ WorkerNavigator::GetAppName(nsString& aAppName, CallerType aCallerType) const
+ {
+   WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
+   MOZ_ASSERT(workerPrivate);
+ 
+   if ((!mProperties.mAppNameOverridden.IsEmpty() ||
+-       workerPrivate->ResistFingerprintingEnabled()) &&
++       DOMPrefs::ResistFingerprintingEnabled()) &&
+       !workerPrivate->UsesSystemPrincipal()) {
+     // We will spoof this value when 'privacy.resistFingerprinting' is true.
+     // See nsRFPService.h for spoofed value.
+-    aAppName = workerPrivate->ResistFingerprintingEnabled() ?
++    aAppName = DOMPrefs::ResistFingerprintingEnabled() ?
+       NS_LITERAL_STRING(SPOOFED_APPNAME) : mProperties.mAppNameOverridden;
+   } else {
+     aAppName = mProperties.mAppName;
+   }
+ }
+ 
+ void
+ WorkerNavigator::GetAppVersion(nsString& aAppVersion, CallerType aCallerType,
+                                ErrorResult& aRv) const
+ {
+   WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
+   MOZ_ASSERT(workerPrivate);
+ 
+   if ((!mProperties.mAppVersionOverridden.IsEmpty() ||
+-       workerPrivate->ResistFingerprintingEnabled()) &&
++       DOMPrefs::ResistFingerprintingEnabled()) &&
+       !workerPrivate->UsesSystemPrincipal()) {
+     // We will spoof this value when 'privacy.resistFingerprinting' is true.
+     // See nsRFPService.h for spoofed value.
+-    aAppVersion = workerPrivate->ResistFingerprintingEnabled() ?
++    aAppVersion = DOMPrefs::ResistFingerprintingEnabled() ?
+       NS_LITERAL_STRING(SPOOFED_APPVERSION) : mProperties.mAppVersionOverridden;
+   } else {
+     aAppVersion = mProperties.mAppVersion;
+   }
+ }
+ 
+ void
+ WorkerNavigator::GetPlatform(nsString& aPlatform, CallerType aCallerType,
+                              ErrorResult& aRv) const
+ {
+   WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
+   MOZ_ASSERT(workerPrivate);
+ 
+   if ((!mProperties.mPlatformOverridden.IsEmpty() ||
+-       workerPrivate->ResistFingerprintingEnabled()) &&
++       DOMPrefs::ResistFingerprintingEnabled()) &&
+       !workerPrivate->UsesSystemPrincipal()) {
+     // We will spoof this value when 'privacy.resistFingerprinting' is true.
+     // See nsRFPService.h for spoofed value.
+-    aPlatform = workerPrivate->ResistFingerprintingEnabled() ?
++    aPlatform = DOMPrefs::ResistFingerprintingEnabled() ?
+       NS_LITERAL_STRING(SPOOFED_PLATFORM) : mProperties.mPlatformOverridden;
+   } else {
+     aPlatform = mProperties.mPlatform;
+   }
+ }
+ 
+ namespace {
+ 
+diff --git a/dom/workers/WorkerPrefs.h b/dom/workers/WorkerPrefs.h
+--- a/dom/workers/WorkerPrefs.h
++++ b/dom/workers/WorkerPrefs.h
+@@ -16,17 +16,16 @@
+ //     macro in Workers.h.
+ //   * The name of the function that updates the new value of a pref.
+ //
+ //   WORKER_PREF("foo.bar", UpdaterFunction)
+ //
+ //   * First argument is the name of the pref.
+ //   * The name of the function that updates the new value of a pref.
+ 
+-WORKER_SIMPLE_PREF("privacy.resistFingerprinting", ResistFingerprintingEnabled, RESISTFINGERPRINTING_ENABLED)
+ WORKER_SIMPLE_PREF("devtools.enabled", DevToolsEnabled, DEVTOOLS_ENABLED)
+ WORKER_PREF("intl.accept_languages", PrefLanguagesChanged)
+ WORKER_PREF("general.appname.override", AppNameOverrideChanged)
+ WORKER_PREF("general.appversion.override", AppVersionOverrideChanged)
+ WORKER_PREF("general.platform.override", PlatformOverrideChanged)
+ #ifdef JS_GC_ZEAL
+ WORKER_PREF("dom.workers.options.gcZeal", LoadGCZealOptions)
+ #endif

+ 185 - 0
frg/work-js/mozilla-release/patches/1419771-20-59a1.patch

@@ -0,0 +1,185 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1515416706 -3600
+# Node ID 895ca9b0e923580850dba9cab2af6d4a1c16edb2
+# Parent  62ea72955e198d95b71cbf274267e9fb86af74f3
+Bug 1419771 - Introduce DOMPrefs, a thread-safe access to preferences for DOM - part 20 - DevTools enabled, r=asuth
+
+diff --git a/dom/base/DOMPrefs.cpp b/dom/base/DOMPrefs.cpp
+--- a/dom/base/DOMPrefs.cpp
++++ b/dom/base/DOMPrefs.cpp
+@@ -48,16 +48,17 @@ PREF(PromiseRejectionEventsEnabled, "dom
+ PREF(PushEnabled, "dom.push.enabled")
+ PREF(StreamsEnabled, "dom.streams.enabled")
+ PREF(RequestContextEnabled, "dom.requestcontext.enabled")
+ PREF(OffscreenCanvasEnabled, "gfx.offscreencanvas.enabled")
+ PREF(WebkitBlinkDirectoryPickerEnabled, "dom.webkitBlink.dirPicker.enabled")
+ PREF(NetworkInformationEnabled, "dom.netinfo.enabled")
+ PREF(FetchObserverEnabled, "dom.fetchObserver.enabled")
+ PREF(ResistFingerprintingEnabled, "privacy.resistFingerprinting")
++PREF(DevToolsEnabled, "devtools.enabled")
+ 
+ #undef PREF
+ 
+ #define PREF_WEBIDL(name)                        \
+   /* static */ bool                              \
+   DOMPrefs::name(JSContext* aCx, JSObject* aObj) \
+   {                                              \
+     return DOMPrefs::name();                     \
+diff --git a/dom/base/DOMPrefs.h b/dom/base/DOMPrefs.h
+--- a/dom/base/DOMPrefs.h
++++ b/dom/base/DOMPrefs.h
+@@ -85,14 +85,17 @@ public:
+   static bool NetworkInformationEnabled(JSContext* aCx, JSObject* aObj);
+ 
+   // Returns true if the dom.fetchObserver.enabled pref is set.
+   static bool FetchObserverEnabled();
+   static bool FetchObserverEnabled(JSContext* aCx, JSObject* aObj);
+ 
+   // Returns true if the privacy.resistFingerprinting pref is set.
+   static bool ResistFingerprintingEnabled();
++
++  // Returns true if the devtools.enabled pref is set.
++  static bool DevToolsEnabled();
+ };
+ 
+ } // dom namespace
+ } // mozilla namespace
+ 
+ #endif // mozilla_dom_DOMPrefs_h
+diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp
+--- a/dom/base/nsContentUtils.cpp
++++ b/dom/base/nsContentUtils.cpp
+@@ -291,17 +291,16 @@ bool nsContentUtils::sTrustedFullScreenO
+ bool nsContentUtils::sIsCutCopyAllowed = true;
+ bool nsContentUtils::sIsFrameTimingPrefEnabled = false;
+ bool nsContentUtils::sIsPerformanceTimingEnabled = false;
+ bool nsContentUtils::sIsResourceTimingEnabled = false;
+ bool nsContentUtils::sIsPerformanceNavigationTimingEnabled = false;
+ bool nsContentUtils::sIsFormAutofillAutocompleteEnabled = false;
+ bool nsContentUtils::sIsWebComponentsEnabled = false;
+ bool nsContentUtils::sIsCustomElementsEnabled = false;
+-bool nsContentUtils::sDevToolsEnabled = false;
+ bool nsContentUtils::sSendPerformanceTimingNotifications = false;
+ bool nsContentUtils::sUseActivityCursor = false;
+ bool nsContentUtils::sAnimationsAPICoreEnabled = false;
+ bool nsContentUtils::sAnimationsAPIElementAnimateEnabled = false;
+ bool nsContentUtils::sAnimationsAPIPendingMemberEnabled = false;
+ bool nsContentUtils::sGetBoxQuadsEnabled = false;
+ bool nsContentUtils::sSkipCursorMoveForSameValueSet = false;
+ bool nsContentUtils::sRequestIdleCallbackEnabled = false;
+@@ -701,19 +700,16 @@ nsContentUtils::Init()
+                                "dom.forms.autocomplete.formautofill", false);
+ 
+   Preferences::AddBoolVarCache(&sIsWebComponentsEnabled,
+                                "dom.webcomponents.enabled", false);
+ 
+   Preferences::AddBoolVarCache(&sIsCustomElementsEnabled,
+                                "dom.webcomponents.customelements.enabled", false);
+ 
+-  Preferences::AddBoolVarCache(&sDevToolsEnabled,
+-                               "devtools.enabled");
+-
+   Preferences::AddIntVarCache(&sPrivacyMaxInnerWidth,
+                               "privacy.window.maxInnerWidth",
+                               1000);
+ 
+   Preferences::AddIntVarCache(&sPrivacyMaxInnerHeight,
+                               "privacy.window.maxInnerHeight",
+                               1000);
+ 
+@@ -11153,31 +11149,16 @@ nsContentUtils::ExtractErrorValues(JSCon
+       JS_ClearPendingException(aCx);
+     }
+   }
+ }
+ 
+ #undef EXTRACT_EXN_VALUES
+ 
+ /* static */ bool
+-nsContentUtils::DevToolsEnabled(JSContext* aCx)
+-{
+-  if (NS_IsMainThread()) {
+-    return sDevToolsEnabled;
+-  }
+-
+-  workers::WorkerPrivate* workerPrivate = workers::GetWorkerPrivateFromContext(aCx);
+-  if (!workerPrivate) {
+-    return false;
+-  }
+-
+-  return workerPrivate->DevToolsEnabled();
+-}
+-
+-/* static */ bool
+ nsContentUtils::ContentIsLink(nsIContent* aContent)
+ {
+   if (!aContent || !aContent->IsElement()) {
+     return false;
+   }
+ 
+   if (aContent->IsHTMLElement(nsGkAtoms::a)) {
+     return true;
+diff --git a/dom/base/nsContentUtils.h b/dom/base/nsContentUtils.h
+--- a/dom/base/nsContentUtils.h
++++ b/dom/base/nsContentUtils.h
+@@ -3437,17 +3437,16 @@ private:
+   static uint32_t sHandlingInputTimeout;
+   static bool sIsPerformanceTimingEnabled;
+   static bool sIsResourceTimingEnabled;
+   static bool sIsPerformanceNavigationTimingEnabled;
+   static bool sIsFrameTimingPrefEnabled;
+   static bool sIsFormAutofillAutocompleteEnabled;
+   static bool sIsWebComponentsEnabled;
+   static bool sIsCustomElementsEnabled;
+-  static bool sDevToolsEnabled;
+   static bool sSendPerformanceTimingNotifications;
+   static bool sUseActivityCursor;
+   static bool sAnimationsAPICoreEnabled;
+   static bool sAnimationsAPIElementAnimateEnabled;
+   static bool sAnimationsAPIPendingMemberEnabled;
+   static bool sGetBoxQuadsEnabled;
+   static bool sSkipCursorMoveForSameValueSet;
+   static bool sRequestIdleCallbackEnabled;
+diff --git a/dom/console/Console.cpp b/dom/console/Console.cpp
+--- a/dom/console/Console.cpp
++++ b/dom/console/Console.cpp
+@@ -1082,17 +1082,17 @@ bool
+ Console::IsEnabled(JSContext* aCx) const
+ {
+   // Console is always enabled if it is a custom Chrome-Only instance.
+   if (mChromeInstance) {
+     return true;
+   }
+ 
+   // Make all Console API no-op if DevTools aren't enabled.
+-  return nsContentUtils::DevToolsEnabled(aCx);
++  return DOMPrefs::DevToolsEnabled();
+ }
+ 
+ void
+ Console::ProfileMethodInternal(JSContext* aCx, MethodName aMethodName,
+                                const nsAString& aAction,
+                                const Sequence<JS::Value>& aData)
+ {
+   if (!IsEnabled(aCx)) {
+diff --git a/dom/workers/WorkerPrefs.h b/dom/workers/WorkerPrefs.h
+--- a/dom/workers/WorkerPrefs.h
++++ b/dom/workers/WorkerPrefs.h
+@@ -16,16 +16,15 @@
+ //     macro in Workers.h.
+ //   * The name of the function that updates the new value of a pref.
+ //
+ //   WORKER_PREF("foo.bar", UpdaterFunction)
+ //
+ //   * First argument is the name of the pref.
+ //   * The name of the function that updates the new value of a pref.
+ 
+-WORKER_SIMPLE_PREF("devtools.enabled", DevToolsEnabled, DEVTOOLS_ENABLED)
+ WORKER_PREF("intl.accept_languages", PrefLanguagesChanged)
+ WORKER_PREF("general.appname.override", AppNameOverrideChanged)
+ WORKER_PREF("general.appversion.override", AppVersionOverrideChanged)
+ WORKER_PREF("general.platform.override", PlatformOverrideChanged)
+ #ifdef JS_GC_ZEAL
+ WORKER_PREF("dom.workers.options.gcZeal", LoadGCZealOptions)
+ #endif

+ 577 - 0
frg/work-js/mozilla-release/patches/1419771-21-59a1.patch

@@ -0,0 +1,577 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1515416707 -3600
+# Node ID 0c9c890371bd8bcd240ca2b574edcb60ec5a5f9d
+# Parent  2acaa3c6b832aefe7baa282b4c0fbd60f5703cbc
+Bug 1419771 - Introduce DOMPrefs, a thread-safe access to preferences for DOM - part 21 - Get rid of WorkerPrefs.h, r=asuth
+
+diff --git a/dom/workers/RuntimeService.cpp b/dom/workers/RuntimeService.cpp
+--- a/dom/workers/RuntimeService.cpp
++++ b/dom/workers/RuntimeService.cpp
+@@ -1438,17 +1438,16 @@ END_WORKERS_NAMESPACE
+ struct RuntimeService::IdleThreadInfo
+ {
+   RefPtr<WorkerThread> mThread;
+   mozilla::TimeStamp mExpirationTime;
+ };
+ 
+ // This is only touched on the main thread. Initialized in Init() below.
+ JSSettings RuntimeService::sDefaultJSSettings;
+-bool RuntimeService::sDefaultPreferences[WORKERPREF_COUNT] = { false };
+ 
+ RuntimeService::RuntimeService()
+ : mMutex("RuntimeService::mMutex"), mObserved(false),
+   mShuttingDown(false), mNavigatorPropertiesLoaded(false)
+ {
+   AssertIsOnMainThread();
+   NS_ASSERTION(!gRuntimeService, "More than one service!");
+ }
+@@ -1962,27 +1961,27 @@ RuntimeService::Init()
+                             LoadJSGCMemoryOptions,
+                             PREF_WORKERS_OPTIONS_PREFIX PREF_MEM_OPTIONS_PREFIX)) ||
+ #ifdef JS_GC_ZEAL
+       NS_FAILED(Preferences::RegisterCallback(
+                                              LoadGCZealOptions,
+                                              PREF_JS_OPTIONS_PREFIX PREF_GCZEAL)) ||
+ #endif
+ 
+-#define WORKER_SIMPLE_PREF(name, getter, NAME)                                \
+-      NS_FAILED(Preferences::RegisterCallbackAndCall(                         \
+-                  WorkerPrefChanged,                                          \
+-                  name,                                                       \
+-                  reinterpret_cast<void*>(WORKERPREF_##NAME))) ||
+ #define WORKER_PREF(name, callback)                                           \
+       NS_FAILED(Preferences::RegisterCallbackAndCall(                         \
+                   callback,                                                   \
+                   name)) ||
+-#include "WorkerPrefs.h"
+-#undef WORKER_SIMPLE_PREF
++      WORKER_PREF("intl.accept_languages", PrefLanguagesChanged)
++      WORKER_PREF("general.appname.override", AppNameOverrideChanged)
++      WORKER_PREF("general.appversion.override", AppVersionOverrideChanged)
++      WORKER_PREF("general.platform.override", PlatformOverrideChanged)
++#ifdef JS_GC_ZEAL
++      WORKER_PREF("dom.workers.options.gcZeal", LoadGCZealOptions)
++#endif
+ #undef WORKER_PREF
+ 
+       NS_FAILED(Preferences::RegisterPrefixCallbackAndCall(
+                                                    LoadContextOptions,
+                                                    PREF_WORKERS_OPTIONS_PREFIX)) ||
+       NS_FAILED(Preferences::RegisterPrefixCallback(LoadContextOptions,
+                                                     PREF_JS_OPTIONS_PREFIX))) {
+     NS_WARNING("Failed to register pref callbacks!");
+@@ -2261,27 +2260,27 @@ RuntimeService::Cleanup()
+   NS_ASSERTION(!mWindowMap.Count(), "All windows should have been released!");
+ 
+   if (mObserved) {
+     if (NS_FAILED(Preferences::UnregisterPrefixCallback(LoadContextOptions,
+                                                         PREF_JS_OPTIONS_PREFIX)) ||
+         NS_FAILED(Preferences::UnregisterPrefixCallback(LoadContextOptions,
+                                                         PREF_WORKERS_OPTIONS_PREFIX)) ||
+ 
+-#define WORKER_SIMPLE_PREF(name, getter, NAME)                                \
+-      NS_FAILED(Preferences::UnregisterCallback(                              \
+-                  WorkerPrefChanged,                                          \
+-                  name,                                                       \
+-                  reinterpret_cast<void*>(WORKERPREF_##NAME))) ||
+ #define WORKER_PREF(name, callback)                                           \
+       NS_FAILED(Preferences::UnregisterCallback(                              \
+                   callback,                                                   \
+                   name)) ||
+-#include "WorkerPrefs.h"
+-#undef WORKER_SIMPLE_PREF
++      WORKER_PREF("intl.accept_languages", PrefLanguagesChanged)
++      WORKER_PREF("general.appname.override", AppNameOverrideChanged)
++      WORKER_PREF("general.appversion.override", AppVersionOverrideChanged)
++      WORKER_PREF("general.platform.override", PlatformOverrideChanged)
++#ifdef JS_GC_ZEAL
++      WORKER_PREF("dom.workers.options.gcZeal", LoadGCZealOptions)
++#endif
+ #undef WORKER_PREF
+ 
+ #ifdef JS_GC_ZEAL
+         NS_FAILED(Preferences::UnregisterCallback(
+                                              LoadGCZealOptions,
+                                              PREF_JS_OPTIONS_PREFIX PREF_GCZEAL)) ||
+ #endif
+         NS_FAILED(Preferences::UnregisterPrefixCallback(
+@@ -2672,22 +2671,16 @@ RuntimeService::UpdateAppVersionOverride
+ void
+ RuntimeService::UpdatePlatformOverridePreference(const nsAString& aValue)
+ {
+   AssertIsOnMainThread();
+   mNavigatorProperties.mPlatformOverridden = aValue;
+ }
+ 
+ void
+-RuntimeService::UpdateAllWorkerPreference(WorkerPreference aPref, bool aValue)
+-{
+-  BROADCAST_ALL_WORKERS(UpdatePreference, aPref, aValue);
+-}
+-
+-void
+ RuntimeService::UpdateAllWorkerLanguages(const nsTArray<nsString>& aLanguages)
+ {
+   MOZ_ASSERT(NS_IsMainThread());
+ 
+   mNavigatorProperties.mLanguages = aLanguages;
+   BROADCAST_ALL_WORKERS(UpdateLanguages, aLanguages);
+ }
+ 
+@@ -2796,44 +2789,16 @@ RuntimeService::Observe(nsISupports* aSu
+     SendOfflineStatusChangeEventToAllWorkers(NS_IsOffline());
+     return NS_OK;
+   }
+ 
+   NS_NOTREACHED("Unknown observer topic!");
+   return NS_OK;
+ }
+ 
+-/* static */ void
+-RuntimeService::WorkerPrefChanged(const char* aPrefName, void* aClosure)
+-{
+-  AssertIsOnMainThread();
+-
+-  const WorkerPreference key =
+-    static_cast<WorkerPreference>(reinterpret_cast<uintptr_t>(aClosure));
+-
+-  switch (key) {
+-#define WORKER_SIMPLE_PREF(name, getter, NAME) case WORKERPREF_##NAME:
+-#define WORKER_PREF(name, callback)
+-#include "WorkerPrefs.h"
+-#undef WORKER_SIMPLE_PREF
+-#undef WORKER_PREF
+-      sDefaultPreferences[key] = Preferences::GetBool(aPrefName, false);
+-      break;
+-
+-    default:
+-      MOZ_ASSERT_UNREACHABLE("Invalid pref key");
+-      break;
+-  }
+-
+-  RuntimeService* rts = RuntimeService::GetService();
+-  if (rts) {
+-    rts->UpdateAllWorkerPreference(key, sDefaultPreferences[key]);
+-  }
+-}
+-
+ bool
+ LogViolationDetailsRunnable::MainThreadRun()
+ {
+   AssertIsOnMainThread();
+ 
+   nsIContentSecurityPolicy* csp = mWorkerPrivate->GetCSP();
+   if (csp) {
+     NS_NAMED_LITERAL_STRING(scriptSample,
+diff --git a/dom/workers/RuntimeService.h b/dom/workers/RuntimeService.h
+--- a/dom/workers/RuntimeService.h
++++ b/dom/workers/RuntimeService.h
+@@ -86,17 +86,16 @@ 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 bool sDefaultPreferences[WORKERPREF_COUNT];
+ 
+ public:
+   struct NavigatorProperties
+   {
+     nsString mAppName;
+     nsString mAppNameOverridden;
+     nsString mAppVersion;
+     nsString mAppVersionOverridden;
+@@ -169,23 +168,16 @@ public:
+   static void
+   GetDefaultJSSettings(JSSettings& aSettings)
+   {
+     AssertIsOnMainThread();
+     aSettings = sDefaultJSSettings;
+   }
+ 
+   static void
+-  GetDefaultPreferences(bool aPreferences[WORKERPREF_COUNT])
+-  {
+-    AssertIsOnMainThread();
+-    memcpy(aPreferences, sDefaultPreferences, WORKERPREF_COUNT * sizeof(bool));
+-  }
+-
+-  static void
+   SetDefaultContextOptions(const JS::ContextOptions& aContextOptions)
+   {
+     AssertIsOnMainThread();
+     sDefaultJSSettings.contextOptions = aContextOptions;
+   }
+ 
+   void
+   UpdateAppNameOverridePreference(const nsAString& aValue);
+@@ -197,19 +189,16 @@ public:
+   UpdatePlatformOverridePreference(const nsAString& aValue);
+ 
+   void
+   UpdateAllWorkerContextOptions();
+ 
+   void
+   UpdateAllWorkerLanguages(const nsTArray<nsString>& aLanguages);
+ 
+-  void
+-  UpdateAllWorkerPreference(WorkerPreference aPref, bool aValue);
+-
+   static void
+   SetDefaultJSGCSettings(JSGCParamKey aKey, uint32_t aValue)
+   {
+     AssertIsOnMainThread();
+     sDefaultJSSettings.ApplyGCSetting(aKey, aValue);
+   }
+ 
+   void
+@@ -265,19 +254,16 @@ private:
+                       nsTArray<WorkerPrivate*>& aWorkers);
+ 
+   bool
+   ScheduleWorker(WorkerPrivate* aWorkerPrivate);
+ 
+   static void
+   ShutdownIdleThreads(nsITimer* aTimer, void* aClosure);
+ 
+-  static void
+-  WorkerPrefChanged(const char* aPrefName, void* aClosure);
+-
+   nsresult
+   CreateSharedWorkerFromLoadInfo(JSContext* aCx,
+                                  WorkerLoadInfo* aLoadInfo,
+                                  const nsAString& aScriptURL,
+                                  const nsAString& aName,
+                                  SharedWorker** aSharedWorker);
+ };
+ 
+diff --git a/dom/workers/WorkerPrefs.h b/dom/workers/WorkerPrefs.h
+deleted file mode 100644
+--- a/dom/workers/WorkerPrefs.h
++++ /dev/null
+@@ -1,30 +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/. */
+-
+-// This is the list of the preferences that are exposed to workers.
+-// The format is as follows:
+-//
+-//   WORKER_SIMPLE_PREF("foo.bar", FooBar, FOO_BAR, UpdaterFunction)
+-//
+-//   * First argument is the name of the pref.
+-//   * The name of the getter function.  This defines a FindName()
+-//     function that returns the value of the pref on WorkerPrivate.
+-//   * The macro version of the name.  This defines a WORKERPREF_FOO_BAR
+-//     macro in Workers.h.
+-//   * The name of the function that updates the new value of a pref.
+-//
+-//   WORKER_PREF("foo.bar", UpdaterFunction)
+-//
+-//   * First argument is the name of the pref.
+-//   * The name of the function that updates the new value of a pref.
+-
+-WORKER_PREF("intl.accept_languages", PrefLanguagesChanged)
+-WORKER_PREF("general.appname.override", AppNameOverrideChanged)
+-WORKER_PREF("general.appversion.override", AppVersionOverrideChanged)
+-WORKER_PREF("general.platform.override", PlatformOverrideChanged)
+-#ifdef JS_GC_ZEAL
+-WORKER_PREF("dom.workers.options.gcZeal", LoadGCZealOptions)
+-#endif
+diff --git a/dom/workers/WorkerPrivate.cpp b/dom/workers/WorkerPrivate.cpp
+--- a/dom/workers/WorkerPrivate.cpp
++++ b/dom/workers/WorkerPrivate.cpp
+@@ -1372,38 +1372,16 @@ private:
+   virtual bool
+   WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate) override
+   {
+     aWorkerPrivate->UpdateContextOptionsInternal(aCx, mContextOptions);
+     return true;
+   }
+ };
+ 
+-class UpdatePreferenceRunnable final : public WorkerControlRunnable
+-{
+-  WorkerPreference mPref;
+-  bool mValue;
+-
+-public:
+-  UpdatePreferenceRunnable(WorkerPrivate* aWorkerPrivate,
+-                           WorkerPreference aPref,
+-                           bool aValue)
+-    : WorkerControlRunnable(aWorkerPrivate, WorkerThreadUnchangedBusyCount),
+-      mPref(aPref),
+-      mValue(aValue)
+-  { }
+-
+-  virtual bool
+-  WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate) override
+-  {
+-    aWorkerPrivate->UpdatePreferenceInternal(mPref, mValue);
+-    return true;
+-  }
+-};
+-
+ class UpdateLanguagesRunnable final : public WorkerRunnable
+ {
+   nsTArray<nsString> mLanguages;
+ 
+ public:
+   UpdateLanguagesRunnable(WorkerPrivate* aWorkerPrivate,
+                           const nsTArray<nsString>& aLanguages)
+     : WorkerRunnable(aWorkerPrivate),
+@@ -3507,30 +3485,16 @@ WorkerPrivateParent<Derived>::UpdateCont
+     new UpdateContextOptionsRunnable(ParentAsWorkerPrivate(), aContextOptions);
+   if (!runnable->Dispatch()) {
+     NS_WARNING("Failed to update worker context options!");
+   }
+ }
+ 
+ template <class Derived>
+ void
+-WorkerPrivateParent<Derived>::UpdatePreference(WorkerPreference aPref, bool aValue)
+-{
+-  AssertIsOnParentThread();
+-  MOZ_ASSERT(aPref >= 0 && aPref < WORKERPREF_COUNT);
+-
+-  RefPtr<UpdatePreferenceRunnable> runnable =
+-    new UpdatePreferenceRunnable(ParentAsWorkerPrivate(), aPref, aValue);
+-  if (!runnable->Dispatch()) {
+-    NS_WARNING("Failed to update worker preferences!");
+-  }
+-}
+-
+-template <class Derived>
+-void
+ WorkerPrivateParent<Derived>::UpdateLanguages(const nsTArray<nsString>& aLanguages)
+ {
+   AssertIsOnParentThread();
+ 
+   RefPtr<UpdateLanguagesRunnable> runnable =
+     new UpdateLanguagesRunnable(ParentAsWorkerPrivate(), aLanguages);
+   if (!runnable->Dispatch()) {
+     NS_WARNING("Failed to update worker languages!");
+@@ -4533,22 +4497,20 @@ WorkerPrivate::WorkerPrivate(WorkerPriva
+   , mPeriodicGCTimerRunning(false)
+   , mIdleGCTimerRunning(false)
+   , mWorkerScriptExecutedSuccessfully(false)
+   , mFetchHandlerWasAdded(false)
+   , mOnLine(false)
+ {
+   if (aParent) {
+     aParent->AssertIsOnWorkerThread();
+-    aParent->GetAllPreferences(mPreferences);
+     mOnLine = aParent->OnLine();
+   }
+   else {
+     AssertIsOnMainThread();
+-    RuntimeService::GetDefaultPreferences(mPreferences);
+     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
+@@ -6854,29 +6816,16 @@ WorkerPrivate::UpdateLanguagesInternal(c
+   }
+ 
+   for (uint32_t index = 0; index < mChildWorkers.Length(); index++) {
+     mChildWorkers[index]->UpdateLanguages(aLanguages);
+   }
+ }
+ 
+ void
+-WorkerPrivate::UpdatePreferenceInternal(WorkerPreference aPref, bool aValue)
+-{
+-  AssertIsOnWorkerThread();
+-  MOZ_ASSERT(aPref >= 0 && aPref < WORKERPREF_COUNT);
+-
+-  mPreferences[aPref] = aValue;
+-
+-  for (uint32_t index = 0; index < mChildWorkers.Length(); index++) {
+-    mChildWorkers[index]->UpdatePreference(aPref, aValue);
+-  }
+-}
+-
+-void
+ WorkerPrivate::UpdateJSWorkerMemoryParameterInternal(JSContext* aCx,
+                                                      JSGCParamKey aKey,
+                                                      uint32_t aValue)
+ {
+   AssertIsOnWorkerThread();
+ 
+   // XXX aValue might be 0 here (telling us to unset a previous value for child
+   // workers). Calling JS_SetGCParameter with a value of 0 isn't actually
+diff --git a/dom/workers/WorkerPrivate.h b/dom/workers/WorkerPrivate.h
+--- a/dom/workers/WorkerPrivate.h
++++ b/dom/workers/WorkerPrivate.h
+@@ -405,19 +405,16 @@ public:
+ 
+   void
+   UpdateContextOptions(const JS::ContextOptions& aContextOptions);
+ 
+   void
+   UpdateLanguages(const nsTArray<nsString>& aLanguages);
+ 
+   void
+-  UpdatePreference(WorkerPreference aPref, bool aValue);
+-
+-  void
+   UpdateJSWorkerMemoryParameter(JSGCParamKey key, uint32_t value);
+ 
+ #ifdef JS_GC_ZEAL
+   void
+   UpdateGCZeal(uint8_t aGCZeal, uint32_t aFrequency);
+ #endif
+ 
+   void
+@@ -1067,17 +1064,16 @@ class WorkerPrivate : public WorkerPriva
+   bool mTimerRunning;
+   bool mRunningExpiredTimeouts;
+   bool mPendingEventQueueClearing;
+   bool mCancelAllPendingRunnables;
+   bool mPeriodicGCTimerRunning;
+   bool mIdleGCTimerRunning;
+   bool mWorkerScriptExecutedSuccessfully;
+   bool mFetchHandlerWasAdded;
+-  bool mPreferences[WORKERPREF_COUNT];
+   bool mOnLine;
+ 
+ protected:
+   ~WorkerPrivate();
+ 
+ public:
+   static already_AddRefed<WorkerPrivate>
+   Constructor(const GlobalObject& aGlobal, const nsAString& aScriptURL,
+@@ -1272,19 +1268,16 @@ public:
+ 
+   void
+   UpdateContextOptionsInternal(JSContext* aCx, const JS::ContextOptions& aContextOptions);
+ 
+   void
+   UpdateLanguagesInternal(const nsTArray<nsString>& aLanguages);
+ 
+   void
+-  UpdatePreferenceInternal(WorkerPreference aPref, bool aValue);
+-
+-  void
+   UpdateJSWorkerMemoryParameterInternal(JSContext* aCx, JSGCParamKey key, uint32_t aValue);
+ 
+   enum WorkerRanOrNot {
+     WorkerNeverRan = 0,
+     WorkerRan
+   };
+ 
+   void
+@@ -1396,28 +1389,16 @@ public:
+   CreateDebuggerGlobalScope(JSContext* aCx);
+ 
+   bool
+   RegisterBindings(JSContext* aCx, JS::Handle<JSObject*> aGlobal);
+ 
+   bool
+   RegisterDebuggerBindings(JSContext* aCx, JS::Handle<JSObject*> aGlobal);
+ 
+-#define WORKER_SIMPLE_PREF(name, getter, NAME)                                \
+-  bool                                                                        \
+-  getter() const                                                              \
+-  {                                                                           \
+-    AssertIsOnWorkerThread();                                                 \
+-    return mPreferences[WORKERPREF_##NAME];                                   \
+-  }
+-#define WORKER_PREF(name, callback)
+-#include "WorkerPrefs.h"
+-#undef WORKER_SIMPLE_PREF
+-#undef WORKER_PREF
+-
+   bool
+   OnLine() const
+   {
+     AssertIsOnWorkerThread();
+     return mOnLine;
+   }
+ 
+   void
+@@ -1568,23 +1549,16 @@ private:
+   WaitForWorkerEvents(PRIntervalTime interval = PR_INTERVAL_NO_TIMEOUT);
+ 
+   void
+   PostMessageToParentInternal(JSContext* aCx,
+                               JS::Handle<JS::Value> aMessage,
+                               const Sequence<JSObject*>& aTransferable,
+                               ErrorResult& aRv);
+ 
+-  void
+-  GetAllPreferences(bool aPreferences[WORKERPREF_COUNT]) const
+-  {
+-    AssertIsOnWorkerThread();
+-    memcpy(aPreferences, mPreferences, WORKERPREF_COUNT * sizeof(bool));
+-  }
+-
+   // 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);
+ 
+   bool
+   RunCurrentSyncLoop();
+diff --git a/dom/workers/Workers.h b/dom/workers/Workers.h
+--- a/dom/workers/Workers.h
++++ b/dom/workers/Workers.h
+@@ -181,26 +181,16 @@ struct JSSettings
+       foundSetting->key.reset();
+       return true;
+     }
+ 
+     return false;
+   }
+ };
+ 
+-enum WorkerPreference
+-{
+-#define WORKER_SIMPLE_PREF(name, getter, NAME) WORKERPREF_ ## NAME,
+-#define WORKER_PREF(name, callback)
+-#include "mozilla/dom/WorkerPrefs.h"
+-#undef WORKER_SIMPLE_PREF
+-#undef WORKER_PREF
+-  WORKERPREF_COUNT
+-};
+-
+ // Implemented in WorkerPrivate.cpp
+ 
+ struct WorkerLoadInfo
+ {
+   // All of these should be released in WorkerPrivateParent::ForgetMainThreadObjects.
+   nsCOMPtr<nsIURI> mBaseURI;
+   nsCOMPtr<nsIURI> mResolvedScriptURI;
+   nsCOMPtr<nsIPrincipal> mPrincipal;
+diff --git a/dom/workers/moz.build b/dom/workers/moz.build
+--- a/dom/workers/moz.build
++++ b/dom/workers/moz.build
+@@ -14,17 +14,16 @@ EXPORTS.mozilla.dom += [
+     'ServiceWorkerContainer.h',
+     'ServiceWorkerDescriptor.h',
+     'ServiceWorkerEvents.h',
+     'ServiceWorkerIPCUtils.h',
+     'ServiceWorkerRegistrar.h',
+     'ServiceWorkerRegistration.h',
+     'WorkerLocation.h',
+     'WorkerNavigator.h',
+-    'WorkerPrefs.h',
+     'WorkerPrivate.h',
+     'WorkerRunnable.h',
+     'WorkerScope.h',
+ ]
+ 
+ EXPORTS.mozilla.dom.workers += [
+     'RuntimeService.h',
+     'ServiceWorkerInfo.h',

+ 417 - 0
frg/work-js/mozilla-release/patches/1419771-22-59a1.patch

@@ -0,0 +1,417 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1515416707 -3600
+# Node ID 92324d3a0edfbf21050df048f66ff231fb9a30bf
+# Parent  db92ff42286ec1ebc68a62f1252236c1bfb80c34
+Bug 1419771 - Introduce DOMPrefs, a thread-safe access to preferences for DOM - part 22 - DOMPrefs initialized at startup, r=asuth
+
+diff --git a/dom/base/DOMPrefs.cpp b/dom/base/DOMPrefs.cpp
+--- a/dom/base/DOMPrefs.cpp
++++ b/dom/base/DOMPrefs.cpp
+@@ -6,80 +6,64 @@
+ 
+ #include "DOMPrefs.h"
+ #include "mozilla/Atomics.h"
+ #include "mozilla/Preferences.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+-#define PREF(name, pref)                                             \
++void
++DOMPrefs::Initialize()
++{
++  MOZ_ASSERT(NS_IsMainThread());
++
++  // Let's cache all the values on the main-thread.
++#if !(defined(DEBUG) || defined(MOZ_ENABLE_JS_DUMP))
++  DOMPrefs::DumpEnabled();
++#endif
++
++#define DOM_PREF(name, pref) DOMPrefs::name();
++#define DOM_WEBIDL_PREF(name)
++
++#include "DOMPrefsInternal.h"
++
++#undef DOM_PREF
++#undef DOM_WEBIDL_PREF
++}
++
++#define DOM_PREF(name, pref)                                         \
+   /* static */ bool                                                  \
+   DOMPrefs::name()                                                   \
+   {                                                                  \
+     static bool initialized = false;                                 \
+     static Atomic<bool> cachedValue;                                 \
+     if (!initialized) {                                              \
+       initialized = true;                                            \
+       Preferences::AddAtomicBoolVarCache(&cachedValue, pref, false); \
+     }                                                                \
+     return cachedValue;                                              \
+   }
+ 
++#define DOM_WEBIDL_PREF(name)                    \
++  /* static */ bool                              \
++  DOMPrefs::name(JSContext* aCx, JSObject* aObj) \
++  {                                              \
++    return DOMPrefs::name();                     \
++  }
++
+ #if !(defined(DEBUG) || defined(MOZ_ENABLE_JS_DUMP))
+-PREF(DumpEnabled, "browser.dom.window.dump.enabled")
++DOM_PREF(DumpEnabled, "browser.dom.window.dump.enabled")
+ #else
+ /* static */ bool
+ DOMPrefs::DumpEnabled()
+ {
+   return true;
+ }
+ #endif
+ 
+-PREF(ImageBitmapExtensionsEnabled, "canvas.imagebitmap_extensions.enabled")
+-PREF(DOMCachesEnabled, "dom.caches.enabled")
+-PREF(DOMCachesTestingEnabled, "dom.caches.testing.enabled")
+-PREF(PerformanceLoggingEnabled, "dom.performance.enable_user_timing_logging")
+-PREF(NotificationEnabled, "dom.webnotifications.enabled")
+-PREF(NotificationEnabledInServiceWorkers, "dom.webnotifications.serviceworker.enabled")
+-PREF(NotificationRIEnabled, "dom.webnotifications.requireinteraction.enabled")
+-PREF(ServiceWorkersEnabled, "dom.serviceWorkers.enabled")
+-PREF(ServiceWorkersTestingEnabled, "dom.serviceWorkers.testing.enabled")
+-PREF(StorageManagerEnabled, "dom.storageManager.enabled")
+-PREF(PromiseRejectionEventsEnabled, "dom.promise_rejection_events.enabled")
+-PREF(PushEnabled, "dom.push.enabled")
+-PREF(StreamsEnabled, "dom.streams.enabled")
+-PREF(RequestContextEnabled, "dom.requestcontext.enabled")
+-PREF(OffscreenCanvasEnabled, "gfx.offscreencanvas.enabled")
+-PREF(WebkitBlinkDirectoryPickerEnabled, "dom.webkitBlink.dirPicker.enabled")
+-PREF(NetworkInformationEnabled, "dom.netinfo.enabled")
+-PREF(FetchObserverEnabled, "dom.fetchObserver.enabled")
+-PREF(ResistFingerprintingEnabled, "privacy.resistFingerprinting")
+-PREF(DevToolsEnabled, "devtools.enabled")
+-
+-#undef PREF
++#include "DOMPrefsInternal.h"
+ 
+-#define PREF_WEBIDL(name)                        \
+-  /* static */ bool                              \
+-  DOMPrefs::name(JSContext* aCx, JSObject* aObj) \
+-  {                                              \
+-    return DOMPrefs::name();                     \
+-  }
+-
+-PREF_WEBIDL(ImageBitmapExtensionsEnabled)
+-PREF_WEBIDL(DOMCachesEnabled)
+-PREF_WEBIDL(NotificationEnabledInServiceWorkers)
+-PREF_WEBIDL(NotificationRIEnabled)
+-PREF_WEBIDL(ServiceWorkersEnabled)
+-PREF_WEBIDL(StorageManagerEnabled)
+-PREF_WEBIDL(PromiseRejectionEventsEnabled)
+-PREF_WEBIDL(PushEnabled)
+-PREF_WEBIDL(StreamsEnabled)
+-PREF_WEBIDL(RequestContextEnabled)
+-PREF_WEBIDL(OffscreenCanvasEnabled)
+-PREF_WEBIDL(WebkitBlinkDirectoryPickerEnabled)
+-PREF_WEBIDL(NetworkInformationEnabled)
+-PREF_WEBIDL(FetchObserverEnabled)
+-
+-#undef PREF_WEBIDL
++#undef DOM_PREF
++#undef DOM_WEBIDL_PREF
+ 
+ } // dom namespace
+ } // mozilla namespace
+diff --git a/dom/base/DOMPrefs.h b/dom/base/DOMPrefs.h
+--- a/dom/base/DOMPrefs.h
++++ b/dom/base/DOMPrefs.h
+@@ -8,94 +8,27 @@
+ #define mozilla_dom_DOMPrefs_h
+ 
+ namespace mozilla {
+ namespace dom {
+ 
+ class DOMPrefs final
+ {
+ public:
++  // This must be called on the main-thread.
++  static void Initialize();
++
+   // Returns true if the browser.dom.window.dump.enabled pref is set.
+   static bool DumpEnabled();
+ 
+-  // Returns true if the canvas.imagebitmap_extensions.enabled pref is set.
+-  static bool ImageBitmapExtensionsEnabled();
+-  static bool ImageBitmapExtensionsEnabled(JSContext* aCx, JSObject* aObj);
+-
+-  // Returns true if the dom.caches.enabled pref is set.
+-  static bool DOMCachesEnabled();
+-  static bool DOMCachesEnabled(JSContext* aCx, JSObject* aObj);
+-
+-  // Returns true if the dom.caches.testing.enabled pref is set.
+-  static bool DOMCachesTestingEnabled();
+-
+-  // Returns true if the dom.performance.enable_user_timing_logging pref is set.
+-  static bool PerformanceLoggingEnabled();
+-
+-  // Returns true if the dom.webnotifications.enabled pref is set.
+-  // Note that you should use NotificationEnabledInServiceWorkers if you need to
+-  // enable Notification API for ServiceWorkers
+-  static bool NotificationEnabled();
+-
+-  // Returns true if the dom.webnotifications.serviceworker.enabled pref is set.
+-  static bool NotificationEnabledInServiceWorkers();
+-  static bool NotificationEnabledInServiceWorkers(JSContext* aCx,
+-                                                  JSObject* aObj);
+-
+-  // Returns true if the dom.webnotifications.requireinteraction.enabled pref is
+-  // set.
+-  static bool NotificationRIEnabled();
+-  static bool NotificationRIEnabled(JSContext* aCx, JSObject* aObj);
+-
+-  // Returns true if the dom.serviceWorkers.enabled pref is set.
+-  static bool ServiceWorkersEnabled();
+-  static bool ServiceWorkersEnabled(JSContext* aCx, JSObject* aObj);
+-
+-  // Returns true if the dom.serviceWorkers.testing.enabled pref is set.
+-  static bool ServiceWorkersTestingEnabled();
++#define DOM_PREF(name, pref) static bool name();
++#define DOM_WEBIDL_PREF(name) static bool name(JSContext* aCx, JSObject* aObj);
+ 
+-  // Returns true if the dom.storageManager.enabled pref is set.
+-  static bool StorageManagerEnabled();
+-  static bool StorageManagerEnabled(JSContext* aCx, JSObject* aObj);
+-
+-  // Returns true if the dom.promise_rejection_events.enabled pref is set.
+-  static bool PromiseRejectionEventsEnabled();
+-  static bool PromiseRejectionEventsEnabled(JSContext* aCx, JSObject* aObj);
+-
+-  // Returns true if the dom.push.enabled pref is set.
+-  static bool PushEnabled();
+-  static bool PushEnabled(JSContext* aCx, JSObject* aObj);
+-
+-  // Returns true if the dom.streams.enabled pref is set.
+-  static bool StreamsEnabled();
+-  static bool StreamsEnabled(JSContext* aCx, JSObject* aObj);
+-
+-  // Returns true if the dom.requestcontext.enabled pref is set.
+-  static bool RequestContextEnabled();
+-  static bool RequestContextEnabled(JSContext* aCx, JSObject* aObj);
++#include "DOMPrefsInternal.h"
+ 
+-  // Returns true if the gfx.offscreencanvas.enabled pref is set.
+-  static bool OffscreenCanvasEnabled();
+-  static bool OffscreenCanvasEnabled(JSContext* aCx, JSObject* aObj);
+-
+-  // Returns true if the dom.webkitBlink.dirPicker.enabled pref is set.
+-  static bool WebkitBlinkDirectoryPickerEnabled();
+-  static bool WebkitBlinkDirectoryPickerEnabled(JSContext* aCx, JSObject* aObj);
+-
+-  // Returns true if the dom.netinfo.enabled pref is set.
+-  static bool NetworkInformationEnabled();
+-  static bool NetworkInformationEnabled(JSContext* aCx, JSObject* aObj);
+-
+-  // Returns true if the dom.fetchObserver.enabled pref is set.
+-  static bool FetchObserverEnabled();
+-  static bool FetchObserverEnabled(JSContext* aCx, JSObject* aObj);
+-
+-  // Returns true if the privacy.resistFingerprinting pref is set.
+-  static bool ResistFingerprintingEnabled();
+-
+-  // Returns true if the devtools.enabled pref is set.
+-  static bool DevToolsEnabled();
++#undef DOM_PREF
++#undef DOM_WEBIDL_PREF
+ };
+ 
+ } // dom namespace
+ } // mozilla namespace
+ 
+ #endif // mozilla_dom_DOMPrefs_h
+diff --git a/dom/base/DOMPrefsInternal.h b/dom/base/DOMPrefsInternal.h
+new file mode 100644
+--- /dev/null
++++ b/dom/base/DOMPrefsInternal.h
+@@ -0,0 +1,56 @@
++/* -*- 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/. */
++
++// This is the list of the preferences that are exposed to workers and
++// main-thread in DOM.
++// The format is as follows:
++//
++//   DOM_PREF(FooBar, "foo.bar")
++//
++//   * First argument is the name of the getter function.  This defines a
++//     DOMPrefs::FooBar()
++//   * The second argument is the name of the pref.
++// 
++//   DOM_WEBIDL_PREF(FooBar)
++//
++//   * This defines DOMPrefs::FooBar(JSContext* aCx, JSObject* aObj);
++//     This is allows the use of DOMPrefs in WebIDL files.
++
++DOM_PREF(ImageBitmapExtensionsEnabled, "canvas.imagebitmap_extensions.enabled")
++DOM_PREF(DOMCachesEnabled, "dom.caches.enabled")
++DOM_PREF(DOMCachesTestingEnabled, "dom.caches.testing.enabled")
++DOM_PREF(PerformanceLoggingEnabled, "dom.performance.enable_user_timing_logging")
++DOM_PREF(NotificationEnabled, "dom.webnotifications.enabled")
++DOM_PREF(NotificationEnabledInServiceWorkers, "dom.webnotifications.serviceworker.enabled")
++DOM_PREF(NotificationRIEnabled, "dom.webnotifications.requireinteraction.enabled")
++DOM_PREF(ServiceWorkersEnabled, "dom.serviceWorkers.enabled")
++DOM_PREF(ServiceWorkersTestingEnabled, "dom.serviceWorkers.testing.enabled")
++DOM_PREF(StorageManagerEnabled, "dom.storageManager.enabled")
++DOM_PREF(PromiseRejectionEventsEnabled, "dom.promise_rejection_events.enabled")
++DOM_PREF(PushEnabled, "dom.push.enabled")
++DOM_PREF(StreamsEnabled, "dom.streams.enabled")
++DOM_PREF(RequestContextEnabled, "dom.requestcontext.enabled")
++DOM_PREF(OffscreenCanvasEnabled, "gfx.offscreencanvas.enabled")
++DOM_PREF(WebkitBlinkDirectoryPickerEnabled, "dom.webkitBlink.dirPicker.enabled")
++DOM_PREF(NetworkInformationEnabled, "dom.netinfo.enabled")
++DOM_PREF(FetchObserverEnabled, "dom.fetchObserver.enabled")
++DOM_PREF(ResistFingerprintingEnabled, "privacy.resistFingerprinting")
++DOM_PREF(DevToolsEnabled, "devtools.enabled")
++
++DOM_WEBIDL_PREF(ImageBitmapExtensionsEnabled)
++DOM_WEBIDL_PREF(DOMCachesEnabled)
++DOM_WEBIDL_PREF(NotificationEnabledInServiceWorkers)
++DOM_WEBIDL_PREF(NotificationRIEnabled)
++DOM_WEBIDL_PREF(ServiceWorkersEnabled)
++DOM_WEBIDL_PREF(StorageManagerEnabled)
++DOM_WEBIDL_PREF(PromiseRejectionEventsEnabled)
++DOM_WEBIDL_PREF(PushEnabled)
++DOM_WEBIDL_PREF(StreamsEnabled)
++DOM_WEBIDL_PREF(RequestContextEnabled)
++DOM_WEBIDL_PREF(OffscreenCanvasEnabled)
++DOM_WEBIDL_PREF(WebkitBlinkDirectoryPickerEnabled)
++DOM_WEBIDL_PREF(NetworkInformationEnabled)
++DOM_WEBIDL_PREF(FetchObserverEnabled)
+diff --git a/dom/base/moz.build b/dom/base/moz.build
+--- a/dom/base/moz.build
++++ b/dom/base/moz.build
+@@ -169,16 +169,17 @@ EXPORTS.mozilla.dom += [
+     'DOMCursor.h',
+     'DOMException.h',
+     'DOMImplementation.h',
+     'DOMIntersectionObserver.h',
+     'DOMMatrix.h',
+     'DOMParser.h',
+     'DOMPoint.h',
+     'DOMPrefs.h',
++    'DOMPrefsInternal.h',
+     'DOMQuad.h',
+     'DOMRect.h',
+     'DOMRequest.h',
+     'DOMStringList.h',
+     'DOMTokenListSupportedTokens.h',
+     'Element.h',
+     'ElementInlines.h',
+     'EventSource.h',
+diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp
+--- a/dom/ipc/ContentChild.cpp
++++ b/dom/ipc/ContentChild.cpp
+@@ -20,16 +20,17 @@
+ #include "mozilla/ProcessHangMonitorIPC.h"
+ #include "mozilla/Unused.h"
+ #include "mozilla/devtools/HeapSnapshotTempFileHelperChild.h"
+ #include "mozilla/docshell/OfflineCacheUpdateChild.h"
+ #include "mozilla/dom/ClientManager.h"
+ #include "mozilla/dom/ClientOpenWindowOpActors.h"
+ #include "mozilla/dom/ContentBridgeChild.h"
+ #include "mozilla/dom/ContentBridgeParent.h"
++#include "mozilla/dom/DOMPrefs.h"
+ #include "mozilla/dom/VideoDecoderManagerChild.h"
+ #include "mozilla/dom/ContentParent.h"
+ #include "mozilla/dom/DataTransfer.h"
+ #include "mozilla/dom/DocGroup.h"
+ #include "mozilla/dom/ExternalHelperAppChild.h"
+ #include "mozilla/dom/FileCreatorHelper.h"
+ #include "mozilla/dom/GetFilesHelper.h"
+ #include "mozilla/dom/IPCBlobUtils.h"
+@@ -1171,16 +1172,18 @@ ContentChild::InitXPCOM(const XPCOMInitD
+ 
+   // The stylesheet cache is not ready yet. Store this URL for future use.
+   nsCOMPtr<nsIURI> ucsURL = DeserializeURI(aXPCOMInit.userContentSheetURL());
+   nsLayoutStylesheetCache::SetUserContentCSSURL(ucsURL);
+ 
+   GfxInfoBase::SetFeatureStatus(aXPCOMInit.gfxFeatureStatus());
+ 
+   DataStorage::SetCachedStorageEntries(aXPCOMInit.dataStorage());
++
++  DOMPrefs::Initialize();
+ }
+ 
+ mozilla::ipc::IPCResult
+ ContentChild::RecvRequestMemoryReport(const uint32_t& aGeneration,
+                                       const bool& aAnonymize,
+                                       const bool& aMinimizeMemoryUsage,
+                                       const MaybeFileDesc& aDMDFile)
+ {
+diff --git a/layout/build/nsLayoutStatics.cpp b/layout/build/nsLayoutStatics.cpp
+--- a/layout/build/nsLayoutStatics.cpp
++++ b/layout/build/nsLayoutStatics.cpp
+@@ -306,16 +306,23 @@ nsLayoutStatics::Initialize()
+   // On Android, we instantiate it when constructing AndroidBridge.
+   MediaPrefs::GetSingleton();
+ #endif
+ 
+   // This must be initialized on the main-thread.
+   mozilla::dom::IPCBlobInputStreamStorage::Initialize();
+ 
+   mozilla::dom::U2FTokenManager::Initialize();
++
++  if (XRE_IsParentProcess()) {
++    // On content process we initialize DOMPrefs when PContentChild is fully
++    // initialized.
++    mozilla::dom::DOMPrefs::Initialize();
++  }
++
+   return NS_OK;
+ }
+ 
+ void
+ nsLayoutStatics::Shutdown()
+ {
+   // Don't need to shutdown nsWindowMemoryReporter, that will be done by the
+   // memory reporter manager.
+diff --git a/layout/style/nsDOMCSSAttrDeclaration.h b/layout/style/nsDOMCSSAttrDeclaration.h
+--- a/layout/style/nsDOMCSSAttrDeclaration.h
++++ b/layout/style/nsDOMCSSAttrDeclaration.h
+@@ -11,16 +11,17 @@
+ 
+ #include "mozilla/Attributes.h"
+ #include "mozilla/dom/DocGroup.h"
+ #include "nsDOMCSSDeclaration.h"
+ 
+ 
+ namespace mozilla {
+ namespace dom {
++class DomGroup;
+ class Element;
+ } // namespace dom
+ } // namespace mozilla
+ 
+ class nsDOMCSSAttributeDeclaration final : public nsDOMCSSDeclaration
+ {
+ public:
+   typedef mozilla::dom::Element Element;
+@@ -35,17 +36,17 @@ public:
+   virtual mozilla::DeclarationBlock* GetCSSDeclaration(Operation aOperation) override;
+   virtual void GetCSSParsingEnvironment(CSSParsingEnvironment& aCSSParseEnv,
+                                         nsIPrincipal* aSubjectPrincipal) override;
+   nsDOMCSSDeclaration::ServoCSSParsingEnvironment
+   GetServoCSSParsingEnvironment(nsIPrincipal* aSubjectPrincipal) const final;
+   NS_IMETHOD GetParentRule(nsIDOMCSSRule **aParent) override;
+ 
+   virtual nsINode* GetParentObject() override;
+-  virtual DocGroup* GetDocGroup() const override;
++  virtual mozilla::dom::DocGroup* GetDocGroup() const override;
+ 
+   NS_IMETHOD SetPropertyValue(const nsCSSPropertyID aPropID,
+                               const nsAString& aValue,
+                               nsIPrincipal* aSubjectPrincipal) override;
+ 
+ protected:
+   ~nsDOMCSSAttributeDeclaration();
+ 

+ 28 - 0
frg/work-js/mozilla-release/patches/1419771-24-59a1.patch

@@ -0,0 +1,28 @@
+# HG changeset patch
+# User David Major <dmajor@mozilla.com>
+# Date 1515530627 18000
+# Node ID a2b1db70bc89cb917a8cebf1314f11b21171bc56
+# Parent  413400a657eb9cc795609bf3762661d49a27da87
+Bug 1419771 followup: fix mingw build bustage
+
+diff --git a/dom/workers/ServiceWorkerEvents.h b/dom/workers/ServiceWorkerEvents.h
+--- a/dom/workers/ServiceWorkerEvents.h
++++ b/dom/workers/ServiceWorkerEvents.h
+@@ -2,16 +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_serviceworkerevents_h__
+ #define mozilla_dom_workers_serviceworkerevents_h__
+ 
++#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/bindings/ServiceWorker.h"

+ 3 - 3
frg/work-js/mozilla-release/patches/1425965-1-59a1.patch

@@ -2,7 +2,7 @@
 # User Ben Kelly <ben@wanderview.com>
 # Date 1515777363 18000
 # Node ID bbc20dc8387908c28ad7c60341c99b6d17ae5e6b
-# Parent  ddb1c786f7940274b410dafffbbce8fde828b10e
+# Parent  c89b94786cd6a0a5dcf5e9a1ed2aca3c5afd38fe
 Bug 1425965 P1 Make ServiceWorkerManager::ReportToAllClients use ConsoleUtils::ReportForServiceWorkerScope. r=asuth
 
 diff --git a/dom/workers/ServiceWorkerManager.cpp b/dom/workers/ServiceWorkerManager.cpp
@@ -19,14 +19,14 @@ diff --git a/dom/workers/ServiceWorkerManager.cpp b/dom/workers/ServiceWorkerMan
  #include "mozilla/dom/ClientManager.h"
 +#include "mozilla/dom/ConsoleUtils.h"
  #include "mozilla/dom/ContentParent.h"
+ #include "mozilla/dom/DOMPrefs.h"
  #include "mozilla/dom/ErrorEvent.h"
  #include "mozilla/dom/Headers.h"
  #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"
-@@ -1720,158 +1721,22 @@ void
+@@ -1721,158 +1722,22 @@ void
  ServiceWorkerManager::ReportToAllClients(const nsCString& aScope,
                                           const nsString& aMessage,
                                           const nsString& aFilename,

+ 18 - 18
frg/work-js/mozilla-release/patches/1428685-59a1.patch

@@ -2,7 +2,7 @@
 # User Jessica Jong <jjong@mozilla.com>
 # Date 1516095720 -28800
 # Node ID bdd0bea249e3ded6e7e9a263ee002205ec30abf9
-# Parent  878e89f0bfc18d5bbba264a5b0e57a4ce0a2fe30
+# Parent  7efe35de5bc5f9062761f6de886954a2f7a435fd
 Bug 1428685 - Use dom.webcomponents.shadowdom.enabled pref for Shadow DOM. r=smaug
 
 Most of the Shadow DOM related code are behind "dom.webcomponents.enabled" and
@@ -295,27 +295,27 @@ diff --git a/dom/base/crashtests/crashtests.list b/dom/base/crashtests/crashtest
 diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp
 --- a/dom/base/nsContentUtils.cpp
 +++ b/dom/base/nsContentUtils.cpp
-@@ -290,17 +290,17 @@ bool nsContentUtils::sIsUnprefixedFullsc
+@@ -289,17 +289,17 @@ bool nsContentUtils::sIsFullScreenApiEna
+ bool nsContentUtils::sIsUnprefixedFullscreenApiEnabled = false;
  bool nsContentUtils::sTrustedFullScreenOnly = true;
  bool nsContentUtils::sIsCutCopyAllowed = true;
  bool nsContentUtils::sIsFrameTimingPrefEnabled = false;
  bool nsContentUtils::sIsPerformanceTimingEnabled = false;
  bool nsContentUtils::sIsResourceTimingEnabled = false;
  bool nsContentUtils::sIsPerformanceNavigationTimingEnabled = false;
- bool nsContentUtils::sIsUserTimingLoggingEnabled = false;
  bool nsContentUtils::sIsFormAutofillAutocompleteEnabled = false;
 -bool nsContentUtils::sIsWebComponentsEnabled = false;
 +bool nsContentUtils::sIsShadowDOMEnabled = false;
  bool nsContentUtils::sIsCustomElementsEnabled = false;
- bool nsContentUtils::sDevToolsEnabled = false;
  bool nsContentUtils::sSendPerformanceTimingNotifications = false;
  bool nsContentUtils::sUseActivityCursor = false;
  bool nsContentUtils::sAnimationsAPICoreEnabled = false;
  bool nsContentUtils::sAnimationsAPIElementAnimateEnabled = false;
  bool nsContentUtils::sAnimationsAPIPendingMemberEnabled = false;
  bool nsContentUtils::sGetBoxQuadsEnabled = false;
-@@ -703,18 +703,18 @@ nsContentUtils::Init()
-                                "dom.performance.enable_user_timing_logging", false);
+ bool nsContentUtils::sSkipCursorMoveForSameValueSet = false;
+@@ -694,18 +694,18 @@ nsContentUtils::Init()
+                                "dom.enable_performance_navigation_timing", true);
  
    Preferences::AddBoolVarCache(&sIsFrameTimingPrefEnabled,
                                 "dom.enable_frame_timing", false);
@@ -331,14 +331,14 @@ diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp
    Preferences::AddBoolVarCache(&sIsCustomElementsEnabled,
                                 "dom.webcomponents.customelements.enabled", false);
  
-   Preferences::AddBoolVarCache(&sDevToolsEnabled,
-                                "devtools.enabled");
- 
    Preferences::AddIntVarCache(&sPrivacyMaxInnerWidth,
+                               "privacy.window.maxInnerWidth",
+                               1000);
+ 
 diff --git a/dom/base/nsContentUtils.h b/dom/base/nsContentUtils.h
 --- a/dom/base/nsContentUtils.h
 +++ b/dom/base/nsContentUtils.h
-@@ -3158,17 +3158,17 @@ public:
+@@ -3141,17 +3141,17 @@ public:
                                          uint64_t* aRequestContextID);
  
    static nsresult
@@ -357,29 +357,29 @@ diff --git a/dom/base/nsContentUtils.h b/dom/base/nsContentUtils.h
    static bool ShouldBlockReservedKeys(mozilla::WidgetKeyboardEvent* aKeyEvent);
  
    /**
-@@ -3447,17 +3447,17 @@ private:
+@@ -3429,17 +3429,17 @@ private:
+   static bool sTrustedFullScreenOnly;
    static bool sIsCutCopyAllowed;
    static uint32_t sHandlingInputTimeout;
    static bool sIsPerformanceTimingEnabled;
    static bool sIsResourceTimingEnabled;
    static bool sIsPerformanceNavigationTimingEnabled;
-   static bool sIsUserTimingLoggingEnabled;
    static bool sIsFrameTimingPrefEnabled;
    static bool sIsFormAutofillAutocompleteEnabled;
 -  static bool sIsWebComponentsEnabled;
 +  static bool sIsShadowDOMEnabled;
    static bool sIsCustomElementsEnabled;
-   static bool sDevToolsEnabled;
    static bool sSendPerformanceTimingNotifications;
    static bool sUseActivityCursor;
    static bool sAnimationsAPICoreEnabled;
    static bool sAnimationsAPIElementAnimateEnabled;
    static bool sAnimationsAPIPendingMemberEnabled;
    static bool sGetBoxQuadsEnabled;
+   static bool sSkipCursorMoveForSameValueSet;
 diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp
 --- a/dom/base/nsDocument.cpp
 +++ b/dom/base/nsDocument.cpp
-@@ -1493,17 +1493,17 @@ nsIDocument::nsIDocument()
+@@ -1496,17 +1496,17 @@ nsIDocument::nsIDocument()
  {
    SetIsInDocument();
    for (auto& cnt : mIncCounters) {
@@ -398,7 +398,7 @@ diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp
    , mFlashClassification(FlashClassification::Unclassified)
    , mHeaderData(nullptr)
    , mIsGoingAway(false)
-@@ -2579,37 +2579,37 @@ nsDocument::IsSynthesized() {
+@@ -2581,37 +2581,37 @@ nsDocument::IsSynthesized() {
    if (internalChan) {
      DebugOnly<nsresult> rv = internalChan->GetResponseSynthesized(&synthesized);
      MOZ_ASSERT(NS_SUCCEEDED(rv), "GetResponseSynthesized shouldn't fail.");
@@ -444,7 +444,7 @@ diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp
 diff --git a/dom/base/nsDocument.h b/dom/base/nsDocument.h
 --- a/dom/base/nsDocument.h
 +++ b/dom/base/nsDocument.h
-@@ -625,21 +625,20 @@ public:
+@@ -624,21 +624,20 @@ public:
    virtual void UnscheduleSVGForPresAttrEvaluation(nsSVGElement* aSVG) override;
    virtual void ResolveScheduledSVGPresAttrs() override;
    bool IsSynthesized();
@@ -473,7 +473,7 @@ diff --git a/dom/base/nsDocument.h b/dom/base/nsDocument.h
 diff --git a/dom/base/nsIDocument.h b/dom/base/nsIDocument.h
 --- a/dom/base/nsIDocument.h
 +++ b/dom/base/nsIDocument.h
-@@ -3193,19 +3193,19 @@ public:
+@@ -3196,19 +3196,19 @@ public:
  
    // ResizeObserver usage.
    virtual void AddResizeObserver(mozilla::dom::ResizeObserver&) = 0;
@@ -495,7 +495,7 @@ diff --git a/dom/base/nsIDocument.h b/dom/base/nsIDocument.h
      return mUseCounters[aUseCounter];
    }
  
-@@ -3562,18 +3562,19 @@ protected:
+@@ -3560,18 +3560,19 @@ protected:
  
    // True if the document is allowed to use PaymentRequest.
    bool mAllowPaymentRequest : 1;

+ 3 - 3
frg/work-js/mozilla-release/patches/1439063-1-60a1.patch

@@ -2,7 +2,7 @@
 # User Jason Orendorff <jorendorff@mozilla.com>
 # Date 1519230619 21600
 # Node ID 0ceb91c42b0ff876a61ed23f5e587ba3a2083bcf
-# Parent  e816e14c84b763bafb5983bd4b26b5ce04a3f7af
+# Parent  696ef54a9b44727077332d4a6c60da2b51a6904a
 Bug 1439063 - Part 1: Move several public headers from js/src to js/public. r=jandem.
 
 js/src/jsalloc.h -> js/public/AllocPolicy.h
@@ -99,7 +99,7 @@ diff --git a/dom/base/WindowDestroyedEvent.cpp b/dom/base/WindowDestroyedEvent.c
 diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp
 --- a/dom/base/nsGlobalWindow.cpp
 +++ b/dom/base/nsGlobalWindow.cpp
-@@ -59,17 +59,17 @@
+@@ -64,17 +64,17 @@
  #include "nsVariant.h"
  #include "nsPrintfCString.h"
  #include "mozilla/intl/LocaleService.h"
@@ -4252,13 +4252,13 @@ diff --git a/js/xpconnect/src/XPCWrappedJSClass.cpp b/js/xpconnect/src/XPCWrappe
 -#include "jsprf.h"
 +#include "js/Printf.h"
  #include "nsArrayEnumerator.h"
- #include "nsContentUtils.h"
  #include "nsINamed.h"
  #include "nsIScriptError.h"
  #include "nsWrapperCache.h"
  #include "AccessCheck.h"
  #include "nsJSUtils.h"
  #include "nsPrintfCString.h"
+ #include "mozilla/Attributes.h"
 diff --git a/js/xpconnect/src/XPCWrappedNative.cpp b/js/xpconnect/src/XPCWrappedNative.cpp
 --- a/js/xpconnect/src/XPCWrappedNative.cpp
 +++ b/js/xpconnect/src/XPCWrappedNative.cpp

+ 28 - 0
frg/work-js/mozilla-release/patches/1447409-61a1.patch

@@ -0,0 +1,28 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1521613479 -3600
+# Node ID 93cd9d50d653ab87e0dd8251950176e574c86c8e
+# Parent  eaab20d9b0595e9efbdd61a9e9513ddc35c0d51e
+Bug 1447409 - DOMPrefs.h must be included in WorkerScope, r=qdot
+
+diff --git a/dom/workers/WorkerScope.h b/dom/workers/WorkerScope.h
+--- a/dom/workers/WorkerScope.h
++++ b/dom/workers/WorkerScope.h
+@@ -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/. */
+ 
+ #ifndef mozilla_dom_workerscope_h__
+ #define mozilla_dom_workerscope_h__
+ 
+ #include "Workers.h"
+ #include "mozilla/DOMEventTargetHelper.h"
++#include "mozilla/dom/DOMPrefs.h"
+ #include "mozilla/dom/Headers.h"
+ #include "mozilla/dom/RequestBinding.h"
+ #include "nsWeakReference.h"
+ #include "mozilla/dom/ImageBitmapSource.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 

+ 0 - 0
frg/work-js/mozilla-release/patches/1458382-61a1.patch → frg/work-js/mozilla-release/patches/1458382-1-61a1.patch


+ 0 - 0
frg/work-js/mozilla-release/patches/mozilla-central-push_429663.patch → frg/work-js/mozilla-release/patches/1461386-63a1.patch


+ 1 - 1
frg/work-js/mozilla-release/patches/1465585-2-std-62a1.patch

@@ -3,7 +3,7 @@
 # Date 1527724357 -7200
 #      Thu May 31 01:52:37 2018 +0200
 # Node ID 6979fe6c19b1c304bdfbc5b23f687c14b46f6c35
-# Parent  cfd5785a66ddc5fda4fed7b86001f5d77d0c5ddc
+# Parent  d6a9ac15184ac8a6d1e911914ec54eb3146568d2
 Bug 1465585: Don't error on pessimizing-move and self-move, for now. r=froydnj
 
 MozReview-Commit-ID: FzoqidPSCaV

+ 54 - 54
frg/work-js/mozilla-release/patches/1465585-3-std-62a1.patch

@@ -2,7 +2,7 @@
 # User Emilio Cobos Alvarez <emilio@crisal.io>
 # Date 1527707735 -7200
 # Node ID b54db66223586b4e04f5cb926fccdacf8a176b91
-# Parent  fe58351be8426819a9f5bdb0c4ba2390857d47c7
+# Parent  990a5c5f9fce762785790a323c9f4c9215e7be5e
 Bug 1465585: Switch from mozilla::Move to std::move. r=froydnj
 
 This was done automatically replacing:
@@ -2945,7 +2945,7 @@ diff --git a/dom/base/nsContentPermissionHelper.cpp b/dom/base/nsContentPermissi
 diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp
 --- a/dom/base/nsContentUtils.cpp
 +++ b/dom/base/nsContentUtils.cpp
-@@ -554,17 +554,17 @@ StableStateEventTarget::IsOnCurrentThrea
+@@ -548,17 +548,17 @@ StableStateEventTarget::IsOnCurrentThrea
  }
  
  NS_IMETHODIMP
@@ -2964,7 +2964,7 @@ diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp
  {
    return Dispatch(nsCOMPtr<nsIRunnable>(aEvent).forget(), aFlags);
  }
-@@ -5910,25 +5910,25 @@ nsContentUtils::AddScriptRunner(nsIRunna
+@@ -5883,25 +5883,25 @@ nsContentUtils::AddScriptRunner(nsIRunna
    AddScriptRunner(runnable.forget());
  }
  
@@ -3448,7 +3448,7 @@ diff --git a/dom/base/nsFrameLoader.cpp b/dom/base/nsFrameLoader.cpp
 diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp
 --- a/dom/base/nsGlobalWindow.cpp
 +++ b/dom/base/nsGlobalWindow.cpp
-@@ -3450,29 +3450,29 @@ nsGlobalWindow::EnsureClientSource()
+@@ -3451,29 +3451,29 @@ nsGlobalWindow::EnsureClientSource()
    // Try to get the reserved client from the LoadInfo.  A Client is
    // reserved at the start of the channel load if there is not an
    // initial about:blank document that will be reused.  It is also
@@ -3480,7 +3480,7 @@ diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp
    // Verify the final ClientSource principal matches the final document
    // principal.  The ClientChannelHelper handles things like network
    // redirects, but there are other ways the document principal can change.
-@@ -4439,29 +4439,29 @@ void
+@@ -4440,29 +4440,29 @@ void
  nsPIDOMWindowInner::SyncStateFromParentWindow()
  {
    nsGlobalWindow::Cast(this)->SyncStateFromParentWindow();
@@ -3513,7 +3513,7 @@ diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp
    nsGlobalWindow::Cast(this)->NoteCalledRegisterForServiceWorkerScope(aScope);
  }
  
-@@ -11909,17 +11909,17 @@ nsGlobalWindow::ShowSlowScriptDialog(con
+@@ -11910,17 +11910,17 @@ nsGlobalWindow::ShowSlowScriptDialog(con
    auto getString = [&] (const char* name,
                          nsContentUtils::PropertiesFile propFile = nsContentUtils::eDOM_PROPERTIES) {
      nsAutoString result;
@@ -3532,7 +3532,7 @@ diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp
    // Get localizable strings
  
    nsAutoString title, checkboxMsg, debugButton, msg;
-@@ -12763,43 +12763,43 @@ nsGlobalWindow::CallOnChildren(Method aM
+@@ -12764,43 +12764,43 @@ nsGlobalWindow::CallOnChildren(Method aM
  Maybe<ClientInfo>
  nsGlobalWindow::GetClientInfo() const
  {
@@ -3579,7 +3579,7 @@ diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp
    FORWARD_TO_INNER(FireDelayedDOMEvents, (), NS_ERROR_UNEXPECTED);
  
    if (mApplicationCache) {
-@@ -15136,19 +15136,19 @@ nsPIDOMWindow<T>::GetDocGroup() const
+@@ -15137,19 +15137,19 @@ nsPIDOMWindow<T>::GetDocGroup() const
  }
  
  nsresult
@@ -4163,7 +4163,7 @@ diff --git a/dom/bindings/TypedArray.h b/dom/bindings/TypedArray.h
 diff --git a/dom/cache/Cache.cpp b/dom/cache/Cache.cpp
 --- a/dom/cache/Cache.cpp
 +++ b/dom/cache/Cache.cpp
-@@ -113,17 +113,17 @@ IsValidPutResponseStatus(Response& aResp
+@@ -114,17 +114,17 @@ IsValidPutResponseStatus(Response& aResp
  // actor.
  class Cache::FetchHandler final : public PromiseNativeHandler
  {
@@ -4182,7 +4182,7 @@ diff --git a/dom/cache/Cache.cpp b/dom/cache/Cache.cpp
    }
  
    virtual void
-@@ -190,17 +190,17 @@ public:
+@@ -191,17 +191,17 @@ public:
        ErrorResult errorResult;
        if (!IsValidPutResponseStatus(*response, PutStatusPolicy::RequireOK,
                                      errorResult)) {
@@ -4201,7 +4201,7 @@ diff --git a/dom/cache/Cache.cpp b/dom/cache/Cache.cpp
      ErrorResult result;
      // TODO: Here we use the JSContext as received by the ResolvedCallback, and
      // its state could be the wrong one. The spec doesn't say anything
-@@ -359,18 +359,18 @@ Cache::Add(JSContext* aContext, const Re
+@@ -360,18 +360,18 @@ Cache::Add(JSContext* aContext, const Re
    }
  
    nsAutoString url;
@@ -4222,7 +4222,7 @@ diff --git a/dom/cache/Cache.cpp b/dom/cache/Cache.cpp
                CallerType aCallerType,
                ErrorResult& aRv)
  {
-@@ -407,20 +407,20 @@ Cache::AddAll(JSContext* aContext,
+@@ -408,20 +408,20 @@ Cache::AddAll(JSContext* aContext,
      }
  
      nsAutoString url;
@@ -4245,7 +4245,7 @@ diff --git a/dom/cache/Cache.cpp b/dom/cache/Cache.cpp
  {
    if (NS_WARN_IF(!mActor)) {
      aRv.Throw(NS_ERROR_UNEXPECTED);
-@@ -637,27 +637,27 @@ Cache::AddAll(const GlobalObject& aGloba
+@@ -615,27 +615,27 @@ Cache::AddAll(const GlobalObject& aGloba
      RequestOrUSVString requestOrString;
      requestOrString.SetAsRequest() = aRequestList[i];
      RefPtr<Promise> fetch = FetchRequest(mGlobal, requestOrString,
@@ -4278,7 +4278,7 @@ diff --git a/dom/cache/Cache.cpp b/dom/cache/Cache.cpp
 diff --git a/dom/cache/CacheStorage.cpp b/dom/cache/CacheStorage.cpp
 --- a/dom/cache/CacheStorage.cpp
 +++ b/dom/cache/CacheStorage.cpp
-@@ -338,17 +338,17 @@ CacheStorage::Match(JSContext* aCx, cons
+@@ -339,17 +339,17 @@ CacheStorage::Match(JSContext* aCx, cons
    CacheQueryParams params;
    ToCacheQueryParams(params, aOptions);
  
@@ -4297,7 +4297,7 @@ diff --git a/dom/cache/CacheStorage.cpp b/dom/cache/CacheStorage.cpp
  CacheStorage::Has(const nsAString& aKey, ErrorResult& aRv)
  {
    NS_ASSERT_OWNINGTHREAD(CacheStorage);
-@@ -362,17 +362,17 @@ CacheStorage::Has(const nsAString& aKey,
+@@ -363,17 +363,17 @@ CacheStorage::Has(const nsAString& aKey,
    if (NS_WARN_IF(!promise)) {
      return nullptr;
    }
@@ -4316,7 +4316,7 @@ diff --git a/dom/cache/CacheStorage.cpp b/dom/cache/CacheStorage.cpp
  CacheStorage::Open(const nsAString& aKey, ErrorResult& aRv)
  {
    NS_ASSERT_OWNINGTHREAD(CacheStorage);
-@@ -386,17 +386,17 @@ CacheStorage::Open(const nsAString& aKey
+@@ -387,17 +387,17 @@ CacheStorage::Open(const nsAString& aKey
    if (NS_WARN_IF(!promise)) {
      return nullptr;
    }
@@ -4335,7 +4335,7 @@ diff --git a/dom/cache/CacheStorage.cpp b/dom/cache/CacheStorage.cpp
  CacheStorage::Delete(const nsAString& aKey, ErrorResult& aRv)
  {
    NS_ASSERT_OWNINGTHREAD(CacheStorage);
-@@ -410,17 +410,17 @@ CacheStorage::Delete(const nsAString& aK
+@@ -411,17 +411,17 @@ CacheStorage::Delete(const nsAString& aK
    if (NS_WARN_IF(!promise)) {
      return nullptr;
    }
@@ -4354,7 +4354,7 @@ diff --git a/dom/cache/CacheStorage.cpp b/dom/cache/CacheStorage.cpp
  CacheStorage::Keys(ErrorResult& aRv)
  {
    NS_ASSERT_OWNINGTHREAD(CacheStorage);
-@@ -434,17 +434,17 @@ CacheStorage::Keys(ErrorResult& aRv)
+@@ -435,17 +435,17 @@ CacheStorage::Keys(ErrorResult& aRv)
    if (NS_WARN_IF(!promise)) {
      return nullptr;
    }
@@ -4370,10 +4370,10 @@ diff --git a/dom/cache/CacheStorage.cpp b/dom/cache/CacheStorage.cpp
  }
  
  // static
- bool
- CacheStorage::PrefEnabled(JSContext* aCx, JSObject* aObj)
- {
-@@ -549,17 +549,17 @@ CacheStorage::~CacheStorage()
+ already_AddRefed<CacheStorage>
+ CacheStorage::Constructor(const GlobalObject& aGlobal,
+                           CacheStorageNamespace aNamespace,
+@@ -543,17 +543,17 @@ CacheStorage::~CacheStorage()
    }
  }
  
@@ -5063,7 +5063,7 @@ diff --git a/dom/canvas/CanvasRenderingContextHelper.cpp b/dom/canvas/CanvasRend
 diff --git a/dom/canvas/ImageBitmap.cpp b/dom/canvas/ImageBitmap.cpp
 --- a/dom/canvas/ImageBitmap.cpp
 +++ b/dom/canvas/ImageBitmap.cpp
-@@ -791,17 +791,17 @@ ImageBitmap::ToCloneData() const
+@@ -792,17 +792,17 @@ ImageBitmap::ToCloneData() const
    UniquePtr<ImageBitmapCloneData> result(new ImageBitmapCloneData());
    result->mPictureRect = mPictureRect;
    result->mAlphaType = mAlphaType;
@@ -5082,7 +5082,7 @@ diff --git a/dom/canvas/ImageBitmap.cpp b/dom/canvas/ImageBitmap.cpp
  {
    RefPtr<layers::Image> data = CreateImageFromSurface(aData->mSurface);
  
-@@ -1250,17 +1250,17 @@ private:
+@@ -1251,17 +1251,17 @@ private:
                              already_AddRefed<nsIInputStream> aInputStream,
                              const nsACString& aMimeType,
                              const Maybe<IntRect>& aCropRect,
@@ -5101,7 +5101,7 @@ diff --git a/dom/canvas/ImageBitmap.cpp b/dom/canvas/ImageBitmap.cpp
    {
    }
  
-@@ -2209,17 +2209,17 @@ CreateImageBitmapFromBlob::Create(Promis
+@@ -2198,17 +2198,17 @@ CreateImageBitmapFromBlob::Create(Promis
  
    UniquePtr<CreateImageBitmapFromBlobHolder> holder(
      new CreateImageBitmapFromBlobHolder(workerPrivate, task));
@@ -5123,7 +5123,7 @@ diff --git a/dom/canvas/ImageBitmap.cpp b/dom/canvas/ImageBitmap.cpp
 diff --git a/dom/canvas/OffscreenCanvas.cpp b/dom/canvas/OffscreenCanvas.cpp
 --- a/dom/canvas/OffscreenCanvas.cpp
 +++ b/dom/canvas/OffscreenCanvas.cpp
-@@ -155,17 +155,17 @@ OffscreenCanvas::GetContext(JSContext* a
+@@ -156,17 +156,17 @@ OffscreenCanvas::GetContext(JSContext* a
          gl::GLScreenBuffer* screen = gl->Screen();
          gl::SurfaceCaps caps = screen->mCaps;
          auto forwarder = mCanvasClient->GetForwarder();
@@ -8252,7 +8252,7 @@ diff --git a/dom/ipc/ContentBridgeParent.cpp b/dom/ipc/ContentBridgeParent.cpp
 diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp
 --- a/dom/ipc/ContentChild.cpp
 +++ b/dom/ipc/ContentChild.cpp
-@@ -551,18 +551,18 @@ ContentChild::RecvSetXPCOMProcessAttribu
+@@ -552,18 +552,18 @@ ContentChild::RecvSetXPCOMProcessAttribu
                                              const StructuredCloneData& aInitialData,
                                              nsTArray<LookAndFeelInt>&& aLookAndFeelIntCache,
                                              nsTArray<SystemFontListEntry>&& aFontList)
@@ -8273,7 +8273,7 @@ diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp
  }
  
  bool
-@@ -1019,34 +1019,34 @@ ContentChild::ProvideWindowCommon(TabChi
+@@ -1020,34 +1020,34 @@ ContentChild::ProvideWindowCommon(TabChi
        url.SetIsVoid(true);
      }
  
@@ -8310,7 +8310,7 @@ diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp
  
    // We have to wait for a response from either SendCreateWindow or
    // SendBrowserFrameOpenWindow with information we're going to need to return
-@@ -1264,49 +1264,49 @@ ContentChild::DeallocPCycleCollectWithLo
+@@ -1267,49 +1267,49 @@ ContentChild::DeallocPCycleCollectWithLo
    // Also, we're already in ~CycleCollectWithLogsChild (q.v.) at
    // this point, so we shouldn't touch the actor in any case.
    return true;
@@ -8365,7 +8365,7 @@ diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp
  {
    if (aOtherPid == base::GetCurrentProcId() || aOtherPid == OtherPid()) {
      // If we are talking to ourselves, or the UI process, then that is a fatal
-@@ -1331,29 +1331,29 @@ ContentChild::RecvInitRendering(Endpoint
+@@ -1334,29 +1334,29 @@ ContentChild::RecvInitRendering(Endpoint
  
    // Note that for all of the methods below, if it can fail, it should only
    // return false if the failure is an IPDL error. In such situations,
@@ -8399,7 +8399,7 @@ diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp
                                    Endpoint<PImageBridgeChild>&& aImageBridge,
                                    Endpoint<PVRManagerChild>&& aVRBridge,
                                    Endpoint<PVideoDecoderManagerChild>&& aVideoManager,
-@@ -1365,38 +1365,38 @@ ContentChild::RecvReinitRendering(Endpoi
+@@ -1368,38 +1368,38 @@ ContentChild::RecvReinitRendering(Endpoi
    // Zap all the old layer managers we have lying around.
    for (const auto& tabChild : tabs) {
      if (tabChild->GetLayersId().IsValid()) {
@@ -8442,7 +8442,7 @@ diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp
  {
  #ifdef XP_WIN
    audio::AudioNotificationReceiver::NotifyDefaultDeviceChanged();
-@@ -2442,17 +2442,17 @@ ContentChild::RecvUpdateDictionaryList(I
+@@ -2445,17 +2445,17 @@ ContentChild::RecvUpdateDictionaryList(I
    mAvailableDictionaries = aDictionaries;
    mozInlineSpellChecker::UpdateCanEnableInlineSpellChecking();
    return IPC_OK();
@@ -8461,7 +8461,7 @@ diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp
  ContentChild::RecvUpdateAppLocales(nsTArray<nsCString>&& aAppLocales)
  {
    LocaleService::GetInstance()->AssignAppLocales(aAppLocales);
-@@ -3451,17 +3451,17 @@ ContentChild::RecvSetPermissionsWithKey(
+@@ -3454,17 +3454,17 @@ ContentChild::RecvSetPermissionsWithKey(
    permissionManager->SetPermissionsWithKey(aPermissionKey, aPerms);
    return IPC_OK();
  }
@@ -16392,7 +16392,7 @@ diff --git a/dom/messagechannel/MessagePortService.cpp b/dom/messagechannel/Mess
 diff --git a/dom/notification/Notification.cpp b/dom/notification/Notification.cpp
 --- a/dom/notification/Notification.cpp
 +++ b/dom/notification/Notification.cpp
-@@ -109,17 +109,17 @@ public:
+@@ -110,17 +110,17 @@ public:
        nsString(aBody),
        nsString(aTag),
        nsString(aIcon),
@@ -16411,7 +16411,7 @@ diff --git a/dom/notification/Notification.cpp b/dom/notification/Notification.c
  protected:
    virtual ~ScopeCheckingGetCallback()
    {}
-@@ -509,17 +509,17 @@ public:
+@@ -510,17 +510,17 @@ public:
    enum NotificationAction {
      eShow,
      eClose
@@ -16430,7 +16430,7 @@ diff --git a/dom/notification/Notification.cpp b/dom/notification/Notification.c
    virtual ~NotificationTask() {}
  
    UniquePtr<NotificationRef> mNotificationRef;
-@@ -702,17 +702,17 @@ NS_IMPL_ISUPPORTS(NotificationObserver, 
+@@ -703,17 +703,17 @@ NS_IMPL_ISUPPORTS(NotificationObserver, 
  class MainThreadNotificationObserver : public nsIObserver
  {
  public:
@@ -16449,7 +16449,7 @@ diff --git a/dom/notification/Notification.cpp b/dom/notification/Notification.c
    virtual ~MainThreadNotificationObserver()
    {
      AssertIsOnMainThread();
-@@ -1069,17 +1069,17 @@ Notification::GetPrincipal()
+@@ -1053,17 +1053,17 @@ Notification::GetPrincipal()
  
  class WorkerNotificationObserver final : public MainThreadNotificationObserver
  {
@@ -16468,7 +16468,7 @@ diff --git a/dom/notification/Notification.cpp b/dom/notification/Notification.c
    void
    ForgetNotification()
    {
-@@ -1529,20 +1529,20 @@ Notification::ShowInternal()
+@@ -1513,20 +1513,20 @@ Notification::ShowInternal()
    nsCOMPtr<nsIObserver> observer;
    if (mScope.IsEmpty()) {
      // Ownership passed to observer.
@@ -16491,7 +16491,7 @@ diff --git a/dom/notification/Notification.cpp b/dom/notification/Notification.c
      //
      // The observer is wholly owned by the NotificationObserver passed to the alert service.
      nsAutoString behavior;
-@@ -1882,17 +1882,17 @@ class WorkerGetResultRunnable final : pu
+@@ -1866,17 +1866,17 @@ class WorkerGetResultRunnable final : pu
    RefPtr<PromiseWorkerProxy> mPromiseProxy;
    const nsTArray<NotificationStrings> mStrings;
  public:
@@ -16510,7 +16510,7 @@ diff --git a/dom/notification/Notification.cpp b/dom/notification/Notification.c
    {
      RefPtr<Promise> workerPromise = mPromiseProxy->WorkerPromise();
  
-@@ -1948,17 +1948,17 @@ public:
+@@ -1932,17 +1932,17 @@ public:
      MutexAutoLock lock(proxy->Lock());
      if (proxy->CleanedUp()) {
        return NS_OK;
@@ -16529,7 +16529,7 @@ diff --git a/dom/notification/Notification.cpp b/dom/notification/Notification.c
  private:
    ~WorkerGetCallback()
    {}
-@@ -2063,17 +2063,17 @@ Notification::Close()
+@@ -2047,17 +2047,17 @@ Notification::Close()
  {
    AssertIsOnTargetThread();
    auto ref = MakeUnique<NotificationRef>(this);
@@ -16548,7 +16548,7 @@ diff --git a/dom/notification/Notification.cpp b/dom/notification/Notification.c
      // If dispatch fails, NotificationTask will release the ref when it goes
      // out of scope at the end of this function.
    }
-@@ -2511,17 +2511,17 @@ Notification::CreateAndShow(JSContext* a
+@@ -2495,17 +2495,17 @@ Notification::CreateAndShow(JSContext* a
    auto ref = MakeUnique<NotificationRef>(notification);
    if (NS_WARN_IF(!ref->Initialized())) {
      aRv.Throw(NS_ERROR_DOM_ABORT_ERR);
@@ -16567,7 +16567,7 @@ diff --git a/dom/notification/Notification.cpp b/dom/notification/Notification.c
    if (NS_WARN_IF(NS_FAILED(rv))) {
      notification->DispatchTrustedEvent(NS_LITERAL_STRING("error"));
    }
-@@ -2579,23 +2579,23 @@ Notification::Observe(nsISupports* aSubj
+@@ -2563,23 +2563,23 @@ Notification::Observe(nsISupports* aSubj
  
    return NS_OK;
  }
@@ -17811,7 +17811,7 @@ diff --git a/dom/workers/FileReaderSync.cpp b/dom/workers/FileReaderSync.cpp
 diff --git a/dom/workers/RuntimeService.cpp b/dom/workers/RuntimeService.cpp
 --- a/dom/workers/RuntimeService.cpp
 +++ b/dom/workers/RuntimeService.cpp
-@@ -1589,17 +1589,17 @@ RuntimeService::RegisterWorker(WorkerPri
+@@ -1588,17 +1588,17 @@ RuntimeService::RegisterWorker(WorkerPri
             MOZ_CRASH("We should not instantiate a new SharedWorker!");
           }
        }
@@ -18060,7 +18060,7 @@ diff --git a/dom/workers/ServiceWorkerEvents.cpp b/dom/workers/ServiceWorkerEven
 diff --git a/dom/workers/ServiceWorkerManager.cpp b/dom/workers/ServiceWorkerManager.cpp
 --- a/dom/workers/ServiceWorkerManager.cpp
 +++ b/dom/workers/ServiceWorkerManager.cpp
-@@ -319,51 +319,51 @@ ServiceWorkerManager::StartControllingCl
+@@ -320,51 +320,51 @@ ServiceWorkerManager::StartControllingCl
    const ServiceWorkerDescriptor& active =
      aRegistrationInfo->GetActive()->Descriptor();
  
@@ -18202,7 +18202,7 @@ diff --git a/dom/workers/ServiceWorkerScriptCache.cpp b/dom/workers/ServiceWorke
 diff --git a/dom/workers/WorkerPrivate.cpp b/dom/workers/WorkerPrivate.cpp
 --- a/dom/workers/WorkerPrivate.cpp
 +++ b/dom/workers/WorkerPrivate.cpp
-@@ -4712,17 +4712,17 @@ WorkerPrivate::Constructor(JSContext* aC
+@@ -4674,17 +4674,17 @@ WorkerPrivate::Constructor(JSContext* aC
    // WorkerThreadPrimaryRunnable::Run for workers just before running worker
    // code), so this is never SpiderMonkey's builtin default locale.
    JS::UniqueChars defaultLocale = JS_GetDefaultLocale(aCx);
@@ -18221,7 +18221,7 @@ diff --git a/dom/workers/WorkerPrivate.cpp b/dom/workers/WorkerPrivate.cpp
  
    worker->EnableDebugger();
  
-@@ -5261,17 +5261,17 @@ WorkerPrivate::DispatchToMainThread(nsIR
+@@ -5223,17 +5223,17 @@ WorkerPrivate::DispatchToMainThread(nsIR
    nsCOMPtr<nsIRunnable> r = aRunnable;
    return DispatchToMainThread(r.forget(), aFlags);
  }
@@ -18240,7 +18240,7 @@ diff --git a/dom/workers/WorkerPrivate.cpp b/dom/workers/WorkerPrivate.cpp
    return mWorkerControlEventTarget;
  }
  
-@@ -7115,17 +7115,17 @@ WorkerPrivate::GetOrCreateGlobalScope(JS
+@@ -7064,17 +7064,17 @@ WorkerPrivate::GetOrCreateGlobalScope(JS
  
      JS::Rooted<JSObject*> global(aCx);
      NS_ENSURE_TRUE(globalScope->WrapGlobalObject(aCx, &global), nullptr);
@@ -18259,7 +18259,7 @@ diff --git a/dom/workers/WorkerPrivate.cpp b/dom/workers/WorkerPrivate.cpp
  
      JS_FireOnNewGlobalObject(aCx, global);
    }
-@@ -7146,17 +7146,17 @@ WorkerPrivate::CreateDebuggerGlobalScope
+@@ -7095,17 +7095,17 @@ WorkerPrivate::CreateDebuggerGlobalScope
    JS::Rooted<JSObject*> global(aCx);
    NS_ENSURE_TRUE(globalScope->WrapGlobalObject(aCx, &global), nullptr);
  
@@ -18300,7 +18300,7 @@ diff --git a/dom/workers/WorkerPrivate.h b/dom/workers/WorkerPrivate.h
    nsresult
    DispatchDebuggerRunnable(already_AddRefed<WorkerRunnable> aDebuggerRunnable);
  
-@@ -1170,17 +1170,17 @@ public:
+@@ -1166,17 +1166,17 @@ public:
    }
  
    JS::UniqueChars
@@ -18385,7 +18385,7 @@ diff --git a/dom/workers/WorkerRunnable.h b/dom/workers/WorkerRunnable.h
 diff --git a/dom/workers/WorkerScope.cpp b/dom/workers/WorkerScope.cpp
 --- a/dom/workers/WorkerScope.cpp
 +++ b/dom/workers/WorkerScope.cpp
-@@ -493,17 +493,17 @@ WorkerGlobalScope::CreateImageBitmap(JSC
+@@ -494,17 +494,17 @@ WorkerGlobalScope::CreateImageBitmap(JSC
      return nullptr;
    }
  }
@@ -18404,7 +18404,7 @@ diff --git a/dom/workers/WorkerScope.cpp b/dom/workers/WorkerScope.cpp
  {
    return mSerialEventTarget;
  }
-@@ -1072,17 +1072,17 @@ WorkerDebuggerGlobalScope::Dump(JSContex
+@@ -1073,17 +1073,17 @@ WorkerDebuggerGlobalScope::Dump(JSContex
      scope->Dump(aString);
    }
  }
@@ -40359,7 +40359,7 @@ diff --git a/js/xpconnect/loader/URLPreloader.cpp b/js/xpconnect/loader/URLPrelo
 diff --git a/js/xpconnect/loader/mozJSComponentLoader.cpp b/js/xpconnect/loader/mozJSComponentLoader.cpp
 --- a/js/xpconnect/loader/mozJSComponentLoader.cpp
 +++ b/js/xpconnect/loader/mozJSComponentLoader.cpp
-@@ -278,17 +278,17 @@ ReportOnCallerUTF8(JSCLContextHelper& he
+@@ -279,17 +279,17 @@ ReportOnCallerUTF8(JSCLContextHelper& he
      nsCString location;
      MOZ_TRY(info.GetLocation(location));
  
@@ -40378,7 +40378,7 @@ diff --git a/js/xpconnect/loader/mozJSComponentLoader.cpp b/js/xpconnect/loader/
  #undef ENSURE_DEP
  
  mozJSComponentLoader::~mozJSComponentLoader()
-@@ -1428,10 +1428,10 @@ JSCLContextHelper::~JSCLContextHelper()
+@@ -1429,10 +1429,10 @@ JSCLContextHelper::~JSCLContextHelper()
          JS_ReportErrorUTF8(mContext, "%s", mBuf.get());
      }
  }

+ 0 - 0
frg/work-js/mozilla-release/patches/mozilla-central-push_429868.patch → frg/work-js/mozilla-release/patches/1469965-63a1.patch


+ 0 - 0
frg/work-js/mozilla-release/patches/mozilla-central-push_429713.patch → frg/work-js/mozilla-release/patches/1473523-1-63a1.patch


+ 0 - 0
frg/work-js/mozilla-release/patches/mozilla-central-push_429714.patch → frg/work-js/mozilla-release/patches/1473523-2-63a1.patch


+ 0 - 0
frg/work-js/mozilla-release/patches/mozilla-central-push_429869.patch → frg/work-js/mozilla-release/patches/1475446-63a1.patch


+ 0 - 0
frg/work-js/mozilla-release/patches/mozilla-central-push_429953.patch → frg/work-js/mozilla-release/patches/1476417-63a1.patch


+ 0 - 0
frg/work-js/mozilla-release/patches/mozilla-central-push_429452.patch → frg/work-js/mozilla-release/patches/1478126-63a1.patch


+ 1 - 1
frg/work-js/mozilla-release/patches/mozilla-central-push_429582.patch → frg/work-js/mozilla-release/patches/1478393-1-63a1.patch

@@ -1,5 +1,5 @@
 # HG changeset patch
-# User Naz?m Can Alt?nova <canaltinova@gmail.com>
+# User Nazim Can Altinova <canaltinova@gmail.com>
 # Date 1532531940 -7200
 #      Wed Jul 25 17:19:00 2018 +0200
 # Node ID c36fc94df388acc54e49df55fd739cdf67b5b972

+ 1 - 1
frg/work-js/mozilla-release/patches/mozilla-central-push_429583.patch → frg/work-js/mozilla-release/patches/1478393-2-63a1.patch

@@ -1,5 +1,5 @@
 # HG changeset patch
-# User Naz?m Can Alt?nova <canaltinova@gmail.com>
+# User Nazim Can Altinova <canaltinova@gmail.com>
 # Date 1533117206 -7200
 #      Wed Aug 01 11:53:26 2018 +0200
 # Node ID 75ef4a9cbc00c98eba433eb8549a30961d47f5d7

+ 48 - 76
frg/work-js/mozilla-release/patches/mozilla-central-push_429392.patch → frg/work-js/mozilla-release/patches/1478404-63a1.patch

@@ -3,7 +3,7 @@
 # Date 1533058765 0
 #      Tue Jul 31 17:39:25 2018 +0000
 # Node ID 6499bc583b573f7d4eefc3a2f1692226ce17ec60
-# Parent  cfc3d5482f79786f4726be893e5fc241a25a9994
+# Parent  e1341c0221bb0ff4fdb1f1e0434e0b7a510d7d83
 Bug 1478404 - remove _xpcom_categories annotations as they're dead code, r=florian
 
 Support for the _xpcom_categories property was removed in Bug 568691,
@@ -15,100 +15,51 @@ Differential Revision: https://phabricator.services.mozilla.com/D2429
 diff --git a/browser/components/feeds/WebContentConverter.js b/browser/components/feeds/WebContentConverter.js
 --- a/browser/components/feeds/WebContentConverter.js
 +++ b/browser/components/feeds/WebContentConverter.js
-@@ -303,38 +303,22 @@ WebContentConverterRegistrar.prototype =
-    */
-   _getBrowserForContentWindow(aBrowserWindow, aContentWindow) {
-     // This depends on pseudo APIs of browser.js and tabbrowser.xml
-     aContentWindow = aContentWindow.top;
-     return aBrowserWindow.gBrowser.browsers.find((browser) =>
-       browser.contentWindow == aContentWindow);
-   },
- 
--  /**
--   * See nsIFactory
--   */
--  createInstance(outer, iid) {
--    if (outer != null)
--      throw Cr.NS_ERROR_NO_AGGREGATION;
--    return this.QueryInterface(iid);
--  },
--
-   classID: WCCR_CLASSID,
- 
+@@ -865,21 +865,16 @@ WebContentConverterRegistrar.prototype =
    /**
     * See nsISupports
     */
--  QueryInterface: ChromeUtils.generateQI(
--     [Ci.nsIWebContentHandlerRegistrar,
--      Ci.nsIFactory]),
+   QueryInterface: XPCOMUtils.generateQI(
+      [Ci.nsIWebContentConverterService,
+       Ci.nsIWebContentHandlerRegistrar,
+       Ci.nsIObserver,
+       Ci.nsIFactory]),
 -
 -  _xpcom_categories: [{
 -    category: "app-startup",
 -    service: true
 -  }]
-+  QueryInterface: ChromeUtils.generateQI([Ci.nsIWebContentHandlerRegistrar]),
  };
  
  function WebContentConverterRegistrarContent() {
+   this._contentTypes = {};
  }
  
  WebContentConverterRegistrarContent.prototype = {
-   registerProtocolHandler(aProtocol, aURIString, aTitle, aBrowserOrWindow) {
-     aProtocol = (aProtocol || "").toLowerCase();
-@@ -350,31 +334,20 @@ WebContentConverterRegistrarContent.prot
-     Utils.checkProtocolHandlerAllowed(aProtocol, aURIString, aBrowserOrWindow);
- 
-     messageManager.sendAsyncMessage("WCCR:registerProtocolHandler",
-                                     { protocol: aProtocol,
-                                       uri: uri.spec,
-                                       title: aTitle });
-   },
  
--  /**
--   * See nsIFactory
--   */
--  createInstance(outer, iid) {
--    if (outer != null)
--      throw Cr.NS_ERROR_NO_AGGREGATION;
--    return this.QueryInterface(iid);
--  },
--
-   classID: WCCR_CLASSID,
- 
-   /**
-    * See nsISupports
-    */
--  QueryInterface: ChromeUtils.generateQI(
--                     [Ci.nsIWebContentHandlerRegistrar,
--                      Ci.nsIFactory])
-+  QueryInterface: ChromeUtils.generateQI([Ci.nsIWebContentHandlerRegistrar])
- };
- 
- this.NSGetFactory =
-   (Services.appinfo.processType === Services.appinfo.PROCESS_TYPE_CONTENT) ?
-     XPCOMUtils.generateNSGetFactory([WebContentConverterRegistrarContent]) :
-     XPCOMUtils.generateNSGetFactory([WebContentConverterRegistrar]);
 diff --git a/browser/components/newtab/aboutNewTabService.js b/browser/components/newtab/aboutNewTabService.js
 --- a/browser/components/newtab/aboutNewTabService.js
 +++ b/browser/components/newtab/aboutNewTabService.js
-@@ -97,17 +97,16 @@ AboutNewTabService.prototype = {
+@@ -62,19 +62,16 @@ function AboutNewTabService() {
+ AboutNewTabService.prototype = {
+ 
+   _newTabURL: ABOUT_URL,
+   _activityStreamEnabled: false,
    _overridden: false,
-   willNotifyUser: false,
  
    classID: Components.ID("{dfcd2adc-7867-4d3a-ba70-17501f208142}"),
-   QueryInterface: ChromeUtils.generateQI([
-     Ci.nsIAboutNewTabService,
-     Ci.nsIObserver
-   ]),
--  _xpcom_categories: [{service: true}],
- 
-   observe(subject, topic, data) {
-     switch (topic) {
-       case "nsPref:changed":
-         if (data === PREF_SEPARATE_PRIVILEGED_CONTENT_PROCESS) {
-           this._privilegedContentProcess = Services.prefs.getBoolPref(PREF_SEPARATE_PRIVILEGED_CONTENT_PROCESS);
-         } else if (data === PREF_ACTIVITY_STREAM_PRERENDER_ENABLED) {
-           this._activityStreamPrerender = Services.prefs.getBoolPref(PREF_ACTIVITY_STREAM_PRERENDER_ENABLED);
+   QueryInterface: XPCOMUtils.generateQI([Ci.nsIAboutNewTabService]),
+-  _xpcom_categories: [{
+-    service: true
+-  }],
+ 
+   _handleToggleEvent(stateEnabled) {
+     if (this.toggleActivityStream(stateEnabled)) {
+       Services.obs.notifyObservers(null, "newtab-url-changed", ABOUT_URL);
+     }
+   },
+ 
+   /**
 diff --git a/js/xpconnect/loader/XPCOMUtils.jsm b/js/xpconnect/loader/XPCOMUtils.jsm
 --- a/js/xpconnect/loader/XPCOMUtils.jsm
 +++ b/js/xpconnect/loader/XPCOMUtils.jsm
@@ -154,7 +105,7 @@ diff --git a/js/xpconnect/loader/XPCOMUtils.jsm b/js/xpconnect/loader/XPCOMUtils
 diff --git a/testing/marionette/components/marionette.js b/testing/marionette/components/marionette.js
 --- a/testing/marionette/components/marionette.js
 +++ b/testing/marionette/components/marionette.js
-@@ -527,21 +527,15 @@ const MarionetteFactory = {
+@@ -612,21 +612,15 @@ const MarionetteFactory = {
  
  function Marionette() {}
  
@@ -188,7 +139,7 @@ diff --git a/toolkit/components/thumbnails/PageThumbsStorageService.js b/toolkit
  
  PageThumbsStorageService.prototype = {
      classID: Components.ID("{97943eec-0e48-49ef-b7b7-cf4aa0109bb6}"),
-     QueryInterface: ChromeUtils.generateQI([Ci.nsIPageThumbsStorageService]),
+     QueryInterface: XPCOMUtils.generateQI([Ci.nsIPageThumbsStorageService]),
 -    _xpcom_categories: [{
 -      service: true
 -    }],
@@ -233,3 +184,24 @@ diff --git a/toolkit/components/timermanager/nsIUpdateTimerManager.idl b/toolkit
     *   preference : the preference to for timer interval. This value can be
     *                optional by specifying an empty string for the value.
     *   interval   : the default interval in seconds for the timer.
+diff --git a/tools/quitter/QuitterObserver.js b/tools/quitter/QuitterObserver.js
+--- a/tools/quitter/QuitterObserver.js
++++ b/tools/quitter/QuitterObserver.js
+@@ -10,17 +10,16 @@ const CHILD_SCRIPT = "chrome://quitter/c
+ /* XPCOM gunk */
+ function QuitterObserver() {}
+ 
+ QuitterObserver.prototype = {
+   classDescription: "Quitter Observer for use in testing.",
+   classID:          Components.ID("{c235a986-5ac1-4f28-ad73-825dae9bad90}"),
+   contractID:       "@mozilla.org/quitter-observer;1",
+   QueryInterface:   XPCOMUtils.generateQI([Ci.nsIObserver]),
+-  _xpcom_categories: [{category: "profile-after-change", service: true }],
+   isFrameScriptLoaded: false,
+ 
+   observe(aSubject, aTopic, aData) {
+     if (aTopic == "profile-after-change") {
+       this.init();
+     } else if (!this.isFrameScriptLoaded &&
+                aTopic == "chrome-document-global-created") {
+ 

+ 0 - 0
frg/work-js/mozilla-release/patches/mozilla-central-push_429552.patch → frg/work-js/mozilla-release/patches/1478854-63a1.patch


+ 0 - 0
frg/work-js/mozilla-release/patches/mozilla-central-push_429832.patch → frg/work-js/mozilla-release/patches/1478879-1-63a1.patch


+ 449 - 0
frg/work-js/mozilla-release/patches/1478879-2-63a1.patch

@@ -0,0 +1,449 @@
+# HG changeset patch
+# User Nicholas Nethercote <nnethercote@mozilla.com>
+# Date 1532657857 -36000
+#      Fri Jul 27 12:17:37 2018 +1000
+# Node ID 1e45ce266b665543f4388b96cd2a2ccc15359bda
+# Parent  591d08c5c22b1286579a216f0dc2c462cb5679fc
+Bug 1478879 - Introduce Iterator and ModIterator in HashTable.h. r=luke
+
+These basically duplicate the existing Range and Enum classes, but use more
+familiar terminology, similar to the iterators we have for
+PLDHashTable/nsTHashtable:
+
+- Hash{Set,Map}::all()  Hash{Set,Map}::iter()
+- Enum constructor      Hash{Set,Map}::modIter()
+- Range::front()        Iterator::get()
+- Range::popFront()     Iterator::next()
+- Range::empty()        Iterator::done()
+- Enum::mutableFront()  ModIterator::getMutable()
+- Enum::removeFront()   ModIterator::remove()
+- Enum::rekeyFront()    ModIterator::rekey()
+
+The next patch will reduce the amount of code duplication.
+
+diff --git a/mfbt/HashTable.h b/mfbt/HashTable.h
+--- a/mfbt/HashTable.h
++++ b/mfbt/HashTable.h
+@@ -223,42 +223,46 @@ public:
+                                   ValueInput&& aValue)
+   {
+     return mImpl.relookupOrAdd(aPtr,
+                                aKey,
+                                std::forward<KeyInput>(aKey),
+                                std::forward<ValueInput>(aValue));
+   }
+ 
+-  // |all()| returns a Range containing |count()| elements. E.g.:
++  // |iter()| returns an Iterator:
+   //
+-  //   using HM = HashMap<int,char>;
+-  //   HM h;
+-  //   for (HM::Range r = h.all(); !r.empty(); r.popFront()) {
+-  //     char c = r.front().value();
++  //   HashMap<int, char> h;
++  //   for (auto iter = h.iter(); !iter.done(); iter.next()) {
++  //     char c = iter.get().value();
+   //   }
+   //
+-  // Also see the definition of Range in HashTable above (with T = Entry).
+-  using Range = typename Impl::Range;
+-  Range all() const { return mImpl.all(); }
++  // Also see the definition of Iterator in HashTable above (with T = Entry).
++  using Iterator = typename Impl::Iterator;
++  Iterator iter() const { return mImpl.iter(); }
+ 
+-  // Typedef for the enumeration class. An Enum may be used to examine and
+-  // remove table entries:
++  // |modIter()| returns a ModIterator:
+   //
+-  //   using HM = HashMap<int,char>;
+-  //   HM s;
+-  //   for (HM::Enum e(s); !e.empty(); e.popFront()) {
+-  //     if (e.front().value() == 'l') {
+-  //       e.removeFront();
++  //   HashMap<int, char> h;
++  //   for (auto iter = h.modIter(); !iter.done(); iter.next()) {
++  //     if (iter.get().value() == 'l') {
++  //       iter.remove();
+   //     }
+   //   }
+   //
+-  // Table resize may occur in Enum's destructor. Also see the definition of
+-  // Enum in HashTable above (with T = Entry).
++  // Table resize may occur in ModIterator's destructor. Also see the
++  // definition of ModIterator in HashTable above (with T = Entry).
++  using ModIterator = typename Impl::ModIterator;
++  ModIterator modIter() { return mImpl.modIter(); }
++
++  // These are similar to Iterator/ModIterator/iter(), but use less common
++  // terminology.
++  using Range = typename Impl::Range;
+   using Enum = typename Impl::Enum;
++  Range all() const { return mImpl.all(); }
+ 
+   // Remove all entries. This does not shrink the table. For that consider
+   // using the finish() method.
+   void clear() { mImpl.clear(); }
+ 
+   // Remove all entries. Unlike clear() this method tries to shrink the table.
+   // Unlike finish() it does not require the map to be initialized again.
+   void clearAndShrink() { mImpl.clearAndShrink(); }
+@@ -512,42 +516,46 @@ public:
+   }
+ 
+   template<typename U>
+   MOZ_MUST_USE bool relookupOrAdd(AddPtr& aPtr, const Lookup& aLookup, U&& aU)
+   {
+     return mImpl.relookupOrAdd(aPtr, aLookup, std::forward<U>(aU));
+   }
+ 
+-  // |all()| returns a Range containing |count()| elements:
++  // |iter()| returns an Iterator:
+   //
+-  //   using HS = HashSet<int>;
+-  //   HS h;
+-  //   for (HS::Range r = h.all(); !r.empty(); r.popFront()) {
+-  //     int i = r.front();
++  //   HashSet<int> h;
++  //   for (auto iter = h.iter(); !iter.done(); iter.next()) {
++  //     int i = iter.get();
+   //   }
+   //
+-  // Also see the definition of Range in HashTable above.
+-  using Range = typename Impl::Range;
+-  Range all() const { return mImpl.all(); }
++  // Also see the definition of Iterator in HashTable above.
++  typedef typename Impl::Iterator Iterator;
++  Iterator iter() const { return mImpl.iter(); }
+ 
+-  // Typedef for the enumeration class. An Enum may be used to examine and
+-  // remove table entries:
++  // |modIter()| returns a ModIterator:
+   //
+-  //   using HS = HashSet<int>;
+-  //   HS s;
+-  //   for (HS::Enum e(s); !e.empty(); e.popFront()) {
+-  //     if (e.front() == 42) {
+-  //       e.removeFront();
++  //   HashSet<int> h;
++  //   for (auto iter = h.modIter(); !iter.done(); iter.next()) {
++  //     if (iter.get() == 42) {
++  //       iter.remove();
+   //     }
+   //   }
+   //
+-  // Table resize may occur in Enum's destructor. Also see the definition of
+-  // Enum in HashTable above.
++  // Table resize may occur in ModIterator's destructor. Also see the
++  // definition of ModIterator in HashTable above.
++  typedef typename Impl::ModIterator ModIterator;
++  ModIterator modIter() { return mImpl.modIter(); }
++
++  // These are similar to Iterator/ModIterator/iter(), but use different
++  // terminology.
++  using Range = typename Impl::Range;
+   using Enum = typename Impl::Enum;
++  Range all() const { return mImpl.all(); }
+ 
+   // Remove all entries. This does not shrink the table. For that consider
+   // using the finish() method.
+   void clear() { mImpl.clear(); }
+ 
+   // Remove all entries. Unlike clear() this method tries to shrink the table.
+   // Unlike finish() it does not require the set to be initialized again.
+   void clearAndShrink() { mImpl.clearAndShrink(); }
+@@ -1190,20 +1198,177 @@ public:
+ 
+   public:
+     AddPtr()
+       : mKeyHash(0)
+     {
+     }
+   };
+ 
+-  // A collection of hash table entries. The collection is enumerated by
+-  // calling |front()| followed by |popFront()| as long as |!empty()|. As
+-  // with Ptr/AddPtr, Range objects must not be used after any mutating hash
+-  // table operation unless the |generation()| is tested.
++  // A hash table iterator that (mostly) doesn't allow table modifications.
++  // As with Ptr/AddPtr, Iterator objects must not be used after any mutating
++  // hash table operation unless the |generation()| is tested.
++  class Iterator
++  {
++  protected:
++    friend class HashTable;
++
++    explicit Iterator(const HashTable& aTable)
++      : mCur(aTable.mTable)
++      , mEnd(aTable.mTable + aTable.capacity())
++#ifdef DEBUG
++      , mTable(aTable)
++      , mMutationCount(aTable.mMutationCount)
++      , mGeneration(aTable.generation())
++      , mValidEntry(true)
++#endif
++    {
++      while (mCur < mEnd && !mCur->isLive()) {
++        ++mCur;
++      }
++    }
++
++    Entry* mCur;
++    Entry* mEnd;
++#ifdef DEBUG
++    const HashTable& mTable;
++    uint64_t mMutationCount;
++    Generation mGeneration;
++    bool mValidEntry;
++#endif
++
++  public:
++    bool done() const
++    {
++#ifdef DEBUG
++      MOZ_ASSERT(mGeneration == mTable.generation());
++      MOZ_ASSERT(mMutationCount == mTable.mMutationCount);
++#endif
++      return mCur == mEnd;
++    }
++
++    T& get() const
++    {
++      MOZ_ASSERT(!done());
++#ifdef DEBUG
++      MOZ_ASSERT(mValidEntry);
++      MOZ_ASSERT(mGeneration == mTable.generation());
++      MOZ_ASSERT(mMutationCount == mTable.mMutationCount);
++#endif
++      return mCur->get();
++    }
++
++    void next()
++    {
++      MOZ_ASSERT(!done());
++#ifdef DEBUG
++      MOZ_ASSERT(mGeneration == mTable.generation());
++      MOZ_ASSERT(mMutationCount == mTable.mMutationCount);
++#endif
++      while (++mCur < mEnd && !mCur->isLive()) {
++        continue;
++      }
++#ifdef DEBUG
++      mValidEntry = true;
++#endif
++    }
++  };
++
++  // A hash table iterator that permits modification, removal and rekeying.
++  // Since rehashing when elements were removed during enumeration would be
++  // bad, it is postponed until the ModIterator is destructed. Since the
++  // ModIterator's destructor touches the hash table, the user must ensure
++  // that the hash table is still alive when the destructor runs.
++  class ModIterator : public Iterator
++  {
++    friend class HashTable;
++
++    HashTable& mTable;
++    bool mRekeyed;
++    bool mRemoved;
++
++    // ModIterator is movable but not copyable.
++    ModIterator(const ModIterator&) = delete;
++    void operator=(const ModIterator&) = delete;
++
++  protected:
++    explicit ModIterator(HashTable& aTable)
++      : Iterator(aTable)
++      , mTable(aTable)
++      , mRekeyed(false)
++      , mRemoved(false)
++    {
++    }
++
++  public:
++    MOZ_IMPLICIT ModIterator(ModIterator&& aOther)
++      : Iterator(aOther)
++      , mTable(aOther.mTable)
++      , mRekeyed(aOther.mRekeyed)
++      , mRemoved(aOther.mRemoved)
++    {
++      aOther.mRekeyed = false;
++      aOther.mRemoved = false;
++    }
++
++    // Removes the current element from the table, leaving |get()|
++    // invalid until the next call to |next()|.
++    void remove()
++    {
++      mTable.remove(*this->mCur);
++      mRemoved = true;
++#ifdef DEBUG
++      this->mValidEntry = false;
++      this->mMutationCount = mTable.mMutationCount;
++#endif
++    }
++
++    NonConstT& getMutable()
++    {
++      MOZ_ASSERT(!this->done());
++#ifdef DEBUG
++      MOZ_ASSERT(this->mValidEntry);
++      MOZ_ASSERT(this->mGeneration == this->Iterator::mTable.generation());
++      MOZ_ASSERT(this->mMutationCount == this->Iterator::mTable.mMutationCount);
++#endif
++      return this->mCur->getMutable();
++    }
++
++    // Removes the current element and re-inserts it into the table with
++    // a new key at the new Lookup position.  |get()| is invalid after
++    // this operation until the next call to |next()|.
++    void rekey(const Lookup& l, const Key& k)
++    {
++      MOZ_ASSERT(&k != &HashPolicy::getKey(this->mCur->get()));
++      Ptr p(*this->mCur, mTable);
++      mTable.rekeyWithoutRehash(p, l, k);
++      mRekeyed = true;
++#ifdef DEBUG
++      this->mValidEntry = false;
++      this->mMutationCount = mTable.mMutationCount;
++#endif
++    }
++
++    void rekey(const Key& k) { rekey(k, k); }
++
++    // Potentially rehashes the table.
++    ~ModIterator()
++    {
++      if (mRekeyed) {
++        mTable.mGen++;
++        mTable.checkOverRemoved();
++      }
++
++      if (mRemoved) {
++        mTable.compactIfUnderloaded();
++      }
++    }
++  };
++
++  // Range is similar to Iterator, but uses different terminology.
+   class Range
+   {
+   protected:
+     friend class HashTable;
+ 
+     Range(const HashTable& aTable, Entry* aCur, Entry* aEnd)
+       : mCur(aCur)
+       , mEnd(aEnd)
+@@ -1260,21 +1425,17 @@ public:
+         continue;
+       }
+ #ifdef DEBUG
+       mValidEntry = true;
+ #endif
+     }
+   };
+ 
+-  // A Range whose lifetime delimits a mutating enumeration of a hash table.
+-  // Since rehashing when elements were removed during enumeration would be
+-  // bad, it is postponed until the Enum is destructed.  Since the Enum's
+-  // destructor touches the hash table, the user must ensure that the hash
+-  // table is still alive when the destructor runs.
++  // Enum is similar to ModIterator, but uses different terminology.
+   class Enum : public Range
+   {
+     friend class HashTable;
+ 
+     HashTable& mTable;
+     bool mRekeyed;
+     bool mRemoved;
+ 
+@@ -1297,25 +1458,16 @@ public:
+       , mTable(aOther.mTable)
+       , mRekeyed(aOther.mRekeyed)
+       , mRemoved(aOther.mRemoved)
+     {
+       aOther.mRekeyed = false;
+       aOther.mRemoved = false;
+     }
+ 
+-    // Removes the |front()| element from the table, leaving |front()|
+-    // invalid until the next call to |popFront()|. For example:
+-    //
+-    //   HashSet<int> s;
+-    //   for (HashSet<int>::Enum e(s); !e.empty(); e.popFront()) {
+-    //     if (e.front() == 42) {
+-    //       e.removeFront();
+-    //     }
+-    //   }
+     void removeFront()
+     {
+       mTable.remove(*this->mCur);
+       mRemoved = true;
+ #ifdef DEBUG
+       this->mValidEntry = false;
+       this->mMutationCount = mTable.mMutationCount;
+ #endif
+@@ -1327,34 +1479,30 @@ public:
+ #ifdef DEBUG
+       MOZ_ASSERT(this->mValidEntry);
+       MOZ_ASSERT(this->mGeneration == this->Range::mTable.generation());
+       MOZ_ASSERT(this->mMutationCount == this->Range::mTable.mMutationCount);
+ #endif
+       return this->mCur->getMutable();
+     }
+ 
+-    // Removes the |front()| element and re-inserts it into the table with
+-    // a new key at the new Lookup position.  |front()| is invalid after
+-    // this operation until the next call to |popFront()|.
+     void rekeyFront(const Lookup& aLookup, const Key& aKey)
+     {
+       MOZ_ASSERT(&aKey != &HashPolicy::getKey(this->mCur->get()));
+       Ptr p(*this->mCur, mTable);
+       mTable.rekeyWithoutRehash(p, aLookup, aKey);
+       mRekeyed = true;
+ #ifdef DEBUG
+       this->mValidEntry = false;
+       this->mMutationCount = mTable.mMutationCount;
+ #endif
+     }
+ 
+     void rekeyFront(const Key& aKey) { rekeyFront(aKey, aKey); }
+ 
+-    // Potentially rehashes the table.
+     ~Enum()
+     {
+       if (mRekeyed) {
+         mTable.mGen++;
+         mTable.checkOverRemoved();
+       }
+ 
+       if (mRemoved) {
+@@ -1949,16 +2097,28 @@ public:
+     mGen++;
+     mEntryCount = 0;
+     mRemovedCount = 0;
+ #ifdef DEBUG
+     mMutationCount++;
+ #endif
+   }
+ 
++  Iterator iter() const
++  {
++    MOZ_ASSERT(mTable);
++    return Iterator(*this);
++  }
++
++  ModIterator modIter()
++  {
++    MOZ_ASSERT(mTable);
++    return ModIterator(*this);
++  }
++
+   Range all() const
+   {
+     MOZ_ASSERT(mTable);
+     return Range(*this, mTable, mTable + capacity());
+   }
+ 
+   bool empty() const
+   {

+ 217 - 0
frg/work-js/mozilla-release/patches/1478879-3-63a1.patch

@@ -0,0 +1,217 @@
+# HG changeset patch
+# User Nicholas Nethercote <nnethercote@mozilla.com>
+# Date 1532996583 -36000
+#      Tue Jul 31 10:23:03 2018 +1000
+# Node ID 2c3b5f4eda625adf917db7402bc1d655d1c1e3bc
+# Parent  1e45ce266b665543f4388b96cd2a2ccc15359bda
+Bug 1478879 - Define Range/Enum in terms of Iterator/ModIterator. r=luke
+
+To reduce the code duplication.
+
+diff --git a/mfbt/HashTable.h b/mfbt/HashTable.h
+--- a/mfbt/HashTable.h
++++ b/mfbt/HashTable.h
+@@ -1361,159 +1361,71 @@ public:
+         mTable.compactIfUnderloaded();
+       }
+     }
+   };
+ 
+   // Range is similar to Iterator, but uses different terminology.
+   class Range
+   {
+-  protected:
+     friend class HashTable;
+ 
+-    Range(const HashTable& aTable, Entry* aCur, Entry* aEnd)
+-      : mCur(aCur)
+-      , mEnd(aEnd)
+-#ifdef DEBUG
+-      , mTable(aTable)
+-      , mMutationCount(aTable.mMutationCount)
+-      , mGeneration(aTable.generation())
+-      , mValidEntry(true)
+-#endif
++    Iterator mIter;
++
++  protected:
++    explicit Range(const HashTable& table)
++      : mIter(table)
+     {
+-      while (mCur < mEnd && !mCur->isLive()) {
+-        ++mCur;
+-      }
+     }
+ 
+-    Entry* mCur;
+-    Entry* mEnd;
+-#ifdef DEBUG
+-    const HashTable& mTable;
+-    uint64_t mMutationCount;
+-    Generation mGeneration;
+-    bool mValidEntry;
+-#endif
+-
+   public:
+-    bool empty() const
+-    {
+-#ifdef DEBUG
+-      MOZ_ASSERT(mGeneration == mTable.generation());
+-      MOZ_ASSERT(mMutationCount == mTable.mMutationCount);
+-#endif
+-      return mCur == mEnd;
+-    }
++    bool empty() const { return mIter.done(); }
+ 
+-    T& front() const
+-    {
+-      MOZ_ASSERT(!empty());
+-#ifdef DEBUG
+-      MOZ_ASSERT(mValidEntry);
+-      MOZ_ASSERT(mGeneration == mTable.generation());
+-      MOZ_ASSERT(mMutationCount == mTable.mMutationCount);
+-#endif
+-      return mCur->get();
+-    }
++    T& front() const { return mIter.get(); }
+ 
+-    void popFront()
+-    {
+-      MOZ_ASSERT(!empty());
+-#ifdef DEBUG
+-      MOZ_ASSERT(mGeneration == mTable.generation());
+-      MOZ_ASSERT(mMutationCount == mTable.mMutationCount);
+-#endif
+-      while (++mCur < mEnd && !mCur->isLive()) {
+-        continue;
+-      }
+-#ifdef DEBUG
+-      mValidEntry = true;
+-#endif
+-    }
++    void popFront() { return mIter.next(); }
+   };
+ 
+   // Enum is similar to ModIterator, but uses different terminology.
+-  class Enum : public Range
++  class Enum
+   {
+-    friend class HashTable;
+-
+-    HashTable& mTable;
+-    bool mRekeyed;
+-    bool mRemoved;
++    ModIterator mIter;
+ 
+     // Enum is movable but not copyable.
+     Enum(const Enum&) = delete;
+     void operator=(const Enum&) = delete;
+ 
+   public:
+     template<class Map>
+     explicit Enum(Map& map)
+-      : Range(map.all())
+-      , mTable(map.mImpl)
+-      , mRekeyed(false)
+-      , mRemoved(false)
++      : mIter(map.mImpl)
++    {
++    }
++
++    MOZ_IMPLICIT Enum(Enum&& other)
++      : mIter(std::move(other.mIter))
+     {
+     }
+ 
+-    MOZ_IMPLICIT Enum(Enum&& aOther)
+-      : Range(aOther)
+-      , mTable(aOther.mTable)
+-      , mRekeyed(aOther.mRekeyed)
+-      , mRemoved(aOther.mRemoved)
+-    {
+-      aOther.mRekeyed = false;
+-      aOther.mRemoved = false;
+-    }
++    bool empty() const { return mIter.done(); }
++
++    T& front() const { return mIter.get(); }
+ 
+-    void removeFront()
+-    {
+-      mTable.remove(*this->mCur);
+-      mRemoved = true;
+-#ifdef DEBUG
+-      this->mValidEntry = false;
+-      this->mMutationCount = mTable.mMutationCount;
+-#endif
+-    }
++    void popFront() { return mIter.next(); }
+ 
+-    NonConstT& mutableFront()
+-    {
+-      MOZ_ASSERT(!this->empty());
+-#ifdef DEBUG
+-      MOZ_ASSERT(this->mValidEntry);
+-      MOZ_ASSERT(this->mGeneration == this->Range::mTable.generation());
+-      MOZ_ASSERT(this->mMutationCount == this->Range::mTable.mMutationCount);
+-#endif
+-      return this->mCur->getMutable();
+-    }
++    void removeFront() { mIter.remove(); }
++
++    NonConstT& mutableFront() { return mIter.getMutable(); }
+ 
+     void rekeyFront(const Lookup& aLookup, const Key& aKey)
+     {
+-      MOZ_ASSERT(&aKey != &HashPolicy::getKey(this->mCur->get()));
+-      Ptr p(*this->mCur, mTable);
+-      mTable.rekeyWithoutRehash(p, aLookup, aKey);
+-      mRekeyed = true;
+-#ifdef DEBUG
+-      this->mValidEntry = false;
+-      this->mMutationCount = mTable.mMutationCount;
+-#endif
++      mIter.rekey(aLookup, aKey);
+     }
+ 
+-    void rekeyFront(const Key& aKey) { rekeyFront(aKey, aKey); }
+-
+-    ~Enum()
+-    {
+-      if (mRekeyed) {
+-        mTable.mGen++;
+-        mTable.checkOverRemoved();
+-      }
+-
+-      if (mRemoved) {
+-        mTable.compactIfUnderloaded();
+-      }
+-    }
++    void rekeyFront(const Key& aKey) { mIter.rekey(aKey); }
+   };
+ 
+   // HashTable is movable
+   HashTable(HashTable&& aRhs)
+     : AllocPolicy(aRhs)
+   {
+     PodAssign(this, &aRhs);
+     aRhs.mTable = nullptr;
+@@ -2112,17 +2024,17 @@ public:
+   {
+     MOZ_ASSERT(mTable);
+     return ModIterator(*this);
+   }
+ 
+   Range all() const
+   {
+     MOZ_ASSERT(mTable);
+-    return Range(*this, mTable, mTable + capacity());
++    return Range(*this);
+   }
+ 
+   bool empty() const
+   {
+     MOZ_ASSERT(mTable);
+     return !mEntryCount;
+   }
+ 

+ 0 - 0
frg/work-js/mozilla-release/patches/mozilla-central-push_429835.patch → frg/work-js/mozilla-release/patches/1478879-4-63a1.patch


+ 229 - 0
frg/work-js/mozilla-release/patches/1478879-5-63a1.patch

@@ -0,0 +1,229 @@
+# HG changeset patch
+# User Nicholas Nethercote <nnethercote@mozilla.com>
+# Date 1532658061 -36000
+#      Fri Jul 27 12:21:01 2018 +1000
+# Node ID 41aeecb74b977130919801900c21b18c19e94258
+# Parent  3bd2221b034d4a57fd97df85fc64a60c5ba3478b
+Bug 1478879 - Remove Range/Enum use in DMD. r=mccr8
+
+diff --git a/memory/replace/dmd/DMD.cpp b/memory/replace/dmd/DMD.cpp
+--- a/memory/replace/dmd/DMD.cpp
++++ b/memory/replace/dmd/DMD.cpp
+@@ -602,18 +602,18 @@ public:
+     return newString;
+   }
+ 
+   size_t
+   SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
+   {
+     size_t n = 0;
+     n += mSet.shallowSizeOfExcludingThis(aMallocSizeOf);
+-    for (auto r = mSet.all(); !r.empty(); r.popFront()) {
+-      n += aMallocSizeOf(r.front());
++    for (auto iter = mSet.iter(); !iter.done(); iter.next()) {
++      n += aMallocSizeOf(iter.get());
+     }
+     return n;
+   }
+ 
+ private:
+   struct StringHasher
+   {
+       typedef const char* Lookup;
+@@ -1129,41 +1129,41 @@ static void
+ GatherUsedStackTraces(StackTraceSet& aStackTraces)
+ {
+   MOZ_ASSERT(gStateLock->IsLocked());
+   MOZ_ASSERT(Thread::Fetch()->InterceptsAreBlocked());
+ 
+   aStackTraces.finish();
+   MOZ_ALWAYS_TRUE(aStackTraces.init(512));
+ 
+-  for (auto r = gLiveBlockTable->all(); !r.empty(); r.popFront()) {
+-    r.front().AddStackTracesToTable(aStackTraces);
++  for (auto iter = gLiveBlockTable->iter(); !iter.done(); iter.next()) {
++    iter.get().AddStackTracesToTable(aStackTraces);
+   }
+ 
+-  for (auto r = gDeadBlockTable->all(); !r.empty(); r.popFront()) {
+-    r.front().key().AddStackTracesToTable(aStackTraces);
++  for (auto iter = gDeadBlockTable->iter(); !iter.done(); iter.next()) {
++    iter.get().key().AddStackTracesToTable(aStackTraces);
+   }
+ }
+ 
+ // Delete stack traces that we aren't using, and compact our hashtable.
+ static void
+ GCStackTraces()
+ {
+   MOZ_ASSERT(gStateLock->IsLocked());
+   MOZ_ASSERT(Thread::Fetch()->InterceptsAreBlocked());
+ 
+   StackTraceSet usedStackTraces;
+   GatherUsedStackTraces(usedStackTraces);
+ 
+-  // Delete all unused stack traces from gStackTraceTable.  The Enum destructor
+-  // will automatically rehash and compact the table.
+-  for (StackTraceTable::Enum e(*gStackTraceTable); !e.empty(); e.popFront()) {
+-    StackTrace* const& st = e.front();
++  // Delete all unused stack traces from gStackTraceTable.  The ModIterator
++  // destructor will automatically rehash and compact the table.
++  for (auto iter = gStackTraceTable->modIter(); !iter.done(); iter.next()) {
++    StackTrace* const& st = iter.get();
+     if (!usedStackTraces.has(st)) {
+-      e.removeFront();
++      iter.remove();
+       InfallibleAllocPolicy::delete_(st);
+     }
+   }
+ 
+   // Schedule a GC when we have twice as many stack traces as we had right after
+   // this GC finished.
+   gGCStackTraceTableWhenSizeExceeds = 2 * gStackTraceTable->count();
+ }
+@@ -1656,18 +1656,18 @@ SizeOfInternal(Sizes* aSizes)
+   MOZ_ASSERT(gStateLock->IsLocked());
+   MOZ_ASSERT(Thread::Fetch()->InterceptsAreBlocked());
+ 
+   aSizes->Clear();
+ 
+   StackTraceSet usedStackTraces;
+   GatherUsedStackTraces(usedStackTraces);
+ 
+-  for (auto r = gStackTraceTable->all(); !r.empty(); r.popFront()) {
+-    StackTrace* const& st = r.front();
++  for (auto iter = gStackTraceTable->iter(); !iter.done(); iter.next()) {
++    StackTrace* const& st = iter.get();
+ 
+     if (usedStackTraces.has(st)) {
+       aSizes->mStackTracesUsed += MallocSizeOf(st);
+     } else {
+       aSizes->mStackTracesUnused += MallocSizeOf(st);
+     }
+   }
+ 
+@@ -1698,18 +1698,18 @@ DMDFuncs::ClearReports()
+     return;
+   }
+ 
+   AutoLockState lock;
+ 
+   // Unreport all blocks that were marked reported by a memory reporter.  This
+   // excludes those that were reported on allocation, because they need to keep
+   // their reported marking.
+-  for (auto r = gLiveBlockTable->all(); !r.empty(); r.popFront()) {
+-    r.front().UnreportIfNotReportedOnAlloc();
++  for (auto iter = gLiveBlockTable->iter(); !iter.done(); iter.next()) {
++    iter.get().UnreportIfNotReportedOnAlloc();
+   }
+ }
+ 
+ class ToIdStringConverter final
+ {
+ public:
+   ToIdStringConverter()
+     : mNextId(0)
+@@ -1907,51 +1907,51 @@ AnalyzeImpl(UniquePtr<JSONWriteFunc> aWr
+       };
+ 
+       // Live blocks.
+       if (!gOptions->IsScanMode()) {
+         // At this point we typically have many LiveBlocks that differ only in
+         // their address. Aggregate them to reduce the size of the output file.
+         AggregatedLiveBlockTable agg;
+         MOZ_ALWAYS_TRUE(agg.init(8192));
+-        for (auto r = gLiveBlockTable->all(); !r.empty(); r.popFront()) {
+-          const LiveBlock& b = r.front();
++        for (auto iter = gLiveBlockTable->iter(); !iter.done(); iter.next()) {
++          const LiveBlock& b = iter.get();
+           b.AddStackTracesToTable(usedStackTraces);
+ 
+           if (AggregatedLiveBlockTable::AddPtr p = agg.lookupForAdd(&b)) {
+             p->value() += 1;
+           } else {
+             MOZ_ALWAYS_TRUE(agg.add(p, &b, 1));
+           }
+         }
+ 
+         // Now iterate over the aggregated table.
+-        for (auto r = agg.all(); !r.empty(); r.popFront()) {
+-          const LiveBlock& b = *r.front().key();
+-          size_t num = r.front().value();
++        for (auto iter = agg.iter(); !iter.done(); iter.next()) {
++          const LiveBlock& b = *iter.get().key();
++          size_t num = iter.get().value();
+           writeLiveBlock(b, num);
+         }
+ 
+       } else {
+         // In scan mode we cannot aggregate because we print each live block's
+         // address and contents.
+-        for (auto r = gLiveBlockTable->all(); !r.empty(); r.popFront()) {
+-          const LiveBlock& b = r.front();
++        for (auto iter = gLiveBlockTable->iter(); !iter.done(); iter.next()) {
++          const LiveBlock& b = iter.get();
+           b.AddStackTracesToTable(usedStackTraces);
+ 
+           writeLiveBlock(b, 1);
+         }
+       }
+ 
+       // Dead blocks.
+-      for (auto r = gDeadBlockTable->all(); !r.empty(); r.popFront()) {
+-        const DeadBlock& b = r.front().key();
++      for (auto iter = gDeadBlockTable->iter(); !iter.done(); iter.next()) {
++        const DeadBlock& b = iter.get().key();
+         b.AddStackTracesToTable(usedStackTraces);
+ 
+-        size_t num = r.front().value();
++        size_t num = iter.get().value();
+         MOZ_ASSERT(num > 0);
+ 
+         writer.StartObjectElement(writer.SingleLineStyle);
+         {
+           writer.IntProperty("req", b.ReqSize());
+           if (b.SlopSize() > 0) {
+             writer.IntProperty("slop", b.SlopSize());
+           }
+@@ -1967,18 +1967,18 @@ AnalyzeImpl(UniquePtr<JSONWriteFunc> aWr
+       }
+     }
+     writer.EndArray();
+ 
+     StatusMsg("  Constructing the stack trace table...\n");
+ 
+     writer.StartObjectProperty("traceTable");
+     {
+-      for (auto r = usedStackTraces.all(); !r.empty(); r.popFront()) {
+-        const StackTrace* const st = r.front();
++      for (auto iter = usedStackTraces.iter(); !iter.done(); iter.next()) {
++        const StackTrace* const st = iter.get();
+         writer.StartArrayProperty(isc.ToIdString(st), writer.SingleLineStyle);
+         {
+           for (uint32_t i = 0; i < st->Length(); i++) {
+             const void* pc = st->Pc(i);
+             writer.StringElement(isc.ToIdString(pc));
+             MOZ_ALWAYS_TRUE(usedPcs.put(pc));
+           }
+         }
+@@ -1989,18 +1989,18 @@ AnalyzeImpl(UniquePtr<JSONWriteFunc> aWr
+ 
+     StatusMsg("  Constructing the stack frame table...\n");
+ 
+     writer.StartObjectProperty("frameTable");
+     {
+       static const size_t locBufLen = 1024;
+       char locBuf[locBufLen];
+ 
+-      for (PointerSet::Enum e(usedPcs); !e.empty(); e.popFront()) {
+-        const void* const pc = e.front();
++      for (auto iter = usedPcs.iter(); !iter.done(); iter.next()) {
++        const void* const pc = iter.get();
+ 
+         // Use 0 for the frame number. See the JSON format description comment
+         // in DMD.h to understand why.
+         locService->GetLocation(0, pc, locBuf, locBufLen);
+         writer.StringProperty(isc.ToIdString(pc), locBuf);
+       }
+     }
+     writer.EndObject();

+ 32 - 0
frg/work-js/mozilla-release/patches/1478879-7-63a1.patch

@@ -0,0 +1,32 @@
+# HG changeset patch
+# User Nicholas Nethercote <nnethercote@mozilla.com>
+# Date 1532997060 -36000
+#      Tue Jul 31 10:31:00 2018 +1000
+# Node ID b0b47dcc51943e79d7505234115eef0189c13f70
+# Parent  af6083aa1ab461e303a3d1f1e7ec6bec4af4e912
+Bug 1478879 - Remove Range/Enum use in dom/. r=mccr8
+
+diff --git a/dom/base/CustomElementRegistry.cpp b/dom/base/CustomElementRegistry.cpp
+--- a/dom/base/CustomElementRegistry.cpp
++++ b/dom/base/CustomElementRegistry.cpp
+@@ -246,18 +246,18 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END
+ 
+ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(CustomElementRegistry)
+   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCustomDefinitions)
+   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mWhenDefinedPromiseMap)
+   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mWindow)
+ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
+ 
+ NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(CustomElementRegistry)
+-  for (ConstructorMap::Enum iter(tmp->mConstructors); !iter.empty(); iter.popFront()) {
+-    aCallbacks.Trace(&iter.front().mutableKey(),
++  for (auto iter = tmp->mConstructors.iter(); !iter.done(); iter.next()) {
++    aCallbacks.Trace(&iter.get().mutableKey(),
+                      "mConstructors key",
+                      aClosure);
+   }
+   NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER
+ NS_IMPL_CYCLE_COLLECTION_TRACE_END
+ 
+ NS_IMPL_CYCLE_COLLECTING_ADDREF(CustomElementRegistry)
+ NS_IMPL_CYCLE_COLLECTING_RELEASE(CustomElementRegistry)

+ 0 - 0
frg/work-js/mozilla-release/patches/mozilla-central-push_429839.patch → frg/work-js/mozilla-release/patches/1478879-8-63a1.patch


+ 4 - 4
frg/work-js/mozilla-release/patches/mozilla-central-push_429840.patch → frg/work-js/mozilla-release/patches/1478879-9-63a1.patch

@@ -3,7 +3,7 @@
 # Date 1532997060 -36000
 #      Tue Jul 31 10:31:00 2018 +1000
 # Node ID 3c7c754ce8fd94709ab2327030e9f08a76618039
-# Parent  fd4f3d39873cd6db83a839c32c2036ff1c04cb4b
+# Parent  6fc9ca2e5ef409617bc43bbcd789697dd8cb5172
 Bug 1478879 - Remove Range/Enum use in XPConnect. r=mccr8
 
 diff --git a/js/xpconnect/src/XPCMaps.cpp b/js/xpconnect/src/XPCMaps.cpp
@@ -88,7 +88,7 @@ diff --git a/js/xpconnect/src/XPCMaps.h b/js/xpconnect/src/XPCMaps.h
 +++ b/js/xpconnect/src/XPCMaps.h
 @@ -47,18 +47,18 @@ public:
      inline nsXPCWrappedJS* Find(JSObject* Obj) {
-         MOZ_ASSERT(Obj,"bad param");
+         NS_PRECONDITION(Obj,"bad param");
          Map::Ptr p = mTable.lookup(Obj);
          return p ? p->value() : nullptr;
      }
@@ -106,10 +106,10 @@ diff --git a/js/xpconnect/src/XPCMaps.h b/js/xpconnect/src/XPCMaps.h
  #endif
  
      inline nsXPCWrappedJS* Add(JSContext* cx, nsXPCWrappedJS* wrapper) {
-         MOZ_ASSERT(wrapper,"bad param");
+         NS_PRECONDITION(wrapper,"bad param");
 @@ -74,18 +74,18 @@ public:
      inline void Remove(nsXPCWrappedJS* wrapper) {
-         MOZ_ASSERT(wrapper,"bad param");
+         NS_PRECONDITION(wrapper,"bad param");
          mTable.remove(wrapper->GetJSObjectPreserveColor());
      }
  

File diff suppressed because it is too large
+ 586 - 182
frg/work-js/mozilla-release/patches/1478896-63a1.patch


+ 0 - 0
frg/work-js/mozilla-release/patches/mozilla-central-push_429549.patch → frg/work-js/mozilla-release/patches/1478902-1-63a1.patch


+ 0 - 0
frg/work-js/mozilla-release/patches/mozilla-central-push_429550.patch → frg/work-js/mozilla-release/patches/1478902-2-63a1.patch


+ 0 - 0
frg/work-js/mozilla-release/patches/mozilla-central-push_429551.patch → frg/work-js/mozilla-release/patches/1478902-3-63a1.patch


+ 0 - 0
frg/work-js/mozilla-release/patches/mozilla-central-push_429555.patch → frg/work-js/mozilla-release/patches/1479360-63a1.patch


+ 1 - 1
frg/work-js/mozilla-release/patches/mozilla-central-push_429366.patch → frg/work-js/mozilla-release/patches/1479388-63a1.patch

@@ -3,7 +3,7 @@
 # Date 1533027966 -3600
 #      Tue Jul 31 10:06:06 2018 +0100
 # Node ID 43730ff0303f8e580f016665fd277c04876db13a
-# Parent  9596750407403946f31786a2f810aeb1dac6bcbf
+# Parent  bbc2d5546b418beb50889cfeaa3a1fcebc3a321e
 Bug 1479388 - Move most WeakMap inline method definitions into a separate header r=sfink
 
 diff --git a/js/src/builtin/WeakMapObject-inl.h b/js/src/builtin/WeakMapObject-inl.h

+ 0 - 0
frg/work-js/mozilla-release/patches/mozilla-central-push_430048.patch → frg/work-js/mozilla-release/patches/1479718-63a1.patch


+ 6 - 6
frg/work-js/mozilla-release/patches/1479900-2-63a1.patch

@@ -2,7 +2,7 @@
 # User Ted Campbell <tcampbell@mozilla.com>
 # Date 1533234736 25200
 # Node ID 819b923159847ebf0227a910e966490f4f9dc177
-# Parent  9b87251dedb102f85edf8a725e73c427df435b38
+# Parent  eef40cddead40534e37bf9b74f67f3a61285c96a
 Bug 1479900 - Part 2: Refactor GC relocation to use a reserved flag. r=sfink
 
 This refactors gc::Cell derived types to start with a uintptr_t-sized
@@ -236,7 +236,7 @@ diff --git a/js/src/gc/GC.cpp b/js/src/gc/GC.cpp
  #endif
  #include "vm/Debugger.h"
  #include "vm/GeckoProfiler.h"
-@@ -383,16 +384,27 @@ static const int IGC_MARK_SLICE_MULTIPLI
+@@ -382,16 +383,27 @@ static const int IGC_MARK_SLICE_MULTIPLI
  const AllocKind gc::slotsToThingKind[] = {
      /*  0 */ AllocKind::OBJECT0,  AllocKind::OBJECT2,  AllocKind::OBJECT2,  AllocKind::OBJECT4,
      /*  4 */ AllocKind::OBJECT4,  AllocKind::OBJECT8,  AllocKind::OBJECT8,  AllocKind::OBJECT8,
@@ -259,12 +259,12 @@ diff --git a/js/src/gc/GC.cpp b/js/src/gc/GC.cpp
  static_assert(mozilla::ArrayLength(slotsToThingKind) == SLOTS_TO_THING_KIND_LIMIT,
                "We have defined a slot count for each kind.");
  
- #define CHECK_THING_SIZE(allocKind, traceKind, type, sizedType, bgFinal, nursery) \
+ #define CHECK_THING_SIZE(allocKind, traceKind, type, sizedType, bgFinal, nursery, compact) \
      static_assert(sizeof(sizedType) >= SortedArenaList::MinThingSize, \
                    #sizedType " is smaller than SortedArenaList::MinThingSize!"); \
      static_assert(sizeof(sizedType) >= sizeof(FreeSpan), \
                    #sizedType " is smaller than FreeSpan"); \
-@@ -2398,17 +2410,17 @@ RelocateArena(Arena* arena, SliceBudget&
+@@ -2372,17 +2384,17 @@ RelocateArena(Arena* arena, SliceBudget&
      for (ArenaCellIterUnderGC i(arena); !i.done(); i.next()) {
          RelocateCell(zone, i.getCell(), thingKind, thingSize);
          sliceBudget.step();
@@ -283,7 +283,7 @@ diff --git a/js/src/gc/GC.cpp b/js/src/gc/GC.cpp
  }
  
  static inline bool
-@@ -8511,18 +8523,18 @@ js::gc::AssertGCThingHasType(js::gc::Cel
+@@ -8502,18 +8514,18 @@ js::gc::AssertGCThingHasType(js::gc::Cel
      if (!cell) {
          MOZ_ASSERT(kind == JS::TraceKind::Null);
          return;
@@ -403,7 +403,7 @@ diff --git a/js/src/gc/Marking-inl.h b/js/src/gc/Marking-inl.h
 diff --git a/js/src/gc/Marking.cpp b/js/src/gc/Marking.cpp
 --- a/js/src/gc/Marking.cpp
 +++ b/js/src/gc/Marking.cpp
-@@ -2826,17 +2826,17 @@ js::gc::StoreBuffer::CellPtrEdge::trace(
+@@ -2857,17 +2857,17 @@ js::gc::StoreBuffer::CellPtrEdge::trace(
  #endif
  
      // Bug 1376646: Make separate store buffers for strings and objects, and

+ 0 - 0
frg/work-js/mozilla-release/patches/mozilla-central-push_429831.patch → frg/work-js/mozilla-release/patches/1479954-63a1.patch


+ 0 - 0
frg/work-js/mozilla-release/patches/mozilla-central-push_430045.patch → frg/work-js/mozilla-release/patches/1480012-63a1.patch


+ 0 - 0
frg/work-js/mozilla-release/patches/mozilla-central-push_429952.patch → frg/work-js/mozilla-release/patches/1480018-63a1.patch


+ 0 - 0
frg/work-js/mozilla-release/patches/mozilla-central-push_429946.patch → frg/work-js/mozilla-release/patches/1480020-63a1.patch


+ 0 - 0
frg/work-js/mozilla-release/patches/mozilla-central-push_429944.patch → frg/work-js/mozilla-release/patches/1480077-63a1.patch


+ 0 - 0
frg/work-js/mozilla-release/patches/mozilla-central-push_429828.patch → frg/work-js/mozilla-release/patches/1480233-63a1.patch


+ 0 - 0
frg/work-js/mozilla-release/patches/mozilla-central-push_430194.patch → frg/work-js/mozilla-release/patches/1480991-63a1.patch


+ 2 - 2
frg/work-js/mozilla-release/patches/1482931-1-63a1.patch

@@ -2,7 +2,7 @@
 # User Ted Campbell <tcampbell@mozilla.com>
 # Date 1534169521 14400
 # Node ID 490b0d605859e612832f6b655d4168e39a30ceb1
-# Parent  ed9314668e62925e4f3b8004fe6aa17c2dbf2301
+# Parent  70c41bcb9cd6529836ee3c5595d6ee5d5c49e11e
 Bug 1482931 - Cleanup const-ness of statics in js/src. r=waldo
 
 Mark read-only global data as const. Replacing |const char* x[]| with
@@ -44,7 +44,7 @@ diff --git a/js/src/gc/GC.cpp b/js/src/gc/GC.cpp
  {
 -    static const char* names[] = {
 +    static const char* const names[] = {
- #define EXPAND_THING_NAME(allocKind, _1, _2, _3, _4, _5) \
+ #define EXPAND_THING_NAME(allocKind, _1, _2, _3, _4, _5, _6) \
          #allocKind,
  FOR_EACH_ALLOCKIND(EXPAND_THING_NAME)
  #undef EXPAND_THING_NAME

+ 6 - 6
frg/work-js/mozilla-release/patches/1483275-1-63a1.patch

@@ -2,7 +2,7 @@
 # User Ted Campbell <tcampbell@mozilla.com>
 # Date 1521060914 14400
 # Node ID cf5e7017ffdc1ebc32f564f95de1ca91bf7a5795
-# Parent  92e9e61a496d79c317a6c3fb911a3267f7855e6e
+# Parent  9bbb22ad5c97215c38d446070856541fbe28f253
 Bug 1483275 - Fix some SpiderMonkey unified-build conflicts. r=waldo
 
 MozReview-Commit-ID: CqFbs7149CZ
@@ -106,7 +106,7 @@ diff --git a/js/src/irregexp/RegExpInterpreter.cpp b/js/src/irregexp/RegExpInter
 diff --git a/js/src/jit/BaselineCacheIRCompiler.cpp b/js/src/jit/BaselineCacheIRCompiler.cpp
 --- a/js/src/jit/BaselineCacheIRCompiler.cpp
 +++ b/js/src/jit/BaselineCacheIRCompiler.cpp
-@@ -447,17 +447,17 @@ BaselineCacheIRCompiler::emitGuardXrayEx
+@@ -462,17 +462,17 @@ BaselineCacheIRCompiler::emitGuardXrayEx
      if (hasExpando) {
          masm.branchTestObject(Assembler::NotEqual, holderAddress, failure->label());
          masm.unboxObject(holderAddress, scratch);
@@ -125,7 +125,7 @@ diff --git a/js/src/jit/BaselineCacheIRCompiler.cpp b/js/src/jit/BaselineCacheIR
  
          // The reserved slots on the expando should all be in fixed slots.
          Address protoAddress(scratch, NativeObject::getFixedSlotOffset(GetXrayJitInfo()->expandoProtoSlot));
-@@ -2055,17 +2055,17 @@ BaselineCacheIRCompiler::emitLoadDOMExpa
+@@ -2042,17 +2042,17 @@ BaselineCacheIRCompiler::emitLoadDOMExpa
      AutoScratchRegister scratch(allocator, masm);
      ValueOperand output = allocator.defineValueRegister(masm, reader.valOperandId());
  
@@ -327,8 +327,8 @@ diff --git a/js/src/vm/ErrorReporting.h b/js/src/vm/ErrorReporting.h
 diff --git a/js/src/vm/JSContext.cpp b/js/src/vm/JSContext.cpp
 --- a/js/src/vm/JSContext.cpp
 +++ b/js/src/vm/JSContext.cpp
-@@ -1045,36 +1045,16 @@ InternalEnqueuePromiseJobCallback(JSCont
-     MOZ_ASSERT(job);
+@@ -1046,36 +1046,16 @@ InternalEnqueuePromiseJobCallback(JSCont
+     JS::JobQueueMayNotBeEmpty(cx);
      if (!cx->jobQueue->append(job)) {
          ReportOutOfMemory(cx);
          return false;
@@ -364,7 +364,7 @@ diff --git a/js/src/vm/JSContext.cpp b/js/src/vm/JSContext.cpp
      MOZ_RELEASE_ASSERT(!cx->runtime()->hasInitializedSelfHosting(),
                         "js::UseInternalJobQueues must be called early during runtime startup.");
      MOZ_ASSERT(!cx->jobQueue);
-@@ -1160,17 +1140,17 @@ js::RunJobs(JSContext* cx)
+@@ -1168,17 +1148,17 @@ js::RunJobs(JSContext* cx)
                      RootedValue exn(cx);
                      if (cx->getPendingException(&exn)) {
                          /*

+ 4 - 4
frg/work-js/mozilla-release/patches/1484421-63a1.patch

@@ -2,7 +2,7 @@
 # User Jeff Walden <jwalden@mit.edu>
 # Date 1534776885 25200
 # Node ID ab5ac052f221b03e0700351ec6534160b38b106c
-# Parent  62d3590273210c7bdbdd3ce48a6ce01a90609313
+# Parent  245097ca7c5752838ac99a48e0fb29d63772337a
 Bug 1484421 - Move JSON-related functionality into js/public/JSON.h that isn't #include'd in jsapi.h.  r=jandem
 
 diff --git a/dom/base/BodyUtil.cpp b/dom/base/BodyUtil.cpp
@@ -65,9 +65,9 @@ diff --git a/dom/base/nsFrameMessageManager.cpp b/dom/base/nsFrameMessageManager
  #include "mozilla/Preferences.h"
  #include "mozilla/ScriptPreloader.h"
  #include "mozilla/Telemetry.h"
+ #include "mozilla/dom/DOMPrefs.h"
  #include "mozilla/dom/File.h"
  #include "mozilla/dom/MessagePort.h"
- #include "mozilla/dom/ContentParent.h"
 diff --git a/dom/base/nsINode.cpp b/dom/base/nsINode.cpp
 --- a/dom/base/nsINode.cpp
 +++ b/dom/base/nsINode.cpp
@@ -333,7 +333,7 @@ diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp
 diff --git a/js/src/jsapi.h b/js/src/jsapi.h
 --- a/js/src/jsapi.h
 +++ b/js/src/jsapi.h
-@@ -4693,71 +4693,16 @@ PropertySpecNameEqualsId(const char* nam
+@@ -4683,71 +4683,16 @@ PropertySpecNameEqualsId(const char* nam
   * during GC marking.
   */
  JS_PUBLIC_API(bool)
@@ -408,7 +408,7 @@ diff --git a/js/src/jsapi.h b/js/src/jsapi.h
 diff --git a/js/src/moz.build b/js/src/moz.build
 --- a/js/src/moz.build
 +++ b/js/src/moz.build
-@@ -137,16 +137,17 @@ EXPORTS.js += [
+@@ -138,16 +138,17 @@ EXPORTS.js += [
      '../public/GCHashTable.h',
      '../public/GCPolicyAPI.h',
      '../public/GCVariant.h',

+ 5 - 4
frg/work-js/mozilla-release/patches/1486577-6-63a1.patch

@@ -3,7 +3,7 @@
 # Date 1535162518 18000
 #      Fri Aug 24 21:01:58 2018 -0500
 # Node ID 2dc7007e3924444f55345606b6785f2d2ba89ce1
-# Parent  b069c90ac10e84324b9507a64d6815ee9bb46fe2
+# Parent  7a4d65c3360a3e3f17bdca0c9fa438927e4f5433
 Bug 1486577 - Don't #include js/SourceBufferHolder.h in jsapi.h, and instead require users to do so -- a minor translation-unit size improvement for anyone who never has to use SourceBufferHolder other than by reference.  r=jandem
 
 diff --git a/dom/base/nsFrameMessageManager.cpp b/dom/base/nsFrameMessageManager.cpp
@@ -24,9 +24,9 @@ diff --git a/dom/base/nsFrameMessageManager.cpp b/dom/base/nsFrameMessageManager
  #include "mozilla/Preferences.h"
  #include "mozilla/ScriptPreloader.h"
  #include "mozilla/Telemetry.h"
+ #include "mozilla/dom/DOMPrefs.h"
  #include "mozilla/dom/File.h"
  #include "mozilla/dom/MessagePort.h"
- #include "mozilla/dom/ContentParent.h"
 diff --git a/dom/base/nsJSUtils.cpp b/dom/base/nsJSUtils.cpp
 --- a/dom/base/nsJSUtils.cpp
 +++ b/dom/base/nsJSUtils.cpp
@@ -296,7 +296,7 @@ diff --git a/js/src/builtin/TestingFunctions.cpp b/js/src/builtin/TestingFunctio
 diff --git a/js/src/frontend/BytecodeCompiler.cpp b/js/src/frontend/BytecodeCompiler.cpp
 --- a/js/src/frontend/BytecodeCompiler.cpp
 +++ b/js/src/frontend/BytecodeCompiler.cpp
-@@ -9,31 +9,35 @@
+@@ -9,32 +9,36 @@
  #include "mozilla/IntegerPrintfMacros.h"
  #include "mozilla/Maybe.h"
  
@@ -313,6 +313,7 @@ diff --git a/js/src/frontend/BytecodeCompiler.cpp b/js/src/frontend/BytecodeComp
  #include "wasm/AsmJS.h"
  
  #include "vm/EnvironmentObject-inl.h"
+ #include "vm/GeckoProfiler-inl.h"
  #include "vm/JSObject-inl.h"
  #include "vm/JSScript-inl.h"
  
@@ -606,7 +607,7 @@ diff --git a/js/src/shell/js.cpp b/js/src/shell/js.cpp
  #include "shell/jsoptparse.h"
  #include "shell/jsshell.h"
  #include "shell/OSObject.h"
-@@ -4274,18 +4275,18 @@ ParseModule(JSContext* cx, unsigned argc
+@@ -4275,18 +4276,18 @@ ParseModule(JSContext* cx, unsigned argc
          options.setFileAndLine("<string>", 1);
      }
  

+ 2 - 2
frg/work-js/mozilla-release/patches/1486577-8-63a1.patch

@@ -3,7 +3,7 @@
 # Date 1535169109 18000
 #      Fri Aug 24 22:51:49 2018 -0500
 # Node ID 48921866b394212e0dddd0ba72c183081bc6805f
-# Parent  8a5a405b2091d84433d2081f8ff4297a41539403
+# Parent  ac4a57076ade452e1349b7248e7136ef16a5e5f4
 Bug 1486577 - Don't #include "js/CompilationAndEvaluation.h" in jsapi.h, minimizing the scope of that header and reducing translation-unit size of anything that needs JSAPI but doesn't need to compile/evaluate JavaScript.  r=jandem
 
 diff --git a/dom/base/nsFrameMessageManager.cpp b/dom/base/nsFrameMessageManager.cpp
@@ -26,7 +26,7 @@ diff --git a/dom/base/nsFrameMessageManager.cpp b/dom/base/nsFrameMessageManager
  #include "mozilla/Preferences.h"
  #include "mozilla/ScriptPreloader.h"
  #include "mozilla/Telemetry.h"
- #include "mozilla/dom/File.h"
+ #include "mozilla/dom/DOMPrefs.h"
 diff --git a/dom/base/nsJSUtils.cpp b/dom/base/nsJSUtils.cpp
 --- a/dom/base/nsJSUtils.cpp
 +++ b/dom/base/nsJSUtils.cpp

+ 7 - 7
frg/work-js/mozilla-release/patches/1486730-63a1.patch

@@ -2,14 +2,13 @@
 # User Jon Coppeard <jcoppeard@mozilla.com>
 # Date 1535656220 -3600
 # Node ID 7d07908ee08acfa5333806b907bce7fb20c59dc1
-# Parent  c3d27e62efe56504abb4d5ce0ae42488cec11577
+# Parent  ff425861e08fc6597ba25bbef4d3777e40cadb9f
 Bug 1486730 - Remove some unnecessary includes from js/src/frontend r=Waldo
 
 diff --git a/js/src/frontend/BytecodeCompiler.cpp b/js/src/frontend/BytecodeCompiler.cpp
 --- a/js/src/frontend/BytecodeCompiler.cpp
 +++ b/js/src/frontend/BytecodeCompiler.cpp
-@@ -17,18 +17,17 @@
- #include "js/SourceBufferHolder.h"
+@@ -18,18 +18,17 @@
  #include "vm/GlobalObject.h"
  #include "vm/JSContext.h"
  #include "vm/JSScript.h"
@@ -17,6 +16,7 @@ diff --git a/js/src/frontend/BytecodeCompiler.cpp b/js/src/frontend/BytecodeComp
  #include "wasm/AsmJS.h"
  
  #include "vm/EnvironmentObject-inl.h"
+ #include "vm/GeckoProfiler-inl.h"
 -#include "vm/JSObject-inl.h"
 -#include "vm/JSScript-inl.h"
 +#include "vm/JSContext-inl.h"
@@ -618,7 +618,7 @@ diff --git a/js/src/frontend/Parser.h b/js/src/frontend/Parser.h
 diff --git a/js/src/frontend/SharedContext.h b/js/src/frontend/SharedContext.h
 --- a/js/src/frontend/SharedContext.h
 +++ b/js/src/frontend/SharedContext.h
-@@ -9,19 +9,19 @@
+@@ -9,20 +9,18 @@
  
  #include "jspubtd.h"
  #include "jstypes.h"
@@ -627,7 +627,7 @@ diff --git a/js/src/frontend/SharedContext.h b/js/src/frontend/SharedContext.h
  #include "ds/InlineTable.h"
  #include "frontend/ParseNode.h"
  #include "frontend/TokenStream.h"
-+// -include "gc/Zone.h"
+-#include "gc/Zone.h"
  #include "vm/BytecodeUtil.h"
 -#include "vm/EnvironmentObject.h"
 -#include "vm/JSAtom.h"
@@ -640,7 +640,7 @@ diff --git a/js/src/frontend/SharedContext.h b/js/src/frontend/SharedContext.h
  class ParseContext;
  class ParseNode;
  
-@@ -404,28 +404,32 @@ class FunctionBox : public ObjectBox, pu
+@@ -405,28 +403,32 @@ class FunctionBox : public ObjectBox, pu
  
      // Whether this function has nested functions.
      bool hasInnerFunctions_:1;
@@ -823,7 +823,7 @@ diff --git a/js/src/vm/Iteration.h b/js/src/vm/Iteration.h
 diff --git a/js/src/vm/Stack.h b/js/src/vm/Stack.h
 --- a/js/src/vm/Stack.h
 +++ b/js/src/vm/Stack.h
-@@ -97,18 +97,27 @@ class Instance;
+@@ -98,18 +98,27 @@ class Instance;
  // the activation's "current regs", which contains the stack pointer 'sp'. In
  // the interpreter, sp is adjusted as individual values are pushed and popped
  // from the stack and the InterpreterRegs struct (pointed to by the

File diff suppressed because it is too large
+ 377 - 78
frg/work-js/mozilla-release/patches/1488698-7-WIP-64a1.patch


+ 5 - 17
frg/work-js/mozilla-release/patches/1489698-5-65a1.patch

@@ -3,14 +3,14 @@
 # Date 1536361555 14400
 #      Fri Sep 07 19:05:55 2018 -0400
 # Node ID a17dfbac6b10ec140dc69ed3053662987eba25ef
-# Parent  bb9934bbc21b82c8f5bb519b7fb4fb3fb062ff47
+# Parent  324aa81cd668c40ca676b62da95f950c57307ead
 Bug 1489698 - Add moz.build for js/src/jit. r=jandem,froydnj
 
 diff --git a/js/src/jit/moz.build b/js/src/jit/moz.build
 new file mode 100644
 --- /dev/null
 +++ b/js/src/jit/moz.build
-@@ -0,0 +1,267 @@
+@@ -0,0 +1,261 @@
 +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
 +# vim: set filetype=python:
 +# This Source Code Form is subject to the terms of the Mozilla Public
@@ -153,7 +153,6 @@ new file mode 100644
 +            'x64/CodeGenerator-x64.cpp',
 +            'x64/Lowering-x64.cpp',
 +            'x64/MacroAssembler-x64.cpp',
-+            'x64/SharedIC-x64.cpp',
 +            'x64/Trampoline-x64.cpp',
 +        ]
 +    else:
@@ -166,7 +165,6 @@ new file mode 100644
 +            'x86/CodeGenerator-x86.cpp',
 +            'x86/Lowering-x86.cpp',
 +            'x86/MacroAssembler-x86.cpp',
-+            'x86/SharedIC-x86.cpp',
 +            'x86/Trampoline-x86.cpp',
 +        ]
 +elif CONFIG['JS_CODEGEN_ARM']:
@@ -183,7 +181,6 @@ new file mode 100644
 +        'arm/Lowering-arm.cpp',
 +        'arm/MacroAssembler-arm.cpp',
 +        'arm/MoveEmitter-arm.cpp',
-+        'arm/SharedIC-arm.cpp',
 +        'arm/Trampoline-arm.cpp',
 +    ]
 +    if CONFIG['JS_SIMULATOR_ARM']:
@@ -207,7 +204,6 @@ new file mode 100644
 +        'arm64/Lowering-arm64.cpp',
 +        'arm64/MacroAssembler-arm64.cpp',
 +        'arm64/MoveEmitter-arm64.cpp',
-+        'arm64/SharedIC-arm64.cpp',
 +        'arm64/Trampoline-arm64.cpp',
 +        'arm64/vixl/Assembler-vixl.cpp',
 +        'arm64/vixl/Cpu-vixl.cpp',
@@ -252,7 +248,6 @@ new file mode 100644
 +            'mips32/Lowering-mips32.cpp',
 +            'mips32/MacroAssembler-mips32.cpp',
 +            'mips32/MoveEmitter-mips32.cpp',
-+            'mips32/SharedIC-mips32.cpp',
 +            'mips32/Trampoline-mips32.cpp',
 +        ]
 +        if CONFIG['JS_SIMULATOR_MIPS32']:
@@ -271,7 +266,6 @@ new file mode 100644
 +            'mips64/Lowering-mips64.cpp',
 +            'mips64/MacroAssembler-mips64.cpp',
 +            'mips64/MoveEmitter-mips64.cpp',
-+            'mips64/SharedIC-mips64.cpp',
 +            'mips64/Trampoline-mips64.cpp',
 +        ]
 +        if CONFIG['JS_SIMULATOR_MIPS64']:
@@ -311,7 +305,7 @@ diff --git a/js/src/moz.build b/js/src/moz.build
      'js.msg',
      'jsapi.h',
      'jsfriendapi.h',
-@@ -260,89 +247,16 @@ UNIFIED_SOURCES += [
+@@ -261,89 +248,16 @@ UNIFIED_SOURCES += [
      'irregexp/NativeRegExpMacroAssembler.cpp',
      'irregexp/RegExpAST.cpp',
      'irregexp/RegExpCharacters.cpp',
@@ -401,7 +395,7 @@ diff --git a/js/src/moz.build b/js/src/moz.build
      'perf/jsperf.cpp',
      'proxy/BaseProxyHandler.cpp',
      'proxy/CrossCompartmentWrapper.cpp',
-@@ -497,174 +411,16 @@ if CONFIG['MOZ_INSTRUMENTS']:
+@@ -498,168 +412,16 @@ if CONFIG['MOZ_INSTRUMENTS']:
  
  if CONFIG['ENABLE_TRACE_LOGGING']:
      SOURCES += [
@@ -442,7 +436,6 @@ diff --git a/js/src/moz.build b/js/src/moz.build
 -            'jit/x64/CodeGenerator-x64.cpp',
 -            'jit/x64/Lowering-x64.cpp',
 -            'jit/x64/MacroAssembler-x64.cpp',
--            'jit/x64/SharedIC-x64.cpp',
 -            'jit/x64/Trampoline-x64.cpp',
 -        ]
 -    else:
@@ -455,7 +448,6 @@ diff --git a/js/src/moz.build b/js/src/moz.build
 -            'jit/x86/CodeGenerator-x86.cpp',
 -            'jit/x86/Lowering-x86.cpp',
 -            'jit/x86/MacroAssembler-x86.cpp',
--            'jit/x86/SharedIC-x86.cpp',
 -            'jit/x86/Trampoline-x86.cpp',
 -        ]
 -elif CONFIG['JS_CODEGEN_ARM']:
@@ -472,7 +464,6 @@ diff --git a/js/src/moz.build b/js/src/moz.build
 -        'jit/arm/Lowering-arm.cpp',
 -        'jit/arm/MacroAssembler-arm.cpp',
 -        'jit/arm/MoveEmitter-arm.cpp',
--        'jit/arm/SharedIC-arm.cpp',
 -        'jit/arm/Trampoline-arm.cpp',
 -    ]
 -    if CONFIG['JS_SIMULATOR_ARM']:
@@ -496,7 +487,6 @@ diff --git a/js/src/moz.build b/js/src/moz.build
 -        'jit/arm64/Lowering-arm64.cpp',
 -        'jit/arm64/MacroAssembler-arm64.cpp',
 -        'jit/arm64/MoveEmitter-arm64.cpp',
--        'jit/arm64/SharedIC-arm64.cpp',
 -        'jit/arm64/Trampoline-arm64.cpp',
 -        'jit/arm64/vixl/Assembler-vixl.cpp',
 -        'jit/arm64/vixl/Cpu-vixl.cpp',
@@ -541,7 +531,6 @@ diff --git a/js/src/moz.build b/js/src/moz.build
 -            'jit/mips32/Lowering-mips32.cpp',
 -            'jit/mips32/MacroAssembler-mips32.cpp',
 -            'jit/mips32/MoveEmitter-mips32.cpp',
--            'jit/mips32/SharedIC-mips32.cpp',
 -            'jit/mips32/Trampoline-mips32.cpp',
 -        ]
 -        if CONFIG['JS_SIMULATOR_MIPS32']:
@@ -560,7 +549,6 @@ diff --git a/js/src/moz.build b/js/src/moz.build
 -            'jit/mips64/Lowering-mips64.cpp',
 -            'jit/mips64/MacroAssembler-mips64.cpp',
 -            'jit/mips64/MoveEmitter-mips64.cpp',
--            'jit/mips64/SharedIC-mips64.cpp',
 -            'jit/mips64/Trampoline-mips64.cpp',
 -        ]
 -        if CONFIG['JS_SIMULATOR_MIPS64']:
@@ -576,7 +564,7 @@ diff --git a/js/src/moz.build b/js/src/moz.build
  else:
      UNIFIED_SOURCES += [
          'threading/posix/CpuCount.cpp',
-@@ -706,16 +462,17 @@ GENERATED_FILES += ['frontend/ReservedWo
+@@ -701,16 +463,17 @@ GENERATED_FILES += ['frontend/ReservedWo
  ReservedWordsGenerated = GENERATED_FILES['frontend/ReservedWordsGenerated.h']
  ReservedWordsGenerated.script = 'frontend/GenerateReservedWords.py'
  ReservedWordsGenerated.inputs += [

+ 72 - 0
frg/work-js/mozilla-release/patches/1495573-64a1.patch

@@ -0,0 +1,72 @@
+# HG changeset patch
+# User Lars T Hansen <lhansen@mozilla.com>
+# Date 1538482361 -7200
+#      Tue Oct 02 14:12:41 2018 +0200
+# Node ID 9d0ccdab956d9037b083d2576cc54e587fb70f71
+# Parent  b56f57205770fc4f55dcb0cf8bebce0dcf3d80cb
+Bug 1495573 - avoid double refcount decrement along failure path.  r=luke
+
+diff --git a/js/src/shell/js.cpp b/js/src/shell/js.cpp
+--- a/js/src/shell/js.cpp
++++ b/js/src/shell/js.cpp
+@@ -5690,41 +5690,52 @@ GetSharedObject(JSContext* cx, unsigned 
+           case MailboxTag::Empty: {
+             break;
+           }
+           case MailboxTag::SharedArrayBuffer:
+           case MailboxTag::WasmMemory: {
+             // Flag was set in the sender; ensure it is set in the receiver.
+             MOZ_ASSERT(cx->realm()->creationOptions().getSharedMemoryAndAtomicsEnabled());
+ 
++            // The protocol for creating a SAB requires the refcount to be
++            // incremented prior to the SAB creation.
++
+             SharedArrayRawBuffer* buf = mbx->val.sarb.buffer;
+             uint32_t length = mbx->val.sarb.length;
+             if (!buf->addReference()) {
+                 JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_SC_SAB_REFCNT_OFLO);
+                 return false;
+             }
+-            auto dropBuf = MakeScopeExit([buf] { buf->dropReference(); });
+-
++
++            // If the allocation fails we must decrement the refcount before
++            // returning.
+             Rooted<ArrayBufferObjectMaybeShared*> maybesab(cx, SharedArrayBufferObject::New(cx, buf, length));
+-            if (!maybesab)
++            if (!maybesab) {
++                buf->dropReference();
+                 return false;
++            }
++
++            // At this point the SAB was created successfully and it owns the
++            // refcount-increase on the buffer that we performed above.  So even
++            // if we fail to allocate along any path below we must not decrement
++            // the refcount; the garbage collector must be allowed to handle
++            // that via finalization of the orphaned SAB object.
++
+             if (mbx->tag == MailboxTag::SharedArrayBuffer) {
+                 newObj = maybesab;
+             } else {
+                 if (!GlobalObject::ensureConstructor(cx, cx->global(), JSProto_WebAssembly))
+                     return false;
+-
+                 RootedObject proto(cx, &cx->global()->getPrototype(JSProto_WasmMemory).toObject());
+                 newObj = WasmMemoryObject::create(cx, maybesab, proto);
+                 MOZ_ASSERT_IF(newObj, newObj->as<WasmMemoryObject>().isShared());
++                if (!newObj) {
++                    return false;
++                }
+             }
+-            if (!newObj)
+-                return false;
+-
+-            dropBuf.release();
+ 
+             break;
+           }
+           case MailboxTag::WasmModule: {
+             // Flag was set in the sender; ensure it is set in the receiver.
+             MOZ_ASSERT(cx->realm()->creationOptions().getSharedMemoryAndAtomicsEnabled());
+ 
+             if (!GlobalObject::ensureConstructor(cx, cx->global(), JSProto_WebAssembly))

+ 256 - 0
frg/work-js/mozilla-release/patches/1502889-65a1.patch

@@ -0,0 +1,256 @@
+# HG changeset patch
+# User Tom Schuster <evilpies@gmail.com>
+# Date 1540936912 0
+# Node ID 79eaa3fb663287a5e3333ad7799e4d730c3b9fdd
+# Parent  52e4ee8939c5b7e879ce4becd436702a072b45e5
+Bug 1502889 - Revert TypedArray [[Set]] to previous behavior if not receiver. r=jorendorff
+
+Differential Revision: https://phabricator.services.mozilla.com/D10116
+
+diff --git a/js/src/jit-test/tests/cacheir/typedarray-set.js b/js/src/jit-test/tests/cacheir/typedarray-set.js
+deleted file mode 100644
+--- a/js/src/jit-test/tests/cacheir/typedarray-set.js
++++ /dev/null
+@@ -1,29 +0,0 @@
+-// Based on work by André Bargull
+-
+-function f() {
+-    var x = [1,2,3];
+-    x[3] = 0xff;
+-
+-    // Should have been defined on typed array.
+-    assertEq(x.length, 3);
+-    assertEq(x[3], -1);
+-
+-    x[3] = 0;
+-}
+-
+-Object.setPrototypeOf(Array.prototype, new Int8Array(4));
+-f();
+-f();
+-
+-function g() {
+-    var x = [1,2,3,4];
+-    x[4] = 0xff;
+-
+-    // OOB [[Set]] should have been ignored
+-    assertEq(x.length, 4);
+-    assertEq(x[4], undefined);
+-}
+-
+-Object.setPrototypeOf(Array.prototype, new Int8Array(4));
+-g();
+-g();
+diff --git a/js/src/jit-test/tests/proxy/testDirectProxySetArray4.js b/js/src/jit-test/tests/proxy/testDirectProxySetArray4.js
+--- a/js/src/jit-test/tests/proxy/testDirectProxySetArray4.js
++++ b/js/src/jit-test/tests/proxy/testDirectProxySetArray4.js
+@@ -16,8 +16,9 @@ function test(arr) {
+     });
+     var hits = 0;
+     p[0] = "ponies";
+     assertEq(hits, 1);
+     assertEq(arr[0], 123);
+ }
+ 
+ test([123]);
++test(new Int32Array([123]));
+diff --git a/js/src/jit/CacheIR.cpp b/js/src/jit/CacheIR.cpp
+--- a/js/src/jit/CacheIR.cpp
++++ b/js/src/jit/CacheIR.cpp
+@@ -3590,20 +3590,16 @@ CanAttachAddElement(NativeObject* obj, b
+ 
+         JSObject* proto = obj->staticPrototype();
+         if (!proto)
+             break;
+ 
+         if (!proto->isNative())
+             return false;
+ 
+-        // TypedArrayObjects [[Set]] has special behavior.
+-        if (proto->is<TypedArrayObject>())
+-            return false;
+-
+         // We have to make sure the proto has no non-writable (frozen) elements
+         // because we're not allowed to shadow them. There are a few cases to
+         // consider:
+         //
+         // * If the proto is extensible, its Shape will change when it's made
+         //   non-extensible.
+         //
+         // * If the proto is already non-extensible, no new elements will be
+diff --git a/js/src/tests/non262/TypedArray/set-with-receiver.js b/js/src/tests/non262/TypedArray/set-with-receiver.js
+--- a/js/src/tests/non262/TypedArray/set-with-receiver.js
++++ b/js/src/tests/non262/TypedArray/set-with-receiver.js
+@@ -1,33 +1,28 @@
+ for (var constructor of anyTypedArrayConstructors) {
+-    var receiver = new Proxy({}, {
+-        getOwnPropertyDescriptor(p) {
+-            throw "fail";
+-        },
+-
+-        defineProperty() {
+-            throw "fail";
+-        }
+-    });
++    var receiver = {};
+ 
+     var ta = new constructor(1);
+     assertEq(Reflect.set(ta, 0, 47, receiver), true);
+-    assertEq(ta[0], 47);
++    assertEq(ta[0], 0);
++    assertEq(receiver[0], 47);
+ 
+     // Out-of-bounds
+-    assertEq(Reflect.set(ta, 10, 47, receiver), false);
++    assertEq(Reflect.set(ta, 10, 47, receiver), true);
+     assertEq(ta[10], undefined);
++    assertEq(receiver[10], 47);
+ 
+     // Detached
+     if (typeof detachArrayBuffer === "function" &&
+         !isSharedConstructor(constructor))
+     {
+         detachArrayBuffer(ta.buffer)
+ 
+         assertEq(ta[0], undefined);
+-        assertEq(Reflect.set(ta, 0, 47, receiver), false);
++        assertEq(Reflect.set(ta, 0, 42, receiver), true);
+         assertEq(ta[0], undefined);
++        assertEq(receiver[0], 42);
+     }
+ }
+ 
+ if (typeof reportCompare === "function")
+     reportCompare(true, true);
+diff --git a/js/src/vm/NativeObject.cpp b/js/src/vm/NativeObject.cpp
+--- a/js/src/vm/NativeObject.cpp
++++ b/js/src/vm/NativeObject.cpp
+@@ -1935,35 +1935,57 @@ js::NativeDefineDataProperty(JSContext* 
+ }
+ 
+ static bool
+ DefineNonexistentProperty(JSContext* cx, HandleNativeObject obj, HandleId id,
+                           HandleValue v, ObjectOpResult& result)
+ {
+     // Optimized NativeDefineProperty() version for known absent properties.
+ 
+-#ifdef DEBUG
+-    // Indexed properties of typed arrays should have been handled by SetTypedArrayElement.
+-    uint64_t index;
+-    MOZ_ASSERT_IF(obj->is<TypedArrayObject>(), !IsTypedArrayIndex(id, &index));
+-#endif
+-
+     // Dispense with custom behavior of exotic native objects first.
+     if (obj->is<ArrayObject>()) {
+         // Array's length property is non-configurable, so we shouldn't
+         // encounter it in this function.
+         MOZ_ASSERT(id != NameToId(cx->names().length));
+ 
+         // 9.4.2.1 step 3. Don't extend a fixed-length array.
+         uint32_t index;
+         if (IdIsIndex(id, &index)) {
+             if (WouldDefinePastNonwritableLength(&obj->as<ArrayObject>(), index))
+                 return result.fail(JSMSG_CANT_DEFINE_PAST_ARRAY_LENGTH);
+         }
+-    }  else if (obj->is<ArgumentsObject>()) {
++    } else if (obj->is<TypedArrayObject>()) {
++        // 9.4.5.5 step 2. Indexed properties of typed arrays are special.
++        uint64_t index;
++        if (IsTypedArrayIndex(id, &index)) {
++            // This method is only called for non-existent properties, which
++            // means any absent indexed property must be out of range.
++            MOZ_ASSERT(index >= obj->as<TypedArrayObject>().length());
++
++            // Steps 1-2 are enforced by the caller.
++
++            // Step 3.
++            // We still need to call ToNumber, because of its possible side
++            // effects.
++            double d;
++            if (!ToNumber(cx, v, &d)) {
++                return false;
++            }
++
++            // Steps 4-5.
++            // ToNumber may have detached the array buffer.
++            if (obj->as<TypedArrayObject>().hasDetachedBuffer()) {
++                return result.failSoft(JSMSG_TYPED_ARRAY_DETACHED);
++            }
++
++            // Steps 6-9.
++            // We (wrongly) ignore out of range defines.
++            return result.failSoft(JSMSG_BAD_INDEX);
++        }
++    } else if (obj->is<ArgumentsObject>()) {
+         // If this method is called with either |length| or |@@iterator|, the
+         // property was previously deleted and hence should already be marked
+         // as overridden.
+         MOZ_ASSERT_IF(id == NameToId(cx->names().length),
+                       obj->as<ArgumentsObject>().hasOverriddenLength());
+         MOZ_ASSERT_IF(JSID_IS_SYMBOL(id) && JSID_TO_SYMBOL(id) == cx->wellKnownSymbols().iterator,
+                       obj->as<ArgumentsObject>().hasOverriddenIterator());
+ 
+@@ -2703,25 +2725,31 @@ SetDenseElement(JSContext* cx, HandleNat
+  * dense or typed array element (i.e. not actually a pointer to a Shape).
+  */
+ static bool
+ SetExistingProperty(JSContext* cx, HandleId id, HandleValue v, HandleValue receiver,
+                     HandleNativeObject pobj, Handle<PropertyResult> prop, ObjectOpResult& result)
+ {
+     // Step 5 for dense elements.
+     if (prop.isDenseOrTypedArrayElement()) {
+-        MOZ_ASSERT(!pobj->is<TypedArrayObject>());
+-
+         // Step 5.a.
+         if (pobj->denseElementsAreFrozen())
+             return result.fail(JSMSG_READ_ONLY);
+ 
+         // Pure optimization for the common case:
+-        if (receiver.isObject() && pobj == &receiver.toObject())
+-            return SetDenseElement(cx, pobj, JSID_TO_INT(id), v, result);
++        if (receiver.isObject() && pobj == &receiver.toObject()) {
++            uint32_t index = JSID_TO_INT(id);
++
++            if (pobj->is<TypedArrayObject>()) {
++                Rooted<TypedArrayObject*> tobj(cx, &pobj->as<TypedArrayObject>());
++                return SetTypedArrayElement(cx, tobj, index, v, result);
++            }
++
++            return SetDenseElement(cx, pobj, index, v, result);
++        }
+ 
+         // Steps 5.b-f.
+         return SetPropertyByDefining(cx, id, v, receiver, result);
+     }
+ 
+     // Step 5 for all other properties.
+     RootedShape shape(cx, prop.shape());
+     if (shape->isDataDescriptor()) {
+@@ -2788,27 +2816,16 @@ js::NativeSetProperty(JSContext* cx, Han
+     // 4.c.i below. (There's a very similar loop in the NativeGetProperty
+     // implementation, but unfortunately not similar enough to common up.)
+     for (;;) {
+         // Steps 2-3. ('done' is a SpiderMonkey-specific thing, used below.)
+         bool done;
+         if (!LookupOwnPropertyInline<CanGC>(cx, pobj, id, &prop, &done))
+             return false;
+ 
+-        if (pobj->is<TypedArrayObject>()) {
+-            uint64_t index;
+-            if (IsTypedArrayIndex(id, &index)) {
+-                Rooted<TypedArrayObject*> tobj(cx, &pobj->as<TypedArrayObject>());
+-                return SetTypedArrayElement(cx, tobj, index, v, result);
+-            }
+-
+-            // This case should have been handled.
+-            MOZ_ASSERT(!prop.isDenseOrTypedArrayElement());
+-        }
+-
+         if (prop) {
+             // Steps 5-6.
+             return SetExistingProperty(cx, id, v, receiver, pobj, prop, result);
+         }
+ 
+         // Steps 4.a-b. The check for 'done' on this next line is tricky.
+         // done can be true in exactly these unlikely-sounding cases:
+         // - We're looking up an element, and pobj is a TypedArray that

+ 30 - 0
frg/work-js/mozilla-release/patches/1517237-66a1.patch

@@ -0,0 +1,30 @@
+# HG changeset patch
+# User Olli Pettay <Olli.Pettay@helsinki.fi>
+# Date 1546458272 -7200
+# Node ID b3acccbde849d18bf5302a545bc005a13e1a1432
+# Parent  c6a9481bc1d47a758d1da08331e2af1ed9dcee57
+Bug 1517237 - Make move assignment of RefPtr to have the same behavior as nsCOMPtr's, r=froydnj
+
+diff --git a/mfbt/RefPtr.h b/mfbt/RefPtr.h
+--- a/mfbt/RefPtr.h
++++ b/mfbt/RefPtr.h
+@@ -213,18 +213,17 @@ public:
+   }
+ 
+   RefPtr<T>& operator=(const nsQueryReferent& aQueryReferent);
+   RefPtr<T>& operator=(const nsCOMPtr_helper& aHelper);
+ 
+   RefPtr<T>&
+   operator=(RefPtr<T> && aRefPtr)
+   {
+-    assign_assuming_AddRef(aRefPtr.mRawPtr);
+-    aRefPtr.mRawPtr = nullptr;
++    assign_assuming_AddRef(aRefPtr.forget().take());
+     return *this;
+   }
+ 
+   // Defined in OwningNonNull.h
+   template<class U>
+   RefPtr<T>&
+   operator=(const mozilla::OwningNonNull<U>& aOther);
+ 

+ 4 - 4
frg/work-js/mozilla-release/patches/1730156-913.patch

@@ -2,7 +2,7 @@
 # User Eden Chuang <echuang@mozilla.com>
 # Date 1634136135 0
 # Node ID 1e024e57bb82cf8035e42807e658e95896cb64f8
-# Parent  dab59288009cc0ba692c4f544992c994713cf79e
+# Parent  1f182cf707a39cfad3161258303a6fb1a43c2039
 Bug 1730156 - Do not create DispatchChangeEventCallback if associated HTMLInputElement has no scriptGlobalObject. r=smaug, a=RyanVM
 
 Differential Revision: https://phabricator.services.mozilla.com/D126095
@@ -10,7 +10,7 @@ Differential Revision: https://phabricator.services.mozilla.com/D126095
 diff --git a/dom/html/HTMLInputElement.cpp b/dom/html/HTMLInputElement.cpp
 --- a/dom/html/HTMLInputElement.cpp
 +++ b/dom/html/HTMLInputElement.cpp
-@@ -240,19 +240,27 @@ public:
+@@ -241,19 +241,27 @@ public:
      : mInputElement(aInputElement)
    {
      MOZ_ASSERT(aInputElement);
@@ -38,7 +38,7 @@ diff --git a/dom/html/HTMLInputElement.cpp b/dom/html/HTMLInputElement.cpp
    }
  
    nsresult
-@@ -679,16 +687,21 @@ HTMLInputElement::nsFilePickerShownCallb
+@@ -680,16 +688,21 @@ HTMLInputElement::nsFilePickerShownCallb
        mInput->OwnerDoc(), lastUsedDir);
    }
  
@@ -55,7 +55,7 @@ diff --git a/dom/html/HTMLInputElement.cpp b/dom/html/HTMLInputElement.cpp
    RefPtr<DispatchChangeEventCallback> dispatchChangeEventCallback =
      new DispatchChangeEventCallback(mInput);
  
-   if (IsWebkitDirPickerEnabled() &&
+   if (DOMPrefs::WebkitBlinkDirectoryPickerEnabled() &&
        mInput->HasAttr(kNameSpaceID_None, nsGkAtoms::webkitdirectory)) {
      ErrorResult error;
      GetFilesHelper* helper = mInput->GetOrCreateGetFilesHelper(true, error);

+ 46 - 0
frg/work-js/mozilla-release/patches/1871112-124a1.patch

@@ -0,0 +1,46 @@
+# HG changeset patch
+# User Tom Schuster <tschuster@mozilla.com>
+# Date 1707915342 0
+# Node ID 12e5815ccf55470884c97422356d765c37aaeb2c
+# Parent  bdeb1b5088193969288d344b7491287e4cc5c5e4
+Bug 1871112 - Specialize AddAttributes for <html>/<body>. r=hsivonen
+
+Differential Revision: https://phabricator.services.mozilla.com/D201562
+
+diff --git a/parser/html/nsHtml5TreeOperation.cpp b/parser/html/nsHtml5TreeOperation.cpp
+--- a/parser/html/nsHtml5TreeOperation.cpp
++++ b/parser/html/nsHtml5TreeOperation.cpp
+@@ -298,29 +298,32 @@ nsHtml5TreeOperation::FosterParent(nsICo
+   return Append(aNode, aParent, aBuilder);
+ }
+ 
+ nsresult
+ nsHtml5TreeOperation::AddAttributes(nsIContent* aNode,
+                                     nsHtml5HtmlAttributes* aAttributes,
+                                     nsHtml5DocumentBuilder* aBuilder)
+ {
++  MOZ_ASSERT(aNode->IsAnyOfHTMLElements(nsGkAtoms::body, nsGkAtoms::html));
++
+   dom::Element* node = aNode->AsElement();
+   nsHtml5OtherDocUpdate update(node->OwnerDoc(),
+                                aBuilder->GetDocument());
+ 
+   int32_t len = aAttributes->getLength();
+   for (int32_t i = len; i > 0;) {
+     --i;
+     // prefix doesn't need regetting. it is always null or a static atom
+     // local name is never null
+     nsCOMPtr<nsIAtom> localName =
+       Reget(aAttributes->getLocalNameNoBoundsCheck(i));
+     int32_t nsuri = aAttributes->getURINoBoundsCheck(i);
+-    if (!node->HasAttr(nsuri, localName)) {
++    if (!node->HasAttr(nsuri, localName) &&
++        !(nsuri == kNameSpaceID_None && localName == nsGkAtoms::nonce)) {
+       // prefix doesn't need regetting. it is always null or a static atom
+       // local name is never null
+       nsString value; // Not Auto, because using it to hold nsStringBuffer*
+       aAttributes->getValueNoBoundsCheck(i).ToString(value);
+       node->SetAttr(
+         nsuri, localName, aAttributes->getPrefixNoBoundsCheck(i), value, true);
+       // XXX what to do with nsresult?
+     }

+ 5 - 5
frg/work-js/mozilla-release/patches/888600-1only-61a1.patch

@@ -2,7 +2,7 @@
 # User Peter Van der Beken <peterv@propagandism.org>
 # Date 1500469454 -7200
 # Node ID a3a9ad856fc9be5962d7d275c1123cfef848086d
-# Parent  0ae03c67ad1bc2a1aab2e235540c53591d61dd01
+# Parent  0c1e28c8c9e8affcdf6a2667b0e3c3b3f88fb4a7
 Bug 888600 - Move ContentFrameMessageManager to WebIDL. Part 1: Add infrastructure to expose 'system' names on a WebIDL global. r=bz.
 
 diff --git a/dom/bindings/BindingUtils.h b/dom/bindings/BindingUtils.h
@@ -258,7 +258,7 @@ diff --git a/dom/bindings/Codegen.py b/dom/bindings/Codegen.py
          names.append((desc.name, desc))
          names.extend((n.identifier.name, desc) for n in desc.interface.namedConstructors)
      return names
-@@ -17510,32 +17576,68 @@ class GlobalGenRoots():
+@@ -17561,32 +17627,68 @@ class GlobalGenRoots():
          # Add include guards.
          curr = CGIncludeGuard('RegisterWorkletBindings', curr)
  
@@ -419,13 +419,13 @@ diff --git a/dom/bindings/WebIDLGlobalNameHash.h b/dom/bindings/WebIDLGlobalName
 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
-@@ -20,16 +20,17 @@
- 
+@@ -21,16 +21,17 @@
  #include "WrapperFactory.h"
  #include "AccessCheck.h"
  
  #include "mozilla/dom/BindingUtils.h"
  #include "mozilla/dom/DOMException.h"
+ #include "mozilla/dom/DOMPrefs.h"
  #include "mozilla/dom/Exceptions.h"
  #include "mozilla/dom/Promise.h"
 +#include "mozilla/dom/ResolveSystemBinding.h"
@@ -437,7 +437,7 @@ diff --git a/js/xpconnect/src/nsXPConnect.cpp b/js/xpconnect/src/nsXPConnect.cpp
  #include "nsIObjectOutputStream.h"
  #include "nsScriptSecurityManager.h"
  #include "nsIPermissionManager.h"
-@@ -576,16 +577,20 @@ InitClassesWithNewWrappedGlobal(JSContex
+@@ -577,16 +578,20 @@ InitClassesWithNewWrappedGlobal(JSContex
  {
      MOZ_ASSERT(aJSContext, "bad param");
      MOZ_ASSERT(aCOMObj, "bad param");

+ 0 - 0
frg/work-js/mozilla-release/patches/mozilla-central-push_429322.patch → frg/work-js/mozilla-release/patches/NOBUG-20180731-jorendb-63a1.patch


+ 10 - 10
frg/work-js/mozilla-release/patches/TOP-NOBUG-JSFIXUPS-25319.patch

@@ -1,7 +1,7 @@
 # HG changeset patch
 # User Frank-Rainer Grahl <frgrahl@gmx.net>
 # Date 1709405564 -3600
-# Parent  b897499da25827e88d19c778472a5f59c3641de6
+# Parent  aefc6f76980421dd7ba7085e5d80653c150febde
 No Bug - Fix js compartment to realm stuff for legacy behavior and others. r=me a=me
 
  - Undo removing obj from SetExistingProperty in Bug 1471841.
@@ -12,7 +12,7 @@ No Bug - Fix js compartment to realm stuff for legacy behavior and others. r=me
  - nsFrameMessageManager global fixup needed pre Bug 888600.
  - EventListenerManager fallout from Bug 1473587 because Bug 1418236 is missing.
  - Promise CheckedUnwrapStatic missing Bug 1521907.
- 
+
 diff --git a/dom/base/nsFrameMessageManager.cpp b/dom/base/nsFrameMessageManager.cpp
 --- a/dom/base/nsFrameMessageManager.cpp
 +++ b/dom/base/nsFrameMessageManager.cpp
@@ -82,7 +82,7 @@ diff --git a/dom/events/EventListenerManager.cpp b/dom/events/EventListenerManag
 diff --git a/js/src/builtin/Promise.cpp b/js/src/builtin/Promise.cpp
 --- a/js/src/builtin/Promise.cpp
 +++ b/js/src/builtin/Promise.cpp
-@@ -2907,17 +2907,17 @@ static MOZ_MUST_USE bool PerformPromiseA
+@@ -2909,17 +2909,17 @@ static MOZ_MUST_USE bool PerformPromiseA
  
    // Step 3.
    // See the big comment in PerformPromiseAll about which objects should be
@@ -104,7 +104,7 @@ diff --git a/js/src/builtin/Promise.cpp b/js/src/builtin/Promise.cpp
 diff --git a/js/src/vm/NativeObject.cpp b/js/src/vm/NativeObject.cpp
 --- a/js/src/vm/NativeObject.cpp
 +++ b/js/src/vm/NativeObject.cpp
-@@ -2739,18 +2739,19 @@ SetDenseElement(JSContext* cx, HandleNat
+@@ -2720,18 +2720,19 @@ SetDenseElement(JSContext* cx, HandleNat
   * Finish the assignment `receiver[id] = v` when an existing property (shape)
   * has been found on a native object (pobj). This implements ES6 draft rev 32
   * (2015 Feb 2) 9.1.9 steps 5 and 6.
@@ -121,12 +121,12 @@ diff --git a/js/src/vm/NativeObject.cpp b/js/src/vm/NativeObject.cpp
  {
      // Step 5 for dense elements.
      if (prop.isDenseOrTypedArrayElement()) {
-         // TypedArray [[Set]] ignores the receiver completely.
-         if (pobj->is<TypedArrayObject>()) {
-             Rooted<TypedArrayObject*> tobj(cx, &pobj->as<TypedArrayObject>());
-             return SetTypedArrayElement(cx, tobj, JSID_TO_INT(id), v, result);
-         }
-@@ -2835,17 +2836,17 @@ js::NativeSetProperty(JSContext* cx, Han
+         // Step 5.a.
+         if (pobj->denseElementsAreFrozen())
+             return result.fail(JSMSG_READ_ONLY);
+ 
+         // Pure optimization for the common case:
+@@ -2818,17 +2819,17 @@ js::NativeSetProperty(JSContext* cx, Han
      for (;;) {
          // Steps 2-3. ('done' is a SpiderMonkey-specific thing, used below.)
          bool done;

+ 1 - 1
frg/work-js/mozilla-release/patches/mozilla-central-push_427183.patch

@@ -1,5 +1,5 @@
 # HG changeset patch
-# User Naz?m Can Alt?nova <canaltinova@gmail.com>
+# User Nazim Can Altinova <canaltinova@gmail.com>
 # Date 1531217995 -7200
 #      Tue Jul 10 12:19:55 2018 +0200
 # Node ID 3d91c1c4d250cd5cd1581c1cd67632661dab8017

+ 0 - 70
frg/work-js/mozilla-release/patches/mozilla-central-push_429300.patch

@@ -1,70 +0,0 @@
-# HG changeset patch
-# User Jeff Walden <jwalden@mit.edu>
-# Date 1532574661 25200
-#      Wed Jul 25 20:11:01 2018 -0700
-# Node ID bb0dd8b2d4e2cb93766120a7ef82746892639f26
-# Parent  8d4b0cb363a4d1faf88d33d23d7a64746f725692
-Bug 1478587 - Invoke TokenStreamChars::getNonAsciiCodePointDontNormalize passing CharT lead (not int32_t).  r=arai
-
-diff --git a/js/src/frontend/TokenStream.cpp b/js/src/frontend/TokenStream.cpp
---- a/js/src/frontend/TokenStream.cpp
-+++ b/js/src/frontend/TokenStream.cpp
-@@ -1823,17 +1823,17 @@ TokenStreamSpecific<CharT, AnyCharsAcces
-             }
- 
-             if (unit != '\\' || !matchUnicodeEscapeIdent(&codePoint))
-                 break;
-         } else {
-             // |restoreNextRawCharAddress| undoes all gets, and this function
-             // doesn't update line/column info.
-             char32_t cp;
--            if (!getNonAsciiCodePointDontNormalize(unit, &cp))
-+            if (!getNonAsciiCodePointDontNormalize(toCharT(unit), &cp))
-                 return false;
- 
-             codePoint = cp;
-             if (!unicode::IsIdentifierPart(codePoint))
-                 break;
-         }
- 
-         if (!appendCodePointToCharBuffer(codePoint))
-@@ -2146,17 +2146,17 @@ TokenStreamSpecific<CharT, AnyCharsAcces
-     MOZ_ASSERT(this->sourceUnits.previousCodeUnit() == '/');
-     this->charBuffer.clear();
- 
-     auto ProcessNonAsciiCodePoint = [this](int32_t lead) {
-         MOZ_ASSERT(lead != EOF);
-         MOZ_ASSERT(!this->isAsciiCodePoint(lead));
- 
-         char32_t codePoint;
--        if (!this->getNonAsciiCodePointDontNormalize(lead, &codePoint))
-+        if (!this->getNonAsciiCodePointDontNormalize(this->toCharT(lead), &codePoint))
-             return false;
- 
-         if (MOZ_UNLIKELY(codePoint == unicode::LINE_SEPARATOR ||
-                          codePoint == unicode::PARA_SEPARATOR))
-         {
-             this->sourceUnits.ungetLineOrParagraphSeparator();
-             this->reportError(JSMSG_UNTERMINATED_REGEXP);
-             return false;
-diff --git a/js/src/frontend/TokenStream.h b/js/src/frontend/TokenStream.h
---- a/js/src/frontend/TokenStream.h
-+++ b/js/src/frontend/TokenStream.h
-@@ -2310,16 +2310,17 @@ class MOZ_STACK_CLASS TokenStreamSpecifi
-     using GeneralCharsBase::matchUnicodeEscapeIdStart;
-     using GeneralCharsBase::newAtomToken;
-     using GeneralCharsBase::newNameToken;
-     using GeneralCharsBase::newNumberToken;
-     using GeneralCharsBase::newRegExpToken;
-     using GeneralCharsBase::newSimpleToken;
-     using CharsBase::peekCodeUnit;
-     // Deliberately don't |using| |sourceUnits| because of bug 1472569.  :-(
-+    using CharsBase::toCharT;
-     using GeneralCharsBase::ungetCodeUnit;
-     using GeneralCharsBase::updateLineInfoForEOL;
- 
-     template<typename CharU> friend class TokenStreamPosition;
- 
-   public:
-     TokenStreamSpecific(JSContext* cx, const ReadOnlyCompileOptions& options,
-                         const CharT* base, size_t length);

+ 0 - 56
frg/work-js/mozilla-release/patches/mozilla-central-push_429301.patch

@@ -1,56 +0,0 @@
-# HG changeset patch
-# User Jeff Walden <jwalden@mit.edu>
-# Date 1532574665 25200
-#      Wed Jul 25 20:11:05 2018 -0700
-# Node ID d3595d3fd0c0e39c94d7cba5043c28be216b29a0
-# Parent  bb0dd8b2d4e2cb93766120a7ef82746892639f26
-Bug 1478587 - Implement correct handling of Unicode line/paragraph separators in template/string literals for UTF-8.  r=arai
-
-diff --git a/js/src/frontend/TokenStream.cpp b/js/src/frontend/TokenStream.cpp
---- a/js/src/frontend/TokenStream.cpp
-+++ b/js/src/frontend/TokenStream.cpp
-@@ -2810,36 +2810,32 @@ TokenStreamSpecific<CharT, AnyCharsAcces
-             return false;
-         }
- 
-         // Non-ASCII code points are always directly appended -- even
-         // U+2028 LINE SEPARATOR and U+2029 PARAGRAPH SEPARATOR that are
-         // ordinarily LineTerminatorSequences.  (They contribute their literal
-         // values to template and [as of recently] string literals, but they're
-         // line terminators when computing line/column coordinates.)  Handle
--        // the non-ASCI case early for readability.
-+        // the non-ASCII case early for readability.
-         if (MOZ_UNLIKELY(!isAsciiCodePoint(unit))) {
--            static_assert(mozilla::IsSame<CharT, char16_t>::value,
--                          "need a getNonAsciiCodePoint that doesn't normalize "
--                          "LineTerminatorSequences to correctly handle UTF-8");
--
--            int32_t codePoint;
--            if (unit == unicode::LINE_SEPARATOR || unit == unicode::PARA_SEPARATOR) {
-+            char32_t cp;
-+            if (!getNonAsciiCodePointDontNormalize(toCharT(unit), &cp))
-+                return false;
-+
-+            if (MOZ_UNLIKELY(cp == unicode::LINE_SEPARATOR || cp == unicode::PARA_SEPARATOR)) {
-                 if (!updateLineInfoForEOL())
-                     return false;
- 
-                 anyCharsAccess().updateFlagsForEOL();
--
--                codePoint = unit;
-             } else {
--                if (!getNonAsciiCodePoint(unit, &codePoint))
--                    return false;
-+                MOZ_ASSERT(!IsLineTerminator(cp));
-             }
- 
--            if (!appendCodePointToCharBuffer(codePoint))
-+            if (!appendCodePointToCharBuffer(cp))
-                 return false;
- 
-             continue;
-         }
- 
-         if (unit == '\\') {
-             // When parsing templates, we don't immediately report errors for
-             // invalid escapes; these are handled by the parser.  We don't

+ 0 - 30
frg/work-js/mozilla-release/patches/mozilla-central-push_429302.patch

@@ -1,30 +0,0 @@
-# HG changeset patch
-# User Jeff Walden <jwalden@mit.edu>
-# Date 1532574668 25200
-#      Wed Jul 25 20:11:08 2018 -0700
-# Node ID 805445fc768f0159334f0e066f62c543be14c2d8
-# Parent  d3595d3fd0c0e39c94d7cba5043c28be216b29a0
-Bug 1478587 - Return the result of CodeUnitValue(), not a CharT, from GeneralTokenStreamChars::getCodeUnit.  r=arai
-
-diff --git a/js/src/frontend/TokenStream.h b/js/src/frontend/TokenStream.h
---- a/js/src/frontend/TokenStream.h
-+++ b/js/src/frontend/TokenStream.h
-@@ -1920,17 +1920,17 @@ class GeneralTokenStreamChars
-      *
-      * Because of these limitations, only use this if (a) the resulting code
-      * unit is guaranteed to be ungotten (by ungetCodeUnit()) if it's an EOL,
-      * and (b) the line-related state (lineno, linebase) is not used before
-      * it's ungotten.
-      */
-     int32_t getCodeUnit() {
-         if (MOZ_LIKELY(!this->sourceUnits.atEnd()))
--            return this->sourceUnits.getCodeUnit();
-+            return CodeUnitValue(this->sourceUnits.getCodeUnit());
- 
-         anyCharsAccess().flags.isEOF = true;
-         return EOF;
-     }
- 
-     void ungetCodeUnit(int32_t c) {
-         MOZ_ASSERT_IF(c == EOF, anyCharsAccess().flags.isEOF);
- 

+ 0 - 157
frg/work-js/mozilla-release/patches/mozilla-central-push_429303.patch

@@ -1,157 +0,0 @@
-# HG changeset patch
-# User Jeff Walden <jwalden@mit.edu>
-# Date 1532574672 25200
-#      Wed Jul 25 20:11:12 2018 -0700
-# Node ID 70b1c176aa7b029b02c64e6dd075b0f4941f038b
-# Parent  805445fc768f0159334f0e066f62c543be14c2d8
-Bug 1478587 - Add CharT casts when comparing code units to particular ASCII characters.  r=arai
-
-diff --git a/js/src/frontend/TokenStream.cpp b/js/src/frontend/TokenStream.cpp
---- a/js/src/frontend/TokenStream.cpp
-+++ b/js/src/frontend/TokenStream.cpp
-@@ -1489,48 +1489,48 @@ TokenStreamSpecific<CharT, AnyCharsAcces
- // We have encountered a '\': check for a Unicode escape sequence after it.
- // Return the length of the escape sequence and the encoded code point (by
- // value) if we found a Unicode escape sequence, and skip all code units
- // involed.  Otherwise, return 0 and don't advance along the buffer.
- template<typename CharT, class AnyCharsAccess>
- uint32_t
- GeneralTokenStreamChars<CharT, AnyCharsAccess>::matchUnicodeEscape(uint32_t* codePoint)
- {
--    MOZ_ASSERT(this->sourceUnits.previousCodeUnit() == '\\');
-+    MOZ_ASSERT(this->sourceUnits.previousCodeUnit() == CharT('\\'));
- 
-     int32_t unit = getCodeUnit();
-     if (unit != 'u') {
-         // NOTE: |unit| may be EOF here.
-         ungetCodeUnit(unit);
--        MOZ_ASSERT(this->sourceUnits.previousCodeUnit() == '\\');
-+        MOZ_ASSERT(this->sourceUnits.previousCodeUnit() == CharT('\\'));
-         return 0;
-     }
- 
-     char16_t v;
-     unit = getCodeUnit();
-     if (JS7_ISHEX(unit) && this->sourceUnits.matchHexDigits(3, &v)) {
-         *codePoint = (JS7_UNHEX(unit) << 12) | v;
-         return 5;
-     }
- 
-     if (unit == '{')
-         return matchExtendedUnicodeEscape(codePoint);
- 
-     // NOTE: |unit| may be EOF here, so this ungets either one or two units.
-     ungetCodeUnit(unit);
-     ungetCodeUnit('u');
--    MOZ_ASSERT(this->sourceUnits.previousCodeUnit() == '\\');
-+    MOZ_ASSERT(this->sourceUnits.previousCodeUnit() == CharT('\\'));
-     return 0;
- }
- 
- template<typename CharT, class AnyCharsAccess>
- uint32_t
- GeneralTokenStreamChars<CharT, AnyCharsAccess>::matchExtendedUnicodeEscape(uint32_t* codePoint)
- {
--    MOZ_ASSERT(this->sourceUnits.previousCodeUnit() == '{');
-+    MOZ_ASSERT(this->sourceUnits.previousCodeUnit() == CharT('{'));
- 
-     int32_t unit = getCodeUnit();
- 
-     // Skip leading zeroes.
-     uint32_t leadingZeroes = 0;
-     while (unit == '0') {
-         leadingZeroes++;
-         unit = getCodeUnit();
-@@ -1551,49 +1551,49 @@ GeneralTokenStreamChars<CharT, AnyCharsA
-         (unit != EOF); // subtract a get if it didn't contribute to length
- 
-     if (unit == '}' && (leadingZeroes > 0 || i > 0) && code <= unicode::NonBMPMax) {
-         *codePoint = code;
-         return gotten;
-     }
- 
-     this->sourceUnits.unskipCodeUnits(gotten);
--    MOZ_ASSERT(this->sourceUnits.previousCodeUnit() == '\\');
-+    MOZ_ASSERT(this->sourceUnits.previousCodeUnit() == CharT('\\'));
-     return 0;
- }
- 
- template<typename CharT, class AnyCharsAccess>
- uint32_t
- GeneralTokenStreamChars<CharT, AnyCharsAccess>::matchUnicodeEscapeIdStart(uint32_t* codePoint)
- {
-     uint32_t length = matchUnicodeEscape(codePoint);
-     if (MOZ_LIKELY(length > 0)) {
-         if (MOZ_LIKELY(unicode::IsIdentifierStart(*codePoint)))
-             return length;
- 
-         this->sourceUnits.unskipCodeUnits(length);
-     }
- 
--    MOZ_ASSERT(this->sourceUnits.previousCodeUnit() == '\\');
-+    MOZ_ASSERT(this->sourceUnits.previousCodeUnit() == CharT('\\'));
-     return 0;
- }
- 
- template<typename CharT, class AnyCharsAccess>
- bool
- GeneralTokenStreamChars<CharT, AnyCharsAccess>::matchUnicodeEscapeIdent(uint32_t* codePoint)
- {
-     uint32_t length = matchUnicodeEscape(codePoint);
-     if (MOZ_LIKELY(length > 0)) {
-         if (MOZ_LIKELY(unicode::IsIdentifierPart(*codePoint)))
-             return true;
- 
-         this->sourceUnits.unskipCodeUnits(length);
-     }
- 
--    MOZ_ASSERT(this->sourceUnits.previousCodeUnit() == '\\');
-+    MOZ_ASSERT(this->sourceUnits.previousCodeUnit() == CharT('\\'));
-     return false;
- }
- 
- template<typename CharT, class AnyCharsAccess>
- bool
- TokenStreamSpecific<CharT, AnyCharsAccess>::getDirectives(bool isMultiline,
-                                                           bool shouldWarnDeprecated)
- {
-@@ -2138,17 +2138,17 @@ TokenStreamSpecific<CharT, AnyCharsAcces
-     newNumberToken(dval, decimalPoint, start, modifier, out);
-     return true;
- }
- 
- template<typename CharT, class AnyCharsAccess>
- MOZ_MUST_USE bool
- TokenStreamSpecific<CharT, AnyCharsAccess>::regexpLiteral(TokenStart start, TokenKind* out)
- {
--    MOZ_ASSERT(this->sourceUnits.previousCodeUnit() == '/');
-+    MOZ_ASSERT(this->sourceUnits.previousCodeUnit() == CharT('/'));
-     this->charBuffer.clear();
- 
-     auto ProcessNonAsciiCodePoint = [this](int32_t lead) {
-         MOZ_ASSERT(lead != EOF);
-         MOZ_ASSERT(!this->isAsciiCodePoint(lead));
- 
-         char32_t codePoint;
-         if (!this->getNonAsciiCodePointDontNormalize(this->toCharT(lead), &codePoint))
-@@ -2783,18 +2783,18 @@ TokenStreamSpecific<CharT, AnyCharsAcces
-     auto noteBadToken = MakeScopeExit([this]() {
-         this->badToken();
-     });
- 
-     auto ReportPrematureEndOfLiteral = [this, untilChar](unsigned errnum) {
-         // Unicode separators aren't end-of-line in template or (as of
-         // recently) string literals, so this assertion doesn't allow them.
-         MOZ_ASSERT(this->sourceUnits.atEnd() ||
--                   this->sourceUnits.peekCodeUnit() == '\r' ||
--                   this->sourceUnits.peekCodeUnit() == '\n',
-+                   this->sourceUnits.peekCodeUnit() == CharT('\r') ||
-+                   this->sourceUnits.peekCodeUnit() == CharT('\n'),
-                    "must be parked at EOF or EOL to call this function");
- 
-         // The various errors reported here include language like "in a ''
-         // literal" or similar, with '' being '', "", or `` as appropriate.
-         const char delimiters[] = { untilChar, untilChar, '\0' };
- 
-         this->error(errnum, delimiters);
-         return;

+ 0 - 92
frg/work-js/mozilla-release/patches/mozilla-central-push_429304.patch

@@ -1,92 +0,0 @@
-# HG changeset patch
-# User Jeff Walden <jwalden@mit.edu>
-# Date 1532574675 25200
-#      Wed Jul 25 20:11:15 2018 -0700
-# Node ID caaac3580bd799e95faf9d215c5b6bd5ed3917a5
-# Parent  70b1c176aa7b029b02c64e6dd075b0f4941f038b
-Bug 1478587 - Switch on the numeric type underlying CharT, not on CharT itself, in a couple switches in TokenStreamSpecific::getTokenInternal.  r=arai
-
-diff --git a/js/src/frontend/TokenStream.cpp b/js/src/frontend/TokenStream.cpp
---- a/js/src/frontend/TokenStream.cpp
-+++ b/js/src/frontend/TokenStream.cpp
-@@ -2538,17 +2538,20 @@ TokenStreamSpecific<CharT, AnyCharsAcces
-         // creation code for all such tokens.  All other tokens must be handled
-         // by returning (or by continuing from the loop enclosing this).
-         //
-         TokenStart start(this->sourceUnits, -1);
-         TokenKind simpleKind;
- #ifdef DEBUG
-         simpleKind = TokenKind::Limit; // sentinel value for code after switch
- #endif
--        switch (static_cast<CharT>(unit)) {
-+
-+        // The block a ways above eliminated all non-ASCII, so cast to the
-+        // smallest type possible to assist the C++ compiler.
-+        switch (AssertedCast<uint8_t>(CodeUnitValue(toCharT(unit)))) {
-           case '.':
-             unit = getCodeUnit();
-             if (IsAsciiDigit(unit)) {
-                 return decimalNumber('.', start, this->sourceUnits.addressOfNextCodeUnit() - 2,
-                                      modifier, ttp);
-             }
- 
-             if (unit == '.') {
-@@ -2747,17 +2750,17 @@ TokenStreamSpecific<CharT, AnyCharsAcces
-             break;
- 
-           default:
-             // We consumed a bad ASCII code point/unit.  Put it back so the
-             // error location is the bad code point.
-             ungetCodeUnit(unit);
-             error(JSMSG_ILLEGAL_CHARACTER);
-             return badToken();
--        } // switch (static_cast<CharT>(unit))
-+        } // switch (AssertedCast<uint8_t>(CodeUnitValue(toCharT(unit))))
- 
-         MOZ_ASSERT(simpleKind != TokenKind::Limit,
-                    "switch-statement should have set |simpleKind| before "
-                    "breaking");
- 
-         newSimpleToken(simpleKind, start, modifier, ttp);
-         return true;
-     } while (true);
-@@ -2860,17 +2863,19 @@ TokenStreamSpecific<CharT, AnyCharsAcces
-                 if (codePoint != '\n') {
-                     if (!this->charBuffer.append(unit))
-                         return false;
-                 }
- 
-                 continue;
-             }
- 
--            switch (static_cast<CharT>(unit)) {
-+            // The block above eliminated all non-ASCII, so cast to the
-+            // smallest type possible to assist the C++ compiler.
-+            switch (AssertedCast<uint8_t>(CodeUnitValue(toCharT(unit)))) {
-               case 'b': unit = '\b'; break;
-               case 'f': unit = '\f'; break;
-               case 'n': unit = '\n'; break;
-               case 'r': unit = '\r'; break;
-               case 't': unit = '\t'; break;
-               case 'v': unit = '\v'; break;
- 
-               case '\r':
-@@ -3057,17 +3062,17 @@ TokenStreamSpecific<CharT, AnyCharsAcces
-                         else
-                             val = save;
-                     }
-                 }
- 
-                 unit = char16_t(val);
-                 break;
-               } // default
--            }
-+            } // switch (AssertedCast<uint8_t>(CodeUnitValue(toCharT(unit))))
- 
-             if (!this->charBuffer.append(unit))
-                 return false;
- 
-             continue;
-         } // (unit == '\\')
- 
-         if (unit == '\r' || unit == '\n') {

+ 0 - 30
frg/work-js/mozilla-release/patches/mozilla-central-push_429305.patch

@@ -1,30 +0,0 @@
-# HG changeset patch
-# User Jeff Walden <jwalden@mit.edu>
-# Date 1532574678 25200
-#      Wed Jul 25 20:11:18 2018 -0700
-# Node ID 8f8857dc9348ff0249a8d2dea82fd0915ff8f5b3
-# Parent  caaac3580bd799e95faf9d215c5b6bd5ed3917a5
-Bug 1478587 - Make ReportUnterminatedRegExp accept an int32_t unit, not a CharT unit.  r=arai
-
-diff --git a/js/src/frontend/TokenStream.cpp b/js/src/frontend/TokenStream.cpp
---- a/js/src/frontend/TokenStream.cpp
-+++ b/js/src/frontend/TokenStream.cpp
-@@ -2160,17 +2160,17 @@ TokenStreamSpecific<CharT, AnyCharsAcces
-             this->sourceUnits.ungetLineOrParagraphSeparator();
-             this->reportError(JSMSG_UNTERMINATED_REGEXP);
-             return false;
-         }
- 
-         return this->appendCodePointToCharBuffer(codePoint);
-     };
- 
--    auto ReportUnterminatedRegExp = [this](CharT unit) {
-+    auto ReportUnterminatedRegExp = [this](int32_t unit) {
-         this->ungetCodeUnit(unit);
-         this->error(JSMSG_UNTERMINATED_REGEXP);
-     };
- 
-     bool inCharClass = false;
-     do {
-         int32_t unit = getCodeUnit();
-         if (unit == EOF) {

+ 0 - 45
frg/work-js/mozilla-release/patches/mozilla-central-push_429307.patch

@@ -1,45 +0,0 @@
-# HG changeset patch
-# User Jeff Walden <jwalden@mit.edu>
-# Date 1532574682 25200
-#      Wed Jul 25 20:11:22 2018 -0700
-# Node ID f1de95a9cc69d06197a37fda8f49dc822dc5e16f
-# Parent  aa240ce556588cbf9439b6f48a892efe6fa01c65
-Bug 1478587 - Make FindReservedWord work for CharT=Utf8Unit.  r=arai
-
-diff --git a/js/src/frontend/TokenStream.cpp b/js/src/frontend/TokenStream.cpp
---- a/js/src/frontend/TokenStream.cpp
-+++ b/js/src/frontend/TokenStream.cpp
-@@ -94,25 +94,32 @@ FindReservedWord(const CharT* s, size_t 
- 
-   got_match:
-     return &reservedWords[i];
- 
-   test_guess:
-     rw = &reservedWords[i];
-     chars = rw->chars;
-     do {
--        if (*s++ != (unsigned char)(*chars++))
-+        if (*s++ != static_cast<unsigned char>(*chars++))
-             goto no_match;
-     } while (--length != 0);
-     return rw;
- 
-   no_match:
-     return nullptr;
- }
- 
-+template <>
-+MOZ_ALWAYS_INLINE const ReservedWordInfo*
-+FindReservedWord<Utf8Unit>(const Utf8Unit* units, size_t length)
-+{
-+    return FindReservedWord(Utf8AsUnsignedChars(units), length);
-+}
-+
- static const ReservedWordInfo*
- FindReservedWord(JSLinearString* str)
- {
-     JS::AutoCheckCannotGC nogc;
-     return str->hasLatin1Chars()
-            ? FindReservedWord(str->latin1Chars(nogc), str->length())
-            : FindReservedWord(str->twoByteChars(nogc), str->length());
- }

+ 0 - 364
frg/work-js/mozilla-release/patches/mozilla-central-push_429308.patch

@@ -1,364 +0,0 @@
-# HG changeset patch
-# User Jeff Walden <jwalden@mit.edu>
-# Date 1532574685 25200
-#      Wed Jul 25 20:11:25 2018 -0700
-# Node ID 69a4d421088167f1baf44a9df12fcc705b1df3eb
-# Parent  f1de95a9cc69d06197a37fda8f49dc822dc5e16f
-Bug 1478587 - Make number-parsing functions deal with UTF-8 input.  r=arai
-
-diff --git a/js/src/frontend/TokenStream.cpp b/js/src/frontend/TokenStream.cpp
---- a/js/src/frontend/TokenStream.cpp
-+++ b/js/src/frontend/TokenStream.cpp
-@@ -2108,19 +2108,21 @@ TokenStreamSpecific<CharT, AnyCharsAcces
-             // Consume exponential digits.
-             do {
-                 unit = getCodeUnit();
-             } while (IsAsciiDigit(unit));
-         }
- 
-         ungetCodeUnit(unit);
- 
--        const CharT* dummy;
--        if (!js_strtod(anyCharsAccess().cx, numStart, this->sourceUnits.addressOfNextCodeUnit(),
--                       &dummy, &dval))
-+        // "0." and "0e..." numbers parse "." or "e..." here.  Neither range
-+        // contains a number, so we can't use |FullStringToDouble|.  (Parse
-+        // failures return 0.0, so we'll still get the right result.)
-+        if (!StringToDouble(anyCharsAccess().cx,
-+                            numStart, this->sourceUnits.addressOfNextCodeUnit(), &dval))
-         {
-            return false;
-         }
-     }
- 
-     // Number followed by IdentifierStart is an error.  (This is the only place
-     // in ECMAScript where token boundary is inadequate to properly separate
-     // two tokens, necessitating this unaesthetic lookahead.)
-@@ -2522,23 +2524,21 @@ TokenStreamSpecific<CharT, AnyCharsAcces
-                 PeekedCodePoint<CharT> peeked = this->sourceUnits.peekCodePoint();
-                 if (!peeked.isNone() && unicode::IsIdentifierStart(peeked.codePoint())) {
-                     error(JSMSG_IDSTART_AFTER_NUMBER);
-                     return badToken();
-                 }
-             }
- 
-             double dval;
--            const char16_t* dummy;
--            if (!GetPrefixInteger(anyCharsAccess().cx, numStart,
--                                  this->sourceUnits.addressOfNextCodeUnit(), radix, &dummy, &dval))
-+            if (!GetFullInteger(anyCharsAccess().cx, numStart,
-+                                this->sourceUnits.addressOfNextCodeUnit(), radix, &dval))
-             {
-                 return badToken();
-             }
--
-             newNumberToken(dval, NoDecimal, start, modifier, ttp);
-             return true;
-         }
- 
-         MOZ_ASSERT(c1kind == Other);
- 
-         // This handles everything else.  Simple tokens distinguished solely by
-         // TokenKind should set |simpleKind| and break, to share simple-token
-diff --git a/js/src/jsnum.cpp b/js/src/jsnum.cpp
---- a/js/src/jsnum.cpp
-+++ b/js/src/jsnum.cpp
-@@ -10,16 +10,17 @@
- 
- #include "jsnum.h"
- 
- #include "mozilla/ArrayUtils.h"
- #include "mozilla/FloatingPoint.h"
- #include "mozilla/Maybe.h"
- #include "mozilla/RangedPtr.h"
- #include "mozilla/TextUtils.h"
-+#include "mozilla/Utf8.h"
- 
- #ifdef HAVE_LOCALECONV
- #include <locale.h>
- #endif
- #include <math.h>
- #include <string.h>
- 
- #include "jstypes.h"
-@@ -42,21 +43,24 @@
- #include "vm/StringType-inl.h"
- 
- using namespace js;
- 
- using mozilla::Abs;
- using mozilla::ArrayLength;
- using mozilla::AsciiAlphanumericToNumber;
- using mozilla::IsAsciiAlphanumeric;
-+using mozilla::IsAsciiDigit;
- using mozilla::Maybe;
- using mozilla::MinNumberValue;
- using mozilla::NegativeInfinity;
- using mozilla::PositiveInfinity;
- using mozilla::RangedPtr;
-+using mozilla::Utf8AsUnsignedChars;
-+using mozilla::Utf8Unit;
- 
- using JS::AutoCheckCannotGC;
- using JS::GenericNaN;
- using JS::ToInt8;
- using JS::ToInt16;
- using JS::ToInt32;
- using JS::ToInt64;
- using JS::ToUint8;
-@@ -256,48 +260,70 @@ js::GetPrefixInteger(JSContext* cx, cons
-         return ComputeAccurateDecimalInteger(cx, start, s, dp);
- 
-     if ((base & (base - 1)) == 0)
-         *dp = ComputeAccurateBinaryBaseInteger(start, s, base);
- 
-     return true;
- }
- 
-+namespace js {
-+
- template bool
--js::GetPrefixInteger(JSContext* cx, const char16_t* start, const char16_t* end, int base,
--                     const char16_t** endp, double* dp);
-+GetPrefixInteger(JSContext* cx, const char16_t* start, const char16_t* end, int base,
-+                 const char16_t** endp, double* dp);
- 
- template bool
--js::GetPrefixInteger(JSContext* cx, const Latin1Char* start, const Latin1Char* end,
--                     int base, const Latin1Char** endp, double* dp);
-+GetPrefixInteger(JSContext* cx, const Latin1Char* start, const Latin1Char* end, int base,
-+                 const Latin1Char** endp, double* dp);
- 
-+} // namespace js
-+
-+template <typename CharT>
- bool
--js::GetDecimalInteger(JSContext* cx, const char16_t* start, const char16_t* end, double* dp)
-+js::GetDecimalInteger(JSContext* cx, const CharT* start, const CharT* end, double* dp)
- {
-     MOZ_ASSERT(start <= end);
- 
--    const char16_t* s = start;
-+    const CharT* s = start;
-     double d = 0.0;
-     for (; s < end; s++) {
--        char16_t c = *s;
--        MOZ_ASSERT('0' <= c && c <= '9');
-+        CharT c = *s;
-+        MOZ_ASSERT(IsAsciiDigit(c));
-         int digit = c - '0';
-         d = d * 10 + digit;
-     }
- 
-     *dp = d;
- 
-     // If we haven't reached the limit of integer precision, we're done.
-     if (d < DOUBLE_INTEGRAL_PRECISION_LIMIT)
-         return true;
- 
-     // Otherwise compute the correct integer from the prefix of valid digits.
-     return ComputeAccurateDecimalInteger(cx, start, s, dp);
- }
- 
-+namespace js {
-+
-+template bool
-+GetDecimalInteger(JSContext* cx, const char16_t* start, const char16_t* end, double* dp);
-+
-+template bool
-+GetDecimalInteger(JSContext* cx, const Latin1Char* start, const Latin1Char* end, double* dp);
-+
-+template <>
-+bool
-+GetDecimalInteger<Utf8Unit>(JSContext* cx, const Utf8Unit* start, const Utf8Unit* end, double* dp)
-+{
-+    return GetDecimalInteger(cx, Utf8AsUnsignedChars(start), Utf8AsUnsignedChars(end), dp);
-+}
-+
-+} // namespace js
-+
- static bool
- num_parseFloat(JSContext* cx, unsigned argc, Value* vp)
- {
-     CallArgs args = CallArgsFromVp(argc, vp);
- 
-     if (args.length() == 0) {
-         args.rval().setNaN();
-         return true;
-diff --git a/js/src/jsnum.h b/js/src/jsnum.h
---- a/js/src/jsnum.h
-+++ b/js/src/jsnum.h
-@@ -5,16 +5,17 @@
-  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
- 
- #ifndef jsnum_h
- #define jsnum_h
- 
- #include "mozilla/Compiler.h"
- #include "mozilla/FloatingPoint.h"
- #include "mozilla/Range.h"
-+#include "mozilla/Utf8.h"
- 
- #include "NamespaceImports.h"
- 
- #include "js/Conversions.h"
- 
- #include "vm/StringType.h"
- 
- 
-@@ -140,23 +141,58 @@ ParseDecimalNumber(const mozilla::Range<
-  * If [start, end) does not begin with a number with the specified base,
-  * *dp == 0 and *endp == start upon return.
-  */
- template <typename CharT>
- extern MOZ_MUST_USE bool
- GetPrefixInteger(JSContext* cx, const CharT* start, const CharT* end, int base,
-                  const CharT** endp, double* dp);
- 
-+inline const char16_t*
-+ToRawChars(const char16_t* units)
-+{
-+    return units;
-+}
-+
-+inline const unsigned char*
-+ToRawChars(const unsigned char* units)
-+{
-+    return units;
-+}
-+
-+inline const unsigned char*
-+ToRawChars(const mozilla::Utf8Unit* units)
-+{
-+    return mozilla::Utf8AsUnsignedChars(units);
-+}
-+
-+/**
-+ * Like the prior function, but [start, end) must all be digits in the given
-+ * base (and so this function doesn't take a useless outparam).
-+ */
-+template <typename CharT>
-+extern MOZ_MUST_USE bool
-+GetFullInteger(JSContext* cx, const CharT* start, const CharT* end, int base, double* dp)
-+{
-+    decltype(ToRawChars(start)) realEnd;
-+    if (GetPrefixInteger(cx, ToRawChars(start), ToRawChars(end), base, &realEnd, dp)) {
-+        MOZ_ASSERT(end == static_cast<const void*>(realEnd));
-+        return true;
-+    }
-+    return false;
-+}
-+
- /*
-- * This is like GetPrefixInteger, but only deals with base 10, and doesn't have
-- * and |endp| outparam.  It should only be used when the characters are known to
-- * only contain digits.
-+ * This is like GetPrefixInteger, but it only deals with base 10 and doesn't
-+ * have an |endp| outparam.  It should only be used when the characters are
-+ * known to only contain digits.
-  */
-+template <typename CharT>
- extern MOZ_MUST_USE bool
--GetDecimalInteger(JSContext* cx, const char16_t* start, const char16_t* end, double* dp);
-+GetDecimalInteger(JSContext* cx, const CharT* start, const CharT* end, double* dp);
- 
- extern MOZ_MUST_USE bool
- StringToNumber(JSContext* cx, JSString* str, double* result);
- 
- /* ES5 9.3 ToNumber, overwriting *vp with the appropriate number value. */
- MOZ_ALWAYS_INLINE MOZ_MUST_USE bool
- ToNumber(JSContext* cx, JS::MutableHandleValue vp)
- {
-@@ -206,16 +242,45 @@ num_parseInt(JSContext* cx, unsigned arg
-  */
- template <typename CharT>
- extern MOZ_MUST_USE bool
- js_strtod(JSContext* cx, const CharT* begin, const CharT* end,
-           const CharT** dEnd, double* d);
- 
- namespace js {
- 
-+/**
-+ * Like js_strtod, but for when you don't require a |dEnd| argument *and* it's
-+ * possible that the number in the string will not occupy the full [begin, end)
-+ * range.
-+ */
-+template <typename CharT>
-+extern MOZ_MUST_USE bool
-+StringToDouble(JSContext* cx, const CharT* begin, const CharT* end, double* d)
-+{
-+    decltype(ToRawChars(begin)) dummy;
-+    return js_strtod(cx, ToRawChars(begin), ToRawChars(end), &dummy, d);
-+}
-+
-+/**
-+ * Like js_strtod, but for when the number always constitutes the entire range
-+ * (and so |dEnd| would be a value already known).
-+ */
-+template <typename CharT>
-+extern MOZ_MUST_USE bool
-+FullStringToDouble(JSContext* cx, const CharT* begin, const CharT* end, double* d)
-+{
-+    decltype(ToRawChars(begin)) realEnd;
-+    if (js_strtod(cx, ToRawChars(begin), ToRawChars(end), &realEnd, d)) {
-+        MOZ_ASSERT(end == static_cast<const void*>(realEnd));
-+        return true;
-+    }
-+    return false;
-+}
-+
- extern MOZ_MUST_USE bool
- num_toString(JSContext* cx, unsigned argc, Value* vp);
- 
- extern MOZ_MUST_USE bool
- num_valueOf(JSContext* cx, unsigned argc, Value* vp);
- 
- /*
-  * Returns true if the given value is definitely an index: that is, the value
-diff --git a/js/src/vm/JSONParser.cpp b/js/src/vm/JSONParser.cpp
---- a/js/src/vm/JSONParser.cpp
-+++ b/js/src/vm/JSONParser.cpp
-@@ -284,20 +284,18 @@ JSONParser<CharT>::readNumber()
-             // largest number a double can represent with integral precision),
-             // parse it using a decimal-only parser.  This comparison is
-             // conservative but faster than a fully-precise check.
-             double d = ParseDecimalNumber(chars);
-             return numberToken(negative ? -d : d);
-         }
- 
-         double d;
--        const CharT* dummy;
--        if (!GetPrefixInteger(cx, digitStart.get(), current.get(), 10, &dummy, &d))
-+        if (!GetFullInteger(cx, digitStart.get(), current.get(), 10, &d))
-             return token(OOM);
--        MOZ_ASSERT(current == dummy);
-         return numberToken(negative ? -d : d);
-     }
- 
-     /* (\.[0-9]+)? */
-     if (current < end && *current == '.') {
-         if (++current == end) {
-             error("missing digits after decimal point");
-             return token(Error);
-@@ -330,20 +328,18 @@ JSONParser<CharT>::readNumber()
-         }
-         while (++current < end) {
-             if (!IsAsciiDigit(*current))
-                 break;
-         }
-     }
- 
-     double d;
--    const CharT* finish;
--    if (!js_strtod(cx, digitStart.get(), current.get(), &finish, &d))
-+    if (!FullStringToDouble(cx, digitStart.get(), current.get(), &d))
-         return token(OOM);
--    MOZ_ASSERT(current == finish);
-     return numberToken(negative ? -d : d);
- }
- 
- static inline bool
- IsJSONWhitespace(char16_t c)
- {
-     return c == '\t' || c == '\r' || c == '\n' || c == ' ';
- }

+ 0 - 32
frg/work-js/mozilla-release/patches/mozilla-central-push_429309.patch

@@ -1,32 +0,0 @@
-# HG changeset patch
-# User Jeff Walden <jwalden@mit.edu>
-# Date 1532659502 25200
-#      Thu Jul 26 19:45:02 2018 -0700
-# Node ID eea8bd3d8e45082679dd8d44c2a18b2ccde80c1c
-# Parent  69a4d421088167f1baf44a9df12fcc705b1df3eb
-Bug 1478587 - Instantiate TokenStreamSpecific for UTF-8.  r=arai
-
-diff --git a/js/src/frontend/TokenStream.cpp b/js/src/frontend/TokenStream.cpp
---- a/js/src/frontend/TokenStream.cpp
-+++ b/js/src/frontend/TokenStream.cpp
-@@ -3166,16 +3166,20 @@ TokenStreamChars<Utf8Unit, ParserAnyChar
- template class
- TokenStreamChars<Utf8Unit, ParserAnyCharsAccess<GeneralParser<SyntaxParseHandler, Utf8Unit>>>;
- template class
- TokenStreamChars<char16_t, ParserAnyCharsAccess<GeneralParser<FullParseHandler, char16_t>>>;
- template class
- TokenStreamChars<char16_t, ParserAnyCharsAccess<GeneralParser<SyntaxParseHandler, char16_t>>>;
- 
- template class
-+TokenStreamSpecific<Utf8Unit, ParserAnyCharsAccess<GeneralParser<FullParseHandler, Utf8Unit>>>;
-+template class
-+TokenStreamSpecific<Utf8Unit, ParserAnyCharsAccess<GeneralParser<SyntaxParseHandler, Utf8Unit>>>;
-+template class
- TokenStreamSpecific<char16_t, ParserAnyCharsAccess<GeneralParser<FullParseHandler, char16_t>>>;
- template class
- TokenStreamSpecific<char16_t, ParserAnyCharsAccess<GeneralParser<SyntaxParseHandler, char16_t>>>;
- 
- } // namespace frontend
- 
- } // namespace js
- 

+ 0 - 142
frg/work-js/mozilla-release/patches/mozilla-central-push_429310.patch

@@ -1,142 +0,0 @@
-# HG changeset patch
-# User Jeff Walden <jwalden@mit.edu>
-# Date 1532574742 25200
-#      Wed Jul 25 20:12:22 2018 -0700
-# Node ID a55de03eb91d84b00906c20755a2e95eae19fe48
-# Parent  eea8bd3d8e45082679dd8d44c2a18b2ccde80c1c
-Bug 1478892 - Make all parser-related classes instantiable for UTF-8 source text.  r=arai
-
-diff --git a/js/src/frontend/Parser.cpp b/js/src/frontend/Parser.cpp
---- a/js/src/frontend/Parser.cpp
-+++ b/js/src/frontend/Parser.cpp
-@@ -18,16 +18,17 @@
-  */
- 
- #include "frontend/Parser.h"
- 
- #include "mozilla/Range.h"
- #include "mozilla/Sprintf.h"
- #include "mozilla/TypeTraits.h"
- #include "mozilla/Unused.h"
-+#include "mozilla/Utf8.h"
- 
- #include <memory>
- #include <new>
- 
- #include "jsapi.h"
- #include "jstypes.h"
- 
- #include "builtin/ModuleObject.h"
-@@ -55,16 +56,17 @@ using namespace js;
- using namespace js::gc;
- 
- using mozilla::Maybe;
- using mozilla::Nothing;
- using mozilla::PodCopy;
- using mozilla::PodZero;
- using mozilla::Some;
- using mozilla::Unused;
-+using mozilla::Utf8Unit;
- 
- using JS::AutoGCRooter;
- 
- namespace js {
- namespace frontend {
- 
- using DeclaredNamePtr = ParseContext::Scope::DeclaredNamePtr;
- using AddDeclaredNamePtr = ParseContext::Scope::AddDeclaredNamePtr;
-@@ -4109,19 +4111,19 @@ Parser<SyntaxParseHandler, CharT>::asmJS
-     // Record that the current script source constains some AsmJS, to disable
-     // any incremental encoder, as AsmJS cannot be encoded with XDR at the
-     // moment.
-     if (ss)
-         ss->setContainsAsmJS();
-     return false;
- }
- 
--template <typename CharT>
-+template <>
- bool
--Parser<FullParseHandler, CharT>::asmJS(Node list)
-+Parser<FullParseHandler, char16_t>::asmJS(Node list)
- {
-     // Disable syntax parsing in anything nested inside the asm.js module.
-     disableSyntaxParser();
- 
-     // We should be encountering the "use asm" directive for the first time; if
-     // the directive is already, we must have failed asm.js validation and we're
-     // reparsing. In that case, don't try to validate again. A non-null
-     // newDirectives means we're not in a normal function.
-@@ -4147,16 +4149,26 @@ Parser<FullParseHandler, CharT>::asmJS(N
-     if (!validated) {
-         pc->newDirectives->setAsmJS();
-         return false;
-     }
- 
-     return true;
- }
- 
-+template <>
-+bool
-+Parser<FullParseHandler, Utf8Unit>::asmJS(Node list)
-+{
-+    // Just succeed without setting the asm.js directive flag.  Given Web
-+    // Assembly's rapid advance, it's probably not worth the trouble to really
-+    // support UTF-8 asm.js.
-+    return true;
-+}
-+
- template <class ParseHandler, typename CharT>
- inline bool
- GeneralParser<ParseHandler, CharT>::asmJS(Node list)
- {
-     return asFinalParser()->asmJS(list);
- }
- 
- /*
-@@ -9114,19 +9126,16 @@ GeneralParser<ParseHandler, CharT>::noSu
- }
- 
- template <typename CharT>
- ParseNode*
- Parser<FullParseHandler, CharT>::newRegExp()
- {
-     MOZ_ASSERT(!options().selfHostingMode);
- 
--    static_assert(mozilla::IsSame<CharT, char16_t>::value,
--                  "code below will need changing for UTF-8 handling");
--
-     // Create the regexp and check its syntax.
-     const auto& chars = tokenStream.getCharBuffer();
-     RegExpFlag flags = anyChars.currentToken().regExpFlags();
- 
-     Rooted<RegExpObject*> reobj(context);
-     reobj = RegExpObject::create(context, chars.begin(), chars.length(), flags, anyChars, alloc,
-                                  TenuredObject);
-     if (!reobj)
-@@ -9136,24 +9145,21 @@ Parser<FullParseHandler, CharT>::newRegE
- }
- 
- template <typename CharT>
- SyntaxParseHandler::Node
- Parser<SyntaxParseHandler, CharT>::newRegExp()
- {
-     MOZ_ASSERT(!options().selfHostingMode);
- 
--    static_assert(mozilla::IsSame<CharT, char16_t>::value,
--                  "code below will need changing for UTF-8 handling");
--
-     // Only check the regexp's syntax, but don't create a regexp object.
-     const auto& chars = tokenStream.getCharBuffer();
-     RegExpFlag flags = anyChars.currentToken().regExpFlags();
- 
--    mozilla::Range<const CharT> source(chars.begin(), chars.length());
-+    mozilla::Range<const char16_t> source(chars.begin(), chars.length());
-     if (!js::irregexp::ParsePatternSyntax(anyChars, alloc, source, flags & UnicodeFlag))
-         return null();
- 
-     return handler.newRegExp(SyntaxParseHandler::NodeGeneric, pos(), *this);
- }
- 
- template <class ParseHandler, typename CharT>
- typename ParseHandler::Node

+ 0 - 90
frg/work-js/mozilla-release/patches/mozilla-central-push_429314.patch

@@ -1,90 +0,0 @@
-# HG changeset patch
-# User Nicholas Nethercote <nnethercote@mozilla.com>
-# Date 1532595166 -36000
-#      Thu Jul 26 18:52:46 2018 +1000
-# Node ID 6ef5c1f956f9ac5fc8f0f5d39454188679ea4060
-# Parent  cd5678331e973d2ea13191578f3d974f354824b7
-Bug 1477626 - Replace some bespoke code with a call to CeilingLog2(). r=Waldo
-
-After all, bug 543034 was fixed 9 years ago.
-
-MozReview-Commit-ID: HDPO3gGuQMx
-
-diff --git a/js/public/HashTable.h b/js/public/HashTable.h
---- a/js/public/HashTable.h
-+++ b/js/public/HashTable.h
-@@ -6,16 +6,17 @@
- 
- #ifndef js_HashTable_h
- #define js_HashTable_h
- 
- #include "mozilla/Assertions.h"
- #include "mozilla/Attributes.h"
- #include "mozilla/Casting.h"
- #include "mozilla/HashFunctions.h"
-+#include "mozilla/MathAlgorithms.h"
- #include "mozilla/MemoryChecking.h"
- #include "mozilla/MemoryReporting.h"
- #include "mozilla/Move.h"
- #include "mozilla/Opaque.h"
- #include "mozilla/PodOperations.h"
- #include "mozilla/ReentrancyGuard.h"
- #include "mozilla/TemplateLib.h"
- #include "mozilla/TypeTraits.h"
-@@ -1248,18 +1249,17 @@ class HashTable : private AllocPolicy
-     } stats;
- #   define METER(x) x
- #else
- #   define METER(x)
- #endif
- 
-     // The default initial capacity is 32 (enough to hold 16 elements), but it
-     // can be as low as 4.
--    static const unsigned sMinCapacityLog2 = 2;
--    static const unsigned sMinCapacity  = 1 << sMinCapacityLog2;
-+    static const unsigned sMinCapacity  = 4;
-     static const unsigned sMaxInit      = JS_BIT(CAP_BITS - 1);
-     static const unsigned sMaxCapacity  = JS_BIT(CAP_BITS);
-     static const unsigned sHashBits     = mozilla::tl::BitSize<HashNumber>::value;
- 
-     // Hash-table alpha is conceptually a fraction, but to avoid floating-point
-     // math we implement it as a ratio of integers.
-     static const uint8_t sAlphaDenominator = 4;
-     static const uint8_t sMinAlphaNumerator = 1; // min alpha: 1/4
-@@ -1356,32 +1356,28 @@ class HashTable : private AllocPolicy
-         // Compute the smallest capacity allowing |length| elements to be
-         // inserted without rehashing: ceil(length / max-alpha).  (Ceiling
-         // integral division: <http://stackoverflow.com/a/2745086>.)
-         uint32_t newCapacity =
-             (length * sAlphaDenominator + sMaxAlphaNumerator - 1) / sMaxAlphaNumerator;
-         if (newCapacity < sMinCapacity)
-             newCapacity = sMinCapacity;
- 
--        // FIXME: use JS_CEILING_LOG2 when PGO stops crashing (bug 543034).
--        uint32_t roundUp = sMinCapacity, roundUpLog2 = sMinCapacityLog2;
--        while (roundUp < newCapacity) {
--            roundUp <<= 1;
--            ++roundUpLog2;
--        }
-+        // Round up capacity to next power-of-two.
-+        uint32_t log2 = mozilla::CeilingLog2(newCapacity);
-+        newCapacity = 1u << log2;
- 
--        newCapacity = roundUp;
-         MOZ_ASSERT(newCapacity >= length);
-         MOZ_ASSERT(newCapacity <= sMaxCapacity);
- 
-         table = createTable(*this, newCapacity);
-         if (!table)
-             return false;
- 
--        setTableSizeLog2(roundUpLog2);
-+        setTableSizeLog2(log2);
-         METER(memset(&stats, 0, sizeof(stats)));
-         return true;
-     }
- 
-     bool initialized() const
-     {
-         return !!table;
-     }

+ 0 - 91
frg/work-js/mozilla-release/patches/mozilla-central-push_429315.patch

@@ -1,91 +0,0 @@
-# HG changeset patch
-# User Nicholas Nethercote <nnethercote@mozilla.com>
-# Date 1532595166 -36000
-#      Thu Jul 26 18:52:46 2018 +1000
-# Node ID cff709da0b230613b24baea53cf8e047fd449f6e
-# Parent  6ef5c1f956f9ac5fc8f0f5d39454188679ea4060
-Bug 1477626 - Use `uint32_t` instead of `unsigned` in HashTable.h. r=Waldo
-
-Because it's more precise, and gives us more consistency.
-
-MozReview-Commit-ID: BLYXYSHgZ7v
-
-diff --git a/js/public/HashTable.h b/js/public/HashTable.h
---- a/js/public/HashTable.h
-+++ b/js/public/HashTable.h
-@@ -1249,32 +1249,32 @@ class HashTable : private AllocPolicy
-     } stats;
- #   define METER(x) x
- #else
- #   define METER(x)
- #endif
- 
-     // The default initial capacity is 32 (enough to hold 16 elements), but it
-     // can be as low as 4.
--    static const unsigned sMinCapacity  = 4;
--    static const unsigned sMaxInit      = JS_BIT(CAP_BITS - 1);
--    static const unsigned sMaxCapacity  = JS_BIT(CAP_BITS);
--    static const unsigned sHashBits     = mozilla::tl::BitSize<HashNumber>::value;
-+    static const uint32_t sMinCapacity  = 4;
-+    static const uint32_t sMaxInit      = JS_BIT(CAP_BITS - 1);
-+    static const uint32_t sMaxCapacity  = JS_BIT(CAP_BITS);
-+    static const uint32_t sHashBits     = mozilla::tl::BitSize<HashNumber>::value;
- 
-     // Hash-table alpha is conceptually a fraction, but to avoid floating-point
-     // math we implement it as a ratio of integers.
-     static const uint8_t sAlphaDenominator = 4;
-     static const uint8_t sMinAlphaNumerator = 1; // min alpha: 1/4
-     static const uint8_t sMaxAlphaNumerator = 3; // max alpha: 3/4
- 
-     static const HashNumber sFreeKey = Entry::sFreeKey;
-     static const HashNumber sRemovedKey = Entry::sRemovedKey;
-     static const HashNumber sCollisionBit = Entry::sCollisionBit;
- 
--    void setTableSizeLog2(unsigned sizeLog2)
-+    void setTableSizeLog2(uint32_t sizeLog2)
-     {
-         hashShift = sHashBits - sizeLog2;
-     }
- 
-     static bool isLiveHash(HashNumber hash)
-     {
-         return Entry::isLiveHash(hash);
-     }
-@@ -1397,17 +1397,17 @@ class HashTable : private AllocPolicy
-     struct DoubleHash
-     {
-         HashNumber h2;
-         HashNumber sizeMask;
-     };
- 
-     DoubleHash hash2(HashNumber curKeyHash) const
-     {
--        unsigned sizeLog2 = sHashBits - hashShift;
-+        uint32_t sizeLog2 = sHashBits - hashShift;
-         DoubleHash dh = {
-             ((curKeyHash << sizeLog2) >> hashShift) | 1,
-             (HashNumber(1) << sizeLog2) - 1
-         };
-         return dh;
-     }
- 
-     static HashNumber applyDoubleHash(HashNumber h1, const DoubleHash& dh)
-@@ -1443,17 +1443,17 @@ class HashTable : private AllocPolicy
-     }
- 
-     // Warning: in order for readonlyThreadsafeLookup() to be safe this
-     // function must not modify the table in any way when |collisionBit| is 0.
-     // (The use of the METER() macro to increment stats violates this
-     // restriction but we will live with that for now because it's enabled so
-     // rarely.)
-     MOZ_ALWAYS_INLINE Entry&
--    lookup(const Lookup& l, HashNumber keyHash, unsigned collisionBit) const
-+    lookup(const Lookup& l, HashNumber keyHash, uint32_t collisionBit) const
-     {
-         MOZ_ASSERT(isLiveHash(keyHash));
-         MOZ_ASSERT(!(keyHash & sCollisionBit));
-         MOZ_ASSERT(collisionBit == 0 || collisionBit == sCollisionBit);
-         MOZ_ASSERT(table);
-         METER(stats.searches++);
- 
-         // Compute the primary hash address.

+ 0 - 818
frg/work-js/mozilla-release/patches/mozilla-central-push_429316.patch

@@ -1,818 +0,0 @@
-# HG changeset patch
-# User Nicholas Nethercote <nnethercote@mozilla.com>
-# Date 1532595166 -36000
-#      Thu Jul 26 18:52:46 2018 +1000
-# Node ID 9cf98793e243bd1fa1413d70cf957b9a4f4d54f4
-# Parent  cff709da0b230613b24baea53cf8e047fd449f6e
-Bug 1477626 - Introduce mozilla::HashNumber and use it in various places. r=Waldo
-
-Currently we have three ways of representing hash values.
-
-- uint32_t: used in HashFunctions.h.
-
-- PLDHashNumber: defined in PLDHashTable.{h,cpp}.
-
-- js::HashNumber: defined in js/public/Utility.h.
-
-Functions that create hash values with functions from HashFunctions.h use a mix
-of these three types. It's a bit of a mess.
-
-This patch introduces mozilla::HashNumber, and redefines PLDHashNumber and
-js::HashNumber as synonyms. It also changes HashFunctions.h to use
-mozilla::HashNumber throughout instead of uint32_t.
-
-This leaves plenty of places that still use uint32_t that should use
-mozilla::HashNumber or one of its synonyms, but I didn't want to tackle that
-now.
-
-The patch also:
-
-- Does similar things for the constants defining the number of bits in each
-  hash number type.
-
-- Moves js::HashNumber from Utility.h to HashTable.h, which is a better spot
-  for it. (This required changing the signature of ScrambleHashCode(); that's
-  ok, it'll get moved by the next patch anyway.)
-
-MozReview-Commit-ID: EdoWlCm7OUC
-
-diff --git a/js/public/HashTable.h b/js/public/HashTable.h
---- a/js/public/HashTable.h
-+++ b/js/public/HashTable.h
-@@ -13,24 +13,26 @@
- #include "mozilla/HashFunctions.h"
- #include "mozilla/MathAlgorithms.h"
- #include "mozilla/MemoryChecking.h"
- #include "mozilla/MemoryReporting.h"
- #include "mozilla/Move.h"
- #include "mozilla/Opaque.h"
- #include "mozilla/PodOperations.h"
- #include "mozilla/ReentrancyGuard.h"
--#include "mozilla/TemplateLib.h"
- #include "mozilla/TypeTraits.h"
- #include "mozilla/UniquePtr.h"
- 
- #include "js/Utility.h"
- 
- namespace js {
- 
-+using HashNumber = mozilla::HashNumber;
-+static const uint32_t kHashNumberBits = mozilla::kHashNumberBits;
-+
- class TempAllocPolicy;
- template <class> struct DefaultHasher;
- template <class, class> class HashMapEntry;
- namespace detail {
-     template <typename T> class HashTableEntry;
-     template <class T, class HashPolicy, class AllocPolicy> class HashTable;
- } // namespace detail
- 
-@@ -1252,31 +1254,30 @@ class HashTable : private AllocPolicy
- #   define METER(x)
- #endif
- 
-     // The default initial capacity is 32 (enough to hold 16 elements), but it
-     // can be as low as 4.
-     static const uint32_t sMinCapacity  = 4;
-     static const uint32_t sMaxInit      = JS_BIT(CAP_BITS - 1);
-     static const uint32_t sMaxCapacity  = JS_BIT(CAP_BITS);
--    static const uint32_t sHashBits     = mozilla::tl::BitSize<HashNumber>::value;
- 
-     // Hash-table alpha is conceptually a fraction, but to avoid floating-point
-     // math we implement it as a ratio of integers.
-     static const uint8_t sAlphaDenominator = 4;
-     static const uint8_t sMinAlphaNumerator = 1; // min alpha: 1/4
-     static const uint8_t sMaxAlphaNumerator = 3; // max alpha: 3/4
- 
-     static const HashNumber sFreeKey = Entry::sFreeKey;
-     static const HashNumber sRemovedKey = Entry::sRemovedKey;
-     static const HashNumber sCollisionBit = Entry::sCollisionBit;
- 
-     void setTableSizeLog2(uint32_t sizeLog2)
-     {
--        hashShift = sHashBits - sizeLog2;
-+        hashShift = js::kHashNumberBits - sizeLog2;
-     }
- 
-     static bool isLiveHash(HashNumber hash)
-     {
-         return Entry::isLiveHash(hash);
-     }
- 
-     static HashNumber prepareHash(const Lookup& l)
-@@ -1321,17 +1322,17 @@ class HashTable : private AllocPolicy
-             e->~Entry();
-         alloc.free_(oldTable, capacity);
-     }
- 
-   public:
-     explicit HashTable(AllocPolicy ap)
-       : AllocPolicy(ap)
-       , gen(0)
--      , hashShift(sHashBits)
-+      , hashShift(js::kHashNumberBits)
-       , table(nullptr)
-       , entryCount(0)
-       , removedCount(0)
- #ifdef JS_DEBUG
-       , mutationCount(0)
-       , mEntered(false)
- #endif
-     {}
-@@ -1397,17 +1398,17 @@ class HashTable : private AllocPolicy
-     struct DoubleHash
-     {
-         HashNumber h2;
-         HashNumber sizeMask;
-     };
- 
-     DoubleHash hash2(HashNumber curKeyHash) const
-     {
--        uint32_t sizeLog2 = sHashBits - hashShift;
-+        uint32_t sizeLog2 = js::kHashNumberBits - hashShift;
-         DoubleHash dh = {
-             ((curKeyHash << sizeLog2) >> hashShift) | 1,
-             (HashNumber(1) << sizeLog2) - 1
-         };
-         return dh;
-     }
- 
-     static HashNumber applyDoubleHash(HashNumber h1, const DoubleHash& dh)
-@@ -1547,17 +1548,17 @@ class HashTable : private AllocPolicy
- 
-     enum RebuildStatus { NotOverloaded, Rehashed, RehashFailed };
- 
-     RebuildStatus changeTableSize(int deltaLog2, FailureBehavior reportFailure = ReportFailure)
-     {
-         // Look, but don't touch, until we succeed in getting new entry store.
-         Entry* oldTable = table;
-         uint32_t oldCap = capacity();
--        uint32_t newLog2 = sHashBits - hashShift + deltaLog2;
-+        uint32_t newLog2 = js::kHashNumberBits - hashShift + deltaLog2;
-         uint32_t newCapacity = JS_BIT(newLog2);
-         if (MOZ_UNLIKELY(newCapacity > sMaxCapacity)) {
-             if (reportFailure)
-                 this->reportAllocOverflow();
-             return RehashFailed;
-         }
- 
-         Entry* newTable = createTable(*this, newCapacity, reportFailure);
-@@ -1786,17 +1787,17 @@ class HashTable : private AllocPolicy
-     {
-         MOZ_ASSERT(table);
-         return entryCount;
-     }
- 
-     uint32_t capacity() const
-     {
-         MOZ_ASSERT(table);
--        return JS_BIT(sHashBits - hashShift);
-+        return JS_BIT(js::kHashNumberBits - hashShift);
-     }
- 
-     Generation generation() const
-     {
-         MOZ_ASSERT(table);
-         return Generation(gen);
-     }
- 
-diff --git a/js/public/Utility.h b/js/public/Utility.h
---- a/js/public/Utility.h
-+++ b/js/public/Utility.h
-@@ -661,20 +661,16 @@ struct FreePolicy
- 
- typedef mozilla::UniquePtr<char[], JS::FreePolicy> UniqueChars;
- typedef mozilla::UniquePtr<char16_t[], JS::FreePolicy> UniqueTwoByteChars;
- 
- } // namespace JS
- 
- namespace js {
- 
--/* Integral types for all hash functions. */
--typedef uint32_t HashNumber;
--const unsigned HashNumberSizeBits = 32;
--
- namespace detail {
- 
- /*
-  * Given a raw hash code, h, return a number that can be used to select a hash
-  * bucket.
-  *
-  * This function aims to produce as uniform an output distribution as possible,
-  * especially in the most significant (leftmost) bits, even though the input
-@@ -682,35 +678,35 @@ namespace detail {
-  * be deterministic and quick to compute.
-  *
-  * Since the leftmost bits of the result are best, the hash bucket index is
-  * computed by doing ScrambleHashCode(h) / (2^32/N) or the equivalent
-  * right-shift, not ScrambleHashCode(h) % N or the equivalent bit-mask.
-  *
-  * FIXME: OrderedHashTable uses a bit-mask; see bug 775896.
-  */
--inline HashNumber
--ScrambleHashCode(HashNumber h)
-+inline uint32_t
-+ScrambleHashCode(uint32_t h)
- {
-     /*
-      * Simply returning h would not cause any hash tables to produce wrong
-      * answers. But it can produce pathologically bad performance: The caller
-      * right-shifts the result, keeping only the highest bits. The high bits of
-      * hash codes are very often completely entropy-free. (So are the lowest
-      * bits.)
-      *
-      * So we use Fibonacci hashing, as described in Knuth, The Art of Computer
-      * Programming, 6.4. This mixes all the bits of the input hash code h.
-      *
-      * The value of goldenRatio is taken from the hex
-      * expansion of the golden ratio, which starts 1.9E3779B9....
-      * This value is especially good if values with consecutive hash codes
-      * are stored in a hash table; see Knuth for details.
-      */
--    static const HashNumber goldenRatio = 0x9E3779B9U;
-+    static const uint32_t goldenRatio = 0x9E3779B9U;
-     return mozilla::WrappingMultiply(h, goldenRatio);
- }
- 
- } /* namespace detail */
- 
- } /* namespace js */
- 
- /* sixgill annotation defines */
-diff --git a/js/src/ds/OrderedHashTable.h b/js/src/ds/OrderedHashTable.h
---- a/js/src/ds/OrderedHashTable.h
-+++ b/js/src/ds/OrderedHashTable.h
-@@ -130,17 +130,17 @@ class OrderedHashTable
- 
-         // clear() requires that members are assigned only after all allocation
-         // has succeeded, and that this->ranges is left untouched.
-         hashTable = tableAlloc;
-         data = dataAlloc;
-         dataLength = 0;
-         dataCapacity = capacity;
-         liveCount = 0;
--        hashShift = HashNumberSizeBits - initialBucketsLog2();
-+        hashShift = js::kHashNumberBits - initialBucketsLog2();
-         MOZ_ASSERT(hashBuckets() == buckets);
-         return true;
-     }
- 
-     ~OrderedHashTable() {
-         forEachRange<Range::onTableDestroyed>();
-         alloc.free_(hashTable, hashBuckets());
-         freeData(data, dataLength, dataCapacity);
-@@ -619,17 +619,17 @@ class OrderedHashTable
-   public:
-     HashNumber prepareHash(const Lookup& l) const {
-         return ScrambleHashCode(Ops::hash(l, hcs));
-     }
- 
-   private:
-     /* The size of hashTable, in elements. Always a power of two. */
-     uint32_t hashBuckets() const {
--        return 1 << (HashNumberSizeBits - hashShift);
-+        return 1 << (js::kHashNumberBits - hashShift);
-     }
- 
-     static void destroyData(Data* data, uint32_t length) {
-         for (Data* p = data + length; p != data; )
-             (--p)->~Data();
-     }
- 
-     void freeData(Data* data, uint32_t length, uint32_t capacity) {
-@@ -691,17 +691,17 @@ class OrderedHashTable
-         // If the size of the table is not changing, rehash in place to avoid
-         // allocating memory.
-         if (newHashShift == hashShift) {
-             rehashInPlace();
-             return true;
-         }
- 
-         size_t newHashBuckets =
--            size_t(1) << (HashNumberSizeBits - newHashShift);
-+            size_t(1) << (js::kHashNumberBits - newHashShift);
-         Data** newHashTable = alloc.template pod_malloc<Data*>(newHashBuckets);
-         if (!newHashTable)
-             return false;
-         for (uint32_t i = 0; i < newHashBuckets; i++)
-             newHashTable[i] = nullptr;
- 
-         uint32_t newCapacity = uint32_t(newHashBuckets * fillFactor());
-         Data* newData = alloc.template pod_malloc<Data>(newCapacity);
-diff --git a/mfbt/HashFunctions.h b/mfbt/HashFunctions.h
---- a/mfbt/HashFunctions.h
-+++ b/mfbt/HashFunctions.h
-@@ -2,18 +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/. */
- 
- /* Utilities for hashing. */
- 
- /*
-- * This file exports functions for hashing data down to a 32-bit value,
-- * including:
-+ * This file exports functions for hashing data down to a uint32_t (a.k.a.
-+ * mozilla::HashNumber), including:
-  *
-  *  - HashString    Hash a char* or char16_t/wchar_t* of known or unknown
-  *                  length.
-  *
-  *  - HashBytes     Hash a byte array of known length.
-  *
-  *  - HashGeneric   Hash one or more values.  Currently, we support uint32_t,
-  *                  types which can be implicitly cast to uint32_t, data
-@@ -27,19 +27,19 @@
-  *
-  *  class ComplexObject
-  *  {
-  *    char* mStr;
-  *    uint32_t mUint1, mUint2;
-  *    void (*mCallbackFn)();
-  *
-  *  public:
-- *    uint32_t hash()
-+ *    HashNumber hash()
-  *    {
-- *      uint32_t hash = HashString(mStr);
-+ *      HashNumber hash = HashString(mStr);
-  *      hash = AddToHash(hash, mUint1, mUint2);
-  *      return AddToHash(hash, mCallbackFn);
-  *    }
-  *  };
-  *
-  * If you want to hash an nsAString or nsACString, use the HashString functions
-  * in nsHashKeys.h.
-  */
-@@ -53,32 +53,35 @@
- #include "mozilla/MathAlgorithms.h"
- #include "mozilla/Types.h"
- #include "mozilla/WrappingOperations.h"
- 
- #include <stdint.h>
- 
- namespace mozilla {
- 
-+using HashNumber = uint32_t;
-+static const uint32_t kHashNumberBits = 32;
-+
- /**
-  * The golden ratio as a 32-bit fixed-point value.
-  */
--static const uint32_t kGoldenRatioU32 = 0x9E3779B9U;
-+static const HashNumber kGoldenRatioU32 = 0x9E3779B9U;
- 
- namespace detail {
- 
- MOZ_NO_SANITIZE_UNSIGNED_OVERFLOW
--constexpr uint32_t
--RotateLeft5(uint32_t aValue)
-+constexpr HashNumber
-+RotateLeft5(HashNumber aValue)
- {
-   return (aValue << 5) | (aValue >> 27);
- }
- 
--constexpr uint32_t
--AddU32ToHash(uint32_t aHash, uint32_t aValue)
-+constexpr HashNumber
-+AddU32ToHash(HashNumber aHash, uint32_t aValue)
- {
-   /*
-    * This is the meat of all our hash routines.  This hash function is not
-    * particularly sophisticated, but it seems to work well for our mostly
-    * plain-text inputs.  Implementation notes follow.
-    *
-    * Our use of the golden ratio here is arbitrary; we could pick almost any
-    * number which:
-@@ -119,25 +122,25 @@ AddU32ToHash(uint32_t aHash, uint32_t aV
-   return mozilla::WrappingMultiply(kGoldenRatioU32,
-                                    RotateLeft5(aHash) ^ aValue);
- }
- 
- /**
-  * AddUintptrToHash takes sizeof(uintptr_t) as a template parameter.
-  */
- template<size_t PtrSize>
--constexpr uint32_t
--AddUintptrToHash(uint32_t aHash, uintptr_t aValue)
-+constexpr HashNumber
-+AddUintptrToHash(HashNumber aHash, uintptr_t aValue)
- {
-   return AddU32ToHash(aHash, static_cast<uint32_t>(aValue));
- }
- 
- template<>
--inline uint32_t
--AddUintptrToHash<8>(uint32_t aHash, uintptr_t aValue)
-+inline HashNumber
-+AddUintptrToHash<8>(HashNumber aHash, uintptr_t aValue)
- {
-   uint32_t v1 = static_cast<uint32_t>(aValue);
-   uint32_t v2 = static_cast<uint32_t>(static_cast<uint64_t>(aValue) >> 32);
-   return AddU32ToHash(AddU32ToHash(aHash, v1), v2);
- }
- 
- } /* namespace detail */
- 
-@@ -146,188 +149,188 @@ AddUintptrToHash<8>(uint32_t aHash, uint
-  * inputs.
-  *
-  * Currently, we support hashing uint32_t's, values which we can implicitly
-  * convert to uint32_t, data pointers, and function pointers.
-  */
- template<typename T,
-          bool TypeIsNotIntegral = !mozilla::IsIntegral<T>::value,
-          typename U = typename mozilla::EnableIf<TypeIsNotIntegral>::Type>
--MOZ_MUST_USE inline uint32_t
--AddToHash(uint32_t aHash, T aA)
-+MOZ_MUST_USE inline HashNumber
-+AddToHash(HashNumber aHash, T aA)
- {
-   /*
-    * Try to convert |A| to uint32_t implicitly.  If this works, great.  If not,
-    * we'll error out.
-    */
-   return detail::AddU32ToHash(aHash, aA);
- }
- 
- template<typename A>
--MOZ_MUST_USE inline uint32_t
--AddToHash(uint32_t aHash, A* aA)
-+MOZ_MUST_USE inline HashNumber
-+AddToHash(HashNumber aHash, A* aA)
- {
-   /*
-    * You might think this function should just take a void*.  But then we'd only
-    * catch data pointers and couldn't handle function pointers.
-    */
- 
-   static_assert(sizeof(aA) == sizeof(uintptr_t), "Strange pointer!");
- 
-   return detail::AddUintptrToHash<sizeof(uintptr_t)>(aHash, uintptr_t(aA));
- }
- 
- // We use AddUintptrToHash() for hashing all integral types.  8-byte integral types
- // are treated the same as 64-bit pointers, and smaller integral types are first
- // implicitly converted to 32 bits and then passed to AddUintptrToHash() to be hashed.
- template<typename T,
-          typename U = typename mozilla::EnableIf<mozilla::IsIntegral<T>::value>::Type>
--MOZ_MUST_USE constexpr uint32_t
--AddToHash(uint32_t aHash, T aA)
-+MOZ_MUST_USE constexpr HashNumber
-+AddToHash(HashNumber aHash, T aA)
- {
-   return detail::AddUintptrToHash<sizeof(T)>(aHash, aA);
- }
- 
- template<typename A, typename... Args>
--MOZ_MUST_USE uint32_t
--AddToHash(uint32_t aHash, A aArg, Args... aArgs)
-+MOZ_MUST_USE HashNumber
-+AddToHash(HashNumber aHash, A aArg, Args... aArgs)
- {
-   return AddToHash(AddToHash(aHash, aArg), aArgs...);
- }
- 
- /**
-  * The HashGeneric class of functions let you hash one or more values.
-  *
-  * If you want to hash together two values x and y, calling HashGeneric(x, y) is
-  * much better than calling AddToHash(x, y), because AddToHash(x, y) assumes
-  * that x has already been hashed.
-  */
- template<typename... Args>
--MOZ_MUST_USE inline uint32_t
-+MOZ_MUST_USE inline HashNumber
- HashGeneric(Args... aArgs)
- {
-   return AddToHash(0, aArgs...);
- }
- 
- namespace detail {
- 
- template<typename T>
--uint32_t
-+HashNumber
- HashUntilZero(const T* aStr)
- {
--  uint32_t hash = 0;
-+  HashNumber hash = 0;
-   for (T c; (c = *aStr); aStr++) {
-     hash = AddToHash(hash, c);
-   }
-   return hash;
- }
- 
- // This is a `constexpr` alternative to HashUntilZero(const T*). It should
- // only be used for compile-time computation because it uses recursion.
- // XXX: once support for GCC 4.9 is dropped, this function should be removed
- // and HashUntilZero(const T*) should be made `constexpr`.
- template<typename T>
--constexpr uint32_t
--ConstExprHashUntilZero(const T* aStr, uint32_t aHash)
-+constexpr HashNumber
-+ConstExprHashUntilZero(const T* aStr, HashNumber aHash)
- {
-   return !*aStr
-        ? aHash
-        : ConstExprHashUntilZero(aStr + 1, AddToHash(aHash, *aStr));
- }
- 
- template<typename T>
--uint32_t
-+HashNumber
- HashKnownLength(const T* aStr, size_t aLength)
- {
--  uint32_t hash = 0;
-+  HashNumber hash = 0;
-   for (size_t i = 0; i < aLength; i++) {
-     hash = AddToHash(hash, aStr[i]);
-   }
-   return hash;
- }
- 
- } /* namespace detail */
- 
- /**
-  * The HashString overloads below do just what you'd expect.
-  *
-  * If you have the string's length, you might as well call the overload which
-  * includes the length.  It may be marginally faster.
-  */
--MOZ_MUST_USE inline uint32_t
-+MOZ_MUST_USE inline HashNumber
- HashString(const char* aStr)
- {
-   return detail::HashUntilZero(reinterpret_cast<const unsigned char*>(aStr));
- }
- 
--MOZ_MUST_USE inline uint32_t
-+MOZ_MUST_USE inline HashNumber
- HashString(const char* aStr, size_t aLength)
- {
-   return detail::HashKnownLength(reinterpret_cast<const unsigned char*>(aStr), aLength);
- }
- 
- MOZ_MUST_USE
--inline uint32_t
-+inline HashNumber
- HashString(const unsigned char* aStr, size_t aLength)
- {
-   return detail::HashKnownLength(aStr, aLength);
- }
- 
--MOZ_MUST_USE inline uint32_t
-+MOZ_MUST_USE inline HashNumber
- HashString(const char16_t* aStr)
- {
-   return detail::HashUntilZero(aStr);
- }
- 
- // This is a `constexpr` alternative to HashString(const char16_t*). It should
- // only be used for compile-time computation because it uses recursion.
- //
- // You may need to use the
- // MOZ_{PUSH,POP}_DISABLE_INTEGRAL_CONSTANT_OVERFLOW_WARNING macros if you use
- // this function. See the comment on those macros' definitions for more detail.
- //
- // XXX: once support for GCC 4.9 is dropped, this function should be removed
- // and HashString(const char16_t*) should be made `constexpr`.
--MOZ_MUST_USE constexpr uint32_t
-+MOZ_MUST_USE constexpr HashNumber
- ConstExprHashString(const char16_t* aStr)
- {
-   return detail::ConstExprHashUntilZero(aStr, 0);
- }
- 
--MOZ_MUST_USE inline uint32_t
-+MOZ_MUST_USE inline HashNumber
- HashString(const char16_t* aStr, size_t aLength)
- {
-   return detail::HashKnownLength(aStr, aLength);
- }
- 
- /*
-  * On Windows, wchar_t is not the same as char16_t, even though it's
-  * the same width!
-  */
- #ifdef WIN32
--MOZ_MUST_USE inline uint32_t
-+MOZ_MUST_USE inline HashNumber
- HashString(const wchar_t* aStr)
- {
-   return detail::HashUntilZero(aStr);
- }
- 
--MOZ_MUST_USE inline uint32_t
-+MOZ_MUST_USE inline HashNumber
- HashString(const wchar_t* aStr, size_t aLength)
- {
-   return detail::HashKnownLength(aStr, aLength);
- }
- #endif
- 
- /**
-  * Hash some number of bytes.
-  *
-  * This hash walks word-by-word, rather than byte-by-byte, so you won't get the
-  * same result out of HashBytes as you would out of HashString.
-  */
--MOZ_MUST_USE extern MFBT_API uint32_t
-+MOZ_MUST_USE extern MFBT_API HashNumber
- HashBytes(const void* bytes, size_t aLength);
- 
- /**
-  * A pseudorandom function mapping 32-bit integers to 32-bit integers.
-  *
-  * This is for when you're feeding private data (like pointer values or credit
-  * card numbers) to a non-crypto hash function (like HashBytes) and then using
-  * the hash code for something that untrusted parties could observe (like a JS
-@@ -350,20 +353,20 @@ class HashCodeScrambler
- public:
-   /** Creates a new scrambler with the given 128-bit key. */
-   constexpr HashCodeScrambler(uint64_t aK0, uint64_t aK1) : mK0(aK0), mK1(aK1) {}
- 
-   /**
-    * Scramble a hash code. Always produces the same result for the same
-    * combination of key and hash code.
-    */
--  uint32_t scramble(uint32_t aHashCode) const
-+  HashNumber scramble(HashNumber aHashCode) const
-   {
-     SipHasher hasher(mK0, mK1);
--    return uint32_t(hasher.sipHash(aHashCode));
-+    return HashNumber(hasher.sipHash(aHashCode));
-   }
- 
- private:
-   struct SipHasher
-   {
-     SipHasher(uint64_t aK0, uint64_t aK1)
-     {
-       // 1. Initialization.
-diff --git a/xpcom/ds/PLDHashTable.cpp b/xpcom/ds/PLDHashTable.cpp
---- a/xpcom/ds/PLDHashTable.cpp
-+++ b/xpcom/ds/PLDHashTable.cpp
-@@ -188,17 +188,17 @@ PLDHashTable::HashShift(uint32_t aEntryS
-   BestCapacity(aLength, &capacity, &log2);
- 
-   uint32_t nbytes;
-   if (!SizeOfEntryStore(capacity, aEntrySize, &nbytes)) {
-     MOZ_CRASH("Initial entry store size is too large");
-   }
- 
-   // Compute the hashShift value.
--  return kHashBits - log2;
-+  return kPLDHashNumberBits - log2;
- }
- 
- PLDHashTable::PLDHashTable(const PLDHashTableOps* aOps, uint32_t aEntrySize,
-                            uint32_t aLength)
-   : mOps(recordreplay::GeneratePLDHashTableCallbacks(aOps))
-   , mEntryStore()
-   , mGeneration(0)
-   , mHashShift(HashShift(aEntrySize, aLength))
-@@ -267,17 +267,17 @@ PLDHashTable::Hash1(PLDHashNumber aHash0
- {
-   return aHash0 >> mHashShift;
- }
- 
- void
- PLDHashTable::Hash2(PLDHashNumber aHash0,
-                     uint32_t& aHash2Out, uint32_t& aSizeMaskOut) const
- {
--  uint32_t sizeLog2 = kHashBits - mHashShift;
-+  uint32_t sizeLog2 = kPLDHashNumberBits - mHashShift;
-   uint32_t sizeMask = (PLDHashNumber(1) << sizeLog2) - 1;
-   aSizeMaskOut = sizeMask;
- 
-   // The incoming aHash0 always has the low bit unset (since we leave it
-   // free for the collision flag), and should have reasonably random
-   // data in the other 31 bits.  We used the high bits of aHash0 for
-   // Hash1, so we use the low bits here.  If the table size is large,
-   // the bits we use may overlap, but that's still more random than
-@@ -472,17 +472,17 @@ PLDHashTable::FindFreeEntry(PLDHashNumbe
- }
- 
- bool
- PLDHashTable::ChangeTable(int32_t aDeltaLog2)
- {
-   MOZ_ASSERT(mEntryStore.Get());
- 
-   // Look, but don't touch, until we succeed in getting new entry store.
--  int32_t oldLog2 = kHashBits - mHashShift;
-+  int32_t oldLog2 = kPLDHashNumberBits - mHashShift;
-   int32_t newLog2 = oldLog2 + aDeltaLog2;
-   uint32_t newCapacity = 1u << newLog2;
-   if (newCapacity > kMaxCapacity) {
-     return false;
-   }
- 
-   uint32_t nbytes;
-   if (!SizeOfEntryStore(newCapacity, mEntrySize, &nbytes)) {
-@@ -490,17 +490,17 @@ PLDHashTable::ChangeTable(int32_t aDelta
-   }
- 
-   char* newEntryStore = (char*)calloc(1, nbytes);
-   if (!newEntryStore) {
-     return false;
-   }
- 
-   // We can't fail from here on, so update table parameters.
--  mHashShift = kHashBits - newLog2;
-+  mHashShift = kPLDHashNumberBits - newLog2;
-   mRemovedCount = 0;
- 
-   // Assign the new entry store to table.
-   char* oldEntryStore;
-   char* oldEntryAddr;
-   oldEntryAddr = oldEntryStore = mEntryStore.Get();
-   mEntryStore.Set(newEntryStore, &mGeneration);
-   PLDHashMoveEntry moveEntry = mOps->moveEntry;
-@@ -694,17 +694,17 @@ void
- PLDHashTable::ShrinkIfAppropriate()
- {
-   uint32_t capacity = Capacity();
-   if (mRemovedCount >= capacity >> 2 ||
-       (capacity > kMinCapacity && mEntryCount <= MinLoad(capacity))) {
-     uint32_t log2;
-     BestCapacity(mEntryCount, &capacity, &log2);
- 
--    int32_t deltaLog2 = log2 - (kHashBits - mHashShift);
-+    int32_t deltaLog2 = log2 - (kPLDHashNumberBits - mHashShift);
-     MOZ_ASSERT(deltaLog2 <= 0);
- 
-     (void) ChangeTable(deltaLog2);
-   }
- }
- 
- size_t
- PLDHashTable::ShallowSizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
-diff --git a/xpcom/ds/PLDHashTable.h b/xpcom/ds/PLDHashTable.h
---- a/xpcom/ds/PLDHashTable.h
-+++ b/xpcom/ds/PLDHashTable.h
-@@ -5,22 +5,24 @@
-  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
- 
- #ifndef PLDHashTable_h
- #define PLDHashTable_h
- 
- #include "mozilla/Atomics.h"
- #include "mozilla/Attributes.h" // for MOZ_ALWAYS_INLINE
- #include "mozilla/fallible.h"
-+#include "mozilla/HashFunctions.h"
- #include "mozilla/MemoryReporting.h"
- #include "mozilla/Move.h"
- #include "mozilla/Types.h"
- #include "nscore.h"
- 
--typedef uint32_t PLDHashNumber;
-+using PLDHashNumber = mozilla::HashNumber;
-+static const uint32_t kPLDHashNumberBits = mozilla::kHashNumberBits;
- 
- class PLDHashTable;
- struct PLDHashTableOps;
- 
- // Table entry header structure.
- //
- // In order to allow in-line allocation of key and value, we do not declare
- // either here. Instead, the API uses const void *key as a formal parameter.
-@@ -498,17 +500,16 @@ public:
-   Iterator ConstIter() const
-   {
-     return Iterator(const_cast<PLDHashTable*>(this));
-   }
- 
- private:
-   // Multiplicative hash uses an unsigned 32 bit integer and the golden ratio,
-   // expressed as a fixed-point 32-bit fraction.
--  static const uint32_t kHashBits = 32;
-   static const uint32_t kGoldenRatio = 0x9E3779B9U;
- 
-   static uint32_t HashShift(uint32_t aEntrySize, uint32_t aLength);
- 
-   static const PLDHashNumber kCollisionFlag = 1;
- 
-   static bool EntryIsFree(const PLDHashEntryHdr* aEntry)
-   {
-@@ -539,17 +540,17 @@ private:
-   static bool MatchEntryKeyhash(const PLDHashEntryHdr* aEntry,
-                                 const PLDHashNumber aHash);
-   PLDHashEntryHdr* AddressEntry(uint32_t aIndex) const;
- 
-   // We store mHashShift rather than sizeLog2 to optimize the collision-free
-   // case in SearchTable.
-   uint32_t CapacityFromHashShift() const
-   {
--    return ((uint32_t)1 << (kHashBits - mHashShift));
-+    return ((uint32_t)1 << (kPLDHashNumberBits - mHashShift));
-   }
- 
-   PLDHashNumber ComputeKeyHash(const void* aKey) const;
- 
-   enum SearchReason { ForSearchOrRemove, ForAdd };
- 
-   template <SearchReason Reason>
-   PLDHashEntryHdr* NS_FASTCALL

+ 0 - 263
frg/work-js/mozilla-release/patches/mozilla-central-push_429317.patch

@@ -1,263 +0,0 @@
-# HG changeset patch
-# User Nicholas Nethercote <nnethercote@mozilla.com>
-# Date 1532595167 -36000
-#      Thu Jul 26 18:52:47 2018 +1000
-# Node ID 2ce09953e25bfbcc4170ed989c028c469b6ea21d
-# Parent  9cf98793e243bd1fa1413d70cf957b9a4f4d54f4
-Bug 1477626 - Move ScrambleHashCode() from js/src/Utility.h to mfbt/HashFunctions.h. r=Waldo
-
-And use it in PLDHashTable.cpp.
-
-MozReview-Commit-ID: BqwEkE0p5AG
-
-diff --git a/js/public/HashTable.h b/js/public/HashTable.h
---- a/js/public/HashTable.h
-+++ b/js/public/HashTable.h
-@@ -1277,17 +1277,17 @@ class HashTable : private AllocPolicy
- 
-     static bool isLiveHash(HashNumber hash)
-     {
-         return Entry::isLiveHash(hash);
-     }
- 
-     static HashNumber prepareHash(const Lookup& l)
-     {
--        HashNumber keyHash = ScrambleHashCode(HashPolicy::hash(l));
-+        HashNumber keyHash = mozilla::ScrambleHashCode(HashPolicy::hash(l));
- 
-         // Avoid reserved hash codes.
-         if (!isLiveHash(keyHash))
-             keyHash -= (sRemovedKey + 1);
-         return keyHash & ~sCollisionBit;
-     }
- 
-     enum FailureBehavior { DontReportFailure = false, ReportFailure = true };
-diff --git a/js/public/Utility.h b/js/public/Utility.h
---- a/js/public/Utility.h
-+++ b/js/public/Utility.h
-@@ -9,17 +9,16 @@
- 
- #include "mozilla/Assertions.h"
- #include "mozilla/Atomics.h"
- #include "mozilla/Attributes.h"
- #include "mozilla/Compiler.h"
- #include "mozilla/Move.h"
- #include "mozilla/TemplateLib.h"
- #include "mozilla/UniquePtr.h"
--#include "mozilla/WrappingOperations.h"
- 
- #include <stdlib.h>
- #include <string.h>
- 
- #ifdef JS_OOM_DO_BACKTRACES
- #include <execinfo.h>
- #include <stdio.h>
- #endif
-@@ -659,61 +658,16 @@ struct FreePolicy
-     }
- };
- 
- typedef mozilla::UniquePtr<char[], JS::FreePolicy> UniqueChars;
- typedef mozilla::UniquePtr<char16_t[], JS::FreePolicy> UniqueTwoByteChars;
- 
- } // namespace JS
- 
--namespace js {
--
--namespace detail {
--
--/*
-- * Given a raw hash code, h, return a number that can be used to select a hash
-- * bucket.
-- *
-- * This function aims to produce as uniform an output distribution as possible,
-- * especially in the most significant (leftmost) bits, even though the input
-- * distribution may be highly nonrandom, given the constraints that this must
-- * be deterministic and quick to compute.
-- *
-- * Since the leftmost bits of the result are best, the hash bucket index is
-- * computed by doing ScrambleHashCode(h) / (2^32/N) or the equivalent
-- * right-shift, not ScrambleHashCode(h) % N or the equivalent bit-mask.
-- *
-- * FIXME: OrderedHashTable uses a bit-mask; see bug 775896.
-- */
--inline uint32_t
--ScrambleHashCode(uint32_t h)
--{
--    /*
--     * Simply returning h would not cause any hash tables to produce wrong
--     * answers. But it can produce pathologically bad performance: The caller
--     * right-shifts the result, keeping only the highest bits. The high bits of
--     * hash codes are very often completely entropy-free. (So are the lowest
--     * bits.)
--     *
--     * So we use Fibonacci hashing, as described in Knuth, The Art of Computer
--     * Programming, 6.4. This mixes all the bits of the input hash code h.
--     *
--     * The value of goldenRatio is taken from the hex
--     * expansion of the golden ratio, which starts 1.9E3779B9....
--     * This value is especially good if values with consecutive hash codes
--     * are stored in a hash table; see Knuth for details.
--     */
--    static const uint32_t goldenRatio = 0x9E3779B9U;
--    return mozilla::WrappingMultiply(h, goldenRatio);
--}
--
--} /* namespace detail */
--
--} /* namespace js */
--
- /* sixgill annotation defines */
- #ifndef HAVE_STATIC_ANNOTATIONS
- # define HAVE_STATIC_ANNOTATIONS
- # ifdef XGILL_PLUGIN
- #  define STATIC_PRECONDITION(COND)         __attribute__((precondition(#COND)))
- #  define STATIC_PRECONDITION_ASSUME(COND)  __attribute__((precondition_assume(#COND)))
- #  define STATIC_POSTCONDITION(COND)        __attribute__((postcondition(#COND)))
- #  define STATIC_POSTCONDITION_ASSUME(COND) __attribute__((postcondition_assume(#COND)))
-diff --git a/js/src/ds/OrderedHashTable.h b/js/src/ds/OrderedHashTable.h
---- a/js/src/ds/OrderedHashTable.h
-+++ b/js/src/ds/OrderedHashTable.h
-@@ -613,17 +613,17 @@ class OrderedHashTable
-     /*
-      * The minimum permitted value of (liveCount / dataLength).
-      * If that ratio drops below this value, we shrink the table.
-      */
-     static double minDataFill() { return 0.25; }
- 
-   public:
-     HashNumber prepareHash(const Lookup& l) const {
--        return ScrambleHashCode(Ops::hash(l, hcs));
-+        return mozilla::ScrambleHashCode(Ops::hash(l, hcs));
-     }
- 
-   private:
-     /* The size of hashTable, in elements. Always a power of two. */
-     uint32_t hashBuckets() const {
-         return 1 << (js::kHashNumberBits - hashShift);
-     }
- 
-diff --git a/mfbt/HashFunctions.h b/mfbt/HashFunctions.h
---- a/mfbt/HashFunctions.h
-+++ b/mfbt/HashFunctions.h
-@@ -61,16 +61,52 @@ namespace mozilla {
- using HashNumber = uint32_t;
- static const uint32_t kHashNumberBits = 32;
- 
- /**
-  * The golden ratio as a 32-bit fixed-point value.
-  */
- static const HashNumber kGoldenRatioU32 = 0x9E3779B9U;
- 
-+/*
-+ * Given a raw hash code, h, return a number that can be used to select a hash
-+ * bucket.
-+ *
-+ * This function aims to produce as uniform an output distribution as possible,
-+ * especially in the most significant (leftmost) bits, even though the input
-+ * distribution may be highly nonrandom, given the constraints that this must
-+ * be deterministic and quick to compute.
-+ *
-+ * Since the leftmost bits of the result are best, the hash bucket index is
-+ * computed by doing ScrambleHashCode(h) / (2^32/N) or the equivalent
-+ * right-shift, not ScrambleHashCode(h) % N or the equivalent bit-mask.
-+ *
-+ * FIXME: OrderedHashTable uses a bit-mask; see bug 775896.
-+ */
-+constexpr HashNumber
-+ScrambleHashCode(HashNumber h)
-+{
-+  /*
-+   * Simply returning h would not cause any hash tables to produce wrong
-+   * answers. But it can produce pathologically bad performance: The caller
-+   * right-shifts the result, keeping only the highest bits. The high bits of
-+   * hash codes are very often completely entropy-free. (So are the lowest
-+   * bits.)
-+   *
-+   * So we use Fibonacci hashing, as described in Knuth, The Art of Computer
-+   * Programming, 6.4. This mixes all the bits of the input hash code h.
-+   *
-+   * The value of goldenRatio is taken from the hex expansion of the golden
-+   * ratio, which starts 1.9E3779B9.... This value is especially good if
-+   * values with consecutive hash codes are stored in a hash table; see Knuth
-+   * for details.
-+   */
-+  return mozilla::WrappingMultiply(h, kGoldenRatioU32);
-+}
-+
- namespace detail {
- 
- MOZ_NO_SANITIZE_UNSIGNED_OVERFLOW
- constexpr HashNumber
- RotateLeft5(HashNumber aValue)
- {
-   return (aValue << 5) | (aValue >> 27);
- }
-diff --git a/xpcom/ds/PLDHashTable.cpp b/xpcom/ds/PLDHashTable.cpp
---- a/xpcom/ds/PLDHashTable.cpp
-+++ b/xpcom/ds/PLDHashTable.cpp
-@@ -523,18 +523,17 @@ PLDHashTable::ChangeTable(int32_t aDelta
-   return true;
- }
- 
- MOZ_ALWAYS_INLINE PLDHashNumber
- PLDHashTable::ComputeKeyHash(const void* aKey) const
- {
-   MOZ_ASSERT(mEntryStore.Get());
- 
--  PLDHashNumber keyHash = mOps->hashKey(aKey);
--  keyHash *= kGoldenRatio;
-+  PLDHashNumber keyHash = mozilla::ScrambleHashCode(mOps->hashKey(aKey));
- 
-   // Avoid 0 and 1 hash codes, they indicate free and removed entries.
-   if (keyHash < 2) {
-     keyHash -= 2;
-   }
-   keyHash &= ~kCollisionFlag;
- 
-   return keyHash;
-diff --git a/xpcom/ds/PLDHashTable.h b/xpcom/ds/PLDHashTable.h
---- a/xpcom/ds/PLDHashTable.h
-+++ b/xpcom/ds/PLDHashTable.h
-@@ -28,18 +28,18 @@ struct PLDHashTableOps;
- // either here. Instead, the API uses const void *key as a formal parameter.
- // The key need not be stored in the entry; it may be part of the value, but
- // need not be stored at all.
- //
- // Callback types are defined below and grouped into the PLDHashTableOps
- // structure, for single static initialization per hash table sub-type.
- //
- // Each hash table sub-type should make its entry type a subclass of
--// PLDHashEntryHdr. The mKeyHash member contains the result of multiplying the
--// hash code returned from the hashKey callback (see below) by kGoldenRatio,
-+// PLDHashEntryHdr. The mKeyHash member contains the result of suitably
-+// scrambling the hash code returned from the hashKey callback (see below),
- // then constraining the result to avoid the magic 0 and 1 values. The stored
- // mKeyHash value is table size invariant, and it is maintained automatically
- // -- users need never access it.
- struct PLDHashEntryHdr
- {
- private:
-   friend class PLDHashTable;
- 
-@@ -498,20 +498,16 @@ public:
-   // Use this if you need to initialize an Iterator in a const method. If you
-   // use this case, you should not call Remove() on the iterator.
-   Iterator ConstIter() const
-   {
-     return Iterator(const_cast<PLDHashTable*>(this));
-   }
- 
- private:
--  // Multiplicative hash uses an unsigned 32 bit integer and the golden ratio,
--  // expressed as a fixed-point 32-bit fraction.
--  static const uint32_t kGoldenRatio = 0x9E3779B9U;
--
-   static uint32_t HashShift(uint32_t aEntrySize, uint32_t aLength);
- 
-   static const PLDHashNumber kCollisionFlag = 1;
- 
-   static bool EntryIsFree(const PLDHashEntryHdr* aEntry)
-   {
-     return aEntry->mKeyHash == 0;
-   }

+ 0 - 72
frg/work-js/mozilla-release/patches/mozilla-central-push_429318.patch

@@ -1,72 +0,0 @@
-# HG changeset patch
-# User Nicholas Nethercote <nnethercote@mozilla.com>
-# Date 1532599975 -36000
-#      Thu Jul 26 20:12:55 2018 +1000
-# Node ID f953e6b321c522d50fe137601694805dea19a9cf
-# Parent  2ce09953e25bfbcc4170ed989c028c469b6ea21d
-Bug 1477626 - Remove use of JS_BIT in js/src/HashTable.h. r=Waldo
-
-MozReview-Commit-ID: DRba0Z0Olo0
-
-diff --git a/js/public/HashTable.h b/js/public/HashTable.h
---- a/js/public/HashTable.h
-+++ b/js/public/HashTable.h
-@@ -1252,18 +1252,18 @@ class HashTable : private AllocPolicy
- #   define METER(x) x
- #else
- #   define METER(x)
- #endif
- 
-     // The default initial capacity is 32 (enough to hold 16 elements), but it
-     // can be as low as 4.
-     static const uint32_t sMinCapacity  = 4;
--    static const uint32_t sMaxInit      = JS_BIT(CAP_BITS - 1);
--    static const uint32_t sMaxCapacity  = JS_BIT(CAP_BITS);
-+    static const uint32_t sMaxInit      = 1u << (CAP_BITS - 1);
-+    static const uint32_t sMaxCapacity  = 1u << CAP_BITS;
- 
-     // Hash-table alpha is conceptually a fraction, but to avoid floating-point
-     // math we implement it as a ratio of integers.
-     static const uint8_t sAlphaDenominator = 4;
-     static const uint8_t sMinAlphaNumerator = 1; // min alpha: 1/4
-     static const uint8_t sMaxAlphaNumerator = 3; // max alpha: 3/4
- 
-     static const HashNumber sFreeKey = Entry::sFreeKey;
-@@ -1549,17 +1549,17 @@ class HashTable : private AllocPolicy
-     enum RebuildStatus { NotOverloaded, Rehashed, RehashFailed };
- 
-     RebuildStatus changeTableSize(int deltaLog2, FailureBehavior reportFailure = ReportFailure)
-     {
-         // Look, but don't touch, until we succeed in getting new entry store.
-         Entry* oldTable = table;
-         uint32_t oldCap = capacity();
-         uint32_t newLog2 = js::kHashNumberBits - hashShift + deltaLog2;
--        uint32_t newCapacity = JS_BIT(newLog2);
-+        uint32_t newCapacity = 1u << newLog2;
-         if (MOZ_UNLIKELY(newCapacity > sMaxCapacity)) {
-             if (reportFailure)
-                 this->reportAllocOverflow();
-             return RehashFailed;
-         }
- 
-         Entry* newTable = createTable(*this, newCapacity, reportFailure);
-         if (!newTable)
-@@ -1787,17 +1787,17 @@ class HashTable : private AllocPolicy
-     {
-         MOZ_ASSERT(table);
-         return entryCount;
-     }
- 
-     uint32_t capacity() const
-     {
-         MOZ_ASSERT(table);
--        return JS_BIT(js::kHashNumberBits - hashShift);
-+        return 1u << (js::kHashNumberBits - hashShift);
-     }
- 
-     Generation generation() const
-     {
-         MOZ_ASSERT(table);
-         return Generation(gen);
-     }
- 

+ 0 - 413
frg/work-js/mozilla-release/patches/mozilla-central-push_429320.patch

@@ -1,413 +0,0 @@
-# HG changeset patch
-# User Tooru Fujisawa <arai_a@mac.com>
-# Date 1533007383 -32400
-#      Tue Jul 31 12:23:03 2018 +0900
-# Node ID 3efa24f1f0ce19ba688e4fecd43aba07a0e07710
-# Parent  4ab2e8e356bec4b7757519178a543faf3daca104
-Bug 1477157 - Store the info about the existence of the default case into the switch ParseNode. r=jwalden
-
-diff --git a/js/src/frontend/BinSource-auto.cpp b/js/src/frontend/BinSource-auto.cpp
---- a/js/src/frontend/BinSource-auto.cpp
-+++ b/js/src/frontend/BinSource-auto.cpp
-@@ -6402,17 +6402,17 @@ BinASTParser<Tok>::parseInterfaceSwitchS
-     MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields));
- #endif // defined(DEBUG)
- 
-     BINJS_MOZ_TRY_DECL(discriminant, parseExpression());
- 
-     BINJS_MOZ_TRY_DECL(cases, parseListOfSwitchCase());
- 
-     BINJS_TRY_DECL(scope, factory_.newLexicalScope(nullptr, cases));
--    BINJS_TRY_DECL(result, factory_.newSwitchStatement(start, discriminant, scope));
-+    BINJS_TRY_DECL(result, factory_.newSwitchStatement(start, discriminant, scope, false));
-     return result;
- }
- 
- 
- /*
-  interface SwitchStatementWithDefault : Node {
-     Expression discriminant;
-     FrozenArray<SwitchCase> preDefaultCases;
-@@ -6462,17 +6462,17 @@ BinASTParser<Tok>::parseInterfaceSwitchS
-     factory_.addList(cases, defaultCase);
-     ParseNode* iter = postDefaultCases->pn_head;
-     while (iter) {
-         ParseNode* next = iter->pn_next;
-         factory_.addList(cases, iter);
-         iter = next;
-     }
-     BINJS_TRY_DECL(scope, factory_.newLexicalScope(nullptr, cases));
--    BINJS_TRY_DECL(result, factory_.newSwitchStatement(start, discriminant, scope));
-+    BINJS_TRY_DECL(result, factory_.newSwitchStatement(start, discriminant, scope, true));
-     return result;
- }
- 
- 
- /*
-  interface TemplateElement : Node {
-     string rawValue;
-  }
-diff --git a/js/src/frontend/BinSource.yaml b/js/src/frontend/BinSource.yaml
---- a/js/src/frontend/BinSource.yaml
-+++ b/js/src/frontend/BinSource.yaml
-@@ -900,31 +900,31 @@ SwitchCase:
- 
- SwitchDefault:
-     build: |
-         BINJS_TRY_DECL(result, factory_.newCaseOrDefault(start, nullptr, consequent));
- 
- SwitchStatement:
-     build: |
-         BINJS_TRY_DECL(scope, factory_.newLexicalScope(nullptr, cases));
--        BINJS_TRY_DECL(result, factory_.newSwitchStatement(start, discriminant, scope));
-+        BINJS_TRY_DECL(result, factory_.newSwitchStatement(start, discriminant, scope, false));
- 
- SwitchStatementWithDefault:
-     build: |
-         // Concatenate `preDefaultCase`, `defaultCase`, `postDefaultCase`
-         auto cases = preDefaultCases;
-         factory_.addList(cases, defaultCase);
-         ParseNode* iter = postDefaultCases->pn_head;
-         while (iter) {
-             ParseNode* next = iter->pn_next;
-             factory_.addList(cases, iter);
-             iter = next;
-         }
-         BINJS_TRY_DECL(scope, factory_.newLexicalScope(nullptr, cases));
--        BINJS_TRY_DECL(result, factory_.newSwitchStatement(start, discriminant, scope));
-+        BINJS_TRY_DECL(result, factory_.newSwitchStatement(start, discriminant, scope, true));
- 
- StaticMemberAssignmentTarget:
-     build: |
-         BINJS_TRY_DECL(result, factory_.newPropertyAccess(object, property->asPropertyName(), start));
- 
- StaticMemberExpression:
-     build: |
-         BINJS_TRY_DECL(result, factory_.newPropertyAccess(object, property->asPropertyName(), start));
-diff --git a/js/src/frontend/BytecodeEmitter.cpp b/js/src/frontend/BytecodeEmitter.cpp
---- a/js/src/frontend/BytecodeEmitter.cpp
-+++ b/js/src/frontend/BytecodeEmitter.cpp
-@@ -2335,33 +2335,33 @@ BytecodeEmitter::emitNumberOp(double dva
- }
- 
- /*
-  * Using MOZ_NEVER_INLINE in here is a workaround for llvm.org/pr14047.
-  * LLVM is deciding to inline this function which uses a lot of stack space
-  * into emitTree which is recursive and uses relatively little stack space.
-  */
- MOZ_NEVER_INLINE bool
--BytecodeEmitter::emitSwitch(ParseNode* pn)
--{
--    ParseNode* lexical = pn->pn_right;
--    MOZ_ASSERT(lexical->isKind(ParseNodeKind::LexicalScope));
--    ParseNode* cases = lexical->scopeBody();
-+BytecodeEmitter::emitSwitch(SwitchStatement* pn)
-+{
-+    ParseNode& lexical = pn->lexicalForCaseList();
-+    MOZ_ASSERT(lexical.isKind(ParseNodeKind::LexicalScope));
-+    ParseNode* cases = lexical.scopeBody();
-     MOZ_ASSERT(cases->isKind(ParseNodeKind::StatementList));
- 
-     SwitchEmitter se(this);
-     if (!se.emitDiscriminant(Some(pn->pn_pos.begin)))
-         return false;
--    if (!emitTree(pn->pn_left))
-+    if (!emitTree(&pn->discriminant()))
-         return false;
- 
-     // Enter the scope before pushing the switch BreakableControl since all
-     // breaks are under this scope.
--    if (!lexical->isEmptyScope()) {
--        if (!se.emitLexical(lexical->scopeBindings()))
-+    if (!lexical.isEmptyScope()) {
-+        if (!se.emitLexical(lexical.scopeBindings()))
-             return false;
- 
-         // A switch statement may contain hoisted functions inside its
-         // cases. The PNX_FUNCDEFS flag is propagated from the STATEMENTLIST
-         // bodies of the cases to the case list.
-         if (cases->pn_xflags & PNX_FUNCDEFS) {
-             for (ParseNode* caseNode = cases->pn_head; caseNode; caseNode = caseNode->pn_next) {
-                 if (caseNode->pn_right->pn_xflags & PNX_FUNCDEFS) {
-@@ -2370,44 +2370,36 @@ BytecodeEmitter::emitSwitch(ParseNode* p
-                 }
-             }
-         }
-     } else {
-         MOZ_ASSERT(!(cases->pn_xflags & PNX_FUNCDEFS));
-     }
- 
-     SwitchEmitter::TableGenerator tableGen(this);
--    uint32_t caseCount = cases->pn_count;
-+    uint32_t caseCount = cases->pn_count - (pn->hasDefault() ? 1 : 0);
-     CaseClause* firstCase = cases->pn_head ? &cases->pn_head->as<CaseClause>() : nullptr;
-     if (caseCount == 0) {
-         tableGen.finish(0);
--    } else if (caseCount == 1 && firstCase->isDefault()) {
--        caseCount = 0;
--        tableGen.finish(0);
-     } else {
-         for (CaseClause* caseNode = firstCase; caseNode; caseNode = caseNode->next()) {
--            if (caseNode->isDefault()) {
--                caseCount--;  // one of the "cases" was the default
--                continue;
--            }
--
--            if (tableGen.isInvalid())
-+            if (caseNode->isDefault())
-                 continue;
- 
-             ParseNode* caseValue = caseNode->caseExpression();
- 
-             if (caseValue->getKind() != ParseNodeKind::Number) {
-                 tableGen.setInvalid();
--                continue;
-+                break;
-             }
- 
-             int32_t i;
-             if (!NumberEqualsInt32(caseValue->pn_dval, &i)) {
-                 tableGen.setInvalid();
--                continue;
-+                break;
-             }
- 
-             if (!tableGen.addNumber(i))
-                 return false;
-         }
- 
-         tableGen.finish(caseCount);
-     }
-@@ -8310,17 +8302,17 @@ BytecodeEmitter::emitTree(ParseNode* pn,
-         break;
- 
-       case ParseNodeKind::If:
-         if (!emitIf(pn))
-             return false;
-         break;
- 
-       case ParseNodeKind::Switch:
--        if (!emitSwitch(pn))
-+        if (!emitSwitch(&pn->as<SwitchStatement>()))
-             return false;
-         break;
- 
-       case ParseNodeKind::While:
-         if (!emitWhile(pn))
-             return false;
-         break;
- 
-diff --git a/js/src/frontend/BytecodeEmitter.h b/js/src/frontend/BytecodeEmitter.h
---- a/js/src/frontend/BytecodeEmitter.h
-+++ b/js/src/frontend/BytecodeEmitter.h
-@@ -683,17 +683,17 @@ struct MOZ_STACK_CLASS BytecodeEmitter
-     MOZ_MUST_USE bool emitCatch(ParseNode* pn);
-     MOZ_MUST_USE bool emitIf(ParseNode* pn);
-     MOZ_MUST_USE bool emitWith(ParseNode* pn);
- 
-     MOZ_NEVER_INLINE MOZ_MUST_USE bool emitLabeledStatement(const LabeledStatement* pn);
-     MOZ_NEVER_INLINE MOZ_MUST_USE bool emitLexicalScope(ParseNode* pn);
-     MOZ_MUST_USE bool emitLexicalScopeBody(ParseNode* body,
-                                            EmitLineNumberNote emitLineNote = EMIT_LINENOTE);
--    MOZ_NEVER_INLINE MOZ_MUST_USE bool emitSwitch(ParseNode* pn);
-+    MOZ_NEVER_INLINE MOZ_MUST_USE bool emitSwitch(SwitchStatement* pn);
-     MOZ_NEVER_INLINE MOZ_MUST_USE bool emitTry(ParseNode* pn);
- 
-     enum DestructuringFlavor {
-         // Destructuring into a declaration.
-         DestructuringDeclaration,
- 
-         // Destructuring into a formal parameter, when the formal parameters
-         // contain an expression that might be evaluated, and thus require
-diff --git a/js/src/frontend/FullParseHandler.h b/js/src/frontend/FullParseHandler.h
---- a/js/src/frontend/FullParseHandler.h
-+++ b/js/src/frontend/FullParseHandler.h
-@@ -604,19 +604,20 @@ class FullParseHandler
- 
-     ParseNode* newForInOrOfHead(ParseNodeKind kind, ParseNode* target, ParseNode* iteratedExpr,
-                                 const TokenPos& pos)
-     {
-         MOZ_ASSERT(kind == ParseNodeKind::ForIn || kind == ParseNodeKind::ForOf);
-         return new_<TernaryNode>(kind, target, nullptr, iteratedExpr, pos);
-     }
- 
--    ParseNode* newSwitchStatement(uint32_t begin, ParseNode* discriminant, ParseNode* caseList) {
--        TokenPos pos(begin, caseList->pn_pos.end);
--        return new_<BinaryNode>(ParseNodeKind::Switch, JSOP_NOP, pos, discriminant, caseList);
-+    ParseNode* newSwitchStatement(uint32_t begin, ParseNode* discriminant,
-+                                  ParseNode* lexicalForCaseList, bool hasDefault)
-+    {
-+        return new_<SwitchStatement>(begin, discriminant, lexicalForCaseList, hasDefault);
-     }
- 
-     ParseNode* newCaseOrDefault(uint32_t begin, ParseNode* expr, ParseNode* body) {
-         return new_<CaseClause>(expr, body, begin);
-     }
- 
-     ParseNode* newContinueStatement(PropertyName* label, const TokenPos& pos) {
-         return new_<ContinueStatement>(label, pos);
-diff --git a/js/src/frontend/ParseNode.h b/js/src/frontend/ParseNode.h
---- a/js/src/frontend/ParseNode.h
-+++ b/js/src/frontend/ParseNode.h
-@@ -253,16 +253,17 @@ IsTypeofKind(ParseNodeKind kind)
-  *
-  * <Statements>
-  * StatementList list   pn_head: list of pn_count statements
-  * If       ternary     pn_kid1: cond, pn_kid2: then, pn_kid3: else or null.
-  * Switch   binary      pn_left: discriminant
-  *                      pn_right: LexicalScope node that contains the list
-  *                        of Case nodes, with at most one
-  *                        default node.
-+ *                      hasDefault: true if there's a default case
-  * Case     binary      pn_left: case-expression if CaseClause, or
-  *                            null if DefaultClause
-  *                          pn_right: StatementList node for this case's
-  *                            statements
-  * While    binary      pn_left: cond, pn_right: body
-  * DoWhile  binary      pn_left: body, pn_right: cond
-  * For      binary      pn_left: either ForIn (for-in statement),
-  *                            ForOf (for-of) or ForHead (for(;;))
-@@ -550,16 +551,17 @@ class ParseNode
-             ParseNode*  kid3;           /* else-part, default case, etc. */
-         } ternary;
-         struct {                        /* two kids if binary */
-             ParseNode*  left;
-             ParseNode*  right;
-             union {
-                 unsigned iflags;        /* JSITER_* flags for ParseNodeKind::For node */
-                 bool isStatic;          /* only for ParseNodeKind::ClassMethod */
-+                bool hasDefault;        /* only for ParseNodeKind::Switch */
-             };
-         } binary;
-         struct {                        /* one kid if unary */
-             ParseNode*  kid;
-             bool        prologue;       /* directive prologue member (as
-                                            pn_prologue) */
-         } unary;
-         struct {                        /* name, labeled statement, etc. */
-@@ -1239,17 +1241,17 @@ struct CallSiteNode : public ListNode {
- 
-     MOZ_MUST_USE bool getRawArrayValue(JSContext* cx, MutableHandleValue vp) {
-         return pn_head->getConstantValue(cx, AllowObjects, vp);
-     }
- };
- 
- struct ClassMethod : public BinaryNode {
-     /*
--     * Method defintions often keep a name and function body that overlap,
-+     * Method definitions often keep a name and function body that overlap,
-      * so explicitly define the beginning and end here.
-      */
-     ClassMethod(ParseNode* name, ParseNode* body, JSOp op, bool isStatic)
-       : BinaryNode(ParseNodeKind::ClassMethod, op, TokenPos(name->pn_pos.begin, body->pn_pos.end), name, body)
-     {
-         pn_u.binary.isStatic = isStatic;
-     }
- 
-@@ -1265,16 +1267,58 @@ struct ClassMethod : public BinaryNode {
-     ParseNode& method() const {
-         return *pn_u.binary.right;
-     }
-     bool isStatic() const {
-         return pn_u.binary.isStatic;
-     }
- };
- 
-+struct SwitchStatement : public BinaryNode {
-+    SwitchStatement(uint32_t begin, ParseNode* discriminant, ParseNode* lexicalForCaseList,
-+                    bool hasDefault)
-+      : BinaryNode(ParseNodeKind::Switch, JSOP_NOP,
-+                   TokenPos(begin, lexicalForCaseList->pn_pos.end),
-+                   discriminant, lexicalForCaseList)
-+    {
-+#ifdef DEBUG
-+        MOZ_ASSERT(lexicalForCaseList->isKind(ParseNodeKind::LexicalScope));
-+        ParseNode* cases = lexicalForCaseList->scopeBody();
-+        MOZ_ASSERT(cases->isKind(ParseNodeKind::StatementList));
-+        bool found = false;
-+        CaseClause* firstCase = cases->pn_head ? &cases->pn_head->as<CaseClause>() : nullptr;
-+        for (CaseClause* caseNode = firstCase; caseNode; caseNode = caseNode->next()) {
-+            if (caseNode->isDefault()) {
-+                found = true;
-+                break;
-+            }
-+        }
-+        MOZ_ASSERT(found == hasDefault);
-+#endif
-+
-+        pn_u.binary.hasDefault = hasDefault;
-+    }
-+
-+    static bool test(const ParseNode& node) {
-+        bool match = node.isKind(ParseNodeKind::Switch);
-+        MOZ_ASSERT_IF(match, node.isArity(PN_BINARY));
-+        return match;
-+    }
-+
-+    ParseNode& discriminant() const {
-+        return *pn_u.binary.left;
-+    }
-+    ParseNode& lexicalForCaseList() const {
-+        return *pn_u.binary.right;
-+    }
-+    bool hasDefault() const {
-+        return pn_u.binary.hasDefault;
-+    }
-+};
-+
- struct ClassNames : public BinaryNode {
-     ClassNames(ParseNode* outerBinding, ParseNode* innerBinding, const TokenPos& pos)
-       : BinaryNode(ParseNodeKind::ClassNames, JSOP_NOP, pos, outerBinding, innerBinding)
-     {
-         MOZ_ASSERT_IF(outerBinding, outerBinding->isKind(ParseNodeKind::Name));
-         MOZ_ASSERT(innerBinding->isKind(ParseNodeKind::Name));
-         MOZ_ASSERT_IF(outerBinding, innerBinding->pn_atom == outerBinding->pn_atom);
-     }
-diff --git a/js/src/frontend/Parser.cpp b/js/src/frontend/Parser.cpp
---- a/js/src/frontend/Parser.cpp
-+++ b/js/src/frontend/Parser.cpp
-@@ -6760,17 +6760,17 @@ GeneralParser<ParseHandler, CharT>::swit
-     }
- 
-     caseList = finishLexicalScope(scope, caseList);
-     if (!caseList)
-         return null();
- 
-     handler.setEndPosition(caseList, pos().end);
- 
--    return handler.newSwitchStatement(begin, discriminant, caseList);
-+    return handler.newSwitchStatement(begin, discriminant, caseList, seenDefault);
- }
- 
- template <class ParseHandler, typename CharT>
- typename ParseHandler::Node
- GeneralParser<ParseHandler, CharT>::continueStatement(YieldHandling yieldHandling)
- {
-     MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::Continue));
-     uint32_t begin = pos().begin;
-diff --git a/js/src/frontend/SyntaxParseHandler.h b/js/src/frontend/SyntaxParseHandler.h
---- a/js/src/frontend/SyntaxParseHandler.h
-+++ b/js/src/frontend/SyntaxParseHandler.h
-@@ -305,17 +305,21 @@ class SyntaxParseHandler
- 
-     Node newExprStatement(Node expr, uint32_t end) {
-         return expr == NodeUnparenthesizedString ? NodeStringExprStatement : NodeGeneric;
-     }
- 
-     Node newIfStatement(uint32_t begin, Node cond, Node then, Node else_) { return NodeGeneric; }
-     Node newDoWhileStatement(Node body, Node cond, const TokenPos& pos) { return NodeGeneric; }
-     Node newWhileStatement(uint32_t begin, Node cond, Node body) { return NodeGeneric; }
--    Node newSwitchStatement(uint32_t begin, Node discriminant, Node caseList) { return NodeGeneric; }
-+    Node newSwitchStatement(uint32_t begin, Node discriminant, Node lexicalForCaseList,
-+                            bool hasDefault)
-+    {
-+        return NodeGeneric;
-+    }
-     Node newCaseOrDefault(uint32_t begin, Node expr, Node body) { return NodeGeneric; }
-     Node newContinueStatement(PropertyName* label, const TokenPos& pos) { return NodeGeneric; }
-     Node newBreakStatement(PropertyName* label, const TokenPos& pos) { return NodeBreak; }
-     Node newReturnStatement(Node expr, const TokenPos& pos) { return NodeReturn; }
-     Node newExpressionBody(Node expr) { return NodeReturn; }
-     Node newWithStatement(uint32_t begin, Node expr, Node body) { return NodeGeneric; }
- 
-     Node newLabeledStatement(PropertyName* label, Node stmt, uint32_t begin) {

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