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 // Test corner cases of for-of iteration over Arrays.
2 // The current spidermonky JSOP_SPREAD implementation for function calls
3 // with '...rest' arguments uses a ForOfIterator to extract values from
4 // the array, so we use that mechanism to test ForOfIterator here.
6 //
7 // Check case where ArrayIterator.prototype.next changes in the middle of iteration.
8 //
9 function TestChangeArrayIteratorNext() {
10 function doIter(f, arr) {
11 return f(...arr)
12 }
14 function fun(a, b, c) {
15 var result = 0;
16 for (var i = 0; i < arguments.length; i++)
17 result += arguments[i];
18 return result;
19 }
21 var GET_COUNT = 0;
22 function getter() {
23 GET_COUNT++;
24 if (GET_COUNT == MID)
25 iterProto.next = NewNext;
26 return M2;
27 }
29 var iter = ([])['@@iterator']();
30 var iterProto = Object.getPrototypeOf(iter);
31 var OldNext = iterProto.next;
32 var NewNext = function () {
33 return OldNext.apply(this, arguments);
34 };
36 var TRUE_SUM = 0;
37 var N = 100;
38 var MID = N/2;
39 var M = 3;
40 var arr = new Array(M);
41 var ARR_SUM = 0;
42 for (var j = 0; j < M; j++) {
43 arr[j] = j;
44 ARR_SUM += j;
45 }
46 var M2 = (M/2)|0;
47 Object.defineProperty(arr, M2, {'get':getter});
49 var sum = 0;
50 for (var i = 0; i < N; i++) {
51 sum += doIter(fun, arr);
52 TRUE_SUM += ARR_SUM;
53 }
54 assertEq(sum, TRUE_SUM);
55 }
56 TestChangeArrayIteratorNext();
58 if (typeof reportCompare === "function")
59 reportCompare(true, true);