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/jit-test/tests/class/superPropMegamorphic.js | |
parent | Initial commit. (diff) | |
download | firefox-upstream.tar.xz firefox-upstream.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/jit-test/tests/class/superPropMegamorphic.js')
-rw-r--r-- | js/src/jit-test/tests/class/superPropMegamorphic.js | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/class/superPropMegamorphic.js b/js/src/jit-test/tests/class/superPropMegamorphic.js new file mode 100644 index 0000000000..489f6ececb --- /dev/null +++ b/js/src/jit-test/tests/class/superPropMegamorphic.js @@ -0,0 +1,42 @@ +// Test GETPROP_SUPER with megamorphic variation +const NCLASS = 20; + +var g_prop = "prop"; +var g_THIS = "THIS"; + +// Define array of base classes with a data property and a getter property. +let C = []; +for (let i = 0; i < NCLASS; ++i) { + let klass = class { + get THIS() { return this; } + }; + klass.prototype.prop = i; + + C.push(klass); +} + +// Derive class using super property access +class D extends C[0] { + get prop() { return super.prop; } + get elem() { return super[g_prop]; } + + get prop_this() { return super.THIS; } + get elem_this() { return super[g_THIS]; } +} + +let d = new D(); + +for (var j = 0; j < 4; ++j) { + for (var i = 0; i < 15; ++i) { + // Change base class by overriding [[HomeObject]].[[Prototype]] + Object.setPrototypeOf(D.prototype, C[j].prototype); + + // Check we get property of correct class + assertEq(d.prop, j); + assertEq(d.elem, j); + + // Check super getter gets |this| of object not base class + assertEq(d.prop_this, d); + assertEq(d.elem_this, d); + } +} |