toolkit/devtools/server/tests/unit/test_breakpoint-12.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.

michael@0 1 /* Any copyright is dedicated to the Public Domain.
michael@0 2 http://creativecommons.org/publicdomain/zero/1.0/ */
michael@0 3
michael@0 4 /**
michael@0 5 * Make sure that setting a breakpoint twice in a line without bytecodes works
michael@0 6 * as expected.
michael@0 7 */
michael@0 8
michael@0 9 const NUM_BREAKPOINTS = 10;
michael@0 10 var gDebuggee;
michael@0 11 var gClient;
michael@0 12 var gThreadClient;
michael@0 13 var gPath = getFilePath('test_breakpoint-12.js');
michael@0 14 var gBpActor;
michael@0 15 var gCount = 1;
michael@0 16
michael@0 17 function run_test()
michael@0 18 {
michael@0 19 initTestDebuggerServer();
michael@0 20 gDebuggee = addTestGlobal("test-stack");
michael@0 21 gClient = new DebuggerClient(DebuggerServer.connectPipe());
michael@0 22 gClient.connect(function () {
michael@0 23 attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) {
michael@0 24 gThreadClient = aThreadClient;
michael@0 25 test_child_skip_breakpoint();
michael@0 26 });
michael@0 27 });
michael@0 28 do_test_pending();
michael@0 29 }
michael@0 30
michael@0 31 function test_child_skip_breakpoint()
michael@0 32 {
michael@0 33 gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
michael@0 34 let location = { url: gPath, line: gDebuggee.line0 + 3};
michael@0 35 gThreadClient.setBreakpoint(location, function (aResponse, bpClient) {
michael@0 36 // Check that the breakpoint has properly skipped forward one line.
michael@0 37 do_check_eq(aResponse.actualLocation.url, location.url);
michael@0 38 do_check_eq(aResponse.actualLocation.line, location.line + 1);
michael@0 39 gBpActor = aResponse.actor;
michael@0 40
michael@0 41 // Set more breakpoints at the same location.
michael@0 42 set_breakpoints(location);
michael@0 43 });
michael@0 44
michael@0 45 });
michael@0 46
michael@0 47 gDebuggee.eval("var line0 = Error().lineNumber;\n" +
michael@0 48 "function foo() {\n" + // line0 + 1
michael@0 49 " this.a = 1;\n" + // line0 + 2
michael@0 50 " // A comment.\n" + // line0 + 3
michael@0 51 " this.b = 2;\n" + // line0 + 4
michael@0 52 "}\n" + // line0 + 5
michael@0 53 "debugger;\n" + // line0 + 6
michael@0 54 "foo();\n"); // line0 + 7
michael@0 55 }
michael@0 56
michael@0 57 // Set many breakpoints at the same location.
michael@0 58 function set_breakpoints(location) {
michael@0 59 do_check_neq(gCount, NUM_BREAKPOINTS);
michael@0 60 gThreadClient.setBreakpoint(location, function (aResponse, bpClient) {
michael@0 61 // Check that the breakpoint has properly skipped forward one line.
michael@0 62 do_check_eq(aResponse.actualLocation.url, location.url);
michael@0 63 do_check_eq(aResponse.actualLocation.line, location.line + 1);
michael@0 64 // Check that the same breakpoint actor was returned.
michael@0 65 do_check_eq(aResponse.actor, gBpActor);
michael@0 66
michael@0 67 if (++gCount < NUM_BREAKPOINTS) {
michael@0 68 set_breakpoints(location);
michael@0 69 return;
michael@0 70 }
michael@0 71
michael@0 72 // After setting all the breakpoints, check that only one has effectively
michael@0 73 // remained.
michael@0 74 gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
michael@0 75 // Check the return value.
michael@0 76 do_check_eq(aPacket.type, "paused");
michael@0 77 do_check_eq(aPacket.frame.where.url, gPath);
michael@0 78 do_check_eq(aPacket.frame.where.line, location.line + 1);
michael@0 79 do_check_eq(aPacket.why.type, "breakpoint");
michael@0 80 do_check_eq(aPacket.why.actors[0], bpClient.actor);
michael@0 81 // Check that the breakpoint worked.
michael@0 82 do_check_eq(gDebuggee.a, 1);
michael@0 83 do_check_eq(gDebuggee.b, undefined);
michael@0 84
michael@0 85 gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
michael@0 86 // We don't expect any more pauses after the breakpoint was hit once.
michael@0 87 do_check_true(false);
michael@0 88 });
michael@0 89 gThreadClient.resume(function () {
michael@0 90 // Give any remaining breakpoints a chance to trigger.
michael@0 91 do_timeout(1000, finishClient.bind(null, gClient));
michael@0 92 });
michael@0 93
michael@0 94 });
michael@0 95 // Continue until the breakpoint is hit.
michael@0 96 gThreadClient.resume();
michael@0 97 });
michael@0 98
michael@0 99 }

mercurial