diff --git a/js/xpconnect/wrappers/XrayWrapper.cpp b/js/xpconnect/wrappers/XrayWrapper.cpp
index a7d79c2e8211..0215f6c94a22 100644
--- a/js/xpconnect/wrappers/XrayWrapper.cpp
+++ b/js/xpconnect/wrappers/XrayWrapper.cpp
@@ -1786,9 +1786,7 @@ XrayWrapper::getPropertyDescriptor(JSContext* cx, HandleObject wra
JS::MutableHandle desc)
const
{
- // We can't assert !Traits::HasPrototypes here, because
- // CrossOriginXrayWrapper::getOwnPropertyDescriptor calls us, but it uses
- // DOMXrayTraits, which have HasPrototype.
+ // CrossOriginXrayWrapper::getOwnPropertyDescriptor calls this.
assertEnteredPolicy(cx, wrapper, id, BaseProxyHandler::GET | BaseProxyHandler::SET |
BaseProxyHandler::GET_PROPERTY_DESCRIPTOR);
@@ -2058,13 +2056,6 @@ XrayWrapper::get(JSContext* cx, HandleObject wrapper,
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.
- RootedValue thisv(cx);
- if (Traits::HasPrototype)
- thisv = receiver;
- else
- thisv.setObject(*wrapper);
// This uses getPropertyDescriptor for backward compatibility with
// the old BaseProxyHandler::get implementation.
@@ -2092,7 +2083,7 @@ XrayWrapper::get(JSContext* cx, HandleObject wrapper,
return true;
}
- return Call(cx, thisv, getter, HandleValueArray::empty(), vp);
+ return Call(cx, receiver, getter, HandleValueArray::empty(), vp);
}
template
@@ -2100,12 +2091,8 @@ bool
XrayWrapper::set(JSContext* cx, HandleObject wrapper, HandleId id, HandleValue v,
HandleValue receiver, ObjectOpResult& result) const
{
- MOZ_ASSERT(!Traits::HasPrototype);
- // Skip our Base if it isn't already BaseProxyHandler.
- // NB: None of the functions we call are prepared for the receiver not
- // being the wrapper, so ignore the receiver here.
- RootedValue wrapperValue(cx, ObjectValue(*wrapper));
- return js::BaseProxyHandler::set(cx, wrapper, id, v, wrapperValue, result);
+ MOZ_CRASH("Shouldn't be called");
+ return false;
}
template
@@ -2146,9 +2133,8 @@ template
JSObject*
XrayWrapper::enumerate(JSContext* cx, HandleObject wrapper) const
{
- MOZ_ASSERT(!Traits::HasPrototype, "Why did we get called?");
- // Skip our Base if it isn't already ProxyHandler.
- return js::BaseProxyHandler::enumerate(cx, wrapper);
+ MOZ_CRASH("Shouldn't be called");
+ return nullptr;
}
template
@@ -2224,7 +2210,7 @@ XrayWrapper::getPrototype(JSContext* cx, JS::HandleObject wrapper,
Value cached = js::GetReservedSlot(holder,
Traits::HOLDER_SLOT_CACHED_PROTO);
if (cached.isUndefined()) {
- if (!getPrototypeHelper(cx, wrapper, target, protop))
+ if (!Traits::singleton.getPrototype(cx, wrapper, target, protop))
return false;
js::SetReservedSlot(holder, Traits::HOLDER_SLOT_CACHED_PROTO,
diff --git a/js/xpconnect/wrappers/XrayWrapper.h b/js/xpconnect/wrappers/XrayWrapper.h
index 45a10184f336..4f8387716ffb 100644
--- a/js/xpconnect/wrappers/XrayWrapper.h
+++ b/js/xpconnect/wrappers/XrayWrapper.h
@@ -146,10 +146,6 @@ class DOMXrayTraits : public XrayTraits
public:
constexpr DOMXrayTraits() = default;
- enum {
- HasPrototype = 1
- };
-
static const XrayType Type = XrayForDOMObject;
virtual bool resolveNativeProperty(JSContext* cx, JS::HandleObject wrapper,
@@ -202,9 +198,6 @@ protected:
class JSXrayTraits : public XrayTraits
{
public:
- enum {
- HasPrototype = 1
- };
static const XrayType Type = XrayForJSObject;
virtual bool resolveNativeProperty(JSContext* cx, JS::HandleObject wrapper,
@@ -319,9 +312,6 @@ public:
class OpaqueXrayTraits : public XrayTraits
{
public:
- enum {
- HasPrototype = 1
- };
static const XrayType Type = XrayForOpaqueObject;
virtual bool resolveNativeProperty(JSContext* cx, JS::HandleObject wrapper,
@@ -404,12 +394,13 @@ public:
XrayType GetXrayType(JSObject* obj);
XrayTraits* GetXrayTraits(JSObject* obj);
-// NB: Base *must* derive from JSProxyHandler
template
class XrayWrapper : public Base {
+ static_assert(mozilla::IsBaseOf::value,
+ "Base *must* derive from js::BaseProxyHandler");
public:
constexpr explicit XrayWrapper(unsigned flags)
- : Base(flags | WrapperFactory::IS_XRAY_WRAPPER_FLAG, Traits::HasPrototype)
+ : Base(flags | WrapperFactory::IS_XRAY_WRAPPER_FLAG, /* aHasPrototype = */ true)
{ };
/* Standard internal methods. */
@@ -459,28 +450,6 @@ class XrayWrapper : public Base {
static const XrayWrapper singleton;
- private:
- template
- typename mozilla::EnableIf::Type
- getPrototypeHelper(JSContext* cx, JS::HandleObject wrapper,
- JS::HandleObject target, JS::MutableHandleObject protop) const
- {
- return Traits::singleton.getPrototype(cx, wrapper, target, protop);
- }
- template
- typename mozilla::EnableIf::Type
- getPrototypeHelper(JSContext* cx, JS::HandleObject wrapper,
- JS::HandleObject target, JS::MutableHandleObject protop) const
- {
- return Base::getPrototype(cx, wrapper, protop);
- }
- bool getPrototypeHelper(JSContext* cx, JS::HandleObject wrapper,
- JS::HandleObject target, JS::MutableHandleObject protop) const
- {
- return getPrototypeHelper(cx, wrapper, target,
- protop);
- }
-
protected:
bool getPropertyKeys(JSContext* cx, JS::Handle wrapper, unsigned flags,
JS::AutoIdVector& props) const;