dom/nfc/tests/marionette/test_nfc_enabled.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 = 30000;
     5 MARIONETTE_HEAD_JS = 'head.js';
     7 let nfc = window.navigator.mozNfc;
     8 function testEnableNFC() {
     9   log('Running \'testEnableNFC\'');
    10   let req = nfc.startPoll();
    11   req.onsuccess = function () {
    12     ok(true);
    13     runNextTest();
    14   };
    15   req.onerror = function () {
    16     ok(false, "startPoll failed");
    17     runNextTest();
    18   };
    19 }
    21 function testDisableNFC() {
    22   log('Running \'testDisableNFC\'');
    23   let req = nfc.powerOff();
    24   req.onsuccess = function () {
    25     ok(true);
    26     runNextTest();
    27   };
    28   req.onerror = function () {
    29     ok(false, "powerOff failed");
    30     runNextTest();
    31   };
    32 }
    34 function testStopPollNFC() {
    35   log('Running \'testStopPollNFC\'');
    36   let req = nfc.stopPoll();
    37   req.onsuccess = function () {
    38     ok(true);
    39     runNextTest();
    40   };
    41   req.onerror = function () {
    42     ok(false, "stopPoll failed");
    43     runNextTest();
    44   };
    45 }
    47 let tests = [
    48   testEnableNFC,
    49   testStopPollNFC,
    50   testDisableNFC
    51 ];
    53 SpecialPowers.pushPermissions(
    54   [{'type': 'nfc-manager', 'allow': true, 'context': document}],
    55   runTests);

mercurial