js/src/jit-test/tests/debug/Environment-identity-02.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 // frame.environment is different for different activations of a scope.
     3 var g = newGlobal();
     4 var dbg = Debugger(g);
     5 g.eval("function h() { debugger; }");
     6 var arr;
     7 dbg.onDebuggerStatement = function (hframe) {
     8     var e = hframe.older.environment;
     9     assertEq(arr.indexOf(e), -1);
    10     arr.push(e);
    11 };
    13 function test(code, expectedHits) {
    14     arr = [];
    15     g.eval(code);
    16     assertEq(arr.length, expectedHits);
    17 }
    19 // two separate calls to a function
    20 test("(function () { var f = function (a) { h(); return a; }; f(1); f(2); })();", 2);
    22 // recursive calls to a function
    23 test("(function f(n) { h(); return n < 2 ? 1 : n * f(n - 1); })(3);", 3);
    25 // separate visits to a block in the same call frame
    26 test("(function () { for (var i = 0; i < 3; i++) { let j = i * 4; h(); }})();", 3);
    28 // two strict direct eval calls in the same function scope
    29 test("(function () { 'use strict'; for (var i = 0; i < 3; i++) eval('h();'); })();", 3);

mercurial