LibWeb: Update document URL to the entry document URL in document.open()

When document.open() is called from another window, the opened
document's URL should be updated to match the calling document's URL.
This commit is contained in:
Shannon Booth
2026-03-22 20:46:08 +01:00
committed by Jelle Raaijmakers
parent 84b41f6270
commit 45a87b1dbe
Notes: github-actions[bot] 2026-03-23 08:01:42 +00:00
6 changed files with 36 additions and 1 deletions

View File

@@ -0,0 +1,4 @@
<!doctype html>
<script>
window.callDocumentMethod = methodName => document[methodName]();
</script>

View File

@@ -0,0 +1,8 @@
<!doctype html>
<meta charset=utf-8>
<script src="../../../../resources/testharness.js"></script>
<script src="../../../../resources/testharnessreport.js"></script>
<div id=log></div>
<script src="../../../../html/webappapis/dynamic-markup-insertion/opening-the-input-stream/url-entry-document-sync-call.window.js"></script>

View File

@@ -0,0 +1,13 @@
for (const methodName of ["open", "write", "writeln"]) {
async_test(t => {
const frame = document.body.appendChild(document.createElement("iframe"));
t.add_cleanup(() => { frame.remove(); });
const frameURL = new URL("resources/url-entry-document-incumbent-frame.html", document.URL).href;
frame.onload = t.step_func_done(() => {
assert_equals(frame.contentDocument.URL, frameURL);
frame.contentWindow.callDocumentMethod(methodName);
assert_equals(frame.contentDocument.URL, document.URL);
});
frame.src = frameURL;
}, `document.${methodName}() changes document's URL to the entry global object's associate document's (sync call)`);
}