diff --git a/dom/midi/MIDIMessageEvent.cpp b/dom/midi/MIDIMessageEvent.cpp index bf7de42bdea5..f3209a2d0d7e 100644 --- a/dom/midi/MIDIMessageEvent.cpp +++ b/dom/midi/MIDIMessageEvent.cpp @@ -99,7 +99,6 @@ void MIDIMessageEvent::GetData(JSContext* cx, return; } mRawData.Clear(); - JS::ExposeObjectToActiveJS(mData); } aData.set(mData); } diff --git a/dom/promise/Promise.cpp b/dom/promise/Promise.cpp index 24566f6cf78e..cf9cd435362d 100644 --- a/dom/promise/Promise.cpp +++ b/dom/promise/Promise.cpp @@ -359,7 +359,7 @@ static JSObject* CreateNativeHandlerFunction(JSContext* aCx, JS::Rooted obj(aCx, JS_GetFunctionObject(func)); - JS::ExposeObjectToActiveJS(aHolder); + JS::AssertObjectIsNotGray(aHolder); js::SetFunctionNativeReserved(obj, SLOT_NATIVEHANDLER, JS::ObjectValue(*aHolder)); js::SetFunctionNativeReserved(obj, SLOT_NATIVEHANDLER_TASK, diff --git a/dom/prototype/PrototypeDocumentContentSink.cpp b/dom/prototype/PrototypeDocumentContentSink.cpp index de2a681aecb3..2c5741f604c1 100644 --- a/dom/prototype/PrototypeDocumentContentSink.cpp +++ b/dom/prototype/PrototypeDocumentContentSink.cpp @@ -987,9 +987,6 @@ nsresult PrototypeDocumentContentSink::ExecuteScript( JS::Rooted global(cx, JS::CurrentGlobalOrNull(cx)); NS_ENSURE_TRUE(xpc::Scriptability::Get(global).Allowed(), NS_OK); - JS::ExposeObjectToActiveJS(global); - JSAutoRealm ar(cx, global); - // The script is in the compilation scope. Clone it into the target scope // and execute it. On failure, ~AutoScriptEntry will handle exceptions, so // there is no need to manually check the return value. diff --git a/dom/script/ScriptSettings.h b/dom/script/ScriptSettings.h index 2ff5a6f4f82f..8bc2dc18b355 100644 --- a/dom/script/ScriptSettings.h +++ b/dom/script/ScriptSettings.h @@ -214,6 +214,9 @@ class MOZ_STACK_CLASS AutoJSAPI : protected ScriptSettingsStackEntry { // If aGlobalObject represents a web-visible global, errors reported by this // AutoJSAPI as it comes off the stack will fire the relevant error events and // show up in the corresponding web console. + // + // Successfully initializing the AutoJSAPI will ensure that it enters the + // Realm of aGlobalObject's JSObject and exposes that JSObject to active JS. MOZ_MUST_USE bool Init(nsIGlobalObject* aGlobalObject); // This is a helper that grabs the native global associated with aObject and @@ -231,7 +234,7 @@ class MOZ_STACK_CLASS AutoJSAPI : protected ScriptSettingsStackEntry { // show up in the corresponding web console. MOZ_MUST_USE bool Init(nsIGlobalObject* aGlobalObject, JSContext* aCx); - // Convenience functions to take an nsPIDOMWindow* or nsGlobalWindow*, + // Convenience functions to take an nsPIDOMWindowInner or nsGlobalWindowInner, // when it is more easily available than an nsIGlobalObject. MOZ_MUST_USE bool Init(nsPIDOMWindowInner* aWindow); MOZ_MUST_USE bool Init(nsPIDOMWindowInner* aWindow, JSContext* aCx); @@ -310,15 +313,21 @@ class MOZ_STACK_CLASS AutoJSAPI : protected ScriptSettingsStackEntry { * |aReason| should be a statically-allocated C string naming the reason we're * invoking JavaScript code: "setTimeout", "event", and so on. The devtools use * these strings to label JS execution in timeline and profiling displays. + * */ class MOZ_STACK_CLASS AutoEntryScript : public AutoJSAPI { public: + // Constructing the AutoEntryScript will ensure that it enters the + // Realm of aGlobalObject's JSObject and exposes that JSObject to active JS. AutoEntryScript(nsIGlobalObject* aGlobalObject, const char* aReason, bool aIsMainThread = NS_IsMainThread()); // aObject can be any object from the relevant global. It must not be a // cross-compartment wrapper because CCWs are not associated with a single // global. + // + // Constructing the AutoEntryScript will ensure that it enters the + // Realm of aObject JSObject and exposes aObject's global to active JS. AutoEntryScript(JSObject* aObject, const char* aReason, bool aIsMainThread = NS_IsMainThread()); diff --git a/dom/vr/VRDisplay.cpp b/dom/vr/VRDisplay.cpp index 53d73692bbc7..a79616d11cf2 100644 --- a/dom/vr/VRDisplay.cpp +++ b/dom/vr/VRDisplay.cpp @@ -730,9 +730,6 @@ void VRFrameData::LazyCreateMatrix(JS::Heap& aArray, return; } } - if (aArray) { - JS::ExposeObjectToActiveJS(aArray); - } aRetval.set(aArray); } diff --git a/dom/xul/nsXULElement.cpp b/dom/xul/nsXULElement.cpp index cf02a8143e5f..420c7ee424c8 100644 --- a/dom/xul/nsXULElement.cpp +++ b/dom/xul/nsXULElement.cpp @@ -2136,9 +2136,6 @@ nsresult nsXULPrototypeScript::Compile( // source from the files on demand. options.setSourceIsLazy(mOutOfLine); JS::Rooted scope(cx, JS::CurrentGlobalOrNull(cx)); - if (scope) { - JS::ExposeObjectToActiveJS(scope); - } if (aOffThreadReceiver && JS::CanCompileOffThread(cx, options, aTextLength)) { if (!JS::CompileOffThread(cx, options, srcBuf,