Revision eb9f8a917a751b5bd2e4ed86840eac8b5c4445f2 authored by Brian Birtles on 15 March 2018, 06:57:09 UTC, committed by Brian Birtles on 15 March 2018, 06:57:09 UTC
This patch also drops the test that an AnimationEffectTiming object is
created in the appropriate realm since it is no longer the case that
a separate timing object is created.
1 parent df2153f
Raw File
nfc_watch.https.html
<!DOCTYPE html>
<meta charset=utf-8>
<title>Web NFC: nfc.watch 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>
<script src="resources/nfc_help.js"></script>

<div id="log"></div>

<script>

"use strict";

promise_test(t => {
  return promise_rejects(t, 'NotFoundError', navigator.nfc.cancelWatch(1));
}, "Test that nfc.cancelWatch fails if invalid watch ID is provided.");

promise_test(t => {
  return promise_rejects(t, 'NotFoundError', navigator.nfc.cancelWatch());
}, "Test that nfc.cancelWatch fails if there are no active watchers.");

promise_test(t => {
  return navigator.nfc.watch(noop).then(id => {
    assert_equals(typeof(id), "number");
    assert_greater_than(id, 0, "greater than zero");
  });
}, "Test that nfc watch success if NFC HW is enable.");

promise_test(t => {
  return navigator.nfc.watch(noop).
      then(id => navigator.nfc.cancelWatch(id));
}, "Test that nfc.cancelWatch succeeds if correct watch id is provided.");

promise_test(t => {
  return navigator.nfc.watch(noop).then(() => {
    navigator.nfc.cancelWatch();
  });
}, "Test that nfc.cancelWatch succeeds if there are active watchers.");

promise_test(t => {
  return promise_rejects(t, 'SyntaxError', navigator.nfc.watch(noop, {url:"www.a.com"}));
}, 'Test that nfc.watch fails if NFCWatchOptions.url is missing components.');

promise_test(t => {
  return promise_rejects(t, 'SyntaxError', navigator.nfc.watch(noop, {url:"invalid"}));
}, 'Test that nfc.watch fails if NFCWatchOptions.url is invalid.');

promise_test(t => {
  return promise_rejects(t, 'SyntaxError', navigator.nfc.watch(noop, {url:"http://a.com"}));
}, 'Test that nfc.watch fails if NFCWatchOptions.url has wrong protocol.');

promise_test(t => {
  return navigator.nfc.watch(noop, {url:"https://a.com"});
}, 'Test that nfc.watch succeeds if NFCWatchOptions.url is valid URL.');

promise_test(t => {
  return navigator.nfc.watch(noop, {url:"https://a.com/*"});
}, 'Test that nfc.watch succeeds if NFCWatchOptions.url is valid URL with "*"' +
   ' wildcard character in path.');

promise_test(t => {
  return navigator.nfc.watch(noop, {url:"https://a.com/*/bar"});
}, 'Test that nfc.watch succeeds if NFCWatchOptions.url is valid URL with "*"' +
   ' wildcard character in the beginning of path component followed by' +
   ' subpath.');

promise_test(t => {
  return navigator.nfc.watch(noop, {url:""});
}, 'Test that nfc.watch succeeds if NFCWatchOptions.url is empty.');

</script>
back to top