dom/mobileconnection/tests/marionette/test_call_barring_change_password.js

branch
TOR_BUG_3246
changeset 7
129ffea94266
equal deleted inserted replaced
-1:000000000000 0:b77c7e6e2857
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
3
4 MARIONETTE_TIMEOUT = 60000;
5
6 SpecialPowers.addPermission("mobileconnection", true, document);
7
8 // Permission changes can't change existing Navigator.prototype
9 // objects, so grab our objects from a new Navigator
10 let ifr = document.createElement("iframe");
11 let connection;
12 ifr.onload = function() {
13 connection = ifr.contentWindow.navigator.mozMobileConnections[0];
14
15 ok(connection instanceof ifr.contentWindow.MozMobileConnection,
16 "connection is instanceof " + connection.constructor);
17
18 setTimeout(testChangeCallBarringPasswordWithFailure, 0);
19 };
20 document.body.appendChild(ifr);
21
22 function testChangeCallBarringPasswordWithFailure() {
23 // Incorrect parameters, expect onerror callback.
24 let options = [
25 {pin: null, newPin: '0000'},
26 {pin: '0000', newPin: null},
27 {pin: null, newPin: null},
28 {pin: '000', newPin: '0000'},
29 {pin: '00000', newPin: '1111'},
30 {pin: 'abcd', newPin: 'efgh'},
31 ];
32
33 function do_test() {
34 for (let i = 0; i < options.length; i++) {
35 let request = connection.changeCallBarringPassword(options[i]);
36
37 request.onsuccess = function() {
38 ok(false, 'Unexpected result.');
39 setTimeout(cleanUp , 0);
40 };
41
42 request.onerror = function() {
43 ok(request.error.name === 'InvalidPassword', 'InvalidPassword');
44 if (i >= options.length) {
45 setTimeout(testChangeCallBarringPasswordWithSuccess, 0);
46 }
47 };
48 }
49 }
50
51 do_test();
52 }
53
54 function testChangeCallBarringPasswordWithSuccess() {
55 // TODO: Bug 906603 - B2G RIL: Support Change Call Barring Password on
56 // Emulator.
57 setTimeout(cleanUp , 0);
58 }
59
60 function cleanUp() {
61 SpecialPowers.removePermission("mobileconnection", document);
62 finish();
63 }

mercurial