зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1468137 - Remove JS_Get*Prototype APIs; use JS::GetRealm*Prototype instead. r=evilpie
--HG-- extra : rebase_source : 9d5e815b83b3a71ab3e74fc2c0e2feb1009f2af9
This commit is contained in:
Родитель
31fa4e1ccf
Коммит
de211d96a6
|
@ -4,12 +4,6 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/*
|
||||
* Ways to get various per-Realm objects. All the getters declared in this
|
||||
* header operate on the Realm corresponding to the current compartment on the
|
||||
* JSContext.
|
||||
*/
|
||||
|
||||
#ifndef js_Realm_h
|
||||
#define js_Realm_h
|
||||
|
||||
|
@ -114,6 +108,11 @@ SetRealmNameCallback(JSContext* cx, RealmNameCallback callback);
|
|||
extern JS_PUBLIC_API(JSObject*)
|
||||
GetRealmGlobalOrNull(Handle<Realm*> realm);
|
||||
|
||||
/*
|
||||
* Ways to get various per-Realm objects. All the getters declared below operate
|
||||
* on the JSContext's current Realm.
|
||||
*/
|
||||
|
||||
extern JS_PUBLIC_API(JSObject*)
|
||||
GetRealmObjectPrototype(JSContext* cx);
|
||||
|
||||
|
|
|
@ -286,13 +286,9 @@ const WHITELIST_FUNCTIONS: &'static [&'static str] = &[
|
|||
"JS::GCTraceKindToAscii",
|
||||
"js::GetArrayBufferLengthAndData",
|
||||
"js::GetArrayBufferViewLengthAndData",
|
||||
"JS_GetErrorPrototype",
|
||||
"js::GetFunctionNativeReserved",
|
||||
"JS_GetFunctionPrototype",
|
||||
"js::GetGlobalForObjectCrossCompartment",
|
||||
"JS_GetIteratorPrototype",
|
||||
"js::GetObjectProto",
|
||||
"JS_GetObjectPrototype",
|
||||
"JS_GetObjectRuntime",
|
||||
"JS_GetOwnPropertyDescriptorById",
|
||||
"JS::GetPromiseResult",
|
||||
|
@ -349,6 +345,10 @@ const WHITELIST_FUNCTIONS: &'static [&'static str] = &[
|
|||
"js::GetPropertyKeys",
|
||||
"JS_GetPrototype",
|
||||
"JS_GetReservedSlot",
|
||||
"JS::GetRealmErrorPrototype",
|
||||
"JS::GetRealmFunctionPrototype",
|
||||
"JS::GetRealmIteratorPrototype",
|
||||
"JS::GetRealmObjectPrototype",
|
||||
"JS::GetScriptedCallerGlobal",
|
||||
"JS_GetTwoByteStringCharsAndLength",
|
||||
"JS_GetUint16ArrayData",
|
||||
|
|
|
@ -30,7 +30,7 @@ fn rooting() {
|
|||
h_option,
|
||||
&c_option));
|
||||
let _ac = js::ac::AutoCompartment::with_obj(cx, global.get());
|
||||
rooted!(in(cx) let prototype_proto = JS_GetObjectPrototype(cx, global.handle()));
|
||||
rooted!(in(cx) let prototype_proto = JS::GetRealmObjectPrototype(cx));
|
||||
rooted!(in(cx) let proto = JS_NewObjectWithUniqueType(cx,
|
||||
&CLASS as *const _,
|
||||
prototype_proto.handle()));
|
||||
|
|
|
@ -39,7 +39,7 @@ BEGIN_TEST(test_GetPropertyDescriptor)
|
|||
CHECK_EQUAL(desc.object(), nullptr);
|
||||
|
||||
CHECK(JS_GetPropertyDescriptor(cx, obj, "toString", &desc));
|
||||
JS::RootedObject objectProto(cx, JS_GetObjectPrototype(cx, obj));
|
||||
JS::RootedObject objectProto(cx, JS::GetRealmObjectPrototype(cx));
|
||||
CHECK(objectProto);
|
||||
CHECK_EQUAL(desc.object(), objectProto);
|
||||
CHECK(desc.value().isObject());
|
||||
|
|
|
@ -1223,49 +1223,6 @@ JS_IdToProtoKey(JSContext* cx, HandleId id)
|
|||
return static_cast<JSProtoKey>(stdnm - standard_class_names);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSObject*)
|
||||
JS_GetObjectPrototype(JSContext* cx, HandleObject forObj)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, forObj);
|
||||
Rooted<GlobalObject*> global(cx, &forObj->global());
|
||||
return GlobalObject::getOrCreateObjectPrototype(cx, global);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSObject*)
|
||||
JS_GetFunctionPrototype(JSContext* cx, HandleObject forObj)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, forObj);
|
||||
Rooted<GlobalObject*> global(cx, &forObj->global());
|
||||
return GlobalObject::getOrCreateFunctionPrototype(cx, global);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSObject*)
|
||||
JS_GetArrayPrototype(JSContext* cx, HandleObject forObj)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, forObj);
|
||||
Rooted<GlobalObject*> global(cx, &forObj->global());
|
||||
return GlobalObject::getOrCreateArrayPrototype(cx, global);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSObject*)
|
||||
JS_GetErrorPrototype(JSContext* cx)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
Rooted<GlobalObject*> global(cx, cx->global());
|
||||
return GlobalObject::getOrCreateCustomErrorPrototype(cx, global, JSEXN_ERR);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSObject*)
|
||||
JS_GetIteratorPrototype(JSContext* cx)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
Rooted<GlobalObject*> global(cx, cx->global());
|
||||
return GlobalObject::getOrCreateIteratorPrototype(cx, global);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSObject*)
|
||||
JS_GetGlobalForObject(JSContext* cx, JSObject* obj)
|
||||
{
|
||||
|
|
|
@ -1207,41 +1207,6 @@ ProtoKeyToId(JSContext* cx, JSProtoKey key, JS::MutableHandleId idp);
|
|||
extern JS_PUBLIC_API(JSProtoKey)
|
||||
JS_IdToProtoKey(JSContext* cx, JS::HandleId id);
|
||||
|
||||
/**
|
||||
* Returns the original value of |Function.prototype| from the global object in
|
||||
* which |forObj| was created.
|
||||
*/
|
||||
extern JS_PUBLIC_API(JSObject*)
|
||||
JS_GetFunctionPrototype(JSContext* cx, JS::HandleObject forObj);
|
||||
|
||||
/**
|
||||
* Returns the original value of |Object.prototype| from the global object in
|
||||
* which |forObj| was created.
|
||||
*/
|
||||
extern JS_PUBLIC_API(JSObject*)
|
||||
JS_GetObjectPrototype(JSContext* cx, JS::HandleObject forObj);
|
||||
|
||||
/**
|
||||
* Returns the original value of |Array.prototype| from the global object in
|
||||
* which |forObj| was created.
|
||||
*/
|
||||
extern JS_PUBLIC_API(JSObject*)
|
||||
JS_GetArrayPrototype(JSContext* cx, JS::HandleObject forObj);
|
||||
|
||||
/**
|
||||
* Returns the original value of |Error.prototype| from the global
|
||||
* object of the current compartment of cx.
|
||||
*/
|
||||
extern JS_PUBLIC_API(JSObject*)
|
||||
JS_GetErrorPrototype(JSContext* cx);
|
||||
|
||||
/**
|
||||
* Returns the %IteratorPrototype% object that all built-in iterator prototype
|
||||
* chains go through for the global object of the current compartment of cx.
|
||||
*/
|
||||
extern JS_PUBLIC_API(JSObject*)
|
||||
JS_GetIteratorPrototype(JSContext* cx);
|
||||
|
||||
extern JS_PUBLIC_API(JSObject*)
|
||||
JS_GetGlobalForObject(JSContext* cx, JSObject* obj);
|
||||
|
||||
|
|
|
@ -1134,7 +1134,7 @@ xpc::CreateSandboxObject(JSContext* cx, MutableHandleValue vp, nsISupports* prin
|
|||
|
||||
// Ensure |Object.prototype| is instantiated before prototype-
|
||||
// splicing below.
|
||||
if (!JS_GetObjectPrototype(cx, sandbox))
|
||||
if (!JS::GetRealmObjectPrototype(cx))
|
||||
return NS_ERROR_XPC_UNEXPECTED;
|
||||
|
||||
if (options.proto) {
|
||||
|
|
|
@ -627,13 +627,9 @@ XPCWrappedNative::Init(nsIXPCScriptable* aScriptable)
|
|||
jsclazz->getResolve() &&
|
||||
jsclazz->hasFinalize(), "bad class");
|
||||
|
||||
// XXXbz JS_GetObjectPrototype wants an object, even though it then asserts
|
||||
// that this object is same-compartment with cx, which means it could just
|
||||
// use the cx global...
|
||||
RootedObject global(cx, CurrentGlobalOrNull(cx));
|
||||
RootedObject protoJSObject(cx, HasProto() ?
|
||||
GetProto()->GetJSProtoObject() :
|
||||
JS_GetObjectPrototype(cx, global));
|
||||
JS::GetRealmObjectPrototype(cx));
|
||||
if (!protoJSObject) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -55,8 +55,7 @@ XPCWrappedNativeProto::Init(nsIXPCScriptable* scriptable)
|
|||
AutoJSContext cx;
|
||||
mScriptable = scriptable;
|
||||
|
||||
JS::RootedObject global(cx, mScope->GetGlobalJSObject());
|
||||
JS::RootedObject proto(cx, JS_GetObjectPrototype(cx, global));
|
||||
JS::RootedObject proto(cx, JS::GetRealmObjectPrototype(cx));
|
||||
mJSProtoObject = JS_NewObjectWithUniqueType(cx, js::Jsvalify(&XPC_WN_Proto_JSClass),
|
||||
proto);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче