mirror of
https://github.com/servo/servo.git
synced 2025-07-12 01:43:43 +01:00
39 lines
1.4 KiB
HTML
39 lines
1.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/"/>
|
|
<script src="/resources/testharness.js"></script>
|
|
<script src="/resources/testharnessreport.js"></script>
|
|
|
|
<div id="log"></div>
|
|
|
|
<script>
|
|
|
|
"use strict";
|
|
|
|
promise_test(async t => {
|
|
const reader = new NFCReader({url: "www.a.com"});
|
|
const readerWatcher = new EventWatcher(t, reader, ["reading", "error"]);
|
|
reader.start();
|
|
const event = await readerWatcher.wait_for("error");
|
|
assert_equals(event.error.name, 'SyntaxError');
|
|
}, 'Test that NFCReader.start fails if NFCReaderOptions.url is missing components.');
|
|
|
|
promise_test(async t => {
|
|
const reader = new NFCReader({url: "invalid"});
|
|
const readerWatcher = new EventWatcher(t, reader, ["reading", "error"]);
|
|
reader.start();
|
|
const event = await readerWatcher.wait_for("error");
|
|
assert_equals(event.error.name, 'SyntaxError');
|
|
}, 'Test that NFCReader.start fails if NFCReaderOptions.url is invalid.');
|
|
|
|
promise_test(async t => {
|
|
const reader = new NFCReader({url: "http://a.com"});
|
|
const readerWatcher = new EventWatcher(t, reader, ["reading", "error"]);
|
|
reader.start();
|
|
const event = await readerWatcher.wait_for("error");
|
|
assert_equals(event.error.name, 'SyntaxError');
|
|
}, 'Test that NFCReader.start fails if NFCReaderOptions.url has wrong protocol.');
|
|
|
|
</script>
|