mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-02 04:27:12 +02:00
LibWeb/HTML: Correctly set base elements frozen base url
This commit implements the fallback to the documents fallback base url if the href of the first base element is a data or javascript url. Additionally the frozen base url is set, if a base element becomes the first base element with an href content attribute because the previous one got removed.
This commit is contained in:
committed by
Shannon Booth
parent
4ed9f6fcc0
commit
6b84cd8d11
Notes:
github-actions[bot]
2025-06-23 06:57:47 +00:00
Author: https://github.com/skyz1 Commit: https://github.com/LadybirdBrowser/ladybird/commit/6b84cd8d116 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4558 Reviewed-by: https://github.com/shannonbooth ✅
@@ -0,0 +1,32 @@
|
||||
<!-- Please update base-javascript.html together with this -->
|
||||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title><base> and data: URLs</title>
|
||||
<script src=../../../../resources/testharness.js></script>
|
||||
<script src=../../../../resources/testharnessreport.js></script>
|
||||
<base href="data:/,test">
|
||||
<base href="https://example.com/">
|
||||
<div id=log></div>
|
||||
<script>
|
||||
test(() => {
|
||||
const link = document.createElement("a");
|
||||
link.href = "blah";
|
||||
assert_equals(link.href, new URL("blah", document.URL).href);
|
||||
}, "First <base> has a data: URL so fallback is used");
|
||||
|
||||
test(() => {
|
||||
document.querySelector("base").remove();
|
||||
const link = document.createElement("a");
|
||||
link.href = "blah";
|
||||
assert_equals(link.href, new URL("blah", "https://example.com/").href);
|
||||
}, "First <base> is removed so second is used");
|
||||
|
||||
test(() => {
|
||||
const base = document.createElement("base");
|
||||
base.href = "data:/,more-test";
|
||||
document.head.prepend(base);
|
||||
const link = document.createElement("a");
|
||||
link.href = "blah";
|
||||
assert_equals(link.href, new URL("blah", document.URL).href);
|
||||
}, "Dynamically inserted first <base> has a data: URL so fallback is used");
|
||||
</script>
|
||||
@@ -0,0 +1,32 @@
|
||||
<!-- Please update base-data.html together with this -->
|
||||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title><base> and javascript: URLs</title>
|
||||
<script src=../../../../resources/testharness.js></script>
|
||||
<script src=../../../../resources/testharnessreport.js></script>
|
||||
<base href="javascript:/,test">
|
||||
<base href="https://example.com/">
|
||||
<div id=log></div>
|
||||
<script>
|
||||
test(() => {
|
||||
const link = document.createElement("a");
|
||||
link.href = "blah";
|
||||
assert_equals(link.href, new URL("blah", document.URL).href);
|
||||
}, "First <base> has a javascript: URL so fallback is used");
|
||||
|
||||
test(() => {
|
||||
document.querySelector("base").remove();
|
||||
const link = document.createElement("a");
|
||||
link.href = "blah";
|
||||
assert_equals(link.href, new URL("blah", "https://example.com/").href);
|
||||
}, "First <base> is removed so second is used");
|
||||
|
||||
test(() => {
|
||||
const base = document.createElement("base");
|
||||
base.href = "javascript:/,more-test";
|
||||
document.head.prepend(base);
|
||||
const link = document.createElement("a");
|
||||
link.href = "blah";
|
||||
assert_equals(link.href, new URL("blah", document.URL).href);
|
||||
}, "Dynamically inserted first <base> has a javascript: URL so fallback is used");
|
||||
</script>
|
||||
Reference in New Issue
Block a user