Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 31ea7826bd9487837a696e15416e3376f5dc0fc6
      
https://github.com/WebKit/WebKit/commit/31ea7826bd9487837a696e15416e3376f5dc0fc6
  Author: Cole Carley <[email protected]>
  Date:   2026-10-05 (Mon, 05 Oct 2026)

  Changed paths:
    A 
LayoutTests/http/tests/quirks/same-document-navigation-reresolves-quirks-expected.txt
    A 
LayoutTests/http/tests/quirks/same-document-navigation-reresolves-quirks.html
    M Source/WebCore/dom/Document.cpp
    M Source/WebCore/dom/Document.h
    M Source/WebCore/page/Page.cpp
    M Source/WebCore/page/Page.h
    M Source/WebCore/page/Quirks.cpp
    M Source/WebCore/page/Quirks.h
    M Source/WebCore/page/QuirksData.h
    M Source/WebCore/testing/Internals.cpp
    M Source/WebCore/testing/Internals.h
    M Source/WebCore/testing/Internals.idl
    M Tools/TestWebKitAPI/SourcesCocoa.txt
    M Tools/TestWebKitAPI/Tests/WebCore/Quirks.cpp
    A Tools/TestWebKitAPI/Tests/WebKit/WKWebView/QuirksURLChange.mm

  Log Message:
  -----------
  [Quirks] Re-resolve site-specific quirks when the document URL changes
https://bugs.webkit.org/show_bug.cgi?id=326379
rdar://189209581

Reviewed by Brent Fulgham.

Quirks are resolved from the document's URL and the top document's URL when the
document is created, and again only when it becomes current in its frame.
Same-document URL changes (history.pushState(), history.replaceState(), and
fragment navigations) go through Document::setURL() but never touched the quirk
set, so the cached quirks go stale. This regressed when quirk resolution moved
to load time in 287966@main.  I address this problem by re-resolving quirks
wherever the URLs they depend on change.

To test this from JavaScript, I added internals.setTopDocumentHostForQuirks(), 
which
replaces only the host of the top document URL used for quirk matching. The
existing setTopDocumentURLForQuirks() replaces the whole URL, so pushState() has
no visible effect under it.

Tests: Tools/TestWebKitAPI/Tests/WebCore/Quirks.cpp
       Tools/TestWebKitAPI/Tests/WebKit/WKWebView/QuirksURLChange.mm
       http/tests/quirks/same-document-navigation-reresolves-quirks.html

* 
LayoutTests/http/tests/quirks/same-document-navigation-reresolves-quirks-expected.txt:
 Added.
* 
LayoutTests/http/tests/quirks/same-document-navigation-reresolves-quirks.html: 
Added.
* Source/WebCore/dom/Document.cpp:
(WebCore::Document::urlsAffectingQuirksDidChange):
(WebCore::Document::setURL):
* Source/WebCore/dom/Document.h:
* Source/WebCore/page/Page.cpp:
(WebCore::Page::setMainFrameURLAndOrigin):
(WebCore::Page::updateTopDocumentSyncData):
(WebCore::Page::setQuirksTopDocumentHostForTesting):
(WebCore::Page::topDocumentURLDidChange):
* Source/WebCore/page/Page.h:
* Source/WebCore/page/Quirks.cpp:
(WebCore::Quirks::applyFacebookFlagQuirk):
(WebCore::Quirks::topDocumentURL const):
(WebCore::Quirks::urlsDidChange):
* Source/WebCore/page/Quirks.h:
* Source/WebCore/page/QuirksData.h:
(WebCore::QuirksData::hasSameBehaviorFlags const):
* Source/WebCore/testing/Internals.cpp:
(WebCore::Internals::resetToConsistentState):
(WebCore::Internals::setTopDocumentHostForQuirks):
* Source/WebCore/testing/Internals.h:
* Source/WebCore/testing/Internals.idl:
* Tools/TestWebKitAPI/SourcesCocoa.txt:
* Tools/TestWebKitAPI/Tests/WebCore/Quirks.cpp:
(TestWebKitAPI::hasActiveQuirk):
(TestWebKitAPI::createPageWithQuirksEnabled):
(TestWebKitAPI::TEST_F(QuirksTest, SameDocumentNavigationReresolvesQuirks)):
* Tools/TestWebKitAPI/Tests/WebKit/WKWebView/QuirksURLChange.mm: Added.
(createWebViewWithInternalsAndQuirks):
(TEST(QuirksURLChange, TopDocumentPushStateReresolvesSubframeQuirks)):

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



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to