js/src/tests/ecma_5/eval/exhaustive-global-strictcaller-direct-normalcode.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 "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 = eval(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 "var y = 5;" +
michael@0 96 "function actY(action)" +
michael@0 97 "{" +
michael@0 98 " switch (action)" +
michael@0 99 " {" +
michael@0 100 " case 'get':" +
michael@0 101 " return y;" +
michael@0 102 " case 'set1':" +
michael@0 103 " y = 2;" +
michael@0 104 " return;" +
michael@0 105 " case 'set2':" +
michael@0 106 " y = 71;" +
michael@0 107 " return;" +
michael@0 108 " case 'delete':" +
michael@0 109 " try { return eval('delete y'); }" +
michael@0 110 " catch (e) { return e.name; }" +
michael@0 111 " }" +
michael@0 112 "}" +
michael@0 113 "actY;";
michael@0 114
michael@0 115 try { var local0 = y; } catch (e) { local0 = e.name; }
michael@0 116
michael@0 117 var f = eval(ycode);
michael@0 118
michael@0 119 var inner1 = f("get");
michael@0 120 try { var local1 = y; } catch (e) { local1 = e.name; }
michael@0 121
michael@0 122 try { y = 8; } catch (e) { assertEq(e.name, "ReferenceError"); }
michael@0 123 var inner2 = f("get");
michael@0 124 try { var local2 = y; } catch (e) { local2 = e.name; }
michael@0 125
michael@0 126 f("set1");
michael@0 127 var inner3 = f("get");
michael@0 128 try { var local3 = y; } catch (e) { local3 = e.name; }
michael@0 129
michael@0 130 var del = f("delete");
michael@0 131 try { var inner4 = f("get"); } catch (e) { inner4 = e.name; }
michael@0 132 try { var local4 = y; } catch (e) { local4 = e.name; }
michael@0 133
michael@0 134 f("set2");
michael@0 135 try { var inner5 = f("get"); } catch (e) { inner5 = e.name; }
michael@0 136 try { var local5 = y; } catch (e) { local5 = e.name; }
michael@0 137
michael@0 138 var resultsY =
michael@0 139 {
michael@0 140 local0: local0,
michael@0 141 inner1: inner1, local1: local1,
michael@0 142 inner2: inner2, local2: local2,
michael@0 143 inner3: inner3, local3: local3,
michael@0 144 del: del,
michael@0 145 inner4: inner4, local4: local4,
michael@0 146 inner5: inner5, local5: local5,
michael@0 147 };
michael@0 148
michael@0 149 assertEq(resultsY.local0, "ReferenceError");
michael@0 150
michael@0 151 assertEq(resultsY.inner1, 5);
michael@0 152 assertEq(resultsY.local1, "ReferenceError");
michael@0 153
michael@0 154 assertEq(resultsY.inner2, 5);
michael@0 155 assertEq(resultsY.local2, "ReferenceError");
michael@0 156
michael@0 157 assertEq(resultsY.inner3, 2);
michael@0 158 assertEq(resultsY.local3, "ReferenceError");
michael@0 159
michael@0 160 assertEq(resultsY.del, "SyntaxError");
michael@0 161
michael@0 162 assertEq(resultsY.inner4, 2);
michael@0 163 assertEq(resultsY.local4, "ReferenceError");
michael@0 164
michael@0 165 assertEq(resultsY.inner5, 71);
michael@0 166 assertEq(resultsY.local5, "ReferenceError");
michael@0 167
michael@0 168 /******************************************************************************/
michael@0 169
michael@0 170 if (typeof reportCompare === "function")
michael@0 171 reportCompare(true, true);
michael@0 172
michael@0 173 print("Tests complete!");

mercurial