Skip to content

Commit

Permalink
LibWeb: Add allowPOST param in populate_session_history_entry_document
Browse files Browse the repository at this point in the history
  • Loading branch information
kalenikaliaksandr authored and awesomekling committed Aug 14, 2023
1 parent b05bd88 commit 38c7703
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
8 changes: 4 additions & 4 deletions Userland/Libraries/LibWeb/HTML/Navigable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ static WebIDL::ExceptionOr<Optional<NavigationParams>> create_navigation_params_
}

// https://html.spec.whatwg.org/multipage/browsing-the-web.html#attempt-to-populate-the-history-entry's-document
WebIDL::ExceptionOr<void> Navigable::populate_session_history_entry_document(JS::GCPtr<SessionHistoryEntry> entry, Optional<NavigationParams> navigation_params, Optional<String> navigation_id, SourceSnapshotParams const& source_snapshot_params, Function<void()> completion_steps)
WebIDL::ExceptionOr<void> Navigable::populate_session_history_entry_document(JS::GCPtr<SessionHistoryEntry> entry, Optional<NavigationParams> navigation_params, Optional<String> navigation_id, SourceSnapshotParams const& source_snapshot_params, bool allow_POST, Function<void()> completion_steps)
{
// FIXME: 1. Assert: this is running in parallel.

Expand All @@ -673,8 +673,8 @@ WebIDL::ExceptionOr<void> 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<Empty>()) {
// - 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<Empty>() || 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
Expand Down Expand Up @@ -939,7 +939,7 @@ WebIDL::ExceptionOr<void> 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

Expand Down
2 changes: 1 addition & 1 deletion Userland/Libraries/LibWeb/HTML/Navigable.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class Navigable : public JS::Cell {

Variant<Empty, Traversal, String> ongoing_navigation() const { return m_ongoing_navigation; }

WebIDL::ExceptionOr<void> populate_session_history_entry_document(JS::GCPtr<SessionHistoryEntry>, Optional<NavigationParams>, Optional<String> navigation_id, SourceSnapshotParams const&, Function<void()>);
WebIDL::ExceptionOr<void> populate_session_history_entry_document(JS::GCPtr<SessionHistoryEntry>, Optional<NavigationParams>, Optional<String> navigation_id, SourceSnapshotParams const&, bool allow_POST, Function<void()>);

WebIDL::ExceptionOr<void> navigate(
AK::URL const&,
Expand Down
5 changes: 3 additions & 2 deletions Userland/Libraries/LibWeb/HTML/TraversableNavigable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,12 +341,13 @@ void TraversableNavigable::apply_the_history_step(int step, Optional<SourceSnaps
// 5. Set targetEntry's document state's reload pending to false.
target_entry->document_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();
});
Expand Down

0 comments on commit 38c7703

Please sign in to comment.