LibWeb: Parse TokenizedFeatures from window.open

This commit is contained in:
Andrew Kaster
2024-05-28 09:12:18 -06:00
committed by Tim Flynn
parent e2d50dc5dd
commit 46e00a8f5e
5 changed files with 136 additions and 15 deletions

View File

@@ -335,7 +335,7 @@ void Navigable::set_ongoing_navigation(Variant<Empty, Traversal, String> ongoing
}
// https://html.spec.whatwg.org/multipage/document-sequences.html#the-rules-for-choosing-a-navigable
Navigable::ChosenNavigable Navigable::choose_a_navigable(StringView name, TokenizedFeature::NoOpener no_opener, ActivateTab activate_tab)
Navigable::ChosenNavigable Navigable::choose_a_navigable(StringView name, TokenizedFeature::NoOpener no_opener, ActivateTab activate_tab, Optional<TokenizedFeature::Map const&> window_features)
{
// NOTE: Implementation for step 7 here.
JS::GCPtr<Navigable> same_name_navigable = nullptr;
@@ -442,12 +442,8 @@ Navigable::ChosenNavigable Navigable::choose_a_navigable(StringView name, Tokeni
if (!Infra::is_ascii_case_insensitive_match(name, "_blank"sv))
target_name = MUST(String::from_utf8(name));
auto create_new_traversable_closure = [this, window_type, no_opener, target_name, activate_tab](JS::GCPtr<BrowsingContext> opener) -> JS::NonnullGCPtr<Navigable> {
// FIXME: The popup state for window.open is calculated after this call (somehow?)
// Probably want to deviate from the spec and pass the popup state in here
auto hints = WebViewHints {
.popup = window_type != WindowType::ExistingOrNone,
};
auto create_new_traversable_closure = [this, no_opener, target_name, activate_tab, window_features](JS::GCPtr<BrowsingContext> opener) -> JS::NonnullGCPtr<Navigable> {
auto hints = WebViewHints::from_tokenised_features(window_features.value_or({}), traversable_navigable()->page());
auto [page, window_handle] = traversable_navigable()->page().client().page_did_request_new_web_view(activate_tab, hints, no_opener);
auto traversable = TraversableNavigable::create_a_new_top_level_traversable(*page, opener, target_name).release_value_but_fixme_should_propagate_errors();
page->set_top_level_traversable(traversable);