Debian Codegraph @

js/src/tests/test262/built-ins/Proxy/deleteProperty/trap-is-missing-target-is-proxy.js

raw
1 // Copyright (C) 2020 Alexey Shvayka. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 esid: sec-proxy-object-internal-methods-and-internal-slots-delete-p
6 description: >
7 If "deleteProperty" trap is null or undefined, [[Delete]] call is
8 properly forwarded to [[ProxyTarget]] (which is also a Proxy object).
9 info: |
10 [[Delete]] ( P )
11
12 [...]
13 5. Let target be O.[[ProxyTarget]].
14 6. Let trap be ? GetMethod(handler, "deleteProperty").
15 7. If trap is undefined, then
16 a. Return ? target.[[Delete]](P).
17 features: [Proxy, Reflect]
18 ---*/
19
20 var plainObject = {
21 get foo() {},
22 };
23
24 Object.defineProperty(plainObject, "bar", {
25 configurable: false,
26 });
27
28 var plainObjectTarget = new Proxy(plainObject, {});
29 var plainObjectProxy = new Proxy(plainObjectTarget, {});
30
31 assert(delete plainObjectProxy.foo);
32 assert(
33 !Object.prototype.hasOwnProperty.call(plainObject, "foo"),
34 "'foo' property was deleted from original object"
35 );
36
37 assert(!Reflect.deleteProperty(plainObjectProxy, "bar"));
38 assert(
39 Object.prototype.hasOwnProperty.call(plainObject, "bar"),
40 "'bar' property was not deleted from original object"
41 );
42
43 var func = function() {};
44 var funcTarget = new Proxy(func, {});
45 var funcProxy = new Proxy(funcTarget, {});
46
47 assert(delete funcProxy.length);
48 assert(
49 !Object.prototype.hasOwnProperty.call(func, "length"),
50 "'length' property was deleted from original object"
51 );
52
53 assert.throws(TypeError, function() {
54 "use strict";
55 delete funcProxy.prototype;
56 });
57
58 reportCompare(0, 0);