mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 789897 - Make BaseProxyHandler::{isExtensible,preventExtensions} pure virtual. r=bholley
--HG-- extra : rebase_source : 6c3bada30b00877f0388baf8a72e18adf9636750
This commit is contained in:
parent
68374c319d
commit
286a3b9607
@ -75,6 +75,20 @@ DOMProxyHandler::EnsureExpandoObject(JSContext* cx, JSObject* obj)
|
||||
return expando;
|
||||
}
|
||||
|
||||
bool
|
||||
DOMProxyHandler::isExtensible(JSObject *proxy)
|
||||
{
|
||||
return true; // always extensible per WebIDL
|
||||
}
|
||||
|
||||
bool
|
||||
DOMProxyHandler::preventExtensions(JSContext *cx, JS::Handle<JSObject*> proxy)
|
||||
{
|
||||
// Throw a TypeError, per WebIDL.
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_CANT_CHANGE_EXTENSIBILITY);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
DOMProxyHandler::getPropertyDescriptor(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id,
|
||||
JSPropertyDescriptor* desc, unsigned flags)
|
||||
|
@ -36,6 +36,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
bool preventExtensions(JSContext *cx, JS::Handle<JSObject*> proxy) MOZ_OVERRIDE;
|
||||
bool getPropertyDescriptor(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id,
|
||||
JSPropertyDescriptor* desc, unsigned flags) MOZ_OVERRIDE;
|
||||
bool defineProperty(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id,
|
||||
@ -44,6 +45,7 @@ public:
|
||||
JS::Handle<jsid> id, bool* bp) MOZ_OVERRIDE;
|
||||
bool enumerate(JSContext* cx, JS::Handle<JSObject*> proxy, JS::AutoIdVector& props) MOZ_OVERRIDE;
|
||||
bool has(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool* bp) MOZ_OVERRIDE;
|
||||
bool isExtensible(JSObject *proxy) MOZ_OVERRIDE;
|
||||
using js::BaseProxyHandler::obj_toString;
|
||||
|
||||
static JSObject* GetExpandoObject(JSObject* obj)
|
||||
|
@ -306,23 +306,6 @@ BaseProxyHandler::iterate(JSContext *cx, HandleObject proxy, unsigned flags, Mut
|
||||
return EnumeratedIdVectorToIterator(cx, proxy, flags, props, vp);
|
||||
}
|
||||
|
||||
bool
|
||||
BaseProxyHandler::isExtensible(JSObject *proxy)
|
||||
{
|
||||
// Unaltered proxies always claim to be extensible. (Whether defining a
|
||||
// property will actually *work* is an entirely different question.) As a
|
||||
// necessary consequence, they can't be made non-extensible.
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
BaseProxyHandler::preventExtensions(JSContext *cx, HandleObject proxy)
|
||||
{
|
||||
// See above.
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_CANT_CHANGE_EXTENSIBILITY);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
BaseProxyHandler::call(JSContext *cx, HandleObject proxy, unsigned argc,
|
||||
Value *vp)
|
||||
@ -793,6 +776,7 @@ class ScriptedIndirectProxyHandler : public BaseProxyHandler {
|
||||
virtual ~ScriptedIndirectProxyHandler();
|
||||
|
||||
/* ES5 Harmony fundamental proxy traps. */
|
||||
virtual bool preventExtensions(JSContext *cx, HandleObject proxy) MOZ_OVERRIDE;
|
||||
virtual bool getPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
||||
PropertyDescriptor *desc, unsigned flags) MOZ_OVERRIDE;
|
||||
virtual bool getOwnPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
||||
@ -815,6 +799,7 @@ class ScriptedIndirectProxyHandler : public BaseProxyHandler {
|
||||
MutableHandleValue vp) MOZ_OVERRIDE;
|
||||
|
||||
/* Spidermonkey extensions. */
|
||||
virtual bool isExtensible(JSObject *proxy) MOZ_OVERRIDE;
|
||||
virtual bool call(JSContext *cx, HandleObject proxy, unsigned argc, Value *vp) MOZ_OVERRIDE;
|
||||
virtual bool construct(JSContext *cx, HandleObject proxy, unsigned argc,
|
||||
Value *argv, MutableHandleValue rval) MOZ_OVERRIDE;
|
||||
@ -838,6 +823,14 @@ ScriptedIndirectProxyHandler::~ScriptedIndirectProxyHandler()
|
||||
{
|
||||
}
|
||||
|
||||
bool
|
||||
ScriptedIndirectProxyHandler::preventExtensions(JSContext *cx, HandleObject proxy)
|
||||
{
|
||||
// Scripted indirect proxies don't support extensibility changes.
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_CANT_CHANGE_EXTENSIBILITY);
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool
|
||||
ReturnedValueMustNotBePrimitive(JSContext *cx, HandleObject proxy, JSAtom *atom, const Value &v)
|
||||
{
|
||||
@ -1018,6 +1011,13 @@ ScriptedIndirectProxyHandler::iterate(JSContext *cx, HandleObject proxy, unsigne
|
||||
ReturnedValueMustNotBePrimitive(cx, proxy, cx->names().iterate, vp);
|
||||
}
|
||||
|
||||
bool
|
||||
ScriptedIndirectProxyHandler::isExtensible(JSObject *proxy)
|
||||
{
|
||||
// Scripted indirect proxies don't support extensibility changes.
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
ScriptedIndirectProxyHandler::call(JSContext *cx, HandleObject proxy, unsigned argc,
|
||||
Value *vp)
|
||||
|
@ -104,7 +104,7 @@ class JS_FRIEND_API(BaseProxyHandler) {
|
||||
bool *bp);
|
||||
|
||||
/* ES5 Harmony fundamental proxy traps. */
|
||||
virtual bool preventExtensions(JSContext *cx, HandleObject proxy);
|
||||
virtual bool preventExtensions(JSContext *cx, HandleObject proxy) = 0;
|
||||
virtual bool getPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
||||
PropertyDescriptor *desc, unsigned flags) = 0;
|
||||
virtual bool getOwnPropertyDescriptor(JSContext *cx, HandleObject proxy,
|
||||
@ -129,7 +129,7 @@ class JS_FRIEND_API(BaseProxyHandler) {
|
||||
MutableHandleValue vp);
|
||||
|
||||
/* Spidermonkey extensions. */
|
||||
virtual bool isExtensible(JSObject *proxy);
|
||||
virtual bool isExtensible(JSObject *proxy) = 0;
|
||||
virtual bool call(JSContext *cx, HandleObject proxy, unsigned argc, Value *vp);
|
||||
virtual bool construct(JSContext *cx, HandleObject proxy, unsigned argc,
|
||||
Value *argv, MutableHandleValue rval);
|
||||
|
@ -687,6 +687,13 @@ DeadObjectProxy::DeadObjectProxy()
|
||||
{
|
||||
}
|
||||
|
||||
bool
|
||||
DeadObjectProxy::preventExtensions(JSContext *cx, HandleObject proxy)
|
||||
{
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_DEAD_OBJECT);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
DeadObjectProxy::getPropertyDescriptor(JSContext *cx, HandleObject wrapper, HandleId id,
|
||||
PropertyDescriptor *desc, unsigned flags)
|
||||
@ -733,6 +740,14 @@ DeadObjectProxy::enumerate(JSContext *cx, HandleObject wrapper, AutoIdVector &pr
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
DeadObjectProxy::isExtensible(JSObject *proxy)
|
||||
{
|
||||
// This is kind of meaningless, but dead-object semantics aside,
|
||||
// [[Extensible]] always being true is consistent with other proxy types.
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
DeadObjectProxy::call(JSContext *cx, HandleObject wrapper, unsigned argc, Value *vp)
|
||||
{
|
||||
|
@ -172,6 +172,7 @@ class JS_FRIEND_API(DeadObjectProxy) : public BaseProxyHandler
|
||||
explicit DeadObjectProxy();
|
||||
|
||||
/* ES5 Harmony fundamental wrapper traps. */
|
||||
virtual bool preventExtensions(JSContext *cx, HandleObject proxy) MOZ_OVERRIDE;
|
||||
virtual bool getPropertyDescriptor(JSContext *cx, HandleObject wrapper, HandleId id,
|
||||
PropertyDescriptor *desc, unsigned flags) MOZ_OVERRIDE;
|
||||
virtual bool getOwnPropertyDescriptor(JSContext *cx, HandleObject wrapper, HandleId id,
|
||||
@ -184,6 +185,7 @@ class JS_FRIEND_API(DeadObjectProxy) : public BaseProxyHandler
|
||||
virtual bool enumerate(JSContext *cx, HandleObject wrapper, AutoIdVector &props) MOZ_OVERRIDE;
|
||||
|
||||
/* Spidermonkey extensions. */
|
||||
virtual bool isExtensible(JSObject *proxy) MOZ_OVERRIDE;
|
||||
virtual bool call(JSContext *cx, HandleObject proxy, unsigned argc, Value *vp);
|
||||
virtual bool construct(JSContext *cx, HandleObject proxy, unsigned argc,
|
||||
Value *argv, MutableHandleValue rval);
|
||||
|
@ -1307,6 +1307,12 @@ class DebugScopeProxy : public BaseProxyHandler
|
||||
|
||||
DebugScopeProxy() : BaseProxyHandler(&family) {}
|
||||
|
||||
bool preventExtensions(JSContext *cx, HandleObject proxy) MOZ_OVERRIDE
|
||||
{
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_CANT_CHANGE_EXTENSIBILITY);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool getPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id, PropertyDescriptor *desc,
|
||||
unsigned flags) MOZ_OVERRIDE
|
||||
{
|
||||
@ -1466,6 +1472,13 @@ class DebugScopeProxy : public BaseProxyHandler
|
||||
return js_ReportValueErrorFlags(cx, JSREPORT_ERROR, JSMSG_CANT_DELETE,
|
||||
JSDVG_IGNORE_STACK, idval, NullPtr(), NULL, NULL);
|
||||
}
|
||||
|
||||
bool isExtensible(JSObject *proxy) MOZ_OVERRIDE
|
||||
{
|
||||
// always [[Extensible]], can't be made non-[[Extensible]], like most
|
||||
// proxies
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
int DebugScopeProxy::family = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user