Sat, 03 Jan 2015 20:18:00 +0100
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 * Test that we don't hit breakpoints in black boxed sources, and that when we
6 * unblack box the source again, the breakpoint hasn't disappeared and we will
7 * hit it again.
8 */
10 var gDebuggee;
11 var gClient;
12 var gThreadClient;
14 function run_test()
15 {
16 initTestDebuggerServer();
17 gDebuggee = addTestGlobal("test-black-box");
18 gClient = new DebuggerClient(DebuggerServer.connectPipe());
19 gClient.connect(function() {
20 attachTestTabAndResume(gClient, "test-black-box", function(aResponse, aTabClient, aThreadClient) {
21 gThreadClient = aThreadClient;
22 test_black_box();
23 });
24 });
25 do_test_pending();
26 }
28 const BLACK_BOXED_URL = "http://example.com/blackboxme.js";
29 const SOURCE_URL = "http://example.com/source.js";
31 function test_black_box()
32 {
33 gClient.addOneTimeListener("paused", function () {
34 gThreadClient.setBreakpoint({
35 url: BLACK_BOXED_URL,
36 line: 2
37 }, function (aResponse) {
38 do_check_true(!aResponse.error, "Should be able to set breakpoint.");
39 gThreadClient.resume(test_black_box_breakpoint);
40 });
41 });
43 Components.utils.evalInSandbox(
44 "" + function doStuff(k) { // line 1
45 let arg = 15; // line 2 - Break here
46 k(arg); // line 3
47 }, // line 4
48 gDebuggee,
49 "1.8",
50 BLACK_BOXED_URL,
51 1
52 );
54 Components.utils.evalInSandbox(
55 "" + function runTest() { // line 1
56 doStuff( // line 2
57 function (n) { // line 3
58 debugger; // line 5
59 } // line 6
60 ); // line 7
61 } // line 8
62 + "\n debugger;", // line 9
63 gDebuggee,
64 "1.8",
65 SOURCE_URL,
66 1
67 );
68 }
70 function test_black_box_breakpoint() {
71 gThreadClient.getSources(function ({error, sources}) {
72 do_check_true(!error, "Should not get an error: " + error);
73 let sourceClient = gThreadClient.source(sources.filter(s => s.url == BLACK_BOXED_URL)[0]);
74 sourceClient.blackBox(function ({error}) {
75 do_check_true(!error, "Should not get an error: " + error);
77 gClient.addOneTimeListener("paused", function (aEvent, aPacket) {
78 do_check_eq(aPacket.why.type, "debuggerStatement",
79 "We should pass over the breakpoint since the source is black boxed.");
80 gThreadClient.resume(test_unblack_box_breakpoint.bind(null, sourceClient));
81 });
82 gDebuggee.runTest();
83 });
84 });
85 }
87 function test_unblack_box_breakpoint(aSourceClient) {
88 aSourceClient.unblackBox(function ({error}) {
89 do_check_true(!error, "Should not get an error: " + error);
90 gClient.addOneTimeListener("paused", function (aEvent, aPacket) {
91 do_check_eq(aPacket.why.type, "breakpoint",
92 "We should hit the breakpoint again");
94 // We will hit the debugger statement on resume, so do this nastiness to skip over it.
95 gClient.addOneTimeListener(
96 "paused",
97 gThreadClient.resume.bind(
98 gThreadClient,
99 finishClient.bind(null, gClient)));
100 gThreadClient.resume();
101 });
102 gDebuggee.runTest();
103 });
104 }