Skip to content

Commit 3e4b105

Browse files
committed
LibWeb: Consistently use navigables for WebDriver BiDi
Corresponds to whatwg/html#10909
1 parent f0c597a commit 3e4b105

File tree

2 files changed

+20
-26
lines changed

2 files changed

+20
-26
lines changed

Libraries/LibWeb/DOM/Document.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -3986,7 +3986,7 @@ void Document::abort()
39863986

39873987
// 3. If document's during-loading navigation ID for WebDriver BiDi is non-null, then:
39883988
if (m_navigation_id.has_value()) {
3989-
// 1. FIXME: Invoke WebDriver BiDi navigation aborted with document's browsing context,
3989+
// 1. FIXME: Invoke WebDriver BiDi navigation aborted with document's node navigable,
39903990
// and new WebDriver BiDi navigation status whose whose id is document's navigation id,
39913991
// status is "canceled", and url is document's URL.
39923992

Libraries/LibWeb/HTML/Navigable.cpp

+19-25
Original file line numberDiff line numberDiff line change
@@ -1161,13 +1161,10 @@ WebIDL::ExceptionOr<void> Navigable::populate_session_history_entry_document(
11611161
if (!navigation_params.has<NullOrError>())
11621162
VERIFY(navigation_params.has<GC::Ref<NavigationParams>>() && navigation_params.get<GC::Ref<NavigationParams>>()->response);
11631163

1164-
// 3. Let currentBrowsingContext be navigable's active browsing context.
1165-
[[maybe_unused]] auto current_browsing_context = active_browsing_context();
1166-
1167-
// 4. Let documentResource be entry's document state's resource.
1164+
// 3. Let documentResource be entry's document state's resource.
11681165
auto document_resource = entry->document_state()->resource();
11691166

1170-
// 5. If navigationParams is null, then:
1167+
// 4. If navigationParams is null, then:
11711168
if (navigation_params.has<NullOrError>()) {
11721169
// 1. If documentResource is a string, then set navigationParams to the result
11731170
// of creating navigation params from a srcdoc resource given entry, navigable,
@@ -1208,7 +1205,7 @@ WebIDL::ExceptionOr<void> Navigable::populate_session_history_entry_document(
12081205
if (!active_window())
12091206
return {};
12101207

1211-
// 6. Queue a global task on the navigation and traversal task source, given navigable's active window, to run these steps:
1208+
// 5. Queue a global task on the navigation and traversal task source, given navigable's active window, to run these steps:
12121209
queue_global_task(Task::Source::NavigationAndTraversal, *active_window(), GC::create_function(heap(), [this, entry, navigation_params = move(navigation_params), navigation_id, user_involvement, completion_steps]() mutable {
12131210
// NOTE: This check is not in the spec but we should not continue navigation if navigable has been destroyed.
12141211
if (has_been_destroyed())
@@ -1276,7 +1273,7 @@ WebIDL::ExceptionOr<void> Navigable::populate_session_history_entry_document(
12761273
// 4. If navigationParams is not null, then:
12771274
if (!navigation_params.has<NullOrError>()) {
12781275
// FIXME: 1. Run the environment discarding steps for navigationParams's reserved environment.
1279-
// FIXME: 2. Invoke WebDriver BiDi navigation failed with currentBrowsingContext and a new WebDriver BiDi navigation status whose id is navigationId, status is "canceled", and url is navigationParams's response's URL.
1276+
// FIXME: 2. Invoke WebDriver BiDi navigation failed with navigable and a new WebDriver BiDi navigation status whose id is navigationId, status is "canceled", and url is navigationParams's response's URL.
12801277
}
12811278
}
12821279
// FIXME: 5. Otherwise, if navigationParams's response has a `Content-Disposition`
@@ -1383,11 +1380,11 @@ WebIDL::ExceptionOr<void> Navigable::navigate(NavigateParams params)
13831380
// Otherwise, queue a global task on the navigation and traversal task source given navigable's active window to continue these steps.
13841381

13851382
// 8. If navigable's active document's unload counter is greater than 0,
1386-
// then invoke WebDriver BiDi navigation failed with a WebDriver BiDi navigation status whose id is navigationId,
1387-
// status is "canceled", and url is url, and return.
1383+
// then invoke WebDriver BiDi navigation failed with navigable and a WebDriver BiDi navigation status whose id
1384+
// is navigationId, status is "canceled", and url is url, and return.
13881385
if (active_document.unload_counter() > 0) {
1389-
// FIXME: invoke WebDriver BiDi navigation failed with a WebDriver BiDi navigation status whose id is navigationId,
1390-
// status is "canceled", and url is url
1386+
// FIXME: invoke WebDriver BiDi navigation failed with navigable and a WebDriver BiDi navigation status whose id
1387+
// is navigationId, status is "canceled", and url is url
13911388
return {};
13921389
}
13931390

@@ -1443,26 +1440,23 @@ WebIDL::ExceptionOr<void> Navigable::navigate(NavigateParams params)
14431440
if (parent() != nullptr)
14441441
set_delaying_load_events(true);
14451442

1446-
// 15. Let targetBrowsingContext be navigable's active browsing context.
1447-
[[maybe_unused]] auto target_browsing_context = active_browsing_context();
1448-
1449-
// 16. Let targetSnapshotParams be the result of snapshotting target snapshot params given navigable.
1450-
auto target_snapshot_params = snapshot_target_snapshot_params();
1443+
// 15. Let targetSnapshotParams be the result of snapshotting target snapshot params given navigable.
1444+
[[maybe_unused]] auto target_snapshot_params = snapshot_target_snapshot_params();
14511445

1452-
// FIXME: 17. Invoke WebDriver BiDi navigation started with targetBrowsingContext, and a new WebDriver BiDi navigation status whose id is navigationId, url is url, and status is "pending".
1446+
// FIXME: 16. Invoke WebDriver BiDi navigation started with navigable and a new WebDriver BiDi navigation status whose id is navigationId, status is "pending", and url is url.
14531447

1454-
// 18. If navigable's ongoing navigation is "traversal", then:
1448+
// 17. If navigable's ongoing navigation is "traversal", then:
14551449
if (ongoing_navigation().has<Traversal>()) {
1456-
// FIXME: 1. Invoke WebDriver BiDi navigation failed with targetBrowsingContext and a new WebDriver BiDi navigation status whose id is navigationId, status is "canceled", and url is url.
1450+
// FIXME: 1. Invoke WebDriver BiDi navigation failed with navigable and a new WebDriver BiDi navigation status whose id is navigationId, status is "canceled", and url is url.
14571451

14581452
// 2. Return.
14591453
return {};
14601454
}
14611455

1462-
// 19. Set the ongoing navigation for navigable to navigationId.
1456+
// 18. Set the ongoing navigation for navigable to navigationId.
14631457
set_ongoing_navigation(navigation_id);
14641458

1465-
// 20. If url's scheme is "javascript", then:
1459+
// 19. If url's scheme is "javascript", then:
14661460
if (url.scheme() == "javascript"sv) {
14671461
// 1. Queue a global task on the navigation and traversal task source given navigable's active window to navigate to a javascript: URL given navigable, url, historyHandling, initiatorOriginSnapshot, userInvolvement, and cspNavigationType.
14681462
VERIFY(active_window());
@@ -1474,7 +1468,7 @@ WebIDL::ExceptionOr<void> Navigable::navigate(NavigateParams params)
14741468
return {};
14751469
}
14761470

1477-
// 21. If all of the following are true:
1471+
// 20. If all of the following are true:
14781472
// - userInvolvement is not "browser UI";
14791473
// - navigable's active document's origin is same origin-domain with sourceDocument's origin;
14801474
// - navigable's active document's is initial about:blank is false; and
@@ -1522,7 +1516,7 @@ WebIDL::ExceptionOr<void> Navigable::navigate(NavigateParams params)
15221516
active_browsing_context()->page().client().page_did_start_loading(url, false);
15231517
}
15241518

1525-
// 22. In parallel, run these steps:
1519+
// 21. In parallel, run these steps:
15261520
Platform::EventLoopPlugin::the().deferred_invoke(GC::create_function(heap(), [this, source_snapshot_params, target_snapshot_params, csp_navigation_type, document_resource, url, navigation_id, referrer_policy, initiator_origin_snapshot, response, history_handling, initiator_base_url_snapshot, user_involvement] {
15271521
// AD-HOC: Not in the spec but subsequent steps will fail if the navigable doesn't have an active window.
15281522
if (!active_window()) {
@@ -1535,7 +1529,7 @@ WebIDL::ExceptionOr<void> Navigable::navigate(NavigateParams params)
15351529

15361530
// 2. If unloadPromptCanceled is true, or navigable's ongoing navigation is no longer navigationId, then:
15371531
if (unload_prompt_canceled != TraversableNavigable::CheckIfUnloadingIsCanceledResult::Continue || !ongoing_navigation().has<String>() || ongoing_navigation().get<String>() != navigation_id) {
1538-
// FIXME: 1. Invoke WebDriver BiDi navigation failed with targetBrowsingContext and a new WebDriver BiDi navigation status whose id is navigationId, status is "canceled", and url is url.
1532+
// FIXME: 1. Invoke WebDriver BiDi navigation failed with navigable and a new WebDriver BiDi navigation status whose id is navigationId, status is "canceled", and url is url.
15391533

15401534
// 2. Abort these steps.
15411535
set_delaying_load_events(false);
@@ -1696,7 +1690,7 @@ WebIDL::ExceptionOr<void> Navigable::navigate_to_a_fragment(URL::URL const& url,
16961690
// 1. Finalize a same-document navigation given traversable, navigable, historyEntry, entryToReplace, historyHandling, and userInvolvement.
16971691
finalize_a_same_document_navigation(*traversable, *this, history_entry, entry_to_replace, history_handling, user_involvement);
16981692

1699-
// FIXME: 2. Invoke WebDriver BiDi fragment navigated with navigable's active browsing context and a new WebDriver BiDi
1693+
// FIXME: 2. Invoke WebDriver BiDi fragment navigated with navigable and a new WebDriver BiDi
17001694
// navigation status whose id is navigationId, url is url, and status is "complete".
17011695
(void)navigation_id;
17021696
}));

0 commit comments

Comments
 (0)