mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-22 09:45:41 +00:00
Bug 892903 - Remove Proxy.create from jit-tests. r=efaust
This commit is contained in:
parent
c1175e55e5
commit
1d0c6f5e3a
@ -1,10 +0,0 @@
|
||||
// |jit-test| error:RangeError;
|
||||
load(libdir + "immutable-prototype.js");
|
||||
|
||||
if (!this.hasOwnProperty("TypedObject"))
|
||||
throw new RangeError();
|
||||
|
||||
if (globalPrototypeChainIsMutable())
|
||||
this.__proto__ = Proxy.create({});
|
||||
|
||||
new TypedObject.StructType;
|
@ -1,11 +0,0 @@
|
||||
// |jit-test| error:TypeError
|
||||
|
||||
// Binary: cache/js-dbg-64-9ca0a738a8ad-linux
|
||||
// Flags:
|
||||
//
|
||||
__defineSetter__("x", Array.reduce)
|
||||
x = Proxy.create(function() {},
|
||||
this.watch("x",
|
||||
function() {
|
||||
yield
|
||||
}))
|
@ -1,16 +0,0 @@
|
||||
// Binary: cache/js-dbg-32-fadb38356e0f-linux
|
||||
// Flags: -j
|
||||
//
|
||||
load(libdir + "immutable-prototype.js");
|
||||
|
||||
if (globalPrototypeChainIsMutable())
|
||||
{
|
||||
this.__proto__ = Proxy.create({
|
||||
has:function(){return false},
|
||||
set:function(){}
|
||||
});
|
||||
}
|
||||
|
||||
(function(){
|
||||
eval("(function(){ for(var j=0;j<6;++j) if(j%2==1) p=0; })")();
|
||||
})()
|
@ -1,14 +0,0 @@
|
||||
// Binary: cache/js-dbg-64-60c111fc0d4b-linux
|
||||
// Flags:
|
||||
//
|
||||
(function () {
|
||||
x = Proxy.createFunction((function () {
|
||||
return {
|
||||
getOwnPropertyDescriptor: function () {
|
||||
return this
|
||||
},
|
||||
get: undefined
|
||||
}
|
||||
})(), Object.getOwnPropertyDescriptor)
|
||||
})()
|
||||
x(x)
|
@ -1,12 +0,0 @@
|
||||
// |jit-test| error:TypeError
|
||||
|
||||
// Binary: cache/js-dbg-64-c271aa43c7ab-linux
|
||||
// Flags:
|
||||
//
|
||||
(function () {
|
||||
x = Proxy.create((function () {
|
||||
return {
|
||||
enumerateOwn: function () Object.getOwnPropertyDescriptor
|
||||
}
|
||||
})(), [])
|
||||
})()(uneval(this))
|
@ -1,18 +0,0 @@
|
||||
// |jit-test| error:TypeError
|
||||
|
||||
// Binary: cache/js-dbg-32-805fd625e65f-linux
|
||||
// Flags: -j
|
||||
//
|
||||
x = Proxy.create((function () {
|
||||
return {
|
||||
get: function () {}
|
||||
}
|
||||
}()), Object.e)
|
||||
Function("\
|
||||
for(var a = 0; a < 2; ++a) {\
|
||||
if (a == 0) {}\
|
||||
else {\
|
||||
x > x\
|
||||
}\
|
||||
}\
|
||||
")()
|
@ -1,15 +0,0 @@
|
||||
// |jit-test| error:TypeError
|
||||
|
||||
// Binary: cache/js-dbg-32-89b775191b9d-linux
|
||||
// Flags: -j
|
||||
//
|
||||
x = Proxy.create(function() {
|
||||
return {
|
||||
get: function() {}
|
||||
};
|
||||
} ());
|
||||
for (var a = 0; a < 6; ++a) {
|
||||
if (a == 3) {
|
||||
x > ""
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
// |jit-test| error:InternalError
|
||||
|
||||
// Binary: cache/js-dbg-64-b22e82ce2364-linux
|
||||
// Flags:
|
||||
//
|
||||
load(libdir + "immutable-prototype.js");
|
||||
|
||||
if (globalPrototypeChainIsMutable())
|
||||
__proto__ = Proxy.create(this, "");
|
||||
|
||||
throw new InternalError("fallback");
|
@ -1,21 +0,0 @@
|
||||
// |jit-test| error:TypeError
|
||||
|
||||
// Binary: cache/js-dbg-64-e8ee411dca70-linux
|
||||
// Flags:
|
||||
//
|
||||
x = Proxy.create((function () {
|
||||
return {
|
||||
get: Object.create
|
||||
}
|
||||
})([]), "")
|
||||
try {
|
||||
(function () {
|
||||
for each(l in [0]) {
|
||||
print(x)
|
||||
}
|
||||
})()
|
||||
} catch (e) {}
|
||||
gc()
|
||||
for each(let a in [0]) {
|
||||
print(x)
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
// |jit-test| error:TypeError
|
||||
|
||||
// Binary: cache/js-dbg-32-7ec0a71652a6-linux
|
||||
// Flags:
|
||||
//
|
||||
f = eval("\
|
||||
(function() {\
|
||||
__proto__ = \
|
||||
Proxy.createFunction((\
|
||||
function() {\
|
||||
return {\
|
||||
has: new ArrayBuffer,\
|
||||
}\
|
||||
})\
|
||||
(\"\"), \
|
||||
JSON.parse\
|
||||
)\
|
||||
})\
|
||||
")()
|
@ -1,10 +0,0 @@
|
||||
// Binary: cache/js-dbg-64-7ef107ab081e-linux
|
||||
// Flags:
|
||||
//
|
||||
var sandbox = evalcx("");
|
||||
function e(code) { try { evalcx(code, sandbox); } catch(e) { } }
|
||||
e("let x;");
|
||||
e("Object.seal(this);");
|
||||
e("x=Proxy.createFunction({keys:Object.getPrototypeOf},function(){})");
|
||||
e("const y;");
|
||||
|
@ -1,9 +0,0 @@
|
||||
// |jit-test| error:TypeError
|
||||
|
||||
// Binary: cache/js-dbg-64-66c8ad02543b-linux
|
||||
// Flags:
|
||||
//
|
||||
var handler = { fix: function() { return []; } };
|
||||
var p = Proxy.createFunction(handler, function(){}, function(){});
|
||||
Proxy.fix(p);
|
||||
new p();
|
@ -1,6 +0,0 @@
|
||||
// Binary: cache/js-dbg-64-6ca8580eb84f-linux
|
||||
// Flags:
|
||||
//
|
||||
var handler = {iterate: function() { return Iterator.prototype; }};
|
||||
var proxy = Proxy.create(handler);
|
||||
for (var p in proxy) { }
|
@ -1,12 +0,0 @@
|
||||
// Binary: cache/js-dbg-64-b01eb1ba58ce-linux
|
||||
// Flags: -m -n
|
||||
//
|
||||
|
||||
gczeal(2);
|
||||
var g1 = newGlobal('same-compartment');
|
||||
var proxyStr = "Proxy.create( "+
|
||||
" { getOwnPropertyDescriptor: function() assertEq(true,false), "+
|
||||
" fix: function() assertEq(true,false), }, "+
|
||||
" Object.prototype "+
|
||||
"); ";
|
||||
var proxy1 = g1.eval(proxyStr);
|
@ -5,5 +5,5 @@
|
||||
//
|
||||
var a = [];
|
||||
for (var i = 0; i < 200; ++i) a.push({});
|
||||
var p = Proxy.create({fix: function() { return a; }});
|
||||
var p = new Proxy({}, {preventExtensions() { return false; }});
|
||||
Object.preventExtensions(p);
|
||||
|
@ -1,20 +0,0 @@
|
||||
// |jit-test| error:TypeError
|
||||
|
||||
// Binary: cache/js-dbg-32-4ce3983a43f4-linux
|
||||
// Flags:
|
||||
//
|
||||
|
||||
function assertEq(setter) {
|
||||
if (setter > 10)
|
||||
return {assertEq: 3.3};
|
||||
return {__proto__: assertEq(setter + 1)};
|
||||
}
|
||||
function testX() {
|
||||
var x = 2;
|
||||
var local0 = x;
|
||||
return { local0: local0 };
|
||||
}
|
||||
var resultsX = testX();
|
||||
assertEq(resultsX.local0, 2);
|
||||
gczeal(2);
|
||||
assertEq(new (Proxy.createFunction({}, function(){}, function(){})), undefined);
|
@ -1,8 +0,0 @@
|
||||
// |jit-test| error:TypeError
|
||||
|
||||
// Binary: cache/js-dbg-64-4e9567eeb09e-linux
|
||||
// Flags:
|
||||
//
|
||||
evaluate({
|
||||
e: [].some(Proxy.create(function() {}), "")
|
||||
})
|
@ -1,7 +0,0 @@
|
||||
// |jit-test| error:TypeError
|
||||
x = Proxy.createFunction(function() {}, function() {})
|
||||
function f() {
|
||||
x = Proxy.create(function() {}, x())
|
||||
}
|
||||
f()
|
||||
f()
|
@ -1,8 +0,0 @@
|
||||
// |jit-test| error: TypeError
|
||||
Array.prototype.__proto__ = Proxy.create({
|
||||
getPropertyDescriptor: function(name) {
|
||||
return 0;
|
||||
},
|
||||
}, null);
|
||||
var statusitems = [];
|
||||
statusitems[0] = '';
|
@ -1,12 +0,0 @@
|
||||
// |jit-test| error: TypeError
|
||||
Object = function () {};
|
||||
var p = Proxy.create({});
|
||||
Object.prototype.__proto__ = p;
|
||||
function newFunc(x) { new Function(x)(); };
|
||||
newFunc('\
|
||||
function f(v, value) {\
|
||||
"failed: " + v + " " + value\
|
||||
}\
|
||||
f({}, false);\
|
||||
f(Object.prototype, false);\
|
||||
');
|
@ -1,2 +1,2 @@
|
||||
z = Proxy.create({}, (function(){}));
|
||||
z = new Proxy({__proto__: (function(){})}, {});
|
||||
({__proto__: z, set c(a) {}});
|
||||
|
@ -1,3 +1,3 @@
|
||||
// |jit-test| error: uncaught exception
|
||||
var prox = Proxy.create({getOwnPropertyDescriptor: function() { throw prox; }});
|
||||
var prox = new Proxy({}, {getOwnPropertyDescriptor: function() { throw prox; }});
|
||||
Object.prototype.__lookupGetter__.call(prox, 'q');
|
||||
|
@ -1,8 +1,8 @@
|
||||
function *f() {
|
||||
var o = Proxy.createFunction({
|
||||
var o = new Proxy({}, {
|
||||
get: function() { assertEq(0, 1); },
|
||||
has: function() { assertEq(0, 2); }
|
||||
}, function() {});
|
||||
});
|
||||
|
||||
with (o) {
|
||||
yield 1;
|
||||
|
@ -1,4 +1,4 @@
|
||||
var p = Proxy.create({
|
||||
var p = new Proxy({}, {
|
||||
getOwnPropertyDescriptor: function() {
|
||||
return {value: 1, configurable: true, writable: true};
|
||||
},
|
||||
|
@ -1,13 +0,0 @@
|
||||
// |jit-test| error: m is not defined
|
||||
load(libdir + "immutable-prototype.js");
|
||||
|
||||
if (globalPrototypeChainIsMutable()) {
|
||||
this.__proto__ = Proxy.create({
|
||||
has:function(){
|
||||
try {
|
||||
aa0 = Function(undefined);
|
||||
} catch (aa) {}
|
||||
}
|
||||
});
|
||||
}
|
||||
m();
|
@ -1,6 +0,0 @@
|
||||
// |jit-test| error: TypeError
|
||||
/* vim: set ts=8 sts=4 et sw=4 tw=99: */
|
||||
|
||||
var p = Proxy.createFunction({}, function(x, y) { undefined.x(); });
|
||||
print(new p(1, 2));
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
var o2 = Proxy.create({});
|
||||
var o2 = new Proxy({}, {});
|
||||
function f1() {}
|
||||
function f2() {}
|
||||
function f4(o) {
|
||||
|
@ -1,39 +0,0 @@
|
||||
var obj;
|
||||
var counter = 0;
|
||||
var p = Proxy.create({
|
||||
has : function(id) {
|
||||
if (id == 'xyz') {
|
||||
++counter;
|
||||
if (counter == 7) {
|
||||
obj.__proto__ = null;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
get : function(id) {
|
||||
if (id == 'xyz')
|
||||
return 10;
|
||||
}
|
||||
});
|
||||
|
||||
function test()
|
||||
{
|
||||
Object.prototype.__proto__ = null;
|
||||
obj = { xyz: 1};
|
||||
var n = 0;
|
||||
for (var i = 0; i != 100; ++i) {
|
||||
var s = obj.xyz;
|
||||
if (s)
|
||||
++n;
|
||||
if (i == 10) {
|
||||
delete obj.xyz;
|
||||
Object.prototype.__proto__ = p;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
test();
|
||||
} catch (e) {}
|
@ -1,10 +0,0 @@
|
||||
a = {}
|
||||
a.getOwnPropertyDescriptor = Array;
|
||||
b = Proxy.create(a)
|
||||
for (x in this)
|
||||
try {
|
||||
(function() {
|
||||
"use strict";
|
||||
b[2] = x // don't assert
|
||||
})()
|
||||
} catch (e) {}
|
@ -10,7 +10,7 @@ function reportCompare (expected, actual, description) {
|
||||
new TestCase
|
||||
}
|
||||
reportCompare(true, eval++, "Dummy description.");
|
||||
var p = Proxy.create({
|
||||
var p = new Proxy({}, {
|
||||
has : function(id) {},
|
||||
set : function() {}
|
||||
});
|
||||
|
@ -1,4 +1,4 @@
|
||||
var prox = Proxy.create({
|
||||
var prox = new Proxy({}, {
|
||||
getOwnPropertyDescriptor: function() { return undefined; },
|
||||
has: function() { return true; },
|
||||
});
|
||||
|
@ -1,12 +1,12 @@
|
||||
var g = true;
|
||||
|
||||
function getown(name)
|
||||
function get(name)
|
||||
{
|
||||
if (g)
|
||||
return { value: 8, enumerable: true, writable: false, configurable: true };
|
||||
return 8;
|
||||
}
|
||||
|
||||
var p = Proxy.create( { getPropertyDescriptor: getown } );
|
||||
var p = new Proxy({}, { get: get } );
|
||||
var o2 = Object.create(p);
|
||||
|
||||
function test(x, expected) {
|
||||
|
@ -1,9 +1,14 @@
|
||||
var objectProxy = Proxy.create({});
|
||||
var functionProxy = Proxy.createFunction({}, function() {}, function() {});
|
||||
var objectProxy = new Proxy({}, {});
|
||||
var functionProxy = new Proxy(function() {}, {});
|
||||
|
||||
assertEq(Object.prototype.toString.call(objectProxy), '[object Object]');
|
||||
assertEq(Object.prototype.toString.call(functionProxy), '[object Function]');
|
||||
assertEq(Function.prototype.toString.call(functionProxy), 'function () {}');
|
||||
try {
|
||||
Function.prototype.toString.call(functionProxy);
|
||||
assertEq(true, false);
|
||||
} catch (e) {
|
||||
assertEq(!!/incompatible/.exec(e), true);
|
||||
}
|
||||
try {
|
||||
Function.prototype.toString.call(objectProxy);
|
||||
assertEq(true, false);
|
||||
|
@ -1,19 +1,10 @@
|
||||
// |jit-test| error: TypeError
|
||||
load(libdir + "immutable-prototype.js");
|
||||
|
||||
p = Proxy.create({
|
||||
has: function() { return function r() { return (s += ''); } },
|
||||
get: function() { throw new TypeError("hit get"); }
|
||||
});
|
||||
|
||||
if (globalPrototypeChainIsMutable()) {
|
||||
Object.prototype.__proto__ = p;
|
||||
} else {
|
||||
Object.defineProperty(Object.prototype, "name",
|
||||
{ set(v) { throw new TypeError("hit name"); },
|
||||
enumerable: true,
|
||||
configurable: true });
|
||||
}
|
||||
Object.defineProperty(Object.prototype, "name",
|
||||
{ set(v) { throw new TypeError("hit name"); },
|
||||
enumerable: true,
|
||||
configurable: true });
|
||||
|
||||
function TestCase(n) {
|
||||
this.name = n;
|
||||
|
@ -1,8 +0,0 @@
|
||||
// |jit-test| error: InternalError
|
||||
let k
|
||||
Proxy.createFunction(function() {
|
||||
return {
|
||||
get: (n) => new Uint32Array(n)
|
||||
}
|
||||
}(), decodeURIComponent) & k
|
||||
|
@ -1 +1 @@
|
||||
try { for (let v of wrapWithProto(Proxy.create({}), [])) { } } catch (e) {}
|
||||
try { for (let v of wrapWithProto(new Proxy({}, {}), [])) { } } catch (e) {}
|
||||
|
@ -1,21 +0,0 @@
|
||||
// When we assign to a property that a proxy claims is inherited, the
|
||||
// defineProperty handler call to create the new own property should get
|
||||
// the newly assigned value.
|
||||
|
||||
var hits;
|
||||
var handlers = {
|
||||
getOwnPropertyDescriptor: function(name) {
|
||||
return undefined;
|
||||
},
|
||||
getPropertyDescriptor: function(name) {
|
||||
return { value:42, writable:true, enumerable:true, configurable:true };
|
||||
},
|
||||
defineProperty: function(name, descriptor) {
|
||||
hits++;
|
||||
assertEq(name, 'x');
|
||||
assertEq(descriptor.value, 43);
|
||||
}
|
||||
};
|
||||
hits = 0;
|
||||
Proxy.create(handlers).x = 43;
|
||||
assertEq(hits, 1);
|
@ -3,7 +3,7 @@
|
||||
* visible externally.
|
||||
*/
|
||||
|
||||
function handlerMaker(obj, expected_exceptions) {
|
||||
function handlerMaker(expected_exceptions) {
|
||||
var order = [];
|
||||
function note(trap, name)
|
||||
{
|
||||
@ -15,68 +15,23 @@ function handlerMaker(obj, expected_exceptions) {
|
||||
|
||||
return [{
|
||||
/* this is the only trap we care about */
|
||||
delete: function(name) {
|
||||
deleteProperty: function(target, name) {
|
||||
note("del", name);
|
||||
return delete obj[name];
|
||||
return Reflect.deleteProperty(target, name);
|
||||
},
|
||||
|
||||
// Fundamental traps
|
||||
getOwnPropertyDescriptor: function(name) {
|
||||
var desc = Object.getOwnPropertyDescriptor(obj, name);
|
||||
// a trapping proxy's properties must always be configurable
|
||||
if (desc !== undefined)
|
||||
desc.configurable = true;
|
||||
return desc;
|
||||
},
|
||||
getPropertyDescriptor: function(name) {
|
||||
var desc = Object.getPropertyDescriptor(obj, name); // not in ES5
|
||||
// a trapping proxy's properties must always be configurable
|
||||
if (desc !== undefined)
|
||||
desc.configurable = true;
|
||||
return desc;
|
||||
},
|
||||
getOwnPropertyNames: function() {
|
||||
return Object.getOwnPropertyNames(obj);
|
||||
},
|
||||
getPropertyNames: function() {
|
||||
return Object.getPropertyNames(obj); // not in ES5
|
||||
},
|
||||
defineProperty: function(name, desc) {
|
||||
note("def", name);
|
||||
Object.defineProperty(obj, name, desc);
|
||||
},
|
||||
fix: function() {
|
||||
if (Object.isFrozen(obj)) {
|
||||
return Object.getOwnPropertyNames(obj).map(function(name) {
|
||||
return Object.getOwnPropertyDescriptor(obj, name);
|
||||
});
|
||||
}
|
||||
// As long as obj is not frozen, the proxy won't allow itself to be fixed
|
||||
return undefined; // will cause a TypeError to be thrown
|
||||
},
|
||||
|
||||
// derived traps
|
||||
has: function(name) {
|
||||
has: function(target, name) {
|
||||
note("has", name);
|
||||
return name in obj;
|
||||
return name in target;
|
||||
},
|
||||
hasOwn: function(name) { return Object.prototype.hasOwnProperty.call(obj, name); },
|
||||
get: function(receiver, name) {
|
||||
get: function(target, name, receiver) {
|
||||
note("get", name);
|
||||
return obj[name];
|
||||
return Reflect.get(target, name, receiver);
|
||||
},
|
||||
set: function(receiver, name, val) {
|
||||
set: function(target, name, value, receiver) {
|
||||
note("set", name);
|
||||
obj[name] = val;
|
||||
return true; // bad behavior when set fails in non-strict mode
|
||||
return Reflect.set(target, name, value, receiver);
|
||||
},
|
||||
enumerate: function() {
|
||||
var result = [];
|
||||
for (name in obj)
|
||||
result.push(name);
|
||||
return result;
|
||||
},
|
||||
keys: function() { return Object.keys(obj) }
|
||||
}, order];
|
||||
}
|
||||
|
||||
@ -84,8 +39,8 @@ function handlerMaker(obj, expected_exceptions) {
|
||||
// expected_order: the expected order of operations on arr, stringified
|
||||
function check_splice_proxy(arr, expected_order, expected_exceptions, expected_array, expected_result) {
|
||||
print (arr);
|
||||
var [handler, store] = handlerMaker(arr, expected_exceptions);
|
||||
var proxy = Proxy.create(handler);
|
||||
var [handler, store] = handlerMaker(expected_exceptions);
|
||||
var proxy = new Proxy(arr, handler);
|
||||
|
||||
try {
|
||||
var args = Array.prototype.slice.call(arguments, 5);
|
||||
|
@ -5,11 +5,11 @@ f = function() {
|
||||
}
|
||||
rv = f()
|
||||
for (a in rv) (function() {})
|
||||
x = Proxy.create((function() {
|
||||
x = new Proxy({}, (function() {
|
||||
return {
|
||||
defineProperty: gc
|
||||
}
|
||||
})(), x)
|
||||
})());
|
||||
with({
|
||||
d: (({
|
||||
x: Object.defineProperty(x, "", ({
|
||||
|
@ -1,6 +0,0 @@
|
||||
if (Proxy.fix) {
|
||||
var handler = { fix: function() { return []; } };
|
||||
var p = Proxy.createFunction(handler, function(){}, function(){});
|
||||
Proxy.fix(p);
|
||||
new p();
|
||||
}
|
@ -1,8 +1,6 @@
|
||||
var proxy = Proxy.createFunction(
|
||||
{},
|
||||
function() {
|
||||
var proxy = new Proxy(function() {
|
||||
return (function () { eval("foo") })();
|
||||
});
|
||||
}, {});
|
||||
|
||||
try {
|
||||
new proxy();
|
||||
|
@ -1,21 +1,15 @@
|
||||
function getter() { return 1; }
|
||||
function setter() { }
|
||||
function getDescriptor(name) {
|
||||
function getDescriptor(target, name) {
|
||||
if (name != 'prop')
|
||||
throw "Unknown property: " + name;
|
||||
return { configurable: true, enumerable: true, get: getter, set: setter };
|
||||
}
|
||||
function getNames() { return ['prop']; }
|
||||
var handler = {
|
||||
getOwnPropertyDescriptor: getDescriptor,
|
||||
getPropertyDescriptor: getDescriptor,
|
||||
getOwnPropertyNames: getNames,
|
||||
getPropertyNames: getNames,
|
||||
defineProperty: function() {},
|
||||
delete: function() {}
|
||||
};
|
||||
|
||||
// Make sure that __lookup{Getter,Setter}__ works on proxies.
|
||||
var proxy = Proxy.create(handler);
|
||||
var proxy = new Proxy({}, handler);
|
||||
assertEq(Object.prototype.__lookupGetter__.call(proxy, 'prop'), getter);
|
||||
assertEq(Object.prototype.__lookupSetter__.call(proxy, 'prop'), setter);
|
||||
|
@ -1,4 +1,4 @@
|
||||
// |jit-test| error:TypeError
|
||||
var otherGlobal = newGlobal();
|
||||
var proxy = otherGlobal.Proxy.create({}, {});
|
||||
var proxy = new (otherGlobal.Proxy)({}, {});
|
||||
Int8Array.set(proxy);
|
||||
|
@ -2,16 +2,14 @@
|
||||
|
||||
var g1 = newGlobal('same-compartment');
|
||||
var g2 = newGlobal();
|
||||
var proxyStr = "Proxy.create( "+
|
||||
var proxyStr = "new Proxy({}, "+
|
||||
" { getOwnPropertyDescriptor: () =>assertEq(true,false), "+
|
||||
" getPropertyDescriptor: () =>assertEq(true,false), "+
|
||||
" getOwnPropertyNames: () =>assertEq(true,false), "+
|
||||
" getPropertyNames: () =>assertEq(true,false), "+
|
||||
" ownKeys: () =>assertEq(true,false), "+
|
||||
" defineProperty: () =>assertEq(true,false), "+
|
||||
" delete: () =>assertEq(true,false), "+
|
||||
" fix: () =>assertEq(true,false), }, "+
|
||||
" Object.prototype "+
|
||||
"); ";
|
||||
" deleteProperty: () =>assertEq(true,false), "+
|
||||
" get: () =>assertEq(true,false), "+
|
||||
" set: () =>assertEq(true,false), "+
|
||||
"}); ";
|
||||
var proxy1 = g1.eval(proxyStr);
|
||||
var proxy2 = g2.eval(proxyStr);
|
||||
|
||||
|
@ -1,19 +0,0 @@
|
||||
// |jit-test| error: ExitCleanly
|
||||
|
||||
var handler = { getPropertyDescriptor() { return undefined; } }
|
||||
|
||||
assertEq((new (Proxy.createFunction(handler,
|
||||
function(){ this.x = 1 },
|
||||
function(){ this.x = 2 }))).x, 2);
|
||||
// proxies can return the callee
|
||||
var x = Proxy.createFunction(handler, function (q) { return q; });
|
||||
assertEq(new x(x), x);
|
||||
try {
|
||||
var x = (Proxy.createFunction(handler, "".indexOf));
|
||||
new x;
|
||||
throw "Should not be reached"
|
||||
}
|
||||
catch (e) {
|
||||
assertEq(String(e.message).indexOf('is not a constructor') === -1, false);
|
||||
}
|
||||
throw "ExitCleanly"
|
@ -4,13 +4,12 @@ var actual = "";
|
||||
|
||||
try {
|
||||
|
||||
(x = Proxy.createFunction((function() {
|
||||
return {
|
||||
defineProperty: function(name, desc) {
|
||||
var x = new Proxy({}, {
|
||||
defineProperty: function(target, name, desc) {
|
||||
Object.defineProperty(x, name, desc)
|
||||
},
|
||||
}
|
||||
})(), (eval)));
|
||||
});
|
||||
|
||||
Object.defineProperty(x, "", ({
|
||||
get: function() {}
|
||||
}))
|
||||
|
@ -11,5 +11,5 @@ dbg.onDebuggerStatement = function (frame) {
|
||||
assertEq(proxy.call(null, 33).return, 34);
|
||||
hits++;
|
||||
};
|
||||
g.eval("f(Proxy.createFunction({}, function (arg) { return arg + 1; }));");
|
||||
g.eval("f(new Proxy(function (arg) { return arg + 1; }, {}));");
|
||||
assertEq(hits, 1);
|
||||
|
@ -13,6 +13,6 @@ g.eval("function f(obj, iscallable) { debugger; }");
|
||||
g.eval("f({}, false);");
|
||||
g.eval("f(Function.prototype, true);");
|
||||
g.eval("f(f, true);");
|
||||
g.eval("f(Proxy.create({}), false);");
|
||||
g.eval("f(Proxy.createFunction(f, f), true);");
|
||||
g.eval("f(new Proxy({}, {}), false);");
|
||||
g.eval("f(new Proxy(f, {}), true);");
|
||||
assertEq(hits, 5);
|
||||
|
@ -16,11 +16,11 @@ dbg.onDebuggerStatement = function (frame) {
|
||||
hits++;
|
||||
};
|
||||
g.f(Object.prototype, [], eval, new Date,
|
||||
Proxy.create({}), Proxy.createFunction({}, eval), new Proxy(new Date, {}));
|
||||
new Proxy({}, {}), new Proxy(eval, {}), new Proxy(new Date, {}));
|
||||
assertEq(hits, 1);
|
||||
|
||||
// Debugger.Object.prototype.class should see through cross-compartment
|
||||
// wrappers.
|
||||
g.eval('f(Object.prototype, [], eval, new Date,\
|
||||
Proxy.create({}), Proxy.createFunction({}, f), new Proxy(new Date, {}));');
|
||||
new Proxy({}, {}), new Proxy(f, {}), new Proxy(new Date, {}));');
|
||||
assertEq(hits, 2);
|
||||
|
@ -12,5 +12,5 @@ dbg.onDebuggerStatement = function (frame) {
|
||||
};
|
||||
|
||||
g.eval("function h(obj) { debugger; }");
|
||||
g.eval("h(Proxy.create({delete: function () { throw Error.prototype; }}));");
|
||||
g.eval("h(new Proxy({}, { deleteProperty() { throw Error.prototype; }}));");
|
||||
|
||||
|
@ -12,5 +12,5 @@ g.eval("function f(nonfunction) { debugger; }");
|
||||
g.eval("f({});");
|
||||
g.eval("f(/a*/);");
|
||||
g.eval("f({name: 'bad'});");
|
||||
g.eval("f(Proxy.createFunction({name: {value: 'bad'}}, function () {}));");
|
||||
g.eval("f(new Proxy({}, {}));");
|
||||
assertEq(hits, 4);
|
||||
|
@ -5,7 +5,7 @@ load(libdir + "iteration.js");
|
||||
|
||||
var s = '';
|
||||
|
||||
var proxyObj = {
|
||||
var handler = {
|
||||
get: function (recipient, name) {
|
||||
if (name == 'length') {
|
||||
s += 'L';
|
||||
@ -17,7 +17,7 @@ var proxyObj = {
|
||||
}
|
||||
};
|
||||
|
||||
var it = Array.prototype[Symbol.iterator].call(Proxy.create(proxyObj));
|
||||
var it = Array.prototype[Symbol.iterator].call(new Proxy([0, 1], handler));
|
||||
|
||||
assertIteratorNext(it, "0");
|
||||
s += ' ';
|
||||
@ -27,7 +27,7 @@ assertIteratorDone(it, undefined);
|
||||
assertEq(s, "L0 L1 L");
|
||||
|
||||
s = '';
|
||||
var ki = Array.prototype.keys.call(Proxy.create(proxyObj));
|
||||
var ki = Array.prototype.keys.call(new Proxy([0, 1], handler));
|
||||
|
||||
assertIteratorNext(ki, 0);
|
||||
s += ' ';
|
||||
@ -37,7 +37,7 @@ assertIteratorDone(ki, undefined);
|
||||
assertEq(s, "L L L");
|
||||
|
||||
s = '';
|
||||
var ei = Array.prototype.entries.call(Proxy.create(proxyObj));
|
||||
var ei = Array.prototype.entries.call(new Proxy([0, 1], handler));
|
||||
|
||||
assertIteratorNext(ei, [0, "0"]);
|
||||
s += ' ';
|
||||
|
@ -1,25 +1,10 @@
|
||||
// Basic for-of test with Proxy.
|
||||
|
||||
function iterableProxy(arr) {
|
||||
return Proxy.create({
|
||||
getPropertyDescriptor: function (name) {
|
||||
for (var obj = arr; obj; obj = Object.getPrototypeOf(obj)) {
|
||||
var desc = Object.getOwnPropertyDescriptor(obj, name);
|
||||
if (desc)
|
||||
return desc;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var s = '';
|
||||
var arr = ['a', 'b', 'c', 'd'];
|
||||
var p = iterableProxy(arr);
|
||||
var p = new Proxy(arr, {});
|
||||
|
||||
// Test the same proxy twice. Each time through the loop, the proxy handler's
|
||||
// getPropertyDescriptor method will be called 10 times (once for 'iterator',
|
||||
// five times for 'length', and once for each of the four elements).
|
||||
// Test the same proxy twice.
|
||||
for (var i = 0; i < 2; i++) {
|
||||
var j = 0;
|
||||
for (var x of p)
|
||||
|
@ -1,27 +1,16 @@
|
||||
// Basic for-of test with Proxy whose iterator method is a generator.
|
||||
|
||||
var arr = ['a', 'b', 'c', 'd'];
|
||||
var proxy = Proxy.create({
|
||||
getPropertyDescriptor: function (name) {
|
||||
if (name == 'iterator') {
|
||||
return {
|
||||
configurable: false,
|
||||
enumerable: false,
|
||||
writeable: false,
|
||||
value: function () {
|
||||
for (var i = 0; i < arr.length; i++)
|
||||
yield arr[i];
|
||||
}
|
||||
};
|
||||
var proxy = new Proxy(arr, {
|
||||
get(target, property, receiver) {
|
||||
if (property === Symbol.iterator) {
|
||||
return function* () {
|
||||
for (var i = 0; i < arr.length; i++)
|
||||
yield arr[i];
|
||||
}
|
||||
}
|
||||
|
||||
// Otherwise, inherit the property from arr.
|
||||
for (var obj = arr; obj; obj = Object.getPrototypeOf(obj)) {
|
||||
var desc = Object.getOwnPropertyDescriptor(obj, name);
|
||||
if (desc)
|
||||
return desc;
|
||||
}
|
||||
return undefined;
|
||||
return Reflect.get(target, property, receiver);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -3,9 +3,9 @@
|
||||
load(libdir + "asserts.js");
|
||||
load(libdir + "iteration.js");
|
||||
|
||||
var p = Proxy.create({
|
||||
getPropertyDescriptor: function (name) {
|
||||
if (name == Symbol.iterator)
|
||||
var p = new Proxy({}, {
|
||||
get(target, property) {
|
||||
if (property === Symbol.iterator)
|
||||
throw "fit";
|
||||
return undefined;
|
||||
}
|
||||
|
@ -5,31 +5,31 @@ load(libdir + "iteration.js");
|
||||
var s = '';
|
||||
|
||||
var i = 0;
|
||||
var next_fn = Proxy.createFunction({}, function () {
|
||||
s += "n";
|
||||
if (i == 3)
|
||||
return { value: undefined, done: true };
|
||||
return { value: i++, done: false };
|
||||
var next_fn = new Proxy(function() {}, {
|
||||
apply() {
|
||||
s += "n";
|
||||
if (i == 3)
|
||||
return { value: undefined, done: true };
|
||||
return { value: i++, done: false };
|
||||
}
|
||||
});
|
||||
|
||||
var it = Proxy.create({
|
||||
get: function (receiver, name) {
|
||||
if (name == 'toSource') {
|
||||
s += '?';
|
||||
return () => 'it';
|
||||
}
|
||||
assertEq(name, "next");
|
||||
var it = new Proxy({}, {
|
||||
get(target, property, receiver) {
|
||||
assertEq(property, "next");
|
||||
s += "N";
|
||||
return next_fn;
|
||||
}
|
||||
});
|
||||
|
||||
var iterator_fn = Proxy.createFunction({}, function () {
|
||||
s += 'i';
|
||||
return it;
|
||||
var iterator_fn = new Proxy(function() {}, {
|
||||
apply() {
|
||||
s += 'i';
|
||||
return it;
|
||||
}
|
||||
});
|
||||
|
||||
var obj = Proxy.create({
|
||||
var obj = new Proxy({}, {
|
||||
get: function (receiver, name) {
|
||||
assertEq(name, Symbol.iterator);
|
||||
s += "I";
|
||||
|
@ -1,12 +1,10 @@
|
||||
Object.defineProperty(this, "x", { get: decodeURI, configurable: true })
|
||||
try {
|
||||
String(b = Proxy.createFunction(function() {
|
||||
return {
|
||||
get: function(r, z) {
|
||||
return x[z]
|
||||
}
|
||||
String(b = new Proxy(function() { }, {
|
||||
get: function(r, z) {
|
||||
return x[z]
|
||||
}
|
||||
}(), function() {}))
|
||||
}))
|
||||
} catch (e) {};
|
||||
var log = "";
|
||||
evaluate(`
|
||||
|
@ -1,6 +1,6 @@
|
||||
// |jit-test| error: ReferenceError
|
||||
o0 = TypeError.prototype.__proto__
|
||||
o1 = Proxy.create({})
|
||||
o1 = new Proxy({}, {})
|
||||
o13 = {}.__proto__
|
||||
var o15 = Object.prototype
|
||||
o31 = (new Uint32Array(100)).buffer
|
||||
|
@ -1,4 +1,4 @@
|
||||
var p = Proxy.create({
|
||||
var p = new Proxy({}, {
|
||||
has : function(id) {}
|
||||
});
|
||||
RegExp.prototype.__proto__ = p;
|
||||
|
@ -7,6 +7,6 @@ var handler = {
|
||||
|
||||
for (var i=0; i<10; i++) {
|
||||
var regex = /undefined/;
|
||||
regex.__proto__ = Proxy.createFunction(handler, function(){})
|
||||
regex.__proto__ = new Proxy(function() {}, handler)
|
||||
}
|
||||
|
||||
|
@ -2,13 +2,13 @@
|
||||
function f() {
|
||||
(e)
|
||||
}
|
||||
(x = Proxy.createFunction((function(x) {
|
||||
(x = new Proxy(Function, (function(x) {
|
||||
return {
|
||||
get: function(r, b) {
|
||||
return x[b]
|
||||
}
|
||||
}
|
||||
})(/x/), Function))
|
||||
})(/x/)))
|
||||
for (z = 0; z < 100; x.unwatch(), z++)
|
||||
for (e in [0]) {
|
||||
gczeal(2)
|
||||
|
@ -1,16 +0,0 @@
|
||||
// |jit-test| error: ReferenceError
|
||||
load(libdir + "immutable-prototype.js");
|
||||
|
||||
p = Proxy.create({
|
||||
has: function() {},
|
||||
set: function() {}
|
||||
});
|
||||
|
||||
if (globalPrototypeChainIsMutable())
|
||||
Object.prototype.__proto__ = p;
|
||||
|
||||
n = [];
|
||||
(function() {
|
||||
var a = [];
|
||||
if (b) t = a.s()
|
||||
})()
|
@ -10,10 +10,7 @@ function reportCompare (expected, actual, description) {
|
||||
}
|
||||
|
||||
reportCompare(true, "isGenerator" in Function, "Function.prototype.isGenerator present");
|
||||
var p = Proxy.create({
|
||||
has : function(id) {},
|
||||
set : function(obj, id, v, rec) {}
|
||||
});
|
||||
var p = new Proxy({}, {});
|
||||
function test() {
|
||||
TestCase.prototype.__proto__=null
|
||||
if (new TestCase)
|
||||
|
@ -3,11 +3,10 @@ var o0 = Function.prototype;
|
||||
o1 = {};
|
||||
var o4 = Error.prototype;
|
||||
o5 = new Int32Array(100);
|
||||
o6 = Proxy.create({
|
||||
o6 = new Proxy({}, {})
|
||||
o8 = new Proxy(function() { return {}; }, {
|
||||
get: function() { return 10; },
|
||||
});
|
||||
o8 = Proxy.createFunction({
|
||||
get: function() {return 10; },
|
||||
}, function(){ return {}; }, function(){ return {}; });
|
||||
o9 = {};
|
||||
var o10 = -500;
|
||||
var o12 = new Int32Array(100);
|
||||
|
@ -1,2 +0,0 @@
|
||||
var x = Proxy.create( {get:function(r,name){Proxy = 0;}} );
|
||||
try { x.watch('e', function(){}); } catch (e) {}
|
@ -1,12 +0,0 @@
|
||||
// Bug 1133294 - Object.getOwnPropertyDescriptor should never return an incomplete descriptor.
|
||||
|
||||
load(libdir + "asserts.js");
|
||||
|
||||
var p = Proxy.create({ getOwnPropertyDescriptor() { return {}; } });
|
||||
var desc = Object.getOwnPropertyDescriptor(p, "x");
|
||||
assertDeepEq(desc, {
|
||||
value: undefined,
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: false
|
||||
});
|
@ -1,27 +0,0 @@
|
||||
// BaseProxyHandler::set correctly defines a property on receiver if the
|
||||
// property being assigned doesn't exist anywhere on the proto chain.
|
||||
|
||||
var p = Proxy.create({
|
||||
getOwnPropertyDescriptor() { return undefined; },
|
||||
getPropertyDescriptor() { return undefined; },
|
||||
defineProperty() { throw "FAIL"; }
|
||||
});
|
||||
var q = new Proxy(p, {
|
||||
defineProperty(t, id, desc) {
|
||||
assertEq(t, p);
|
||||
assertEq(id, "x");
|
||||
assertEq(desc.configurable, true);
|
||||
assertEq(desc.enumerable, true);
|
||||
assertEq(desc.writable, true);
|
||||
assertEq(desc.value, 3);
|
||||
hits++;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
var hits = 0;
|
||||
|
||||
// This assignment eventually reaches ScriptedIndirectProxyHandler::set
|
||||
// with arguments (proxy=p, receiver=q). Test that it finishes by defining
|
||||
// a property on receiver, not on proxy.
|
||||
q.x = 3;
|
||||
assertEq(hits, 1);
|
Loading…
Reference in New Issue
Block a user