diff --git a/Libraries/LibWeb/HTML/Navigable.cpp b/Libraries/LibWeb/HTML/Navigable.cpp
index 3a42cd7dda4..d9c92b556c6 100644
--- a/Libraries/LibWeb/HTML/Navigable.cpp
+++ b/Libraries/LibWeb/HTML/Navigable.cpp
@@ -895,7 +895,7 @@ static WebIDL::ExceptionOr create_navigation
// If the latter condition occurs, then abort fetchController, and return. Otherwise, proceed onward.
if (navigation_id.has_value() && (!navigable->ongoing_navigation().has() || navigable->ongoing_navigation().get() != *navigation_id)) {
fetch_controller->abort(realm, {});
- return Empty {};
+ return Navigable::NullOrError {};
}
// 8. If request's body is null, then set entry's document state's resource to null.
@@ -1010,9 +1010,9 @@ static WebIDL::ExceptionOr create_navigation
if (response_holder->response()->network_error_message().has_value() && !response_holder->response()->network_error_message().value().is_null())
return response_holder->response()->network_error_message().value();
else
- return Empty {};
+ return Navigable::NullOrError {};
} else if (location_url.is_error() || (location_url.value().has_value() && Fetch::Infrastructure::is_fetch_scheme(location_url.value().value().scheme())))
- return Empty {};
+ return Navigable::NullOrError {};
// 22. Assert: locationURL is null and response is not a network error.
VERIFY(!location_url.value().has_value());
@@ -1079,7 +1079,7 @@ WebIDL::ExceptionOr Navigable::populate_session_history_entry_document(
// FIXME: 1. Assert: this is running in parallel.
// 2. Assert: if navigationParams is non-null, then navigationParams's response is non-null.
- if (!navigation_params.has() && !navigation_params.has())
+ if (!navigation_params.has())
VERIFY(navigation_params.has>() && navigation_params.get>()->response);
// 3. Let currentBrowsingContext be navigable's active browsing context.
@@ -1089,7 +1089,7 @@ WebIDL::ExceptionOr Navigable::populate_session_history_entry_document(
auto document_resource = entry->document_state()->resource();
// 5. If navigationParams is null, then:
- if (navigation_params.has() || navigation_params.has()) {
+ if (navigation_params.has()) {
// 1. If documentResource is a string, then set navigationParams to the result
// of creating navigation params from a srcdoc resource given entry, navigable,
// targetSnapshotParams, navigationId, and navTimingType.
@@ -1160,9 +1160,9 @@ WebIDL::ExceptionOr Navigable::populate_session_history_entry_document(
// - FIXME: the result of should navigation response to navigation request of type in target be blocked by Content Security Policy? given navigationParams's request, navigationParams's response, navigationParams's policy container's CSP list, cspNavigationType, and navigable is "Blocked";
// - FIXME: navigationParams's reserved environment is non-null and the result of checking a navigation response's adherence to its embedder policy given navigationParams's response, navigable, and navigationParams's policy container's embedder policy is false; or
// - FIXME: the result of checking a navigation response's adherence to `X-Frame-Options` given navigationParams's response, navigable, navigationParams's policy container's CSP list, and navigationParams's origin is false,
- if (navigation_params.has() || navigation_params.has()) {
+ if (navigation_params.has()) {
// 1. Set entry's document state's document to the result of creating a document for inline content that doesn't have a DOM, given navigable, null, and navTimingType. The inline content should indicate to the user the sort of error that occurred.
- auto error_message = navigation_params.has() ? navigation_params.get() : "Unknown error"sv;
+ auto error_message = navigation_params.get().value_or("Unknown error"sv);
auto error_html = load_error_page(entry->url(), error_message).release_value_but_fixme_should_propagate_errors();
entry->document_state()->set_document(create_document_for_inline_content(this, navigation_id, [error_html](auto& document) {
@@ -1178,7 +1178,7 @@ WebIDL::ExceptionOr Navigable::populate_session_history_entry_document(
saveExtraDocumentState = false;
// 4. If navigationParams is not null, then:
- if (!navigation_params.has() && !navigation_params.has()) {
+ if (!navigation_params.has()) {
// FIXME: 1. Run the environment discarding steps for navigationParams's reserved environment.
// 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.
}
@@ -1210,7 +1210,7 @@ WebIDL::ExceptionOr Navigable::populate_session_history_entry_document(
// 3. If entry's document state's request referrer is "client", and navigationParams is a navigation params (i.e., neither null nor a non-fetch scheme navigation params), then:
if (entry->document_state()->request_referrer() == Fetch::Infrastructure::Request::Referrer::Client
- && (!navigation_params.has() && !navigation_params.has() && navigation_params.has>())) {
+ && (!navigation_params.has() && navigation_params.has>())) {
// 1. Assert: navigationParams's request is not null.
VERIFY(navigation_params.has>() && navigation_params.get>()->request);
@@ -1463,7 +1463,7 @@ WebIDL::ExceptionOr Navigable::navigate(NavigateParams params)
history_entry->set_document_state(document_state);
// 7. Let navigationParams be null.
- NavigationParamsVariant navigation_params = Empty {};
+ NavigationParamsVariant navigation_params = Navigable::NullOrError {};
// FIXME: 8. If response is non-null:
if (response) {
diff --git a/Libraries/LibWeb/HTML/Navigable.h b/Libraries/LibWeb/HTML/Navigable.h
index af71a559d82..1c6d07c2772 100644
--- a/Libraries/LibWeb/HTML/Navigable.h
+++ b/Libraries/LibWeb/HTML/Navigable.h
@@ -54,8 +54,8 @@ class Navigable : public JS::Cell {
public:
virtual ~Navigable() override;
- using NullWithError = StringView;
- using NavigationParamsVariant = Variant, GC::Ref>;
+ using NullOrError = Optional;
+ using NavigationParamsVariant = Variant, GC::Ref>;
ErrorOr initialize_navigable(GC::Ref document_state, GC::Ptr parent);
@@ -132,7 +132,7 @@ public:
SourceSnapshotParams const& source_snapshot_params,
TargetSnapshotParams const& target_snapshot_params,
Optional navigation_id = {},
- NavigationParamsVariant navigation_params = Empty {},
+ NavigationParamsVariant navigation_params = Navigable::NullOrError {},
CSPNavigationType csp_navigation_type = CSPNavigationType::Other,
bool allow_POST = false,
GC::Ptr> completion_steps = {});
diff --git a/Libraries/LibWeb/HTML/TraversableNavigable.cpp b/Libraries/LibWeb/HTML/TraversableNavigable.cpp
index bd3e2cb4e97..7aaa722d195 100644
--- a/Libraries/LibWeb/HTML/TraversableNavigable.cpp
+++ b/Libraries/LibWeb/HTML/TraversableNavigable.cpp
@@ -644,7 +644,7 @@ TraversableNavigable::HistoryStepResult TraversableNavigable::apply_the_history_
// targetSnapshotParams, with allowPOST set to allowPOST and completionSteps set to queue a global task on the navigation and traversal task source given
// navigable's active window to run afterDocumentPopulated.
Platform::EventLoopPlugin::the().deferred_invoke(GC::create_function(this->heap(), [populated_target_entry, potentially_target_specific_source_snapshot_params, target_snapshot_params, this, allow_POST, navigable, after_document_populated = GC::create_function(this->heap(), move(after_document_populated))] {
- navigable->populate_session_history_entry_document(populated_target_entry, *potentially_target_specific_source_snapshot_params, target_snapshot_params, {}, Empty {}, CSPNavigationType::Other, allow_POST, GC::create_function(this->heap(), [this, after_document_populated, populated_target_entry]() mutable {
+ navigable->populate_session_history_entry_document(populated_target_entry, *potentially_target_specific_source_snapshot_params, target_snapshot_params, {}, Navigable::NullOrError {}, CSPNavigationType::Other, allow_POST, GC::create_function(this->heap(), [this, after_document_populated, populated_target_entry]() mutable {
VERIFY(active_window());
queue_global_task(Task::Source::NavigationAndTraversal, *active_window(), GC::create_function(this->heap(), [after_document_populated, populated_target_entry]() mutable {
after_document_populated->function()(true, populated_target_entry);