1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/mobileconnection/tests/marionette/test_call_barring_change_password.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,63 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +MARIONETTE_TIMEOUT = 60000; 1.8 + 1.9 +SpecialPowers.addPermission("mobileconnection", true, document); 1.10 + 1.11 +// Permission changes can't change existing Navigator.prototype 1.12 +// objects, so grab our objects from a new Navigator 1.13 +let ifr = document.createElement("iframe"); 1.14 +let connection; 1.15 +ifr.onload = function() { 1.16 + connection = ifr.contentWindow.navigator.mozMobileConnections[0]; 1.17 + 1.18 + ok(connection instanceof ifr.contentWindow.MozMobileConnection, 1.19 + "connection is instanceof " + connection.constructor); 1.20 + 1.21 + setTimeout(testChangeCallBarringPasswordWithFailure, 0); 1.22 +}; 1.23 +document.body.appendChild(ifr); 1.24 + 1.25 +function testChangeCallBarringPasswordWithFailure() { 1.26 + // Incorrect parameters, expect onerror callback. 1.27 + let options = [ 1.28 + {pin: null, newPin: '0000'}, 1.29 + {pin: '0000', newPin: null}, 1.30 + {pin: null, newPin: null}, 1.31 + {pin: '000', newPin: '0000'}, 1.32 + {pin: '00000', newPin: '1111'}, 1.33 + {pin: 'abcd', newPin: 'efgh'}, 1.34 + ]; 1.35 + 1.36 + function do_test() { 1.37 + for (let i = 0; i < options.length; i++) { 1.38 + let request = connection.changeCallBarringPassword(options[i]); 1.39 + 1.40 + request.onsuccess = function() { 1.41 + ok(false, 'Unexpected result.'); 1.42 + setTimeout(cleanUp , 0); 1.43 + }; 1.44 + 1.45 + request.onerror = function() { 1.46 + ok(request.error.name === 'InvalidPassword', 'InvalidPassword'); 1.47 + if (i >= options.length) { 1.48 + setTimeout(testChangeCallBarringPasswordWithSuccess, 0); 1.49 + } 1.50 + }; 1.51 + } 1.52 + } 1.53 + 1.54 + do_test(); 1.55 +} 1.56 + 1.57 +function testChangeCallBarringPasswordWithSuccess() { 1.58 + // TODO: Bug 906603 - B2G RIL: Support Change Call Barring Password on 1.59 + // Emulator. 1.60 + setTimeout(cleanUp , 0); 1.61 +} 1.62 + 1.63 +function cleanUp() { 1.64 + SpecialPowers.removePermission("mobileconnection", document); 1.65 + finish(); 1.66 +}