From 0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 03:47:29 +0200 Subject: Adding upstream version 115.8.0esr. Signed-off-by: Daniel Baumann --- .../resources/battery-status-helpers.js | 34 ++++++++++++++++++++++ .../battery-status/resources/support-iframe.html | 5 ++++ .../resources/support-window-open.html | 10 +++++++ .../resources/window-postmessage-open-close.html | 9 ++++++ 4 files changed, 58 insertions(+) create mode 100644 testing/web-platform/tests/battery-status/resources/battery-status-helpers.js create mode 100644 testing/web-platform/tests/battery-status/resources/support-iframe.html create mode 100644 testing/web-platform/tests/battery-status/resources/support-window-open.html create mode 100644 testing/web-platform/tests/battery-status/resources/window-postmessage-open-close.html (limited to 'testing/web-platform/tests/battery-status/resources') 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 @@ + + +
+Hello! +
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 @@ + + + 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..3adb8ceecd --- /dev/null +++ b/testing/web-platform/tests/battery-status/resources/window-postmessage-open-close.html @@ -0,0 +1,9 @@ + + + + + + + -- cgit v1.2.3