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 377636 7d0b7d6ae3cad08f730adb5c6d49c48244bb7329
parent 377635 ece477bc26a761831519a9ad9893c504dcd14f03
child 377637 13545155cfc0d3124aba1b2f7b73a36b1d9b08b0
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnbp
bugs1332378
milestone53.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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;
     }