summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/regress/regress-591846.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/non262/regress/regress-591846.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 '')
-rw-r--r--js/src/tests/non262/regress/regress-591846.js64
1 files changed, 64 insertions, 0 deletions
diff --git a/js/src/tests/non262/regress/regress-591846.js b/js/src/tests/non262/regress/regress-591846.js
new file mode 100644
index 0000000000..68b1feca3c
--- /dev/null
+++ b/js/src/tests/non262/regress/regress-591846.js
@@ -0,0 +1,64 @@
+/*
+ * Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/licenses/publicdomain/
+ */
+
+function check(obj, name, value, readonly) {
+ // Start with a non-configurable, writable data property implemented via
+ // js::PropertyOp getter and setter.
+ var pd = Object.getOwnPropertyDescriptor(obj, name);
+
+ assertEq(pd.configurable, false, "non-configurable " + name);
+ assertEq(pd.writable, !readonly, "writable " + name);
+
+ try {
+ // Do not allow a transition from js::PropertyOp to writable js::Value
+ // data property.
+ Object.defineProperty(obj, name, {writable: true});
+ assertEq(0, 1);
+ } catch (e) {
+ assertEq('' + e, "TypeError: can't redefine non-configurable property '" + name + "'");
+ }
+
+ if (!readonly) {
+ try {
+ // Do not allow the property denoted by name to become a true data
+ // property via a descriptor that preserves the native property's
+ // writable attribute.
+ Object.defineProperty(obj, name, {value: value});
+ assertEq(0, 1);
+ } catch (e) {
+ assertEq('' + e, "TypeError: can't redefine non-configurable property '" + name + "'");
+ }
+ }
+
+ try {
+ // Do not allow the property to be frozen at some bogus value.
+ Object.defineProperty(obj, name, {value: "bogus", writable: false});
+ assertEq(0, 1);
+ } catch (e) {
+ assertEq('' + e, "TypeError: can't redefine non-configurable property '" + name + "'");
+ }
+
+ // Now make name non-writable.
+ Object.defineProperty(obj, name, {writable: false})
+
+ // Assert that the right getter result "stuck".
+ assertEq(obj[name], value);
+
+ // Test that it is operationally non-writable now.
+ obj[name] = "eek!";
+ assertEq(obj[name], value);
+}
+
+// Reset RegExp.leftContext to the empty string.
+/x/.test('x');
+
+var d = Object.getOwnPropertyDescriptor(RegExp, "leftContext");
+assertEq(d.set, undefined);
+assertEq(typeof d.get, "function");
+assertEq(d.enumerable, true);
+assertEq(d.configurable, false);
+assertEq(d.get.call(RegExp), "");
+
+reportCompare(0, 0, "ok");