dom/bindings/test/test_defineProperty.html

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

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

mercurial