[webkit-changes] [WebKit/WebKit] f14203: Add support for the Web Extensions Event API in th...

kiaraarose noreply at github.com
Mon Dec 5 09:42:28 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: f14203440c9ccb1f09af72288eec9fb1b75f235d
      https://github.com/WebKit/WebKit/commit/f14203440c9ccb1f09af72288eec9fb1b75f235d
  Author: Kiara Rose <kiara_rose at apple.com>
  Date:   2022-12-05 (Mon, 05 Dec 2022)

  Changed paths:
    M Source/WebKit/DerivedSources-input.xcfilelist
    M Source/WebKit/DerivedSources-output.xcfilelist
    M Source/WebKit/DerivedSources.make
    M Source/WebKit/Scripts/webkit/messages.py
    A Source/WebKit/Shared/Extensions/WebExtensionEventListenerType.h
    A Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIEventCocoa.mm
    M Source/WebKit/UIProcess/Extensions/WebExtensionContext.h
    M Source/WebKit/UIProcess/Extensions/WebExtensionContext.messages.in
    M Source/WebKit/WebKit.xcodeproj/project.pbxproj
    A Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIEventCocoa.mm
    A Source/WebKit/WebProcess/Extensions/API/WebExtensionAPIEvent.h
    M Source/WebKit/WebProcess/Extensions/Bindings/Scripts/CodeGeneratorExtensions.pm
    M Source/WebKit/WebProcess/Extensions/Interfaces/WebExtensionAPIEvent.idl

  Log Message:
  -----------
  Add support for the Web Extensions Event API in the WebProcess.
https://bugs.webkit.org/show_bug.cgi?id=248684

Reviewed by Timothy Hatcher.

This patch adds support for the Web Extensions Event API in the WebProcess. This includes support
for adding, removing, and invoking event listeners.

Testing:
Using a test extension, I added a 'testEvent' property to the WebExtensionTest API, and I called
"browser.test.testEvent.addListener()" in the background page of the extension. Using the debugger,
I confirmed that the code path for adding the listener hits and a call to
Messages::WebExtensionContext::AddListener is made.

* Source/WebKit/DerivedSources-input.xcfilelist:
* Source/WebKit/DerivedSources-output.xcfilelist:
* Source/WebKit/DerivedSources.make:

* Source/WebKit/Scripts/webkit/messages.py:
(types_that_cannot_be_forward_declared):
Add WebKit::WebExtensionEventListenerType to types that cannot be forward declared so that the
correct type will be used in WebExtensionMessageReceiver.

* Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIEventCocoa.mm:
Copied from Source/WebKit/UIProcess/Extensions/WebExtensionContext.messages.in.
(WebKit::WebExtensionContext::addListener):
(WebKit::WebExtensionContext::removeListener):
Methods for adding and removing event listeners for extensions in the UIProcess.
Implementation being tracked in https://bugs.webkit.org/show_bug.cgi?id=248684.

* Source/WebKit/UIProcess/Extensions/WebExtensionContext.h:
* Source/WebKit/UIProcess/Extensions/WebExtensionContext.messages.in:
* Source/WebKit/WebKit.xcodeproj/project.pbxproj:

* Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIEventCocoa.mm: Added.
(WebKit::WebExtensionAPIEvent::invokeListeners):
(WebKit::WebExtensionAPIEvent::invokeListenersWithArgument):
(WebKit::WebExtensionAPIEvent::addListener):
(WebKit::WebExtensionAPIEvent::removeListener):
(WebKit::WebExtensionAPIEvent::hasListener):

* Source/WebKit/WebProcess/Extensions/Bindings/Scripts/CodeGeneratorExtensions.pm:
(_platformTypeVariableDeclaration):
Remove this line of code so that the generated code in JSWebExtensionAPIEvent::addListener can
successfully set the listener. With this line, RefPtr<WebExtensionCallbackHandler> listener
never gets set.

* Source/WebKit/WebProcess/Extensions/Interfaces/WebExtensionAPIEvent.idl:
Use [NeedsPage] instead of NeedsPageWithCallbackHandler since hasListeners doesn't need the WebPage.

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




More information about the webkit-changes mailing list