mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-22 17:31:58 -05:00
LibWeb: Use the correct document URL in DOMParser.parseFromString()
We were hard-coding "about:blank" as the document URL for parsed HTML documents, which was definitely not correct. This fixes a bunch of WPT tests under /domparsing/ :^) (cherry picked from commit 55f58eea99c0429dcc39cd0430fafa60eecf5542)
This commit is contained in:
parent
e4903feab8
commit
337b113e68
3 changed files with 22 additions and 2 deletions
|
@ -0,0 +1,2 @@
|
|||
PASS text/html
|
||||
PASS application/xhtml+xml
|
|
@ -0,0 +1,19 @@
|
|||
<script src="../include.js"></script>
|
||||
<script>
|
||||
test(() => {
|
||||
const parser = new DOMParser();
|
||||
|
||||
for (const mimeType of ["text/html", "application/xhtml+xml"]) {
|
||||
const doc = parser.parseFromString("<html><b>hello", mimeType);
|
||||
if (doc.URL == "about:blank") {
|
||||
println("FAIL 1 " + mimeType);
|
||||
} else if (!doc.URL.endsWith(".html")) {
|
||||
println("FAIL 2 " + mimeType);
|
||||
} else if (doc.URL == document.URL) {
|
||||
println("PASS " + mimeType);
|
||||
} else {
|
||||
println("FAIL 3 " + mimeType);
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
|
@ -5324,8 +5324,7 @@ void Document::parse_html_from_a_string(StringView html)
|
|||
auto parser = HTML::HTMLParser::create(*this, html, "UTF-8"sv);
|
||||
|
||||
// 4. Start parser and let it run until it has consumed all the characters just inserted into the input stream.
|
||||
// FIXME: This is to match the default URL. Instead, pass in this's relevant global object's associated Document's URL.
|
||||
parser->run("about:blank"sv);
|
||||
parser->run(verify_cast<HTML::Window>(HTML::relevant_global_object(*this)).associated_document().url());
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-parsehtmlunsafe
|
||||
|
|
Loading…
Reference in a new issue