js/src/tests/ecma_5/Array/toString-01.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 = 562446;
    10 var summary = 'ES5: Array.prototype.toString';
    12 print(BUGNUMBER + ": " + summary);
    14 /**************
    15  * BEGIN TEST *
    16  **************/
    18 var o;
    20 o = { join: function() { assertEq(arguments.length, 0); return "ohai"; } };
    21 assertEq(Array.prototype.toString.call(o), "ohai");
    23 o = {};
    24 assertEq(Array.prototype.toString.call(o), "[object Object]");
    26 Array.prototype.join = function() { return "kthxbai"; };
    27 assertEq(Array.prototype.toString.call([]), "kthxbai");
    29 o = { join: 17 };
    30 assertEq(Array.prototype.toString.call(o), "[object Object]");
    32 o = { get join() { throw 42; } };
    33 try
    34 {
    35   var str = Array.prototype.toString.call(o);
    36   assertEq(true, false,
    37            "expected an exception calling [].toString on an object with a " +
    38            "join getter that throws, got " + str + " instead");
    39 }
    40 catch (e)
    41 {
    42   assertEq(e, 42,
    43            "expected thrown e === 42 when calling [].toString on an object " +
    44            "with a join getter that throws, got " + e);
    45 }
    47 /******************************************************************************/
    49 if (typeof reportCompare === "function")
    50   reportCompare(true, true);
    52 print("All tests passed!");

mercurial