diff --git a/Userland/Libraries/LibWeb/HTML/Navigable.cpp b/Userland/Libraries/LibWeb/HTML/Navigable.cpp index 84bd71e329e..28a8435ce57 100644 --- a/Userland/Libraries/LibWeb/HTML/Navigable.cpp +++ b/Userland/Libraries/LibWeb/HTML/Navigable.cpp @@ -649,7 +649,7 @@ static WebIDL::ExceptionOr> create_navigation_params_ } // https://html.spec.whatwg.org/multipage/browsing-the-web.html#attempt-to-populate-the-history-entry's-document -WebIDL::ExceptionOr Navigable::populate_session_history_entry_document(JS::GCPtr entry, Optional navigation_params, Optional navigation_id, SourceSnapshotParams const& source_snapshot_params, Function completion_steps) +WebIDL::ExceptionOr Navigable::populate_session_history_entry_document(JS::GCPtr entry, Optional navigation_params, Optional navigation_id, SourceSnapshotParams const& source_snapshot_params, bool allow_POST, Function completion_steps) { // FIXME: 1. Assert: this is running in parallel. @@ -673,8 +673,8 @@ WebIDL::ExceptionOr Navigable::populate_session_history_entry_document(JS: } // 2. Otherwise, if both of the following are true: // - entry's URL's scheme is a fetch scheme; and - // - documentResource is null, FIXME: or allowPOST is true and documentResource's request body is not failure - else if (Fetch::Infrastructure::is_fetch_scheme(entry->url.scheme()) && document_resource.has()) { + // - documentResource is null, or allowPOST is true and documentResource's request body is not failure (FIXME: check if request body is not failure) + else if (Fetch::Infrastructure::is_fetch_scheme(entry->url.scheme()) && (document_resource.has() || allow_POST)) { navigation_params = create_navigation_params_by_fetching(entry, this, source_snapshot_params, navigation_id).release_value_but_fixme_should_propagate_errors(); } // FIXME: 3. Otherwise, if entry's URL's scheme is not a fetch scheme, then set navigationParams to a new non-fetch scheme navigation params, with @@ -939,7 +939,7 @@ WebIDL::ExceptionOr Navigable::navigate( // for historyEntry, given navigable, "navigate", sourceSnapshotParams, // targetSnapshotParams, navigationId, navigationParams, cspNavigationType, with allowPOST // set to true and completionSteps set to the following step: - populate_session_history_entry_document(history_entry, navigation_params, navigation_id, source_snapshot_params, [this, history_entry, history_handling, navigation_id] { + populate_session_history_entry_document(history_entry, navigation_params, navigation_id, source_snapshot_params, true, [this, history_entry, history_handling, navigation_id] { traversable_navigable()->append_session_history_traversal_steps([this, history_entry, history_handling, navigation_id] { // https://html.spec.whatwg.org/multipage/browsing-the-web.html#finalize-a-cross-document-navigation diff --git a/Userland/Libraries/LibWeb/HTML/Navigable.h b/Userland/Libraries/LibWeb/HTML/Navigable.h index 76a9d5b2557..32bd6eed2af 100644 --- a/Userland/Libraries/LibWeb/HTML/Navigable.h +++ b/Userland/Libraries/LibWeb/HTML/Navigable.h @@ -86,7 +86,7 @@ public: Variant ongoing_navigation() const { return m_ongoing_navigation; } - WebIDL::ExceptionOr populate_session_history_entry_document(JS::GCPtr, Optional, Optional navigation_id, SourceSnapshotParams const&, Function); + WebIDL::ExceptionOr populate_session_history_entry_document(JS::GCPtr, Optional, Optional navigation_id, SourceSnapshotParams const&, bool allow_POST, Function); WebIDL::ExceptionOr navigate( AK::URL const&, diff --git a/Userland/Libraries/LibWeb/HTML/TraversableNavigable.cpp b/Userland/Libraries/LibWeb/HTML/TraversableNavigable.cpp index 822d1a65d1e..d8f652c3cbd 100644 --- a/Userland/Libraries/LibWeb/HTML/TraversableNavigable.cpp +++ b/Userland/Libraries/LibWeb/HTML/TraversableNavigable.cpp @@ -341,12 +341,13 @@ void TraversableNavigable::apply_the_history_step(int step, Optionaldocument_state->set_reload_pending(false); - // FIXME: 6. Let allowPOST be targetEntry's document state's reload pending. + // 6. Let allowPOST be targetEntry's document state's reload pending. + auto allow_POST = target_entry->document_state->reload_pending(); // 7. In parallel, attempt to populate the history entry's document for targetEntry, given navigable, potentiallyTargetSpecificSourceSnapshotParams, // 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. - navigable->populate_session_history_entry_document(target_entry, {}, {}, *potentially_target_specific_source_snapshot_params, [this, after_document_populated]() mutable { + navigable->populate_session_history_entry_document(target_entry, {}, {}, *potentially_target_specific_source_snapshot_params, allow_POST, [this, after_document_populated]() mutable { queue_global_task(Task::Source::NavigationAndTraversal, *active_window(), [after_document_populated]() mutable { after_document_populated(); });