mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 1468219 - Rename JS_InitStandardClasses to JS::InitRealmStandardClasses, remove obj argument. r=anba
--HG-- extra : rebase_source : 5c092c37298e89096b85524e92d143ff2447f31f
This commit is contained in:
parent
de211d96a6
commit
2b3ff5c90a
@ -98,7 +98,7 @@ struct DevTools : public ::testing::Test {
|
||||
|
||||
/* Populate the global object with the standard globals, like Object and
|
||||
Array. */
|
||||
if (!JS_InitStandardClasses(cx, newGlobal))
|
||||
if (!JS::InitRealmStandardClasses(cx))
|
||||
return nullptr;
|
||||
|
||||
return newGlobal;
|
||||
|
@ -19,7 +19,7 @@ DEF_TEST(DoesCrossCompartmentBoundaries, {
|
||||
JS::Compartment* newCompartment = nullptr;
|
||||
{
|
||||
JSAutoRealm ar(cx, newGlobal);
|
||||
ASSERT_TRUE(JS_InitStandardClasses(cx, newGlobal));
|
||||
ASSERT_TRUE(JS::InitRealmStandardClasses(cx));
|
||||
newCompartment = js::GetContextCompartment(cx);
|
||||
}
|
||||
ASSERT_TRUE(newCompartment);
|
||||
|
@ -19,7 +19,7 @@ DEF_TEST(DoesntCrossCompartmentBoundaries, {
|
||||
JS::Compartment* newCompartment = nullptr;
|
||||
{
|
||||
JSAutoRealm ar(cx, newGlobal);
|
||||
ASSERT_TRUE(JS_InitStandardClasses(cx, newGlobal));
|
||||
ASSERT_TRUE(JS::InitRealmStandardClasses(cx));
|
||||
newCompartment = js::GetContextCompartment(cx);
|
||||
}
|
||||
ASSERT_TRUE(newCompartment);
|
||||
|
@ -3062,8 +3062,7 @@ CreateGlobal(JSContext* aCx, T* aNative, nsWrapperCache* aCache,
|
||||
}
|
||||
}
|
||||
|
||||
if (aInitStandardClasses &&
|
||||
!JS_InitStandardClasses(aCx, aGlobal)) {
|
||||
if (aInitStandardClasses && !JS::InitRealmStandardClasses(aCx)) {
|
||||
NS_WARNING("Failed to init standard classes");
|
||||
return false;
|
||||
}
|
||||
|
@ -108,6 +108,12 @@ SetRealmNameCallback(JSContext* cx, RealmNameCallback callback);
|
||||
extern JS_PUBLIC_API(JSObject*)
|
||||
GetRealmGlobalOrNull(Handle<Realm*> realm);
|
||||
|
||||
// Initialize standard JS class constructors, prototypes, and any top-level
|
||||
// functions and constants associated with the standard classes (e.g. isNaN
|
||||
// for Number).
|
||||
extern JS_PUBLIC_API(bool)
|
||||
InitRealmStandardClasses(JSContext* cx);
|
||||
|
||||
/*
|
||||
* Ways to get various per-Realm objects. All the getters declared below operate
|
||||
* on the JSContext's current Realm.
|
||||
|
@ -358,7 +358,7 @@ const WHITELIST_FUNCTIONS: &'static [&'static str] = &[
|
||||
"JS::GetWellKnownSymbol",
|
||||
"JS_GlobalObjectTraceHook",
|
||||
"JS::HideScriptedCaller",
|
||||
"JS_InitStandardClasses",
|
||||
"JS::InitRealmStandardClasses",
|
||||
"JS_IsArrayObject",
|
||||
"JS_IsExceptionPending",
|
||||
"JS_IsGlobalObject",
|
||||
|
@ -11,7 +11,7 @@ use js::conversions::ConversionResult;
|
||||
use js::conversions::FromJSValConvertible;
|
||||
use js::conversions::ToJSValConvertible;
|
||||
use js::jsapi::root::JS::RealmOptions;
|
||||
use js::jsapi::root::JS_InitStandardClasses;
|
||||
use js::jsapi::root::JS::InitRealmStandardClasses;
|
||||
use js::jsapi::root::JS_NewGlobalObject;
|
||||
use js::jsapi::root::JS::OnNewGlobalHookOption;
|
||||
use js::jsval::UndefinedValue;
|
||||
@ -43,7 +43,7 @@ fn vec_conversion() {
|
||||
let global = global_root.handle();
|
||||
|
||||
let _ac = AutoCompartment::with_obj(cx, global.get());
|
||||
assert!(JS_InitStandardClasses(cx, global));
|
||||
assert!(InitRealmStandardClasses(cx));
|
||||
|
||||
rooted!(in(cx) let mut rval = UndefinedValue());
|
||||
|
||||
|
@ -56,7 +56,7 @@ jsfuzz_createGlobal(JSContext* cx, JSPrincipals* principals)
|
||||
|
||||
// Populate the global object with the standard globals like Object and
|
||||
// Array.
|
||||
if (!JS_InitStandardClasses(cx, newGlobal))
|
||||
if (!JS::InitRealmStandardClasses(cx))
|
||||
return nullptr;
|
||||
|
||||
return newGlobal;
|
||||
|
@ -92,7 +92,7 @@ main(int argc, const char** argv)
|
||||
|
||||
/* Populate the global object with the standard globals,
|
||||
like Object and Array. */
|
||||
checkBool(JS_InitStandardClasses(cx, global));
|
||||
checkBool(JS::InitRealmStandardClasses(cx));
|
||||
|
||||
argv++;
|
||||
while (*argv) {
|
||||
|
@ -20,7 +20,7 @@ BEGIN_TEST(testDebugger_newScriptHook)
|
||||
CHECK(g);
|
||||
{
|
||||
JSAutoRealm ae(cx, g);
|
||||
CHECK(JS_InitStandardClasses(cx, g));
|
||||
CHECK(JS::InitRealmStandardClasses(cx));
|
||||
}
|
||||
|
||||
JS::RootedObject gWrapper(cx, g);
|
||||
|
@ -47,7 +47,7 @@ eval(const char* asciiChars, bool mutedErrors, JS::MutableHandleValue rval)
|
||||
JS::FireOnNewGlobalHook, globalOptions));
|
||||
CHECK(global);
|
||||
JSAutoRealm ar(cx, global);
|
||||
CHECK(JS_InitStandardClasses(cx, global));
|
||||
CHECK(JS::InitRealmStandardClasses(cx));
|
||||
|
||||
|
||||
JS::CompileOptions options(cx);
|
||||
|
@ -148,7 +148,7 @@ END_TEST(testResolveRecursion)
|
||||
*/
|
||||
BEGIN_TEST(testResolveRecursion_InitStandardClasses)
|
||||
{
|
||||
CHECK(JS_InitStandardClasses(cx, global));
|
||||
CHECK(JS::InitRealmStandardClasses(cx));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ JSObject* JSAPITest::createGlobal(JSPrincipals* principals)
|
||||
|
||||
// Populate the global object with the standard globals like Object and
|
||||
// Array.
|
||||
if (!JS_InitStandardClasses(cx, newGlobal))
|
||||
if (!JS::InitRealmStandardClasses(cx))
|
||||
return nullptr;
|
||||
|
||||
global = newGlobal;
|
||||
|
@ -946,19 +946,6 @@ JS_RefreshCrossCompartmentWrappers(JSContext* cx, HandleObject obj)
|
||||
return RemapAllWrappersForObject(cx, obj, obj);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(bool)
|
||||
JS_InitStandardClasses(JSContext* cx, HandleObject obj)
|
||||
{
|
||||
MOZ_ASSERT(!cx->zone()->isAtomsZone());
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
|
||||
assertSameCompartment(cx, obj);
|
||||
|
||||
Rooted<GlobalObject*> global(cx, &obj->global());
|
||||
return GlobalObject::initStandardClasses(cx, global);
|
||||
}
|
||||
|
||||
typedef struct JSStdName {
|
||||
size_t atomOffset; /* offset of atom pointer in JSAtomState */
|
||||
JSProtoKey key;
|
||||
|
@ -1137,16 +1137,6 @@ JS_MarkCrossZoneId(JSContext* cx, jsid id);
|
||||
extern JS_PUBLIC_API(void)
|
||||
JS_MarkCrossZoneIdValue(JSContext* cx, const JS::Value& value);
|
||||
|
||||
/**
|
||||
* Initialize standard JS class constructors, prototypes, and any top-level
|
||||
* functions and constants associated with the standard classes (e.g. isNaN
|
||||
* for Number).
|
||||
*
|
||||
* NB: This sets cx's global object to obj if it was null.
|
||||
*/
|
||||
extern JS_PUBLIC_API(bool)
|
||||
JS_InitStandardClasses(JSContext* cx, JS::Handle<JSObject*> obj);
|
||||
|
||||
/**
|
||||
* Resolve id, which must contain either a string or an int, to a standard
|
||||
* class name in obj if possible, defining the class's constructor and/or
|
||||
|
@ -3442,7 +3442,7 @@ NewSandbox(JSContext* cx, bool lazy)
|
||||
|
||||
{
|
||||
JSAutoRealm ar(cx, obj);
|
||||
if (!lazy && !JS_InitStandardClasses(cx, obj))
|
||||
if (!lazy && !JS::InitRealmStandardClasses(cx))
|
||||
return nullptr;
|
||||
|
||||
RootedValue value(cx, BooleanValue(lazy));
|
||||
@ -8283,7 +8283,7 @@ NewGlobalObject(JSContext* cx, JS::RealmOptions& options,
|
||||
JSAutoRealm ar(cx, glob);
|
||||
|
||||
#ifndef LAZY_STANDARD_CLASSES
|
||||
if (!JS_InitStandardClasses(cx, glob))
|
||||
if (!JS::InitRealmStandardClasses(cx))
|
||||
return nullptr;
|
||||
#endif
|
||||
|
||||
|
@ -1049,6 +1049,15 @@ JS::GetRealmGlobalOrNull(Handle<JS::Realm*> realm)
|
||||
return realm->maybeGlobal();
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(bool)
|
||||
JS::InitRealmStandardClasses(JSContext* cx)
|
||||
{
|
||||
MOZ_ASSERT(!cx->zone()->isAtomsZone());
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
return GlobalObject::initStandardClasses(cx, cx->global());
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSObject*)
|
||||
JS::GetRealmObjectPrototype(JSContext* cx)
|
||||
{
|
||||
|
@ -191,7 +191,7 @@ XPCWrappedNative::WrapNewGlobal(xpcObjectHelper& nativeHelper,
|
||||
JSAutoRealm ar(cx, global);
|
||||
|
||||
// If requested, initialize the standard classes on the global.
|
||||
if (initStandardClasses && ! JS_InitStandardClasses(cx, global))
|
||||
if (initStandardClasses && !JS::InitRealmStandardClasses(cx))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// Make a proto.
|
||||
|
@ -665,7 +665,7 @@ private:
|
||||
|
||||
JSAutoRealm ar(mContext, global);
|
||||
AutoPACErrorReporter aper(mContext);
|
||||
if (!JS_InitStandardClasses(mContext, global)) {
|
||||
if (!JS::InitRealmStandardClasses(mContext)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
if (!JS_DefineFunctions(mContext, global, PACGlobalFunctions)) {
|
||||
|
Loading…
Reference in New Issue
Block a user