diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/resources | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/resources')
7 files changed, 105 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/resources/empty.html b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/resources/empty.html new file mode 100644 index 0000000000..763b0739be --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/resources/empty.html @@ -0,0 +1 @@ +<!DOCTYPE html>
\ No newline at end of file diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/resources/hello-world.html b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/resources/hello-world.html new file mode 100644 index 0000000000..0d1111b48c --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/resources/hello-world.html @@ -0,0 +1,11 @@ +<!DOCTYPE html> +<html> + <head> + <style> + * { color: 'green'; } + </style> + </head> + <body> + <div><span style="color: green">Hello world!</span></div> + </body> +</html>
\ No newline at end of file diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/resources/iframe-loading-lazy-in-viewport.html b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/resources/iframe-loading-lazy-in-viewport.html new file mode 100644 index 0000000000..1efd2bd056 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/resources/iframe-loading-lazy-in-viewport.html @@ -0,0 +1,2 @@ +<!DOCTYPE html> +<iframe id="iframe" loading="lazy" src="subframe.html"></iframe> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/resources/post-origin-to-opener.html b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/resources/post-origin-to-opener.html new file mode 100644 index 0000000000..bb625942f8 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/resources/post-origin-to-opener.html @@ -0,0 +1,3 @@ +<script> + opener.postMessage({origin: window.origin}, "*"); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/resources/sandbox-top-navigation-helper.js b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/resources/sandbox-top-navigation-helper.js new file mode 100644 index 0000000000..413f392dfc --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/resources/sandbox-top-navigation-helper.js @@ -0,0 +1,76 @@ +// To use this file, use the following imports: +// // META: script=/common/dispatcher/dispatcher.js +// // META: script=/common/get-host-info.sub.js +// // META: script=/common/utils.js +// // META: script=/resources/testdriver.js +// // META: script=/resources/testdriver-vendor.js +// // META: script=/html/browsers/browsing-the-web/remote-context-helper/resources/remote-context-helper.js +// // META: script=./resources/sandbox-top-navigation-helper.js + +// Helper file that provides various functions to test top-level navigation +// with various frame and sandbox flag configurations. + +async function createNestedIframe(parent, origin, frame_sandbox, header_sandbox) +{ + let headers = []; + if (header_sandbox) { + headers.push([ + "Content-Security-Policy", + "sandbox allow-scripts " + header_sandbox + ]); + } + let iframe_attributes = {}; + if (frame_sandbox) { + iframe_attributes.sandbox = "allow-scripts " + frame_sandbox; + } + return parent.addIframe({ + origin: origin, + scripts: [ + '/resources/testdriver.js', + '/resources/testdriver-driver.js', + '/resources/testdriver-vendor.js' + ], + headers: headers, + }, iframe_attributes); +} + +async function attemptTopNavigation(iframe, should_succeed) { + let did_succeed; + try { + await iframe.executeScript(() => { + window.top.location.href = "https://google.com"; + }); + did_succeed = true; + } catch (e) { + did_succeed = false; + } + + assert_equals(did_succeed, should_succeed, + should_succeed ? + "The navigation should succeed." : + "The navigation should fail."); +} + +async function setupTest() { + const rcHelper = new RemoteContextHelper(); + return rcHelper.addWindow(/*config=*/ null, /*options=*/ {}); +} + +async function activate(iframe) { + return iframe.executeScript(async () => { + let b = document.createElement("button"); + document.body.appendChild(b); + + // Since test_driver.bless() does not play nicely with the remote context + // helper, this is a workaround to trigger user activation in the iframe. + // This adds a button to the iframe and then simulates hitting the 'tab' key + // twice. Once to focus on the button, and once to trigger user activation + // in the iframe (user activation is given to the frame that has focus when + // the tab key is pressed, not the frame that ends up getting focus). Note + // that this will result in both the parent and this frame getting user + // activation. Note that this currently only works for iframes nested 1 + // level deep. + test_driver.set_test_context(window.top); + return test_driver.send_keys(document.body, "\uE004\uE004"); + }); +} diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/resources/subframe.html b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/resources/subframe.html new file mode 100644 index 0000000000..07cb999afa --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/resources/subframe.html @@ -0,0 +1,4 @@ +<!DOCTYPE html> +<body> + <p>Subframe</p> +</body> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/resources/unload-reporter.html b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/resources/unload-reporter.html new file mode 100644 index 0000000000..18599b2a6e --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/resources/unload-reporter.html @@ -0,0 +1,8 @@ +<!DOCTYPE html> +<h1>I'll report to my parent when I'm unloaded</h1> + +<script> + window.onbeforeunload = e => { + parent.postMessage('unloading', '*'); + }; +</script> |