js/src/tests/js1_8/extensions/regress-422269.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 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 //-----------------------------------------------------------------------------
     7 var BUGNUMBER = 422269;
     8 var summary = 'Compile-time let block should not capture runtime references';
     9 var actual = 'referenced only by stack and closure';
    10 var expect = 'referenced only by stack and closure';
    13 //-----------------------------------------------------------------------------
    14 test();
    16 //-----------------------------------------------------------------------------
    18 function test()
    19 {
    20   enterFunc ('test');
    21   printBugNumber(BUGNUMBER);
    22   printStatus (summary);
    24   function f()
    25   {
    26     let m = {sin: Math.sin};
    27     (function holder() { m.sin(1); })();
    28     return m;
    29   }
    31   if (typeof findReferences == 'undefined')
    32   {
    33     expect = actual = 'Test skipped';
    34     print('Test skipped. Requires findReferences function.');
    35   }
    36   else
    37   {
    38     var x = f();
    39     var refs = findReferences(x);
    41     // At this point, x should only be referenced from the stack --- the
    42     // variable 'x' itself, and any random things the conservative scanner
    43     // finds --- and possibly from the 'holder' closure, which could itself
    44     // be held alive for random reasons. Remove those from the refs list, and 
    45     // then complain if anything is left.
    46     for (var edge in refs) {
    47       // Remove references from roots, like the stack.
    48       if (refs[edge].every(function (r) r === null))
    49         delete refs[edge];
    50       // Remove references from the closure, which could be held alive for
    51       // random reasons.
    52       else if (refs[edge].length === 1 &&
    53                typeof refs[edge][0] === "function" &&
    54                refs[edge][0].name === "holder")
    55         delete refs[edge];
    56     }
    58     if (Object.keys(refs).length != 0)
    59         actual = "unexpected references to the result of f: " + Object.keys(refs).join(", ");
    60   }
    61   reportCompare(expect, actual, summary);
    63   exitFunc ('test');
    64 }

mercurial