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