зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1506324 - Use DefaultGlobalClassOps in existing code. r=jorendorff
Summary: Depends on D11570 Reviewers: tcampbell, jorendorff Reviewed By: tcampbell, jorendorff Subscribers: jandem Bug #: 1506324 Differential Revision: https://phabricator.services.mozilla.com/D11571
This commit is contained in:
Родитель
051426775c
Коммит
31c3522845
|
@ -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() {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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++;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
Загрузка…
Ссылка в новой задаче