js/src/tests/ecma_5/Array/length-truncate-nonconfigurable.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  * Contributor:
     5  *   Jeff Walden <jwalden+code@mit.edu>
     6  */
     8 //-----------------------------------------------------------------------------
     9 var BUGNUMBER = 858381;
    10 var summary =
    11   "Array length redefinition behavior with non-configurable elements";
    13 print(BUGNUMBER + ": " + summary);
    15 /**************
    16  * BEGIN TEST *
    17  **************/
    19 var arr = [0, 1, 2];
    20 Object.defineProperty(arr, 1, { configurable: false });
    22 try
    23 {
    24   Object.defineProperty(arr, "length", { value: 0, writable: false });
    25 }
    26 catch (e)
    27 {
    28   assertEq(e instanceof TypeError, true,
    29            "must throw TypeError when array truncation would have to remove " +
    30            "non-configurable elements");
    31 }
    33 assertEq(arr.length, 2, "length is highest remaining index plus one");
    35 var desc = Object.getOwnPropertyDescriptor(arr, "length");
    36 assertEq(desc !== undefined, true);
    38 assertEq(desc.value, 2);
    39 assertEq(desc.writable, false);
    40 assertEq(desc.enumerable, false);
    41 assertEq(desc.configurable, false);
    43 /******************************************************************************/
    45 if (typeof reportCompare === "function")
    46   reportCompare(true, true);
    48 print("Tests complete");

mercurial