[webkit-changes] [WebKit/WebKit] d85dda: [Site Isolation] Document::isTopDocument should re...

Sihui noreply at github.com
Wed May 1 12:25:30 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: d85ddaf99d035414fda2f2974bee09751b6ad50e
      https://github.com/WebKit/WebKit/commit/d85ddaf99d035414fda2f2974bee09751b6ad50e
  Author: Sihui Liu <sihui_liu at apple.com>
  Date:   2024-05-01 (Wed, 01 May 2024)

  Changed paths:
    M Source/WebCore/dom/Document.cpp
    M Source/WebCore/dom/Document.h

  Log Message:
  -----------
  [Site Isolation] Document::isTopDocument should return false for document of subframe
https://bugs.webkit.org/show_bug.cgi?id=273510
rdar://127308766

Reviewed by Alex Christensen.

Currently `Document::isTopDocument` can return true when `Document` is in a subframe, as `Document::topDocument` returns
`this` when main frame is remote. When main frame is remote, the document cannot be top-level document, as the top-level
document should be in the same process as the main frame. To fix this, this patch makes `Document::isTopDocument` return
true only when main frame is local and main frame's document is the same as `this` (there could be multiple documents
pointing to the same frame, but only the one in use by frame can be the top). This change will make sure
`Document::isSameSiteForCookies` return the correct value and cookie test passes when site isolation flag is enabled.

To avoid breakage, the patch adds `Document::isTopDocumentLegacy`, which implements the old behavior of
`Document::isTopDocument`. `Document::isTopDocumentLegacy` is used when site isolation is not enabled, and at places
where new `Document::isTopDocument` implementation would cause breakage. We will migrate those call sites to use
`Document::isTopDocument` later.

Test: http/tests/cookies/same-site/popup-cross-site-from-cross-origin-iframe.html.

* Source/WebCore/dom/Document.cpp:
(WebCore::Document::isTopDocument const):
* Source/WebCore/dom/Document.h:
(WebCore::Document::setUserDidInteractWithPage):
(WebCore::Document::userDidInteractWithPage const):
(WebCore::Document::isTopDocumentLegacy const):
(WebCore::Document::isTopDocument const): Deleted.

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



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


More information about the webkit-changes mailing list