toolkit/devtools/server/tests/unit/test_dbgclient_debuggerstatement.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 Cu.import("resource://gre/modules/devtools/dbg-server.jsm");
     5 Cu.import("resource://gre/modules/devtools/dbg-client.jsm");
     7 var gClient;
     8 var gTabClient;
     9 var gDebuggee;
    11 function run_test()
    12 {
    13   initTestDebuggerServer();
    14   gDebuggee = testGlobal("test-1");
    15   DebuggerServer.addTestGlobal(gDebuggee);
    17   let transport = DebuggerServer.connectPipe();
    18   gClient = new DebuggerClient(transport);
    19   gClient.connect(function(aType, aTraits) {
    20     attachTestTab(gClient, "test-1", function(aReply, aTabClient) {
    21       gTabClient = aTabClient;
    22       test_threadAttach(aReply.threadActor);
    23     });
    24   });
    25   do_test_pending();
    26 }
    28 function test_threadAttach(aThreadActorID)
    29 {
    30   do_print("Trying to attach to thread " + aThreadActorID);
    31   gTabClient.attachThread({}, function(aResponse, aThreadClient) {
    32     do_check_eq(aThreadClient.state, "paused");
    33     do_check_eq(aThreadClient.actor, aThreadActorID);
    34     aThreadClient.resume(function() {
    35       do_check_eq(aThreadClient.state, "attached");
    36       test_debugger_statement(aThreadClient);
    37     });
    38   });
    39 }
    41 function test_debugger_statement(aThreadClient)
    42 {
    43   aThreadClient.addListener("paused", function(aEvent, aPacket) {
    44     do_check_eq(aThreadClient.state, "paused");
    45     // Reach around the protocol to check that the debuggee is in the state
    46     // we expect.
    47     do_check_true(gDebuggee.a);
    48     do_check_false(gDebuggee.b);
    50     let xpcInspector = Cc["@mozilla.org/jsinspector;1"].getService(Ci.nsIJSInspector);
    51     do_check_eq(xpcInspector.eventLoopNestLevel, 1);
    53     aThreadClient.resume(cleanup);
    54   });
    56   Cu.evalInSandbox("var a = true; var b = false; debugger; var b = true;", gDebuggee);
    58   // Now make sure that we've run the code after the debugger statement...
    59   do_check_true(gDebuggee.b);
    60 }
    62 function cleanup()
    63 {
    64   gClient.addListener("closed", function(aEvent) {
    65     do_test_finished();
    66   });
    68   try {
    69     let xpcInspector = Cc["@mozilla.org/jsinspector;1"].getService(Ci.nsIJSInspector);
    70     do_check_eq(xpcInspector.eventLoopNestLevel, 0);
    71   } catch(e) {
    72     dump(e);
    73   }
    75   gClient.close();
    76 }

mercurial