diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
commit | 0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d (patch) | |
tree | a31f07c9bcca9d56ce61e9a1ffd30ef350d513aa /testing/web-platform/tests/webusb/resources/open-in-iframe.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.tar.xz firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.zip |
Adding upstream version 115.8.0esr.upstream/115.8.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/webusb/resources/open-in-iframe.html')
-rw-r--r-- | testing/web-platform/tests/webusb/resources/open-in-iframe.html | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/testing/web-platform/tests/webusb/resources/open-in-iframe.html b/testing/web-platform/tests/webusb/resources/open-in-iframe.html new file mode 100644 index 0000000000..ad0e12d371 --- /dev/null +++ b/testing/web-platform/tests/webusb/resources/open-in-iframe.html @@ -0,0 +1,42 @@ +<!DOCTYPE html> +<!-- Intentionally use relative paths here because this file is also used by blink/web_tests/usb/usbDevice-iframe.html. --> +<script src="../../resources/test-only-api.js"></script> +<script src="usb-helpers.js"></script> +<script src="/resources/testdriver.js"></script> +<script src="/resources/testdriver-vendor.js"></script> + +<body> + <button>Fake user gesture</button> +</body> + +<script> + 'use strict'; + test_driver.set_test_context(parent); + window.onmessage = messageEvent => { + switch (messageEvent.data) { + case 'ConnectEvent': + navigator.usb.addEventListener('connect', connectEvent => { + connectEvent.device.open() + .then(() => parent.postMessage('Success', '*')) + .catch(err => + parent.postMessage(`FAIL: open rejected ${err}`, '*')); + }); + parent.postMessage('Ready', '*'); + break; + case 'GetDevices': + navigator.usb.getDevices() + .then(devices => parent.postMessage('Success', '*')) + .catch(err => parent.postMessage(`FAIL: ${err}`, '*')); + break; + case 'RequestDevice': + test_driver.click(document.getElementsByTagName('button')[0]) + .then(() => navigator.usb.requestDevice({filters: []})) + .then(device => parent.postMessage('Success', '*')) + .catch(err => parent.postMessage(`FAIL: ${err}`, '*')); + break; + default: + parent.postMessage( + `FAIL: Bad message type: ${messageEvent.data}`, '*'); + } + }; +</script> |