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 MARIONETTE_TIMEOUT = 60000;
5 MARIONETTE_HEAD_JS = 'head.js';
7 let inNumber = "5555551111";
8 let incomingCall;
10 function simulateIncoming() {
11 log("Simulating an incoming call.");
13 telephony.onincoming = function onincoming(event) {
14 log("Received 'incoming' call event.");
15 incomingCall = event.call;
16 ok(incomingCall);
17 is(incomingCall.number, inNumber);
18 is(incomingCall.state, "incoming");
20 is(telephony.calls.length, 1);
21 is(telephony.calls[0], incomingCall);
23 emulator.run("gsm list", function(result) {
24 log("Call list is now: " + result);
25 is(result[0], "inbound from " + inNumber + " : incoming");
26 is(result[1], "OK");
27 answerIncoming();
28 });
29 };
30 emulator.run("gsm call " + inNumber);
31 }
33 function answerIncoming() {
34 log("Answering the incoming call.");
36 let gotConnecting = false;
37 incomingCall.onconnecting = function onconnectingIn(event) {
38 log("Received 'connecting' call event for incoming call.");
39 is(incomingCall, event.call);
40 is(incomingCall.state, "connecting");
41 gotConnecting = true;
42 };
44 incomingCall.onconnected = function onconnectedIn(event) {
45 log("Received 'connected' call event for incoming call.");
46 is(incomingCall, event.call);
47 is(incomingCall.state, "connected");
48 ok(gotConnecting);
50 is(incomingCall, telephony.active);
52 emulator.run("gsm list", function(result) {
53 log("Call list is now: " + result);
54 is(result[0], "inbound from " + inNumber + " : active");
55 is(result[1], "OK");
56 answerAlreadyConnected();
57 });
58 };
59 incomingCall.answer();
60 }
62 function answerAlreadyConnected() {
63 log("Attempting to answer already connected call, should be ignored.");
65 incomingCall.onconnecting = function onconnectingErr(event) {
66 log("Received 'connecting' call event, but should not have.");
67 ok(false, "Received 'connecting' event when answered already active call");
68 };
70 incomingCall.onconnected = function onconnectedErr(event) {
71 log("Received 'connected' call event, but should not have.");
72 ok(false, "Received 'connected' event when answered already active call");
73 };
75 incomingCall.answer();
77 is(incomingCall.state, "connected");
78 is(telephony.calls.length, 1);
79 is(telephony.calls[0], incomingCall);
80 is(incomingCall, telephony.active);
81 hold();
82 }
84 function hold() {
85 log("Putting the call on hold.");
87 let gotHolding = false;
88 incomingCall.onholding = function onholding(event) {
89 log("Received 'holding' call event.");
90 is(incomingCall, event.call);
91 is(incomingCall.state, "holding");
92 gotHolding = true;
93 };
95 incomingCall.onheld = function onheld(event) {
96 log("Received 'held' call event.");
97 is(incomingCall, event.call);
98 is(incomingCall.state, "held");
99 ok(gotHolding);
101 is(telephony.active, null);
102 is(telephony.calls.length, 1);
103 is(telephony.calls[0], incomingCall);
105 emulator.run("gsm list", function(result) {
106 log("Call list is now: " + result);
107 is(result[0], "inbound from " + inNumber + " : held");
108 is(result[1], "OK");
109 holdAlreadyHeld();
110 });
111 };
112 incomingCall.hold();
113 }
115 function holdAlreadyHeld() {
116 log("Attempting to hold an already held call, should be ignored.");
118 incomingCall.onholding = function onholding(event) {
119 log("Received 'holding' call event, but should not have.");
120 ok(false, "Received 'holding' event when held an already held call");
121 };
123 incomingCall.onheld = function onheldErr(event) {
124 log("Received 'held' call event, but should not have.");
125 ok(false, "Received 'held' event when held an already held call");
126 };
128 incomingCall.hold();
130 is(incomingCall.state, "held");
131 is(telephony.active, null);
132 is(telephony.calls.length, 1);
133 is(telephony.calls[0], incomingCall);
135 answerHeld();
136 }
138 function answerHeld() {
139 log("Attempting to answer a held call, should be ignored.");
141 incomingCall.onconnecting = function onconnectingErr(event) {
142 log("Received 'connecting' call event, but should not have.");
143 ok(false, "Received 'connecting' event when answered a held call");
144 };
146 incomingCall.onconnected = function onconnectedErr(event) {
147 log("Received 'connected' call event, but should not have.");
148 ok(false, "Received 'connected' event when answered a held call");
149 };
151 incomingCall.answer();
153 is(incomingCall.state, "held");
154 is(telephony.active, null);
155 is(telephony.calls.length, 1);
156 is(telephony.calls[0], incomingCall);
158 resume();
159 }
161 function resume() {
162 log("Resuming the held call.");
164 let gotResuming = false;
165 incomingCall.onresuming = function onresuming(event) {
166 log("Received 'resuming' call event.");
167 is(incomingCall, event.call);
168 is(incomingCall.state, "resuming");
169 gotResuming = true;
170 };
172 incomingCall.onconnected = function onconnected(event) {
173 log("Received 'connected' call event.");
174 is(incomingCall, event.call);
175 is(incomingCall.state, "connected");
176 ok(gotResuming);
178 is(incomingCall, telephony.active);
179 is(telephony.calls.length, 1);
180 is(telephony.calls[0], incomingCall);
182 emulator.run("gsm list", function(result) {
183 log("Call list is now: " + result);
184 is(result[0], "inbound from " + inNumber + " : active");
185 is(result[1], "OK");
186 resumeNonHeld();
187 });
188 };
189 incomingCall.resume();
190 }
192 function resumeNonHeld() {
193 log("Attempting to resume non-held call, should be ignored.");
195 incomingCall.onresuming = function onresumingErr(event) {
196 log("Received 'resuming' call event, but should not have.");
197 ok(false, "Received 'resuming' event when resumed non-held call");
198 };
200 incomingCall.onconnected = function onconnectedErr(event) {
201 log("Received 'connected' call event, but should not have.");
202 ok(false, "Received 'connected' event when resumed non-held call");
203 };
205 incomingCall.resume();
207 is(incomingCall.state, "connected");
208 is(telephony.calls.length, 1);
209 is(telephony.calls[0], incomingCall);
210 is(incomingCall, telephony.active);
211 hangUp();
212 }
214 function hangUp() {
215 log("Hanging up the call (local hang-up).");
217 let gotDisconnecting = false;
218 incomingCall.ondisconnecting = function ondisconnecting(event) {
219 log("Received 'disconnecting' call event.");
220 is(incomingCall, event.call);
221 is(incomingCall.state, "disconnecting");
222 gotDisconnecting = true;
223 };
225 incomingCall.ondisconnected = function ondisconnectedOut(event) {
226 log("Received 'disconnected' call event.");
227 is(incomingCall, event.call);
228 is(incomingCall.state, "disconnected");
229 ok(gotDisconnecting);
231 is(telephony.active, null);
232 is(telephony.calls.length, 0);
234 emulator.run("gsm list", function(result) {
235 log("Call list is now: " + result);
236 is(result[0], "OK");
237 answerDisconnected();
238 });
239 };
240 incomingCall.hangUp();
241 }
243 function answerDisconnected() {
244 log("Attempting to answer disconnected call, should be ignored.");
246 incomingCall.onconnecting = function onconnectingErr(event) {
247 log("Received 'connecting' call event, but should not have.");
248 ok(false, "Received 'connecting' event when answered disconnected call");
249 };
251 incomingCall.onconnected = function onconnectedErr(event) {
252 log("Received 'connected' call event, but should not have.");
253 ok(false, "Received 'connected' event when answered disconnected call");
254 };
256 incomingCall.answer();
258 is(telephony.active, null);
259 is(telephony.calls.length, 0);
260 holdDisconnected();
261 }
263 function holdDisconnected() {
264 log("Attempting to hold disconnected call, should be ignored.");
266 incomingCall.onholding = function onholdingErr(event) {
267 log("Received 'holding' call event, but should not have.");
268 ok(false, "Received 'holding' event when held a disconnected call");
269 };
271 incomingCall.onheld = function onheldErr(event) {
272 log("Received 'held' call event, but should not have.");
273 ok(false, "Received 'held' event when held a disconnected call");
274 };
276 incomingCall.hold();
278 is(telephony.active, null);
279 is(telephony.calls.length, 0);
280 resumeDisconnected();
281 }
283 function resumeDisconnected() {
284 log("Attempting to resume disconnected call, should be ignored.");
286 incomingCall.onresuming = function onresumingErr(event) {
287 log("Received 'resuming' call event, but should not have.");
288 ok(false, "Received 'resuming' event when resumed disconnected call");
289 };
291 incomingCall.onconnected = function onconnectedErr(event) {
292 log("Received 'connected' call event, but should not have.");
293 ok(false, "Received 'connected' event when resumed disconnected call");
294 };
296 incomingCall.resume();
298 is(telephony.active, null);
299 is(telephony.calls.length, 0);
300 hangUpNonConnected();
301 }
303 function hangUpNonConnected() {
304 log("Attempting to hang-up disconnected call, should be ignored.");
306 incomingCall.ondisconnecting = function ondisconnectingErr(event) {
307 log("Received 'disconnecting' call event, but should not have.");
308 ok(false, "Received 'disconnecting' event when hung-up non-active call");
309 };
311 incomingCall.ondisconnected = function ondisconnectedErr(event) {
312 log("Received 'disconnected' call event, but should not have.");
313 ok(false, "Received 'disconnected' event when hung-up non-active call");
314 };
316 incomingCall.hangUp();
318 is(telephony.active, null);
319 is(telephony.calls.length, 0);
320 cleanUp();
321 }
323 function cleanUp() {
324 telephony.onincoming = null;
325 finish();
326 }
328 startTest(function() {
329 simulateIncoming();
330 });