dom/mobileconnection/tests/marionette/test_call_barring_change_password.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.

     1 /* Any copyright is dedicated to the Public Domain.
     2    http://creativecommons.org/publicdomain/zero/1.0/ */
     4 MARIONETTE_TIMEOUT = 60000;
     6 SpecialPowers.addPermission("mobileconnection", true, document);
     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];
    15   ok(connection instanceof ifr.contentWindow.MozMobileConnection,
    16      "connection is instanceof " + connection.constructor);
    18   setTimeout(testChangeCallBarringPasswordWithFailure, 0);
    19 };
    20 document.body.appendChild(ifr);
    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   ];
    33   function do_test() {
    34     for (let i = 0; i < options.length; i++) {
    35       let request = connection.changeCallBarringPassword(options[i]);
    37       request.onsuccess = function() {
    38         ok(false, 'Unexpected result.');
    39         setTimeout(cleanUp , 0);
    40       };
    42       request.onerror = function() {
    43         ok(request.error.name === 'InvalidPassword', 'InvalidPassword');
    44         if (i >= options.length) {
    45           setTimeout(testChangeCallBarringPasswordWithSuccess, 0);
    46         }
    47       };
    48     }
    49   }
    51   do_test();
    52 }
    54 function testChangeCallBarringPasswordWithSuccess() {
    55   // TODO: Bug 906603 - B2G RIL: Support Change Call Barring Password on
    56   // Emulator.
    57   setTimeout(cleanUp , 0);
    58 }
    60 function cleanUp() {
    61   SpecialPowers.removePermission("mobileconnection", document);
    62   finish();
    63 }

mercurial