Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 74d7462ebe66e555633466c13d32671d6575296d
      
https://github.com/WebKit/WebKit/commit/74d7462ebe66e555633466c13d32671d6575296d
  Author: Rupin Mittal <[email protected]>
  Date:   2025-09-29 (Mon, 29 Sep 2025)

  Changed paths:
    M Source/WebCore/loader/FrameLoader.cpp
    M Source/WebCore/loader/PolicyChecker.cpp
    M Source/WebCore/loader/PolicyChecker.h

  Log Message:
  -----------
  [Navigation API] activation-history-replaceState.html and pushState fail on 
WPT
https://bugs.webkit.org/show_bug.cgi?id=299703
rdar://161520741

Reviewed by Basuke Suzuki.

These two tests fail on WPT but not locally when run with WKTR.

The issue is that with WPT, when Navigation::setActivation is called, there is
no NavigationNavigationType passed in, so the activation is not set and when
the test tries to retrieve it, it gets back null and fails.

The NavigationNavigationType that gets passed into Navigation::setActivation
comes from the DocumentLoader's triggeringAction in 
FrameLoader::didBeginDocument.

In the case of the WPT runner, the NavigationNavigationType is set on the
triggeringAction in FrameLoader::loadWithDocumentLoader in the if statement:
"if (loader->triggeringAction().isEmpty()) { }"

But loadWithDocumentLoader then calls PolicyChecker::checkNavigationPolicy.
Here, the triggeringAction is still considered empty (in isEmpty())
because m_requester->url().isEmpty() is true (meaning the Document's url
is an empty string). So a new triggeringAction is created and set on the
DocumentLoader. No NavigationNavigationType is set on this triggeringAction.
So later on, Navigation::setActivation has no NavigationNavigationType.

WKTR goes down this same code path. The NavigationNavigationType is set on the
triggeringAction in FrameLoader::loadWithDocumentLoader in the if statement:
"if (loader->triggeringAction().isEmpty()) { }".

Next, FrameLoader::loadWithDocumentLoader calls 
PolicyChecker::checkNavigationPolicy.
But here, the triggeringAction is NOT empty because the Document's url is 
about:blank.
So no new triggeringAction is set, which means the DocumentLoader's 
triggeringAction
will still have the NavigationNavigationType set earlier.

It's unclear why the Document doesn't have a URL in the WPT case, but we can fix
this by ensuring that when FrameLoader::loadWithDocumentLoader calls
PolicyChecker::checkNavigationPolicy, it passes in the NavigationNavigationType
that checkNavigationPolicy should set in the event that the triggeringAction is
empty and checkNavigationPolicy needs to make a new one.

This is covered by activation-history-replaceState.html and 
activation-history-pushState.html
now passing on WPT. I have manually verified this.

* Source/WebCore/loader/FrameLoader.cpp:
(WebCore::FrameLoader::loadWithDocumentLoader):
* Source/WebCore/loader/PolicyChecker.cpp:
(WebCore::PolicyChecker::checkNavigationPolicy):
* Source/WebCore/loader/PolicyChecker.h:

Canonical link: https://commits.webkit.org/300712@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to