From 43a97878ce14b72f0981164f87f2e35e14151312 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:22:09 +0200 Subject: Adding upstream version 110.0.1. Signed-off-by: Daniel Baumann --- .../resources/blank_page_green.html | 10 ++ .../resources/iframe-post-load.html | 8 ++ .../resources/iframe-with-subframes.html | 6 ++ .../tests/page-visibility/resources/iframe.html | 12 +++ .../resources/pagevistestharness.js | 112 +++++++++++++++++++++ .../page-visibility/resources/unload-bubbles.html | 19 ++++ .../tests/page-visibility/resources/unload.html | 17 ++++ .../resources/window_state_context.js | 19 ++++ 8 files changed, 203 insertions(+) create mode 100644 testing/web-platform/tests/page-visibility/resources/blank_page_green.html create mode 100644 testing/web-platform/tests/page-visibility/resources/iframe-post-load.html create mode 100644 testing/web-platform/tests/page-visibility/resources/iframe-with-subframes.html create mode 100644 testing/web-platform/tests/page-visibility/resources/iframe.html create mode 100644 testing/web-platform/tests/page-visibility/resources/pagevistestharness.js create mode 100644 testing/web-platform/tests/page-visibility/resources/unload-bubbles.html create mode 100644 testing/web-platform/tests/page-visibility/resources/unload.html create mode 100644 testing/web-platform/tests/page-visibility/resources/window_state_context.js (limited to 'testing/web-platform/tests/page-visibility/resources') diff --git a/testing/web-platform/tests/page-visibility/resources/blank_page_green.html b/testing/web-platform/tests/page-visibility/resources/blank_page_green.html new file mode 100644 index 0000000000..b8a1947b77 --- /dev/null +++ b/testing/web-platform/tests/page-visibility/resources/blank_page_green.html @@ -0,0 +1,10 @@ + + + + + Green Test Page + + +

Placeholder

+ + diff --git a/testing/web-platform/tests/page-visibility/resources/iframe-post-load.html b/testing/web-platform/tests/page-visibility/resources/iframe-post-load.html new file mode 100644 index 0000000000..5c8f2e3a08 --- /dev/null +++ b/testing/web-platform/tests/page-visibility/resources/iframe-post-load.html @@ -0,0 +1,8 @@ + + + + + + diff --git a/testing/web-platform/tests/page-visibility/resources/iframe-with-subframes.html b/testing/web-platform/tests/page-visibility/resources/iframe-with-subframes.html new file mode 100644 index 0000000000..febb954369 --- /dev/null +++ b/testing/web-platform/tests/page-visibility/resources/iframe-with-subframes.html @@ -0,0 +1,6 @@ + + + + + + diff --git a/testing/web-platform/tests/page-visibility/resources/iframe.html b/testing/web-platform/tests/page-visibility/resources/iframe.html new file mode 100644 index 0000000000..e08acb827a --- /dev/null +++ b/testing/web-platform/tests/page-visibility/resources/iframe.html @@ -0,0 +1,12 @@ + + +Document + +

Document

+ + + diff --git a/testing/web-platform/tests/page-visibility/resources/pagevistestharness.js b/testing/web-platform/tests/page-visibility/resources/pagevistestharness.js new file mode 100644 index 0000000000..d164d4603b --- /dev/null +++ b/testing/web-platform/tests/page-visibility/resources/pagevistestharness.js @@ -0,0 +1,112 @@ +// +// Helper functions for Page Visibility tests +// + +var VISIBILITY_STATES = +{ + HIDDEN: "hidden", + VISIBLE: "visible" +}; + +var feature_check = false; + +// +// All test() functions in the WebPerf PageVis test suite should use pv_test() instead. +// +// pv_test() validates the document.hidden and document.visibilityState attributes +// exist prior to running tests and immediately shows a failure if they do not. +// + +function pv_test(func, msg, doc) +{ + if (!doc) + { + doc = document; + } + + // only run the feature check once, unless func == null, in which case, + // this call is intended as a feature check + if (!feature_check) + { + feature_check = true; + + var hiddenVal = doc.hidden; + var visStateVal = doc.visibilityState; + + // show a single error that the Page Visibility feature is undefined + test(function() + { + assert_true(hiddenVal !== undefined && hiddenVal != null, + "document.hidden is defined and not null.");}, + "document.hidden is defined and not null."); + + test(function() + { + assert_true(visStateVal !== undefined && hiddenVal != null, + "document.visibilityState is defined and not null.");}, + "document.visibilityState is defined and not null."); + + } + + if (func) + { + test(func, msg); + } +} + + +function test_feature_exists(doc, msg) +{ + if (!msg) + { + msg = ""; + } + var hiddenMsg = "document.hidden is defined" + msg + "."; + var stateMsg = "document.visibilityState is defined" + msg + "."; + pv_test(function(){assert_not_equals(document.hidden, undefined, hiddenMsg);}, hiddenMsg, doc); + pv_test(function(){assert_not_equals(document.visibilityState, undefined, stateMsg);}, stateMsg, doc); +} + +// +// Common helper functions +// + +function test_true(value, msg) +{ + pv_test(function() { assert_true(value, msg); }, msg); +} + +function test_equals(value, equals, msg) +{ + pv_test(function() { assert_equals(value, equals, msg); }, msg); +} + +// +// asynchronous test helper functions +// + +function add_async_result(test_obj, pass_state) +{ + // add assertion to manual test for the pass state + test_obj.step(function() { assert_true(pass_state) }); + + // end manual test + test_obj.done(); +} + +function add_async_result_assert(test_obj, func) +{ + // add assertion to manual test for the pass state + test_obj.step(func); + + // end manual test + test_obj.done(); +} + +var open_link; +function TabSwitch() +{ + //var open_link = window.open("http://www.bing.com"); + open_link = window.open('', '_blank'); + step_timeout(function() { open_link.close(); }, 2000); +} diff --git a/testing/web-platform/tests/page-visibility/resources/unload-bubbles.html b/testing/web-platform/tests/page-visibility/resources/unload-bubbles.html new file mode 100644 index 0000000000..cc9e14f787 --- /dev/null +++ b/testing/web-platform/tests/page-visibility/resources/unload-bubbles.html @@ -0,0 +1,19 @@ + + +Document + +

Document

+ + + diff --git a/testing/web-platform/tests/page-visibility/resources/unload.html b/testing/web-platform/tests/page-visibility/resources/unload.html new file mode 100644 index 0000000000..b548518784 --- /dev/null +++ b/testing/web-platform/tests/page-visibility/resources/unload.html @@ -0,0 +1,17 @@ + + +Document + +

Document

+ + + diff --git a/testing/web-platform/tests/page-visibility/resources/window_state_context.js b/testing/web-platform/tests/page-visibility/resources/window_state_context.js new file mode 100644 index 0000000000..40f10a5644 --- /dev/null +++ b/testing/web-platform/tests/page-visibility/resources/window_state_context.js @@ -0,0 +1,19 @@ +function window_state_context(t) { + let rect = null; + let state = "restored"; + t.add_cleanup(async () => { + if (state === "minimized") + await restore(); + }); + async function restore() { + state = "restored"; + await test_driver.set_window_rect(rect); + } + + async function minimize() { + state = "minimized"; + rect = await test_driver.minimize_window(); + } + + return {minimize, restore}; +} -- cgit v1.2.3