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 * Simple tests for "location", "callsite", "time", "parameterNames",
6 * "arguments", and "return" trace types.
7 */
9 var gDebuggee;
10 var gClient;
11 var gTraceClient;
13 function run_test()
14 {
15 initTestTracerServer();
16 gDebuggee = addTestGlobal("test-tracer-actor");
17 gClient = new DebuggerClient(DebuggerServer.connectPipe());
18 gClient.connect(function() {
19 attachTestTab(gClient, "test-tracer-actor", function(aResponse, aTabClient) {
20 gClient.attachTracer(aResponse.traceActor, function(aResponse, aTraceClient) {
21 gTraceClient = aTraceClient;
22 test_enter_exit_frame();
23 });
24 });
25 });
26 do_test_pending();
27 }
29 function check_number(value)
30 {
31 do_check_eq(typeof value, "number");
32 do_check_true(!isNaN(value));
33 }
35 function check_location(actual, expected)
36 {
37 do_check_eq(typeof actual, "object");
39 check_number(actual.line);
40 check_number(actual.column);
42 do_check_eq(actual.url, expected.url);
43 do_check_eq(actual.line, expected.line);
44 do_check_eq(actual.column, expected.column);
46 }
48 function test_enter_exit_frame()
49 {
50 let traces = [];
51 let traceStopped = promise.defer();
53 gClient.addListener("traces", function(aEvent, aPacket) {
54 for (let t of aPacket.traces) {
55 if (t.type == "enteredFrame") {
56 do_check_eq(typeof t.name, "string");
57 do_check_eq(typeof t.location, "object");
59 check_number(t.sequence);
60 check_number(t.time);
61 check_number(t.location.line);
62 check_number(t.location.column);
63 if (t.callsite) {
64 check_number(t.callsite.line);
65 check_number(t.callsite.column);
66 }
67 } else {
68 check_number(t.sequence);
69 check_number(t.time);
70 }
72 traces[t.sequence] = t;
73 if (traces.length === 4) {
74 traceStopped.resolve();
75 }
76 }
77 });
79 start_trace()
80 .then(eval_code)
81 .then(() => traceStopped.promise)
82 .then(stop_trace)
83 .then(function() {
84 let url = getFileUrl("tracerlocations.js");
86 check_location(traces[0].location, { url: url, line: 1, column: 0 });
88 do_check_eq(traces[1].name, "foo");
90 // XXX: foo's definition is at tracerlocations.js:3:0, but Debugger.Script
91 // does not provide complete definition locations (bug 901138). Therefore,
92 // we use the first statement in the function (tracerlocations.js:4:2) as
93 // an approximation.
94 //
95 // However, |column| will always be 0 until we can get bug 863089
96 // fixed.
97 check_location(traces[1].location, { url: url, line: 4, column: 0 });
98 check_location(traces[1].callsite, { url: url, line: 8, column: 0 });
100 do_check_eq(typeof traces[1].parameterNames, "object");
101 do_check_eq(traces[1].parameterNames.length, 1);
102 do_check_eq(traces[1].parameterNames[0], "x");
104 do_check_eq(typeof traces[1].arguments, "object");
105 do_check_true(Array.isArray(traces[1].arguments));
106 do_check_eq(traces[1].arguments.length, 1);
107 do_check_eq(traces[1].arguments[0], 42);
109 do_check_eq(typeof traces[2].return, "string");
110 do_check_eq(traces[2].return, "bar");
112 finishClient(gClient);
113 }, error => {
114 DevToolsUtils.reportException("test_trace_actor-05.js", error);
115 do_check_true(false);
116 });
117 }
119 function start_trace()
120 {
121 let deferred = promise.defer();
122 gTraceClient.startTrace(
123 ["name", "location", "callsite", "time", "parameterNames", "arguments", "return"],
124 null,
125 function() { deferred.resolve(); });
126 return deferred.promise;
127 }
129 function eval_code()
130 {
131 let code = readFile("tracerlocations.js");
132 Components.utils.evalInSandbox(code, gDebuggee, "1.8",
133 getFileUrl("tracerlocations.js"), 1);
134 }
136 function stop_trace()
137 {
138 let deferred = promise.defer();
139 gTraceClient.stopTrace(null, function() { deferred.resolve(); });
140 return deferred.promise;
141 }