summaryrefslogtreecommitdiffstats
path: root/dom/base/test/test_window_define_nonconfigurable.html
diff options
context:
space:
mode:
Diffstat (limited to 'dom/base/test/test_window_define_nonconfigurable.html')
-rw-r--r--dom/base/test/test_window_define_nonconfigurable.html115
1 files changed, 115 insertions, 0 deletions
diff --git a/dom/base/test/test_window_define_nonconfigurable.html b/dom/base/test/test_window_define_nonconfigurable.html
new file mode 100644
index 0000000000..9d35c687f0
--- /dev/null
+++ b/dom/base/test/test_window_define_nonconfigurable.html
@@ -0,0 +1,115 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1107443
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 1107443</title>
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+ <script type="application/javascript">
+
+ var { AppConstants } = SpecialPowers.ChromeUtils.import(
+ "resource://gre/modules/AppConstants.jsm"
+ );
+
+ /**
+ * Test for Bug 1107443, modified when it was backed out in bug 1329323.
+ * This is now testing the _current_ behavior, not the desired one; expect
+ * failures in this test and needing to update it when bug 1329324 is
+ * fixed.
+ */
+ var retval = Object.defineProperty(window, "nosuchprop",
+ { value: 5, configurable: false });
+ todo_is(retval, null,
+ "Should return null when 'failing' to define non-configurable property via Object.defineProperty.")
+
+ var desc = Object.getOwnPropertyDescriptor(window, "nosuchprop");
+ is(typeof(desc), "object", "Should have a property 'nosuchprop' now");
+ todo_is(desc.configurable, true,
+ "Property 'nosuchprop' should be configurable");
+ is(desc.writable, false, "Property 'nosuchprop' should be readonly");
+ is(desc.value, 5, "Property 'nosuchprop' should have the right value");
+
+ retval = Object.defineProperties(window, {
+ "firstProp": { value: 1 },
+ "secondProp": { value: 2, configurable: false },
+ "thirdProp": { value: 3 },
+ });
+ todo_is(retval, null,
+ "Should return null when 'failing' to define non-configurable property via Object.defineProperties.")
+ // The properties should all be defined.
+ for (var [prop, val] of [["firstProp", 1], ["secondProp", 2], ["thirdProp", 3]]) {
+ desc = Object.getOwnPropertyDescriptor(window, prop);
+ is(typeof(desc), "object", `Should have a property '${prop}' now`);
+ todo_is(desc.configurable, true,
+ `Property '${prop}' should be configurable`);
+ is(desc.writable, false, `Property '${prop}' should be readonly`);
+ is(desc.value, val, `Property '${prop}' should have the right value`);
+ }
+
+ retval = Object.defineProperty(window, "nosuchprop2", { value: 6 });
+ is(retval, window,
+ "Should return object when succesfully defining 'nosuchprop2'");
+ desc = Object.getOwnPropertyDescriptor(window, "nosuchprop2");
+ is(typeof(desc), "object", "Should have a property 'nosuchprop2' now");
+ todo_is(desc.configurable, true,
+ "Property 'nosuchprop2' should be configurable");
+ is(desc.writable, false, "Property 'nosuchprop2' should be readonly");
+ is(desc.value, 6, "Property 'nosuchprop2' should have the right value");
+
+ retval = Object.defineProperty(window, "nosuchprop3",
+ { value: 7, configurable: true });
+ is(retval, window,
+ "Should return object when succesfully defining 'nosuchprop3'");
+ desc = Object.getOwnPropertyDescriptor(window, "nosuchprop3");
+ is(typeof(desc), "object", "Should have a property 'nosuchprop3' now");
+ is(desc.configurable, true,
+ "Property 'nosuchprop3' should be configurable");
+ is(desc.writable, false, "Property 'nosuchprop3' should be readonly");
+ is(desc.value, 7, "Property 'nosuchprop3' should have the right value");
+
+ retval = Reflect.defineProperty(window, "nosuchprop4",
+ { value: 8, configurable: false });
+ todo_is(retval, false,
+ "Should not be able to Reflect.defineProperty if non-configurable");
+ desc = Object.getOwnPropertyDescriptor(window, "nosuchprop4");
+ is(typeof(desc), "object", "Should have a property 'nosuchprop4' now");
+ todo_is(desc.configurable, true,
+ "Property 'nosuchprop4' should be configurable");
+ is(desc.writable, false, "Property 'nosuchprop4' should be readonly");
+ is(desc.value, 8, "Property 'nosuchprop4' should have the right value");
+
+ retval = Reflect.defineProperty(window, "nosuchprop5",
+ { value: 9 });
+ is(retval, true,
+ "Should be able to Reflect.defineProperty with default configurability");
+ desc = Object.getOwnPropertyDescriptor(window, "nosuchprop5");
+ is(typeof(desc), "object", "Should have a property 'nosuchprop5' now");
+ todo_is(desc.configurable, true,
+ "Property 'nosuchprop5' should be configurable");
+ is(desc.writable, false, "Property 'nosuchprop5' should be readonly");
+ is(desc.value, 9, "Property 'nosuchprop5' should have the right value");
+
+ retval = Reflect.defineProperty(window, "nosuchprop6",
+ { value: 10, configurable: true });
+ is(retval, true,
+ "Should be able to Reflect.defineProperty if configurable");
+ desc = Object.getOwnPropertyDescriptor(window, "nosuchprop6");
+ is(typeof(desc), "object", "Should have a property 'nosuchprop6' now");
+ is(desc.configurable, true, "Property 'nosuchprop6' should be configurable");
+ is(desc.writable, false, "Property 'nosuchprop6' should be readonly");
+ is(desc.value, 10, "Property 'nosuchprop6' should have the right value");
+ </script>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1107443">Mozilla Bug 1107443</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+</pre>
+</body>
+</html>