mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-22 09:19:03 +00:00
LibWeb/HTML: Add null handling for "get noopener for window open"
See: https://github.com/whatwg/html/pull/10847 Which also fixes a crash when window.open is given a blob URL which is not present in the Blob URL registry.
This commit is contained in:
committed by
Jelle Raaijmakers
parent
03aafda788
commit
6c691ccddc
@@ -155,12 +155,12 @@ WebIDL::ExceptionOr<GC::Ptr<WindowProxy>> 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<URL::URL> 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::OpenedWindow> 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);
|
||||
|
||||
Reference in New Issue
Block a user