toolkit/devtools/server/tests/unit/test_trace_actor-09.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 /* Any copyright is dedicated to the Public Domain.
     2  http://creativecommons.org/publicdomain/zero/1.0/ */
     4 /**
     5  * Test that self-hosted functions aren't traced and don't add depth.
     6  */
     8 var gDebuggee;
     9 var gClient;
    10 var gTraceClient;
    12 function run_test()
    13 {
    14   initTestTracerServer();
    15   gDebuggee = addTestGlobal("test-tracer-actor");
    16   gClient = new DebuggerClient(DebuggerServer.connectPipe());
    17   gClient.connect(function() {
    18     attachTestTab(gClient, "test-tracer-actor", function(aResponse, aTabClient) {
    19       gClient.attachTracer(aResponse.traceActor, function(aResponse, aTraceClient) {
    20         gTraceClient = aTraceClient;
    21         test_frame_depths();
    22       });
    23     });
    24   });
    25   do_test_pending();
    26 }
    28 function test_frame_depths()
    29 {
    30   const tracesStopped = promise.defer();
    31   gClient.addListener("traces", (aEvent, { traces }) => {
    32     for (let t of traces) {
    33       check_trace(t);
    34     }
    35     tracesStopped.resolve();
    36   });
    38   start_trace()
    39     .then(eval_code)
    40     .then(() => tracesStopped.promise)
    41     .then(stop_trace)
    42     .then(function() {
    43       finishClient(gClient);
    44     }).then(null, error => {
    45       do_check_true(false, "Should not get an error, got: " + DevToolsUtils.safeErrorString(error));
    46     });
    47 }
    49 function start_trace()
    50 {
    51   let deferred = promise.defer();
    52   gTraceClient.startTrace(["depth", "name", "location"], null, function() { deferred.resolve(); });
    53   return deferred.promise;
    54 }
    56 function eval_code()
    57 {
    58   gDebuggee.eval("(" + function iife() {
    59     [1].forEach(function noop() {});
    60     for (let x of [1]) {}
    61   } + ")()");
    62 }
    64 function stop_trace()
    65 {
    66   let deferred = promise.defer();
    67   gTraceClient.stopTrace(null, function() { deferred.resolve(); });
    68   return deferred.promise;
    69 }
    71 function check_trace({ sequence, depth, name, location })
    72 {
    73   if (location) {
    74     do_check_true(location.url !== "self-hosted");
    75   }
    77   switch(sequence) {
    78   case 0:
    79     do_check_eq(name, "(eval)");
    80   case 5:
    81     do_check_eq(depth, 0);
    82     break;
    84   case 1:
    85     do_check_eq(name, "iife");
    86   case 4:
    87     do_check_eq(depth, 1);
    88     break;
    90   case 2:
    91     do_check_eq(name, "noop");
    92   case 3:
    93     do_check_eq(depth, 2);
    94     break;
    96   default:
    97     // Should have covered all sequences.
    98     do_check_true(false);
    99   }
   100 }

mercurial