toolkit/devtools/server/tests/unit/test_breakpoint-18.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/devtools/server/tests/unit/test_breakpoint-18.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,73 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 +   http://creativecommons.org/publicdomain/zero/1.0/ */
     1.6 +
     1.7 +/**
     1.8 + * Check that we only break on offsets that are entry points for the line we are
     1.9 + * breaking on. Bug 907278.
    1.10 + */
    1.11 +
    1.12 +var gDebuggee;
    1.13 +var gClient;
    1.14 +var gThreadClient;
    1.15 +
    1.16 +function run_test()
    1.17 +{
    1.18 +  initTestDebuggerServer();
    1.19 +  gDebuggee = addTestGlobal("test-breakpoints");
    1.20 +  gDebuggee.console = { log: x => void x };
    1.21 +  gClient = new DebuggerClient(DebuggerServer.connectPipe());
    1.22 +  gClient.connect(function () {
    1.23 +    attachTestTabAndResume(gClient,
    1.24 +                           "test-breakpoints",
    1.25 +                           function (aResponse, aTabClient, aThreadClient) {
    1.26 +      gThreadClient = aThreadClient;
    1.27 +      setUpCode();
    1.28 +    });
    1.29 +  });
    1.30 +  do_test_pending();
    1.31 +}
    1.32 +
    1.33 +const URL = "test.js";
    1.34 +
    1.35 +function setUpCode() {
    1.36 +  gClient.addOneTimeListener("newSource", setBreakpoint);
    1.37 +  Cu.evalInSandbox(
    1.38 +    "" + function test() {
    1.39 +      console.log("foo bar");
    1.40 +      debugger;
    1.41 +    },
    1.42 +    gDebuggee,
    1.43 +    "1.8",
    1.44 +    URL
    1.45 +  );
    1.46 +}
    1.47 +
    1.48 +function setBreakpoint() {
    1.49 +  gClient.addOneTimeListener("resumed", runCode);
    1.50 +  gThreadClient.setBreakpoint({
    1.51 +    url: URL,
    1.52 +    line: 1
    1.53 +  }, ({ error }) => {
    1.54 +    do_check_true(!error);
    1.55 +  });
    1.56 +}
    1.57 +
    1.58 +function runCode() {
    1.59 +  gClient.addOneTimeListener("paused", testBPHit);
    1.60 +  gDebuggee.test();
    1.61 +}
    1.62 +
    1.63 +function testBPHit(event, { why }) {
    1.64 +  do_check_eq(why.type, "breakpoint");
    1.65 +  gClient.addOneTimeListener("paused", testDbgStatement);
    1.66 +  gThreadClient.resume();
    1.67 +}
    1.68 +
    1.69 +function testDbgStatement(event, { why }) {
    1.70 +  // Should continue to the debugger statement.
    1.71 +  do_check_eq(why.type, "debuggerStatement");
    1.72 +  // Not break on another offset from the same line (that isn't an entry point
    1.73 +  // to the line)
    1.74 +  do_check_neq(why.type, "breakpoint");
    1.75 +  finishClient(gClient);
    1.76 +}

mercurial