Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 2 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /html/semantics/document-metadata/the-base-element/base-data.html - WPT Dashboard Interop Dashboard
<!-- 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">
<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";
}, "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>