toolkit/devtools/server/tests/unit/test_breakpoint-03.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 setting a breakpoint in a line without code will skip forward.
     6  */
     8 var gDebuggee;
     9 var gClient;
    10 var gThreadClient;
    12 function run_test()
    13 {
    14   initTestDebuggerServer();
    15   gDebuggee = addTestGlobal("test-stack");
    16   gClient = new DebuggerClient(DebuggerServer.connectPipe());
    17   gClient.connect(function () {
    18     attachTestTabAndResume(gClient,
    19                            "test-stack",
    20                            function (aResponse, aTabClient, aThreadClient) {
    21                              gThreadClient = aThreadClient;
    22                              test_skip_breakpoint();
    23                            });
    24   });
    25   do_test_pending();
    26 }
    28 function test_skip_breakpoint()
    29 {
    30   gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
    31     let path = getFilePath('test_breakpoint-03.js');
    32     let location = { url: path, line: gDebuggee.line0 + 3};
    33     gThreadClient.setBreakpoint(location, function (aResponse, bpClient) {
    34       // Check that the breakpoint has properly skipped forward one line.
    35       do_check_true(!!aResponse.actualLocation);
    36       do_check_eq(aResponse.actualLocation.url, location.url);
    37       do_check_eq(aResponse.actualLocation.line, location.line + 1);
    38       gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
    39         // Check the return value.
    40         do_check_eq(aPacket.type, "paused");
    41         do_check_eq(aPacket.frame.where.url, path);
    42         do_check_eq(aPacket.frame.where.line, location.line + 1);
    43         do_check_eq(aPacket.why.type, "breakpoint");
    44         do_check_eq(aPacket.why.actors[0], bpClient.actor);
    45         // Check that the breakpoint worked.
    46         do_check_eq(gDebuggee.a, 1);
    47         do_check_eq(gDebuggee.b, undefined);
    49         // Remove the breakpoint.
    50         bpClient.remove(function (aResponse) {
    51           gThreadClient.resume(function () {
    52             finishClient(gClient);
    53           });
    54         });
    56       });
    57       // Continue until the breakpoint is hit.
    58       gThreadClient.resume();
    60     });
    62   });
    64   gDebuggee.eval("var line0 = Error().lineNumber;\n" +
    65                  "debugger;\n" +      // line0 + 1
    66                  "var a = 1;\n" +     // line0 + 2
    67                  "// A comment.\n" +  // line0 + 3
    68                  "var b = 2;\n");     // line0 + 4
    69 }

mercurial