From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- ...-manipulation-inside-portal-with-subframes.html | 42 +++++++++++ .../history-manipulation-inside-portal.html | 60 ++++++++++++++++ .../portals/history/resources/inner-iframe.html | 13 ++++ .../portals/history/resources/portal-harness.js | 30 ++++++++ ...rtal-manipulate-history-with-subframes.sub.html | 83 ++++++++++++++++++++++ .../resources/portal-manipulate-history.html | 66 +++++++++++++++++ .../history/resources/run-test-in-portal.js | 16 +++++ 7 files changed, 310 insertions(+) create mode 100644 testing/web-platform/tests/portals/history/history-manipulation-inside-portal-with-subframes.html create mode 100644 testing/web-platform/tests/portals/history/history-manipulation-inside-portal.html create mode 100644 testing/web-platform/tests/portals/history/resources/inner-iframe.html create mode 100644 testing/web-platform/tests/portals/history/resources/portal-harness.js create mode 100644 testing/web-platform/tests/portals/history/resources/portal-manipulate-history-with-subframes.sub.html create mode 100644 testing/web-platform/tests/portals/history/resources/portal-manipulate-history.html create mode 100644 testing/web-platform/tests/portals/history/resources/run-test-in-portal.js (limited to 'testing/web-platform/tests/portals/history') diff --git a/testing/web-platform/tests/portals/history/history-manipulation-inside-portal-with-subframes.html b/testing/web-platform/tests/portals/history/history-manipulation-inside-portal-with-subframes.html new file mode 100644 index 0000000000..cb4c8d0f91 --- /dev/null +++ b/testing/web-platform/tests/portals/history/history-manipulation-inside-portal-with-subframes.html @@ -0,0 +1,42 @@ + + + + + + + diff --git a/testing/web-platform/tests/portals/history/history-manipulation-inside-portal.html b/testing/web-platform/tests/portals/history/history-manipulation-inside-portal.html new file mode 100644 index 0000000000..d4b0cf4db9 --- /dev/null +++ b/testing/web-platform/tests/portals/history/history-manipulation-inside-portal.html @@ -0,0 +1,60 @@ + + + + + + + diff --git a/testing/web-platform/tests/portals/history/resources/inner-iframe.html b/testing/web-platform/tests/portals/history/resources/inner-iframe.html new file mode 100644 index 0000000000..5c6daa22a5 --- /dev/null +++ b/testing/web-platform/tests/portals/history/resources/inner-iframe.html @@ -0,0 +1,13 @@ + + + + diff --git a/testing/web-platform/tests/portals/history/resources/portal-harness.js b/testing/web-platform/tests/portals/history/resources/portal-harness.js new file mode 100644 index 0000000000..fa8c761afb --- /dev/null +++ b/testing/web-platform/tests/portals/history/resources/portal-harness.js @@ -0,0 +1,30 @@ +// We don't have the test harness in this context, so we roll our own +// which communicates with our host which is actually running the tests. + +window.onload = async () => { + let urlParams = new URLSearchParams(window.location.search); + let testName = urlParams.get('testName'); + let testFn = window[testName]; + if (!testFn) { + window.portalHost.postMessage('Missing test: ' + testName); + return; + } + + // The document load event is not finished at this point, so navigations + // would be done with replacement. This interferes with our tests. We wait + // for the next task before navigating to avoid this. + await new Promise((resolve) => { window.setTimeout(resolve); }); + + try { + await testFn(); + window.portalHost.postMessage('Passed'); + } catch (e) { + window.portalHost.postMessage( + 'Failed: ' + e.name + ': ' + e.message); + } +}; + +function assert(condition, message) { + if (!condition) + throw new Error('Assertion failed: ' + message); +} diff --git a/testing/web-platform/tests/portals/history/resources/portal-manipulate-history-with-subframes.sub.html b/testing/web-platform/tests/portals/history/resources/portal-manipulate-history-with-subframes.sub.html new file mode 100644 index 0000000000..bab83b444f --- /dev/null +++ b/testing/web-platform/tests/portals/history/resources/portal-manipulate-history-with-subframes.sub.html @@ -0,0 +1,83 @@ + + + + + diff --git a/testing/web-platform/tests/portals/history/resources/portal-manipulate-history.html b/testing/web-platform/tests/portals/history/resources/portal-manipulate-history.html new file mode 100644 index 0000000000..3e25f0e6f2 --- /dev/null +++ b/testing/web-platform/tests/portals/history/resources/portal-manipulate-history.html @@ -0,0 +1,66 @@ + + + + + diff --git a/testing/web-platform/tests/portals/history/resources/run-test-in-portal.js b/testing/web-platform/tests/portals/history/resources/run-test-in-portal.js new file mode 100644 index 0000000000..c982a1fac8 --- /dev/null +++ b/testing/web-platform/tests/portals/history/resources/run-test-in-portal.js @@ -0,0 +1,16 @@ +// This is called from the portal host which is running with the test harness. +// This creates a portal and communicates with our ad hoc test harness in the +// portal context which performs the history manipulation in the portal. We +// confirm that the history manipulation works as expected in the portal. +async function runTestInPortal(portalSrc, testName) { + let portal = document.createElement('portal'); + portal.src = portalSrc + '?testName=' + testName; + let result = await new Promise((resolve) => { + portal.onmessage = (e) => { + resolve(e.data); + }; + document.body.appendChild(portal); + }); + + assert_equals(result, 'Passed'); +} -- cgit v1.2.3