js/src/tests/js1_5/Array/regress-364104.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

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 var BUGNUMBER = "364104";
michael@0 8 var summary = "Array.prototype.indexOf, Array.prototype.lastIndexOf issues " +
michael@0 9 "with the optional second fromIndex argument";
michael@0 10 var actual, expect;
michael@0 11
michael@0 12 printBugNumber(BUGNUMBER);
michael@0 13 printStatus(summary);
michael@0 14
michael@0 15 /**************
michael@0 16 * BEGIN TEST *
michael@0 17 **************/
michael@0 18
michael@0 19 var failed = false;
michael@0 20
michael@0 21 try
michael@0 22 {
michael@0 23 // indexOf
michael@0 24 if ([2].indexOf(2) != 0)
michael@0 25 throw "indexOf: not finding 2!?";
michael@0 26 if ([2].indexOf(2, 0) != 0)
michael@0 27 throw "indexOf: not interpreting explicit second argument 0!";
michael@0 28 if ([2].indexOf(2, 1) != -1)
michael@0 29 throw "indexOf: ignoring second argument with value equal to array length!";
michael@0 30 if ([2].indexOf(2, 2) != -1)
michael@0 31 throw "indexOf: ignoring second argument greater than array length!";
michael@0 32 if ([2].indexOf(2, 17) != -1)
michael@0 33 throw "indexOf: ignoring large second argument!";
michael@0 34 if ([2].indexOf(2, -5) != 0)
michael@0 35 throw "indexOf: calculated fromIndex < 0, should search entire array!";
michael@0 36 if ([2, 3].indexOf(2, -1) != -1)
michael@0 37 throw "indexOf: not handling index == (-1 + 2), element 2 correctly!";
michael@0 38 if ([2, 3].indexOf(3, -1) != 1)
michael@0 39 throw "indexOf: not handling index == (-1 + 2), element 3 correctly!";
michael@0 40
michael@0 41 // lastIndexOf
michael@0 42 if ([2].lastIndexOf(2) != 0)
michael@0 43 throw "lastIndexOf: not finding 2!?";
michael@0 44 if ([2].lastIndexOf(2, 1) != 0)
michael@0 45 throw "lastIndexOf: not interpreting explicit second argument 1!?";
michael@0 46 if ([2].lastIndexOf(2, 17) != 0)
michael@0 47 throw "lastIndexOf: should have searched entire array!";
michael@0 48 if ([2].lastIndexOf(2, -5) != -1)
michael@0 49 throw "lastIndexOf: -5 + 1 < 0, so array shouldn't be searched!";
michael@0 50 if ([2].lastIndexOf(2, -2) != -1)
michael@0 51 throw "lastIndexOf: -2 + 1 < 0, so array shouldn't be searched!";
michael@0 52 if ([2, 3].lastIndexOf(2, -1) != 0)
michael@0 53 throw "lastIndexOf: not handling index == (-1 + 2), element 2 correctly!";
michael@0 54 if ([2, 3].lastIndexOf(3, -1) != 1)
michael@0 55 throw "lastIndexOf: not handling index == (-1 + 2), element 3 correctly!";
michael@0 56 if ([2, 3].lastIndexOf(2, -2) != 0)
michael@0 57 throw "lastIndexOf: not handling index == (-2 + 2), element 2 correctly!";
michael@0 58 if ([2, 3].lastIndexOf(3, -2) != -1)
michael@0 59 throw "lastIndexOf: not handling index == (-2 + 2), element 3 correctly!";
michael@0 60 if ([2, 3].lastIndexOf(2, -3) != -1)
michael@0 61 throw "lastIndexOf: calculated fromIndex < 0, shouldn't search array for 2!";
michael@0 62 if ([2, 3].lastIndexOf(3, -3) != -1)
michael@0 63 throw "lastIndexOf: calculated fromIndex < 0, shouldn't search array for 3!";
michael@0 64 }
michael@0 65 catch (e)
michael@0 66 {
michael@0 67 failed = e;
michael@0 68 }
michael@0 69
michael@0 70
michael@0 71 expect = false;
michael@0 72 actual = failed;
michael@0 73
michael@0 74 reportCompare(expect, actual, summary);

mercurial