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 outgoingCall;
8 let outNumber = "5555551111";
10 function dial() {
11 log("Make an outgoing call.");
13 telephony.dial(outNumber).then(call => {
14 outgoingCall = call;
15 ok(outgoingCall);
16 is(outgoingCall.number, outNumber);
17 is(outgoingCall.state, "dialing");
19 is(outgoingCall, telephony.active);
20 is(telephony.calls.length, 1);
21 is(telephony.calls[0], outgoingCall);
23 outgoingCall.onstatechange = function statechangering(event) {
24 log("Received 'onstatechange' call event.");
26 is(outgoingCall, event.call);
27 let expectedStates = ["dialing", "alerting"];
28 ok(expectedStates.indexOf(event.call.state) != -1);
30 if (event.call.state == "alerting") {
31 emulator.run("gsm list", function(result) {
32 log("Call list is now: " + result);
33 is(result[0], "outbound to " + outNumber + " : ringing");
34 is(result[1], "OK");
35 answer();
36 });
37 }
38 };
39 });
40 }
42 function answer() {
43 log("Answering the outgoing call.");
45 // We get no "connecting" event when the remote party answers the call.
47 outgoingCall.onstatechange = function onstatechangeanswer(event) {
48 log("Received 'onstatechange' call event.");
49 is(outgoingCall, event.call);
50 is(outgoingCall.state, "connected");
51 is(outgoingCall, telephony.active);
53 emulator.run("gsm list", function(result) {
54 log("Call list is now: " + result);
55 is(result[0], "outbound to " + outNumber + " : active");
56 is(result[1], "OK");
57 hold();
58 });
59 };
60 emulator.run("gsm accept " + outNumber);
61 }
63 function hold() {
64 log("Putting the call on hold.");
66 let gotHolding = false;
67 outgoingCall.onstatechange = function onstatechangehold(event) {
68 log("Received 'onstatechange' call event.");
69 is(outgoingCall, event.call);
70 if(!gotHolding){
71 is(outgoingCall.state, "holding");
72 gotHolding = true;
73 } else {
74 is(outgoingCall.state, "held");
75 is(telephony.active, null);
76 is(telephony.calls.length, 1);
77 is(telephony.calls[0], outgoingCall);
79 emulator.run("gsm list", function(result) {
80 log("Call list is now: " + result);
81 is(result[0], "outbound to " + outNumber + " : held");
82 is(result[1], "OK");
83 resume();
84 });
85 }
86 };
87 outgoingCall.hold();
88 }
90 function resume() {
91 log("Resuming the held call.");
93 let gotResuming = false;
94 outgoingCall.onstatechange = function onstatechangeresume(event) {
95 log("Received 'onstatechange' call event.");
96 is(outgoingCall, event.call);
97 if(!gotResuming){
98 is(outgoingCall.state, "resuming");
99 gotResuming = true;
100 } else {
101 is(outgoingCall.state, "connected");
102 is(telephony.active, outgoingCall);
103 is(telephony.calls.length, 1);
104 is(telephony.calls[0], outgoingCall);
106 emulator.run("gsm list", function(result) {
107 log("Call list is now: " + result);
108 is(result[0], "outbound to " + outNumber + " : active");
109 is(result[1], "OK");
110 hangUp();
111 });
112 }
113 };
114 outgoingCall.resume();
115 }
117 function hangUp() {
118 log("Hanging up the outgoing call (local hang-up).");
120 let gotDisconnecting = false;
121 outgoingCall.onstatechange = function onstatechangedisconnect(event) {
122 log("Received 'onstatechange' call event.");
123 is(outgoingCall, event.call);
124 if(!gotDisconnecting){
125 is(outgoingCall.state, "disconnecting");
126 gotDisconnecting = true;
127 } else {
128 is(outgoingCall.state, "disconnected");
129 is(telephony.active, null);
130 is(telephony.calls.length, 0);
132 emulator.run("gsm list", function(result) {
133 log("Call list is now: " + result);
134 is(result[0], "OK");
135 cleanUp();
136 });
137 }
138 };
139 outgoingCall.hangUp();
140 }
142 function cleanUp() {
143 finish();
144 }
146 startTest(function() {
147 dial();
148 });