Bug 980565 - Remove defunct Proxy.[[HasOwnProperty]]. (r=jorendorff)

This commit is contained in:
Eric Faust
2014-06-18 19:46:07 -07:00
parent 9af70e091e
commit 2004ae94b3
8 changed files with 25 additions and 172 deletions

View File

@@ -1071,7 +1071,9 @@ class ScriptedDirectProxyHandler : public DirectProxyHandler {
/* ES5 Harmony derived proxy traps. */
virtual bool has(JSContext *cx, HandleObject proxy, HandleId id, bool *bp) MOZ_OVERRIDE;
virtual bool hasOwn(JSContext *cx,HandleObject proxy, HandleId id, bool *bp) MOZ_OVERRIDE;
virtual bool hasOwn(JSContext *cx, HandleObject proxy, HandleId id, bool *bp) MOZ_OVERRIDE {
return BaseProxyHandler::hasOwn(cx, proxy, id, bp);
}
virtual bool get(JSContext *cx, HandleObject proxy, HandleObject receiver, HandleId id,
MutableHandleValue vp) MOZ_OVERRIDE;
virtual bool set(JSContext *cx, HandleObject proxy, HandleObject receiver, HandleId id,
@@ -1841,82 +1843,6 @@ ScriptedDirectProxyHandler::has(JSContext *cx, HandleObject proxy, HandleId id,
return true;
}
// Proxy.[[HasOwnProperty]](P)
bool
ScriptedDirectProxyHandler::hasOwn(JSContext *cx, HandleObject proxy, HandleId id, bool *bp)
{
// step 1
RootedObject handler(cx, GetDirectProxyHandlerObject(proxy));
// step 2
RootedObject target(cx, proxy->as<ProxyObject>().target());
// step 3
RootedValue trap(cx);
if (!JSObject::getProperty(cx, handler, handler, cx->names().hasOwn, &trap))
return false;
// step 4
if (trap.isUndefined())
return DirectProxyHandler::hasOwn(cx, proxy, id, bp);
// step 5
RootedValue value(cx);
if (!IdToExposableValue(cx, id, &value))
return false;
Value argv[] = {
ObjectOrNullValue(target),
value
};
RootedValue trapResult(cx);
if (!Invoke(cx, ObjectValue(*handler), trap, ArrayLength(argv), argv, &trapResult))
return false;
// step 6
bool success = ToBoolean(trapResult);
// steps 7-8
if (!success) {
bool sealed;
if (!IsSealed(cx, target, id, &sealed))
return false;
if (sealed) {
JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_CANT_REPORT_NC_AS_NE);
return false;
}
bool extensible;
if (!JSObject::isExtensible(cx, target, &extensible))
return false;
if (!extensible) {
bool isFixed;
if (!HasOwn(cx, target, id, &isFixed))
return false;
if (isFixed) {
JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_CANT_REPORT_E_AS_NE);
return false;
}
}
} else {
bool extensible;
if (!JSObject::isExtensible(cx, target, &extensible))
return false;
if (!extensible) {
bool isFixed;
if (!HasOwn(cx, target, id, &isFixed))
return false;
if (!isFixed) {
JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_CANT_REPORT_NEW);
return false;
}
}
}
// step 9
*bp = !!success;
return true;
}
// Proxy.[[GetP]](P, Receiver)
bool
ScriptedDirectProxyHandler::get(JSContext *cx, HandleObject proxy, HandleObject receiver,