Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for creating panels in the Web Extension devtools background page. #24365

Merged
merged 1 commit into from
Feb 13, 2024

Conversation

xeenon
Copy link
Contributor

@xeenon xeenon commented Feb 13, 2024

553a55c

Add support for creating panels in the Web Extension devtools background page.
https://webkit.org/b/246485
rdar://problem/114823326

Reviewed by Jeff Miller.

This adds support for browser.devtools.panels.create() and firing the onShown and
onHidden events on those panels when they are shown / hidden in Web Inspector.

This requires loading the devtools background page in the same process as Web Inspector,
since we need to pass the window object of the new panel's frame to the onShown listeners.

Added a new test that exercise this end-to-end. We also have WKInspectorExtension API
tests that test this separate from the Web Extensions tests.

* Source/WebKit/Scripts/webkit/messages.py:
(types_that_cannot_be_forward_declared):
(headers_for_type):
* Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIDevToolsPanels.mm: Added.
(WebKit::WebExtensionContext::devToolsPanelsCreate):
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm:
(WebKit::WebExtensionContext::webViewConfiguration):
(WebKit::WebExtensionContext::openInspectors const):
(WebKit::WebExtensionContext::inspectorExtension const):
(WebKit::WebExtensionContext::inspector const):
(WebKit::WebExtensionContext::processes const):
(WebKit::WebExtensionContext::loadInspectorBackgroundPage):
(WebKit::WebExtensionContext::unloadInspectorBackgroundPage):
(WebKit::WebExtensionContext::didShowInspectorExtensionPanel const):
(WebKit::WebExtensionContext::didHideInspectorExtensionPanel const):
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionURLSchemeHandlerCocoa.mm:
(WebKit::WebExtensionURLSchemeHandler::platformStartTask):
* Source/WebKit/UIProcess/Extensions/WebExtensionContext.h:
(WebKit::WebExtensionContext::sendToProcesses const):
(WebKit::WebExtensionContext::sendToProcessesForEvent const):
(WebKit::WebExtensionContext::sendToProcessesForEvents const):
(WebKit::WebExtensionContext::sendToContentScriptProcessesForEvent const):
(WebKit::WebExtensionContext::sendToProcesses): Deleted.
(WebKit::WebExtensionContext::sendToProcessesForEvent): Deleted.
(WebKit::WebExtensionContext::sendToProcessesForEvents): Deleted.
(WebKit::WebExtensionContext::sendToContentScriptProcessesForEvent): Deleted.
* Source/WebKit/UIProcess/Extensions/WebExtensionContext.messages.in:
* Source/WebKit/UIProcess/Extensions/WebExtensionController.h:
* Source/WebKit/UIProcess/Inspector/mac/WKInspectorViewController.mm:
(-[WKInspectorViewController webViewConfiguration]):
* Source/WebKit/UIProcess/WebPageProxy.h:
* Source/WebKit/UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::processForNavigationInternal):
* Source/WebKit/WebKit.xcodeproj/project.pbxproj:
* Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIDevToolsCocoa.mm:
* Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIDevToolsExtensionPanelCocoa.mm:
(WebKit::WebExtensionAPIDevToolsExtensionPanel::onHidden):
(WebKit::WebExtensionContextProxy::dispatchDevToolsExtensionPanelShownEvent):
(WebKit::WebExtensionContextProxy::dispatchDevToolsExtensionPanelHiddenEvent):
* Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIDevToolsInspectedWindowCocoa.mm:
* Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIDevToolsNetworkCocoa.mm:
* Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIDevToolsPanelsCocoa.mm:
(WebKit::WebExtensionAPIDevToolsPanels::extensionPanel const):
(WebKit::WebExtensionAPIDevToolsPanels::createPanel):
(WebKit::WebExtensionAPIDevToolsPanels::createTab): Deleted.
* Source/WebKit/WebProcess/Extensions/API/WebExtensionAPIDevToolsPanels.h:
* Source/WebKit/WebProcess/Extensions/Interfaces/WebExtensionAPIDevToolsPanels.idl:
* Source/WebKit/WebProcess/Extensions/WebExtensionContextProxy.h:
* Source/WebKit/WebProcess/Extensions/WebExtensionContextProxy.messages.in:
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIDevTools.mm:
(TestWebKitAPI::TEST):

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

2a3fa44

Misc iOS, tvOS & watchOS macOS Linux Windows
βœ… πŸ§ͺ style βœ… πŸ›  ios βœ… πŸ›  mac βœ… πŸ›  wpe βœ… πŸ›  wincairo
βœ… πŸ§ͺ bindings βœ… πŸ›  ios-sim βœ… πŸ›  mac-AS-debug   πŸ§ͺ wpe-wk2
βœ… πŸ§ͺ webkitperl βœ… πŸ§ͺ ios-wk2 ⏳ πŸ§ͺ api-mac   πŸ§ͺ api-wpe
βœ… πŸ§ͺ webkitpy   πŸ§ͺ ios-wk2-wpt βœ… πŸ§ͺ mac-wk1 βœ… πŸ›  gtk
βœ… πŸ§ͺ api-ios βœ… πŸ§ͺ mac-wk2   πŸ§ͺ gtk-wk2
  πŸ›  tv βœ… πŸ§ͺ mac-AS-debug-wk2   πŸ§ͺ api-gtk
βœ… πŸ›  tv-sim
  πŸ›  watch
βœ… πŸ›  πŸ§ͺ unsafe-merge   πŸ›  watch-sim

@xeenon xeenon self-assigned this Feb 13, 2024
@xeenon xeenon added the WebKit Extensions Bugs related to extension support. label Feb 13, 2024
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Feb 13, 2024
@xeenon xeenon removed the merging-blocked Applied to prevent a change from being merged label Feb 13, 2024
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Feb 13, 2024
@xeenon xeenon removed the merging-blocked Applied to prevent a change from being merged label Feb 13, 2024
Copy link
Contributor

@jeffmapple jeffmapple left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned offline, it would be nice to move every #import after #import "config.h" at the top of the source files you're touching to be inside the #if for source files that are fully conditional on feature flags. You said the style bot complains if you don't immediately import the corresponding header file after config.h, but some of these source files have slight different names (e.g. WebExtensionAPIDevToolsPanelsCocoa.m imports WebExtensionAPIDevToolsPanels.h).

@xeenon xeenon added the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label Feb 13, 2024
@xeenon
Copy link
Contributor Author

xeenon commented Feb 13, 2024

As mentioned offline, it would be nice to move every #import after #import "config.h" at the top of the source files you're touching to be inside the #if for source files that are fully conditional on feature flags. You said the style bot complains if you don't immediately import the corresponding header file after config.h, but some of these source files have slight different names (e.g. WebExtensionAPIDevToolsPanelsCocoa.m imports WebExtensionAPIDevToolsPanels.h).

The style bot complained about this:

ERROR: Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIActionCocoa.mm:36:  Found header this file implements after other header. Should be: config.h, primary header, blank line, and then alphabetically sorted.  [build/include_order] [4]
ERROR: Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIAlarmsCocoa.mm:35:  Found header this file implements after other header. Should be: config.h, primary header, blank line, and then alphabetically sorted.  [build/include_order] [4]
ERROR: Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPICommandsCocoa.mm:37:  Found header this file implements after other header. Should be: config.h, primary header, blank line, and then alphabetically sorted.  [build/include_order] [4]
ERROR: Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPICookiesCocoa.mm:38:  Found header this file implements after other header. Should be: config.h, primary header, blank line, and then alphabetically sorted.  [build/include_order] [4]
ERROR: Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIDeclarativeNetRequestCocoa.mm:36:  Found header this file implements after other header. Should be: config.h, primary header, blank line, and then alphabetically sorted.  [build/include_order] [4]
ERROR: Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIDevToolsPanels.mm:35:  Found header this file implements after other header. Should be: config.h, primary header, blank line, and then alphabetically sorted.  [build/include_order] [4]
ERROR: Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIEventCocoa.mm:35:  Found header this file implements after other header. Should be: config.h, primary header, blank line, and then alphabetically sorted.  [build/include_order] [4]
ERROR: Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIExtensionCocoa.mm:34:  You should not add a blank line before implementation file's own header.  [build/include_order] [4]
ERROR: Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIMenusCocoa.mm:34:  You should add a blank line after implementation file's own header.  [build/include_order] [4]
ERROR: Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIMenusCocoa.mm:34:  You should not add a blank line before implementation file's own header.  [build/include_order] [4]
ERROR: Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIPermissionsCocoa.mm:36:  Found header this file implements after other header. Should be: config.h, primary header, blank line, and then alphabetically sorted.  [build/include_order] [4]
ERROR: Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIPortCocoa.mm:37:  Found header this file implements after other header. Should be: config.h, primary header, blank line, and then alphabetically sorted.  [build/include_order] [4]
ERROR: Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIRuntimeCocoa.mm:36:  Found header this file implements after other header. Should be: config.h, primary header, blank line, and then alphabetically sorted.  [build/include_order] [4]
ERROR: Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIScriptingCocoa.mm:39:  Found header this file implements after other header. Should be: config.h, primary header, blank line, and then alphabetically sorted.  [build/include_order] [4]
ERROR: Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIStorageCocoa.mm:36:  Found header this file implements after other header. Should be: config.h, primary header, blank line, and then alphabetically sorted.  [build/include_order] [4]
ERROR: Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPITabsCocoa.mm:37:  Found header this file implements after other header. Should be: config.h, primary header, blank line, and then alphabetically sorted.  [build/include_order] [4]
ERROR: Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPITestCocoa.mm:35:  Found header this file implements after other header. Should be: config.h, primary header, blank line, and then alphabetically sorted.  [build/include_order] [4]
ERROR: Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIWebNavigationCocoa.mm:36:  Found header this file implements after other header. Should be: config.h, primary header, blank line, and then alphabetically sorted.  [build/include_order] [4]
ERROR: Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIWindowsCocoa.mm:35:  Found header this file implements after other header. Should be: config.h, primary header, blank line, and then alphabetically sorted.  [build/include_order] [4]

…und page.

https://webkit.org/b/246485
rdar://problem/114823326

Reviewed by Jeff Miller.

This adds support for browser.devtools.panels.create() and firing the onShown and
onHidden events on those panels when they are shown / hidden in Web Inspector.

This requires loading the devtools background page in the same process as Web Inspector,
since we need to pass the window object of the new panel's frame to the onShown listeners.

Added a new test that exercise this end-to-end. We also have WKInspectorExtension API
tests that test this separate from the Web Extensions tests.

* Source/WebKit/Scripts/webkit/messages.py:
(types_that_cannot_be_forward_declared):
(headers_for_type):
* Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIDevToolsPanels.mm: Added.
(WebKit::WebExtensionContext::devToolsPanelsCreate):
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm:
(WebKit::WebExtensionContext::webViewConfiguration):
(WebKit::WebExtensionContext::openInspectors const):
(WebKit::WebExtensionContext::inspectorExtension const):
(WebKit::WebExtensionContext::inspector const):
(WebKit::WebExtensionContext::processes const):
(WebKit::WebExtensionContext::loadInspectorBackgroundPage):
(WebKit::WebExtensionContext::unloadInspectorBackgroundPage):
(WebKit::WebExtensionContext::didShowInspectorExtensionPanel const):
(WebKit::WebExtensionContext::didHideInspectorExtensionPanel const):
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionURLSchemeHandlerCocoa.mm:
(WebKit::WebExtensionURLSchemeHandler::platformStartTask):
* Source/WebKit/UIProcess/Extensions/WebExtensionContext.h:
(WebKit::WebExtensionContext::sendToProcesses const):
(WebKit::WebExtensionContext::sendToProcessesForEvent const):
(WebKit::WebExtensionContext::sendToProcessesForEvents const):
(WebKit::WebExtensionContext::sendToContentScriptProcessesForEvent const):
(WebKit::WebExtensionContext::sendToProcesses): Deleted.
(WebKit::WebExtensionContext::sendToProcessesForEvent): Deleted.
(WebKit::WebExtensionContext::sendToProcessesForEvents): Deleted.
(WebKit::WebExtensionContext::sendToContentScriptProcessesForEvent): Deleted.
* Source/WebKit/UIProcess/Extensions/WebExtensionContext.messages.in:
* Source/WebKit/UIProcess/Extensions/WebExtensionController.h:
* Source/WebKit/UIProcess/Inspector/mac/WKInspectorViewController.mm:
(-[WKInspectorViewController webViewConfiguration]):
* Source/WebKit/UIProcess/WebPageProxy.h:
* Source/WebKit/UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::processForNavigationInternal):
* Source/WebKit/WebKit.xcodeproj/project.pbxproj:
* Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIDevToolsCocoa.mm:
* Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIDevToolsExtensionPanelCocoa.mm:
(WebKit::WebExtensionAPIDevToolsExtensionPanel::onHidden):
(WebKit::WebExtensionContextProxy::dispatchDevToolsExtensionPanelShownEvent):
(WebKit::WebExtensionContextProxy::dispatchDevToolsExtensionPanelHiddenEvent):
* Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIDevToolsInspectedWindowCocoa.mm:
* Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIDevToolsNetworkCocoa.mm:
* Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIDevToolsPanelsCocoa.mm:
(WebKit::WebExtensionAPIDevToolsPanels::extensionPanel const):
(WebKit::WebExtensionAPIDevToolsPanels::createPanel):
(WebKit::WebExtensionAPIDevToolsPanels::createTab): Deleted.
* Source/WebKit/WebProcess/Extensions/API/WebExtensionAPIDevToolsPanels.h:
* Source/WebKit/WebProcess/Extensions/Interfaces/WebExtensionAPIDevToolsPanels.idl:
* Source/WebKit/WebProcess/Extensions/WebExtensionContextProxy.h:
* Source/WebKit/WebProcess/Extensions/WebExtensionContextProxy.messages.in:
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIDevTools.mm:
(TestWebKitAPI::TEST):

Canonical link: https://commits.webkit.org/274589@main
@webkit-commit-queue
Copy link
Collaborator

Committed 274589@main (553a55c): https://commits.webkit.org/274589@main

Reviewed commits have been landed. Closing PR #24365 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit 553a55c into WebKit:main Feb 13, 2024
@webkit-commit-queue webkit-commit-queue removed the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label Feb 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WebKit Extensions Bugs related to extension support.
Projects
None yet
5 participants