dom/mobileconnection/tests/marionette/test_call_barring_set_error.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   nextTest();
    19 };
    20 document.body.appendChild(ifr);
    22 let caseId = 0;
    23 let options = [
    24   buildOption(5, true, '0000', 0),  // invalid program.
    26   // test null.
    27   buildOption(null, true, '0000', 0),
    28   buildOption(0, null, '0000', 0),
    29   buildOption(0, true, null, 0),
    30   buildOption(0, true, '0000', null),
    32   // test undefined.
    33   {'enabled': true, 'password': '0000', 'serviceClass': 0},
    34   {'program': 0, 'password': '0000', 'serviceClass': 0},
    35   {'program': 0, 'enabled': true, 'serviceClass': 0},
    36   {'program': 0, 'enabled': true, 'password': '0000'},
    37 ];
    39 function buildOption(program, enabled, password, serviceClass) {
    40   return {
    41     'program': program,
    42     'enabled': enabled,
    43     'password': password,
    44     'serviceClass': serviceClass
    45   };
    46 }
    48 function testSetCallBarringOptionError(option) {
    49   let request = connection.setCallBarringOption(option);
    50   request.onsuccess = function() {
    51     ok(false,
    52        'should not fire onsuccess for invaild call barring option: '
    53        + JSON.stringify(option));
    54   };
    55   request.onerror = function(event) {
    56     is(event.target.error.name, 'InvalidParameter', JSON.stringify(option));
    57     nextTest();
    58   };
    59 }
    61 function nextTest() {
    62   if (caseId >= options.length) {
    63     cleanUp();
    64   } else {
    65     let option = options[caseId++];
    66     log('test for ' + JSON.stringify(option));
    67     testSetCallBarringOptionError(option);
    68   }
    69 }
    71 function cleanUp() {
    72   SpecialPowers.removePermission("mobileconnection", document);
    73   finish();
    74 }

mercurial