summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/language/statements/class/elements/private-field-is-visible-in-computed-properties.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/test262/language/statements/class/elements/private-field-is-visible-in-computed-properties.js
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/language/statements/class/elements/private-field-is-visible-in-computed-properties.js')
-rw-r--r--js/src/tests/test262/language/statements/class/elements/private-field-is-visible-in-computed-properties.js51
1 files changed, 51 insertions, 0 deletions
diff --git a/js/src/tests/test262/language/statements/class/elements/private-field-is-visible-in-computed-properties.js b/js/src/tests/test262/language/statements/class/elements/private-field-is-visible-in-computed-properties.js
new file mode 100644
index 0000000000..cb2bb60987
--- /dev/null
+++ b/js/src/tests/test262/language/statements/class/elements/private-field-is-visible-in-computed-properties.js
@@ -0,0 +1,51 @@
+// Copyright (C) 2019 Caio Lima (Igalia SL). All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: PrivateName of a class is visible in its ComputetProperty scope
+esid: prod-ClassTail
+info: |
+ ClassTail : ClassHeritage { ClassBody }
+ 1. Let lex be the LexicalEnvironment of the running execution context.
+ 2. Let classScope be NewDeclarativeEnvironment(lex).
+ 3. Let classScopeEnvRec be classScope's EnvironmentRecord.
+ ...
+ 8. If ClassBodyopt is present, then
+ a. For each element dn of the PrivateBoundIdentifiers of ClassBodyopt,
+ i. Perform classPrivateEnvRec.CreateImmutableBinding(dn, true).
+ ii. Let privateName be NewPrivateName(dn).
+ iii. Perform ! classPrivateEnvRec.InitializeBinding(dn, dn).
+ ...
+ 15. Set the running execution context's LexicalEnvironment to classScope.
+ 16. Set the running execution context's PrivateEnvironment to classPrivateEnvironment.
+ ...
+ 27. For each ClassElement e in order from elements
+ a. If IsStatic of e is false, then
+ i. Let field be the result of ClassElementEvaluation for e with arguments proto and false.
+ ...
+
+ GetValue ( V )
+ ...
+ 5. If IsPropertyReference(V), then
+ ...
+ b. If IsPrivateReference(V), then
+ i. Return ? PrivateFieldGet(GetReferencedName(V), base).
+
+ PrivateFieldGet ( P, O )
+ ...
+ 4. If entry is empty, throw a TypeError exception.
+ ...
+
+features: [class-fields-private, class-fields-public, class]
+---*/
+
+const self = this;
+assert.throws(TypeError, function() {
+ class C {
+ [self.#f] = 'Test262';
+ #f = 'foo';
+ }
+}, 'access to a not defined private field in object should throw a TypeError');
+
+
+reportCompare(0, 0);