test262/implementation-contributed/javascriptcore/stress/proxy-with-unbalanced-getter-setter.js
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

71 lines
2.1 KiB
JavaScript

function assert(b) {
if (!b)
throw new Error("Bad assertion");
}
// Setting the getter only.
(function () {
let target = {};
let called = false;
let handler = {
defineProperty: function(theTarget, propName, descriptor) {
called = true;
return Reflect.defineProperty(theTarget, propName, descriptor);
}
};
let proxy = new Proxy(target, handler);
for (let i = 0; i < 500; i++) {
let result = Reflect.defineProperty(proxy, "x", {
enumerable: true,
configurable: true,
get: function(){},
});
assert(result);
assert(called);
called = false;
for (let obj of [target, proxy]) {
let pDesc = Object.getOwnPropertyDescriptor(obj, "x");
assert(typeof pDesc.get === "function");
assert(typeof pDesc.set === "undefined");
assert(pDesc.get.toString() === (function(){}).toString());
assert(pDesc.configurable === true);
assert(pDesc.enumerable === true);
}
}
})();
// Setting the setter only.
(function () {
let target = {};
let called = false;
let handler = {
defineProperty: function(theTarget, propName, descriptor) {
called = true;
return Reflect.defineProperty(theTarget, propName, descriptor);
}
};
let proxy = new Proxy(target, handler);
for (let i = 0; i < 500; i++) {
let result = Reflect.defineProperty(proxy, "x", {
enumerable: true,
configurable: true,
set: function(x){},
});
assert(result);
assert(called);
called = false;
for (let obj of [target, proxy]) {
let pDesc = Object.getOwnPropertyDescriptor(obj, "x");
assert(typeof pDesc.get === "undefined");
assert(typeof pDesc.set === "function");
assert(pDesc.set.toString() === (function(x){}).toString());
assert(pDesc.configurable === true);
assert(pDesc.enumerable === true);
}
}
})();