Bug 1479363 part 10 - Use JSAutoRealm instead of JSAutoRealmAllowCCW in other directories. r=mrbkap
authorJan de Mooij <jdemooij@mozilla.com>
Thu, 02 Aug 2018 19:30:17 +0200
changeset 429892 f5545b566fd7fddf676fde944562c6986ca0cba5
parent 429891 6b45f9604ee3a2abad4cbdf29808be817aced99b
child 429893 bf9e613634df8b0081ada0ceef2c1f5f0aeee7c5
push id34375
push usernbeleuzu@mozilla.com
push dateThu, 02 Aug 2018 22:28:56 +0000
treeherdermozilla-central@b1c100e2b29a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmrbkap
bugs1479363
milestone63.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 1479363 part 10 - Use JSAutoRealm instead of JSAutoRealmAllowCCW in other directories. r=mrbkap
devtools/shared/heapsnapshot/tests/gtest/DevTools.h
devtools/shared/heapsnapshot/tests/gtest/DoesCrossCompartmentBoundaries.cpp
devtools/shared/heapsnapshot/tests/gtest/DoesntCrossCompartmentBoundaries.cpp
extensions/pref/autoconfig/src/nsJSConfigTriggers.cpp
ipc/testshell/XPCShellEnvironment.cpp
js/ductwork/debugger/JSDebugger.cpp
js/ipc/JavaScriptParent.cpp
js/ipc/JavaScriptShared.cpp
js/ipc/WrapperOwner.cpp
netwerk/base/ProxyAutoConfig.cpp
toolkit/components/extensions/MatchPattern.cpp
toolkit/components/mozintl/MozIntlHelper.cpp
--- a/devtools/shared/heapsnapshot/tests/gtest/DevTools.h
+++ b/devtools/shared/heapsnapshot/tests/gtest/DevTools.h
@@ -89,17 +89,17 @@ struct DevTools : public ::testing::Test
     /* Create the global object. */
     JS::RootedObject newGlobal(cx);
     JS::RealmOptions options;
     newGlobal = JS_NewGlobalObject(cx, getGlobalClass(), nullptr,
                                    JS::FireOnNewGlobalHook, options);
     if (!newGlobal)
       return nullptr;
 
-    JSAutoRealmAllowCCW ar(cx, newGlobal);
+    JSAutoRealm ar(cx, newGlobal);
 
     /* Populate the global object with the standard globals, like Object and
        Array. */
     if (!JS::InitRealmStandardClasses(cx))
       return nullptr;
 
     return newGlobal;
   }
--- a/devtools/shared/heapsnapshot/tests/gtest/DoesCrossCompartmentBoundaries.cpp
+++ b/devtools/shared/heapsnapshot/tests/gtest/DoesCrossCompartmentBoundaries.cpp
@@ -13,17 +13,17 @@ DEF_TEST(DoesCrossCompartmentBoundaries,
     JS::RootedObject newGlobal(cx, JS_NewGlobalObject(cx,
                                                       getGlobalClass(),
                                                       nullptr,
                                                       JS::FireOnNewGlobalHook,
                                                       options));
     ASSERT_TRUE(newGlobal);
     JS::Compartment* newCompartment = nullptr;
     {
-      JSAutoRealmAllowCCW ar(cx, newGlobal);
+      JSAutoRealm ar(cx, newGlobal);
       ASSERT_TRUE(JS::InitRealmStandardClasses(cx));
       newCompartment = js::GetContextCompartment(cx);
     }
     ASSERT_TRUE(newCompartment);
     ASSERT_NE(newCompartment, compartment);
 
     // Our set of target compartments is both the old and new compartments.
     JS::CompartmentSet targetCompartments;
--- a/devtools/shared/heapsnapshot/tests/gtest/DoesntCrossCompartmentBoundaries.cpp
+++ b/devtools/shared/heapsnapshot/tests/gtest/DoesntCrossCompartmentBoundaries.cpp
@@ -13,17 +13,17 @@ DEF_TEST(DoesntCrossCompartmentBoundarie
     JS::RootedObject newGlobal(cx, JS_NewGlobalObject(cx,
                                                       getGlobalClass(),
                                                       nullptr,
                                                       JS::FireOnNewGlobalHook,
                                                       options));
     ASSERT_TRUE(newGlobal);
     JS::Compartment* newCompartment = nullptr;
     {
-      JSAutoRealmAllowCCW ar(cx, newGlobal);
+      JSAutoRealm ar(cx, newGlobal);
       ASSERT_TRUE(JS::InitRealmStandardClasses(cx));
       newCompartment = js::GetContextCompartment(cx);
     }
     ASSERT_TRUE(newCompartment);
     ASSERT_NE(newCompartment, compartment);
 
     // Our set of target compartments is only the pre-existing compartment and
     // does not include the new compartment.
--- a/extensions/pref/autoconfig/src/nsJSConfigTriggers.cpp
+++ b/extensions/pref/autoconfig/src/nsJSConfigTriggers.cpp
@@ -70,17 +70,17 @@ nsresult CentralizedAdminPrefManagerInit
     principal = NullPrincipal::CreateWithoutOriginAttributes();
     rv = xpc->CreateSandbox(cx, principal, sandbox.address());
     NS_ENSURE_SUCCESS(rv, rv);
 
     autoconfigSb.init(cx, js::UncheckedUnwrap(sandbox));
 
 
     // Define gSandbox on system sandbox.
-    JSAutoRealmAllowCCW ac(cx, autoconfigSystemSb);
+    JSAutoRealm ar(cx, autoconfigSystemSb);
 
     JS::Rooted<JS::Value> value(cx, JS::ObjectValue(*sandbox));
 
     if (!JS_WrapValue(cx, &value) ||
         !JS_DefineProperty(cx, autoconfigSystemSb, "gSandbox", value, JSPROP_ENUMERATE)) {
       return NS_ERROR_FAILURE;
     }
 
@@ -165,17 +165,17 @@ nsresult EvaluateAdminConfigScript(JS::H
             NS_LITERAL_STRING("Your AutoConfig file is ASCII. Please convert it to UTF-8."),
             nsIScriptError::warningFlag,
             NS_LITERAL_CSTRING("autoconfig"),
             nullptr);
         /* If the length is 0, the conversion failed. Fallback to ASCII */
         convertedScript = NS_ConvertASCIItoUTF16(script);
     }
     {
-        JSAutoRealmAllowCCW ac(cx, autoconfigSystemSb);
+        JSAutoRealm ar(cx, autoconfigSystemSb);
         JS::Rooted<JS::Value> value(cx, JS::BooleanValue(isUTF8));
         if (!JS_DefineProperty(cx, autoconfigSystemSb, "gIsUTF8", value, JSPROP_ENUMERATE)) {
             return NS_ERROR_UNEXPECTED;
         }
     }
     rv = xpc->EvalInSandboxObject(convertedScript, filename, cx,
                                   sandbox, &v);
     NS_ENSURE_SUCCESS(rv, rv);
--- a/ipc/testshell/XPCShellEnvironment.cpp
+++ b/ipc/testshell/XPCShellEnvironment.cpp
@@ -382,17 +382,17 @@ XPCShellEnvironment::~XPCShellEnvironmen
         AutoJSAPI jsapi;
         if (!jsapi.Init(GetGlobalObject())) {
             return;
         }
         JSContext* cx = jsapi.cx();
         Rooted<JSObject*> global(cx, GetGlobalObject());
 
         {
-            JSAutoRealmAllowCCW ar(cx, global);
+            JSAutoRealm ar(cx, global);
             JS_SetAllNonReservedSlotsToUndefined(cx, global);
         }
         mGlobalHolder.reset();
 
         JS_GC(cx);
     }
 }
 
@@ -443,17 +443,17 @@ XPCShellEnvironment::Init()
         NS_ERROR("InitClassesWithNewWrappedGlobal failed!");
         return false;
     }
 
     if (!globalObj) {
         NS_ERROR("Failed to get global JSObject!");
         return false;
     }
-    JSAutoRealmAllowCCW ar(cx, globalObj);
+    JSAutoRealm ar(cx, globalObj);
 
     backstagePass->SetGlobalObject(globalObj);
 
     JS::Rooted<Value> privateVal(cx, PrivateValue(this));
     if (!JS_DefineProperty(cx, globalObj, "__XPCShellEnvironment",
                            privateVal,
                            JSPROP_READONLY | JSPROP_PERMANENT) ||
         !JS_DefineFunctions(cx, globalObj, gGlobalFunctions) ||
--- a/js/ductwork/debugger/JSDebugger.cpp
+++ b/js/ductwork/debugger/JSDebugger.cpp
@@ -49,17 +49,17 @@ JSDebugger::AddClass(JS::Handle<JS::Valu
   if (!obj) {
     return NS_ERROR_FAILURE;
   }
 
   if (!JS_IsGlobalObject(obj)) {
     return NS_ERROR_INVALID_ARG;
   }
 
-  JSAutoRealmAllowCCW ar(cx, obj);
+  JSAutoRealm ar(cx, obj);
   if (!JS_DefineDebuggerObject(cx, obj)) {
     return NS_ERROR_FAILURE;
   }
 
   if (recordreplay::IsRecordingOrReplaying() || recordreplay::IsMiddleman()) {
     if (!recordreplay::DefineRecordReplayControlObject(cx, obj)) {
       return NS_ERROR_FAILURE;
     }
--- a/js/ipc/JavaScriptParent.cpp
+++ b/js/ipc/JavaScriptParent.cpp
@@ -80,17 +80,17 @@ JavaScriptParent::allowMessage(JSContext
     bool isSafe = channel->IsInTransaction();
 
     if (isSafe)
         return true;
 
     nsIGlobalObject* global = dom::GetIncumbentGlobal();
     JS::Rooted<JSObject*> jsGlobal(cx, global ? global->GetGlobalJSObject() : nullptr);
     if (jsGlobal) {
-        JSAutoRealmAllowCCW ar(cx, jsGlobal);
+        JSAutoRealm ar(cx, jsGlobal);
 
         if (!xpc::CompartmentPrivate::Get(jsGlobal)->allowCPOWs &&
             ForbidUnsafeBrowserCPOWs())
         {
             Telemetry::Accumulate(Telemetry::BROWSER_SHIM_USAGE_BLOCKED, 1);
             JS_ReportErrorASCII(cx, "unsafe CPOW usage forbidden");
             return false;
         }
--- a/js/ipc/JavaScriptShared.cpp
+++ b/js/ipc/JavaScriptShared.cpp
@@ -531,17 +531,17 @@ JavaScriptShared::findObjectById(JSConte
         JS_ReportErrorASCII(cx, "operation not possible on dead CPOW");
         return nullptr;
     }
 
     // Each process has a dedicated compartment for CPOW targets. All CPOWs
     // from the other process point to objects in this scope. From there, they
     // can access objects in other compartments using cross-compartment
     // wrappers.
-    JSAutoRealmAllowCCW ar(cx, scopeForTargetObjects());
+    JSAutoRealm ar(cx, scopeForTargetObjects());
     if (objId.hasXrayWaiver()) {
         {
             JSAutoRealmAllowCCW ar2(cx, obj);
             obj = js::ToWindowProxyIfWindow(obj);
             MOZ_ASSERT(obj);
         }
         if (!xpc::WrapperFactory::WaiveXrayAndWrap(cx, &obj))
             return nullptr;
--- a/js/ipc/WrapperOwner.cpp
+++ b/js/ipc/WrapperOwner.cpp
@@ -1155,17 +1155,17 @@ WrapperOwner::fromRemoteObjectVariant(JS
     }
 
     ObjectId objId = maybeObjId.value();
     RootedObject obj(cx, findCPOWById(objId));
     if (!obj) {
 
         // All CPOWs live in the privileged junk scope.
         RootedObject junkScope(cx, xpc::PrivilegedJunkScope());
-        JSAutoRealmAllowCCW ar(cx, junkScope);
+        JSAutoRealm ar(cx, junkScope);
         RootedValue v(cx, UndefinedValue());
         // We need to setLazyProto for the getPrototype/getPrototypeIfOrdinary
         // hooks.
         ProxyOptions options;
         options.setLazyProto(true);
         obj = NewProxyObject(cx,
                              &CPOWProxyHandler::singleton,
                              v,
--- a/netwerk/base/ProxyAutoConfig.cpp
+++ b/netwerk/base/ProxyAutoConfig.cpp
@@ -658,17 +658,17 @@ private:
     mGlobal = JS_NewGlobalObject(mContext, &sGlobalClass, nullptr,
                                  JS::DontFireOnNewGlobalHook, options);
     if (!mGlobal) {
       JS_ClearPendingException(mContext);
       return NS_ERROR_OUT_OF_MEMORY;
     }
     JS::Rooted<JSObject*> global(mContext, mGlobal);
 
-    JSAutoRealmAllowCCW ar(mContext, global);
+    JSAutoRealm ar(mContext, global);
     AutoPACErrorReporter aper(mContext);
     if (!JS::InitRealmStandardClasses(mContext)) {
       return NS_ERROR_FAILURE;
     }
     if (!JS_DefineFunctions(mContext, global, PACGlobalFunctions)) {
       return NS_ERROR_FAILURE;
     }
 
@@ -735,17 +735,17 @@ ProxyAutoConfig::SetupJS()
   NS_GetCurrentThread()->SetCanInvokeJS(true);
 
   mJSContext = JSContextWrapper::Create(mExtraHeapSize);
   if (!mJSContext)
     return NS_ERROR_FAILURE;
 
   JSContext* cx = mJSContext->Context();
   JSAutoRequest areq(cx);
-  JSAutoRealmAllowCCW ar(cx, mJSContext->Global());
+  JSAutoRealm ar(cx, mJSContext->Global());
   AutoPACErrorReporter aper(cx);
 
   // check if this is a data: uri so that we don't spam the js console with
   // huge meaningless strings. this is not on the main thread, so it can't
   // use nsIURI scheme methods
   bool isDataURI = nsDependentCSubstring(mPACURI, 0, 5).LowerCaseEqualsASCII("data:", 5);
 
   SetRunning(this);
@@ -795,17 +795,17 @@ ProxyAutoConfig::GetProxyForURI(const ns
   if (mJSNeedsSetup)
     SetupJS();
 
   if (!mJSContext || !mJSContext->IsOK())
     return NS_ERROR_NOT_AVAILABLE;
 
   JSContext *cx = mJSContext->Context();
   JSAutoRequest areq(cx);
-  JSAutoRealmAllowCCW ar(cx, mJSContext->Global());
+  JSAutoRealm ar(cx, mJSContext->Global());
   AutoPACErrorReporter aper(cx);
 
   // the sRunning flag keeps a new PAC file from being installed
   // while the event loop is spinning on a DNS function. Don't early return.
   SetRunning(this);
   mRunningHost = aTestHost;
 
   nsresult rv = NS_ERROR_FAILURE;
@@ -862,17 +862,17 @@ ProxyAutoConfig::GetProxyForURI(const ns
 }
 
 void
 ProxyAutoConfig::GC()
 {
   if (!mJSContext || !mJSContext->IsOK())
     return;
 
-  JSAutoRealmAllowCCW ar(mJSContext->Context(), mJSContext->Global());
+  JSAutoRealm ar(mJSContext->Context(), mJSContext->Global());
   JS_MaybeGC(mJSContext->Context());
 }
 
 ProxyAutoConfig::~ProxyAutoConfig()
 {
   MOZ_COUNT_DTOR(ProxyAutoConfig);
   MOZ_ASSERT(mShutdown, "Shutdown must be called before dtor.");
   NS_ASSERTION(!mJSContext,
@@ -1040,9 +1040,9 @@ ProxyAutoConfig::MyIPAddress(const JS::C
     return false;
   }
 
   aArgs.rval().setString(dottedDecimalString);
   return true;
 }
 
 } // namespace net
-} // namespace mozilla
\ No newline at end of file
+} // namespace mozilla
--- a/toolkit/components/extensions/MatchPattern.cpp
+++ b/toolkit/components/extensions/MatchPattern.cpp
@@ -735,17 +735,17 @@ MatchGlob::Init(JSContext* aCx, const ns
 bool
 MatchGlob::Matches(const nsAString& aString) const
 {
   if (mRegExp) {
     AutoJSAPI jsapi;
     jsapi.Init();
     JSContext* cx = jsapi.cx();
 
-    JSAutoRealmAllowCCW ar(cx, mRegExp);
+    JSAutoRealm ar(cx, mRegExp);
 
     JS::RootedObject regexp(cx, mRegExp);
     JS::RootedValue result(cx);
 
     nsString input(aString);
 
     size_t index = 0;
     if (!JS_ExecuteRegExpNoStatics(cx, regexp, input.BeginWriting(), aString.Length(),
--- a/toolkit/components/mozintl/MozIntlHelper.cpp
+++ b/toolkit/components/mozintl/MozIntlHelper.cpp
@@ -25,17 +25,17 @@ AddFunctions(JSContext* cx, JS::Handle<J
     return NS_ERROR_INVALID_ARG;
   }
 
   JS::Rooted<JSObject*> realIntlObj(cx, js::CheckedUnwrap(&val.toObject()));
   if (!realIntlObj) {
     return NS_ERROR_INVALID_ARG;
   }
 
-  JSAutoRealmAllowCCW ar(cx, realIntlObj);
+  JSAutoRealm ar(cx, realIntlObj);
 
   if (!JS_DefineFunctions(cx, realIntlObj, funcs)) {
     return NS_ERROR_FAILURE;
   }
 
   return NS_OK;
 }
 
@@ -68,17 +68,17 @@ MozIntlHelper::AddDateTimeFormatConstruc
     return NS_ERROR_INVALID_ARG;
   }
 
   JS::Rooted<JSObject*> realIntlObj(cx, js::CheckedUnwrap(&val.toObject()));
   if (!realIntlObj) {
     return NS_ERROR_INVALID_ARG;
   }
 
-  JSAutoRealmAllowCCW ar(cx, realIntlObj);
+  JSAutoRealm ar(cx, realIntlObj);
 
   if (!js::AddMozDateTimeFormatConstructor(cx, realIntlObj)) {
     return NS_ERROR_FAILURE;
   }
 
   return NS_OK;
 }
 
@@ -89,17 +89,17 @@ MozIntlHelper::AddRelativeTimeFormatCons
     return NS_ERROR_INVALID_ARG;
   }
 
   JS::Rooted<JSObject*> realIntlObj(cx, js::CheckedUnwrap(&val.toObject()));
   if (!realIntlObj) {
     return NS_ERROR_INVALID_ARG;
   }
 
-  JSAutoRealmAllowCCW ar(cx, realIntlObj);
+  JSAutoRealm ar(cx, realIntlObj);
 
   if (!js::AddRelativeTimeFormatConstructor(cx, realIntlObj)) {
     return NS_ERROR_FAILURE;
   }
 
   return NS_OK;
 }