mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-27 10:07:15 +02:00
Tests/LibWeb: Import Fullscreen WPT tests
This commit is contained in:
Notes:
github-actions[bot]
2026-02-23 18:45:39 +00:00
Author: https://github.com/Lubrsi Commit: https://github.com/LadybirdBrowser/ladybird/commit/8017f8a7ed3 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/7649 Reviewed-by: https://github.com/shannonbooth ✅ Reviewed-by: https://github.com/tcl3
@@ -0,0 +1,65 @@
|
||||
<!DOCTYPE html>
|
||||
<title>Document#exitFullscreen() for nested fullscreen inside an iframe</title>
|
||||
<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="../trusted-click.js"></script>
|
||||
<iframe allowfullscreen></iframe>
|
||||
<script>
|
||||
async function fullscreenNestedElements(t, iframe, outer, inner) {
|
||||
// First request fullscreen for the outer element.
|
||||
await Promise.all([fullScreenChange(), fullScreenChange(iframe.contentDocument), trusted_request(outer)]);
|
||||
assert_equals(document.fullscreenElement, iframe);
|
||||
assert_equals(iframe.contentDocument.fullscreenElement, outer);
|
||||
|
||||
document.onfullscreenchange = t.unreached_func(
|
||||
"fullscreenchange event should not be emitted a second time for parent document."
|
||||
);
|
||||
|
||||
// Then request fullscreen for the inner element.
|
||||
await Promise.all([fullScreenChange(iframe.contentDocument), trusted_request(inner)]);
|
||||
assert_equals(document.fullscreenElement, iframe);
|
||||
assert_equals(iframe.contentDocument.fullscreenElement, inner);
|
||||
|
||||
document.onfullscreenchange = null;
|
||||
}
|
||||
|
||||
promise_test(async (t) => {
|
||||
const iframe = document.querySelector("iframe");
|
||||
await new Promise((resolve) => {
|
||||
iframe.onload = resolve;
|
||||
iframe.srcdoc = "<div id='outer'><div id='inner'></div></div>";
|
||||
});
|
||||
|
||||
const iframeDoc = iframe.contentDocument;
|
||||
const outer = iframeDoc.getElementById("outer");
|
||||
const inner = iframeDoc.getElementById("inner");
|
||||
|
||||
// Fullscreen outer, then inner, 2 elements in toplayer of <iframe>
|
||||
await fullscreenNestedElements(t, iframe, outer, inner);
|
||||
|
||||
// Check if iframe sees (fullscreenchange, element) as per spec
|
||||
await Promise.all([fullScreenChange(iframeDoc), iframeDoc.exitFullscreen()]);
|
||||
|
||||
// First iframe.contentDocument.exitFullscreen()
|
||||
// should only remove 1 from the top layer of iframe
|
||||
assert_equals(iframeDoc.fullscreenElement, outer);
|
||||
assert_equals(document.fullscreenElement, iframe);
|
||||
// Second exitFullscreen should exit fully from fullscreen, as stated by
|
||||
// https://fullscreen.spec.whatwg.org/#collect-documents-to-unfullscreen, since
|
||||
// all documents are now simple fullscreen documents
|
||||
// https://fullscreen.spec.whatwg.org/#simple-fullscreen-document
|
||||
await Promise.all([fullScreenChange(document), iframeDoc.exitFullscreen()]);
|
||||
assert_equals(iframeDoc.fullscreenElement, null);
|
||||
assert_equals(document.fullscreenElement, null);
|
||||
|
||||
await fullscreenNestedElements(t, iframe, outer, inner);
|
||||
|
||||
// Exit the top level document from fullscreen - should exit all documents below it as
|
||||
// per step 13 & 15 in https://fullscreen.spec.whatwg.org/#exit-fullscreen
|
||||
await Promise.all([fullScreenChange(document), document.exitFullscreen()]);
|
||||
assert_equals(iframeDoc.fullscreenElement, null);
|
||||
assert_equals(document.fullscreenElement, null);
|
||||
}, "Exit fullscreen for nested fullscreen inside an iframe");
|
||||
</script>
|
||||
Reference in New Issue
Block a user