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 function setRadioEnabled(enabled) {
8 log("Set radio enabled: " + enabled + ".");
10 let desiredRadioState = enabled ? 'enabled' : 'disabled';
11 let deferred = Promise.defer();
12 let connection = navigator.mozMobileConnections[0];
14 connection.onradiostatechange = function() {
15 let state = connection.radioState;
16 log("Received 'radiostatechange' event, radioState: " + state);
18 // We are waiting for 'desiredRadioState.' Ignore any transient state.
19 if (state === desiredRadioState) {
20 connection.onradiostatechange = null;
21 deferred.resolve();
22 }
23 };
24 connection.setRadioEnabled(enabled);
26 return deferred.promise;
27 }
29 function dial(number) {
30 log("Make an outgoing call.");
32 let deferred = Promise.defer();
33 telephony.dial(number).then(call => {
34 ok(call);
35 is(call.number, number);
36 is(call.state, "dialing");
38 call.onalerting = function(event) {
39 log("Received 'onalerting' call event.");
40 call.onalerting = null;
41 is(call, event.call);
42 is(call.state, "alerting");
43 deferred.resolve(call);
44 };
45 });
47 return deferred.promise;
48 }
50 function remoteAnswer(call) {
51 log("Remote answering the call.");
53 let deferred = Promise.defer();
55 call.onconnected = function(event) {
56 log("Received 'connected' call event.");
57 call.onconnected = null;
58 is(call, event.call);
59 is(call.state, "connected");
60 deferred.resolve(call);
61 };
62 emulator.run("gsm accept " + call.number);
64 return deferred.promise;
65 }
67 function disableRadioAndWaitForCallEvent(call) {
68 log("Disable radio and wait for call event.");
70 let deferred = Promise.defer();
72 call.ondisconnected = function(event) {
73 log("Received 'disconnected' call event.");
74 call.ondisconnected = null;
75 is(call, event.call);
76 is(call.state, "disconnected");
77 deferred.resolve();
78 };
79 navigator.mozMobileConnections[0].setRadioEnabled(false);
81 return deferred.promise;
82 }
84 /**
85 * Make an outgoing call then power off radio.
86 */
87 function testOutgoingCallRadioOff() {
88 log("= testOutgoingCallRadioOff =");
89 let number = "0912345000";
91 return Promise.resolve()
92 .then(() => dial(number))
93 .then(call => remoteAnswer(call))
94 .then(call => disableRadioAndWaitForCallEvent(call))
95 .then(() => setRadioEnabled(true));
96 }
98 // Start test
99 startTestWithPermissions(['mobileconnection'], function() {
100 testOutgoingCallRadioOff()
101 .then(null, () => {
102 ok(false, "promise rejects during test.");
103 })
104 .then(finish);
105 });