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.

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

mercurial