summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/language/expressions/class/private-static-method-brand-check-multiple-evaluations-of-class-function-ctor.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /js/src/tests/test262/language/expressions/class/private-static-method-brand-check-multiple-evaluations-of-class-function-ctor.js
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/language/expressions/class/private-static-method-brand-check-multiple-evaluations-of-class-function-ctor.js')
-rw-r--r--js/src/tests/test262/language/expressions/class/private-static-method-brand-check-multiple-evaluations-of-class-function-ctor.js54
1 files changed, 54 insertions, 0 deletions
diff --git a/js/src/tests/test262/language/expressions/class/private-static-method-brand-check-multiple-evaluations-of-class-function-ctor.js b/js/src/tests/test262/language/expressions/class/private-static-method-brand-check-multiple-evaluations-of-class-function-ctor.js
new file mode 100644
index 0000000000..04f4da476d
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/class/private-static-method-brand-check-multiple-evaluations-of-class-function-ctor.js
@@ -0,0 +1,54 @@
+// Copyright (C) 2019 Caio Lima (Igalia SL). All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: Every new evaluation of a class creates a different brand (private static methods)
+esid: sec-privatefieldget
+info: |
+ ClassTail : ClassHeritage { ClassBody }
+ ...
+ 19. Let F be constructorInfo.[[Closure]].
+ 20. If ClassHeritage_opt is present and protoParent is not null, then set F.[[ConstructorKind]] to "derived".
+ 21. Perform MakeConstructor(F, false, proto).
+ 22. Perform MakeClassConstructor(F).
+ ...
+ 33. If PrivateBoundIdentifiers of ClassBody contains a Private Name P such that P's [[Kind]] field is either "method" or "accessor" and P's [[Brand]] is F,
+ a. PrivateBrandAdd(F, F).
+ ...
+
+ PrivateBrandCheck(O, P)
+ 1. If O.[[PrivateBrands]] does not contain an entry e such that SameValue(e, P.[[Brand]]) is true,
+ a. Throw a TypeError exception.
+features: [class, class-static-methods-private]
+---*/
+
+let classStringExpression = `
+return class {
+ static #m() { return 'test262'; }
+
+ static access() {
+ return this.#m();
+ }
+}
+`;
+
+let createClass = function () {
+ let classFactoryFunction = new Function(classStringExpression);
+ return classFactoryFunction();
+};
+
+let C1 = createClass();
+let C2 = createClass();
+
+assert.sameValue(C1.access(), 'test262');
+assert.sameValue(C2.access(), 'test262');
+
+assert.throws(TypeError, function() {
+ C1.access.call(C2);
+}, 'invalid access of c1 private static method');
+
+assert.throws(TypeError, function() {
+ C2.access.call(C1);
+}, 'invalid access of c2 private static method');
+
+reportCompare(0, 0);