summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/page-visibility/minimize.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/page-visibility/minimize.html
parentInitial commit. (diff)
downloadfirefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz
firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/page-visibility/minimize.html')
-rw-r--r--testing/web-platform/tests/page-visibility/minimize.html53
1 files changed, 53 insertions, 0 deletions
diff --git a/testing/web-platform/tests/page-visibility/minimize.html b/testing/web-platform/tests/page-visibility/minimize.html
new file mode 100644
index 0000000000..ca834f74b6
--- /dev/null
+++ b/testing/web-platform/tests/page-visibility/minimize.html
@@ -0,0 +1,53 @@
+<!DOCTYPE HTML>
+<title>Test different scenarios of how browser interactions are reflected by page visibility</title>
+<link rel="author" title="Noam Rosenthal" href="mailto:noam@webkit.org">
+<link rel="help" href="https://www.w3.org/TR/page-visibility-2/">
+<meta name="timeout" content="long">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/testdriver.js"></script>
+<script src="/resources/testdriver-vendor.js"></script>
+<script src="resources/window_state_context.js"></script>
+<script>
+
+const iframePath = 'resources/blank_page_green.html'
+
+promise_test(async t => {
+ const {minimize, restore} = window_state_context(t);
+ assert_equals(document.visibilityState, "visible");
+ assert_equals(document.hidden, false);
+ await minimize();
+ assert_equals(document.visibilityState, "hidden");
+ assert_equals(document.hidden, true);
+ await restore()
+ assert_equals(document.visibilityState, "visible");
+ assert_equals(document.hidden, false);
+}, "visibilityState & hidden should be affected by window being minimized/restored");
+
+promise_test(async t => {
+ const {minimize, restore} = window_state_context(t);
+ const events = [];
+ const callback = () => events.push(document.visibilityState);
+ document.addEventListener('visibilitychange', callback);
+ t.add_cleanup(() => document.removeEventListener('visibilitychange', callback));
+ await minimize();
+ await restore();
+ assert_array_equals(events, ['hidden', 'visible']);
+}, "visibilitychange event should be fired when minimized/restored")
+
+promise_test(async t => {
+ const {minimize, restore} = window_state_context(t);
+ const events = [];
+ const iframe = document.createElement('iframe');
+ iframe.src = iframePath;
+ document.body.appendChild(iframe);
+ t.add_cleanup(() => iframe.remove());
+ await new Promise(resolve => iframe.onload = resolve);
+ const callback = () => events.push(iframe.contentWindow.document.visibilityState);
+ iframe.contentWindow.addEventListener('visibilitychange', callback);
+ await minimize();
+ await restore();
+ iframe.contentWindow.removeEventListener('visibilitychange', callback);
+ assert_array_equals(events, ['hidden', 'visible']);
+}, "iframe should receive visibility events when top level window is shown/hidden");
+</script> \ No newline at end of file