LibWeb: Fix crash when setting innerHTML inside iframe srcdoc document

In particular, there was an assertion failure due to the temporary
parser document's "about base URL" being empty when trying to "parse a
URL" during parsing.

We fix this by copying the context element's document's about base URL
to the temporary parsing document while parsing a fragment.

This fixes a crash when loading search results on https://amazon.com/
This commit is contained in:
Andreas Kling 2024-08-28 16:22:44 +02:00 committed by Andreas Kling
parent 782926601d
commit b64df59cc6
Notes: github-actions[bot] 2024-08-29 04:25:08 +00:00
3 changed files with 19 additions and 0 deletions

View file

@ -0,0 +1,14 @@
<iframe id="ifr" srcdoc=""></iframe>
<script src="../include.js"></script>
<script>
test(() => {
ifr.contentDocument.body.innerHTML = "<a href='foo.html'>foo</a>";
let href = ifr.contentDocument.body.querySelector("a").href;
if (href.endsWith("foo.html")) {
println("PASS (Didn't crash)");
} else {
println("FAIL");
}
ifr.remove();
});
</script>