Bug 1332378 - Worklet must evaluate scripts in the right JS compartment, r=nbp
authorAndrea Marchesini <amarchesini@mozilla.com>
Fri, 20 Jan 2017 14:39:39 +0100
changeset 358376 7d0b7d6ae3cad08f730adb5c6d49c48244bb7329
parent 358375 ece477bc26a761831519a9ad9893c504dcd14f03
child 358377 13545155cfc0d3124aba1b2f7b73a36b1d9b08b0
push id10621
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 16:02:43 +0000
treeherdermozilla-aurora@dca7b42e6c67 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnbp
bugs1332378
milestone53.0a1
Bug 1332378 - Worklet must evaluate scripts in the right JS compartment, r=nbp
dom/worklet/Worklet.cpp
--- a/dom/worklet/Worklet.cpp
+++ b/dom/worklet/Worklet.cpp
@@ -203,16 +203,18 @@ public:
     compileOptions.setFileAndLine(NS_ConvertUTF16toUTF8(mURL).get(), 0);
     compileOptions.setVersion(JSVERSION_DEFAULT);
     compileOptions.setIsRunOnce(true);
 
     // We only need the setNoScriptRval bit when compiling off-thread here,
     // since otherwise nsJSUtils::EvaluateString will set it up for us.
     compileOptions.setNoScriptRval(true);
 
+    JSAutoCompartment comp(cx, globalObj);
+
     JS::Rooted<JS::Value> unused(cx);
     if (!JS::Evaluate(cx, compileOptions, buffer, &unused)) {
       ErrorResult error;
       error.MightThrowJSException();
       error.StealExceptionFromJSContext(cx);
       RejectPromises(error.StealNSResult());
       return NS_OK;
     }