mirror of
https://github.com/tc39/test262.git
synced 2025-05-03 14:30:27 +02:00
* [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)
71 lines
2.1 KiB
JavaScript
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);
|
|
}
|
|
}
|
|
})();
|