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.

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: general2.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:push,splice,concat,unshift,sort';
michael@0 19
michael@0 20 writeHeaderToLog('Executing script: general2.js');
michael@0 21 writeHeaderToLog( SECTION + " "+ TITLE);
michael@0 22
michael@0 23 array1 = new Array();
michael@0 24 array2 = [];
michael@0 25 size = 10;
michael@0 26
michael@0 27 // this for loop populates array1 and array2 as follows:
michael@0 28 // array1 = [0,1,2,3,4,....,size - 2,size - 1]
michael@0 29 // array2 = [size - 1, size - 2,...,4,3,2,1,0]
michael@0 30 for (var i = 0; i < size; i++)
michael@0 31 {
michael@0 32 array1.push(i);
michael@0 33 array2.push(size - 1 - i);
michael@0 34 }
michael@0 35
michael@0 36 // the following for loop reverses the order of array1 so
michael@0 37 // that it should be similarly ordered to array2
michael@0 38 for (i = array1.length; i > 0; i--)
michael@0 39 {
michael@0 40 array3 = array1.slice(1,i);
michael@0 41 array1.splice(1,i-1);
michael@0 42 array1 = array3.concat(array1);
michael@0 43 }
michael@0 44
michael@0 45 // the following for loop reverses the order of array1
michael@0 46 // and array2
michael@0 47 for (i = 0; i < size; i++)
michael@0 48 {
michael@0 49 array1.push(array1.shift());
michael@0 50 array2.unshift(array2.pop());
michael@0 51 }
michael@0 52
michael@0 53 new TestCase( SECTION, "Array.push,pop,shift,unshift,slice,splice", true,String(array1) == String(array2));
michael@0 54 array1.sort();
michael@0 55 array2.sort();
michael@0 56 new TestCase( SECTION, "Array.sort", true,String(array1) == String(array2));
michael@0 57
michael@0 58 test();
michael@0 59

mercurial