4 https://bugzilla.mozilla.org/show_bug.cgi?id=1107443
8 <title>Test for Bug
1107443</title>
9 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
10 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css"/>
11 <script type=
"application/javascript">
13 var {AppConstants} = SpecialPowers.Cu.import(
"resource://gre/modules/AppConstants.jsm", {});
16 * Test for Bug
1107443, modified when it was backed out in bug
1329323.
17 * This is now testing the _current_ behavior, not the desired one; expect
18 * failures in this test and needing to update it when bug
1329324 is
21 var retval = Object.defineProperty(window,
"nosuchprop",
22 { value:
5, configurable: false });
23 if (AppConstants.RELEASE_OR_BETA) {
25 "Should return null when 'failing' to define non-configurable property via Object.defineProperty.")
28 "Should return null when 'failing' to define non-configurable property via Object.defineProperty.")
30 var desc = Object.getOwnPropertyDescriptor(window,
"nosuchprop");
31 is(typeof(desc),
"object",
"Should have a property 'nosuchprop' now");
32 if (AppConstants.RELEASE_OR_BETA) {
33 todo_is(desc.configurable, true,
34 "Property 'nosuchprop' should be configurable");
36 is(desc.configurable, true,
37 "Property 'nosuchprop' should be configurable");
39 is(desc.writable, false,
"Property 'nosuchprop' should be readonly");
40 is(desc.value,
5,
"Property 'nosuchprop' should have the right value");
42 retval = Object.defineProperties(window, {
43 "firstProp": { value:
1 },
44 "secondProp": { value:
2, configurable: false },
45 "thirdProp": { value:
3 },
47 if (AppConstants.RELEASE_OR_BETA) {
49 "Should return null when 'failing' to define non-configurable property via Object.defineProperties.")
52 "Should return null when 'failing' to define non-configurable property via Object.defineProperties.")
54 // The properties should all be defined.
55 for (var [prop, val] of [[
"firstProp",
1], [
"secondProp",
2], [
"thirdProp",
3]]) {
56 desc = Object.getOwnPropertyDescriptor(window, prop);
57 is(typeof(desc),
"object", `Should have a property '${prop}' now`);
58 if (AppConstants.RELEASE_OR_BETA) {
59 todo_is(desc.configurable, true,
60 `Property '${prop}' should be configurable`);
62 is(desc.configurable, true,
63 `Property '${prop}' should be configurable`);
65 is(desc.writable, false, `Property '${prop}' should be readonly`);
66 is(desc.value, val, `Property '${prop}' should have the right value`);
69 retval = Object.defineProperty(window,
"nosuchprop2", { value:
6 });
71 "Should return object when succesfully defining 'nosuchprop2'");
72 desc = Object.getOwnPropertyDescriptor(window,
"nosuchprop2");
73 is(typeof(desc),
"object",
"Should have a property 'nosuchprop2' now");
74 if (AppConstants.RELEASE_OR_BETA) {
75 todo_is(desc.configurable, true,
76 "Property 'nosuchprop2' should be configurable");
78 is(desc.configurable, true,
79 "Property 'nosuchprop2' should be configurable");
81 is(desc.writable, false,
"Property 'nosuchprop2' should be readonly");
82 is(desc.value,
6,
"Property 'nosuchprop2' should have the right value");
84 retval = Object.defineProperty(window,
"nosuchprop3",
85 { value:
7, configurable: true });
87 "Should return object when succesfully defining 'nosuchprop3'");
88 desc = Object.getOwnPropertyDescriptor(window,
"nosuchprop3");
89 is(typeof(desc),
"object",
"Should have a property 'nosuchprop3' now");
90 is(desc.configurable, true,
91 "Property 'nosuchprop3' should be configurable");
92 is(desc.writable, false,
"Property 'nosuchprop3' should be readonly");
93 is(desc.value,
7,
"Property 'nosuchprop3' should have the right value");
95 retval = Reflect.defineProperty(window,
"nosuchprop4",
96 { value:
8, configurable: false });
97 if (AppConstants.RELEASE_OR_BETA) {
98 todo_is(retval, false,
99 "Should not be able to Reflect.defineProperty if non-configurable");
102 "Should not be able to Reflect.defineProperty if non-configurable");
104 desc = Object.getOwnPropertyDescriptor(window,
"nosuchprop4");
105 is(typeof(desc),
"object",
"Should have a property 'nosuchprop4' now");
106 if (AppConstants.RELEASE_OR_BETA) {
107 todo_is(desc.configurable, true,
108 "Property 'nosuchprop4' should be configurable");
110 is(desc.configurable, true,
111 "Property 'nosuchprop4' should be configurable");
113 is(desc.writable, false,
"Property 'nosuchprop4' should be readonly");
114 is(desc.value,
8,
"Property 'nosuchprop4' should have the right value");
116 retval = Reflect.defineProperty(window,
"nosuchprop5",
119 "Should be able to Reflect.defineProperty with default configurability");
120 desc = Object.getOwnPropertyDescriptor(window,
"nosuchprop5");
121 is(typeof(desc),
"object",
"Should have a property 'nosuchprop5' now");
122 if (AppConstants.RELEASE_OR_BETA) {
123 todo_is(desc.configurable, true,
124 "Property 'nosuchprop5' should be configurable");
126 is(desc.configurable, true,
127 "Property 'nosuchprop5' should be configurable");
129 is(desc.writable, false,
"Property 'nosuchprop5' should be readonly");
130 is(desc.value,
9,
"Property 'nosuchprop5' should have the right value");
132 retval = Reflect.defineProperty(window,
"nosuchprop6",
133 { value:
10, configurable: true });
135 "Should be able to Reflect.defineProperty if configurable");
136 desc = Object.getOwnPropertyDescriptor(window,
"nosuchprop6");
137 is(typeof(desc),
"object",
"Should have a property 'nosuchprop6' now");
138 is(desc.configurable, true,
"Property 'nosuchprop6' should be configurable");
139 is(desc.writable, false,
"Property 'nosuchprop6' should be readonly");
140 is(desc.value,
10,
"Property 'nosuchprop6' should have the right value");
144 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=1107443">Mozilla Bug
1107443</a>
146 <div id=
"content" style=
"display: none">