js/src/tests/ecma/Array/15.4.5.2-2.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 File Name: 15.4.5.2-2.js
michael@0 9 ECMA Section: Array.length
michael@0 10 Description:
michael@0 11 15.4.5.2 length
michael@0 12 The length property of this Array object is always numerically greater
michael@0 13 than the name of every property whose name is an array index.
michael@0 14
michael@0 15 The length property has the attributes { DontEnum, DontDelete }.
michael@0 16
michael@0 17 This test verifies that the Array.length property is not Read Only.
michael@0 18
michael@0 19 Author: christine@netscape.com
michael@0 20 Date: 12 november 1997
michael@0 21 */
michael@0 22
michael@0 23 var SECTION = "15.4.5.2-2";
michael@0 24 var VERSION = "ECMA_1";
michael@0 25 startTest();
michael@0 26 var TITLE = "Array.length";
michael@0 27
michael@0 28 writeHeaderToLog( SECTION + " "+ TITLE);
michael@0 29
michael@0 30 addCase( new Array(), 0, Math.pow(2,14), Math.pow(2,14) );
michael@0 31
michael@0 32 addCase( new Array(), 0, 1, 1 );
michael@0 33
michael@0 34 addCase( new Array(Math.pow(2,12)), Math.pow(2,12), 0, 0 );
michael@0 35 addCase( new Array(Math.pow(2,13)), Math.pow(2,13), Math.pow(2,12), Math.pow(2,12) );
michael@0 36 addCase( new Array(Math.pow(2,12)), Math.pow(2,12), Math.pow(2,12), Math.pow(2,12) );
michael@0 37 addCase( new Array(Math.pow(2,14)), Math.pow(2,14), Math.pow(2,12), Math.pow(2,12) )
michael@0 38
michael@0 39 // some tests where array is not empty
michael@0 40 // array is populated with strings
michael@0 41 for ( var arg = "", i = 0; i < Math.pow(2,12); i++ ) {
michael@0 42 arg += String(i) + ( i != Math.pow(2,12)-1 ? "," : "" );
michael@0 43
michael@0 44 }
michael@0 45 // print(i +":"+arg);
michael@0 46
michael@0 47 var a = eval( "new Array("+arg+")" );
michael@0 48
michael@0 49 addCase( a, i, i, i );
michael@0 50 addCase( a, i, Math.pow(2,12)+i+1, Math.pow(2,12)+i+1, true );
michael@0 51 addCase( a, Math.pow(2,12)+5, 0, 0, true );
michael@0 52
michael@0 53 test();
michael@0 54
michael@0 55 function addCase( object, old_len, set_len, new_len, checkitems ) {
michael@0 56 object.length = set_len;
michael@0 57
michael@0 58 new TestCase( SECTION,
michael@0 59 "array = new Array("+ old_len+"); array.length = " + set_len +
michael@0 60 "; array.length",
michael@0 61 new_len,
michael@0 62 object.length );
michael@0 63
michael@0 64 if ( checkitems ) {
michael@0 65 // verify that items between old and newlen are all undefined
michael@0 66 if ( new_len < old_len ) {
michael@0 67 var passed = true;
michael@0 68 for ( var i = new_len; i < old_len; i++ ) {
michael@0 69 if ( object[i] != void 0 ) {
michael@0 70 passed = false;
michael@0 71 }
michael@0 72 }
michael@0 73 new TestCase( SECTION,
michael@0 74 "verify that array items have been deleted",
michael@0 75 true,
michael@0 76 passed );
michael@0 77 }
michael@0 78 if ( new_len > old_len ) {
michael@0 79 var passed = true;
michael@0 80 for ( var i = old_len; i < new_len; i++ ) {
michael@0 81 if ( object[i] != void 0 ) {
michael@0 82 passed = false;
michael@0 83 }
michael@0 84 }
michael@0 85 new TestCase( SECTION,
michael@0 86 "verify that new items are undefined",
michael@0 87 true,
michael@0 88 passed );
michael@0 89 }
michael@0 90 }
michael@0 91
michael@0 92 }
michael@0 93

mercurial