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 connection; |
michael@0 | 8 | let number = "112"; |
michael@0 | 9 | let outgoing; |
michael@0 | 10 | |
michael@0 | 11 | function setRadioEnabled(enabled, callback) { |
michael@0 | 12 | let request = connection.setRadioEnabled(enabled); |
michael@0 | 13 | let desiredRadioState = enabled ? 'enabled' : 'disabled'; |
michael@0 | 14 | |
michael@0 | 15 | let pending = ['onradiostatechange', 'onsuccess']; |
michael@0 | 16 | let done = callback; |
michael@0 | 17 | |
michael@0 | 18 | connection.onradiostatechange = function() { |
michael@0 | 19 | let state = connection.radioState; |
michael@0 | 20 | log("Received 'radiostatechange' event, radioState: " + state); |
michael@0 | 21 | |
michael@0 | 22 | if (state == desiredRadioState) { |
michael@0 | 23 | gReceivedPending('onradiostatechange', pending, done); |
michael@0 | 24 | } |
michael@0 | 25 | }; |
michael@0 | 26 | |
michael@0 | 27 | request.onsuccess = function onsuccess() { |
michael@0 | 28 | gReceivedPending('onsuccess', pending, done); |
michael@0 | 29 | }; |
michael@0 | 30 | |
michael@0 | 31 | request.onerror = function onerror() { |
michael@0 | 32 | ok(false, "setRadioEnabled should be ok"); |
michael@0 | 33 | }; |
michael@0 | 34 | } |
michael@0 | 35 | |
michael@0 | 36 | function dial() { |
michael@0 | 37 | log("Make an outgoing call."); |
michael@0 | 38 | |
michael@0 | 39 | telephony.dial(number).then(call => { |
michael@0 | 40 | outgoing = call; |
michael@0 | 41 | ok(outgoing); |
michael@0 | 42 | is(outgoing.number, number); |
michael@0 | 43 | is(outgoing.state, "dialing"); |
michael@0 | 44 | |
michael@0 | 45 | is(outgoing, telephony.active); |
michael@0 | 46 | is(telephony.calls.length, 1); |
michael@0 | 47 | is(telephony.calls[0], outgoing); |
michael@0 | 48 | |
michael@0 | 49 | outgoing.onalerting = function onalerting(event) { |
michael@0 | 50 | log("Received 'onalerting' call event."); |
michael@0 | 51 | is(outgoing, event.call); |
michael@0 | 52 | is(outgoing.state, "alerting"); |
michael@0 | 53 | |
michael@0 | 54 | emulator.run("gsm list", function(result) { |
michael@0 | 55 | log("Call list is now: " + result); |
michael@0 | 56 | is(result[0], "outbound to " + number + " : ringing"); |
michael@0 | 57 | is(result[1], "OK"); |
michael@0 | 58 | answer(); |
michael@0 | 59 | }); |
michael@0 | 60 | }; |
michael@0 | 61 | }); |
michael@0 | 62 | } |
michael@0 | 63 | |
michael@0 | 64 | function answer() { |
michael@0 | 65 | log("Answering the outgoing call."); |
michael@0 | 66 | |
michael@0 | 67 | // We get no "connecting" event when the remote party answers the call. |
michael@0 | 68 | |
michael@0 | 69 | outgoing.onconnected = function onconnected(event) { |
michael@0 | 70 | log("Received 'connected' call event."); |
michael@0 | 71 | is(outgoing, event.call); |
michael@0 | 72 | is(outgoing.state, "connected"); |
michael@0 | 73 | |
michael@0 | 74 | is(outgoing, telephony.active); |
michael@0 | 75 | |
michael@0 | 76 | emulator.run("gsm list", function(result) { |
michael@0 | 77 | log("Call list is now: " + result); |
michael@0 | 78 | is(result[0], "outbound to " + number + " : active"); |
michael@0 | 79 | is(result[1], "OK"); |
michael@0 | 80 | hangUp(); |
michael@0 | 81 | }); |
michael@0 | 82 | }; |
michael@0 | 83 | emulator.run("gsm accept " + number); |
michael@0 | 84 | } |
michael@0 | 85 | |
michael@0 | 86 | function hangUp() { |
michael@0 | 87 | log("Hanging up the outgoing call."); |
michael@0 | 88 | |
michael@0 | 89 | // We get no "disconnecting" event when the remote party terminates the call. |
michael@0 | 90 | |
michael@0 | 91 | outgoing.ondisconnected = function ondisconnected(event) { |
michael@0 | 92 | log("Received 'disconnected' call event."); |
michael@0 | 93 | is(outgoing, event.call); |
michael@0 | 94 | is(outgoing.state, "disconnected"); |
michael@0 | 95 | |
michael@0 | 96 | is(telephony.active, null); |
michael@0 | 97 | is(telephony.calls.length, 0); |
michael@0 | 98 | |
michael@0 | 99 | emulator.run("gsm list", function(result) { |
michael@0 | 100 | log("Call list is now: " + result); |
michael@0 | 101 | is(result[0], "OK"); |
michael@0 | 102 | cleanUp(); |
michael@0 | 103 | }); |
michael@0 | 104 | }; |
michael@0 | 105 | emulator.run("gsm cancel " + number); |
michael@0 | 106 | } |
michael@0 | 107 | |
michael@0 | 108 | function cleanUp() { |
michael@0 | 109 | finish(); |
michael@0 | 110 | } |
michael@0 | 111 | |
michael@0 | 112 | startTestWithPermissions(['mobileconnection'], function() { |
michael@0 | 113 | connection = navigator.mozMobileConnections[0]; |
michael@0 | 114 | ok(connection instanceof MozMobileConnection, |
michael@0 | 115 | "connection is instanceof " + connection.constructor); |
michael@0 | 116 | |
michael@0 | 117 | setRadioEnabled(false, function() { |
michael@0 | 118 | dial(); |
michael@0 | 119 | }); |
michael@0 | 120 | }); |