Debian Codegraph @

js/src/tests/test262/built-ins/Proxy/defineProperty/targetdesc-not-configurable-writable-desc-not-writable.js

raw
1 // Copyright (C) 2019 Aleksey Shvayka. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3 /*---
4 esid: sec-proxy-object-internal-methods-and-internal-slots-defineownproperty-p-desc
5 description: >
6 Throw a TypeError exception if trap result is true, targetDesc is not configurable
7 and writable, while Desc is not writable.
8 info: |
9 [[DefineOwnProperty]] (P, Desc)
10
11 ...
12 16. Else targetDesc is not undefined,
13 ...
14 c. If IsDataDescriptor(targetDesc) is true, targetDesc.[[Configurable]] is
15 false, and targetDesc.[[Writable]] is true, then
16 i. If Desc has a [[Writable]] field and Desc.[[Writable]] is
17 false, throw a TypeError exception.
18 ...
19 features: [Proxy, Reflect, proxy-missing-checks]
20 ---*/
21
22 var trapCalls = 0;
23 var p = new Proxy({}, {
24 defineProperty: function(t, prop, desc) {
25 Object.defineProperty(t, prop, {
26 configurable: false,
27 writable: true,
28 });
29
30 trapCalls++;
31 return true;
32 },
33 });
34
35 assert.throws(TypeError, function() {
36 Reflect.defineProperty(p, "prop", {
37 writable: false,
38 });
39 });
40 assert.sameValue(trapCalls, 1);
41
42 reportCompare(0, 0);