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 | * Check setting breakpoints in source mapped sources. |
michael@0 | 6 | */ |
michael@0 | 7 | |
michael@0 | 8 | var gDebuggee; |
michael@0 | 9 | var gClient; |
michael@0 | 10 | var gThreadClient; |
michael@0 | 11 | |
michael@0 | 12 | Components.utils.import('resource:///modules/devtools/SourceMap.jsm'); |
michael@0 | 13 | |
michael@0 | 14 | function run_test() |
michael@0 | 15 | { |
michael@0 | 16 | initTestDebuggerServer(); |
michael@0 | 17 | gDebuggee = addTestGlobal("test-source-map"); |
michael@0 | 18 | gClient = new DebuggerClient(DebuggerServer.connectPipe()); |
michael@0 | 19 | gClient.connect(function() { |
michael@0 | 20 | attachTestTabAndResume(gClient, "test-source-map", function(aResponse, aTabClient, aThreadClient) { |
michael@0 | 21 | gThreadClient = aThreadClient; |
michael@0 | 22 | test_simple_source_map(); |
michael@0 | 23 | }); |
michael@0 | 24 | }); |
michael@0 | 25 | do_test_pending(); |
michael@0 | 26 | } |
michael@0 | 27 | |
michael@0 | 28 | function testBreakpointMapping(aName, aCallback) |
michael@0 | 29 | { |
michael@0 | 30 | // Pause so we can set a breakpoint. |
michael@0 | 31 | gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { |
michael@0 | 32 | do_check_true(!aPacket.error); |
michael@0 | 33 | do_check_eq(aPacket.why.type, "debuggerStatement"); |
michael@0 | 34 | |
michael@0 | 35 | gThreadClient.setBreakpoint({ |
michael@0 | 36 | url: "http://example.com/www/js/" + aName + ".js", |
michael@0 | 37 | // Setting the breakpoint on an empty line so that it is pushed down one |
michael@0 | 38 | // line and we can check the source mapped actualLocation later. |
michael@0 | 39 | line: 3, |
michael@0 | 40 | column: 0 |
michael@0 | 41 | }, function (aResponse) { |
michael@0 | 42 | do_check_true(!aResponse.error); |
michael@0 | 43 | |
michael@0 | 44 | // Actual location should come back source mapped still so that |
michael@0 | 45 | // breakpoints are displayed in the UI correctly, etc. |
michael@0 | 46 | do_check_eq(aResponse.actualLocation.line, 4); |
michael@0 | 47 | do_check_eq(aResponse.actualLocation.url, |
michael@0 | 48 | "http://example.com/www/js/" + aName + ".js"); |
michael@0 | 49 | |
michael@0 | 50 | // The eval will cause us to resume, then we get an unsolicited pause |
michael@0 | 51 | // because of our breakpoint, we resume again to finish the eval, and |
michael@0 | 52 | // finally receive our last pause which has the result of the client |
michael@0 | 53 | // evaluation. |
michael@0 | 54 | gThreadClient.eval(null, aName + "()", function (aResponse) { |
michael@0 | 55 | do_check_true(!aResponse.error, "Shouldn't be an error resuming to eval"); |
michael@0 | 56 | do_check_eq(aResponse.type, "resumed"); |
michael@0 | 57 | |
michael@0 | 58 | gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { |
michael@0 | 59 | do_check_eq(aPacket.why.type, "breakpoint"); |
michael@0 | 60 | // Assert that we paused because of the breakpoint at the correct |
michael@0 | 61 | // location in the code by testing that the value of `ret` is still |
michael@0 | 62 | // undefined. |
michael@0 | 63 | do_check_eq(aPacket.frame.environment.bindings.variables.ret.value.type, |
michael@0 | 64 | "undefined"); |
michael@0 | 65 | |
michael@0 | 66 | gThreadClient.resume(function (aResponse) { |
michael@0 | 67 | do_check_true(!aResponse.error); |
michael@0 | 68 | |
michael@0 | 69 | gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { |
michael@0 | 70 | do_check_eq(aPacket.why.type, "clientEvaluated"); |
michael@0 | 71 | do_check_eq(aPacket.why.frameFinished.return, aName); |
michael@0 | 72 | |
michael@0 | 73 | gThreadClient.resume(function (aResponse) { |
michael@0 | 74 | do_check_true(!aResponse.error); |
michael@0 | 75 | aCallback(); |
michael@0 | 76 | }); |
michael@0 | 77 | }); |
michael@0 | 78 | }); |
michael@0 | 79 | }); |
michael@0 | 80 | }); |
michael@0 | 81 | }); |
michael@0 | 82 | }); |
michael@0 | 83 | |
michael@0 | 84 | gDebuggee.eval("(" + function () { |
michael@0 | 85 | debugger; |
michael@0 | 86 | } + "());"); |
michael@0 | 87 | } |
michael@0 | 88 | |
michael@0 | 89 | function test_simple_source_map() |
michael@0 | 90 | { |
michael@0 | 91 | let expectedSources = new Set([ |
michael@0 | 92 | "http://example.com/www/js/a.js", |
michael@0 | 93 | "http://example.com/www/js/b.js", |
michael@0 | 94 | "http://example.com/www/js/c.js" |
michael@0 | 95 | ]); |
michael@0 | 96 | |
michael@0 | 97 | gClient.addListener("newSource", function _onNewSource(aEvent, aPacket) { |
michael@0 | 98 | expectedSources.delete(aPacket.source.url); |
michael@0 | 99 | if (expectedSources.size > 0) { |
michael@0 | 100 | return; |
michael@0 | 101 | } |
michael@0 | 102 | gClient.removeListener("newSource", _onNewSource); |
michael@0 | 103 | |
michael@0 | 104 | testBreakpointMapping("a", function () { |
michael@0 | 105 | testBreakpointMapping("b", function () { |
michael@0 | 106 | testBreakpointMapping("c", function () { |
michael@0 | 107 | finishClient(gClient); |
michael@0 | 108 | }); |
michael@0 | 109 | }); |
michael@0 | 110 | }); |
michael@0 | 111 | }); |
michael@0 | 112 | |
michael@0 | 113 | let a = new SourceNode(null, null, null, [ |
michael@0 | 114 | new SourceNode(1, 0, "a.js", "function a() {\n"), |
michael@0 | 115 | new SourceNode(2, 0, "a.js", " var ret;\n"), |
michael@0 | 116 | new SourceNode(3, 0, "a.js", " // Empty line\n"), |
michael@0 | 117 | new SourceNode(4, 0, "a.js", " ret = 'a';\n"), |
michael@0 | 118 | new SourceNode(5, 0, "a.js", " return ret;\n"), |
michael@0 | 119 | new SourceNode(6, 0, "a.js", "}\n") |
michael@0 | 120 | ]); |
michael@0 | 121 | let b = new SourceNode(null, null, null, [ |
michael@0 | 122 | new SourceNode(1, 0, "b.js", "function b() {\n"), |
michael@0 | 123 | new SourceNode(2, 0, "b.js", " var ret;\n"), |
michael@0 | 124 | new SourceNode(3, 0, "b.js", " // Empty line\n"), |
michael@0 | 125 | new SourceNode(4, 0, "b.js", " ret = 'b';\n"), |
michael@0 | 126 | new SourceNode(5, 0, "b.js", " return ret;\n"), |
michael@0 | 127 | new SourceNode(6, 0, "b.js", "}\n") |
michael@0 | 128 | ]); |
michael@0 | 129 | let c = new SourceNode(null, null, null, [ |
michael@0 | 130 | new SourceNode(1, 0, "c.js", "function c() {\n"), |
michael@0 | 131 | new SourceNode(2, 0, "c.js", " var ret;\n"), |
michael@0 | 132 | new SourceNode(3, 0, "c.js", " // Empty line\n"), |
michael@0 | 133 | new SourceNode(4, 0, "c.js", " ret = 'c';\n"), |
michael@0 | 134 | new SourceNode(5, 0, "c.js", " return ret;\n"), |
michael@0 | 135 | new SourceNode(6, 0, "c.js", "}\n") |
michael@0 | 136 | ]); |
michael@0 | 137 | |
michael@0 | 138 | let { code, map } = (new SourceNode(null, null, null, [ |
michael@0 | 139 | a, b, c |
michael@0 | 140 | ])).toStringWithSourceMap({ |
michael@0 | 141 | file: "http://example.com/www/js/abc.js", |
michael@0 | 142 | sourceRoot: "http://example.com/www/js/" |
michael@0 | 143 | }); |
michael@0 | 144 | |
michael@0 | 145 | code += "//# sourceMappingURL=data:text/json;base64," + btoa(map.toString()); |
michael@0 | 146 | |
michael@0 | 147 | Components.utils.evalInSandbox(code, gDebuggee, "1.8", |
michael@0 | 148 | "http://example.com/www/js/abc.js", 1); |
michael@0 | 149 | } |