Debian Codegraph @

js/src/tests/test262/language/statements/class/elements/public-class-field-initialization-is-visible-to-proxy.js

raw
1 // Copyright (C) 2019 Caio Lima. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 description: Public class field initialization calls [[DefineOwnProperty]] and can be observed by Proxies
6 esid: sec-define-field
7 info: |
8 DefineField(receiver, fieldRecord)
9 ...
10 8. If fieldName is a Private Name,
11 a. Perform ? PrivateFieldAdd(fieldName, receiver, initValue).
12 9. Else,
13 a. Assert: IsPropertyKey(fieldName) is true.
14 b. Perform ? CreateDataPropertyOrThrow(receiver, fieldName, initValue).
15 10. Return.
16 features: [class, class-fields-public]
17 ---*/
18
19 function ProxyBase() {
20 return new Proxy(this, {
21 defineProperty: function (target, key, descriptor) {
22 throw new Test262Error();
23 }
24 });
25 }
26
27 class Base extends ProxyBase {
28 f = "Test262";
29 }
30
31 assert.throws(Test262Error, () => { new Base(); });
32
33 reportCompare(0, 0);