[webkit-changes] [WebKit/WebKit] a6ce7b: Document Leak Occurs when opening Context Menu

Nathan Solomon noreply at github.com
Wed Jan 15 16:22:38 PST 2025


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: a6ce7b296295f0b388d6c7ea235bdc2490d13508
      https://github.com/WebKit/WebKit/commit/a6ce7b296295f0b388d6c7ea235bdc2490d13508
  Author: Nathan Solomon <nathan_solomon at apple.com>
  Date:   2025-01-15 (Wed, 15 Jan 2025)

  Changed paths:
    A LayoutTests/editing/mac/spelling/disable-automatic-spelling-correction-context-menu-item-does-not-leak-expected.txt
    A LayoutTests/editing/mac/spelling/disable-automatic-spelling-correction-context-menu-item-does-not-leak.html
    M LayoutTests/editing/mac/spelling/disable-automatic-spelling-correction-context-menu-item.html
    M LayoutTests/platform/mac-wk1/TestExpectations
    M LayoutTests/resources/document-leak-test.js
    M Source/WebCore/page/ContextMenuController.cpp
    M Source/WebCore/page/ContextMenuController.h
    M Source/WebCore/testing/Internals.cpp
    M Source/WebKit/UIProcess/WebPageProxy.cpp

  Log Message:
  -----------
  Document Leak Occurs when opening Context Menu
https://bugs.webkit.org/show_bug.cgi?id=284189
rdar://137308000

Reviewed by Wenson Hsieh.
When a context click occurs, the ContextMenu is created.
The Page currently owns the ContextMenuController, which owns the
ContextMenu. The context menu's context strongly holds onto the event
target of the context click, as well as HitTestResults which hold
Refs to Nodes.
The document that the context click occured
on can't be destructed because of this strong reference to the Node that
is held by the context menu's context. Because a new context object
is already being created for every new context click, ensure that we
destroy the held context when dismissing the context menu so that
the Page does not indirectly hold onto a node during document
destruction.

* LayoutTests/editing/mac/spelling/disable-automatic-spelling-correction-context-menu-item-does-not-leak-expected.txt: Added.
* LayoutTests/editing/mac/spelling/disable-automatic-spelling-correction-context-menu-item-does-not-leak.html: Added.
* LayoutTests/editing/mac/spelling/disable-automatic-spelling-correction-context-menu-item.html:
* LayoutTests/platform/mac-wk1/TestExpectations:
* LayoutTests/resources/document-leak-test.js:
(async runDocumentLeakTestSynchronously):
(cleanIframeUponMessageReceived):
* Source/WebCore/page/ContextMenuController.cpp:
(WebCore::ContextMenuController::didDismissContextMenu):
* Source/WebCore/page/ContextMenuController.h:
(WebCore::ContextMenuController::setContextMenuContext): Deleted.
* Source/WebCore/testing/Internals.cpp:
(WebCore::Internals::resetToConsistentState):
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didDismissContextMenu):

Canonical link: https://commits.webkit.org/288976@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