dom/mobileconnection/tests/marionette/test_mobile_roaming_preference.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

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
michael@0 6 SpecialPowers.addPermission("mobileconnection", true, document);
michael@0 7
michael@0 8 let connection = navigator.mozMobileConnections[0];
michael@0 9 ok(connection instanceof MozMobileConnection,
michael@0 10 "connection is instanceof " + connection.constructor);
michael@0 11
michael@0 12 function failedToSetRoamingPreference(mode, expectedErrorMessage, callback) {
michael@0 13 let request = connection.setRoamingPreference(mode);
michael@0 14
michael@0 15 ok(request instanceof DOMRequest,
michael@0 16 "request instanceof " + request.constructor);
michael@0 17
michael@0 18 request.onsuccess = function onsuccess() {
michael@0 19 ok(false, "Should not be here !!");
michael@0 20
michael@0 21 callback();
michael@0 22 }
michael@0 23
michael@0 24 request.onerror = function onerror() {
michael@0 25 is(request.error.name, expectedErrorMessage);
michael@0 26
michael@0 27 callback();
michael@0 28 }
michael@0 29 }
michael@0 30
michael@0 31 function testSetRoamingPreferenceWithNullValue() {
michael@0 32 log("test setRoamingPreference(null)");
michael@0 33
michael@0 34 failedToSetRoamingPreference(null, "InvalidParameter", runNextTest);
michael@0 35 }
michael@0 36
michael@0 37 function testSetRoamingPreferenceWithInvalidValue() {
michael@0 38 log("test setRoamingPreference(\"InvalidValue\")");
michael@0 39
michael@0 40 failedToSetRoamingPreference("InvalidValue", "InvalidParameter", runNextTest);
michael@0 41 }
michael@0 42
michael@0 43 function testSetRoamingPreferenceToHome() {
michael@0 44 log("test setRoamingPreference(\"home\")");
michael@0 45
michael@0 46 // TODO: Bug 896394.
michael@0 47 // Currently emulator run as GSM mode by default. So we expect to get a
michael@0 48 // 'RequestNotSupported' error here.
michael@0 49 failedToSetRoamingPreference("home", "RequestNotSupported", runNextTest);
michael@0 50 }
michael@0 51
michael@0 52 function testGetRoamingPreference() {
michael@0 53 log("test getRoamingPreference()");
michael@0 54
michael@0 55 // TODO: Bug 896394.
michael@0 56 // Currently emulator run as GSM mode by default. So we expect to get a
michael@0 57 // 'RequestNotSupported' error here.
michael@0 58 let request = connection.getRoamingPreference();
michael@0 59
michael@0 60 ok(request instanceof DOMRequest,
michael@0 61 "request instanceof " + request.constructor);
michael@0 62
michael@0 63 request.onsuccess = function onsuccess() {
michael@0 64 ok(false, "Should not be here !!");
michael@0 65
michael@0 66 runNextTest();
michael@0 67 }
michael@0 68
michael@0 69 request.onerror = function onerror() {
michael@0 70 is(request.error.name, "RequestNotSupported");
michael@0 71
michael@0 72 runNextTest();
michael@0 73 }
michael@0 74 }
michael@0 75
michael@0 76 let tests = [
michael@0 77 testSetRoamingPreferenceWithNullValue,
michael@0 78 testSetRoamingPreferenceWithInvalidValue,
michael@0 79 testSetRoamingPreferenceToHome,
michael@0 80 testGetRoamingPreference
michael@0 81 ];
michael@0 82
michael@0 83 function runNextTest() {
michael@0 84 let test = tests.shift();
michael@0 85 if (!test) {
michael@0 86 cleanUp();
michael@0 87 return;
michael@0 88 }
michael@0 89
michael@0 90 test();
michael@0 91 }
michael@0 92
michael@0 93 function cleanUp() {
michael@0 94 SpecialPowers.removePermission("mobileconnection", document);
michael@0 95 finish();
michael@0 96 }
michael@0 97
michael@0 98 runNextTest();

mercurial