dom/nfc/tests/marionette/test_nfc_enabled.js

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 /* Any copyright is dedicated to the Public Domain.
michael@0 2 http://creativecommons.org/publicdomain/zero/1.0/ */
michael@0 3
michael@0 4 MARIONETTE_TIMEOUT = 30000;
michael@0 5 MARIONETTE_HEAD_JS = 'head.js';
michael@0 6
michael@0 7 let nfc = window.navigator.mozNfc;
michael@0 8 function testEnableNFC() {
michael@0 9 log('Running \'testEnableNFC\'');
michael@0 10 let req = nfc.startPoll();
michael@0 11 req.onsuccess = function () {
michael@0 12 ok(true);
michael@0 13 runNextTest();
michael@0 14 };
michael@0 15 req.onerror = function () {
michael@0 16 ok(false, "startPoll failed");
michael@0 17 runNextTest();
michael@0 18 };
michael@0 19 }
michael@0 20
michael@0 21 function testDisableNFC() {
michael@0 22 log('Running \'testDisableNFC\'');
michael@0 23 let req = nfc.powerOff();
michael@0 24 req.onsuccess = function () {
michael@0 25 ok(true);
michael@0 26 runNextTest();
michael@0 27 };
michael@0 28 req.onerror = function () {
michael@0 29 ok(false, "powerOff failed");
michael@0 30 runNextTest();
michael@0 31 };
michael@0 32 }
michael@0 33
michael@0 34 function testStopPollNFC() {
michael@0 35 log('Running \'testStopPollNFC\'');
michael@0 36 let req = nfc.stopPoll();
michael@0 37 req.onsuccess = function () {
michael@0 38 ok(true);
michael@0 39 runNextTest();
michael@0 40 };
michael@0 41 req.onerror = function () {
michael@0 42 ok(false, "stopPoll failed");
michael@0 43 runNextTest();
michael@0 44 };
michael@0 45 }
michael@0 46
michael@0 47 let tests = [
michael@0 48 testEnableNFC,
michael@0 49 testStopPollNFC,
michael@0 50 testDisableNFC
michael@0 51 ];
michael@0 52
michael@0 53 SpecialPowers.pushPermissions(
michael@0 54 [{'type': 'nfc-manager', 'allow': true, 'context': document}],
michael@0 55 runTests);

mercurial