mirror of
https://github.com/servo/servo.git
synced 2025-07-30 10:40:27 +01:00
40 lines
1.3 KiB
HTML
40 lines
1.3 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/"/>
|
|
<script src="/resources/testharness.js"></script>
|
|
<script src="/resources/testharnessreport.js"></script>
|
|
|
|
<div id="log"></div>
|
|
|
|
<script>
|
|
|
|
"use strict";
|
|
|
|
function waitSyntaxErrorPromise(t, reader) {
|
|
const readerWatcher = new EventWatcher(t, reader, ["reading", "error"]);
|
|
const promise = readerWatcher.wait_for("error").then(event => {
|
|
assert_equals(event.error.name, 'SyntaxError');
|
|
});
|
|
// NFCReader#start() synchronously dispatches the syntax error event.
|
|
reader.start();
|
|
return promise;
|
|
}
|
|
|
|
promise_test(t => {
|
|
const reader = new NFCReader({url: "www.a.com"});
|
|
return waitSyntaxErrorPromise(t, reader);
|
|
}, 'Test that NFCReader.start fails if NFCReaderOptions.url is missing components.');
|
|
|
|
promise_test(t => {
|
|
const reader = new NFCReader({url: "invalid"});
|
|
return waitSyntaxErrorPromise(t, reader);
|
|
}, 'Test that NFCReader.start fails if NFCReaderOptions.url is invalid.');
|
|
|
|
promise_test(t => {
|
|
const reader = new NFCReader({url: "http://a.com"});
|
|
return waitSyntaxErrorPromise(t, reader);
|
|
}, 'Test that NFCReader.start fails if NFCReaderOptions.url has wrong protocol.');
|
|
|
|
</script>
|