toolkit/devtools/server/tests/unit/test_breakpoint-14.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 a breakpoint or a debugger statement cause execution to pause even
     6  * in a stepped-over function.
     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-14.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           // Reached the breakpoint.
    40           do_check_eq(aPacket.frame.where.line, location.line);
    41           do_check_eq(aPacket.why.type, "breakpoint");
    42           do_check_neq(aPacket.why.type, "resumeLimit");
    44           gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
    45             // The frame is about to be popped while stepping.
    46             do_check_eq(aPacket.frame.where.line, location.line);
    47             do_check_neq(aPacket.why.type, "breakpoint");
    48             do_check_eq(aPacket.why.type, "resumeLimit");
    49             do_check_eq(aPacket.why.frameFinished.return.type, "undefined");
    51             gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
    52               // The foo function call frame was just popped from the stack.
    53               do_check_eq(gDebuggee.a, 1);
    54               do_check_eq(gDebuggee.b, undefined);
    55               do_check_eq(aPacket.frame.where.line, gDebuggee.line0 + 5);
    56               do_check_eq(aPacket.why.type, "resumeLimit");
    57               do_check_eq(aPacket.poppedFrames.length, 1);
    59               gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
    60                 // Check that the debugger statement wasn't the reason for this pause.
    61                 do_check_eq(aPacket.frame.where.line, gDebuggee.line0 + 6);
    62                 do_check_neq(aPacket.why.type, "debuggerStatement");
    63                 do_check_eq(aPacket.why.type, "resumeLimit");
    65                 gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
    66                   // Check that the debugger statement wasn't the reason for this pause.
    67                   do_check_eq(aPacket.frame.where.line, gDebuggee.line0 + 7);
    68                   do_check_neq(aPacket.why.type, "debuggerStatement");
    69                   do_check_eq(aPacket.why.type, "resumeLimit");
    71                   // Remove the breakpoint and finish.
    72                   bpClient.remove(() => gThreadClient.resume(() => finishClient(gClient)));
    74                 });
    75                 // Step past the debugger statement.
    76                 gThreadClient.stepOver();
    77               });
    78               // Step over the debugger statement.
    79               gThreadClient.stepOver();
    80             });
    81             // Get back to the frame above.
    82             gThreadClient.stepOver();
    83           });
    84           // Step to the end of the function call frame.
    85           gThreadClient.stepOver();
    86         });
    87         // Step over the function call.
    88         gThreadClient.stepOver();
    89       });
    90       // Step over to the next line with the function call.
    91       gThreadClient.stepOver();
    92     });
    93   });
    95   gDebuggee.eval("var line0 = Error().lineNumber;\n" +
    96                  "function foo() {\n" + // line0 + 1
    97                  "  this.a = 1;\n" +    // line0 + 2 <-- Breakpoint is set here.
    98                  "}\n" +                // line0 + 3
    99                  "debugger;\n" +        // line0 + 4
   100                  "foo();\n" +           // line0 + 5
   101                  "debugger;\n" +        // line0 + 6
   102                  "var b = 2;\n");       // line0 + 7
   103 }

mercurial