diff --git a/Libraries/LibWeb/HTML/Window.cpp b/Libraries/LibWeb/HTML/Window.cpp index c57ff134a81..45acef00cad 100644 --- a/Libraries/LibWeb/HTML/Window.cpp +++ b/Libraries/LibWeb/HTML/Window.cpp @@ -155,12 +155,12 @@ WebIDL::ExceptionOr> Window::window_open_steps(StringView u } // https://html.spec.whatwg.org/multipage/nav-history-apis.html#get-noopener-for-window-open -static TokenizedFeature::NoOpener get_noopener_for_window_open(DOM::Document const& source_document, TokenizedFeature::Map const& tokenized_features, URL::URL url) +static TokenizedFeature::NoOpener get_noopener_for_window_open(DOM::Document const& source_document, TokenizedFeature::Map const& tokenized_features, Optional const& url) { - // 1. If url's scheme is "blob": - if (url.scheme() == "blob"sv) { + // 1. If url is not null and url's blob URL entry is not null: + if (url.has_value() && url->blob_url_entry().has_value()) { // 1. Let blobOrigin be url's blob URL entry's environment's origin. - auto blob_origin = url.blob_url_entry()->environment_origin; + auto blob_origin = url->blob_url_entry()->environment_origin; // 2. Let topLevelOrigin be sourceDocument's relevant settings object's top-level origin. auto top_level_origin = source_document.relevant_settings_object().top_level_origin; @@ -221,8 +221,7 @@ WebIDL::ExceptionOr Window::window_open_steps_internal(Str } // 9. Let noopener be the result of getting noopener for window open with sourceDocument, tokenizedFeatures, and urlRecord. - // FIXME: Spec bug: https://github.com/whatwg/html/issues/10844 - auto no_opener = get_noopener_for_window_open(source_document, tokenized_features, url_record.has_value() ? *url_record : URL::URL("about:blank")); + auto no_opener = get_noopener_for_window_open(source_document, tokenized_features, url_record); // 10. Remove tokenizedFeatures["noopener"] and tokenizedFeatures["noreferrer"]. tokenized_features.remove("noopener"sv); diff --git a/Tests/LibWeb/Text/expected/HTML/Window-open-blob-url-without-blob-entry.txt b/Tests/LibWeb/Text/expected/HTML/Window-open-blob-url-without-blob-entry.txt new file mode 100644 index 00000000000..50586a4cbfb --- /dev/null +++ b/Tests/LibWeb/Text/expected/HTML/Window-open-blob-url-without-blob-entry.txt @@ -0,0 +1 @@ +PASS! (Didn't crash) diff --git a/Tests/LibWeb/Text/input/HTML/Window-open-blob-url-without-blob-entry.html b/Tests/LibWeb/Text/input/HTML/Window-open-blob-url-without-blob-entry.html new file mode 100644 index 00000000000..3b5f9eb4dad --- /dev/null +++ b/Tests/LibWeb/Text/input/HTML/Window-open-blob-url-without-blob-entry.html @@ -0,0 +1,7 @@ + +