Skip to content

Commit

Permalink
[Navigation] Reverse order of resolving transition and finished promises
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=280398

Reviewed by Anne van Kesteren.

Reorder order of resolving transition and finished promises, the tests already expect this order
and the spec was adjusted recently:
whatwg/html#10658

* Source/WebCore/page/Navigation.cpp:
(WebCore::Navigation::innerDispatchNavigateEvent):

Canonical link: https://commits.webkit.org/284445@main
  • Loading branch information
rwlbuis committed Sep 30, 2024
1 parent 447bcbf commit a354d41
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions Source/WebCore/page/Navigation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -912,14 +912,14 @@ bool Navigation::innerDispatchNavigateEvent(NavigationNavigationType navigationT

dispatchEvent(Event::create(eventNames().navigatesuccessEvent, { }));

if (apiMethodTracker)
resolveFinishedPromise(apiMethodTracker.get());

if (RefPtr transition = std::exchange(m_transition, nullptr))
transition->resolvePromise();

m_ongoingNavigateEvent = nullptr;

if (apiMethodTracker)
resolveFinishedPromise(apiMethodTracker.get());

}, [this, abortController, document, apiMethodTracker, weakThis = WeakPtr { *this }](JSC::JSValue result) mutable {
if (!weakThis || abortController->signal().aborted() || !document->isFullyActive() || !m_ongoingNavigateEvent)
return;
Expand All @@ -941,11 +941,11 @@ bool Navigation::innerDispatchNavigateEvent(NavigationNavigationType navigationT

dispatchEvent(ErrorEvent::create(eventNames().navigateerrorEvent, errorMessage, errorInformation.sourceURL, errorInformation.line, errorInformation.column, { protectedScriptExecutionContext()->globalObject()->vm(), result }));

if (RefPtr transition = std::exchange(m_transition, nullptr))
transition->rejectPromise(exception);

if (apiMethodTracker)
apiMethodTracker->finishedPromise->reject<IDLAny>(result, RejectAsHandled::Yes);

if (RefPtr transition = std::exchange(m_transition, nullptr))
transition->rejectPromise(exception);
});

// If a new event has been dispatched in our event handler then we were aborted above.
Expand Down

0 comments on commit a354d41

Please sign in to comment.