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