summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/web-nfc/NDEFReader_scan_iframe.https.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /testing/web-platform/tests/web-nfc/NDEFReader_scan_iframe.https.html
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/web-nfc/NDEFReader_scan_iframe.https.html')
-rw-r--r--testing/web-platform/tests/web-nfc/NDEFReader_scan_iframe.https.html43
1 files changed, 43 insertions, 0 deletions
diff --git a/testing/web-platform/tests/web-nfc/NDEFReader_scan_iframe.https.html b/testing/web-platform/tests/web-nfc/NDEFReader_scan_iframe.https.html
new file mode 100644
index 0000000000..6967c76ecd
--- /dev/null
+++ b/testing/web-platform/tests/web-nfc/NDEFReader_scan_iframe.https.html
@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<meta charset=utf-8>
+<title>NDEFReader.scan with an focused iframe</title>
+<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-helpers.js"></script>
+<body>
+<script>
+
+nfc_test(async (t, mockNFC) => {
+ const ndef = new NDEFReader();
+ const controller = new AbortController();
+ const ndefWatcher = new EventWatcher(t, ndef, ["reading", "readingerror"]);
+
+ const promise = ndefWatcher.wait_for("reading").then(event => {
+ assert_true(event instanceof NDEFReadingEvent);
+ controller.abort();
+ });
+ await ndef.scan({ signal: controller.signal });
+
+ const iframe = document.createElement('iframe');
+ iframe.src = 'resources/support-iframe.html';
+
+ const iframeLoadWatcher = new EventWatcher(t, iframe, 'load');
+ document.body.appendChild(iframe);
+ await iframeLoadWatcher.wait_for('load');
+ // Focus on iframe.
+ iframe.contentWindow.document.getElementById('foo').focus();
+ assert_true(iframe.contentDocument.hasFocus(), 'iframe gains the focus');
+ // Suspend NFC operations is async in blink, use setTimeout as a workaround.
+ // TODO(wanming.lin@intel.com): find a good way to eliminate this race
+ // condition.
+ await new Promise(resolve => t.step_timeout(resolve, 0));
+ mockNFC.setReadingMessage(createMessage([createTextRecord(test_text_data)]));
+ await promise;
+
+ // Remove iframe from main document.
+ iframe.parentNode.removeChild(iframe);
+}, 'Test that NDEFReader.scan is not suspended if iframe gains focus.');
+
+</script>
+</body>