toolkit/devtools/server/tests/unit/test_conditional_breakpoint-03.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_conditional_breakpoint-03.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,62 @@
     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 conditional breakpoint when condition throws and make sure it is ignored
     1.9 + */
    1.10 +
    1.11 +var gDebuggee;
    1.12 +var gClient;
    1.13 +var gThreadClient;
    1.14 +
    1.15 +function run_test()
    1.16 +{
    1.17 +  initTestDebuggerServer();
    1.18 +  gDebuggee = addTestGlobal("test-conditional-breakpoint");
    1.19 +  gClient = new DebuggerClient(DebuggerServer.connectPipe());
    1.20 +  gClient.connect(function () {
    1.21 +    attachTestTabAndResume(gClient, "test-conditional-breakpoint", function (aResponse, aTabClient, aThreadClient) {
    1.22 +      gThreadClient = aThreadClient;
    1.23 +      test_simple_breakpoint();
    1.24 +    });
    1.25 +  });
    1.26 +  do_test_pending();
    1.27 +}
    1.28 +
    1.29 +function test_simple_breakpoint()
    1.30 +{
    1.31 +  gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
    1.32 +    gThreadClient.setBreakpoint({
    1.33 +      url: "test.js",
    1.34 +      line: 3,
    1.35 +      condition: "throw new Error()"
    1.36 +    }, function (aResponse, bpClient) {
    1.37 +      gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
    1.38 +        // Check the return value.
    1.39 +        do_check_eq(aPacket.why.type, "debuggerStatement");
    1.40 +        do_check_eq(aPacket.frame.where.line, 4);
    1.41 +
    1.42 +        // Remove the breakpoint.
    1.43 +        bpClient.remove(function (aResponse) {
    1.44 +          gThreadClient.resume(function () {
    1.45 +            finishClient(gClient);
    1.46 +          });
    1.47 +        });
    1.48 +
    1.49 +      });
    1.50 +      // Continue until the breakpoint is hit.
    1.51 +      gThreadClient.resume();
    1.52 +
    1.53 +    });
    1.54 +
    1.55 +  });
    1.56 +
    1.57 +  Components.utils.evalInSandbox("debugger;\n" +   // 1
    1.58 +                                 "var a = 1;\n" +  // 2
    1.59 +                                 "var b = 2;\n" +  // 3
    1.60 +                                 "debugger;",      // 4
    1.61 +                                 gDebuggee,
    1.62 +                                 "1.8",
    1.63 +                                 "test.js",
    1.64 +                                 1);
    1.65 +}

mercurial