LibWeb/HTML: Do not allow named window targeting with noopener
Some checks are pending
CI / Lagom (arm64, Sanitizer_CI, false, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (x86_64, Fuzzers_CI, false, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, false, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, true, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (arm64, macos-15, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (x86_64, ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run

Corresponds to dfdafb4b29

We fail the test for this, but we actually do create the separate popup
windows correctly (when popups aren't blocked!) but the test checks
`window.name` which we incorrectly return the empty string for.
https://wpt.live/html/browsers/windows/auxiliary-browsing-contexts/named-lookup-noopener.html
This commit is contained in:
Sam Atkins 2025-05-15 12:57:51 +01:00 committed by Shannon Booth
parent 08419a6d8f
commit 3f18331594
Notes: github-actions[bot] 2025-05-15 22:22:03 +00:00

View file

@ -362,17 +362,6 @@ 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, Optional<TokenizedFeature::Map const&> window_features)
{
// NOTE: Implementation for step 7 here.
GC::Ptr<Navigable> navigable_by_target_name = nullptr;
auto find_and_assign_navigable_by_target_name = [&](StringView name) {
auto maybe_navigable = find_a_navigable_by_target_name(name);
if (maybe_navigable) {
navigable_by_target_name = maybe_navigable;
return true;
}
return false;
};
// 1. Let chosen be null.
GC::Ptr<Navigable> chosen = nullptr;
@ -402,16 +391,16 @@ Navigable::ChosenNavigable Navigable::choose_a_navigable(StringView name, Tokeni
chosen = traversable_navigable();
}
// 7. Otherwise, if name is not an ASCII case-insensitive match for "_blank", and there exists a navigable that is
// the result of finding a navigable by target name given name and currentNavigable, set chosen to that navigable.
else if (!Infra::is_ascii_case_insensitive_match(name, "_blank"sv) && find_and_assign_navigable_by_target_name(name)) {
chosen = navigable_by_target_name;
// 7. Otherwise, if name is not an ASCII case-insensitive match for "_blank" and noopener is false, then set chosen
// to the result of finding a navigable by target name given name and currentNavigable.
else if (!Infra::is_ascii_case_insensitive_match(name, "_blank"sv) && no_opener == TokenizedFeature::NoOpener::No) {
chosen = find_a_navigable_by_target_name(name);
}
// 8. Otherwise, a new top-level traversable is being requested, and what happens depends on the
// user agent's configuration and abilities — it is determined by the rules given for the first
// applicable option from the following list:
else {
// 8. If chosen is null, then a new top-level traversable is being requested, and what happens depends on the user
// agent's configuration and abilities — it is determined by the rules given for the first applicable option
// from the following list:
if (!chosen) {
// --> If currentNavigable's active window does not have transient activation and the user agent has been configured to
// not show popups (i.e., the user agent has a "popup blocker" enabled)
if (active_window() && !active_window()->has_transient_activation() && traversable_navigable()->page().should_block_pop_ups()) {