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