diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /testing/web-platform/tests/page-visibility/visibility-state-entry.tentative.html | |
parent | Initial commit. (diff) | |
download | thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/page-visibility/visibility-state-entry.tentative.html')
-rw-r--r-- | testing/web-platform/tests/page-visibility/visibility-state-entry.tentative.html | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/testing/web-platform/tests/page-visibility/visibility-state-entry.tentative.html b/testing/web-platform/tests/page-visibility/visibility-state-entry.tentative.html new file mode 100644 index 0000000000..0dbe634d25 --- /dev/null +++ b/testing/web-platform/tests/page-visibility/visibility-state-entry.tentative.html @@ -0,0 +1,70 @@ +<!DOCTYPE HTML> +<title>Test VisibleStateEntry</title> +<link rel="author" title="Noam Rosenthal" href="mailto:nrosenthal@chromium.org"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/interaction.html#page-visibility"> +<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> + +setup(() => { + assert_implements(window.VisibilityStateEntry, 'VisibilityStateEntry is not supported.'); +}); + +promise_test(async t => { + const {minimizeAndWait, restoreAndWait} = window_state_context(t); + const all = performance.getEntries(); + let entries = performance.getEntriesByType("visibility-state"); + assert_equals(entries.length, 1); + assert_equals(entries[0].name, "visible"); + assert_equals(entries[0].startTime, 0); + assert_equals(entries[0].duration, 0); + await minimizeAndWait(); + entries = performance.getEntriesByType("visibility-state"); + assert_equals(entries.length, 2); + assert_equals(entries[1].name, "hidden"); + assert_equals(entries[1].duration, 0); + await restoreAndWait(); + entries = performance.getEntriesByType("visibility-state"); + assert_equals(entries.length, 3); + assert_equals(entries[2].name, "visible"); + assert_equals(entries[2].duration, 0); +}, "Hiding/showing the page should create visibility-state entries"); + +promise_test(async t => { + const {minimizeAndWait} = window_state_context(t); + await minimizeAndWait(); + const iframe = document.createElement("iframe"); + iframe.src = "resources/blank_page_green.html"; + const loaded = new Promise(resolve => iframe.addEventListener("load", resolve)); + t.add_cleanup(() => iframe.remove()); + document.body.appendChild(iframe); + await loaded; + const entries = iframe.contentWindow.performance.getEntriesByType("visibility-state"); + assert_equals(entries[0].name, "hidden"); + assert_equals(entries[0].startTime, 0); +}, "If a page starts as hidden, the first visibility-state entry should be hidden"); + +promise_test(async t => { + const {minimize, restore} = window_state_context(t); + const observed = new Promise(resolve => new PerformanceObserver(list => { + if (list.getEntries()[0].name === "visible") + resolve(); + }).observe({entryTypes: ['visibility-state']})); + await minimize(); + await restore(); + await observed; +}, "Visibility state entries should be queued to performance observers"); + +promise_test(async t => { + const entry = await new Promise(resolve => new PerformanceObserver( + (list, observer) => { + observer.disconnect(); + resolve(list.getEntries()[0]); + }).observe({type: "visibility-state", buffered: true})); + assert_equals(entry.name, "visible"); +}, "Visibility state observers should respect the buffered flag"); +</script> |