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 permanently cache source maps.
6 */
8 var gDebuggee;
9 var gClient;
10 var gThreadClient;
12 Components.utils.import("resource:///modules/devtools/SourceMap.jsm");
14 function run_test()
15 {
16 initTestDebuggerServer();
17 gDebuggee = addTestGlobal("test-source-map");
18 gClient = new DebuggerClient(DebuggerServer.connectPipe());
19 gClient.connect(function() {
20 attachTestTabAndResume(gClient, "test-source-map", function(aResponse, aTabClient, aThreadClient) {
21 gThreadClient = aThreadClient;
22 setup_code();
23 });
24 });
25 do_test_pending();
26 }
28 // The MAP_FILE_NAME is .txt so that the OS will definitely have an extension ->
29 // content type mapping for the extension. If it doesn't (like .map or .json),
30 // it logs console errors, which cause the test to fail. See bug 907839.
31 const MAP_FILE_NAME = "temporary-generated.txt";
33 const TEMP_FILE_1 = "temporary1.js";
34 const TEMP_FILE_2 = "temporary2.js";
35 const TEMP_GENERATED_SOURCE = "temporary-generated.js";
37 function setup_code() {
38 let node = new SourceNode(1, 0,
39 getFileUrl(TEMP_FILE_1, true),
40 "function temporary1() {}\n");
41 let { code, map } = node.toStringWithSourceMap({
42 file: getFileUrl(TEMP_GENERATED_SOURCE, true)
43 });
45 code += "//# sourceMappingURL=" + getFileUrl(MAP_FILE_NAME, true);
46 writeFile(MAP_FILE_NAME, map.toString());
48 Cu.evalInSandbox(code,
49 gDebuggee,
50 "1.8",
51 getFileUrl(TEMP_GENERATED_SOURCE, true),
52 1);
54 test_initial_sources();
55 }
57 function test_initial_sources() {
58 gThreadClient.getSources(function ({ error, sources }) {
59 do_check_true(!error);
60 do_check_eq(sources.length, 1);
61 do_check_eq(sources[0].url, getFileUrl(TEMP_FILE_1, true));
62 setup_new_code();
63 });
64 }
66 function setup_new_code() {
67 let node = new SourceNode(1, 0,
68 getFileUrl(TEMP_FILE_2, true),
69 "function temporary2() {}\n");
70 let { code, map } = node.toStringWithSourceMap({
71 file: getFileUrl(TEMP_GENERATED_SOURCE, true)
72 });
74 code += "\n//# sourceMappingURL=" + getFileUrl(MAP_FILE_NAME, true);
75 writeFile(MAP_FILE_NAME, map.toString());
77 Cu.evalInSandbox(code,
78 gDebuggee,
79 "1.8",
80 getFileUrl(TEMP_GENERATED_SOURCE, true),
81 1);
83 gClient.addOneTimeListener("newSource", test_new_sources);
84 }
86 function test_new_sources() {
87 gThreadClient.getSources(function ({ error, sources }) {
88 do_check_true(!error);
90 // Should now have TEMP_FILE_2 as a source.
91 do_check_eq(sources.length, 2);
92 let s = sources.filter(s => s.url === getFileUrl(TEMP_FILE_2, true))[0];
93 do_check_true(!!s);
95 finish_test();
96 });
97 }
99 function finish_test() {
100 do_get_file(MAP_FILE_NAME).remove(false);
101 finishClient(gClient);
102 }