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.
michael@0 | 1 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | * http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | |
michael@0 | 4 | MARIONETTE_TIMEOUT = 60000; |
michael@0 | 5 | MARIONETTE_HEAD_JS = 'head.js'; |
michael@0 | 6 | |
michael@0 | 7 | let inNumber = "5555551111"; |
michael@0 | 8 | let outNumber = "5555552222"; |
michael@0 | 9 | let incomingCall; |
michael@0 | 10 | let outgoingCall; |
michael@0 | 11 | |
michael@0 | 12 | function simulateIncoming() { |
michael@0 | 13 | log("Simulating an incoming call."); |
michael@0 | 14 | |
michael@0 | 15 | telephony.onincoming = function onincoming(event) { |
michael@0 | 16 | log("Received 'incoming' call event."); |
michael@0 | 17 | incomingCall = event.call; |
michael@0 | 18 | ok(incomingCall); |
michael@0 | 19 | is(incomingCall.number, inNumber); |
michael@0 | 20 | is(incomingCall.state, "incoming"); |
michael@0 | 21 | |
michael@0 | 22 | is(telephony.calls.length, 1); |
michael@0 | 23 | is(telephony.calls[0], incomingCall); |
michael@0 | 24 | |
michael@0 | 25 | // Wait for emulator to catch up before continuing |
michael@0 | 26 | waitFor(verifyCallList,function() { |
michael@0 | 27 | return(rcvdEmulatorCallback); |
michael@0 | 28 | }); |
michael@0 | 29 | }; |
michael@0 | 30 | |
michael@0 | 31 | let rcvdEmulatorCallback = false; |
michael@0 | 32 | emulator.run("gsm call " + inNumber, function(result) { |
michael@0 | 33 | is(result[0], "OK", "emulator callback"); |
michael@0 | 34 | rcvdEmulatorCallback = true; |
michael@0 | 35 | }); |
michael@0 | 36 | } |
michael@0 | 37 | |
michael@0 | 38 | function verifyCallList(){ |
michael@0 | 39 | emulator.run("gsm list", function(result) { |
michael@0 | 40 | log("Call list is now: " + result); |
michael@0 | 41 | is(result[0], "inbound from " + inNumber + " : incoming"); |
michael@0 | 42 | is(result[1], "OK"); |
michael@0 | 43 | answerIncoming(); |
michael@0 | 44 | }); |
michael@0 | 45 | } |
michael@0 | 46 | |
michael@0 | 47 | function answerIncoming() { |
michael@0 | 48 | log("Answering the incoming call."); |
michael@0 | 49 | |
michael@0 | 50 | let gotConnecting = false; |
michael@0 | 51 | incomingCall.onconnecting = function onconnectingIn(event) { |
michael@0 | 52 | log("Received 'connecting' call event for original (incoming) call."); |
michael@0 | 53 | is(incomingCall, event.call); |
michael@0 | 54 | is(incomingCall.state, "connecting"); |
michael@0 | 55 | gotConnecting = true; |
michael@0 | 56 | }; |
michael@0 | 57 | |
michael@0 | 58 | incomingCall.onconnected = function onconnectedIn(event) { |
michael@0 | 59 | log("Received 'connected' call event for original (incoming) call."); |
michael@0 | 60 | is(incomingCall, event.call); |
michael@0 | 61 | is(incomingCall.state, "connected"); |
michael@0 | 62 | ok(gotConnecting); |
michael@0 | 63 | |
michael@0 | 64 | is(incomingCall, telephony.active); |
michael@0 | 65 | |
michael@0 | 66 | emulator.run("gsm list", function(result) { |
michael@0 | 67 | log("Call list is now: " + result); |
michael@0 | 68 | is(result[0], "inbound from " + inNumber + " : active"); |
michael@0 | 69 | is(result[1], "OK"); |
michael@0 | 70 | holdCall(); |
michael@0 | 71 | }); |
michael@0 | 72 | }; |
michael@0 | 73 | incomingCall.answer(); |
michael@0 | 74 | } |
michael@0 | 75 | |
michael@0 | 76 | // Put the original (incoming) call on hold |
michael@0 | 77 | function holdCall(){ |
michael@0 | 78 | log("Putting the original (incoming) call on hold."); |
michael@0 | 79 | |
michael@0 | 80 | let gotHolding = false; |
michael@0 | 81 | incomingCall.onholding = function onholding(event) { |
michael@0 | 82 | log("Received 'holding' call event"); |
michael@0 | 83 | is(incomingCall, event.call); |
michael@0 | 84 | is(incomingCall.state, "holding"); |
michael@0 | 85 | gotHolding = true; |
michael@0 | 86 | }; |
michael@0 | 87 | |
michael@0 | 88 | incomingCall.onheld = function onheld(event) { |
michael@0 | 89 | log("Received 'held' call event"); |
michael@0 | 90 | is(incomingCall, event.call); |
michael@0 | 91 | is(incomingCall.state, "held"); |
michael@0 | 92 | ok(gotHolding); |
michael@0 | 93 | |
michael@0 | 94 | is(telephony.active, null); |
michael@0 | 95 | is(telephony.calls.length, 1); |
michael@0 | 96 | is(telephony.calls[0], incomingCall); |
michael@0 | 97 | |
michael@0 | 98 | emulator.run("gsm list", function(result) { |
michael@0 | 99 | log("Call list is now: " + result); |
michael@0 | 100 | is(result[0], "inbound from " + inNumber + " : held"); |
michael@0 | 101 | is(result[1], "OK"); |
michael@0 | 102 | dial(); |
michael@0 | 103 | }); |
michael@0 | 104 | }; |
michael@0 | 105 | incomingCall.hold(); |
michael@0 | 106 | } |
michael@0 | 107 | |
michael@0 | 108 | // With one call on hold, make outgoing call |
michael@0 | 109 | function dial() { |
michael@0 | 110 | log("Making an outgoing call (while have one call already held)."); |
michael@0 | 111 | |
michael@0 | 112 | telephony.dial(outNumber).then(call => { |
michael@0 | 113 | outgoingCall = call; |
michael@0 | 114 | ok(outgoingCall); |
michael@0 | 115 | is(outgoingCall.number, outNumber); |
michael@0 | 116 | is(outgoingCall.state, "dialing"); |
michael@0 | 117 | |
michael@0 | 118 | is(outgoingCall, telephony.active); |
michael@0 | 119 | is(telephony.calls.length, 2); |
michael@0 | 120 | is(telephony.calls[0], incomingCall); |
michael@0 | 121 | is(telephony.calls[1], outgoingCall); |
michael@0 | 122 | |
michael@0 | 123 | outgoingCall.onalerting = function onalerting(event) { |
michael@0 | 124 | log("Received 'onalerting' call event."); |
michael@0 | 125 | is(outgoingCall, event.call); |
michael@0 | 126 | is(outgoingCall.state, "alerting"); |
michael@0 | 127 | |
michael@0 | 128 | emulator.run("gsm list", function(result) { |
michael@0 | 129 | log("Call list is now: " + result); |
michael@0 | 130 | is(result[0], "inbound from " + inNumber + " : held"); |
michael@0 | 131 | is(result[1], "outbound to " + outNumber + " : ringing"); |
michael@0 | 132 | is(result[2], "OK"); |
michael@0 | 133 | answerOutgoing(); |
michael@0 | 134 | }); |
michael@0 | 135 | }; |
michael@0 | 136 | }); |
michael@0 | 137 | } |
michael@0 | 138 | |
michael@0 | 139 | // Have the outgoing call answered |
michael@0 | 140 | function answerOutgoing() { |
michael@0 | 141 | log("Answering the outgoing/2nd call"); |
michael@0 | 142 | |
michael@0 | 143 | // We get no "connecting" event when the remote party answers the call. |
michael@0 | 144 | outgoingCall.onconnected = function onconnectedOut(event) { |
michael@0 | 145 | log("Received 'connected' call event for outgoing/2nd call."); |
michael@0 | 146 | is(outgoingCall, event.call); |
michael@0 | 147 | is(outgoingCall.state, "connected"); |
michael@0 | 148 | |
michael@0 | 149 | is(outgoingCall, telephony.active); |
michael@0 | 150 | |
michael@0 | 151 | // Wait for emulator to catch up before continuing |
michael@0 | 152 | waitFor(checkCallList,function() { |
michael@0 | 153 | return(rcvdEmulatorCallback); |
michael@0 | 154 | }); |
michael@0 | 155 | }; |
michael@0 | 156 | |
michael@0 | 157 | let rcvdEmulatorCallback = false; |
michael@0 | 158 | emulator.run("gsm accept " + outNumber, function(result) { |
michael@0 | 159 | is(result[0], "OK", "emulator callback"); |
michael@0 | 160 | rcvdEmulatorCallback = true; |
michael@0 | 161 | }); |
michael@0 | 162 | } |
michael@0 | 163 | |
michael@0 | 164 | function checkCallList(){ |
michael@0 | 165 | emulator.run("gsm list", function(result) { |
michael@0 | 166 | log("Call list is now: " + result); |
michael@0 | 167 | is(result[0], "inbound from " + inNumber + " : held"); |
michael@0 | 168 | is(result[1], "outbound to " + outNumber + " : active"); |
michael@0 | 169 | is(result[2], "OK"); |
michael@0 | 170 | hangUpIncoming(); |
michael@0 | 171 | }); |
michael@0 | 172 | } |
michael@0 | 173 | |
michael@0 | 174 | // Hang-up the original incoming call, which is now held |
michael@0 | 175 | function hangUpIncoming() { |
michael@0 | 176 | log("Hanging up the original incoming (now held) call."); |
michael@0 | 177 | |
michael@0 | 178 | let gotDisconnecting = false; |
michael@0 | 179 | incomingCall.ondisconnecting = function ondisconnectingIn(event) { |
michael@0 | 180 | log("Received 'disconnecting' call event for original (incoming) call."); |
michael@0 | 181 | is(incomingCall, event.call); |
michael@0 | 182 | is(incomingCall.state, "disconnecting"); |
michael@0 | 183 | gotDisconnecting = true; |
michael@0 | 184 | }; |
michael@0 | 185 | |
michael@0 | 186 | incomingCall.ondisconnected = function ondisconnectedIn(event) { |
michael@0 | 187 | log("Received 'disconnected' call event for original (incoming) call."); |
michael@0 | 188 | is(incomingCall, event.call); |
michael@0 | 189 | is(incomingCall.state, "disconnected"); |
michael@0 | 190 | ok(gotDisconnecting); |
michael@0 | 191 | |
michael@0 | 192 | // Now back to one call |
michael@0 | 193 | is(telephony.active, outgoingCall); |
michael@0 | 194 | is(telephony.calls.length, 1); |
michael@0 | 195 | is(telephony.calls[0], outgoingCall); |
michael@0 | 196 | |
michael@0 | 197 | emulator.run("gsm list", function(result) { |
michael@0 | 198 | log("Call list is now: " + result); |
michael@0 | 199 | is(result[0], "outbound to " + outNumber + " : active"); |
michael@0 | 200 | is(result[1], "OK"); |
michael@0 | 201 | hangUpOutgoing(); |
michael@0 | 202 | }); |
michael@0 | 203 | }; |
michael@0 | 204 | incomingCall.hangUp(); |
michael@0 | 205 | } |
michael@0 | 206 | |
michael@0 | 207 | // Hang-up the remaining (outgoing) call |
michael@0 | 208 | function hangUpOutgoing() { |
michael@0 | 209 | log("Hanging up the remaining (outgoing) call."); |
michael@0 | 210 | |
michael@0 | 211 | let gotDisconnecting = false; |
michael@0 | 212 | outgoingCall.ondisconnecting = function ondisconnectingOut(event) { |
michael@0 | 213 | log("Received 'disconnecting' call event for remaining (outgoing) call."); |
michael@0 | 214 | is(outgoingCall, event.call); |
michael@0 | 215 | is(outgoingCall.state, "disconnecting"); |
michael@0 | 216 | gotDisconnecting = true; |
michael@0 | 217 | }; |
michael@0 | 218 | |
michael@0 | 219 | outgoingCall.ondisconnected = function ondisconnectedOut(event) { |
michael@0 | 220 | log("Received 'disconnected' call event for remaining (outgoing) call."); |
michael@0 | 221 | is(outgoingCall, event.call); |
michael@0 | 222 | is(outgoingCall.state, "disconnected"); |
michael@0 | 223 | ok(gotDisconnecting); |
michael@0 | 224 | |
michael@0 | 225 | // Now no calls |
michael@0 | 226 | is(telephony.active, null); |
michael@0 | 227 | is(telephony.calls.length, 0); |
michael@0 | 228 | |
michael@0 | 229 | emulator.run("gsm list", function(result) { |
michael@0 | 230 | log("Call list is now: " + result); |
michael@0 | 231 | is(result[0], "OK"); |
michael@0 | 232 | cleanUp(); |
michael@0 | 233 | }); |
michael@0 | 234 | }; |
michael@0 | 235 | outgoingCall.hangUp(); |
michael@0 | 236 | } |
michael@0 | 237 | |
michael@0 | 238 | function cleanUp() { |
michael@0 | 239 | telephony.onincoming = null; |
michael@0 | 240 | finish(); |
michael@0 | 241 | } |
michael@0 | 242 | |
michael@0 | 243 | startTest(function() { |
michael@0 | 244 | simulateIncoming(); |
michael@0 | 245 | }); |