[webkit-changes] [WebKit/WebKit] 11b7c4: ASSERTION FAILED: m_contextMenuPreventionState != ...

Aditya Keerthi noreply at github.com
Mon Mar 6 15:53:34 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 11b7c45306f25d65ee4762c0d0fb6c7d6c2f2bef
      https://github.com/WebKit/WebKit/commit/11b7c45306f25d65ee4762c0d0fb6c7d6c2f2bef
  Author: Aditya Keerthi <akeerthi at apple.com>
  Date:   2023-03-06 (Mon, 06 Mar 2023)

  Changed paths:
    M Tools/TestWebKitAPI/Tests/mac/ContextMenuTests.mm
    M Tools/TestWebKitAPI/cocoa/TestUIDelegate.h
    M Tools/TestWebKitAPI/cocoa/TestUIDelegate.mm

  Log Message:
  -----------
  ASSERTION FAILED: m_contextMenuPreventionState != EventPreventionState::Waiting when running ContextMenuTests
https://bugs.webkit.org/show_bug.cgi?id=253402
rdar://106209710

Reviewed by Wenson Hsieh.

255193 at main added `m_contextMenuPreventionState` and the associated assertions to
ensure a consistent ordering between right clicking, contextmenu events, and
context menu display. The state is set to "Waiting" when the right click is first
received in the UI process, and is only reset when the Web process responds with
the result.

261019 at main added multiple context menu tests that perform two successive right
clicks, while using SPI to prevent showing a context menu. This means that the
second right click is received by the UI process before the Web process has a
chance to handle the first event. Consequently, `m_contextMenuPreventionState`
is still "Waiting" when the second right click is received, and the assertion
is hit.

In real use cases, this scenario should never occur. Normally, menu presentation
is not suppressed at the UI process layer, so the second right click will only
be received in the UI process after the menu is presented, giving the web
process time to respond. The only way two right clicks could be received before
the Web process responds is if the Web process is hung, in which case there are
already minimal guarantees about event handling.

Consequently, fix the issue by updating the tests to wait for a presentation
update prior to sending the second right click. This ensures that the Web
process can handle the first right click before the second one is received.

* Tools/TestWebKitAPI/Tests/mac/ContextMenuTests.mm:
(-[TestWKWebView rightClickAtPointAndWaitForContextMenu:]):

Move the all the context menu waiting logic into a common method to avoid code
duplication, and reduce future errors.

(TestWebKitAPI::TEST):
* Tools/TestWebKitAPI/cocoa/TestUIDelegate.h:
* Tools/TestWebKitAPI/cocoa/TestUIDelegate.mm:

Move the context menu helper code out of here since it needs to operate on a
`TestWKWebView`.

(-[WKWebView _test_waitForContextMenu]): Deleted.

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




More information about the webkit-changes mailing list