dom/fmradio/test/marionette/test_bug862672.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* Any copyright is dedicated to the Public Domain.
     2  * http://creativecommons.org/publicdomain/zero/1.0/ */
     4 MARIONETTE_TIMEOUT = 10000;
     6 SpecialPowers.addPermission("fmradio", true, document);
     8 let FMRadio = window.navigator.mozFMRadio;
    10 function verifyInitialState() {
    11   log("Verifying initial state.");
    12   ok(FMRadio);
    13   is(FMRadio.enabled, false);
    14   enableThenDisable();
    15 }
    17 function enableThenDisable() {
    18   log("Enable FM Radio and disable it immediately.");
    19   var frequency = FMRadio.frequencyLowerBound + FMRadio.channelWidth;
    20   var request = FMRadio.enable(frequency);
    21   ok(request);
    23   var failedToEnable = false;
    24   request.onerror = function() {
    25     failedToEnable = true;
    26   };
    28   var enableCompleted = false;
    29   request.onsuccess = function() {
    30     ok(!failedToEnable);
    31     enableCompleted = true;
    32   };
    34   var disableReq = FMRadio.disable();
    35   ok(disableReq);
    37   disableReq.onsuccess = function() {
    38     // There are two possibilities which depends on the system
    39     // process scheduling (bug 911063 comment 0):
    40     //   - enable fails
    41     //   - enable's onsuccess fires before disable's onsucess
    42     ok(failedToEnable || enableCompleted);
    43     ok(!FMRadio.enabled);
    44     finish();
    45   };
    47   disableReq.onerror = function() {
    48     ok(false, "Disable request should not fail.");
    49   };
    50 }
    52 verifyInitialState();

mercurial