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 = 30000; |
michael@0 | 5 | MARIONETTE_HEAD_JS = "mobile_header.js"; |
michael@0 | 6 | |
michael@0 | 7 | /* Emulator command for GSM/UMTS signal strength */ |
michael@0 | 8 | function setEmulatorGsmSignalStrength(rssi) { |
michael@0 | 9 | emulatorHelper.sendCommand("gsm signal " + rssi); |
michael@0 | 10 | } |
michael@0 | 11 | |
michael@0 | 12 | /* Emulator command for LTE signal strength */ |
michael@0 | 13 | function setEmulatorLteSignalStrength(rxlev, rsrp, rssnr) { |
michael@0 | 14 | let lteSignal = rxlev + " " + rsrp + " " + rssnr; |
michael@0 | 15 | emulatorHelper.sendCommand("gsm lte_signal " + lteSignal); |
michael@0 | 16 | } |
michael@0 | 17 | |
michael@0 | 18 | function waitForVoiceChangeEvent(callback) { |
michael@0 | 19 | mobileConnection.addEventListener("voicechange", function onvoicechange() { |
michael@0 | 20 | mobileConnection.removeEventListener("voicechange", onvoicechange); |
michael@0 | 21 | |
michael@0 | 22 | if (callback && typeof callback === "function") { |
michael@0 | 23 | callback(); |
michael@0 | 24 | } |
michael@0 | 25 | }); |
michael@0 | 26 | } |
michael@0 | 27 | |
michael@0 | 28 | /* Test Initial Signal Strength Info */ |
michael@0 | 29 | taskHelper.push(function testInitialSignalStrengthInfo() { |
michael@0 | 30 | log("Test initial signal strength info"); |
michael@0 | 31 | |
michael@0 | 32 | let voice = mobileConnection.voice; |
michael@0 | 33 | // Android emulator initializes the signal strength to -99 dBm |
michael@0 | 34 | is(voice.signalStrength, -99, "check voice.signalStrength"); |
michael@0 | 35 | is(voice.relSignalStrength, 44, "check voice.relSignalStrength"); |
michael@0 | 36 | |
michael@0 | 37 | taskHelper.runNext(); |
michael@0 | 38 | }); |
michael@0 | 39 | |
michael@0 | 40 | /* Test Unsolicited Signal Strength Events for LTE */ |
michael@0 | 41 | taskHelper.push(function testLteSignalStrength() { |
michael@0 | 42 | // Set emulator's LTE signal strength and wait for 'onvoicechange' event. |
michael@0 | 43 | function doTestLteSignalStrength(input, expect, callback) { |
michael@0 | 44 | log("Test LTE signal info with data : " + JSON.stringify(input)); |
michael@0 | 45 | |
michael@0 | 46 | waitForVoiceChangeEvent(function() { |
michael@0 | 47 | let voice = mobileConnection.voice; |
michael@0 | 48 | is(voice.signalStrength, expect.signalStrength, |
michael@0 | 49 | "check voice.signalStrength"); |
michael@0 | 50 | is(voice.relSignalStrength, expect.relSignalStrength, |
michael@0 | 51 | "check voice.relSignalStrength"); |
michael@0 | 52 | |
michael@0 | 53 | if (callback && typeof callback === "function") { |
michael@0 | 54 | callback(); |
michael@0 | 55 | } |
michael@0 | 56 | }); |
michael@0 | 57 | |
michael@0 | 58 | setEmulatorLteSignalStrength(input.rxlev, input.rsrp, input.rssnr); |
michael@0 | 59 | } |
michael@0 | 60 | |
michael@0 | 61 | let testData = [ |
michael@0 | 62 | // All invalid case. |
michael@0 | 63 | {input: { |
michael@0 | 64 | rxlev: 99, |
michael@0 | 65 | rsrp: 65535, |
michael@0 | 66 | rssnr: 65535}, |
michael@0 | 67 | expect: { |
michael@0 | 68 | signalStrength: null, |
michael@0 | 69 | relSignalStrength: null} |
michael@0 | 70 | }, |
michael@0 | 71 | // Valid rxlev with max value. |
michael@0 | 72 | {input: { |
michael@0 | 73 | rxlev: 63, |
michael@0 | 74 | rsrp: 65535, |
michael@0 | 75 | rssnr: 65535}, |
michael@0 | 76 | expect: { |
michael@0 | 77 | signalStrength: -48, |
michael@0 | 78 | relSignalStrength: 100} |
michael@0 | 79 | }, |
michael@0 | 80 | // Valid rxlev. |
michael@0 | 81 | {input: { |
michael@0 | 82 | rxlev: 12, |
michael@0 | 83 | rsrp: 65535, |
michael@0 | 84 | rssnr: 65535}, |
michael@0 | 85 | expect: { |
michael@0 | 86 | signalStrength: -99, |
michael@0 | 87 | relSignalStrength: 100} |
michael@0 | 88 | }, |
michael@0 | 89 | // Valid rxlev with min value. |
michael@0 | 90 | {input: { |
michael@0 | 91 | rxlev: 0, |
michael@0 | 92 | rsrp: 65535, |
michael@0 | 93 | rssnr: 65535}, |
michael@0 | 94 | expect: { |
michael@0 | 95 | signalStrength: -111, |
michael@0 | 96 | relSignalStrength: 0} |
michael@0 | 97 | } |
michael@0 | 98 | ]; |
michael@0 | 99 | |
michael@0 | 100 | // Run all test data. |
michael@0 | 101 | (function do_call() { |
michael@0 | 102 | let next = testData.shift(); |
michael@0 | 103 | if (!next) { |
michael@0 | 104 | taskHelper.runNext(); |
michael@0 | 105 | return; |
michael@0 | 106 | } |
michael@0 | 107 | doTestLteSignalStrength(next.input, next.expect, do_call); |
michael@0 | 108 | })(); |
michael@0 | 109 | }); |
michael@0 | 110 | |
michael@0 | 111 | /* Reset Signal Strength Info to default, and finsih the test */ |
michael@0 | 112 | taskHelper.push(function testResetSignalStrengthInfo() { |
michael@0 | 113 | // Reset emulator's signal strength and wait for 'onvoicechange' event. |
michael@0 | 114 | function doResetSignalStrength(rssi) { |
michael@0 | 115 | waitForVoiceChangeEvent(function() { |
michael@0 | 116 | let voice = mobileConnection.voice; |
michael@0 | 117 | is(voice.signalStrength, -99, "check voice.signalStrength"); |
michael@0 | 118 | is(voice.relSignalStrength, 44, "check voice.relSignalStrength"); |
michael@0 | 119 | |
michael@0 | 120 | taskHelper.runNext(); |
michael@0 | 121 | }); |
michael@0 | 122 | |
michael@0 | 123 | setEmulatorGsmSignalStrength(rssi); |
michael@0 | 124 | } |
michael@0 | 125 | |
michael@0 | 126 | // Emulator uses rssi = 7 as default value, and we need to reset it after |
michael@0 | 127 | // finishing test in case other test cases need those values for testing. |
michael@0 | 128 | doResetSignalStrength(7); |
michael@0 | 129 | }); |
michael@0 | 130 | |
michael@0 | 131 | // Start test |
michael@0 | 132 | taskHelper.runNext(); |