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 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | |
michael@0 | 7 | /** |
michael@0 | 8 | Filename: slice.js |
michael@0 | 9 | Description: 'This tests out some of the functionality on methods on the Array objects' |
michael@0 | 10 | |
michael@0 | 11 | Author: Nick Lerissa |
michael@0 | 12 | Date: Fri Feb 13 09:58:28 PST 1998 |
michael@0 | 13 | */ |
michael@0 | 14 | |
michael@0 | 15 | var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; |
michael@0 | 16 | var VERSION = 'no version'; |
michael@0 | 17 | startTest(); |
michael@0 | 18 | var TITLE = 'String:slice'; |
michael@0 | 19 | |
michael@0 | 20 | writeHeaderToLog('Executing script: slice.js'); |
michael@0 | 21 | writeHeaderToLog( SECTION + " "+ TITLE); |
michael@0 | 22 | |
michael@0 | 23 | var a = ['a','test string',456,9.34,new String("string object"),[],['h','i','j','k']]; |
michael@0 | 24 | var b = [1,2,3,4,5,6,7,8,9,0]; |
michael@0 | 25 | |
michael@0 | 26 | exhaustiveSliceTest("exhaustive slice test 1", a); |
michael@0 | 27 | exhaustiveSliceTest("exhaustive slice test 2", b); |
michael@0 | 28 | |
michael@0 | 29 | test(); |
michael@0 | 30 | |
michael@0 | 31 | function mySlice(a, from, to) |
michael@0 | 32 | { |
michael@0 | 33 | var from2 = from; |
michael@0 | 34 | var to2 = to; |
michael@0 | 35 | var returnArray = []; |
michael@0 | 36 | var i; |
michael@0 | 37 | |
michael@0 | 38 | if (from2 < 0) from2 = a.length + from; |
michael@0 | 39 | if (to2 < 0) to2 = a.length + to; |
michael@0 | 40 | |
michael@0 | 41 | if ((to2 > from2)&&(to2 > 0)&&(from2 < a.length)) |
michael@0 | 42 | { |
michael@0 | 43 | if (from2 < 0) from2 = 0; |
michael@0 | 44 | if (to2 > a.length) to2 = a.length; |
michael@0 | 45 | |
michael@0 | 46 | for (i = from2; i < to2; ++i) returnArray.push(a[i]); |
michael@0 | 47 | } |
michael@0 | 48 | return returnArray; |
michael@0 | 49 | } |
michael@0 | 50 | |
michael@0 | 51 | // This function tests the slice command on an Array |
michael@0 | 52 | // passed in. The arguments passed into slice range in |
michael@0 | 53 | // value from -5 to the length of the array + 4. Every |
michael@0 | 54 | // combination of the two arguments is tested. The expected |
michael@0 | 55 | // result of the slice(...) method is calculated and |
michael@0 | 56 | // compared to the actual result from the slice(...) method. |
michael@0 | 57 | // If the Arrays are not similar false is returned. |
michael@0 | 58 | function exhaustiveSliceTest(testname, a) |
michael@0 | 59 | { |
michael@0 | 60 | var x = 0; |
michael@0 | 61 | var y = 0; |
michael@0 | 62 | var errorMessage; |
michael@0 | 63 | var reason = ""; |
michael@0 | 64 | var passed = true; |
michael@0 | 65 | |
michael@0 | 66 | for (x = -(2 + a.length); x <= (2 + a.length); x++) |
michael@0 | 67 | for (y = (2 + a.length); y >= -(2 + a.length); y--) |
michael@0 | 68 | { |
michael@0 | 69 | var b = a.slice(x,y); |
michael@0 | 70 | var c = mySlice(a,x,y); |
michael@0 | 71 | |
michael@0 | 72 | if (String(b) != String(c)) |
michael@0 | 73 | { |
michael@0 | 74 | errorMessage = |
michael@0 | 75 | "ERROR: 'TEST FAILED' ERROR: 'TEST FAILED' ERROR: 'TEST FAILED'\n" + |
michael@0 | 76 | " test: " + "a.slice(" + x + "," + y + ")\n" + |
michael@0 | 77 | " a: " + String(a) + "\n" + |
michael@0 | 78 | " actual result: " + String(b) + "\n" + |
michael@0 | 79 | " expected result: " + String(c) + "\n"; |
michael@0 | 80 | writeHeaderToLog(errorMessage); |
michael@0 | 81 | reason = reason + errorMessage; |
michael@0 | 82 | passed = false; |
michael@0 | 83 | } |
michael@0 | 84 | } |
michael@0 | 85 | var testCase = new TestCase(SECTION, testname, true, passed); |
michael@0 | 86 | if (passed == false) |
michael@0 | 87 | testCase.reason = reason; |
michael@0 | 88 | return testCase; |
michael@0 | 89 | } |