gecko-dev/testing/web-platform/tests/web-nfc/NFCReader-manual.https.html
kaixinjxq b968ac40e9 Bug 1533676 [wpt PR 15666] - Update web-nfc nfc_watch.https.html, a=testonly
Automatic update from web-platform-tests
Update web-nfc nfc_watch.https.html (#15666)

* Update web-nfc nfc_watch.https.html
* Make code nicer
* Change NFCReader tests to manual tests
* Address @Honry's comments
* Delete redundant code and s/enable/enabled

--

wpt-commits: 2b3fc33c35c0f89a271f4f7019a0b61255e52fae
wpt-pr: 15666
2019-04-01 14:42:59 +01:00

64 lines
2.4 KiB
HTML

<!DOCTYPE html>
<meta charset=utf-8>
<title>Web NFC: NFCReader tests</title>
<link rel="author" title="Intel" href="http://www.intel.com"/>
<link rel="help" href="https://w3c.github.io/web-nfc/"/>
<meta name="timeout" content="long">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<meta name="flags" content="interact">
<p>Tap an NFC tag to the test device with NFC support.</p>
<p>Note: All the actions need to be done in 60 seconds, otherwise it will get TIMEOUT.</p>
<div id="log"></div>
<script>
"use strict";
promise_test(async t => {
const reader = new NFCReader();
const readerWatcher = new EventWatcher(t, reader, ["reading", "error"]);
reader.start();
const event = await readerWatcher.wait_for("reading");
assert_true(event instanceof NFCReadingEvent);
}, 'Test that nfc watch success if NFC HW is enabled.');
promise_test(async t => {
const reader = new NFCReader({url: "https://a.com"});
const readerWatcher = new EventWatcher(t, reader, ["reading", "error"]);
reader.start();
const event = await readerWatcher.wait_for("reading");
assert_true(event instanceof NFCReadingEvent);
}, 'Test that NFCReader.start succeeds if NFCReaderOptions.url is valid URL.');
promise_test(async t => {
const reader = new NFCReader({url: "https://a.com/*"});
const readerWatcher = new EventWatcher(t, reader, ["reading", "error"]);
reader.start();
const event = await readerWatcher.wait_for("reading");
assert_true(event instanceof NFCReadingEvent);
}, 'Test that NFCReader.start succeeds if NFCReaderOptions.url is valid URL with "*"' +
' wildcard character in path.');
promise_test(async t => {
const reader = new NFCReader({url: "https://a.com/*/bar"});
const readerWatcher = new EventWatcher(t, reader, ["reading", "error"]);
reader.start();
const event = await readerWatcher.wait_for("reading");
assert_true(event instanceof NFCReadingEvent);
}, 'Test that NFCReader.start succeeds if NFCReaderOptions.url is valid URL with "*"' +
' wildcard character in the beginning of path component followed by' +
' subpath.');
promise_test(async t => {
const reader = new NFCReader({url: ""});
const readerWatcher = new EventWatcher(t, reader, ["reading", "error"]);
reader.start();
const event = await readerWatcher.wait_for("reading");
assert_true(event instanceof NFCReadingEvent);
}, 'Test that NFCReader.start succeeds if NFCReaderOptions.url is empty.');
</script>