diff --git a/devtools/shared/heapsnapshot/tests/gtest/DevTools.h b/devtools/shared/heapsnapshot/tests/gtest/DevTools.h index b7ff696f4de2..01bd1dc8b26b 100644 --- a/devtools/shared/heapsnapshot/tests/gtest/DevTools.h +++ b/devtools/shared/heapsnapshot/tests/gtest/DevTools.h @@ -69,15 +69,9 @@ struct DevTools : public ::testing::Test { } static const JSClass* getGlobalClass() { - static const JSClassOps globalClassOps = { - nullptr, nullptr, nullptr, nullptr, - nullptr, nullptr, nullptr, nullptr, - nullptr, nullptr, - JS_GlobalObjectTraceHook - }; static const JSClass globalClass = { "global", JSCLASS_GLOBAL_FLAGS, - &globalClassOps + &JS::DefaultGlobalClassOps }; return &globalClass; } @@ -85,21 +79,9 @@ struct DevTools : public ::testing::Test { JSObject* createGlobal() { /* Create the global object. */ - JS::RootedObject newGlobal(cx); JS::RealmOptions options; - newGlobal = JS_NewGlobalObject(cx, getGlobalClass(), nullptr, - JS::FireOnNewGlobalHook, options); - if (!newGlobal) - return nullptr; - - JSAutoRealm ar(cx, newGlobal); - - /* Populate the global object with the standard globals, like Object and - Array. */ - if (!JS::InitRealmStandardClasses(cx)) - return nullptr; - - return newGlobal; + return JS_NewGlobalObject(cx, getGlobalClass(), nullptr, + JS::FireOnNewGlobalHook, options); } virtual void TearDown() { diff --git a/js/src/fuzz-tests/tests.cpp b/js/src/fuzz-tests/tests.cpp index c605904a4125..162faad3e701 100644 --- a/js/src/fuzz-tests/tests.cpp +++ b/js/src/fuzz-tests/tests.cpp @@ -25,15 +25,9 @@ JSContext* gCx = nullptr; static const JSClass* getGlobalClass() { - static const JSClassOps cOps = { - nullptr, nullptr, nullptr, nullptr, - nullptr, nullptr, nullptr, nullptr, - nullptr, nullptr, - JS_GlobalObjectTraceHook - }; static const JSClass c = { "global", JSCLASS_GLOBAL_FLAGS, - &cOps + &JS::DefaultGlobalClassOps }; return &c; } @@ -42,27 +36,13 @@ static JSObject* jsfuzz_createGlobal(JSContext* cx, JSPrincipals* principals) { /* Create the global object. */ - JS::RootedObject newGlobal(cx); JS::RealmOptions options; options.creationOptions().setStreamsEnabled(true); #ifdef ENABLE_BIGINT options.creationOptions().setBigIntEnabled(true); #endif - newGlobal = JS_NewGlobalObject(cx, getGlobalClass(), principals, JS::FireOnNewGlobalHook, - options); - if (!newGlobal) { - return nullptr; - } - - JSAutoRealm ar(cx, newGlobal); - - // Populate the global object with the standard globals like Object and - // Array. - if (!JS::InitRealmStandardClasses(cx)) { - return nullptr; - } - - return newGlobal; + return JS_NewGlobalObject(cx, getGlobalClass(), principals, JS::FireOnNewGlobalHook, + options); } static bool diff --git a/js/src/gdb/gdb-tests.cpp b/js/src/gdb/gdb-tests.cpp index 5f90b903b020..0745167fc742 100644 --- a/js/src/gdb/gdb-tests.cpp +++ b/js/src/gdb/gdb-tests.cpp @@ -13,17 +13,10 @@ using namespace JS; -static const JSClassOps global_classOps = { - nullptr, nullptr, nullptr, nullptr, - nullptr, nullptr, nullptr, nullptr, - nullptr, nullptr, - JS_GlobalObjectTraceHook -}; - /* The class of the global object. */ static const JSClass global_class = { "global", JSCLASS_GLOBAL_FLAGS, - &global_classOps + &DefaultGlobalClassOps }; static volatile int dontOptimizeMeAway = 0; @@ -90,10 +83,6 @@ main(int argc, const char** argv) nullptr, JS::FireOnNewGlobalHook, options))); JSAutoRealm ar(cx, global); - /* Populate the global object with the standard globals, - like Object and Array. */ - checkBool(JS::InitRealmStandardClasses(cx)); - argv++; while (*argv) { const char* name = *argv++; diff --git a/js/src/jsapi-tests/testChromeBuffer.cpp b/js/src/jsapi-tests/testChromeBuffer.cpp index 08c753ba95aa..2aa1fbe69fda 100644 --- a/js/src/jsapi-tests/testChromeBuffer.cpp +++ b/js/src/jsapi-tests/testChromeBuffer.cpp @@ -9,24 +9,10 @@ static TestJSPrincipals system_principals(1); -static const JSClassOps global_classOps = { - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - JS_GlobalObjectTraceHook -}; - static const JSClass global_class = { "global", JSCLASS_IS_GLOBAL | JSCLASS_GLOBAL_FLAGS, - &global_classOps + &JS::DefaultGlobalClassOps }; static JS::PersistentRootedObject trusted_glob; diff --git a/js/src/jsapi-tests/testDebugger.cpp b/js/src/jsapi-tests/testDebugger.cpp index 2024cc5925e4..9639d4ad3bf8 100644 --- a/js/src/jsapi-tests/testDebugger.cpp +++ b/js/src/jsapi-tests/testDebugger.cpp @@ -18,10 +18,6 @@ BEGIN_TEST(testDebugger_newScriptHook) JS::RootedObject g(cx, JS_NewGlobalObject(cx, getGlobalClass(), nullptr, JS::FireOnNewGlobalHook, options)); CHECK(g); - { - JSAutoRealm ar(cx, g); - CHECK(JS::InitRealmStandardClasses(cx)); - } JS::RootedObject gWrapper(cx, g); CHECK(JS_WrapObject(cx, &gWrapper)); diff --git a/js/src/jsapi-tests/testMutedErrors.cpp b/js/src/jsapi-tests/testMutedErrors.cpp index 561287d6f9e1..681d86809051 100644 --- a/js/src/jsapi-tests/testMutedErrors.cpp +++ b/js/src/jsapi-tests/testMutedErrors.cpp @@ -50,8 +50,6 @@ eval(const char* asciiChars, bool mutedErrors, JS::MutableHandleValue rval) JS::FireOnNewGlobalHook, globalOptions)); CHECK(global); JSAutoRealm ar(cx, global); - CHECK(JS::InitRealmStandardClasses(cx)); - JS::CompileOptions options(cx); options.setMutedErrors(mutedErrors) diff --git a/js/src/jsapi-tests/testSetProperty.cpp b/js/src/jsapi-tests/testSetProperty.cpp index 56a7c8a97b0b..46972e476bcf 100644 --- a/js/src/jsapi-tests/testSetProperty.cpp +++ b/js/src/jsapi-tests/testSetProperty.cpp @@ -9,11 +9,13 @@ BEGIN_TEST(testSetProperty_InheritedGlobalSetter) { - // This is a JSAPI test because jsapi-test globals do not have a resolve - // hook and therefore can use the property cache in some cases where the - // shell can't. + // This is a JSAPI test because jsapi-test globals can be set up to not have + // a resolve hook and therefore can use the property cache in some cases + // where the shell can't. MOZ_RELEASE_ASSERT(!JS_GetClass(global)->getResolve()); + CHECK(JS::InitRealmStandardClasses(cx)); + CHECK(JS_DefineProperty(cx, global, "HOTLOOP", 8, 0)); EXEC("var n = 0;\n" "var global = this;\n" @@ -25,4 +27,28 @@ BEGIN_TEST(testSetProperty_InheritedGlobalSetter) " throw 'FAIL';\n"); return true; } + +const JSClass* getGlobalClass(void) override { + static const JSClassOps noResolveGlobalClassOps = { + nullptr, // add + nullptr, // delete + nullptr, // enumerate + nullptr, // newEnumerate + nullptr, // resolve + nullptr, // mayResolve + nullptr, // finalize + nullptr, // call + nullptr, // hasInstance + nullptr, // construct + JS_GlobalObjectTraceHook + }; + + static const JSClass noResolveGlobalClass = { + "testSetProperty_InheritedGlobalSetter_noResolveGlobalClass", + JSCLASS_GLOBAL_FLAGS, + &noResolveGlobalClassOps + }; + + return &noResolveGlobalClass; +} END_TEST(testSetProperty_InheritedGlobalSetter) diff --git a/js/src/jsapi-tests/tests.cpp b/js/src/jsapi-tests/tests.cpp index 93bfd384cd3a..904faa0c67f5 100644 --- a/js/src/jsapi-tests/tests.cpp +++ b/js/src/jsapi-tests/tests.cpp @@ -95,14 +95,6 @@ JSObject* JSAPITest::createGlobal(JSPrincipals* principals) return nullptr; } - JSAutoRealm ar(cx, newGlobal); - - // Populate the global object with the standard globals like Object and - // Array. - if (!JS::InitRealmStandardClasses(cx)) { - return nullptr; - } - global = newGlobal; return newGlobal; } diff --git a/js/src/jsapi-tests/tests.h b/js/src/jsapi-tests/tests.h index 1618a5a0669b..a81e60524924 100644 --- a/js/src/jsapi-tests/tests.h +++ b/js/src/jsapi-tests/tests.h @@ -261,15 +261,9 @@ class JSAPITest JSAPITestString messages() const { return msgs; } static const JSClass * basicGlobalClass() { - static const JSClassOps cOps = { - nullptr, nullptr, nullptr, nullptr, - nullptr, nullptr, nullptr, nullptr, - nullptr, nullptr, - JS_GlobalObjectTraceHook - }; static const JSClass c = { "global", JSCLASS_GLOBAL_FLAGS, - &cOps + &JS::DefaultGlobalClassOps }; return &c; } diff --git a/js/src/vm/HelperThreads.cpp b/js/src/vm/HelperThreads.cpp index 841d08d52b10..0afb53db13f8 100644 --- a/js/src/vm/HelperThreads.cpp +++ b/js/src/vm/HelperThreads.cpp @@ -429,16 +429,9 @@ js::HasOffThreadIonCompile(Realm* realm) } #endif -static const JSClassOps parseTaskGlobalClassOps = { - nullptr, nullptr, nullptr, nullptr, - nullptr, nullptr, nullptr, nullptr, - nullptr, nullptr, - JS_GlobalObjectTraceHook -}; - static const JSClass parseTaskGlobalClass = { "internal-parse-task-global", JSCLASS_GLOBAL_FLAGS, - &parseTaskGlobalClassOps + &JS::DefaultGlobalClassOps }; ParseTask::ParseTask(ParseTaskKind kind, JSContext* cx, diff --git a/netwerk/base/ProxyAutoConfig.cpp b/netwerk/base/ProxyAutoConfig.cpp index 933bc2056338..cb9ac47c4b4a 100644 --- a/netwerk/base/ProxyAutoConfig.cpp +++ b/netwerk/base/ProxyAutoConfig.cpp @@ -680,9 +680,6 @@ private: 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; } @@ -693,17 +690,10 @@ private: } }; -static const JSClassOps sJSContextWrapperGlobalClassOps = { - nullptr, nullptr, nullptr, nullptr, - nullptr, nullptr, nullptr, nullptr, - nullptr, nullptr, - JS_GlobalObjectTraceHook -}; - const JSClass JSContextWrapper::sGlobalClass = { "PACResolutionThreadGlobal", JSCLASS_GLOBAL_FLAGS, - &sJSContextWrapperGlobalClassOps + &JS::DefaultGlobalClassOps }; void diff --git a/xpcom/tests/gtest/TestGCPostBarriers.cpp b/xpcom/tests/gtest/TestGCPostBarriers.cpp index 1e2627e38566..2271a8ac7d5b 100644 --- a/xpcom/tests/gtest/TestGCPostBarriers.cpp +++ b/xpcom/tests/gtest/TestGCPostBarriers.cpp @@ -84,15 +84,9 @@ RunTest(JSContext* cx, ArrayT* array) static void CreateGlobalAndRunTest(JSContext* cx) { - static const JSClassOps GlobalClassOps = { - nullptr, nullptr, nullptr, nullptr, - nullptr, nullptr, nullptr, nullptr, - nullptr, nullptr, JS_GlobalObjectTraceHook - }; - static const JSClass GlobalClass = { "global", JSCLASS_GLOBAL_FLAGS, - &GlobalClassOps + &JS::DefaultGlobalClassOps }; JS::RealmOptions options;