Bug 1291011 - When inspecting an object, do not trim property names except when displaying them. r=jimb

Make proxyTarget and proxyHandler methods of Debugger.Object consider that the value of
[[ProxyTarget]] and [[ProxyHandler]] can be null in revoked scripted proxies.
This commit is contained in:
Oriol 2016-08-10 18:32:00 +02:00
Родитель c581ae6d18
Коммит a7275c6f7f
3 изменённых файлов: 40 добавлений и 18 удалений

Просмотреть файл

@ -189,18 +189,20 @@ from its prototype:
`undefined`.
`isProxy`
: If the referent is a (scripted) proxy, return `true`. If the referent is not
a (scripted) proxy, return `false`.
: If the referent is a (scripted) proxy, either revoked or not, return `true`.
If the referent is not a (scripted) proxy, return `false`.
`proxyTarget`
: If the referent is a (scripted) proxy, return a `Debugger.Object` instance
referring to the ECMAScript `[[ProxyTarget]]` of the referent. If the referent
is not a (scripted) proxy, return `undefined`.
: If the referent is a non-revoked (scripted) proxy, return a `Debugger.Object`
instance referring to the ECMAScript `[[ProxyTarget]]` of the referent.
If the referent is a revoked (scripted) proxy, return `null`.
If the referent is not a (scripted) proxy, return `undefined`.
`proxyHandler`
: If the referent is a (scripted) proxy, return a `Debugger.Object` instance
referring to the ECMAScript `[[ProxyHandler]]` of the referent. If the referent
is not a (scripted) proxy, return `undefined`.
: If the referent is a non-revoked (scripted) proxy, return a `Debugger.Object`
instance referring to the ECMAScript `[[ProxyHandler]]` of the referent.
If the referent is a revoked (scripted) proxy, return `null`.
If the referent is not a (scripted) proxy, return `undefined`.
`promiseState`
: If the referent is a [`Promise`][promise], this is an object describing

Просмотреть файл

@ -10,23 +10,35 @@ g.eval('var target = [1,2,3];');
g.eval('var handler = {has: ()=>false};');
g.eval('var proxy = new Proxy(target, handler);');
g.eval('var proxyProxy = new Proxy(proxy, proxy);');
g.eval('var revoker = Proxy.revocable(target, handler);');
g.eval('var revocable = revoker.proxy;');
var target = gDO.getOwnPropertyDescriptor('target').value;
var handler = gDO.getOwnPropertyDescriptor('handler').value;
var proxy = gDO.getOwnPropertyDescriptor('proxy').value;
var proxyProxy = gDO.getOwnPropertyDescriptor('proxyProxy').value;
var revocable = gDO.getOwnPropertyDescriptor('revocable').value;
assertEq(target.isProxy, false);
assertEq(handler.isProxy, false);
assertEq(proxy.isProxy, true);
assertEq(proxyProxy.isProxy, true);
assertEq(target.proxyTarget, undefined);
assertEq(handler.proxyTarget, undefined);
assertEq(proxy.proxyTarget, target);
assertEq(proxyProxy.proxyTarget, proxy);
assertEq(target.proxyHandler, undefined);
assertEq(handler.isProxy, false);
assertEq(handler.proxyTarget, undefined);
assertEq(handler.proxyHandler, undefined);
assertEq(proxy.isProxy, true);
assertEq(proxy.proxyTarget, target);
assertEq(proxy.proxyHandler, handler);
assertEq(proxyProxy.isProxy, true);
assertEq(proxyProxy.proxyTarget, proxy);
assertEq(proxyProxy.proxyHandler, proxy);
assertEq(revocable.isProxy, true);
assertEq(revocable.proxyTarget, target);
assertEq(revocable.proxyHandler, handler);
g.eval('revoker.revoke();');
assertEq(revocable.isProxy, true);
assertEq(revocable.proxyTarget, null);
assertEq(revocable.proxyHandler, null);

Просмотреть файл

@ -8499,7 +8499,7 @@ DebuggerObject::proxyTargetGetter(JSContext* cx, unsigned argc, Value* vp)
if (!DebuggerObject::scriptedProxyTarget(cx, object, &result))
return false;
args.rval().setObject(*result);
args.rval().setObjectOrNull(result);
return true;
}
@ -8516,7 +8516,7 @@ DebuggerObject::proxyHandlerGetter(JSContext* cx, unsigned argc, Value* vp)
if (!DebuggerObject::scriptedProxyHandler(cx, object, &result))
return false;
args.rval().setObject(*result);
args.rval().setObjectOrNull(result);
return true;
}
@ -9901,6 +9901,10 @@ DebuggerObject::scriptedProxyTarget(JSContext* cx, HandleDebuggerObject object,
RootedObject referent(cx, object->referent());
Debugger* dbg = object->owner();
RootedObject unwrapped(cx, js::GetProxyTargetObject(referent));
if(!unwrapped) {
result.set(nullptr);
return true;
}
return dbg->wrapDebuggeeObject(cx, unwrapped, result);
}
@ -9912,6 +9916,10 @@ DebuggerObject::scriptedProxyHandler(JSContext* cx, HandleDebuggerObject object,
RootedObject referent(cx, object->referent());
Debugger* dbg = object->owner();
RootedObject unwrapped(cx, ScriptedProxyHandler::handlerObject(referent));
if(!unwrapped) {
result.set(nullptr);
return true;
}
return dbg->wrapDebuggeeObject(cx, unwrapped, result);
}