js/src/tests/ecma_5/Array/length-set-object.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 = 657298;
    10 var summary = 'Various quirks of setting array length properties to objects';
    12 print(BUGNUMBER + ": " + summary);
    14 /**************
    15  * BEGIN TEST *
    16  **************/
    18 function invokeConversionTwice1()
    19 {
    20   var count = 0;
    21   [].length = { valueOf: function() { count++; return 1; } };
    22   assertEq(count, 2);
    23 }
    24 invokeConversionTwice1();
    26 function invokeConversionTwice2()
    27 {
    28   var count = 0;
    29   [].length = { toString: function() { count++; return 1; }, valueOf: null };
    30   assertEq(count, 2);
    31 }
    32 invokeConversionTwice2();
    34 function dontOverwriteError1()
    35 {
    36   try
    37   {
    38     [].length = { valueOf: {}, toString: {} };
    39     throw new Error("didn't throw a TypeError");
    40   }
    41   catch (e)
    42   {
    43     assertEq(e instanceof TypeError, true,
    44              "expected a TypeError running out of conversion options, got " + e);
    45   }
    46 }
    47 dontOverwriteError1();
    49 function dontOverwriteError2()
    50 {
    51   try
    52   {
    53     [].length = { valueOf: function() { throw "error"; } };
    54     throw new Error("didn't throw a TypeError");
    55   }
    56   catch (e)
    57   {
    58     assertEq(e, "error", "expected 'error' from failed conversion, got " + e);
    59   }
    60 }
    61 dontOverwriteError2();
    63 /******************************************************************************/
    65 if (typeof reportCompare === "function")
    66   reportCompare(true, true);
    68 print("All tests passed!");

mercurial