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