js/src/tests/ecma_5/Function/redefine-arguments-length.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 /*
     2  * Any copyright is dedicated to the Public Domain.
     3  * http://creativecommons.org/licenses/publicdomain/
     4  */
     6 var gTestfile = 'redefine-arguments-length.js';
     7 //-----------------------------------------------------------------------------
     8 var BUGNUMBER = 539766;
     9 var summary =
    10   "Object.defineProperty sets arguments.length without setting the " +
    11   "length-overridden bit";
    13 print(BUGNUMBER + ": " + summary);
    15 /**************
    16  * BEGIN TEST *
    17  **************/
    19 function test_JSOP_ARGCNT()
    20 {
    21   var length = "length";
    22   Object.defineProperty(arguments, length, { value: 17 });
    23   assertEq(arguments.length, 17);
    24   assertEq(arguments[length], 17);
    25 }
    26 test_JSOP_ARGCNT();
    28 function test_js_fun_apply()
    29 {
    30   var length = "length";
    31   Object.defineProperty(arguments, length, { value: 17 });
    33   function fun()
    34   {
    35     assertEq(arguments.length, 17);
    36     assertEq(arguments[length], 17);
    37     assertEq(arguments[0], "foo");
    38     for (var i = 1; i < 17; i++)
    39       assertEq(arguments[i], undefined);
    40   }
    41   fun.apply(null, arguments);
    42 }
    43 test_js_fun_apply("foo");
    45 function test_array_toString_sub_1()
    46 {
    47   Object.defineProperty(arguments, "length", { value: 1 });
    48   arguments.join = [].join;
    49   assertEq([].toString.call(arguments), "1");
    50 }
    51 test_array_toString_sub_1(1, 2);
    53 function test_array_toString_sub_2()
    54 {
    55   Object.defineProperty(arguments, "length", { value: 1 });
    56   assertEq([].toLocaleString.call(arguments), "1");
    57 }
    58 test_array_toString_sub_2(1, 2);
    61 /******************************************************************************/
    63 reportCompare(true, true);
    65 print("All tests passed!");

mercurial