mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1087928 - write marionette-webapi tests for ontagfound. r=yoshi
This commit is contained in:
parent
50beb391b6
commit
5d4e906c48
@ -14,3 +14,5 @@ qemu=true
|
||||
[test_nfc_read_tag.js]
|
||||
[test_nfc_checkP2PRegistration.js]
|
||||
[test_nfc_error_messages.js]
|
||||
[test_nfc_tag_found.js]
|
||||
[test_nfc_tag_lost.js]
|
||||
|
46
dom/nfc/tests/marionette/test_nfc_tag_found.js
Normal file
46
dom/nfc/tests/marionette/test_nfc_tag_found.js
Normal file
@ -0,0 +1,46 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
MARIONETTE_TIMEOUT = 30000;
|
||||
MARIONETTE_HEAD_JS = 'head.js';
|
||||
|
||||
function handleTechnologyDiscoveredRE0(msg) {
|
||||
log('Received \'nfc-manager-tech-discovered\'');
|
||||
ok(msg.peer, 'check for correct tech type');
|
||||
|
||||
deactivateAndWaitForTechLost().then(() => toggleNFC(false)).then(runNextTest);
|
||||
}
|
||||
|
||||
function tagFoundCb(evt) {
|
||||
log("tagFoundCb called ");
|
||||
ok(evt.tag instanceof MozNFCTag, "Should get a NFCTag object.");
|
||||
|
||||
nfc.ontagfound = null;
|
||||
deactivateAndWaitForTechLost().then(() => toggleNFC(false)).then(runNextTest);
|
||||
}
|
||||
|
||||
function tagFoundErrorCb(evt) {
|
||||
ok(false, "ontagfound shouldn't be called");
|
||||
}
|
||||
|
||||
function testTagFound() {
|
||||
nfc.ontagfound = tagFoundCb;
|
||||
|
||||
toggleNFC(true).then(() => NCI.activateRE(emulator.T1T_RE_INDEX));
|
||||
}
|
||||
|
||||
function testTagFoundShouldNotFired() {
|
||||
nfc.ontagfound = tagFoundErrorCb;
|
||||
sysMsgHelper.waitForTechDiscovered(handleTechnologyDiscoveredRE0);
|
||||
|
||||
toggleNFC(true).then(() => NCI.activateRE(emulator.P2P_RE_INDEX_0));
|
||||
}
|
||||
|
||||
var tests = [
|
||||
testTagFound,
|
||||
testTagFoundShouldNotFired
|
||||
];
|
||||
|
||||
SpecialPowers.pushPermissions(
|
||||
[{"type": "nfc", "allow": true, context: document},
|
||||
{'type': 'nfc-manager', 'allow': true, context: document}], runTests);
|
36
dom/nfc/tests/marionette/test_nfc_tag_lost.js
Normal file
36
dom/nfc/tests/marionette/test_nfc_tag_lost.js
Normal file
@ -0,0 +1,36 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
MARIONETTE_TIMEOUT = 30000;
|
||||
MARIONETTE_HEAD_JS = 'head.js';
|
||||
|
||||
function tagFoundCb(evt) {
|
||||
log("tagFoundCb called ");
|
||||
ok(evt.tag instanceof MozNFCTag, "Should get a NFCTag object.");
|
||||
|
||||
NCI.deactivate();
|
||||
}
|
||||
|
||||
function tagLostCb(evt) {
|
||||
log("tagLostCb called ");
|
||||
ok(true);
|
||||
|
||||
nfc.ontagfound = null;
|
||||
nfc.ontaglost = null;
|
||||
toggleNFC(false).then(runNextTest);
|
||||
}
|
||||
|
||||
function testTagLost() {
|
||||
nfc.ontagfound = tagFoundCb;
|
||||
nfc.ontaglost = tagLostCb;
|
||||
|
||||
toggleNFC(true).then(() => NCI.activateRE(emulator.T1T_RE_INDEX));
|
||||
}
|
||||
|
||||
var tests = [
|
||||
testTagLost
|
||||
];
|
||||
|
||||
SpecialPowers.pushPermissions(
|
||||
[{"type": "nfc", "allow": true, context: document},
|
||||
{'type': 'nfc-manager', 'allow': true, context: document}], runTests);
|
Loading…
Reference in New Issue
Block a user