diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /js/src/tests/test262/language/expressions/class/private-static-setter-multiple-evaluations-of-class-realm.js | |
parent | Initial commit. (diff) | |
download | firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/language/expressions/class/private-static-setter-multiple-evaluations-of-class-realm.js')
-rw-r--r-- | js/src/tests/test262/language/expressions/class/private-static-setter-multiple-evaluations-of-class-realm.js | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/js/src/tests/test262/language/expressions/class/private-static-setter-multiple-evaluations-of-class-realm.js b/js/src/tests/test262/language/expressions/class/private-static-setter-multiple-evaluations-of-class-realm.js new file mode 100644 index 0000000000..b7999a61f6 --- /dev/null +++ b/js/src/tests/test262/language/expressions/class/private-static-setter-multiple-evaluations-of-class-realm.js @@ -0,0 +1,64 @@ +// |reftest| shell-option(--enable-private-methods) skip-if(!xulRuntime.shell) -- requires shell-options +// 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 Private Name (private static setter) +esid: sec-runtime-semantics-evaluate-name +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, cross-realm] +flags: [noStrict] +---*/ + +let global1 = $262.createRealm().global; +let global2 = $262.createRealm().global; +let eval1 = global1.eval; +let eval2 = global2.eval; + +let classStringExpression = `( +class { + static set #m(v) { + this._v = v; + } + + static access() { + this.#m = 'test262'; + } +} +)`; + +let evalClass = function (_eval) { + return _eval(classStringExpression); +}; + +let C1 = evalClass(eval1); +let C2 = evalClass(eval2); + +C1.access(); +assert.sameValue(C1._v, 'test262'); +C2.access(); +assert.sameValue(C2._v, 'test262'); + +assert.throws(global1.TypeError, function() { + C1.access.call(C2); +}, 'invalid access of C1 private static setter'); + +assert.throws(global2.TypeError, function() { + C2.access.call(C1); +}, 'invalid access of C2 private static setter'); + +reportCompare(0, 0); |