Bug 828462 - Root Proxy/Wrapper delete. r=terrence

This commit is contained in:
Tom Schuster 2013-03-21 23:23:48 +01:00
parent 097f3a1110
commit b8e3b65fa7
11 changed files with 33 additions and 34 deletions

View File

@ -554,7 +554,8 @@ public:
virtual bool getOwnPropertyNames(JSContext *cx,
JS::Handle<JSObject *> proxy,
JS::AutoIdVector &props) MOZ_OVERRIDE;
virtual bool delete_(JSContext *cx, JSObject *proxy, jsid id,
virtual bool delete_(JSContext *cx, JS::Handle<JSObject *> proxy,
JS::Handle<jsid> id,
bool *bp) MOZ_OVERRIDE;
virtual bool enumerate(JSContext *cx, JSObject *proxy,
JS::AutoIdVector &props) MOZ_OVERRIDE;
@ -692,8 +693,8 @@ nsOuterWindowProxy::getOwnPropertyNames(JSContext *cx, JS::Handle<JSObject *> pr
}
bool
nsOuterWindowProxy::delete_(JSContext *cx, JSObject *proxy, jsid id,
bool *bp)
nsOuterWindowProxy::delete_(JSContext *cx, JS::Handle<JSObject *> proxy,
JS::Handle<jsid> id, bool *bp)
{
if (nsCOMPtr<nsIDOMWindow> frame = GetSubframeWindow(cx, proxy, id)) {
// Reject (which means throw if strict, else return false) the delete.

View File

@ -6212,8 +6212,8 @@ class CGDOMJSProxyHandler_defineProperty(ClassMethod):
class CGDOMJSProxyHandler_delete(ClassMethod):
def __init__(self, descriptor):
args = [Argument('JSContext*', 'cx'), Argument('JSObject*', 'proxy'),
Argument('jsid', 'id'),
args = [Argument('JSContext*', 'cx'), Argument('JS::Handle<JSObject *>', 'proxy'),
Argument('JS::Handle<jsid>', 'id'),
Argument('bool*', 'bp')]
ClassMethod.__init__(self, "delete_", "bool", args)
self.descriptor = descriptor

View File

@ -124,7 +124,8 @@ DOMProxyHandler::defineProperty(JSContext* cx, JS::Handle<JSObject *> proxy, JS:
}
bool
DOMProxyHandler::delete_(JSContext* cx, JSObject* proxy, jsid id, bool* bp)
DOMProxyHandler::delete_(JSContext* cx, JS::Handle<JSObject *> proxy,
JS::Handle<jsid> id, bool* bp)
{
JSBool b = true;

View File

@ -40,7 +40,8 @@ public:
unsigned flags) MOZ_OVERRIDE;
bool defineProperty(JSContext* cx, JS::Handle<JSObject *> proxy, JS::Handle<jsid> id,
JSPropertyDescriptor* desc) MOZ_OVERRIDE;
bool delete_(JSContext* cx, JSObject* proxy, jsid id, bool* bp) MOZ_OVERRIDE;
bool delete_(JSContext* cx, JS::Handle<JSObject *> proxy,
JS::Handle<jsid> id, bool* bp) MOZ_OVERRIDE;
bool enumerate(JSContext* cx, JSObject* proxy, JS::AutoIdVector& props) MOZ_OVERRIDE;
bool fix(JSContext* cx, JSObject* proxy, JS::Value* vp);
bool has(JSContext* cx, JSObject* proxy, jsid id, bool* bp) MOZ_OVERRIDE;

View File

@ -498,11 +498,11 @@ DirectProxyHandler::getOwnPropertyNames(JSContext *cx, HandleObject proxy,
}
bool
DirectProxyHandler::delete_(JSContext *cx, JSObject *proxy, jsid id, bool *bp)
DirectProxyHandler::delete_(JSContext *cx, HandleObject proxy, HandleId id, bool *bp)
{
RootedValue v(cx);
assertEnteredPolicy(cx, proxy, id);
RootedObject target(cx, GetProxyTargetObject(proxy));
RootedValue v(cx);
if (!JS_DeletePropertyById2(cx, target, id, v.address()))
return false;
JSBool b;
@ -810,7 +810,7 @@ class ScriptedIndirectProxyHandler : public BaseProxyHandler {
virtual bool defineProperty(JSContext *cx, HandleObject proxy, HandleId id,
PropertyDescriptor *desc) MOZ_OVERRIDE;
virtual bool getOwnPropertyNames(JSContext *cx, HandleObject proxy, AutoIdVector &props);
virtual bool delete_(JSContext *cx, JSObject *proxy, jsid id, bool *bp) MOZ_OVERRIDE;
virtual bool delete_(JSContext *cx, HandleObject proxy, HandleId id, bool *bp) MOZ_OVERRIDE;
virtual bool enumerate(JSContext *cx, JSObject *proxy, AutoIdVector &props) MOZ_OVERRIDE;
/* ES5 Harmony derived proxy traps. */
@ -912,10 +912,9 @@ ScriptedIndirectProxyHandler::getOwnPropertyNames(JSContext *cx, HandleObject pr
}
bool
ScriptedIndirectProxyHandler::delete_(JSContext *cx, JSObject *proxy, jsid id_, bool *bp)
ScriptedIndirectProxyHandler::delete_(JSContext *cx, HandleObject proxy, HandleId id, bool *bp)
{
RootedObject handler(cx, GetIndirectProxyHandlerObject(proxy));
RootedId id(cx, id_);
RootedValue fval(cx), value(cx);
return GetFundamentalTrap(cx, handler, cx->names().delete_, &fval) &&
Trap1(cx, handler, fval, id, value.address()) &&
@ -1070,7 +1069,7 @@ class ScriptedDirectProxyHandler : public DirectProxyHandler {
virtual bool defineProperty(JSContext *cx, HandleObject proxy, HandleId id,
PropertyDescriptor *desc) MOZ_OVERRIDE;
virtual bool getOwnPropertyNames(JSContext *cx, HandleObject proxy, AutoIdVector &props);
virtual bool delete_(JSContext *cx, JSObject *proxy, jsid id, bool *bp) MOZ_OVERRIDE;
virtual bool delete_(JSContext *cx, HandleObject proxy, HandleId id, bool *bp) MOZ_OVERRIDE;
virtual bool enumerate(JSContext *cx, JSObject *proxy, AutoIdVector &props) MOZ_OVERRIDE;
/* ES5 Harmony derived proxy traps. */
@ -1726,11 +1725,8 @@ ScriptedDirectProxyHandler::getOwnPropertyNames(JSContext *cx, HandleObject prox
// Proxy.[[Delete]](P, Throw)
bool
ScriptedDirectProxyHandler::delete_(JSContext *cx, JSObject *proxy_, jsid id_, bool *bp)
ScriptedDirectProxyHandler::delete_(JSContext *cx, HandleObject proxy, HandleId id, bool *bp)
{
RootedObject proxy(cx, proxy_);
RootedId id(cx, id_);
// step 1
RootedObject handler(cx, GetDirectProxyHandlerObject(proxy));
@ -2336,12 +2332,10 @@ Proxy::getOwnPropertyNames(JSContext *cx, HandleObject proxy, AutoIdVector &prop
}
bool
Proxy::delete_(JSContext *cx, JSObject *proxy_, jsid id_, bool *bp)
Proxy::delete_(JSContext *cx, HandleObject proxy, HandleId id, bool *bp)
{
JS_CHECK_RECURSION(cx, return false);
BaseProxyHandler *handler = GetProxyHandler(proxy_);
RootedObject proxy(cx, proxy_);
RootedId id(cx, id_);
BaseProxyHandler *handler = GetProxyHandler(proxy);
*bp = true; // default result if we refuse to perform this action
AutoEnterPolicy policy(cx, handler, proxy, id, BaseProxyHandler::SET, true);
if (!policy.allowed())

View File

@ -113,7 +113,7 @@ class JS_FRIEND_API(BaseProxyHandler) {
PropertyDescriptor *desc) = 0;
virtual bool getOwnPropertyNames(JSContext *cx, HandleObject proxy,
AutoIdVector &props) = 0;
virtual bool delete_(JSContext *cx, JSObject *proxy, jsid id, bool *bp) = 0;
virtual bool delete_(JSContext *cx, HandleObject proxy, HandleId id, bool *bp) = 0;
virtual bool enumerate(JSContext *cx, JSObject *proxy,
AutoIdVector &props) = 0;
@ -167,7 +167,7 @@ public:
PropertyDescriptor *desc) MOZ_OVERRIDE;
virtual bool getOwnPropertyNames(JSContext *cx, HandleObject proxy,
AutoIdVector &props) MOZ_OVERRIDE;
virtual bool delete_(JSContext *cx, JSObject *proxy, jsid id,
virtual bool delete_(JSContext *cx, HandleObject proxy, HandleId id,
bool *bp) MOZ_OVERRIDE;
virtual bool enumerate(JSContext *cx, JSObject *proxy,
AutoIdVector &props) MOZ_OVERRIDE;
@ -218,7 +218,7 @@ class Proxy {
static bool defineProperty(JSContext *cx, HandleObject proxy, HandleId id, PropertyDescriptor *desc);
static bool defineProperty(JSContext *cx, HandleObject proxy, HandleId id, HandleValue v);
static bool getOwnPropertyNames(JSContext *cx, HandleObject proxy, AutoIdVector &props);
static bool delete_(JSContext *cx, JSObject *proxy, jsid id, bool *bp);
static bool delete_(JSContext *cx, HandleObject proxy, HandleId id, bool *bp);
static bool enumerate(JSContext *cx, JSObject *proxy, AutoIdVector &props);
/* ES5 Harmony derived proxy traps. */

View File

@ -276,12 +276,12 @@ CrossCompartmentWrapper::getOwnPropertyNames(JSContext *cx, HandleObject wrapper
}
bool
CrossCompartmentWrapper::delete_(JSContext *cx, JSObject *wrapperArg, jsid id, bool *bp)
CrossCompartmentWrapper::delete_(JSContext *cx, HandleObject wrapper, HandleId id, bool *bp)
{
RootedObject wrapper(cx, wrapperArg);
RootedId idCopy(cx, id);
PIERCE(cx, wrapper,
cx->compartment->wrapId(cx, &id),
Wrapper::delete_(cx, wrapper, id, bp),
cx->compartment->wrapId(cx, idCopy.address()),
Wrapper::delete_(cx, wrapper, idCopy, bp),
NOTHING);
}
@ -734,7 +734,7 @@ DeadObjectProxy::getOwnPropertyNames(JSContext *cx, HandleObject wrapper,
}
bool
DeadObjectProxy::delete_(JSContext *cx, JSObject *wrapper, jsid id, bool *bp)
DeadObjectProxy::delete_(JSContext *cx, HandleObject wrapper, HandleId id, bool *bp)
{
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_DEAD_OBJECT);
return false;

View File

@ -94,7 +94,7 @@ class JS_FRIEND_API(CrossCompartmentWrapper) : public Wrapper
PropertyDescriptor *desc) MOZ_OVERRIDE;
virtual bool getOwnPropertyNames(JSContext *cx, HandleObject wrapper,
AutoIdVector &props) MOZ_OVERRIDE;
virtual bool delete_(JSContext *cx, JSObject *wrapper, jsid id, bool *bp) MOZ_OVERRIDE;
virtual bool delete_(JSContext *cx, HandleObject wrapper, HandleId id, bool *bp) MOZ_OVERRIDE;
virtual bool enumerate(JSContext *cx, JSObject *wrapper, AutoIdVector &props) MOZ_OVERRIDE;
/* ES5 Harmony derived wrapper traps. */
@ -171,7 +171,7 @@ class JS_FRIEND_API(DeadObjectProxy) : public BaseProxyHandler
PropertyDescriptor *desc) MOZ_OVERRIDE;
virtual bool getOwnPropertyNames(JSContext *cx, HandleObject wrapper,
AutoIdVector &props) MOZ_OVERRIDE;
virtual bool delete_(JSContext *cx, JSObject *wrapper, jsid id, bool *bp) MOZ_OVERRIDE;
virtual bool delete_(JSContext *cx, HandleObject wrapper, HandleId id, bool *bp) MOZ_OVERRIDE;
virtual bool enumerate(JSContext *cx, JSObject *wrapper, AutoIdVector &props) MOZ_OVERRIDE;
/* Spidermonkey extensions. */

View File

@ -1469,7 +1469,7 @@ class DebugScopeProxy : public BaseProxyHandler
return true;
}
bool delete_(JSContext *cx, JSObject *proxy, jsid id, bool *bp) MOZ_OVERRIDE
bool delete_(JSContext *cx, HandleObject proxy, HandleId id, bool *bp) MOZ_OVERRIDE
{
RootedValue idval(cx, IdToValue(id));
return js_ReportValueErrorFlags(cx, JSREPORT_ERROR, JSMSG_CANT_DELETE,

View File

@ -1668,7 +1668,8 @@ XrayWrapper<Base, Traits>::getOwnPropertyNames(JSContext *cx, JS::Handle<JSObjec
template <typename Base, typename Traits>
bool
XrayWrapper<Base, Traits>::delete_(JSContext *cx, JSObject *wrapper, jsid id, bool *bp)
XrayWrapper<Base, Traits>::delete_(JSContext *cx, JS::Handle<JSObject *> wrapper,
JS::Handle<jsid> id, bool *bp)
{
assertEnteredPolicy(cx, wrapper, id);
// Redirect access straight to the wrapper if we should be transparent.

View File

@ -75,7 +75,8 @@ class XrayWrapper : public Base {
js::PropertyDescriptor *desc);
virtual bool getOwnPropertyNames(JSContext *cx, JS::Handle<JSObject *> wrapper,
js::AutoIdVector &props);
virtual bool delete_(JSContext *cx, JSObject *wrapper, jsid id, bool *bp);
virtual bool delete_(JSContext *cx, JS::Handle<JSObject *> wrapper,
JS::Handle<jsid> id, bool *bp);
virtual bool enumerate(JSContext *cx, JSObject *wrapper, js::AutoIdVector &props);
/* Derived proxy traps. */