Bug 1246318 - Make the proxy enumerate trap non-standard. r=efaust

This commit is contained in:
Tom Schuster 2016-02-10 00:12:24 +01:00
parent a9dc5fef4d
commit 369af34f4a
8 changed files with 5 additions and 43 deletions

View File

@ -259,13 +259,6 @@ BaseDOMProxyHandler::getOwnEnumerablePropertyKeys(JSContext* cx,
return ownPropNames(cx, proxy, JSITER_OWNONLY, props); return ownPropNames(cx, proxy, JSITER_OWNONLY, props);
} }
bool
BaseDOMProxyHandler::enumerate(JSContext *cx, JS::Handle<JSObject*> proxy,
JS::MutableHandle<JSObject*> objp) const
{
return BaseProxyHandler::enumerate(cx, proxy, objp);
}
bool bool
DOMProxyHandler::has(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool* bp) const DOMProxyHandler::has(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool* bp) const
{ {

View File

@ -59,9 +59,6 @@ public:
virtual bool ownPropertyKeys(JSContext* cx, JS::Handle<JSObject*> proxy, virtual bool ownPropertyKeys(JSContext* cx, JS::Handle<JSObject*> proxy,
JS::AutoIdVector &props) const override; JS::AutoIdVector &props) const override;
virtual bool enumerate(JSContext *cx, JS::Handle<JSObject*> proxy,
JS::MutableHandle<JSObject*> objp) const override;
// We override getOwnEnumerablePropertyKeys() and implement it directly // We override getOwnEnumerablePropertyKeys() and implement it directly
// instead of using the default implementation, which would call // instead of using the default implementation, which would call
// ownPropertyKeys and then filter out the non-enumerable ones. This avoids // ownPropertyKeys and then filter out the non-enumerable ones. This avoids

View File

@ -59,16 +59,15 @@ class JS_FRIEND_API(Wrapper);
* *
* ### Proxies and internal methods * ### Proxies and internal methods
* *
* ES6 draft rev 27 (24 August 2014) specifies 14 internal methods. The runtime * ES2016 specifies 13 internal methods. The runtime semantics of just
* semantics of just about everything a script can do to an object is specified * about everything a script can do to an object is specified in terms
* in terms of these internal methods. For example: * of these internal methods. For example:
* *
* JS code ES6 internal method that gets called * JS code ES6 internal method that gets called
* --------------------------- -------------------------------- * --------------------------- --------------------------------
* obj.prop obj.[[Get]](obj, "prop") * obj.prop obj.[[Get]](obj, "prop")
* "prop" in obj obj.[[HasProperty]]("prop") * "prop" in obj obj.[[HasProperty]]("prop")
* new obj() obj.[[Construct]](<empty argument List>) * new obj() obj.[[Construct]](<empty argument List>)
* for (k in obj) {} obj.[[Enumerate]]()
* *
* With regard to the implementation of these internal methods, there are three * With regard to the implementation of these internal methods, there are three
* very different kinds of object in SpiderMonkey. * very different kinds of object in SpiderMonkey.
@ -261,14 +260,6 @@ class JS_FRIEND_API(BaseProxyHandler)
virtual bool delete_(JSContext* cx, HandleObject proxy, HandleId id, virtual bool delete_(JSContext* cx, HandleObject proxy, HandleId id,
ObjectOpResult& result) const = 0; ObjectOpResult& result) const = 0;
/*
* Because [[Enumerate]] is one of the standard traps it should be overridden.
* However for convenience BaseProxyHandler includes a pure virtual implementation,
* that turns the properties returned by getOwnEnumerablePropertyKeys (and proto walking)
* into an Iterator object.
*/
virtual bool enumerate(JSContext* cx, HandleObject proxy, MutableHandleObject objp) const = 0;
/* /*
* These methods are standard, but the engine does not normally call them. * These methods are standard, but the engine does not normally call them.
* They're opt-in. See "Proxy prototype chains" above. * They're opt-in. See "Proxy prototype chains" above.
@ -315,6 +306,7 @@ class JS_FRIEND_API(BaseProxyHandler)
virtual bool construct(JSContext* cx, HandleObject proxy, const CallArgs& args) const; virtual bool construct(JSContext* cx, HandleObject proxy, const CallArgs& args) const;
/* SpiderMonkey extensions. */ /* SpiderMonkey extensions. */
virtual bool enumerate(JSContext* cx, HandleObject proxy, MutableHandleObject objp) const;
virtual bool getPropertyDescriptor(JSContext* cx, HandleObject proxy, HandleId id, virtual bool getPropertyDescriptor(JSContext* cx, HandleObject proxy, HandleId id,
MutableHandle<PropertyDescriptor> desc) const; MutableHandle<PropertyDescriptor> desc) const;
virtual bool hasOwn(JSContext* cx, HandleObject proxy, HandleId id, bool* bp) const; virtual bool hasOwn(JSContext* cx, HandleObject proxy, HandleId id, bool* bp) const;

View File

@ -493,13 +493,6 @@ ModuleNamespaceObject::ProxyHandler::delete_(JSContext* cx, HandleObject proxy,
return result.succeed(); return result.succeed();
} }
bool
ModuleNamespaceObject::ProxyHandler::enumerate(JSContext* cx, HandleObject proxy,
MutableHandleObject objp) const
{
return BaseProxyHandler::enumerate(cx, proxy, objp);
}
bool bool
ModuleNamespaceObject::ProxyHandler::ownPropertyKeys(JSContext* cx, HandleObject proxy, ModuleNamespaceObject::ProxyHandler::ownPropertyKeys(JSContext* cx, HandleObject proxy,
AutoIdVector& props) const AutoIdVector& props) const

View File

@ -162,7 +162,6 @@ class ModuleNamespaceObject : public ProxyObject
AutoIdVector& props) const override; AutoIdVector& props) const override;
bool delete_(JSContext* cx, HandleObject proxy, HandleId id, bool delete_(JSContext* cx, HandleObject proxy, HandleId id,
ObjectOpResult& result) const override; ObjectOpResult& result) const override;
bool enumerate(JSContext* cx, HandleObject proxy, MutableHandleObject objp) const override;
bool getPrototype(JSContext* cx, HandleObject proxy, bool getPrototype(JSContext* cx, HandleObject proxy,
MutableHandleObject protop) const override; MutableHandleObject protop) const override;
bool setPrototype(JSContext* cx, HandleObject proxy, HandleObject proto, bool setPrototype(JSContext* cx, HandleObject proxy, HandleObject proto,

View File

@ -53,13 +53,6 @@ DeadObjectProxy::delete_(JSContext* cx, HandleObject wrapper, HandleId id,
return false; return false;
} }
bool
DeadObjectProxy::enumerate(JSContext* cx, HandleObject wrapper, MutableHandleObject objp) const
{
ReportDead(cx);
return false;
}
bool bool
DeadObjectProxy::getPrototype(JSContext* cx, HandleObject proxy, MutableHandleObject protop) const DeadObjectProxy::getPrototype(JSContext* cx, HandleObject proxy, MutableHandleObject protop) const
{ {

View File

@ -28,7 +28,6 @@ class DeadObjectProxy : public BaseProxyHandler
AutoIdVector& props) const override; AutoIdVector& props) const override;
virtual bool delete_(JSContext* cx, HandleObject wrapper, HandleId id, virtual bool delete_(JSContext* cx, HandleObject wrapper, HandleId id,
ObjectOpResult& result) const override; ObjectOpResult& result) const override;
virtual bool enumerate(JSContext* cx, HandleObject wrapper, MutableHandleObject objp) const override;
virtual bool getPrototype(JSContext* cx, HandleObject proxy, virtual bool getPrototype(JSContext* cx, HandleObject proxy,
MutableHandleObject protop) const override; MutableHandleObject protop) const override;
virtual bool preventExtensions(JSContext* cx, HandleObject proxy, virtual bool preventExtensions(JSContext* cx, HandleObject proxy,
@ -39,6 +38,7 @@ class DeadObjectProxy : public BaseProxyHandler
/* SpiderMonkey extensions. */ /* SpiderMonkey extensions. */
// BaseProxyHandler::getPropertyDescriptor will throw by calling getOwnPropertyDescriptor. // BaseProxyHandler::getPropertyDescriptor will throw by calling getOwnPropertyDescriptor.
// BaseProxyHandler::enumerate will throw by calling ownKeys.
virtual bool nativeCall(JSContext* cx, IsAcceptableThis test, NativeImpl impl, virtual bool nativeCall(JSContext* cx, IsAcceptableThis test, NativeImpl impl,
const CallArgs& args) const override; const CallArgs& args) const override;
virtual bool hasInstance(JSContext* cx, HandleObject proxy, MutableHandleValue v, virtual bool hasInstance(JSContext* cx, HandleObject proxy, MutableHandleValue v,

View File

@ -2333,11 +2333,6 @@ class DebugScopeProxy : public BaseProxyHandler
return true; return true;
} }
bool enumerate(JSContext* cx, HandleObject proxy, MutableHandleObject objp) const override
{
return BaseProxyHandler::enumerate(cx, proxy, objp);
}
bool has(JSContext* cx, HandleObject proxy, HandleId id_, bool* bp) const override bool has(JSContext* cx, HandleObject proxy, HandleId id_, bool* bp) const override
{ {
RootedId id(cx, id_); RootedId id(cx, id_);