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 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 //-----------------------------------------------------------------------------
7 var BUGNUMBER = "364104";
8 var summary = "Array.prototype.indexOf, Array.prototype.lastIndexOf issues " +
9 "with the optional second fromIndex argument";
10 var actual, expect;
12 printBugNumber(BUGNUMBER);
13 printStatus(summary);
15 /**************
16 * BEGIN TEST *
17 **************/
19 var failed = false;
21 try
22 {
23 // indexOf
24 if ([2].indexOf(2) != 0)
25 throw "indexOf: not finding 2!?";
26 if ([2].indexOf(2, 0) != 0)
27 throw "indexOf: not interpreting explicit second argument 0!";
28 if ([2].indexOf(2, 1) != -1)
29 throw "indexOf: ignoring second argument with value equal to array length!";
30 if ([2].indexOf(2, 2) != -1)
31 throw "indexOf: ignoring second argument greater than array length!";
32 if ([2].indexOf(2, 17) != -1)
33 throw "indexOf: ignoring large second argument!";
34 if ([2].indexOf(2, -5) != 0)
35 throw "indexOf: calculated fromIndex < 0, should search entire array!";
36 if ([2, 3].indexOf(2, -1) != -1)
37 throw "indexOf: not handling index == (-1 + 2), element 2 correctly!";
38 if ([2, 3].indexOf(3, -1) != 1)
39 throw "indexOf: not handling index == (-1 + 2), element 3 correctly!";
41 // lastIndexOf
42 if ([2].lastIndexOf(2) != 0)
43 throw "lastIndexOf: not finding 2!?";
44 if ([2].lastIndexOf(2, 1) != 0)
45 throw "lastIndexOf: not interpreting explicit second argument 1!?";
46 if ([2].lastIndexOf(2, 17) != 0)
47 throw "lastIndexOf: should have searched entire array!";
48 if ([2].lastIndexOf(2, -5) != -1)
49 throw "lastIndexOf: -5 + 1 < 0, so array shouldn't be searched!";
50 if ([2].lastIndexOf(2, -2) != -1)
51 throw "lastIndexOf: -2 + 1 < 0, so array shouldn't be searched!";
52 if ([2, 3].lastIndexOf(2, -1) != 0)
53 throw "lastIndexOf: not handling index == (-1 + 2), element 2 correctly!";
54 if ([2, 3].lastIndexOf(3, -1) != 1)
55 throw "lastIndexOf: not handling index == (-1 + 2), element 3 correctly!";
56 if ([2, 3].lastIndexOf(2, -2) != 0)
57 throw "lastIndexOf: not handling index == (-2 + 2), element 2 correctly!";
58 if ([2, 3].lastIndexOf(3, -2) != -1)
59 throw "lastIndexOf: not handling index == (-2 + 2), element 3 correctly!";
60 if ([2, 3].lastIndexOf(2, -3) != -1)
61 throw "lastIndexOf: calculated fromIndex < 0, shouldn't search array for 2!";
62 if ([2, 3].lastIndexOf(3, -3) != -1)
63 throw "lastIndexOf: calculated fromIndex < 0, shouldn't search array for 3!";
64 }
65 catch (e)
66 {
67 failed = e;
68 }
71 expect = false;
72 actual = failed;
74 reportCompare(expect, actual, summary);