diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/battery-status/resources | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/battery-status/resources')
4 files changed, 58 insertions, 0 deletions
diff --git a/testing/web-platform/tests/battery-status/resources/battery-status-helpers.js b/testing/web-platform/tests/battery-status/resources/battery-status-helpers.js new file mode 100644 index 0000000000..02acfe6c29 --- /dev/null +++ b/testing/web-platform/tests/battery-status/resources/battery-status-helpers.js @@ -0,0 +1,34 @@ +'use strict'; + +// These tests rely on the User Agent providing an implementation of +// platform battery status backends. +// +// In Chromium-based browsers this implementation is provided by a polyfill +// in order to reduce the amount of test-only code shipped to users. To enable +// these tests the browser must be run with these options: +// +// --enable-blink-features=MojoJS,MojoJSTest + +let mockBatteryMonitor = undefined; + +function battery_status_test(func, name, properties) { + promise_test(async t => { + if (mockBatteryMonitor === undefined) { + if (isChromiumBased) { + const mocks = + await import('/resources/chromium/mock-battery-monitor.js'); + mockBatteryMonitor = mocks.mockBatteryMonitor; + } + } + assert_implements( + mockBatteryMonitor, 'missing mockBatteryMonitor after initialization'); + + mockBatteryMonitor.start(); + + t.add_cleanup(() => { + mockBatteryMonitor.reset(); + return mockBatteryMonitor.stop(); + }); + return func(t, mockBatteryMonitor); + }, name, properties); +} diff --git a/testing/web-platform/tests/battery-status/resources/support-iframe.html b/testing/web-platform/tests/battery-status/resources/support-iframe.html new file mode 100644 index 0000000000..d4e5b31f13 --- /dev/null +++ b/testing/web-platform/tests/battery-status/resources/support-iframe.html @@ -0,0 +1,5 @@ +<!DOCTYPE HTML> +<meta charset="utf-8"> +<div> +Hello! +</div> diff --git a/testing/web-platform/tests/battery-status/resources/support-window-open.html b/testing/web-platform/tests/battery-status/resources/support-window-open.html new file mode 100644 index 0000000000..afffc3af28 --- /dev/null +++ b/testing/web-platform/tests/battery-status/resources/support-window-open.html @@ -0,0 +1,10 @@ +<!DOCTYPE HTML> +<meta charset="utf-8"> +<script> +var data = [ + navigator === window.opener.navigator, + navigator.getBattery() === window.opener.navigator.getBattery(), + navigator.getBattery() === navigator.getBattery() +]; +window.opener.postMessage(data, '*'); +</script> diff --git a/testing/web-platform/tests/battery-status/resources/window-postmessage-open-close.html b/testing/web-platform/tests/battery-status/resources/window-postmessage-open-close.html new file mode 100644 index 0000000000..ae256c71ce --- /dev/null +++ b/testing/web-platform/tests/battery-status/resources/window-postmessage-open-close.html @@ -0,0 +1,9 @@ +<!DOCTYPE html> +<!-- Used when testing access of a closed/detached window's properties --> +<html> +<body onpagehide="opener.postMessage('closed', '*');"> +<script> +opener.postMessage("opened", "*"); +</script> +</body> +</html> |