test262-automation e9a5a7f918 [javascriptcore-test262-automation] changes from git@github.com:WebKit/webkit.git at sha 949e26452cfa153a7f4afe593da97e2fe9e1b706 on Tue Jul 03 2018 14:35:15 GMT-0400 (Eastern Daylight Time) (#1620)
* [javascriptcore-test262-automation] changes from git@github.com:WebKit/webkit.git at sha 949e26452cfa153a7f4afe593da97e2fe9e1b706 on Tue Jul 03 2018 14:35:15 GMT-0400 (Eastern Daylight Time)
2018-07-03 15:59:58 -04:00

62 lines
1.4 KiB
JavaScript

function assert(b) {
if (!b)
throw new Error("Bad assertion.")
}
function test(f) {
for (let i = 0; i < 500; i++)
f();
}
test(function() {
let proxy = new Proxy([], {});
assert(Array.isArray(proxy));
});
test(function() {
let {proxy, revoke} = Proxy.revocable([], {});
assert(Array.isArray(proxy));
revoke();
let threw = false;
try {
Array.isArray(proxy);
} catch(e) {
threw = true;
assert(e.toString() === "TypeError: Array.isArray cannot be called on a Proxy that has been revoked");
}
assert(threw);
});
test(function() {
let proxyChain = new Proxy([], {});
for (let i = 0; i < 400; i++)
proxyChain = new Proxy(proxyChain, {});
assert(Array.isArray(proxyChain));
});
test(function() {
let proxyChain = new Proxy([], {});
let revoke = null;
for (let i = 0; i < 400; i++) {
if (i !== 250) {
proxyChain = new Proxy(proxyChain, {});
} else {
let result = Proxy.revocable(proxyChain, {});
proxyChain = result.proxy;
revoke = result.revoke;
}
}
assert(Array.isArray(proxyChain));
revoke();
let threw = false;
try {
Array.isArray(proxyChain);
} catch(e) {
threw = true;
assert(e.toString() === "TypeError: Array.isArray cannot be called on a Proxy that has been revoked");
}
assert(threw);
});