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 permanently cache source maps. |
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 | setup_code(); |
michael@0 | 23 | }); |
michael@0 | 24 | }); |
michael@0 | 25 | do_test_pending(); |
michael@0 | 26 | } |
michael@0 | 27 | |
michael@0 | 28 | // The MAP_FILE_NAME is .txt so that the OS will definitely have an extension -> |
michael@0 | 29 | // content type mapping for the extension. If it doesn't (like .map or .json), |
michael@0 | 30 | // it logs console errors, which cause the test to fail. See bug 907839. |
michael@0 | 31 | const MAP_FILE_NAME = "temporary-generated.txt"; |
michael@0 | 32 | |
michael@0 | 33 | const TEMP_FILE_1 = "temporary1.js"; |
michael@0 | 34 | const TEMP_FILE_2 = "temporary2.js"; |
michael@0 | 35 | const TEMP_GENERATED_SOURCE = "temporary-generated.js"; |
michael@0 | 36 | |
michael@0 | 37 | function setup_code() { |
michael@0 | 38 | let node = new SourceNode(1, 0, |
michael@0 | 39 | getFileUrl(TEMP_FILE_1, true), |
michael@0 | 40 | "function temporary1() {}\n"); |
michael@0 | 41 | let { code, map } = node.toStringWithSourceMap({ |
michael@0 | 42 | file: getFileUrl(TEMP_GENERATED_SOURCE, true) |
michael@0 | 43 | }); |
michael@0 | 44 | |
michael@0 | 45 | code += "//# sourceMappingURL=" + getFileUrl(MAP_FILE_NAME, true); |
michael@0 | 46 | writeFile(MAP_FILE_NAME, map.toString()); |
michael@0 | 47 | |
michael@0 | 48 | Cu.evalInSandbox(code, |
michael@0 | 49 | gDebuggee, |
michael@0 | 50 | "1.8", |
michael@0 | 51 | getFileUrl(TEMP_GENERATED_SOURCE, true), |
michael@0 | 52 | 1); |
michael@0 | 53 | |
michael@0 | 54 | test_initial_sources(); |
michael@0 | 55 | } |
michael@0 | 56 | |
michael@0 | 57 | function test_initial_sources() { |
michael@0 | 58 | gThreadClient.getSources(function ({ error, sources }) { |
michael@0 | 59 | do_check_true(!error); |
michael@0 | 60 | do_check_eq(sources.length, 1); |
michael@0 | 61 | do_check_eq(sources[0].url, getFileUrl(TEMP_FILE_1, true)); |
michael@0 | 62 | setup_new_code(); |
michael@0 | 63 | }); |
michael@0 | 64 | } |
michael@0 | 65 | |
michael@0 | 66 | function setup_new_code() { |
michael@0 | 67 | let node = new SourceNode(1, 0, |
michael@0 | 68 | getFileUrl(TEMP_FILE_2, true), |
michael@0 | 69 | "function temporary2() {}\n"); |
michael@0 | 70 | let { code, map } = node.toStringWithSourceMap({ |
michael@0 | 71 | file: getFileUrl(TEMP_GENERATED_SOURCE, true) |
michael@0 | 72 | }); |
michael@0 | 73 | |
michael@0 | 74 | code += "\n//# sourceMappingURL=" + getFileUrl(MAP_FILE_NAME, true); |
michael@0 | 75 | writeFile(MAP_FILE_NAME, map.toString()); |
michael@0 | 76 | |
michael@0 | 77 | Cu.evalInSandbox(code, |
michael@0 | 78 | gDebuggee, |
michael@0 | 79 | "1.8", |
michael@0 | 80 | getFileUrl(TEMP_GENERATED_SOURCE, true), |
michael@0 | 81 | 1); |
michael@0 | 82 | |
michael@0 | 83 | gClient.addOneTimeListener("newSource", test_new_sources); |
michael@0 | 84 | } |
michael@0 | 85 | |
michael@0 | 86 | function test_new_sources() { |
michael@0 | 87 | gThreadClient.getSources(function ({ error, sources }) { |
michael@0 | 88 | do_check_true(!error); |
michael@0 | 89 | |
michael@0 | 90 | // Should now have TEMP_FILE_2 as a source. |
michael@0 | 91 | do_check_eq(sources.length, 2); |
michael@0 | 92 | let s = sources.filter(s => s.url === getFileUrl(TEMP_FILE_2, true))[0]; |
michael@0 | 93 | do_check_true(!!s); |
michael@0 | 94 | |
michael@0 | 95 | finish_test(); |
michael@0 | 96 | }); |
michael@0 | 97 | } |
michael@0 | 98 | |
michael@0 | 99 | function finish_test() { |
michael@0 | 100 | do_get_file(MAP_FILE_NAME).remove(false); |
michael@0 | 101 | finishClient(gClient); |
michael@0 | 102 | } |