michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: MARIONETTE_TIMEOUT = 60000; michael@0: michael@0: SpecialPowers.addPermission("mobileconnection", true, document); michael@0: michael@0: // Permission changes can't change existing Navigator.prototype michael@0: // objects, so grab our objects from a new Navigator michael@0: let ifr = document.createElement("iframe"); michael@0: let connection; michael@0: ifr.onload = function() { michael@0: connection = ifr.contentWindow.navigator.mozMobileConnections[0]; michael@0: michael@0: ok(connection instanceof ifr.contentWindow.MozMobileConnection, michael@0: "connection is instanceof " + connection.constructor); michael@0: michael@0: setTimeout(testChangeCallBarringPasswordWithFailure, 0); michael@0: }; michael@0: document.body.appendChild(ifr); michael@0: michael@0: function testChangeCallBarringPasswordWithFailure() { michael@0: // Incorrect parameters, expect onerror callback. michael@0: let options = [ michael@0: {pin: null, newPin: '0000'}, michael@0: {pin: '0000', newPin: null}, michael@0: {pin: null, newPin: null}, michael@0: {pin: '000', newPin: '0000'}, michael@0: {pin: '00000', newPin: '1111'}, michael@0: {pin: 'abcd', newPin: 'efgh'}, michael@0: ]; michael@0: michael@0: function do_test() { michael@0: for (let i = 0; i < options.length; i++) { michael@0: let request = connection.changeCallBarringPassword(options[i]); michael@0: michael@0: request.onsuccess = function() { michael@0: ok(false, 'Unexpected result.'); michael@0: setTimeout(cleanUp , 0); michael@0: }; michael@0: michael@0: request.onerror = function() { michael@0: ok(request.error.name === 'InvalidPassword', 'InvalidPassword'); michael@0: if (i >= options.length) { michael@0: setTimeout(testChangeCallBarringPasswordWithSuccess, 0); michael@0: } michael@0: }; michael@0: } michael@0: } michael@0: michael@0: do_test(); michael@0: } michael@0: michael@0: function testChangeCallBarringPasswordWithSuccess() { michael@0: // TODO: Bug 906603 - B2G RIL: Support Change Call Barring Password on michael@0: // Emulator. michael@0: setTimeout(cleanUp , 0); michael@0: } michael@0: michael@0: function cleanUp() { michael@0: SpecialPowers.removePermission("mobileconnection", document); michael@0: finish(); michael@0: }