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 that source maps and breakpoints work with minified javascript. |
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_minified(); |
michael@0 | 23 | }); |
michael@0 | 24 | }); |
michael@0 | 25 | do_test_pending(); |
michael@0 | 26 | } |
michael@0 | 27 | |
michael@0 | 28 | function test_minified() |
michael@0 | 29 | { |
michael@0 | 30 | let newSourceFired = false; |
michael@0 | 31 | |
michael@0 | 32 | gClient.addOneTimeListener("newSource", function _onNewSource(aEvent, aPacket) { |
michael@0 | 33 | do_check_eq(aEvent, "newSource"); |
michael@0 | 34 | do_check_eq(aPacket.type, "newSource"); |
michael@0 | 35 | do_check_true(!!aPacket.source); |
michael@0 | 36 | |
michael@0 | 37 | do_check_eq(aPacket.source.url, "http://example.com/foo.js", |
michael@0 | 38 | "The new source should be foo.js"); |
michael@0 | 39 | do_check_eq(aPacket.source.url.indexOf("foo.min.js"), -1, |
michael@0 | 40 | "The new source should not be the minified file"); |
michael@0 | 41 | |
michael@0 | 42 | newSourceFired = true; |
michael@0 | 43 | }); |
michael@0 | 44 | |
michael@0 | 45 | gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { |
michael@0 | 46 | do_check_eq(aEvent, "paused"); |
michael@0 | 47 | do_check_eq(aPacket.why.type, "debuggerStatement"); |
michael@0 | 48 | |
michael@0 | 49 | const location = { |
michael@0 | 50 | url: "http://example.com/foo.js", |
michael@0 | 51 | line: 5 |
michael@0 | 52 | }; |
michael@0 | 53 | |
michael@0 | 54 | gThreadClient.setBreakpoint(location, function (aResponse, bpClient) { |
michael@0 | 55 | do_check_true(!aResponse.error); |
michael@0 | 56 | testHitBreakpoint(); |
michael@0 | 57 | }); |
michael@0 | 58 | }); |
michael@0 | 59 | |
michael@0 | 60 | // This is the original foo.js, which was then minified with uglifyjs version |
michael@0 | 61 | // 2.2.5 and the "--mangle" option. |
michael@0 | 62 | // |
michael@0 | 63 | // (function () { |
michael@0 | 64 | // debugger; |
michael@0 | 65 | // function foo(n) { |
michael@0 | 66 | // var bar = n + n; |
michael@0 | 67 | // var unused = null; |
michael@0 | 68 | // return bar; |
michael@0 | 69 | // } |
michael@0 | 70 | // for (var i = 0; i < 10; i++) { |
michael@0 | 71 | // foo(i); |
michael@0 | 72 | // } |
michael@0 | 73 | // }()); |
michael@0 | 74 | |
michael@0 | 75 | let code = '(function(){debugger;function r(r){var n=r+r;var u=null;return n}for(var n=0;n<10;n++){r(n)}})();\n//# sourceMappingURL=data:text/json,{"file":"foo.min.js","version":3,"sources":["foo.js"],"names":["foo","n","bar","unused","i"],"mappings":"CAAC,WACC,QACA,SAASA,GAAIC,GACX,GAAIC,GAAMD,EAAIA,CACd,IAAIE,GAAS,IACb,OAAOD,GAET,IAAK,GAAIE,GAAI,EAAGA,EAAI,GAAIA,IAAK,CAC3BJ,EAAII"}'; |
michael@0 | 76 | |
michael@0 | 77 | Components.utils.evalInSandbox(code, gDebuggee, "1.8", |
michael@0 | 78 | "http://example.com/foo.min.js", 1); |
michael@0 | 79 | } |
michael@0 | 80 | |
michael@0 | 81 | function testHitBreakpoint(timesHit=0) { |
michael@0 | 82 | gClient.addOneTimeListener("paused", function (aEvent, aPacket) { |
michael@0 | 83 | ++timesHit; |
michael@0 | 84 | |
michael@0 | 85 | do_check_eq(aEvent, "paused"); |
michael@0 | 86 | do_check_eq(aPacket.why.type, "breakpoint"); |
michael@0 | 87 | |
michael@0 | 88 | if (timesHit === 10) { |
michael@0 | 89 | gThreadClient.resume(() => finishClient(gClient)); |
michael@0 | 90 | } else { |
michael@0 | 91 | testHitBreakpoint(timesHit); |
michael@0 | 92 | } |
michael@0 | 93 | }); |
michael@0 | 94 | |
michael@0 | 95 | gThreadClient.resume(); |
michael@0 | 96 | } |