From ef793d867933afae7f9033e14165b5a56b221539 Mon Sep 17 00:00:00 2001 From: Shannon Booth Date: Tue, 21 Jan 2025 18:03:37 +1300 Subject: [PATCH] LibWeb/HTML: Support blob URLs in HTMLLinkElement We are meant to apply the 'URL parser' here, which indicates that this should work with Blob URLs. --- Libraries/LibWeb/HTML/HTMLLinkElement.cpp | 3 ++- .../HTML/HTMLLinkElement-blob-url.txt | 2 ++ .../input/HTML/HTMLLinkElement-blob-url.html | 27 +++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 Tests/LibWeb/Text/expected/HTML/HTMLLinkElement-blob-url.txt create mode 100644 Tests/LibWeb/Text/input/HTML/HTMLLinkElement-blob-url.html diff --git a/Libraries/LibWeb/HTML/HTMLLinkElement.cpp b/Libraries/LibWeb/HTML/HTMLLinkElement.cpp index 333776d5ff0..5fc3552cff6 100644 --- a/Libraries/LibWeb/HTML/HTMLLinkElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLLinkElement.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -264,7 +265,7 @@ GC::Ptr HTMLLinkElement::create_link_request(HTM // 3. Let url be the result of encoding-parsing a URL given options's href, relative to options's base URL. // FIXME: Spec issue: We should be parsing this URL relative to a document or environment settings object. // https://github.com/whatwg/html/issues/9715 - auto url = options.base_url.complete_url(options.href); + auto url = DOMURL::parse(options.href, options.base_url); // 4. If url is failure, then return null. if (!url.is_valid()) diff --git a/Tests/LibWeb/Text/expected/HTML/HTMLLinkElement-blob-url.txt b/Tests/LibWeb/Text/expected/HTML/HTMLLinkElement-blob-url.txt new file mode 100644 index 00000000000..0057831214a --- /dev/null +++ b/Tests/LibWeb/Text/expected/HTML/HTMLLinkElement-blob-url.txt @@ -0,0 +1,2 @@ +rgb(255, 0, 0) +700 diff --git a/Tests/LibWeb/Text/input/HTML/HTMLLinkElement-blob-url.html b/Tests/LibWeb/Text/input/HTML/HTMLLinkElement-blob-url.html new file mode 100644 index 00000000000..ba6e7eef397 --- /dev/null +++ b/Tests/LibWeb/Text/input/HTML/HTMLLinkElement-blob-url.html @@ -0,0 +1,27 @@ + +
Test Element
+