js/src/tests/ecma_5/eval/exhaustive-global-strictcaller-indirect-strictcode.js

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 // Any copyright is dedicated to the Public Domain.
michael@0 2 // http://creativecommons.org/licenses/publicdomain/
michael@0 3 "use strict";
michael@0 4
michael@0 5 //-----------------------------------------------------------------------------
michael@0 6 var BUGNUMBER = 514568;
michael@0 7 var summary = "eval in all its myriad flavors";
michael@0 8
michael@0 9 print(BUGNUMBER + ": " + summary);
michael@0 10
michael@0 11 /**************
michael@0 12 * BEGIN TEST *
michael@0 13 **************/
michael@0 14
michael@0 15 var x = 17;
michael@0 16
michael@0 17 var ev = eval;
michael@0 18
michael@0 19 var xcode =
michael@0 20 "'use strict';" +
michael@0 21 "var x = 4;" +
michael@0 22 "function actX(action)" +
michael@0 23 "{" +
michael@0 24 " switch (action)" +
michael@0 25 " {" +
michael@0 26 " case 'get':" +
michael@0 27 " return x;" +
michael@0 28 " case 'set1':" +
michael@0 29 " x = 9;" +
michael@0 30 " return;" +
michael@0 31 " case 'set2':" +
michael@0 32 " x = 23;" +
michael@0 33 " return;" +
michael@0 34 " case 'delete':" +
michael@0 35 " try { return eval('delete x'); }" +
michael@0 36 " catch (e) { return e.name; }" +
michael@0 37 " }" +
michael@0 38 "}" +
michael@0 39 "actX;";
michael@0 40
michael@0 41 var local0 = x;
michael@0 42
michael@0 43 var f = ev(xcode);
michael@0 44
michael@0 45 var inner1 = f("get");
michael@0 46 var local1 = x;
michael@0 47
michael@0 48 x = 7;
michael@0 49 var inner2 = f("get");
michael@0 50 var local2 = x;
michael@0 51
michael@0 52 f("set1");
michael@0 53 var inner3 = f("get");
michael@0 54 var local3 = x;
michael@0 55
michael@0 56 var del = f("delete");
michael@0 57 var inner4 = f("get");
michael@0 58 var local4 = x;
michael@0 59
michael@0 60 f("set2");
michael@0 61 var inner5 = f("get");
michael@0 62 var local5 = x;
michael@0 63
michael@0 64 var resultsX =
michael@0 65 {
michael@0 66 local0: local0,
michael@0 67 inner1: inner1, local1: local1,
michael@0 68 inner2: inner2, local2: local2,
michael@0 69 inner3: inner3, local3: local3,
michael@0 70 del: del,
michael@0 71 inner4: inner4, local4: local4,
michael@0 72 inner5: inner5, local5: local5,
michael@0 73 };
michael@0 74
michael@0 75 assertEq(resultsX.local0, 17);
michael@0 76
michael@0 77 assertEq(resultsX.inner1, 4);
michael@0 78 assertEq(resultsX.local1, 17);
michael@0 79
michael@0 80 assertEq(resultsX.inner2, 4);
michael@0 81 assertEq(resultsX.local2, 7);
michael@0 82
michael@0 83 assertEq(resultsX.inner3, 9);
michael@0 84 assertEq(resultsX.local3, 7);
michael@0 85
michael@0 86 assertEq(resultsX.del, "SyntaxError");
michael@0 87
michael@0 88 assertEq(resultsX.inner4, 9);
michael@0 89 assertEq(resultsX.local4, 7);
michael@0 90
michael@0 91 assertEq(resultsX.inner5, 23);
michael@0 92 assertEq(resultsX.local5, 7);
michael@0 93
michael@0 94
michael@0 95 var ycode =
michael@0 96 "'use strict';" +
michael@0 97 "var y = 5;" +
michael@0 98 "function actY(action)" +
michael@0 99 "{" +
michael@0 100 " switch (action)" +
michael@0 101 " {" +
michael@0 102 " case 'get':" +
michael@0 103 " return y;" +
michael@0 104 " case 'set1':" +
michael@0 105 " y = 2;" +
michael@0 106 " return;" +
michael@0 107 " case 'set2':" +
michael@0 108 " y = 71;" +
michael@0 109 " return;" +
michael@0 110 " case 'delete':" +
michael@0 111 " try { return eval('delete y'); }" +
michael@0 112 " catch (e) { return e.name; }" +
michael@0 113 " }" +
michael@0 114 "}" +
michael@0 115 "actY;";
michael@0 116
michael@0 117 try { var local0 = y; } catch (e) { local0 = e.name; }
michael@0 118
michael@0 119 var f = ev(ycode);
michael@0 120
michael@0 121 var inner1 = f("get");
michael@0 122 try { var local1 = y; } catch (e) { local1 = e.name; }
michael@0 123
michael@0 124 try { y = 8; } catch (e) { assertEq(e.name, "ReferenceError"); }
michael@0 125 var inner2 = f("get");
michael@0 126 try { var local2 = y; } catch (e) { local2 = e.name; }
michael@0 127
michael@0 128 f("set1");
michael@0 129 var inner3 = f("get");
michael@0 130 try { var local3 = y; } catch (e) { local3 = e.name; }
michael@0 131
michael@0 132 var del = f("delete");
michael@0 133 try { var inner4 = f("get"); } catch (e) { inner4 = e.name; }
michael@0 134 try { var local4 = y; } catch (e) { local4 = e.name; }
michael@0 135
michael@0 136 f("set2");
michael@0 137 try { var inner5 = f("get"); } catch (e) { inner5 = e.name; }
michael@0 138 try { var local5 = y; } catch (e) { local5 = e.name; }
michael@0 139
michael@0 140 var resultsY =
michael@0 141 {
michael@0 142 local0: local0,
michael@0 143 inner1: inner1, local1: local1,
michael@0 144 inner2: inner2, local2: local2,
michael@0 145 inner3: inner3, local3: local3,
michael@0 146 del: del,
michael@0 147 inner4: inner4, local4: local4,
michael@0 148 inner5: inner5, local5: local5,
michael@0 149 };
michael@0 150
michael@0 151 assertEq(resultsY.local0, "ReferenceError");
michael@0 152
michael@0 153 assertEq(resultsY.inner1, 5);
michael@0 154 assertEq(resultsY.local1, "ReferenceError");
michael@0 155
michael@0 156 assertEq(resultsY.inner2, 5);
michael@0 157 assertEq(resultsY.local2, "ReferenceError");
michael@0 158
michael@0 159 assertEq(resultsY.inner3, 2);
michael@0 160 assertEq(resultsY.local3, "ReferenceError");
michael@0 161
michael@0 162 assertEq(resultsY.del, "SyntaxError");
michael@0 163
michael@0 164 assertEq(resultsY.inner4, 2);
michael@0 165 assertEq(resultsY.local4, "ReferenceError");
michael@0 166
michael@0 167 assertEq(resultsY.inner5, 71);
michael@0 168 assertEq(resultsY.local5, "ReferenceError");
michael@0 169
michael@0 170 /******************************************************************************/
michael@0 171
michael@0 172 if (typeof reportCompare === "function")
michael@0 173 reportCompare(true, true);
michael@0 174
michael@0 175 print("Tests complete!");

mercurial