mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-02 10:00:54 +00:00
Backed out 2 changesets (bug 1506324) for bustages error: redefinition of 'DefaultGlobalClassOps' CLOSED TREE
Backed out changeset 412920e602fa (bug 1506324) Backed out changeset f00f5277735f (bug 1506324)
This commit is contained in:
parent
a102a4969c
commit
2b079b82ee
@ -69,9 +69,15 @@ 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,
|
||||
&JS::DefaultGlobalClassOps
|
||||
&globalClassOps
|
||||
};
|
||||
return &globalClass;
|
||||
}
|
||||
@ -79,9 +85,21 @@ struct DevTools : public ::testing::Test {
|
||||
JSObject* createGlobal()
|
||||
{
|
||||
/* Create the global object. */
|
||||
JS::RootedObject newGlobal(cx);
|
||||
JS::RealmOptions options;
|
||||
return JS_NewGlobalObject(cx, getGlobalClass(), nullptr,
|
||||
JS::FireOnNewGlobalHook, 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;
|
||||
}
|
||||
|
||||
virtual void TearDown() {
|
||||
|
@ -25,9 +25,15 @@ 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,
|
||||
&JS::DefaultGlobalClassOps
|
||||
&cOps
|
||||
};
|
||||
return &c;
|
||||
}
|
||||
@ -36,13 +42,27 @@ 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
|
||||
return JS_NewGlobalObject(cx, getGlobalClass(), principals, JS::FireOnNewGlobalHook,
|
||||
options);
|
||||
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;
|
||||
}
|
||||
|
||||
static bool
|
||||
|
@ -13,10 +13,17 @@
|
||||
|
||||
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,
|
||||
&DefaultGlobalClassOps
|
||||
&global_classOps
|
||||
};
|
||||
|
||||
static volatile int dontOptimizeMeAway = 0;
|
||||
@ -83,6 +90,10 @@ 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,10 +9,24 @@
|
||||
|
||||
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,
|
||||
&JS::DefaultGlobalClassOps
|
||||
&global_classOps
|
||||
};
|
||||
|
||||
static JS::PersistentRootedObject trusted_glob;
|
||||
|
@ -18,6 +18,10 @@ 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,6 +50,8 @@ 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,13 +9,11 @@
|
||||
|
||||
BEGIN_TEST(testSetProperty_InheritedGlobalSetter)
|
||||
{
|
||||
// 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.
|
||||
// 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.
|
||||
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"
|
||||
@ -27,28 +25,4 @@ 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,6 +95,14 @@ 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,9 +261,15 @@ 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,
|
||||
&JS::DefaultGlobalClassOps
|
||||
&cOps
|
||||
};
|
||||
return &c;
|
||||
}
|
||||
|
@ -1939,20 +1939,6 @@ const JSClassOps JS::DefaultGlobalClassOps = {
|
||||
JS_GlobalObjectTraceHook
|
||||
};
|
||||
|
||||
const JSClassOps JS::DefaultGlobalClassOps = {
|
||||
nullptr, // addProperty
|
||||
nullptr, // deleteProperty
|
||||
nullptr, // enumerate
|
||||
JS_NewEnumerateStandardClasses,
|
||||
JS_ResolveStandardClass,
|
||||
JS_MayResolveStandardClass,
|
||||
nullptr, // finalize
|
||||
nullptr, // call
|
||||
nullptr, // hasInstance
|
||||
nullptr, // construct
|
||||
JS_GlobalObjectTraceHook
|
||||
};
|
||||
|
||||
JS_PUBLIC_API(void)
|
||||
JS_FireOnNewGlobalObject(JSContext* cx, JS::HandleObject global)
|
||||
{
|
||||
|
@ -1850,21 +1850,6 @@ extern JS_PUBLIC_DATA(const JSClassOps) DefaultGlobalClassOps;
|
||||
|
||||
} // namespace JS
|
||||
|
||||
namespace JS {
|
||||
|
||||
/**
|
||||
* This allows easily constructing a global object without having to deal with
|
||||
* JSClassOps, forgetting to add JS_GlobalObjectTraceHook, or forgetting to call
|
||||
* JS::InitRealmStandardClasses(). Example:
|
||||
*
|
||||
* const JSClass globalClass = { "MyGlobal", JSCLASS_GLOBAL_FLAGS,
|
||||
* &JS::DefaultGlobalClassOps };
|
||||
* JS_NewGlobalObject(cx, &globalClass, ...);
|
||||
*/
|
||||
extern JS_PUBLIC_DATA(const JSClassOps) DefaultGlobalClassOps;
|
||||
|
||||
} // namespace JS
|
||||
|
||||
extern JS_PUBLIC_API(void)
|
||||
JS_FireOnNewGlobalObject(JSContext* cx, JS::HandleObject global);
|
||||
|
||||
|
@ -429,9 +429,16 @@ 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,
|
||||
&JS::DefaultGlobalClassOps
|
||||
&parseTaskGlobalClassOps
|
||||
};
|
||||
|
||||
ParseTask::ParseTask(ParseTaskKind kind, JSContext* cx,
|
||||
|
@ -680,6 +680,9 @@ 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;
|
||||
}
|
||||
@ -690,10 +693,17 @@ 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,
|
||||
&JS::DefaultGlobalClassOps
|
||||
&sJSContextWrapperGlobalClassOps
|
||||
};
|
||||
|
||||
void
|
||||
|
@ -84,9 +84,15 @@ 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,
|
||||
&JS::DefaultGlobalClassOps
|
||||
&GlobalClassOps
|
||||
};
|
||||
|
||||
JS::RealmOptions options;
|
||||
|
Loading…
Reference in New Issue
Block a user