toolkit/devtools/server/tests/unit/test_breakpoint-18.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  * Check that we only break on offsets that are entry points for the line we are
     6  * breaking on. Bug 907278.
     7  */
     9 var gDebuggee;
    10 var gClient;
    11 var gThreadClient;
    13 function run_test()
    14 {
    15   initTestDebuggerServer();
    16   gDebuggee = addTestGlobal("test-breakpoints");
    17   gDebuggee.console = { log: x => void x };
    18   gClient = new DebuggerClient(DebuggerServer.connectPipe());
    19   gClient.connect(function () {
    20     attachTestTabAndResume(gClient,
    21                            "test-breakpoints",
    22                            function (aResponse, aTabClient, aThreadClient) {
    23       gThreadClient = aThreadClient;
    24       setUpCode();
    25     });
    26   });
    27   do_test_pending();
    28 }
    30 const URL = "test.js";
    32 function setUpCode() {
    33   gClient.addOneTimeListener("newSource", setBreakpoint);
    34   Cu.evalInSandbox(
    35     "" + function test() {
    36       console.log("foo bar");
    37       debugger;
    38     },
    39     gDebuggee,
    40     "1.8",
    41     URL
    42   );
    43 }
    45 function setBreakpoint() {
    46   gClient.addOneTimeListener("resumed", runCode);
    47   gThreadClient.setBreakpoint({
    48     url: URL,
    49     line: 1
    50   }, ({ error }) => {
    51     do_check_true(!error);
    52   });
    53 }
    55 function runCode() {
    56   gClient.addOneTimeListener("paused", testBPHit);
    57   gDebuggee.test();
    58 }
    60 function testBPHit(event, { why }) {
    61   do_check_eq(why.type, "breakpoint");
    62   gClient.addOneTimeListener("paused", testDbgStatement);
    63   gThreadClient.resume();
    64 }
    66 function testDbgStatement(event, { why }) {
    67   // Should continue to the debugger statement.
    68   do_check_eq(why.type, "debuggerStatement");
    69   // Not break on another offset from the same line (that isn't an entry point
    70   // to the line)
    71   do_check_neq(why.type, "breakpoint");
    72   finishClient(gClient);
    73 }

mercurial