js/src/tests/ecma/Array/15.4.5.1-1.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    File Name:          15.4.5.1-1.js
     9    ECMA Section:       [[ Put]] (P, V)
    10    Description:
    11    Array objects use a variation of the [[Put]] method used for other native
    12    ECMAScript objects (section 8.6.2.2).
    14    Assume A is an Array object and P is a string.
    16    When the [[Put]] method of A is called with property P and value V, the
    17    following steps are taken:
    19    1.  Call the [[CanPut]] method of A with name P.
    20    2.  If Result(1) is false, return.
    21    3.  If A doesn't have a property with name P, go to step 7.
    22    4.  If P is "length", go to step 12.
    23    5.  Set the value of property P of A to V.
    24    6.  Go to step 8.
    25    7.  Create a property with name P, set its value to V and give it empty
    26    attributes.
    27    8.  If P is not an array index, return.
    28    9.  If A itself has a property (not an inherited property) named "length",
    29    andToUint32(P) is less than the value of the length property of A, then
    30    return.
    31    10. Change (or set) the value of the length property of A to ToUint32(P)+1.
    32    11. Return.
    33    12. Compute ToUint32(V).
    34    13. For every integer k that is less than the value of the length property
    35    of A but not less than Result(12), if A itself has a property (not an
    36    inherited property) named ToString(k), then delete that property.
    37    14. Set the value of property P of A to Result(12).
    38    15. Return.
    39    Author:             christine@netscape.com
    40    Date:               12 november 1997
    41 */
    43 var SECTION = "15.4.5.1-1";
    44 var VERSION = "ECMA_1";
    45 startTest();
    46 var TITLE   = "Array [[Put]] (P, V)";
    48 writeHeaderToLog( SECTION + " "+ TITLE);
    51 // P is "length"
    53 new TestCase(   SECTION,
    54 		"var A = new Array(); A.length = 1000; A.length",
    55 		1000,
    56 		eval("var A = new Array(); A.length = 1000; A.length") );
    58 // A has Property P, and P is not length or an array index
    59 new TestCase(   SECTION,
    60 		"var A = new Array(1000); A.name = 'name of this array'; A.name",
    61 		'name of this array',
    62 		eval("var A = new Array(1000); A.name = 'name of this array'; A.name") );
    64 new TestCase(   SECTION,
    65 		"var A = new Array(1000); A.name = 'name of this array'; A.length",
    66 		1000,
    67 		eval("var A = new Array(1000); A.name = 'name of this array'; A.length") );
    70 // A has Property P, P is not length, P is an array index, and ToUint32(p) is less than the
    71 // value of length
    73 new TestCase(   SECTION,
    74 		"var A = new Array(1000); A[123] = 'hola'; A[123]",
    75 		'hola',
    76 		eval("var A = new Array(1000); A[123] = 'hola'; A[123]") );
    78 new TestCase(   SECTION,
    79 		"var A = new Array(1000); A[123] = 'hola'; A.length",
    80 		1000,
    81 		eval("var A = new Array(1000); A[123] = 'hola'; A.length") );
    84 for ( var i = 0X0020, TEST_STRING = "var A = new Array( " ; i < 0x00ff; i++ ) {
    85   if (i === "u".charCodeAt(0) || i === "x".charCodeAt(0))
    86     continue;
    87   TEST_STRING += "\'\\"+ String.fromCharCode( i ) +"\'";
    88   if ( i < 0x00FF - 1   ) {
    89     TEST_STRING += ",";
    90   } else {
    91     TEST_STRING += ");"
    92       }
    93 }
    95 var LENGTH = 0x00ff - 0x0020 - 2 /* "u"/"x" exclusions above */;
    97 new TestCase(   SECTION,
    98 		TEST_STRING +" A[150] = 'hello'; A[150]",
    99 		'hello',
   100 		eval( TEST_STRING + " A[150] = 'hello'; A[150]" ) );
   102 new TestCase(   SECTION,
   103 		TEST_STRING +" A[150] = 'hello'; A[150]",
   104 		LENGTH,
   105 		eval( TEST_STRING + " A[150] = 'hello'; A.length" ) );
   107 // A has Property P, P is not length, P is an array index, and ToUint32(p) is not less than the
   108 // value of length
   110 new TestCase(   SECTION,
   111 		"var A = new Array(); A[123] = true; A.length",
   112 		124,
   113 		eval("var A = new Array(); A[123] = true; A.length") );
   115 new TestCase(   SECTION,
   116 		"var A = new Array(0,1,2,3,4,5,6,7,8,9,10); A[15] ='15'; A.length",
   117 		16,
   118 		eval("var A = new Array(0,1,2,3,4,5,6,7,8,9,10); A[15] ='15'; A.length") );
   120 for ( var i = 0; i < A.length; i++ ) {
   121   new TestCase( SECTION,
   122 		"var A = new Array(0,1,2,3,4,5,6,7,8,9,10); A[15] ='15'; A[" +i +"]",
   123 		(i <= 10) ? i : ( i == 15 ? '15' : void 0 ),
   124 		A[i] );
   125 }
   126 // P is not an array index, and P is not "length"
   128 new TestCase(   SECTION,
   129 		"var A = new Array(); A.join.length = 4; A.join.length",
   130 		1,
   131 		eval("var A = new Array(); A.join.length = 4; A.join.length") );
   133 new TestCase(   SECTION,
   134 		"var A = new Array(); A.join.length = 4; A.length",
   135 		0,
   136 		eval("var A = new Array(); A.join.length = 4; A.length") );
   138 test();

mercurial