js/src/tests/js1_2/Array/general2.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.

     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/. */
     7 /**
     8    Filename:     general2.js
     9    Description:  'This tests out some of the functionality on methods on the Array objects'
    11    Author:       Nick Lerissa
    12    Date:         Fri Feb 13 09:58:28 PST 1998
    13 */
    15 var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
    16 var VERSION = 'no version';
    17 startTest();
    18 var TITLE = 'String:push,splice,concat,unshift,sort';
    20 writeHeaderToLog('Executing script: general2.js');
    21 writeHeaderToLog( SECTION + " "+ TITLE);
    23 array1 = new Array();
    24 array2 = [];
    25 size   = 10;
    27 // this for loop populates array1 and array2 as follows:
    28 // array1 = [0,1,2,3,4,....,size - 2,size - 1]
    29 // array2 = [size - 1, size - 2,...,4,3,2,1,0]
    30 for (var i = 0; i < size; i++)
    31 {
    32   array1.push(i);
    33   array2.push(size - 1 - i);
    34 }
    36 // the following for loop reverses the order of array1 so
    37 // that it should be similarly ordered to array2
    38 for (i = array1.length; i > 0; i--)
    39 {
    40   array3 = array1.slice(1,i);
    41   array1.splice(1,i-1);
    42   array1 = array3.concat(array1);
    43 }
    45 // the following for loop reverses the order of array1
    46 // and array2
    47 for (i = 0; i < size; i++)
    48 {
    49   array1.push(array1.shift());
    50   array2.unshift(array2.pop());
    51 }
    53 new TestCase( SECTION, "Array.push,pop,shift,unshift,slice,splice", true,String(array1) == String(array2));
    54 array1.sort();
    55 array2.sort();
    56 new TestCase( SECTION, "Array.sort", true,String(array1) == String(array2));
    58 test();

mercurial