toolkit/devtools/server/tests/unit/test_trace_actor-08.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 the "depth" trace type.
     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: " + error);
    46     });
    47 }
    49 function start_trace()
    50 {
    51   let deferred = promise.defer();
    52   gTraceClient.startTrace(["depth", "name"], null, function() { deferred.resolve(); });
    53   return deferred.promise;
    54 }
    56 function eval_code()
    57 {
    58   gDebuggee.eval("(" + function iife() {
    59     function first() {
    60       second();
    61     }
    63     function second() {
    64       third();
    65     }
    67     function third() {
    68     }
    70     first();
    71   } + ")()");
    72 }
    74 function stop_trace()
    75 {
    76   let deferred = promise.defer();
    77   gTraceClient.stopTrace(null, function() { deferred.resolve(); });
    78   return deferred.promise;
    79 }
    81 function check_trace({ sequence, depth, name })
    82 {
    83   switch(sequence) {
    84   case 0:
    85     do_check_eq(name, "(eval)");
    86     // Fall through
    87   case 9:
    88     do_check_eq(depth, 0);
    89     break;
    91   case 1:
    92     do_check_eq(name, "iife");
    93     // Fall through
    94   case 8:
    95     do_check_eq(depth, 1);
    96     break;
    98   case 2:
    99     do_check_eq(name, "first");
   100     // Fall through
   101   case 7:
   102     do_check_eq(depth, 2);
   103     break;
   105   case 3:
   106     do_check_eq(name, "second");
   107     // Fall through
   108   case 6:
   109     do_check_eq(depth, 3);
   110     break;
   112   case 4:
   113     do_check_eq(name, "third");
   114     // Fall through
   115   case 5:
   116     do_check_eq(depth, 4);
   117     break;
   119   default:
   120     // Should have covered all sequences.
   121     do_check_true(false);
   122   }
   123 }

mercurial