Debian Codegraph @

js/src/tests/test262/built-ins/Proxy/deleteProperty/targetdesc-is-configurable-target-is-not-extensible.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-delete-p
5 description: >
6 Throw a TypeError exception if trap result is true, targetDesc is configurable,
7 and target is not extensible.
8 info: |
9 [[Delete]] (P)
10
11 ...
12 13. Let extensibleTarget be ? IsExtensible(target).
13 14. If extensibleTarget is false, throw a TypeError exception.
14 ...
15 features: [Proxy, Reflect, proxy-missing-checks]
16 ---*/
17
18 var trapCalls = 0;
19 var p = new Proxy({prop: 1}, {
20 deleteProperty: function(t, prop) {
21 Object.preventExtensions(t);
22 trapCalls++;
23 return true;
24 },
25 });
26
27 assert.throws(TypeError, function() {
28 Reflect.deleteProperty(p, "prop");
29 });
30 assert.sameValue(trapCalls, 1);
31
32 assert(Reflect.deleteProperty(p, "nonExistent"));
33 assert.sameValue(trapCalls, 2);
34
35 reportCompare(0, 0);