toolkit/devtools/server/tests/unit/test_trace_actor-07.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  * Tests that the exit frame packets get the correct `why` value.
     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_exit_frame_whys();
    22       });
    23     });
    24   });
    25   do_test_pending();
    26 }
    28 function test_exit_frame_whys()
    29 {
    30   gClient.addListener("traces", (aEvent, { traces }) => {
    31     for (let t of traces) {
    32       if (t.type == "exitedFrame") {
    33         check_trace(t);
    34       }
    35     }
    36   });
    38   start_trace()
    39     .then(eval_code)
    40     .then(stop_trace)
    41     .then(function() {
    42       finishClient(gClient);
    43     }).then(null, error => {
    44       do_check_true(false, "Should not get an error, got: " + error);
    45     });
    46 }
    48 function start_trace()
    49 {
    50   let deferred = promise.defer();
    51   gTraceClient.startTrace(["name"], null, function() { deferred.resolve(); });
    52   return deferred.promise;
    53 }
    55 function eval_code()
    56 {
    57   gDebuggee.eval("(" + function() {
    58     function thrower() {
    59       throw new Error();
    60     }
    62     function* yielder() {
    63       yield 1;
    64     }
    66     function returner() {
    67       return 1;
    68     }
    70     try {
    71       thrower();
    72     } catch(e) {}
    74     // XXX bug 923729: Can't test yielding yet.
    75     // for (let x of yielder()) {
    76     //   break;
    77     // }
    79     returner();
    80   } + ")()");
    81 }
    83 function stop_trace()
    84 {
    85   let deferred = promise.defer();
    86   gTraceClient.stopTrace(null, function() { deferred.resolve(); });
    87   return deferred.promise;
    88 }
    90 function check_trace(aEvent, { sequence, why })
    91 {
    92   switch(sequence) {
    93   case 3:
    94     do_check_eq(why, "throw");
    95     break;
    96   case 5:
    97     do_check_eq(why, "return");
    98     break;
    99   }
   100 }

mercurial