зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset f1660c847ca2 (bug 978235) for landing with random debug code.
This commit is contained in:
Родитель
1e23ccace1
Коммит
0aecd9e3d2
|
@ -439,8 +439,6 @@ JavaScriptChild::AnswerIsExtensible(const ObjectId &objId, ReturnStatus *rs, boo
|
|||
if (!obj)
|
||||
return false;
|
||||
|
||||
JSAutoCompartment comp(cx, obj);
|
||||
|
||||
bool extensible;
|
||||
if (!JS_IsExtensible(cx, obj, &extensible))
|
||||
return fail(cx, rs);
|
||||
|
|
|
@ -312,7 +312,7 @@ struct BaselineScript
|
|||
inline bool
|
||||
IsBaselineEnabled(JSContext *cx)
|
||||
{
|
||||
return false && cx->runtime()->options().baseline();
|
||||
return cx->runtime()->options().baseline();
|
||||
}
|
||||
|
||||
MethodStatus
|
||||
|
|
|
@ -159,7 +159,7 @@ void StopAllOffThreadCompilations(JSCompartment *comp);
|
|||
static inline bool
|
||||
IsIonEnabled(JSContext *cx)
|
||||
{
|
||||
return false && cx->runtime()->options().ion() &&
|
||||
return cx->runtime()->options().ion() &&
|
||||
cx->runtime()->options().baseline() &&
|
||||
cx->runtime()->jitSupportsFloatingPoint;
|
||||
}
|
||||
|
|
|
@ -437,4 +437,3 @@ MSG_DEF(JSMSG_SETPROTOTYPEOF_FAIL, 382, 1, JSEXN_TYPEERR, "[[SetPrototypeOf
|
|||
MSG_DEF(JSMSG_INVALID_ARG_TYPE, 383, 3, JSEXN_TYPEERR, "Invalid type: {0} can't be a{1} {2}")
|
||||
MSG_DEF(JSMSG_TERMINATED, 384, 1, JSEXN_ERR, "Script terminated by timeout at:\n{0}")
|
||||
MSG_DEF(JSMSG_NO_SUCH_SELF_HOSTED_PROP, 385, 1, JSEXN_ERR, "No such property on self-hosted object: {0}")
|
||||
MSG_DEF(JSMSG_PROXY_EXTENSIBILITY, 386, 0, JSEXN_TYPEERR, "proxy must report same extensiblitity as target")
|
||||
|
|
|
@ -1077,6 +1077,12 @@ ScriptedIndirectProxyHandler::fun_toString(JSContext *cx, HandleObject proxy, un
|
|||
|
||||
ScriptedIndirectProxyHandler ScriptedIndirectProxyHandler::singleton;
|
||||
|
||||
static JSObject *
|
||||
GetDirectProxyHandlerObject(JSObject *proxy)
|
||||
{
|
||||
return proxy->as<ProxyObject>().extra(0).toObjectOrNull();
|
||||
}
|
||||
|
||||
/* Derived class for all scripted direct proxy handlers. */
|
||||
class ScriptedDirectProxyHandler : public DirectProxyHandler {
|
||||
public:
|
||||
|
@ -1108,9 +1114,6 @@ class ScriptedDirectProxyHandler : public DirectProxyHandler {
|
|||
virtual bool iterate(JSContext *cx, HandleObject proxy, unsigned flags,
|
||||
MutableHandleValue vp) MOZ_OVERRIDE;
|
||||
|
||||
/* ES6 Harmony traps */
|
||||
virtual bool isExtensible(JSContext *cx, HandleObject proxy, bool *extensible) MOZ_OVERRIDE;
|
||||
|
||||
/* Spidermonkey extensions. */
|
||||
virtual bool call(JSContext *cx, HandleObject proxy, const CallArgs &args) MOZ_OVERRIDE;
|
||||
virtual bool construct(JSContext *cx, HandleObject proxy, const CallArgs &args) MOZ_OVERRIDE;
|
||||
|
@ -1362,16 +1365,6 @@ IdToValue(JSContext *cx, HandleId id, MutableHandleValue value)
|
|||
return true;
|
||||
}
|
||||
|
||||
// Get the [[ProxyHandler]] of a scripted direct proxy.
|
||||
//
|
||||
// NB: This *must* stay synched with proxy().
|
||||
static JSObject *
|
||||
GetDirectProxyHandlerObject(JSObject *proxy)
|
||||
{
|
||||
JS_ASSERT(proxy->as<ProxyObject>().handler() == &ScriptedDirectProxyHandler::singleton);
|
||||
return proxy->as<ProxyObject>().extra(0).toObjectOrNull();
|
||||
}
|
||||
|
||||
// TrapGetOwnProperty(O, P)
|
||||
static bool
|
||||
TrapGetOwnProperty(JSContext *cx, HandleObject proxy, HandleId id, MutableHandleValue rval)
|
||||
|
@ -2232,42 +2225,6 @@ ScriptedDirectProxyHandler::keys(JSContext *cx, HandleObject proxy, AutoIdVector
|
|||
return ArrayToIdVector(cx, proxy, target, trapResult, props, JSITER_OWNONLY, cx->names().keys);
|
||||
}
|
||||
|
||||
// ES6 (5 April, 2014) 9.5.3 Proxy.[[IsExtensible]](P)
|
||||
bool
|
||||
ScriptedDirectProxyHandler::isExtensible(JSContext *cx, HandleObject proxy, bool *extensible)
|
||||
{
|
||||
RootedObject handler(cx, GetDirectProxyHandlerObject(proxy));
|
||||
|
||||
RootedObject target(cx, proxy->as<ProxyObject>().target());
|
||||
|
||||
RootedValue trap(cx);
|
||||
if (!JSObject::getProperty(cx, handler, handler, cx->names().isExtensible, &trap))
|
||||
return false;
|
||||
|
||||
if (trap.isUndefined())
|
||||
return DirectProxyHandler::isExtensible(cx, proxy, extensible);
|
||||
|
||||
Value argv[] = {
|
||||
ObjectValue(*target)
|
||||
};
|
||||
RootedValue trapResult(cx);
|
||||
if (!Invoke(cx, ObjectValue(*handler), trap, ArrayLength(argv), argv, &trapResult))
|
||||
return false;
|
||||
|
||||
bool booleanTrapResult = ToBoolean(trapResult);
|
||||
bool targetResult;
|
||||
if (!JSObject::isExtensible(cx, target, &targetResult))
|
||||
return false;
|
||||
|
||||
if (targetResult != booleanTrapResult) {
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_PROXY_EXTENSIBILITY);
|
||||
return false;
|
||||
}
|
||||
|
||||
*extensible = booleanTrapResult;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
ScriptedDirectProxyHandler::iterate(JSContext *cx, HandleObject proxy, unsigned flags,
|
||||
MutableHandleValue vp)
|
||||
|
|
|
@ -1,94 +0,0 @@
|
|||
// Test ES6 Proxy trap compliance for Object.isExtensible() on exotic proxy
|
||||
// objects.
|
||||
var unsealed = {};
|
||||
var sealed = Object.seal({});
|
||||
var handler = {};
|
||||
|
||||
assertEq(Object.isExtensible(unsealed), true);
|
||||
assertEq(Object.isExtensible(sealed), false);
|
||||
|
||||
var targetSealed = new Proxy(sealed, handler);
|
||||
var targetUnsealed = new Proxy(unsealed, handler);
|
||||
|
||||
var handlerCalled = false;
|
||||
|
||||
// without traps, forward to the target
|
||||
// First, make sure we get the obvious answer on a non-exotic target.
|
||||
assertEq(Object.isExtensible(targetSealed), false, "Must forward to target without hook.");
|
||||
assertEq(Object.isExtensible(targetUnsealed), true, "Must forward to target without hook.");
|
||||
|
||||
// Now, keep everyone honest. What if the target itself is a proxy?
|
||||
function ensureCalled() { handlerCalled = true; return true; }
|
||||
var proxyTarget = new Proxy({}, { isExtensible : ensureCalled });
|
||||
assertEq(Object.isExtensible(new Proxy(proxyTarget, {})), true, "Must forward to target without hook.");
|
||||
assertEq(handlerCalled, true, "Must forward to target without hook.");
|
||||
|
||||
// with traps, makes sure that the handler is called, and that we throw if the
|
||||
// trap disagrees with the target
|
||||
function testExtensible(obj, shouldThrow, expectedResult)
|
||||
{
|
||||
handlerCalled = false;
|
||||
if (shouldThrow)
|
||||
assertThrowsInstanceOf(function () { Object.isExtensible(obj); },
|
||||
TypeError, "Must throw if handler and target disagree.");
|
||||
else
|
||||
assertEq(Object.isExtensible(obj), expectedResult, "Must return the correct value.");
|
||||
assertEq(handlerCalled, true, "Must call handler trap if present");
|
||||
}
|
||||
|
||||
// What if the trap says it's necessarily sealed?
|
||||
function fakeSealed() { handlerCalled = true; return false; }
|
||||
handler.isExtensible = fakeSealed;
|
||||
testExtensible(targetSealed, false, false);
|
||||
testExtensible(targetUnsealed, true);
|
||||
|
||||
// What if the trap says it's never sealed?
|
||||
function fakeUnsealed() { handlerCalled = true; return true; }
|
||||
handler.isExtensible = fakeUnsealed;
|
||||
testExtensible(targetSealed, true);
|
||||
testExtensible(targetUnsealed, false, true);
|
||||
|
||||
// make sure we are able to prevent further extensions mid-flight and throw if the
|
||||
// hook tries to lie.
|
||||
function makeSealedTruth(target) { handlerCalled = true; Object.preventExtensions(target); return false; }
|
||||
function makeSealedLie(target) { handlerCalled = true; Object.preventExtensions(target); return true; }
|
||||
handler.isExtensible = makeSealedTruth;
|
||||
testExtensible(new Proxy({}, handler), false, false);
|
||||
handler.isExtensible = makeSealedLie;
|
||||
testExtensible(new Proxy({}, handler), true);
|
||||
|
||||
// What if the trap doesn't directly return a boolean?
|
||||
function falseyNonBool() { handlerCalled = true; return undefined; }
|
||||
handler.isExtensible = falseyNonBool;
|
||||
testExtensible(targetSealed, false, false);
|
||||
testExtensible(targetUnsealed, true);
|
||||
|
||||
function truthyNonBool() { handlerCalled = true; return {}; }
|
||||
handler.isExtensible = truthyNonBool;
|
||||
testExtensible(targetSealed, true);
|
||||
testExtensible(targetUnsealed, false, true);
|
||||
|
||||
// What if the trap throws?
|
||||
function ExtensibleError() { }
|
||||
ExtensibleError.prototype = new Error();
|
||||
ExtensibleError.prototype.constructor = ExtensibleError;
|
||||
function throwFromTrap() { throw new ExtensibleError(); }
|
||||
handler.isExtensible = throwFromTrap;
|
||||
|
||||
// exercise some other code paths and make sure that they invoke the trap and
|
||||
// can handle the ensuing error.
|
||||
assertThrowsInstanceOf(function () { Object.isExtensible(targetSealed); },
|
||||
ExtensibleError, "Must throw if the trap does.");
|
||||
assertThrowsInstanceOf(function () { Object.isFrozen(targetSealed); },
|
||||
ExtensibleError, "Must throw if the trap does.");
|
||||
assertThrowsInstanceOf(function () { Object.isSealed(targetSealed); },
|
||||
ExtensibleError, "Must throw if the trap does.");
|
||||
|
||||
|
||||
// What if the trap likes to re-ask old questions?
|
||||
function recurse() { return Object.isExtensible(targetSealed); }
|
||||
handler.isExtensible = recurse;
|
||||
assertThrowsInstanceOf(function () { Object.isExtensible(targetSealed); },
|
||||
InternalError, "Should allow and detect infinite recurison.");
|
||||
|
||||
reportCompare(0, 0, "OK");
|
|
@ -103,7 +103,6 @@
|
|||
macro(int8, int8, "int8") \
|
||||
macro(int16, int16, "int16") \
|
||||
macro(int32, int32, "int32") \
|
||||
macro(isExtensible, isExtensible, "isExtensible") \
|
||||
macro(iterator, iterator, "iterator") \
|
||||
macro(iteratorIntrinsic, iteratorIntrinsic, "__iterator__") \
|
||||
macro(join, join, "join") \
|
||||
|
|
|
@ -2920,8 +2920,6 @@ END_CASE(JSOP_SETALIASEDVAR)
|
|||
CASE(JSOP_GETARG)
|
||||
{
|
||||
unsigned i = GET_ARGNO(REGS.pc);
|
||||
if (script->lineno() == 39)
|
||||
printf("break here");
|
||||
if (script->argsObjAliasesFormals())
|
||||
PUSH_COPY(REGS.fp()->argsObj().arg(i));
|
||||
else
|
||||
|
|
Загрузка…
Ссылка в новой задаче