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 | // |jit-test| slow; |
michael@0 | 2 | |
michael@0 | 3 | // Binary: cache/js-dbg-32-be41973873db-linux |
michael@0 | 4 | // Flags: --ion-eager |
michael@0 | 5 | // |
michael@0 | 6 | function MersenneTwister19937() { |
michael@0 | 7 | N = 624; |
michael@0 | 8 | var M = 397; |
michael@0 | 9 | MATRIX_A = 567483615; |
michael@0 | 10 | UPPER_MASK = 2147483648; |
michael@0 | 11 | var LOWER_MASK = 767; |
michael@0 | 12 | mt = Array(); |
michael@0 | 13 | function unsigned32(n1) { |
michael@0 | 14 | return n1 < 0 ? (n1 ^ UPPER_MASK) + UPPER_MASK : n1; |
michael@0 | 15 | } |
michael@0 | 16 | function addition32(n1, n2) { |
michael@0 | 17 | return unsigned32(n1 + n2 & 4294967295); |
michael@0 | 18 | } |
michael@0 | 19 | function multiplication32(n1, n2) { |
michael@0 | 20 | sum = 0; |
michael@0 | 21 | for (i = 0; i < 32; ++i) { |
michael@0 | 22 | if (n1 >> i & 1) { |
michael@0 | 23 | sum = addition32(sum, unsigned32(n2 << i)); |
michael@0 | 24 | } |
michael@0 | 25 | } |
michael@0 | 26 | return sum; |
michael@0 | 27 | } |
michael@0 | 28 | this.init_genrand = function() { |
michael@0 | 29 | for (mti = 1; mti < N; mti++) { |
michael@0 | 30 | mt[mti] = addition32(multiplication32(181433253, unsigned32(mt[mti - 1] ^ mt[mti - 1] >>> 30)), mti); |
michael@0 | 31 | } |
michael@0 | 32 | }; |
michael@0 | 33 | this.genrand_int32 = function() { |
michael@0 | 34 | mag01 = Array(0, MATRIX_A); |
michael@0 | 35 | if (mti > N) { |
michael@0 | 36 | for (kk = 0; kk < N - M; kk++) { |
michael@0 | 37 | y = unsigned32(mt[kk] & UPPER_MASK | mt[kk + 1] & LOWER_MASK); |
michael@0 | 38 | } |
michael@0 | 39 | for (; kk < N; kk++) { |
michael@0 | 40 | mt[kk] = unsigned32(mt[kk + (M - N)] ^ y >>> 1 ^ mag01[y & 1]); |
michael@0 | 41 | } |
michael@0 | 42 | mti = 0; |
michael@0 | 43 | } |
michael@0 | 44 | y = mt[mti++]; |
michael@0 | 45 | return y; |
michael@0 | 46 | }; |
michael@0 | 47 | } |
michael@0 | 48 | (function() { |
michael@0 | 49 | var fuzzMT = new MersenneTwister19937; |
michael@0 | 50 | fuzzSeed = 4; |
michael@0 | 51 | fuzzMT.init_genrand(fuzzSeed); |
michael@0 | 52 | rnd = function(n) { |
michael@0 | 53 | var x = fuzzMT.genrand_int32() * 2.2e-10; |
michael@0 | 54 | return Math.floor(x * n); |
michael@0 | 55 | }; |
michael@0 | 56 | }()); |
michael@0 | 57 | |
michael@0 | 58 | function rndElt(a) { |
michael@0 | 59 | return a[rnd(a.length)]; |
michael@0 | 60 | } |
michael@0 | 61 | varBinderFor = ["", "t", ""]; |
michael@0 | 62 | function forLoopHead(d, b, v, reps) { |
michael@0 | 63 | var sInit = rndElt(varBinderFor) + v + "=0"; |
michael@0 | 64 | var sCond = v + "<" + reps; |
michael@0 | 65 | sNext = "++" + v; |
michael@0 | 66 | return "for(" + sInit + ";" + sCond + ";" + sNext + ")"; |
michael@0 | 67 | } |
michael@0 | 68 | function makeBranchUnstableLoop(d, b) { |
michael@0 | 69 | var reps = rnd(rnd(9)); |
michael@0 | 70 | v = uniqueVarName(); |
michael@0 | 71 | var mod = rnd(); |
michael@0 | 72 | target = rnd(mod); |
michael@0 | 73 | return "" + forLoopHead(d, b, v, reps) + "{" + "if(" + v + "%" + mod + "==" + target + "){" + makeStatement(d - 2, b) + "}" + "{" + makeStatement(d - 2) + "}" + "}"; |
michael@0 | 74 | } |
michael@0 | 75 | function weighted(wa) { |
michael@0 | 76 | a = []; |
michael@0 | 77 | for (var i = 0; i < wa.length; ++i) { |
michael@0 | 78 | for (var j = 0; j < wa[i].w; ++j) { |
michael@0 | 79 | a.push(wa[i].fun); |
michael@0 | 80 | } |
michael@0 | 81 | } |
michael@0 | 82 | return a; |
michael@0 | 83 | } |
michael@0 | 84 | statementMakers = weighted([{ |
michael@0 | 85 | w: 6, |
michael@0 | 86 | fun: makeBranchUnstableLoop |
michael@0 | 87 | }, {}]); |
michael@0 | 88 | (function() { |
michael@0 | 89 | builderStatementMakers = weighted([{ |
michael@0 | 90 | w: 1, |
michael@0 | 91 | fun: function() { |
michael@0 | 92 | return "gc()"; |
michael@0 | 93 | } |
michael@0 | 94 | }, { |
michael@0 | 95 | w: 10, |
michael@0 | 96 | fun: function() {} |
michael@0 | 97 | }]); |
michael@0 | 98 | makeBuilderStatement = function() { |
michael@0 | 99 | return rndElt(builderStatementMakers)(); |
michael@0 | 100 | }; |
michael@0 | 101 | }()); |
michael@0 | 102 | function uniqueVarName() { |
michael@0 | 103 | for (i = 0; i < 6; ++i) { |
michael@0 | 104 | s = String.fromCharCode(97 + rnd(6)); |
michael@0 | 105 | } |
michael@0 | 106 | return s; |
michael@0 | 107 | } |
michael@0 | 108 | function makeLittleStatement(d) { |
michael@0 | 109 | rnd(0); |
michael@0 | 110 | if (rnd) { |
michael@0 | 111 | rndElt(littleStatementMakers)(); |
michael@0 | 112 | } |
michael@0 | 113 | } |
michael@0 | 114 | littleStatementMakers = [function() {}]; |
michael@0 | 115 | function testOne() { |
michael@0 | 116 | var code = makeOv(10); |
michael@0 | 117 | tryItOut(code); |
michael@0 | 118 | } |
michael@0 | 119 | function makeStatement(d, b) { |
michael@0 | 120 | if (rnd(0)) {} |
michael@0 | 121 | if (rnd(2)) { |
michael@0 | 122 | return makeBuilderStatement(); |
michael@0 | 123 | } |
michael@0 | 124 | d < 6 && rnd() == 0; |
michael@0 | 125 | if (d < rnd(8)) { |
michael@0 | 126 | return makeLittleStatement(); |
michael@0 | 127 | } |
michael@0 | 128 | return rndElt(statementMakers)(d, b); |
michael@0 | 129 | } |
michael@0 | 130 | function makeOv(d, B) { |
michael@0 | 131 | if (rnd() == 0) {} |
michael@0 | 132 | return "" + makeStatement(d, [""]); |
michael@0 | 133 | } |
michael@0 | 134 | function tryItOut(code) { |
michael@0 | 135 | try { |
michael@0 | 136 | f = Function(code); |
michael@0 | 137 | f(); |
michael@0 | 138 | } catch (r) {} |
michael@0 | 139 | } |
michael@0 | 140 | for (let aa = 0; aa < 9999; aa++) { |
michael@0 | 141 | testOne(); |
michael@0 | 142 | } |