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