diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index c65107ee979..dda717cd2fd 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -635,7 +635,7 @@ public: virtual bool has(JSContext *cx, JS::Handle proxy, JS::Handle id, bool *bp) const override; virtual bool get(JSContext *cx, JS::Handle proxy, - JS::Handle receiver, + JS::Handle receiver, JS::Handle id, JS::MutableHandle vp) const override; virtual bool set(JSContext *cx, JS::Handle proxy, @@ -900,7 +900,7 @@ nsOuterWindowProxy::hasOwn(JSContext *cx, JS::Handle proxy, bool nsOuterWindowProxy::get(JSContext *cx, JS::Handle proxy, - JS::Handle receiver, + JS::Handle receiver, JS::Handle id, JS::MutableHandle vp) const { diff --git a/dom/bindings/BindingUtils.cpp b/dom/bindings/BindingUtils.cpp index 7f2dafd6768..9ad52f44684 100644 --- a/dom/bindings/BindingUtils.cpp +++ b/dom/bindings/BindingUtils.cpp @@ -1699,8 +1699,8 @@ NativePropertyHooks sEmptyNativePropertyHooks = { bool GetPropertyOnPrototype(JSContext* cx, JS::Handle proxy, - JS::Handle id, bool* found, - JS::MutableHandle vp) + JS::Handle receiver, JS::Handle id, + bool* found, JS::MutableHandle vp) { JS::Rooted proto(cx); if (!js::GetObjectProto(cx, proxy, &proto)) { @@ -1719,7 +1719,7 @@ GetPropertyOnPrototype(JSContext* cx, JS::Handle proxy, return true; } - return JS_ForwardGetPropertyTo(cx, proto, id, proxy, vp); + return JS_ForwardGetPropertyTo(cx, proto, id, receiver, vp); } bool diff --git a/dom/bindings/BindingUtils.h b/dom/bindings/BindingUtils.h index 57adbb097f4..c30bf137c5b 100644 --- a/dom/bindings/BindingUtils.h +++ b/dom/bindings/BindingUtils.h @@ -1847,8 +1847,8 @@ ThrowConstructorWithoutNew(JSContext* cx, const char* name); bool GetPropertyOnPrototype(JSContext* cx, JS::Handle proxy, - JS::Handle id, bool* found, - JS::MutableHandle vp); + JS::Handle receiver, JS::Handle id, + bool* found, JS::MutableHandle vp); // bool diff --git a/dom/bindings/Codegen.py b/dom/bindings/Codegen.py index 8706a23577d..08fe9850d1d 100644 --- a/dom/bindings/Codegen.py +++ b/dom/bindings/Codegen.py @@ -11039,7 +11039,7 @@ class CGDOMJSProxyHandler_get(ClassMethod): def __init__(self, descriptor): args = [Argument('JSContext*', 'cx'), Argument('JS::Handle', 'proxy'), - Argument('JS::Handle', 'receiver'), + Argument('JS::Handle', 'receiver'), Argument('JS::Handle', 'id'), Argument('JS::MutableHandle', 'vp')] ClassMethod.__init__(self, "get", "bool", args, @@ -11094,7 +11094,7 @@ class CGDOMJSProxyHandler_get(ClassMethod): getOnPrototype = dedent(""" bool foundOnPrototype; - if (!GetPropertyOnPrototype(cx, proxy, id, &foundOnPrototype, vp)) { + if (!GetPropertyOnPrototype(cx, proxy, receiver, id, &foundOnPrototype, vp)) { return false; } diff --git a/js/ipc/JavaScriptBase.h b/js/ipc/JavaScriptBase.h index db1b603f28d..28c8337706f 100644 --- a/js/ipc/JavaScriptBase.h +++ b/js/ipc/JavaScriptBase.h @@ -66,9 +66,8 @@ class JavaScriptBase : public WrapperOwner, public WrapperAnswer, public Base ReturnStatus* rs, bool* bp) { return Answer::RecvHasOwn(ObjectId::deserialize(objId), id, rs, bp); } - bool RecvGet(const uint64_t& objId, const ObjectVariant& receiverVar, - const JSIDVariant& id, - ReturnStatus* rs, JSVariant* result) { + bool RecvGet(const uint64_t& objId, const JSVariant& receiverVar, const JSIDVariant& id, + ReturnStatus* rs, JSVariant* result) { return Answer::RecvGet(ObjectId::deserialize(objId), receiverVar, id, rs, result); } bool RecvSet(const uint64_t& objId, const JSIDVariant& id, const JSVariant& value, @@ -155,8 +154,7 @@ class JavaScriptBase : public WrapperOwner, public WrapperAnswer, public Base ReturnStatus* rs, bool* bp) { return Base::SendHasOwn(objId.serialize(), id, rs, bp); } - bool SendGet(const ObjectId& objId, const ObjectVariant& receiverVar, - const JSIDVariant& id, + bool SendGet(const ObjectId& objId, const JSVariant& receiverVar, const JSIDVariant& id, ReturnStatus* rs, JSVariant* result) { return Base::SendGet(objId.serialize(), receiverVar, id, rs, result); } diff --git a/js/ipc/PJavaScript.ipdl b/js/ipc/PJavaScript.ipdl index d8599cffe71..bea7941c0ed 100644 --- a/js/ipc/PJavaScript.ipdl +++ b/js/ipc/PJavaScript.ipdl @@ -32,7 +32,7 @@ both: prio(high) sync Has(uint64_t objId, JSIDVariant id) returns (ReturnStatus rs, bool has); prio(high) sync HasOwn(uint64_t objId, JSIDVariant id) returns (ReturnStatus rs, bool has); - prio(high) sync Get(uint64_t objId, ObjectVariant receiver, JSIDVariant id) returns (ReturnStatus rs, JSVariant result); + prio(high) sync Get(uint64_t objId, JSVariant receiver, JSIDVariant id) returns (ReturnStatus rs, JSVariant result); prio(high) sync Set(uint64_t objId, JSIDVariant id, JSVariant value, JSVariant receiver) returns (ReturnStatus rs); prio(high) sync IsExtensible(uint64_t objId) returns (ReturnStatus rs, bool result); diff --git a/js/ipc/WrapperAnswer.cpp b/js/ipc/WrapperAnswer.cpp index 7e84a67e443..ef7f7f2718f 100644 --- a/js/ipc/WrapperAnswer.cpp +++ b/js/ipc/WrapperAnswer.cpp @@ -272,7 +272,7 @@ WrapperAnswer::RecvHasOwn(const ObjectId& objId, const JSIDVariant& idVar, Retur } bool -WrapperAnswer::RecvGet(const ObjectId& objId, const ObjectVariant& receiverVar, +WrapperAnswer::RecvGet(const ObjectId& objId, const JSVariant& receiverVar, const JSIDVariant& idVar, ReturnStatus* rs, JSVariant* result) { // We may run scripted getters. @@ -289,8 +289,8 @@ WrapperAnswer::RecvGet(const ObjectId& objId, const ObjectVariant& receiverVar, if (!obj) return fail(aes, rs); - RootedObject receiver(cx, fromObjectVariant(cx, receiverVar)); - if (!receiver) + RootedValue receiver(cx); + if (!fromVariant(cx, receiverVar, &receiver)) return fail(aes, rs); RootedId id(cx); diff --git a/js/ipc/WrapperAnswer.h b/js/ipc/WrapperAnswer.h index 4c01a200b2f..ebb154a7685 100644 --- a/js/ipc/WrapperAnswer.h +++ b/js/ipc/WrapperAnswer.h @@ -39,7 +39,7 @@ class WrapperAnswer : public virtual JavaScriptShared ReturnStatus* rs, bool* foundp); bool RecvHasOwn(const ObjectId& objId, const JSIDVariant& id, ReturnStatus* rs, bool* foundp); - bool RecvGet(const ObjectId& objId, const ObjectVariant& receiverVar, + bool RecvGet(const ObjectId& objId, const JSVariant& receiverVar, const JSIDVariant& id, ReturnStatus* rs, JSVariant* result); bool RecvSet(const ObjectId& objId, const JSIDVariant& id, const JSVariant& value, diff --git a/js/ipc/WrapperOwner.cpp b/js/ipc/WrapperOwner.cpp index f88aa5634e5..97e7160fc4b 100644 --- a/js/ipc/WrapperOwner.cpp +++ b/js/ipc/WrapperOwner.cpp @@ -111,7 +111,7 @@ class CPOWProxyHandler : public BaseProxyHandler ObjectOpResult& result) const override; virtual bool isExtensible(JSContext* cx, HandleObject proxy, bool* extensible) const override; virtual bool has(JSContext* cx, HandleObject proxy, HandleId id, bool* bp) const override; - virtual bool get(JSContext* cx, HandleObject proxy, HandleObject receiver, + virtual bool get(JSContext* cx, HandleObject proxy, HandleValue receiver, HandleId id, MutableHandleValue vp) const override; virtual bool set(JSContext* cx, JS::HandleObject proxy, JS::HandleId id, JS::HandleValue v, JS::HandleValue receiver, JS::ObjectOpResult& result) const override; @@ -341,7 +341,7 @@ WrapperOwner::hasOwn(JSContext* cx, HandleObject proxy, HandleId id, bool* bp) } bool -CPOWProxyHandler::get(JSContext* cx, HandleObject proxy, HandleObject receiver, +CPOWProxyHandler::get(JSContext* cx, HandleObject proxy, HandleValue receiver, HandleId id, MutableHandleValue vp) const { FORWARD(get, (cx, proxy, receiver, id, vp)); @@ -458,13 +458,13 @@ WrapperOwner::DOMQI(JSContext* cx, JS::HandleObject proxy, JS::CallArgs& args) } bool -WrapperOwner::get(JSContext* cx, HandleObject proxy, HandleObject receiver, +WrapperOwner::get(JSContext* cx, HandleObject proxy, HandleValue receiver, HandleId id, MutableHandleValue vp) { ObjectId objId = idOf(proxy); - ObjectVariant receiverVar; - if (!toObjectVariant(cx, receiver, &receiverVar)) + JSVariant receiverVar; + if (!toVariant(cx, receiver, &receiverVar)) return false; JSIDVariant idVar; diff --git a/js/ipc/WrapperOwner.h b/js/ipc/WrapperOwner.h index b35db385129..ac1cccc8cc3 100644 --- a/js/ipc/WrapperOwner.h +++ b/js/ipc/WrapperOwner.h @@ -40,7 +40,7 @@ class WrapperOwner : public virtual JavaScriptShared bool preventExtensions(JSContext* cx, JS::HandleObject proxy, JS::ObjectOpResult& result); bool isExtensible(JSContext* cx, JS::HandleObject proxy, bool* extensible); bool has(JSContext* cx, JS::HandleObject proxy, JS::HandleId id, bool* bp); - bool get(JSContext* cx, JS::HandleObject proxy, JS::HandleObject receiver, + bool get(JSContext* cx, JS::HandleObject proxy, JS::HandleValue receiver, JS::HandleId id, JS::MutableHandleValue vp); bool set(JSContext* cx, JS::HandleObject proxy, JS::HandleId id, JS::HandleValue v, JS::HandleValue receiver, JS::ObjectOpResult& result); @@ -125,7 +125,7 @@ class WrapperOwner : public virtual JavaScriptShared ReturnStatus* rs, bool* bp) = 0; virtual bool SendHasOwn(const ObjectId& objId, const JSIDVariant& id, ReturnStatus* rs, bool* bp) = 0; - virtual bool SendGet(const ObjectId& objId, const ObjectVariant& receiverVar, + virtual bool SendGet(const ObjectId& objId, const JSVariant& receiverVar, const JSIDVariant& id, ReturnStatus* rs, JSVariant* result) = 0; virtual bool SendSet(const ObjectId& objId, const JSIDVariant& id, const JSVariant& value, diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp index 8636c83d477..66951d046d4 100644 --- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -2920,12 +2920,16 @@ JS_GetPropertyDescriptor(JSContext* cx, HandleObject obj, const char* name, JS_PUBLIC_API(bool) JS_GetPropertyById(JSContext* cx, HandleObject obj, HandleId id, MutableHandleValue vp) { - return JS_ForwardGetPropertyTo(cx, obj, id, obj, vp); + AssertHeapIsIdle(cx); + CHECK_REQUEST(cx); + assertSameCompartment(cx, obj, id); + + return GetProperty(cx, obj, obj, id, vp); } JS_PUBLIC_API(bool) -JS_ForwardGetPropertyTo(JSContext* cx, JS::HandleObject obj, JS::HandleId id, JS::HandleObject onBehalfOf, - JS::MutableHandleValue vp) +JS_ForwardGetPropertyTo(JSContext* cx, HandleObject obj, HandleId id, HandleValue onBehalfOf, + MutableHandleValue vp) { AssertHeapIsIdle(cx); CHECK_REQUEST(cx); @@ -2935,9 +2939,13 @@ JS_ForwardGetPropertyTo(JSContext* cx, JS::HandleObject obj, JS::HandleId id, JS } JS_PUBLIC_API(bool) -JS_GetElement(JSContext* cx, HandleObject objArg, uint32_t index, MutableHandleValue vp) +JS_GetElement(JSContext* cx, HandleObject obj, uint32_t index, MutableHandleValue vp) { - return JS_ForwardGetElementTo(cx, objArg, index, objArg, vp); + AssertHeapIsIdle(cx); + CHECK_REQUEST(cx); + assertSameCompartment(cx, obj); + + return GetElement(cx, obj, obj, index, vp); } JS_PUBLIC_API(bool) diff --git a/js/src/jsapi.h b/js/src/jsapi.h index c4a1c980342..ddc6afbb5fc 100644 --- a/js/src/jsapi.h +++ b/js/src/jsapi.h @@ -2853,7 +2853,7 @@ extern JS_PUBLIC_API(bool) JS_GetPropertyById(JSContext* cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp); extern JS_PUBLIC_API(bool) -JS_ForwardGetPropertyTo(JSContext* cx, JS::HandleObject obj, JS::HandleId id, JS::HandleObject onBehalfOf, +JS_ForwardGetPropertyTo(JSContext* cx, JS::HandleObject obj, JS::HandleId id, JS::HandleValue onBehalfOf, JS::MutableHandleValue vp); extern JS_PUBLIC_API(bool) diff --git a/js/xpconnect/src/Sandbox.cpp b/js/xpconnect/src/Sandbox.cpp index 8a44da5a2af..6cbe739b237 100644 --- a/js/xpconnect/src/Sandbox.cpp +++ b/js/xpconnect/src/Sandbox.cpp @@ -828,7 +828,7 @@ xpc::SandboxProxyHandler::hasOwn(JSContext* cx, JS::Handle proxy, bool xpc::SandboxProxyHandler::get(JSContext* cx, JS::Handle proxy, - JS::Handle receiver, + JS::Handle receiver, JS::Handle id, JS::MutableHandle vp) const { diff --git a/js/xpconnect/wrappers/AddonWrapper.cpp b/js/xpconnect/wrappers/AddonWrapper.cpp index e0fdd960568..bfc3e2e5937 100644 --- a/js/xpconnect/wrappers/AddonWrapper.cpp +++ b/js/xpconnect/wrappers/AddonWrapper.cpp @@ -169,7 +169,7 @@ AddonWrapper::getOwnPropertyDescriptor(JSContext* cx, HandleObject wrapper template bool -AddonWrapper::get(JSContext* cx, JS::Handle wrapper, JS::Handle receiver, +AddonWrapper::get(JSContext* cx, JS::Handle wrapper, JS::Handle receiver, JS::Handle id, JS::MutableHandle vp) const { Rooted desc(cx); @@ -180,10 +180,7 @@ AddonWrapper::get(JSContext* cx, JS::Handle wrapper, JS::Handle return Base::get(cx, wrapper, receiver, id, vp); if (desc.getter()) { - MOZ_ASSERT(desc.hasGetterObject()); - AutoValueVector args(cx); - RootedValue fval(cx, ObjectValue(*desc.getterObject())); - return JS_CallFunctionValue(cx, receiver, fval, args, vp); + return Call(cx, receiver, desc.getterObject(), HandleValueArray::empty(), vp); } else { vp.set(desc.value()); return true; diff --git a/js/xpconnect/wrappers/AddonWrapper.h b/js/xpconnect/wrappers/AddonWrapper.h index 8515f71ad17..5d1a324c3da 100644 --- a/js/xpconnect/wrappers/AddonWrapper.h +++ b/js/xpconnect/wrappers/AddonWrapper.h @@ -36,7 +36,7 @@ class AddonWrapper : public Base { JS::ObjectOpResult& result) const override; virtual bool delete_(JSContext* cx, JS::HandleObject proxy, JS::HandleId id, JS::ObjectOpResult& result) const override; - virtual bool get(JSContext* cx, JS::Handle wrapper, JS::Handle receiver, + virtual bool get(JSContext* cx, JS::Handle wrapper, JS::Handle receiver, JS::Handle id, JS::MutableHandle vp) const override; virtual bool set(JSContext* cx, JS::HandleObject wrapper, JS::HandleId id, JS::HandleValue v, JS::HandleValue receiver, JS::ObjectOpResult& result) const override; diff --git a/js/xpconnect/wrappers/WaiveXrayWrapper.cpp b/js/xpconnect/wrappers/WaiveXrayWrapper.cpp index 3ad47217be0..7e78c122c24 100644 --- a/js/xpconnect/wrappers/WaiveXrayWrapper.cpp +++ b/js/xpconnect/wrappers/WaiveXrayWrapper.cpp @@ -50,8 +50,7 @@ WaiveXrayWrapper::getOwnPropertyDescriptor(JSContext* cx, HandleObject wrapper, } bool -WaiveXrayWrapper::get(JSContext* cx, HandleObject wrapper, - HandleObject receiver, HandleId id, +WaiveXrayWrapper::get(JSContext* cx, HandleObject wrapper, HandleValue receiver, HandleId id, MutableHandleValue vp) const { return CrossCompartmentWrapper::get(cx, wrapper, receiver, id, vp) && diff --git a/js/xpconnect/wrappers/WaiveXrayWrapper.h b/js/xpconnect/wrappers/WaiveXrayWrapper.h index 4ecef0a905a..eeb1507dbb3 100644 --- a/js/xpconnect/wrappers/WaiveXrayWrapper.h +++ b/js/xpconnect/wrappers/WaiveXrayWrapper.h @@ -22,7 +22,7 @@ class WaiveXrayWrapper : public js::CrossCompartmentWrapper { JS::MutableHandle desc) const override; virtual bool getPrototype(JSContext* cx, JS::Handle wrapper, JS::MutableHandle protop) const override; - virtual bool get(JSContext* cx, JS::Handle wrapper, JS::Handle receiver, + virtual bool get(JSContext* cx, JS::Handle wrapper, JS::Handle receiver, JS::Handle id, JS::MutableHandle vp) const override; virtual bool call(JSContext* cx, JS::Handle wrapper, const JS::CallArgs& args) const override; diff --git a/js/xpconnect/wrappers/XrayWrapper.cpp b/js/xpconnect/wrappers/XrayWrapper.cpp index 9b4d6df2abc..eae06fb7ca9 100644 --- a/js/xpconnect/wrappers/XrayWrapper.cpp +++ b/js/xpconnect/wrappers/XrayWrapper.cpp @@ -2092,13 +2092,18 @@ XrayWrapper::delete_(JSContext* cx, HandleObject wrapper, template bool XrayWrapper::get(JSContext* cx, HandleObject wrapper, - HandleObject receiver, HandleId id, + HandleValue receiver, HandleId id, MutableHandleValue vp) const { // Skip our Base if it isn't already ProxyHandler. // NB: None of the functions we call are prepared for the receiver not // being the wrapper, so ignore the receiver here. - return js::BaseProxyHandler::get(cx, wrapper, Traits::HasPrototype ? receiver : wrapper, id, vp); + RootedValue thisv(cx); + if (Traits::HasPrototype) + thisv = receiver; + else + thisv.setObject(*wrapper); + return js::BaseProxyHandler::get(cx, wrapper, thisv, id, vp); } template diff --git a/js/xpconnect/wrappers/XrayWrapper.h b/js/xpconnect/wrappers/XrayWrapper.h index d233372929c..bb0b7178140 100644 --- a/js/xpconnect/wrappers/XrayWrapper.h +++ b/js/xpconnect/wrappers/XrayWrapper.h @@ -446,7 +446,7 @@ class XrayWrapper : public Base { virtual bool isExtensible(JSContext* cx, JS::Handle wrapper, bool* extensible) const override; virtual bool has(JSContext* cx, JS::Handle wrapper, JS::Handle id, bool* bp) const override; - virtual bool get(JSContext* cx, JS::Handle wrapper, JS::Handle receiver, + virtual bool get(JSContext* cx, JS::Handle wrapper, JS::HandleValue receiver, JS::Handle id, JS::MutableHandle vp) const override; virtual bool set(JSContext* cx, JS::Handle wrapper, JS::Handle id, JS::Handle v, JS::Handle receiver, @@ -520,7 +520,7 @@ public: // which implement them in terms of lower-level methods. virtual bool has(JSContext* cx, JS::Handle proxy, JS::Handle id, bool* bp) const override; - virtual bool get(JSContext* cx, JS::Handle proxy, JS::Handle receiver, + virtual bool get(JSContext* cx, JS::Handle proxy, JS::HandleValue receiver, JS::Handle id, JS::MutableHandle vp) const override; virtual bool set(JSContext* cx, JS::Handle proxy, JS::Handle id, JS::Handle v, JS::Handle receiver,