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 number = "5555551234";
8 let connectedCalls;
9 let incomingCall;
11 function simulateIncoming() {
12 log("Simulating an incoming call.");
14 telephony.onincoming = function onincoming(event) {
15 log("Received 'incoming' call event.");
16 incomingCall = event.call;
17 ok(incomingCall);
18 is(incomingCall.number, number);
19 is(incomingCall.state, "incoming");
21 is(telephony.calls.length, 1);
22 is(telephony.calls[0], incomingCall);
24 emulator.run("gsm list", function(result) {
25 log("Call list is now: " + result);
26 is(result[0], "inbound from " + number + " : incoming");
27 is(result[1], "OK");
28 answer();
29 });
30 };
31 emulator.run("gsm call " + number);
32 }
34 function answer() {
35 log("Answering the incoming call.");
37 let gotConnecting = false;
38 incomingCall.onconnecting = function onconnecting(event) {
39 log("Received 'connecting' call event.");
40 is(incomingCall, event.call);
41 is(incomingCall.state, "connecting");
42 gotConnecting = true;
43 };
45 incomingCall.onconnected = function onconnected(event) {
46 log("Received 'connected' call event.");
47 is(incomingCall, event.call);
48 is(incomingCall.state, "connected");
49 ok(gotConnecting);
51 is(incomingCall, telephony.active);
53 emulator.run("gsm list", function(result) {
54 log("Call list is now: " + result);
55 is(result[0], "inbound from " + number + " : active");
56 is(result[1], "OK");
57 hold();
58 });
59 };
60 incomingCall.answer();
61 }
63 function hold() {
64 log("Putting the call on hold.");
66 let gotHolding = false;
67 incomingCall.onholding = function onholding(event) {
68 log("Received 'holding' call event");
69 is(incomingCall, event.call);
70 is(incomingCall.state, "holding");
71 gotHolding = true;
72 };
74 incomingCall.onheld = function onheld(event) {
75 log("Received 'held' call event");
76 is(incomingCall, event.call);
77 is(incomingCall.state, "held");
78 ok(gotHolding);
80 is(telephony.active, null);
81 is(telephony.calls.length, 1);
82 is(telephony.calls[0], incomingCall);
84 emulator.run("gsm list", function(result) {
85 log("Call list is now: " + result);
86 is(result[0], "inbound from " + number + " : held");
87 is(result[1], "OK");
88 // Wait on hold for a couple of seconds
89 log("Pausing 2 seconds while on hold");
90 setTimeout(resume, 2000);
91 });
92 };
93 incomingCall.hold();
94 }
96 function resume() {
97 log("Resuming the held call.");
99 let gotResuming = false;
100 incomingCall.onresuming = function onresuming(event) {
101 log("Received 'resuming' call event");
102 is(incomingCall, event.call);
103 is(incomingCall.state, "resuming");
104 gotResuming = true;
105 };
107 incomingCall.onconnected = function onconnected(event) {
108 log("Received 'connected' call event");
109 is(incomingCall, event.call);
110 is(incomingCall.state, "connected");
111 ok(gotResuming);
113 is(incomingCall, telephony.active);
114 is(telephony.calls.length, 1);
115 is(telephony.calls[0], incomingCall);
117 emulator.run("gsm list", function(result) {
118 log("Call list is now: " + result);
119 is(result[0], "inbound from " + number + " : active");
120 is(result[1], "OK");
121 hangUp();
122 });
123 };
124 incomingCall.resume();
125 }
127 function hangUp() {
128 log("Hanging up the incoming call.");
130 let gotDisconnecting = false;
131 incomingCall.ondisconnecting = function ondisconnecting(event) {
132 log("Received 'disconnecting' call event.");
133 is(incomingCall, event.call);
134 is(incomingCall.state, "disconnecting");
135 gotDisconnecting = true;
136 };
138 incomingCall.ondisconnected = function ondisconnected(event) {
139 log("Received 'disconnected' call event.");
140 is(incomingCall, event.call);
141 is(incomingCall.state, "disconnected");
142 ok(gotDisconnecting);
144 is(telephony.active, null);
145 is(telephony.calls.length, 0);
147 emulator.run("gsm list", function(result) {
148 log("Call list is now: " + result);
149 is(result[0], "OK");
150 cleanUp();
151 });
152 };
153 incomingCall.hangUp();
154 }
156 function cleanUp() {
157 telephony.onincoming = null;
158 finish();
159 }
161 startTest(function() {
162 simulateIncoming();
163 });