Bumping manifests a=b2g-bump
[gecko.git] / dom / bindings / test / test_defineProperty.html
blobf8f5f6283edbaad7e1541d8a991aa23c89b55d13
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=910220
5 -->
6 <head>
7 <meta charset="utf-8">
8 <title>Test for Bug 910220</title>
9 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
11 </head>
12 <body>
13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=910220">Mozilla Bug 910220</a>
14 <p id="display"></p>
15 <div id="content" style="display: none">
16 <form name="x"></form>
17 </div>
18 <pre id="test">
19 </pre>
20 <script type="application/javascript">
22 /** Test for Bug 910220 **/
24 function getX() {
25 return "x";
28 function namedSetStrict(obj) {
29 "use strict";
30 var threw;
31 try {
32 obj.x = 5;
33 threw = false;
34 } catch (e) {
35 threw = true;
37 ok(threw,
38 "Should throw in strict mode when setting named property on " + obj);
40 try {
41 obj[getX()] = 5;
42 threw = false;
43 } catch (e) {
44 threw = true;
46 ok(threw,
47 "Should throw in strict mode when setting named property via SETELEM on " + obj);
49 try {
50 Object.defineProperty(obj, "x", { value: 17 });
51 threw = false;
52 } catch (e) {
53 threw = true;
55 ok(threw,
56 "Should throw in strict mode when defining named property on " + obj);
58 function namedSetNonStrict(obj) {
59 var threw;
60 try {
61 obj.x = 5;
62 threw = false;
63 } catch (e) {
64 threw = true;
66 ok(!threw,
67 "Should not throw in non-strict mode when setting named property on " + obj);
69 try {
70 obj[getX()] = 5;
71 threw = false;
72 } catch (e) {
73 threw = true;
75 ok(!threw,
76 "Should not throw in non-strict mode when setting named property via SETELEM on" + obj);
78 try {
79 Object.defineProperty(obj, "x", { value: 17 });
80 threw = false;
81 } catch (e) {
82 threw = true;
84 ok(threw,
85 "Should throw in non-strict mode when defining named property on " + obj);
87 for (var obj of [ document, document.forms ]) {
88 namedSetStrict(obj);
89 namedSetNonStrict(obj);
92 function indexedSetStrict(obj) {
93 "use strict";
94 var threw;
95 try {
96 obj[0] = 5;
97 threw = false;
98 } catch (e) {
99 threw = true;
101 ok(threw,
102 "Should throw in strict mode when setting indexed property on " + obj);
104 try {
105 obj[1000] = 5;
106 threw = false;
107 } catch (e) {
108 threw = true;
110 ok(threw,
111 "Should throw in strict mode when setting out of bounds indexed property on " + obj);
113 try {
114 Object.defineProperty(obj, "0", { value: 17 });
115 threw = false;
116 } catch (e) {
117 threw = true;
119 ok(threw,
120 "Should throw in strict mode when defining indexed property on " + obj);
122 function indexedSetNonStrict(obj) {
123 var threw;
124 try {
125 obj[0] = 5;
126 threw = false;
127 } catch (e) {
128 threw = true;
130 ok(!threw,
131 "Should not throw in non-strict mode when setting indexed property on " + obj);
133 try {
134 obj[1000] = 5;
135 threw = false;
136 } catch (e) {
137 threw = true;
139 ok(!threw,
140 "Should not throw in non-strict mode when setting out of bounds indexed property on " + obj);
142 try {
143 Object.defineProperty(obj, "0", { value: 17 });
144 threw = false;
145 } catch (e) {
146 threw = true;
148 ok(threw,
149 "Should throw in non-strict mode when defining indexed property on " + obj);
151 for (var obj of [ document.forms, document.childNodes ]) {
152 indexedSetStrict(obj);
153 indexedSetNonStrict(obj);
155 </script>
156 </body>
157 </html>