Diff
Modified: trunk/Source/WebInspectorUI/ChangeLog (283195 => 283196)
--- trunk/Source/WebInspectorUI/ChangeLog 2021-09-28 21:16:29 UTC (rev 283195)
+++ trunk/Source/WebInspectorUI/ChangeLog 2021-09-28 21:28:07 UTC (rev 283196)
@@ -1,3 +1,22 @@
+2021-09-28 BJ Burg <[email protected]>
+
+ [Cocoa] Add SPI to select a tab created by _WKInspectorExtension
+ https://bugs.webkit.org/show_bug.cgi?id=230580
+ <rdar://problem/83372851>
+
+ Reviewed by Devin Rousso.
+
+ Add a method to look up a WebInspectorExtensionTabContentView
+ by its extensionTabID and then show it with WI.tabBrowser.
+
+ * UserInterface/Controllers/WebInspectorExtensionController.js:
+ (WI.WebInspectorExtensionController.prototype.reloadForExtension):
+ Remove extra newlines.
+ (WI.WebInspectorExtensionController.prototype.showExtensionTab): Added.
+
+ * UserInterface/Protocol/InspectorFrontendAPI.js:
+ (InspectorFrontendAPI.showExtensionTab): Added.
+
2021-09-23 Myles C. Maxfield <[email protected]>
Web Inspector support for font-palette
Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/WebInspectorExtensionController.js (283195 => 283196)
--- trunk/Source/WebInspectorUI/UserInterface/Controllers/WebInspectorExtensionController.js 2021-09-28 21:16:29 UTC (rev 283195)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/WebInspectorExtensionController.js 2021-09-28 21:28:07 UTC (rev 283196)
@@ -151,9 +151,25 @@
return WI.WebInspectorExtension.ErrorCode.InvalidRequest;
return target.PageAgent.reload.invoke({ignoreCache});
-
-
}
+
+ showExtensionTab(extensionTabID)
+ {
+ let tabContentView = this._extensionTabContentViewForExtensionTabIDMap.get(extensionTabID);
+ if (!tabContentView) {
+ WI.reportInternalError("Unable to show extension tab with unknown extensionTabID: " + extensionTabID);
+ return WI.WebInspectorExtension.ErrorCode.InvalidRequest;
+ }
+
+ let success = WI.tabBrowser.showTabForContentView(tabContentView, {
+ initiatorHint: WI.TabBrowser.TabNavigationInitiator.FrontendAPI,
+ });
+
+ if (!success) {
+ WI.reportInternalError("Unable to show extension tab with extensionTabID: " + extensionTabID);
+ return WI.WebInspectorExtension.ErrorCode.InternalError;
+ }
+ }
};
WI.WebInspectorExtensionController.Event = {
Modified: trunk/Source/WebInspectorUI/UserInterface/Protocol/InspectorFrontendAPI.js (283195 => 283196)
--- trunk/Source/WebInspectorUI/UserInterface/Protocol/InspectorFrontendAPI.js 2021-09-28 21:16:29 UTC (rev 283195)
+++ trunk/Source/WebInspectorUI/UserInterface/Protocol/InspectorFrontendAPI.js 2021-09-28 21:28:07 UTC (rev 283196)
@@ -230,4 +230,10 @@
{
return WI.sharedApp.extensionController.reloadForExtension(extensionID, {ignoreCache, userAgent, injectedScript});
},
+
+ // Returns a WI.WebInspectorExtension.ErrorCode if an error occurred, otherwise nothing.
+ showExtensionTab(extensionTabID)
+ {
+ return WI.sharedApp.extensionController.showExtensionTab(extensionTabID);
+ }
};
Modified: trunk/Source/WebKit/ChangeLog (283195 => 283196)
--- trunk/Source/WebKit/ChangeLog 2021-09-28 21:16:29 UTC (rev 283195)
+++ trunk/Source/WebKit/ChangeLog 2021-09-28 21:28:07 UTC (rev 283196)
@@ -1,3 +1,34 @@
+2021-09-28 BJ Burg <[email protected]>
+
+ [Cocoa] Add SPI to select a tab created by _WKInspectorExtension
+ https://bugs.webkit.org/show_bug.cgi?id=230580
+ <rdar://problem/83372851>
+
+ Reviewed by Devin Rousso.
+
+ Add a new method for selecting an extension tab in WebInspectorUI
+ that was previously created by using
+ -[_WKInspectorExtension createNewTab:tabIconURL:sourceURL:completionHandler].
+
+ This is a straightforward plumbing exercise. The API test uses the new method
+ to test the existing _WKInspectorExtensionDelegate callback methods for
+ didShowTab and didHideTab.
+
+ New API test: WKInspectorExtensionDelegate.ShowAndHideTabCallbacks.
+
+ * UIProcess/API/Cocoa/_WKInspector.mm:
+ (-[_WKInspector showExtensionTabWithIdentifier:completionHandler:]):
+ * UIProcess/API/Cocoa/_WKInspectorExtensionHost.h:
+ * UIProcess/API/Cocoa/_WKRemoteWebInspectorViewController.mm:
+ (-[_WKRemoteWebInspectorViewController showExtensionTabWithIdentifier:completionHandler:]):
+ * UIProcess/Inspector/WebInspectorUIExtensionControllerProxy.cpp:
+ (WebKit::WebInspectorUIExtensionControllerProxy::showExtensionTab):
+ * UIProcess/Inspector/WebInspectorUIExtensionControllerProxy.h:
+ * WebProcess/Inspector/WebInspectorUIExtensionController.cpp:
+ (WebKit::WebInspectorUIExtensionController::showExtensionTab):
+ * WebProcess/Inspector/WebInspectorUIExtensionController.h:
+ * WebProcess/Inspector/WebInspectorUIExtensionController.messages.in:
+
2021-09-28 Brent Fulgham <[email protected]>
Remove redundant sandbox exception rules for registering mach extensions
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspector.mm (283195 => 283196)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspector.mm 2021-09-28 21:16:29 UTC (rev 283195)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspector.mm 2021-09-28 21:28:07 UTC (rev 283196)
@@ -270,4 +270,24 @@
#endif
}
+- (void)showExtensionTabWithIdentifier:(NSString *)extensionTabIdentifier completionHandler:(void(^)(NSError *))completionHandler
+{
+#if ENABLE(INSPECTOR_EXTENSIONS)
+ // It is an error to call this method prior to creating a frontend (i.e., with -connect or -show).
+ if (!_inspector->extensionController()) {
+ completionHandler([NSError errorWithDomain:WKErrorDomain code:WKErrorUnknown userInfo:@{ NSLocalizedFailureReasonErrorKey: Inspector::extensionErrorToString(Inspector::ExtensionError::InvalidRequest)}]);
+ return;
+ }
+
+ _inspector->extensionController()->showExtensionTab(extensionTabIdentifier, [protectedSelf = retainPtr(self), capturedBlock = makeBlockPtr(completionHandler)] (Expected<bool, Inspector::ExtensionError>&& result) mutable {
+ if (!result) {
+ capturedBlock([NSError errorWithDomain:WKErrorDomain code:WKErrorUnknown userInfo:@{ NSLocalizedFailureReasonErrorKey: Inspector::extensionErrorToString(result.error())}]);
+ return;
+ }
+
+ capturedBlock(nil);
+ });
+#endif
+}
+
@end
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspectorExtensionHost.h (283195 => 283196)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspectorExtensionHost.h 2021-09-28 21:16:29 UTC (rev 283195)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspectorExtensionHost.h 2021-09-28 21:28:07 UTC (rev 283196)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020 Apple Inc. All rights reserved.
+ * Copyright (C) 2020-2021 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -54,6 +54,15 @@
- (void)unregisterExtension:(_WKInspectorExtension *)extension completionHandler:(void(^)(NSError * _Nullable))completionHandler;
/**
+ * @abstract Opens the specified extension tab in the associated Web Inspector.
+ * @param extensionTabIdentifier An identifier for an extension tab created using WKInspectorExtension methods.
+ * @param completionHandler The completion handler to be called when the request to show the tab succeeds or fails.
+ * @discussion This method has no effect if the extensionTabIdentifier is invalid.
+ * It is an error to call this method prior to calling -[_WKInspectorIBActions show].
+ */
+- (void)showExtensionTabWithIdentifier:(NSString *)extensionTabIdentifier completionHandler:(void(^)(NSError * _Nullable))completionHandler;
+
+/**
* @abstract The web view that is used to host extension tabs created via _WKInspectorExtension.
* @discussion Browsing contexts for extension tabs are loaded in subframes of this web view.
*/
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKRemoteWebInspectorViewController.mm (283195 => 283196)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKRemoteWebInspectorViewController.mm 2021-09-28 21:16:29 UTC (rev 283195)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKRemoteWebInspectorViewController.mm 2021-09-28 21:28:07 UTC (rev 283196)
@@ -217,6 +217,26 @@
m_remoteInspectorProxy->showResources();
}
+- (void)showExtensionTabWithIdentifier:(NSString *)extensionTabIdentifier completionHandler:(void(^)(NSError * _Nullable))completionHandler
+{
+#if ENABLE(INSPECTOR_EXTENSIONS)
+ // It is an error to call this method prior to creating a frontend (i.e., with -connect or -show).
+ if (!m_remoteInspectorProxy->extensionController()) {
+ completionHandler([NSError errorWithDomain:WKErrorDomain code:WKErrorUnknown userInfo:@{ NSLocalizedFailureReasonErrorKey: Inspector::extensionErrorToString(Inspector::ExtensionError::InvalidRequest)}]);
+ return;
+ }
+
+ m_remoteInspectorProxy->extensionController()->showExtensionTab(extensionTabIdentifier, [protectedSelf = retainPtr(self), capturedBlock = makeBlockPtr(completionHandler)] (Expected<bool, Inspector::ExtensionError>&& result) mutable {
+ if (!result) {
+ capturedBlock([NSError errorWithDomain:WKErrorDomain code:WKErrorUnknown userInfo:@{ NSLocalizedFailureReasonErrorKey: Inspector::extensionErrorToString(result.error())}]);
+ return;
+ }
+
+ capturedBlock(nil);
+ });
+#endif
+}
+
@end
NS_ASSUME_NONNULL_END
Modified: trunk/Source/WebKit/UIProcess/Inspector/WebInspectorUIExtensionControllerProxy.cpp (283195 => 283196)
--- trunk/Source/WebKit/UIProcess/Inspector/WebInspectorUIExtensionControllerProxy.cpp 2021-09-28 21:16:29 UTC (rev 283195)
+++ trunk/Source/WebKit/UIProcess/Inspector/WebInspectorUIExtensionControllerProxy.cpp 2021-09-28 21:28:07 UTC (rev 283196)
@@ -187,6 +187,19 @@
});
}
+void WebInspectorUIExtensionControllerProxy::showExtensionTab(const Inspector::ExtensionTabID& extensionTabIdentifier, CompletionHandler<void(Expected<bool, Inspector::ExtensionError>)>&& completionHandler)
+{
+ whenFrontendHasLoaded([weakThis = makeWeakPtr(this), extensionTabIdentifier, completionHandler = WTFMove(completionHandler)] () mutable {
+ if (!weakThis || !weakThis->m_inspectorPage) {
+ completionHandler(makeUnexpected(Inspector::ExtensionError::ContextDestroyed));
+ return;
+ }
+
+ weakThis->m_inspectorPage->sendWithAsyncReply(Messages::WebInspectorUIExtensionController::ShowExtensionTab { extensionTabIdentifier }, WTFMove(completionHandler));
+ });
+}
+
+
// WebInspectorUIExtensionControllerProxy IPC messages.
void WebInspectorUIExtensionControllerProxy::didShowExtensionTab(const Inspector::ExtensionID& extensionID, const Inspector::ExtensionTabID& extensionTabID)
Modified: trunk/Source/WebKit/UIProcess/Inspector/WebInspectorUIExtensionControllerProxy.h (283195 => 283196)
--- trunk/Source/WebKit/UIProcess/Inspector/WebInspectorUIExtensionControllerProxy.h 2021-09-28 21:16:29 UTC (rev 283195)
+++ trunk/Source/WebKit/UIProcess/Inspector/WebInspectorUIExtensionControllerProxy.h 2021-09-28 21:28:07 UTC (rev 283196)
@@ -60,6 +60,7 @@
void createTabForExtension(const Inspector::ExtensionID&, const String& tabName, const URL& tabIconURL, const URL& sourceURL, WTF::CompletionHandler<void(Expected<Inspector::ExtensionTabID, Inspector::ExtensionError>)>&&);
void evaluateScriptForExtension(const Inspector::ExtensionID&, const String& scriptSource, const std::optional<URL>& frameURL, const std::optional<URL>& contextSecurityOrigin, const std::optional<bool>& useContentScriptContext, WTF::CompletionHandler<void(Inspector::ExtensionEvaluationResult)>&&);
void reloadForExtension(const Inspector::ExtensionID&, const std::optional<bool>& ignoreCache, const std::optional<String>& userAgent, const std::optional<String>& injectedScript, WTF::CompletionHandler<void(Inspector::ExtensionEvaluationResult)>&&);
+ void showExtensionTab(const Inspector::ExtensionTabID&, CompletionHandler<void(Expected<bool, Inspector::ExtensionError>)>&&);
// WebInspectorUIExtensionControllerProxy IPC messages.
void didShowExtensionTab(const Inspector::ExtensionID&, const Inspector::ExtensionTabID&);
Modified: trunk/Source/WebKit/WebProcess/Inspector/WebInspectorUIExtensionController.cpp (283195 => 283196)
--- trunk/Source/WebKit/WebProcess/Inspector/WebInspectorUIExtensionController.cpp 2021-09-28 21:16:29 UTC (rev 283195)
+++ trunk/Source/WebKit/WebProcess/Inspector/WebInspectorUIExtensionController.cpp 2021-09-28 21:28:07 UTC (rev 283196)
@@ -326,6 +326,39 @@
});
}
+void WebInspectorUIExtensionController::showExtensionTab(const Inspector::ExtensionTabID& extensionTabIdentifier, CompletionHandler<void(Expected<bool, Inspector::ExtensionError>)>&& completionHandler)
+{
+ if (!m_frontendClient) {
+ completionHandler(makeUnexpected(Inspector::ExtensionError::InvalidRequest));
+ return;
+ }
+
+ Vector<Ref<JSON::Value>> arguments {
+ JSON::Value::create(extensionTabIdentifier),
+ };
+
+ m_frontendClient->frontendAPIDispatcher().dispatchCommandWithResultAsync("showExtensionTab"_s, WTFMove(arguments), [weakThis = makeWeakPtr(this), completionHandler = WTFMove(completionHandler)](InspectorFrontendAPIDispatcher::EvaluationResult&& result) mutable {
+ if (!weakThis) {
+ completionHandler(makeUnexpected(Inspector::ExtensionError::ContextDestroyed));
+ return;
+ }
+
+ auto* frontendGlobalObject = weakThis->m_frontendClient->frontendAPIDispatcher().frontendGlobalObject();
+ if (!frontendGlobalObject) {
+ completionHandler(makeUnexpected(Inspector::ExtensionError::ContextDestroyed));
+ return;
+ }
+
+ if (auto parsedError = weakThis->parseExtensionErrorFromEvaluationResult(result)) {
+ LOG(Inspector, "Internal error encountered while evaluating upon the frontend: %s", Inspector::extensionErrorToString(*parsedError).utf8().data());
+ completionHandler(makeUnexpected(*parsedError));
+ return;
+ }
+
+ completionHandler(true);
+ });
+}
+
void WebInspectorUIExtensionController::didShowExtensionTab(const Inspector::ExtensionID& extensionID, const Inspector::ExtensionTabID& extensionTabID)
{
WebProcess::singleton().parentProcessConnection()->send(Messages::WebInspectorUIExtensionControllerProxy::DidShowExtensionTab { extensionID, extensionTabID }, m_inspectorPageIdentifier);
Modified: trunk/Source/WebKit/WebProcess/Inspector/WebInspectorUIExtensionController.h (283195 => 283196)
--- trunk/Source/WebKit/WebProcess/Inspector/WebInspectorUIExtensionController.h 2021-09-28 21:16:29 UTC (rev 283195)
+++ trunk/Source/WebKit/WebProcess/Inspector/WebInspectorUIExtensionController.h 2021-09-28 21:28:07 UTC (rev 283196)
@@ -68,12 +68,11 @@
void createTabForExtension(const Inspector::ExtensionID&, const String& tabName, const URL& tabIconURL, const URL& sourceURL, CompletionHandler<void(Expected<Inspector::ExtensionTabID, Inspector::ExtensionError>)>&&);
void evaluateScriptForExtension(const Inspector::ExtensionID&, const String& scriptSource, const std::optional<URL>& frameURL, const std::optional<URL>& contextSecurityOrigin, const std::optional<bool>& useContentScriptContext, CompletionHandler<void(const IPC::DataReference&, const std::optional<WebCore::ExceptionDetails>&, const std::optional<Inspector::ExtensionError>&)>&&);
void reloadForExtension(const Inspector::ExtensionID&, const std::optional<bool>& ignoreCache, const std::optional<String>& userAgent, const std::optional<String>& injectedScript, CompletionHandler<void(const std::optional<Inspector::ExtensionError>&)>&&);
+ void showExtensionTab(const Inspector::ExtensionTabID&, CompletionHandler<void(Expected<bool, Inspector::ExtensionError>)>&&);
// Callbacks from the frontend.
-#if ENABLE(INSPECTOR_EXTENSIONS)
void didShowExtensionTab(const Inspector::ExtensionID&, const Inspector::ExtensionTabID&);
void didHideExtensionTab(const Inspector::ExtensionID&, const Inspector::ExtensionTabID&);
-#endif
private:
JSC::JSObject* unwrapEvaluationResultAsObject(WebCore::InspectorFrontendAPIDispatcher::EvaluationResult);
Modified: trunk/Source/WebKit/WebProcess/Inspector/WebInspectorUIExtensionController.messages.in (283195 => 283196)
--- trunk/Source/WebKit/WebProcess/Inspector/WebInspectorUIExtensionController.messages.in 2021-09-28 21:16:29 UTC (rev 283195)
+++ trunk/Source/WebKit/WebProcess/Inspector/WebInspectorUIExtensionController.messages.in 2021-09-28 21:28:07 UTC (rev 283196)
@@ -22,6 +22,10 @@
#if ENABLE(INSPECTOR_EXTENSIONS)
+// FIXME: some completion handlers with a parameter type of Expected<bool, Inspector::ExtensionError>
+// should actually be Expected<void, Inspector::ExtensionError>, but this does not compile as-is without
+// changes to argument coders. This cleanup is tracked by <https://bugs.webkit.org/b/230907>.
+
messages -> WebInspectorUIExtensionController NotRefCounted {
RegisterExtension(String extensionID, String displayName) -> (Expected<bool, Inspector::ExtensionError> result) Async
UnregisterExtension(String extensionID) -> (Expected<bool, Inspector::ExtensionError> result) Async
@@ -29,6 +33,7 @@
CreateTabForExtension(String extensionID, String tabName, URL tabIconURL, URL sourceURL) -> (Expected<String, Inspector::ExtensionError> result) Async
EvaluateScriptForExtension(String extensionID, String scriptSource, std::optional<URL> frameURL, std::optional<URL> contextSecurityOrigin, std::optional<bool> useContentScriptContext) -> (IPC::DataReference resultData, std::optional<WebCore::ExceptionDetails> details, std::optional<Inspector::ExtensionError> error) Async
ReloadForExtension(String extensionID, std::optional<bool> ignoreCache, std::optional<String> userAgent, std::optional<String> injectedScript) -> (std::optional<Inspector::ExtensionError> error) Async
+ ShowExtensionTab(String extensionTabIdentifier) -> (Expected<bool, Inspector::ExtensionError> result) Async
}
#endif // ENABLE(INSPECTOR_EXTENSIONS)
Modified: trunk/Tools/ChangeLog (283195 => 283196)
--- trunk/Tools/ChangeLog 2021-09-28 21:16:29 UTC (rev 283195)
+++ trunk/Tools/ChangeLog 2021-09-28 21:28:07 UTC (rev 283196)
@@ -1,3 +1,25 @@
+2021-09-28 BJ Burg <[email protected]>
+
+ [Cocoa] Add SPI to select a tab created by _WKInspectorExtension
+ https://bugs.webkit.org/show_bug.cgi?id=230580
+ <rdar://problem/83372851>
+
+ Reviewed by Devin Rousso.
+
+ Create a new test file for _WKInspectorExtensionDelegate. Add a
+ new test case that exercises creating an extension tab, showing an
+ extension tab, and uses delegate callbacks for didShowTab/didHideTab.
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/Tests/WebKitCocoa/InspectorExtension-TabIcon-30x30.png: Added.
+ * TestWebKitAPI/Tests/WebKitCocoa/InspectorExtension-basic-tab.html: Added.
+ * TestWebKitAPI/Tests/WebKitCocoa/WKInspectorExtensionDelegate.mm: Added.
+ (resetGlobalState):
+ (-[UIDelegateForTestingInspectorExtensionDelegate _webView:didAttachLocalInspector:]):
+ (-[InspectorExtensionDelegateForTesting inspectorExtension:didShowTabWithIdentifier:]):
+ (-[InspectorExtensionDelegateForTesting inspectorExtension:didHideTabWithIdentifier:]):
+ (TEST):
+
2021-09-28 Kate Cheney <[email protected]>
PCM: different bundleID entries will override each other
Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (283195 => 283196)
--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2021-09-28 21:16:29 UTC (rev 283195)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2021-09-28 21:28:07 UTC (rev 283196)
@@ -893,6 +893,9 @@
9999108B1F393C96008AD455 /* Copying.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9999108A1F393C8B008AD455 /* Copying.mm */; };
999B7EE32551C63B00F450A4 /* WKInspectorExtensionHost.mm in Sources */ = {isa = PBXBuildFile; fileRef = 999B7EE22551C63B00F450A4 /* WKInspectorExtensionHost.mm */; };
99B4F9C624EDED9700022B82 /* WKInspectorDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 99B4F9C524EDED9600022B82 /* WKInspectorDelegate.mm */; };
+ 99E2846426F91F7F0003F1FA /* WKInspectorExtensionDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 99E2846326F91F7F0003F1FA /* WKInspectorExtensionDelegate.mm */; };
+ 99E2846626F93DB50003F1FA /* InspectorExtension-TabIcon-30x30.png in Copy Resources */ = {isa = PBXBuildFile; fileRef = 99E2846526F93D760003F1FA /* InspectorExtension-TabIcon-30x30.png */; };
+ 99E2846826F941540003F1FA /* InspectorExtension-basic-tab.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 99E2846726F9413B0003F1FA /* InspectorExtension-basic-tab.html */; };
9B02E0D6235FA47D004044B2 /* TextManipulation.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9B02E0D5235FA47D004044B2 /* TextManipulation.mm */; };
9B0786A51C5885C300D159E3 /* InjectedBundleMakeAllShadowRootsOpen_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9B0786A41C5885C300D159E3 /* InjectedBundleMakeAllShadowRootsOpen_Bundle.cpp */; };
9B0C051924FDFB7D00F2FE31 /* CompactUniquePtrTuple.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9B0C051824FDFB7000F2FE31 /* CompactUniquePtrTuple.cpp */; };
@@ -1573,6 +1576,8 @@
2EFF06CD1D8A429A0004BB30 /* input-field-in-scrollable-document.html in Copy Resources */,
CE3524FA1B1443890028A7C5 /* input-focus-blur.html in Copy Resources */,
CE6D0EE32426B932002AD901 /* insert-text.html in Copy Resources */,
+ 99E2846826F941540003F1FA /* InspectorExtension-basic-tab.html in Copy Resources */,
+ 99E2846626F93DB50003F1FA /* InspectorExtension-TabIcon-30x30.png in Copy Resources */,
57F56A5C1C7F8CC100F31D7E /* IsNavigationActionTrusted.html in Copy Resources */,
C9B4AD2C1ECA6F7F00F5FEA0 /* js-autoplay-audio.html in Copy Resources */,
C99B675D1E39722000FC6C80 /* js-play-with-controls.html in Copy Resources */,
@@ -2619,6 +2624,9 @@
9999108A1F393C8B008AD455 /* Copying.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Copying.mm; sourceTree = "<group>"; };
999B7EE22551C63B00F450A4 /* WKInspectorExtensionHost.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKInspectorExtensionHost.mm; sourceTree = "<group>"; };
99B4F9C524EDED9600022B82 /* WKInspectorDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKInspectorDelegate.mm; sourceTree = "<group>"; };
+ 99E2846326F91F7F0003F1FA /* WKInspectorExtensionDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKInspectorExtensionDelegate.mm; sourceTree = "<group>"; };
+ 99E2846526F93D760003F1FA /* InspectorExtension-TabIcon-30x30.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "InspectorExtension-TabIcon-30x30.png"; sourceTree = "<group>"; };
+ 99E2846726F9413B0003F1FA /* InspectorExtension-basic-tab.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "InspectorExtension-basic-tab.html"; sourceTree = "<group>"; };
9B02E0D5235FA47D004044B2 /* TextManipulation.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = TextManipulation.mm; sourceTree = "<group>"; };
9B0786A21C58830F00D159E3 /* InjectedBundleMakeAllShadowRootsOpen.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedBundleMakeAllShadowRootsOpen.cpp; sourceTree = "<group>"; };
9B0786A41C5885C300D159E3 /* InjectedBundleMakeAllShadowRootsOpen_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedBundleMakeAllShadowRootsOpen_Bundle.cpp; sourceTree = "<group>"; };
@@ -3473,7 +3481,6 @@
6B25A75125DC8D4E0070744F /* EventAttribution.mm */,
CDA29B2820FD2A9900F15CED /* ExitFullscreenOnEnterPiP.mm */,
1D12BEBF245BEF85004C0B7A /* ExitPiPOnSuspendVideoElement.mm */,
- 51819F2926EAC98200E47375 /* FTP.mm */,
2D8104CB1BEC13E70020DA46 /* FindInPage.mm */,
51242CD42374E61E00EED9C1 /* FindInPageAPI.mm */,
118153472208BADF00B2CCD2 /* FirstVisuallyNonEmptyMilestone.mm */,
@@ -3481,6 +3488,7 @@
2E92B8F8216490EA005B64F0 /* FontAttributes.mm */,
F4FA282924CD012700618A46 /* FormValidation.mm */,
5CB5B3BD1FFC517E00C27BB0 /* FrameHandleSerialization.mm */,
+ 51819F2926EAC98200E47375 /* FTP.mm */,
CDCF78A7244A2EDB00480311 /* FullscreenAlert.mm */,
CD78E11A1DB7EA360014A2DE /* FullscreenDelegate.mm */,
3F1B52681D3D7129008D60C4 /* FullscreenLayoutConstraints.mm */,
@@ -3658,6 +3666,7 @@
370CE2291F57343400E7410B /* WKContentViewTargetForAction.mm */,
51D124971E763AF8002B2820 /* WKHTTPCookieStore.mm */,
99B4F9C524EDED9600022B82 /* WKInspectorDelegate.mm */,
+ 99E2846326F91F7F0003F1FA /* WKInspectorExtensionDelegate.mm */,
999B7EE22551C63B00F450A4 /* WKInspectorExtensionHost.mm */,
A5A729F01F622A9A00DE5A28 /* WKNavigationResponse.mm */,
DF4B273821A47727009BD1CA /* WKNSDictionaryEmptyDictionaryCrash.mm */,
@@ -4090,6 +4099,8 @@
93A274A1252163D600A1B6D4 /* IndexUpgradeWithMultipleIndices.sqlite3 */,
93A274A4252241D000A1B6D4 /* IndexUpgradeWithMultipleIndicesHaveSameID.sqlite3 */,
2EFF06CC1D8A42910004BB30 /* input-field-in-scrollable-document.html */,
+ 99E2846726F9413B0003F1FA /* InspectorExtension-basic-tab.html */,
+ 99E2846526F93D760003F1FA /* InspectorExtension-TabIcon-30x30.png */,
937A6C8824357BF300C3A6B0 /* KillWebProcessWithOpenConnection-1.html */,
937A6C8924357BF300C3A6B0 /* KillWebProcessWithOpenConnection-2.html */,
F4538EF01E846B4100B5C953 /* large-red-square.png */,
@@ -5541,6 +5552,7 @@
7CCE7EC01A411A7E00447C4C /* FragmentNavigation.mm in Sources */,
7CCE7EF61A411AE600447C4C /* FrameMIMETypeHTML.cpp in Sources */,
7CCE7EF71A411AE600447C4C /* FrameMIMETypePNG.cpp in Sources */,
+ 51819F2A26EAC98300E47375 /* FTP.mm in Sources */,
CDCF78A8244A32F700480311 /* FullscreenAlert.mm in Sources */,
CD78E11D1DB7EA660014A2DE /* FullscreenDelegate.mm in Sources */,
CDB213BD24EF522800FDE301 /* FullscreenFocus.mm in Sources */,
@@ -5798,7 +5810,6 @@
7CCE7F141A411AE600447C4C /* ShouldKeepCurrentBackForwardListItemInList.cpp in Sources */,
37BCA61C1B596BA9002012CA /* ShouldOpenExternalURLsInNewWindowActions.mm in Sources */,
7C83E0C51D0A654600FEBCF3 /* ShrinkToFit.mm in Sources */,
- 51819F2A26EAC98300E47375 /* FTP.mm in Sources */,
7CCE7ECD1A411A7E00447C4C /* SimplifyMarkup.mm in Sources */,
C149D550242E98DF003EBB12 /* SleepDisabler.mm in Sources */,
2DFF7B6D1DA487AF00814614 /* SnapshotStore.mm in Sources */,
@@ -5936,6 +5947,7 @@
51D124981E763B02002B2820 /* WKHTTPCookieStore.mm in Sources */,
7CCE7F1D1A411AE600447C4C /* WKImageCreateCGImageCrash.cpp in Sources */,
99B4F9C624EDED9700022B82 /* WKInspectorDelegate.mm in Sources */,
+ 99E2846426F91F7F0003F1FA /* WKInspectorExtensionDelegate.mm in Sources */,
999B7EE32551C63B00F450A4 /* WKInspectorExtensionHost.mm in Sources */,
A5A729F11F622AA700DE5A28 /* WKNavigationResponse.mm in Sources */,
DF4B273921A47728009BD1CA /* WKNSDictionaryEmptyDictionaryCrash.mm in Sources */,
@@ -6018,6 +6030,7 @@
5C4259462266A68A0039AA7A /* BasicProposedCredentialPlugIn.mm in Sources */,
374B7A611DF371CF00ACCB6C /* BundleEditingDelegatePlugIn.mm in Sources */,
7A89BB682331643A0042CB1E /* BundleFormDelegatePlugIn.mm in Sources */,
+ 5175C7A226F876230003AF5C /* BundlePageConsoleMessage.mm in Sources */,
A13EBBB01B87436F00097110 /* BundleParametersPlugIn.mm in Sources */,
37A709AF1E3EA97E00CA5969 /* BundleRangeHandlePlugIn.mm in Sources */,
5C75716122124C5200B9E5AC /* BundleRetainPagePlugIn.mm in Sources */,
@@ -6035,7 +6048,6 @@
2D3CA3A8221DF4B40088E803 /* PageOverlayPlugin.mm in Sources */,
F44C7A0020F9EEBF0014478C /* ParserYieldTokenPlugIn.mm in Sources */,
A13EBBAB1B87434600097110 /* PlatformUtilitiesCocoa.mm in Sources */,
- 5175C7A226F876230003AF5C /* BundlePageConsoleMessage.mm in Sources */,
1A4F81CF1BDFFD53004E672E /* RemoteObjectRegistryPlugIn.mm in Sources */,
A12DDC021E837C2400CF6CAE /* RenderedImageWithOptionsPlugIn.mm in Sources */,
5245178721B9F57B0082CB34 /* RenderingProgressPlugIn.mm in Sources */,
Added: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/InspectorExtension-TabIcon-30x30.png
(Binary files differ)
Index: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/InspectorExtension-TabIcon-30x30.png
===================================================================
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/InspectorExtension-TabIcon-30x30.png 2021-09-28 21:16:29 UTC (rev 283195)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/InspectorExtension-TabIcon-30x30.png 2021-09-28 21:28:07 UTC (rev 283196)
Property changes on: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/InspectorExtension-TabIcon-30x30.png
___________________________________________________________________
Added: svn:mime-type
+image/png
\ No newline at end of property
Added: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/InspectorExtension-basic-tab.html (0 => 283196)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/InspectorExtension-basic-tab.html (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/InspectorExtension-basic-tab.html 2021-09-28 21:28:07 UTC (rev 283196)
@@ -0,0 +1,6 @@
+<html>
+<body>
+<h1>This is a test extension.</h1>
+<p>In a normal extension, this area would show the extension's user interface.</p>
+</body>
+</html>
Added: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKInspectorExtensionDelegate.mm (0 => 283196)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKInspectorExtensionDelegate.mm (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKInspectorExtensionDelegate.mm 2021-09-28 21:28:07 UTC (rev 283196)
@@ -0,0 +1,159 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+
+#import "Test.h"
+#import "Utilities.h"
+#import <WebKit/WKPreferencesPrivate.h>
+#import <WebKit/WKWebViewPrivate.h>
+#import <WebKit/_WKInspector.h>
+#import <WebKit/_WKInspectorExtension.h>
+#import <WebKit/_WKInspectorExtensionDelegate.h>
+#import <WebKit/_WKInspectorPrivateForTesting.h>
+#import <wtf/RetainPtr.h>
+
+#if ENABLE(INSPECTOR_EXTENSIONS)
+
+static bool didAttachLocalInspectorCalled = false;
+static bool didShowExtensionTabWasCalled = false;
+static bool didHideExtensionTabWasCalled = false;
+static bool pendingCallbackWasCalled = false;
+static RetainPtr<_WKInspectorExtension> sharedInspectorExtension;
+static RetainPtr<NSString> sharedExtensionTabIdentifier;
+
+static void resetGlobalState()
+{
+ didAttachLocalInspectorCalled = false;
+ didShowExtensionTabWasCalled = false;
+ didHideExtensionTabWasCalled = false;
+ pendingCallbackWasCalled = false;
+}
+
+@interface UIDelegateForTestingInspectorExtensionDelegate : NSObject <WKUIDelegate>
+@end
+
+@implementation UIDelegateForTestingInspectorExtensionDelegate
+
+- (void)_webView:(WKWebView *)webView didAttachLocalInspector:(_WKInspector *)inspector
+{
+ EXPECT_EQ(webView._inspector, inspector);
+ didAttachLocalInspectorCalled = true;
+}
+
+@end
+
+
+@interface InspectorExtensionDelegateForTesting : NSObject <_WKInspectorExtensionDelegate>
+@end
+
+@implementation InspectorExtensionDelegateForTesting {
+}
+
+- (void)inspectorExtension:(_WKInspectorExtension *)extension didShowTabWithIdentifier:(NSString *)tabIdentifier
+{
+ didShowExtensionTabWasCalled = true;
+}
+
+- (void)inspectorExtension:(_WKInspectorExtension *)extension didHideTabWithIdentifier:(NSString *)tabIdentifier
+{
+ didHideExtensionTabWasCalled = true;
+}
+
+@end
+
+TEST(WKInspectorExtensionDelegate, ShowAndHideTabCallbacks)
+{
+ resetGlobalState();
+
+ auto webViewConfiguration = adoptNS([WKWebViewConfiguration new]);
+ webViewConfiguration.get().preferences._developerExtrasEnabled = YES;
+ auto webView = adoptNS([[WKWebView alloc] initWithFrame:CGRectMake(0, 0, 800, 600) configuration:webViewConfiguration.get()]);
+ auto uiDelegate = adoptNS([UIDelegateForTestingInspectorExtensionDelegate new]);
+
+ [webView setUIDelegate:uiDelegate.get()];
+ [webView loadHTMLString:@"<head><title>Test page to be inspected</title></head><body><p>Filler content</p></body>" baseURL:[NSURL URLWithString:@"http://example.com/"]];
+
+ [[webView _inspector] show];
+ TestWebKitAPI::Util::run(&didAttachLocalInspectorCalled);
+
+ auto extensionID = [NSUUID UUID].UUIDString;
+ auto extensionDisplayName = @"FirstExtension";
+
+ // Register the test extension.
+ pendingCallbackWasCalled = false;
+ [[webView _inspector] registerExtensionWithID:extensionID displayName:extensionDisplayName completionHandler:^(NSError * _Nullable error, _WKInspectorExtension * _Nullable extension) {
+ EXPECT_NULL(error);
+ EXPECT_NOT_NULL(extension);
+ sharedInspectorExtension = extension;
+
+ pendingCallbackWasCalled = true;
+ }];
+ TestWebKitAPI::Util::run(&pendingCallbackWasCalled);
+
+ auto extensionDelegate = adoptNS([InspectorExtensionDelegateForTesting new]);
+ [sharedInspectorExtension setDelegate:extensionDelegate.get()];
+
+ // Create an extension tab.
+ auto iconURL = [[NSBundle mainBundle] URLForResource:@"InspectorExtension-TabIcon-30x30" withExtension:@"png" subdirectory:@"TestWebKitAPI.resources"];
+ auto sourceURL = [[NSBundle mainBundle] URLForResource:@"InspectorExtension-basic-tab" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"];
+
+ pendingCallbackWasCalled = false;
+ [sharedInspectorExtension createTabWithName:@"FirstExtension-Tab" tabIconURL:iconURL sourceURL:sourceURL completionHandler:^(NSError * _Nullable error, NSString * _Nullable extensionTabIdentifier) {
+ EXPECT_NULL(error);
+ EXPECT_NOT_NULL(extensionTabIdentifier);
+ sharedExtensionTabIdentifier = extensionTabIdentifier;
+
+ pendingCallbackWasCalled = true;
+ }];
+ TestWebKitAPI::Util::run(&pendingCallbackWasCalled);
+
+ // Force a known non-extension tab to be shown before showing the extension tab. Otherwise,
+ // if the extension tab was already open, then this test would hang waiting for a didShow callback.
+ [[webView _inspector] showConsole];
+
+ pendingCallbackWasCalled = false;
+ [[webView _inspector] showExtensionTabWithIdentifier:sharedExtensionTabIdentifier.get() completionHandler:^(NSError * _Nullable error) {
+ EXPECT_NULL(error);
+
+ pendingCallbackWasCalled = true;
+ }];
+ TestWebKitAPI::Util::run(&pendingCallbackWasCalled);
+ TestWebKitAPI::Util::run(&didShowExtensionTabWasCalled);
+
+ [[webView _inspector] showConsole];
+ TestWebKitAPI::Util::run(&didHideExtensionTabWasCalled);
+
+ // Unregister the test extension.
+ pendingCallbackWasCalled = false;
+ [[webView _inspector] unregisterExtension:sharedInspectorExtension.get() completionHandler:^(NSError * _Nullable error) {
+ EXPECT_NULL(error);
+
+ pendingCallbackWasCalled = true;
+ }];
+ TestWebKitAPI::Util::run(&pendingCallbackWasCalled);
+}
+
+#endif // ENABLE(INSPECTOR_EXTENSIONS)