mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 04:17:34 +00:00
LibWeb+WebContent: Convert WebDriver to choose a navigable AO
Also use the TraversableNavigable's window_handle instead of the BrowsingContext's.
This commit is contained in:
parent
713698d2ca
commit
3aee787539
4 changed files with 18 additions and 11 deletions
|
@ -305,7 +305,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)
|
||||
Navigable::ChosenNavigable Navigable::choose_a_navigable(StringView name, TokenizedFeature::NoOpener no_opener, ActivateTab activate_tab)
|
||||
{
|
||||
// NOTE: Implementation for step 7 here.
|
||||
JS::GCPtr<Navigable> same_name_navigable = nullptr;
|
||||
|
@ -412,13 +412,13 @@ 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](JS::GCPtr<BrowsingContext> opener) -> JS::NonnullGCPtr<Navigable> {
|
||||
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 [page, window_handle] = traversable_navigable()->page().client().page_did_request_new_web_view(ActivateTab::Yes, hints, no_opener);
|
||||
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);
|
||||
traversable->set_window_handle(window_handle);
|
||||
|
|
|
@ -5,7 +5,9 @@
|
|||
*/
|
||||
|
||||
#include <AK/JsonObject.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/HTML/BrowsingContext.h>
|
||||
#include <LibWeb/HTML/TraversableNavigable.h>
|
||||
#include <LibWeb/HTML/WindowProxy.h>
|
||||
#include <LibWeb/WebDriver/Contexts.h>
|
||||
|
||||
|
@ -16,7 +18,13 @@ JsonObject window_proxy_reference_object(HTML::WindowProxy const& window)
|
|||
{
|
||||
// 1. Let identifier be the web window identifier if the associated browsing context of window is a top-level browsing context.
|
||||
// Otherwise let it be the web frame identifier.
|
||||
auto identifier = window.associated_browsing_context()->is_top_level()
|
||||
|
||||
// NOTE: We look at the active browsing context's active document's node navigable instead.
|
||||
// Because a Browsing context's top-level traversable is this navigable's top level traversable.
|
||||
// Ref: https://html.spec.whatwg.org/multipage/document-sequences.html#bc-traversable
|
||||
auto traversable_navigable = window.associated_browsing_context()->active_document()->navigable()->traversable_navigable();
|
||||
|
||||
auto identifier = traversable_navigable->is_top_level_traversable()
|
||||
? WEB_WINDOW_IDENTIFIER
|
||||
: WEB_FRAME_IDENTIFIER;
|
||||
|
||||
|
@ -25,7 +33,7 @@ JsonObject window_proxy_reference_object(HTML::WindowProxy const& window)
|
|||
|
||||
// identifier
|
||||
// Associated window handle of the window’s browsing context.
|
||||
object.set(identifier, window.associated_browsing_context()->window_handle().to_byte_string());
|
||||
object.set(identifier, traversable_navigable->window_handle().to_byte_string());
|
||||
|
||||
return object;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue