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.
1 function map_test(t, cases)
2 {
3 for (var i = 0; i < cases.length; i++) {
4 function c() { return t(cases[i].input); }
5 var expected = cases[i].expected;
6 assertEq(c(), expected);
7 }
8 }
10 function lsh_inner(n)
11 {
12 var r;
13 for (var i = 0; i < 35; i++)
14 r = 0x1 << n;
15 return r;
16 }
17 map_test (lsh_inner,
18 [{input: 15, expected: 32768},
19 {input: 55, expected: 8388608},
20 {input: 1, expected: 2},
21 {input: 0, expected: 1}]);
23 function rsh_inner(n)
24 {
25 var r;
26 for (var i = 0; i < 35; i++)
27 r = 0x11010101 >> n;
28 return r;
29 }
30 map_test (rsh_inner,
31 [{input: 8, expected: 1114369},
32 {input: 5, expected: 8914952},
33 {input: 35, expected: 35659808},
34 {input: -1, expected: 0}]);
36 function ursh_inner(n)
37 {
38 var r;
39 for (var i = 0; i < 35; i++)
40 r = -55 >>> n;
41 return r;
42 }
43 map_test (ursh_inner,
44 [{input: 8, expected: 16777215},
45 {input: 33, expected: 2147483620},
46 {input: 0, expected: 4294967241},
47 {input: 1, expected: 2147483620}]);
49 function doMath_inner(cos)
50 {
51 var s = 0;
52 var sin = Math.sin;
53 for (var i = 0; i < 200; i++)
54 s = -Math.pow(sin(i) + cos(i * 0.75), 4);
55 return s;
56 }
57 function doMath() {
58 return doMath_inner(Math.cos);
59 }
60 assertEq(doMath(), -0.5405549555611059);