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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* Any copyright is dedicated to the Public Domain.
     2    http://creativecommons.org/publicdomain/zero/1.0/ */
     4 /**
     5  * Check that execution doesn't pause twice while stepping, when encountering
     6  * either a breakpoint or a debugger statement.
     7  */
     9 var gDebuggee;
    10 var gClient;
    11 var gThreadClient;
    13 function run_test()
    14 {
    15   initTestDebuggerServer();
    16   gDebuggee = addTestGlobal("test-stack");
    17   gClient = new DebuggerClient(DebuggerServer.connectPipe());
    18   gClient.connect(function () {
    19     attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) {
    20       gThreadClient = aThreadClient;
    21       test_simple_breakpoint();
    22     });
    23   });
    24   do_test_pending();
    25 }
    27 function test_simple_breakpoint()
    28 {
    29   gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
    30     let path = getFilePath('test_breakpoint-13.js');
    31     let location = { url: path, line: gDebuggee.line0 + 2};
    32     gThreadClient.setBreakpoint(location, function (aResponse, bpClient) {
    33       gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
    34         // Check that the stepping worked.
    35         do_check_eq(aPacket.frame.where.line, gDebuggee.line0 + 5);
    36         do_check_eq(aPacket.why.type, "resumeLimit");
    38         gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
    39           // Entered the foo function call frame.
    40           do_check_eq(aPacket.frame.where.line, location.line);
    41           do_check_neq(aPacket.why.type, "breakpoint");
    42           do_check_eq(aPacket.why.type, "resumeLimit");
    44           gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
    45             // Check that the breakpoint wasn't the reason for this pause, but
    46             // that the frame is about to be popped while stepping.
    47             do_check_eq(aPacket.frame.where.line, location.line);
    48             do_check_neq(aPacket.why.type, "breakpoint");
    49             do_check_eq(aPacket.why.type, "resumeLimit");
    50             do_check_eq(aPacket.why.frameFinished.return.type, "undefined");
    52             gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
    53               // The foo function call frame was just popped from the stack.
    54               do_check_eq(gDebuggee.a, 1);
    55               do_check_eq(gDebuggee.b, undefined);
    56               do_check_eq(aPacket.frame.where.line, gDebuggee.line0 + 5);
    57               do_check_eq(aPacket.why.type, "resumeLimit");
    58               do_check_eq(aPacket.poppedFrames.length, 1);
    60               gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
    61                 // Check that the debugger statement wasn't the reason for this pause.
    62                 do_check_eq(aPacket.frame.where.line, gDebuggee.line0 + 6);
    63                 do_check_neq(aPacket.why.type, "debuggerStatement");
    64                 do_check_eq(aPacket.why.type, "resumeLimit");
    66                 gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
    67                   // Check that the debugger statement wasn't the reason for this pause.
    68                   do_check_eq(aPacket.frame.where.line, gDebuggee.line0 + 7);
    69                   do_check_neq(aPacket.why.type, "debuggerStatement");
    70                   do_check_eq(aPacket.why.type, "resumeLimit");
    72                   // Remove the breakpoint and finish.
    73                   bpClient.remove(() => gThreadClient.resume(() => finishClient(gClient)));
    75                 });
    76                 // Step past the debugger statement.
    77                 gThreadClient.stepIn();
    78               });
    79               // Step into the debugger statement.
    80               gThreadClient.stepIn();
    81             });
    82             // Get back to the frame above.
    83             gThreadClient.stepIn();
    84           });
    85           // Step to the end of the function call frame.
    86           gThreadClient.stepIn();
    87         });
    89         // Step into the function call.
    90         gThreadClient.stepIn();
    91       });
    92       // Step into the next line with the function call.
    93       gThreadClient.stepIn();
    94     });
    95   });
    97   gDebuggee.eval("var line0 = Error().lineNumber;\n" +
    98                  "function foo() {\n" + // line0 + 1
    99                  "  this.a = 1;\n" +    // line0 + 2 <-- Breakpoint is set here.
   100                  "}\n" +                // line0 + 3
   101                  "debugger;\n" +        // line0 + 4
   102                  "foo();\n" +           // line0 + 5
   103                  "debugger;\n" +        // line0 + 6
   104                  "var b = 2;\n");       // line0 + 7
   105 }

mercurial