js/src/jit-test/tests/basic/testAddInconvertibleObjectAny.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 function testAddInconvertibleObjectAny()
     2 {
     3   var count = 0;
     4   function toString()
     5   {
     6     ++count;
     7     if (count == 95)
     8       return {};
     9     return "" + count;
    10   }
    11   var o = {valueOf: undefined, toString: toString};
    13   var threw = false;
    14   try
    15   {
    16     for (var i = 0; i < 100; i++)
    17         var q = o + 5;
    18   }
    19   catch (e)
    20   {
    21     threw = true;
    22     if (i !== 94)
    23       return "expected i === 94, got " + i;
    24     if (q !== "945")
    25       return "expected q === '945', got " + q + " (type " + typeof q + ")";
    26     if (count !== 95)
    27       return "expected count === 95, got " + count;
    28   }
    29   if (!threw)
    30     return "expected throw with o + 5";
    32   return "pass";
    33 }
    34 assertEq(testAddInconvertibleObjectAny(), "pass");

mercurial