Diff
Modified: trunk/Source/WebCore/ChangeLog (267410 => 267411)
--- trunk/Source/WebCore/ChangeLog 2020-09-22 16:00:50 UTC (rev 267410)
+++ trunk/Source/WebCore/ChangeLog 2020-09-22 16:14:08 UTC (rev 267411)
@@ -1,3 +1,23 @@
+2020-09-22 Brian Burg <[email protected]>
+
+ [Cocoa] _WKInspectorDelegate should handle showing external resources
+ https://bugs.webkit.org/show_bug.cgi?id=216334
+
+ Reviewed by Devin Rousso.
+
+ Adapt to the rename of InspectorFrontendHost.{openInNewTab => openURLExternally}.
+
+ * inspector/InspectorFrontendClient.h:
+ * inspector/InspectorFrontendClientLocal.cpp:
+ (WebCore::InspectorFrontendClientLocal::openURLExternally):
+ (WebCore::InspectorFrontendClientLocal::openInNewTab): Deleted.
+ * inspector/InspectorFrontendClientLocal.h:
+ * inspector/InspectorFrontendHost.cpp:
+ (WebCore::InspectorFrontendHost::openURLExternally):
+ (WebCore::InspectorFrontendHost::openInNewTab): Deleted.
+ * inspector/InspectorFrontendHost.h:
+ * inspector/InspectorFrontendHost.idl:
+
2020-09-22 Sam Weinig <[email protected]>
[WebIDL] Split up Performance.idl into component partials
Modified: trunk/Source/WebCore/inspector/InspectorFrontendClient.h (267410 => 267411)
--- trunk/Source/WebCore/inspector/InspectorFrontendClient.h 2020-09-22 16:00:50 UTC (rev 267410)
+++ trunk/Source/WebCore/inspector/InspectorFrontendClient.h 2020-09-22 16:14:08 UTC (rev 267411)
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2010 Google Inc. All rights reserved.
+ * Copyright (C) 2020 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
@@ -90,8 +91,7 @@
WEBCORE_EXPORT virtual void changeSheetRect(const FloatRect&) = 0;
- WEBCORE_EXPORT virtual void openInNewTab(const String& url) = 0;
-
+ WEBCORE_EXPORT virtual void openURLExternally(const String& url) = 0;
virtual bool canSave() = 0;
virtual void save(const WTF::String& url, const WTF::String& content, bool base64Encoded, bool forceSaveAs) = 0;
virtual void append(const WTF::String& url, const WTF::String& content) = 0;
Modified: trunk/Source/WebCore/inspector/InspectorFrontendClientLocal.cpp (267410 => 267411)
--- trunk/Source/WebCore/inspector/InspectorFrontendClientLocal.cpp 2020-09-22 16:00:50 UTC (rev 267410)
+++ trunk/Source/WebCore/inspector/InspectorFrontendClientLocal.cpp 2020-09-22 16:14:08 UTC (rev 267411)
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2010 Google Inc. All rights reserved.
- * Copyright (C) 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2015-2020 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
@@ -250,7 +250,7 @@
setSheetRect(rect);
}
-void InspectorFrontendClientLocal::openInNewTab(const String& url)
+void InspectorFrontendClientLocal::openURLExternally(const String& url)
{
UserGestureIndicator indicator { ProcessingUserGesture };
Frame& mainFrame = m_inspectedPageController->inspectedPage().mainFrame();
Modified: trunk/Source/WebCore/inspector/InspectorFrontendClientLocal.h (267410 => 267411)
--- trunk/Source/WebCore/inspector/InspectorFrontendClientLocal.h 2020-09-22 16:00:50 UTC (rev 267410)
+++ trunk/Source/WebCore/inspector/InspectorFrontendClientLocal.h 2020-09-22 16:14:08 UTC (rev 267411)
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2010 Google Inc. All rights reserved.
- * Copyright (C) 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2015-2020 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
@@ -76,7 +76,7 @@
WEBCORE_EXPORT void changeAttachedWindowHeight(unsigned) final;
WEBCORE_EXPORT void changeAttachedWindowWidth(unsigned) final;
WEBCORE_EXPORT void changeSheetRect(const FloatRect&) final;
- WEBCORE_EXPORT void openInNewTab(const String& url) final;
+ WEBCORE_EXPORT void openURLExternally(const String& url) final;
bool canSave() override { return false; }
void save(const String&, const String&, bool, bool) override { }
void append(const String&, const String&) override { }
Modified: trunk/Source/WebCore/inspector/InspectorFrontendHost.cpp (267410 => 267411)
--- trunk/Source/WebCore/inspector/InspectorFrontendHost.cpp 2020-09-22 16:00:50 UTC (rev 267410)
+++ trunk/Source/WebCore/inspector/InspectorFrontendHost.cpp 2020-09-22 16:14:08 UTC (rev 267411)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007-2019 Apple Inc. All rights reserved.
+ * Copyright (C) 2007-2020 Apple Inc. All rights reserved.
* Copyright (C) 2008 Matt Lilek <[email protected]>
*
* Redistribution and use in source and binary forms, with or without
@@ -414,13 +414,13 @@
editor.addTextToKillRing(text, insertionMode);
}
-void InspectorFrontendHost::openInNewTab(const String& url)
+void InspectorFrontendHost::openURLExternally(const String& url)
{
if (WTF::protocolIsJavaScript(url))
return;
if (m_client)
- m_client->openInNewTab(url);
+ m_client->openURLExternally(url);
}
bool InspectorFrontendHost::canSave()
Modified: trunk/Source/WebCore/inspector/InspectorFrontendHost.h (267410 => 267411)
--- trunk/Source/WebCore/inspector/InspectorFrontendHost.h 2020-09-22 16:00:50 UTC (rev 267410)
+++ trunk/Source/WebCore/inspector/InspectorFrontendHost.h 2020-09-22 16:14:08 UTC (rev 267411)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2007-2020 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -102,7 +102,7 @@
void copyText(const String& text);
void killText(const String& text, bool shouldPrependToKillRing, bool shouldStartNewSequence);
- void openInNewTab(const String& url);
+ void openURLExternally(const String& url);
bool canSave();
void save(const String& url, const String& content, bool base64Encoded, bool forceSaveAs);
void append(const String& url, const String& content);
Modified: trunk/Source/WebCore/inspector/InspectorFrontendHost.idl (267410 => 267411)
--- trunk/Source/WebCore/inspector/InspectorFrontendHost.idl 2020-09-22 16:00:50 UTC (rev 267410)
+++ trunk/Source/WebCore/inspector/InspectorFrontendHost.idl 2020-09-22 16:14:08 UTC (rev 267411)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2007-2020 Apple Inc. All rights reserved.
* Copyright (C) 2008 Matt Lilek <[email protected]>
* Copyright (C) 2009 Google Inc. All rights reserved.
*
@@ -71,7 +71,7 @@
undefined copyText(DOMString text);
undefined killText(DOMString text, boolean shouldPrependToKillRing, boolean shouldStartNewSequence);
- undefined openInNewTab(DOMString url);
+ undefined openURLExternally(DOMString url);
boolean canSave();
undefined save(DOMString url, DOMString content, boolean base64Encoded, boolean forceSaveAs);
undefined append(DOMString url, DOMString content);
Modified: trunk/Source/WebInspectorUI/ChangeLog (267410 => 267411)
--- trunk/Source/WebInspectorUI/ChangeLog 2020-09-22 16:00:50 UTC (rev 267410)
+++ trunk/Source/WebInspectorUI/ChangeLog 2020-09-22 16:14:08 UTC (rev 267411)
@@ -1,3 +1,19 @@
+2020-09-22 Brian Burg <[email protected]>
+
+ [Cocoa] _WKInspectorDelegate should handle showing external resources
+ https://bugs.webkit.org/show_bug.cgi?id=216334
+
+ Reviewed by Devin Rousso.
+
+ Adapt to the rename of InspectorFrontendHost.{openInNewTab => openURLExternally}.
+
+ * UserInterface/Base/Main.js:
+ * UserInterface/Debug/UncaughtExceptionReporter.js:
+ (sheetElement.innerHTML.div):
+ * UserInterface/Protocol/InspectorFrontendAPI.js:
+ * UserInterface/Views/ResourceTreeElement.js:
+ (WI.ResourceTreeElement.prototype.ondblclick):
+
2020-09-21 Nikita Vasilyev <[email protected]>
Web Inspector: Uncaught Exception: Missing node for given nodeId
Modified: trunk/Source/WebInspectorUI/UserInterface/Base/Main.js (267410 => 267411)
--- trunk/Source/WebInspectorUI/UserInterface/Base/Main.js 2020-09-22 16:00:50 UTC (rev 267410)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/Main.js 2020-09-22 16:14:08 UTC (rev 267411)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2013-2020 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -1060,7 +1060,7 @@
options.alwaysOpenExternally = window.event ? window.event.metaKey : false;
if (options.alwaysOpenExternally) {
- InspectorFrontendHost.openInNewTab(url);
+ InspectorFrontendHost.openURLExternally(url);
return;
}
@@ -1087,7 +1087,7 @@
return;
}
- InspectorFrontendHost.openInNewTab(url);
+ InspectorFrontendHost.openURLExternally(url);
};
WI.close = function()
Modified: trunk/Source/WebInspectorUI/UserInterface/Debug/UncaughtExceptionReporter.js (267410 => 267411)
--- trunk/Source/WebInspectorUI/UserInterface/Debug/UncaughtExceptionReporter.js 2020-09-22 16:00:50 UTC (rev 267410)
+++ trunk/Source/WebInspectorUI/UserInterface/Debug/UncaughtExceptionReporter.js 2020-09-22 16:14:08 UTC (rev 267411)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2015-2020 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -297,7 +297,7 @@
document.body.appendChild(sheetElement);
document.getElementById("uncaught-exception-bug-report-link").addEventListener("click", (event) => {
- InspectorFrontendHost.openInNewTab(prefilledBugReportLink);
+ InspectorFrontendHost.openURLExternally(prefilledBugReportLink);
event.stopImmediatePropagation();
event.preventDefault();
});
Modified: trunk/Source/WebInspectorUI/UserInterface/Protocol/InspectorFrontendAPI.js (267410 => 267411)
--- trunk/Source/WebInspectorUI/UserInterface/Protocol/InspectorFrontendAPI.js 2020-09-22 16:00:50 UTC (rev 267410)
+++ trunk/Source/WebInspectorUI/UserInterface/Protocol/InspectorFrontendAPI.js 2020-09-22 16:14:08 UTC (rev 267411)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013, 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2013-2020 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ResourceTreeElement.js (267410 => 267411)
--- trunk/Source/WebInspectorUI/UserInterface/Views/ResourceTreeElement.js 2020-09-22 16:00:50 UTC (rev 267410)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ResourceTreeElement.js 2020-09-22 16:14:08 UTC (rev 267411)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013, 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2013-2020 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -121,7 +121,7 @@
if (this._resource.type === WI.Resource.Type.WebSocket)
return;
- InspectorFrontendHost.openInNewTab(this._resource.url);
+ WI.openURL(this._resource.url);
}
// Protected (Used by FrameTreeElement)
Modified: trunk/Source/WebKit/ChangeLog (267410 => 267411)
--- trunk/Source/WebKit/ChangeLog 2020-09-22 16:00:50 UTC (rev 267410)
+++ trunk/Source/WebKit/ChangeLog 2020-09-22 16:14:08 UTC (rev 267411)
@@ -1,3 +1,110 @@
+2020-09-22 Brian Burg <[email protected]>
+
+ [Cocoa] _WKInspectorDelegate should handle showing external resources
+ https://bugs.webkit.org/show_bug.cgi?id=216334
+
+ Reviewed by Devin Rousso.
+
+ WebKit clients need a way to control the loading and presentation of
+ external resources that are linked in Web Inspector's user interface.
+
+ Rename InspectorFrontendHost.openInNewTab to openURLExternally. Change
+ the implementation to forward the request to UIProcess rather than the
+ inspected WebProcess.
+
+ When a navigation is triggered in WKInspectorViewController's WKWebView,
+ allow the delegate to open the requested resource. Otherwise, redirect
+ the navigation to the inspected WebView or open it using NSWorkspace
+ (for the remote case).
+
+ New API test: WKInspectorDelegate.OpenURLExternally.
+
+ * UIProcess/API/Cocoa/_WKInspectorPrivateForTesting.h: Added.
+ * UIProcess/API/Cocoa/_WKInspectorTesting.mm: Added.
+ (snippetToOpenURLExternally):
+ (-[_WKInspector _openURLExternallyForTesting:useFrontendAPI:]):
+ Add some helpers for writing API tests.
+
+ * UIProcess/API/APIInspectorClient.h:
+ (API::InspectorClient::openURLExternally):
+ * UIProcess/API/Cocoa/_WKInspectorDelegate.h:
+ * UIProcess/Cocoa/PageClientImplCocoa.mm:
+ * UIProcess/Inspector/Cocoa/InspectorDelegate.h:
+ * UIProcess/Inspector/Cocoa/InspectorDelegate.mm:
+ (WebKit::InspectorDelegate::setDelegate):
+ (WebKit::InspectorDelegate::InspectorClient::openURLExternally):
+ Add new delegate method to _WKInspectorDelegate.
+
+ * UIProcess/Inspector/RemoteWebInspectorProxy.messages.in:
+ * UIProcess/Inspector/RemoteWebInspectorProxy.h:
+ * UIProcess/Inspector/RemoteWebInspectorProxy.cpp:
+ (WebKit::RemoteWebInspectorProxy::openURLExternally):
+ (WebKit::RemoteWebInspectorProxy::platformOpenURLExternally):
+ (WebKit::RemoteWebInspectorProxy::openInNewTab): Deleted.
+ (WebKit::RemoteWebInspectorProxy::platformOpenInNewTab): Deleted.
+ * UIProcess/Inspector/gtk/RemoteWebInspectorProxyGtk.cpp:
+ (WebKit::RemoteWebInspectorProxy::platformURLExternally):
+ (WebKit::RemoteWebInspectorProxy::platformOpenInNewTab): Deleted.
+ * UIProcess/Inspector/mac/RemoteWebInspectorProxyMac.mm:
+ (WebKit::RemoteWebInspectorProxy::platformOpenURLExternally):
+ (WebKit::RemoteWebInspectorProxy::platformOpenInNewTab): Deleted.
+ * UIProcess/Inspector/win/RemoteWebInspectorProxyWin.cpp:
+ (WebKit::RemoteWebInspectorProxy::platformOpenURLExternally):
+ (WebKit::RemoteWebInspectorProxy::platformOpenInNewTab): Deleted.
+ Rename openInNewTab to openURLExternally. In some cases the client
+ may not choose to present a new tab, so the name is no longer accurate.
+
+ * UIProcess/Inspector/WebInspectorProxy.messages.in:
+ * UIProcess/Inspector/WebInspectorProxy.h:
+ * UIProcess/Inspector/WebInspectorProxy.cpp:
+ (WebKit::WebInspectorProxy::inspectorWindow const):
+ (WebKit::WebInspectorProxy::openURLExternally):
+ (WebKit::WebInspectorProxy::evaluateInFrontendForTesting):
+ * UIProcess/Inspector/mac/WebInspectorProxyMac.mm:
+ (-[WKWebInspectorProxyObjCAdapter inspectorViewController:openURLExternally:]):
+ Add some helpers for writing API tests. Add an IPC message
+ for evaluating a _javascript_ _expression_ in the frontend page.
+ Also, add a message receiver for the OpenURLExternally message
+ which passes the request to the API layer.
+
+ * UIProcess/Inspector/mac/WKInspectorViewController.h:
+ * UIProcess/Inspector/mac/WKInspectorViewController.mm:
+ (-[WKInspectorViewController webView:decidePolicyForNavigationAction:decisionHandler:]):
+ Call the delegate method if a navigation inside the inspector WKWebView is an external URL.
+ Specifically the request is to load something other than the Web Inspector's main HTML page.
+
+ * WebProcess/Inspector/WebInspector.cpp:
+ (WebKit::WebInspector::openInNewTab): Deleted.
+ * WebProcess/Inspector/WebInspector.h:
+ * WebProcess/Inspector/WebInspector.messages.in:
+ No need to handle this message anymore in the inspected WebProcess.
+
+ * WebProcess/Inspector/RemoteWebInspectorUI.h:
+ * WebProcess/Inspector/RemoteWebInspectorUI.cpp:
+ (WebKit::RemoteWebInspectorUI::openURLExternally):
+ (WebKit::RemoteWebInspectorUI::openInNewTab): Deleted.
+ * WebProcess/Inspector/WebInspectorUI.messages.in:
+ * WebProcess/Inspector/WebInspectorUI.h:
+ * WebProcess/Inspector/WebInspectorUI.cpp:
+ (WebKit::WebInspectorUI::updateConnection):
+ (WebKit::WebInspectorUI::closeWindow):
+ (WebKit::WebInspectorUI::openURLExternally):
+ (WebKit::WebInspectorUI::evaluateInFrontendForTesting):
+ (WebKit::WebInspectorUI::openInNewTab): Deleted.
+ When we need to open the URL externally, send an IPC message to UIProcess.
+ The old implementation triggered the navigation from the inspected WebProcess.
+ That approach is no longer desirable. Remove the unneeded IPC connection.
+
+ * WebProcess/Inspector/WebInspectorFrontendAPIDispatcher.h:
+ * WebProcess/Inspector/WebInspectorFrontendAPIDispatcher.cpp:
+ (WebKit::WebInspectorFrontendAPIDispatcher::evaluateExpressionForTesting):
+ Fulfill the request to evaluate the _expression_ in the frontend page.
+
+ * SourcesCocoa.txt:
+ * WebKit.xcodeproj/project.pbxproj:
+ Some files were added.
+
+
2020-09-22 Per Arne Vollan <[email protected]>
[macOS] Start collecting telemetry from message filtering
Modified: trunk/Source/WebKit/SourcesCocoa.txt (267410 => 267411)
--- trunk/Source/WebKit/SourcesCocoa.txt 2020-09-22 16:00:50 UTC (rev 267410)
+++ trunk/Source/WebKit/SourcesCocoa.txt 2020-09-22 16:14:08 UTC (rev 267411)
@@ -259,6 +259,7 @@
UIProcess/API/Cocoa/_WKFrameTreeNode.mm
UIProcess/API/Cocoa/_WKGeolocationPosition.mm
UIProcess/API/Cocoa/_WKInspector.mm
+UIProcess/API/Cocoa/_WKInspectorTesting.mm
UIProcess/API/Cocoa/_WKInspectorDebuggableInfo.mm
UIProcess/API/Cocoa/_WKInspectorWindow.mm
UIProcess/API/Cocoa/_WKInternalDebugFeature.mm
Modified: trunk/Source/WebKit/UIProcess/API/APIInspectorClient.h (267410 => 267411)
--- trunk/Source/WebKit/UIProcess/API/APIInspectorClient.h 2020-09-22 16:00:50 UTC (rev 267410)
+++ trunk/Source/WebKit/UIProcess/API/APIInspectorClient.h 2020-09-22 16:14:08 UTC (rev 267411)
@@ -25,6 +25,8 @@
#pragma once
+#include <wtf/Forward.h>
+
namespace WebKit {
class WebInspectorProxy;
}
@@ -38,6 +40,7 @@
virtual void browserDomainEnabled(WebKit::WebInspectorProxy&) { }
virtual void browserDomainDisabled(WebKit::WebInspectorProxy&) { }
+ virtual void openURLExternally(WebKit::WebInspectorProxy&, const WTF::String& url) { }
};
} // namespace API
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspectorDelegate.h (267410 => 267411)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspectorDelegate.h 2020-09-22 16:00:50 UTC (rev 267410)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspectorDelegate.h 2020-09-22 16:14:08 UTC (rev 267411)
@@ -41,4 +41,11 @@
*/
- (void)inspectorDidDisableBrowserDomain:(_WKInspector *)inspector;
+/*! @abstract Called when the _WKInspector requests to show a resource externally. This
+ is used to display documentation pages and to show external URLs that are linkified.
+ @param inspector the associated inspector for which an external navigation should be triggered.
+ @param url The resource to be shown.
+ */
+- (void)inspector:(_WKInspector *)inspector openURLExternally:(NSURL *)url;
+
@end
Copied: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspectorPrivateForTesting.h (from rev 267410, trunk/Source/WebKit/UIProcess/API/APIInspectorClient.h) (0 => 267411)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspectorPrivateForTesting.h (rev 0)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspectorPrivateForTesting.h 2020-09-22 16:14:08 UTC (rev 267411)
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2020 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 "_WKInspector.h"
+
+@interface _WKInspector (WKTesting)
+- (void)_openURLExternallyForTesting:(NSURL *)url useFrontendAPI:(BOOL)useFrontendAPI;
+@end
Copied: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspectorTesting.mm (from rev 267410, trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspectorDelegate.h) (0 => 267411)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspectorTesting.mm (rev 0)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspectorTesting.mm 2020-09-22 16:14:08 UTC (rev 267411)
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2020 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 "WKWebView.h"
+#import "_WKInspectorInternal.h"
+#import "_WKInspectorPrivateForTesting.h"
+
+// This file exists to centralize all fragile code that is used by _WKInspector API tests. The tests
+// trigger WebInspectorUI behavior by evaluating _javascript_ or by calling internal methods.
+
+static NSString *_javascript_SnippetToOpenURLExternally(NSURL *url)
+{
+ return [NSString stringWithFormat:@"InspectorFrontendHost.openURLExternally(\"%@\")", url.absoluteString];
+}
+
+@implementation _WKInspector (WKTesting)
+
+- (void)_openURLExternallyForTesting:(NSURL *)url useFrontendAPI:(BOOL)useFrontendAPI
+{
+ if (useFrontendAPI)
+ _inspector->evaluateInFrontendForTesting(_javascript_SnippetToOpenURLExternally(url));
+ else {
+ // Force the navigation request to be handled naturally through the
+ // internal NavigationDelegate of WKInspectorViewController.
+ [self.inspectorWebView loadRequest:[NSURLRequest requestWithURL:url]];
+ }
+}
+
+@end
Modified: trunk/Source/WebKit/UIProcess/Cocoa/PageClientImplCocoa.mm (267410 => 267411)
--- trunk/Source/WebKit/UIProcess/Cocoa/PageClientImplCocoa.mm 2020-09-22 16:00:50 UTC (rev 267410)
+++ trunk/Source/WebKit/UIProcess/Cocoa/PageClientImplCocoa.mm 2020-09-22 16:14:08 UTC (rev 267411)
@@ -38,7 +38,7 @@
PageClientImplCocoa::PageClientImplCocoa(WKWebView *webView)
: m_webView { webView }
- , m_alternativeTextUIController { makeUnique<AlternativeTextUIController>() }
+ , m_alternativeTextUIController { makeUnique<WebCore::AlternativeTextUIController>() }
{
}
Modified: trunk/Source/WebKit/UIProcess/Inspector/Cocoa/InspectorDelegate.h (267410 => 267411)
--- trunk/Source/WebKit/UIProcess/Inspector/Cocoa/InspectorDelegate.h 2020-09-22 16:00:50 UTC (rev 267410)
+++ trunk/Source/WebKit/UIProcess/Inspector/Cocoa/InspectorDelegate.h 2020-09-22 16:14:08 UTC (rev 267411)
@@ -58,6 +58,7 @@
// API::InspectorClient
void browserDomainEnabled(WebInspectorProxy&);
void browserDomainDisabled(WebInspectorProxy&);
+ void openURLExternally(WebInspectorProxy&, const String& url);
InspectorDelegate& m_inspectorDelegate;
};
@@ -68,6 +69,7 @@
struct {
bool inspectorDidEnableBrowserDomain : 1;
bool inspectorDidDisableBrowserDomain : 1;
+ bool inspectorOpenURLExternally : 1;
} m_delegateMethods;
};
Modified: trunk/Source/WebKit/UIProcess/Inspector/Cocoa/InspectorDelegate.mm (267410 => 267411)
--- trunk/Source/WebKit/UIProcess/Inspector/Cocoa/InspectorDelegate.mm 2020-09-22 16:00:50 UTC (rev 267410)
+++ trunk/Source/WebKit/UIProcess/Inspector/Cocoa/InspectorDelegate.mm 2020-09-22 16:14:08 UTC (rev 267411)
@@ -54,6 +54,7 @@
m_delegateMethods.inspectorDidEnableBrowserDomain = [delegate respondsToSelector:@selector(inspectorDidEnableBrowserDomain:)];
m_delegateMethods.inspectorDidDisableBrowserDomain = [delegate respondsToSelector:@selector(inspectorDidDisableBrowserDomain:)];
+ m_delegateMethods.inspectorOpenURLExternally = [delegate respondsToSelector:@selector(inspector:openURLExternally:)];
}
InspectorDelegate::InspectorClient::InspectorClient(InspectorDelegate& delegate)
@@ -87,4 +88,16 @@
[delegate inspectorDidDisableBrowserDomain:m_inspectorDelegate.m_inspector.get().get()];
}
+void InspectorDelegate::InspectorClient::openURLExternally(WebInspectorProxy&, const String& url)
+{
+ if (!m_inspectorDelegate.m_delegateMethods.inspectorOpenURLExternally)
+ return;
+
+ auto& delegate = m_inspectorDelegate.m_delegate;
+ if (!delegate)
+ return;
+
+ [delegate inspector:m_inspectorDelegate.m_inspector.get().get() openURLExternally:[NSURL URLWithString:url]];
+}
+
} // namespace WebKit
Modified: trunk/Source/WebKit/UIProcess/Inspector/RemoteWebInspectorProxy.cpp (267410 => 267411)
--- trunk/Source/WebKit/UIProcess/Inspector/RemoteWebInspectorProxy.cpp 2020-09-22 16:00:50 UTC (rev 267410)
+++ trunk/Source/WebKit/UIProcess/Inspector/RemoteWebInspectorProxy.cpp 2020-09-22 16:14:08 UTC (rev 267411)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2016-2020 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -148,9 +148,9 @@
platformStartWindowDrag();
}
-void RemoteWebInspectorProxy::openInNewTab(const String& url)
+void RemoteWebInspectorProxy::openURLExternally(const String& url)
{
- platformOpenInNewTab(url);
+ platformOpenURLExternally(url);
}
void RemoteWebInspectorProxy::showCertificate(const CertificateInfo& certificateInfo)
@@ -205,7 +205,7 @@
void RemoteWebInspectorProxy::platformSetSheetRect(const FloatRect&) { }
void RemoteWebInspectorProxy::platformSetForcedAppearance(InspectorFrontendClient::Appearance) { }
void RemoteWebInspectorProxy::platformStartWindowDrag() { }
-void RemoteWebInspectorProxy::platformOpenInNewTab(const String&) { }
+void RemoteWebInspectorProxy::platformOpenURLExternally(const String&) { }
void RemoteWebInspectorProxy::platformShowCertificate(const CertificateInfo&) { }
void RemoteWebInspectorProxy::platformCloseFrontendPageAndWindow() { }
#endif // !ENABLE(REMOTE_INSPECTOR) || (!PLATFORM(MAC) && !PLATFORM(GTK) && !PLATFORM(WIN))
Modified: trunk/Source/WebKit/UIProcess/Inspector/RemoteWebInspectorProxy.h (267410 => 267411)
--- trunk/Source/WebKit/UIProcess/Inspector/RemoteWebInspectorProxy.h 2020-09-22 16:00:50 UTC (rev 267410)
+++ trunk/Source/WebKit/UIProcess/Inspector/RemoteWebInspectorProxy.h 2020-09-22 16:14:08 UTC (rev 267411)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2016-2020 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -123,7 +123,7 @@
void setSheetRect(const WebCore::FloatRect&);
void setForcedAppearance(WebCore::InspectorFrontendClient::Appearance);
void startWindowDrag();
- void openInNewTab(const String& url);
+ void openURLExternally(const String& url);
void showCertificate(const WebCore::CertificateInfo&);
void sendMessageToBackend(const String& message);
@@ -140,7 +140,7 @@
void platformSetSheetRect(const WebCore::FloatRect&);
void platformSetForcedAppearance(WebCore::InspectorFrontendClient::Appearance);
void platformStartWindowDrag();
- void platformOpenInNewTab(const String& url);
+ void platformOpenURLExternally(const String& url);
void platformShowCertificate(const WebCore::CertificateInfo&);
RemoteWebInspectorProxyClient* m_client { nullptr };
Modified: trunk/Source/WebKit/UIProcess/Inspector/RemoteWebInspectorProxy.messages.in (267410 => 267411)
--- trunk/Source/WebKit/UIProcess/Inspector/RemoteWebInspectorProxy.messages.in 2020-09-22 16:00:50 UTC (rev 267410)
+++ trunk/Source/WebKit/UIProcess/Inspector/RemoteWebInspectorProxy.messages.in 2020-09-22 16:14:08 UTC (rev 267411)
@@ -1,4 +1,4 @@
-# Copyright (C) 2016 Apple Inc. All rights reserved.
+# Copyright (C) 2016-2020 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
@@ -35,7 +35,7 @@
StartWindowDrag()
- OpenInNewTab(String url)
+ OpenURLExternally(String url)
ShowCertificate(WebCore::CertificateInfo certificateInfo)
SendMessageToBackend(String message)
Modified: trunk/Source/WebKit/UIProcess/Inspector/WebInspectorProxy.cpp (267410 => 267411)
--- trunk/Source/WebKit/UIProcess/Inspector/WebInspectorProxy.cpp 2020-09-22 16:00:50 UTC (rev 267410)
+++ trunk/Source/WebKit/UIProcess/Inspector/WebInspectorProxy.cpp 2020-09-22 16:14:08 UTC (rev 267411)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2010-2020 Apple Inc. All rights reserved.
* Portions Copyright (c) 2011 Motorola Mobility, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -605,6 +605,11 @@
platformSetForcedAppearance(appearance);
}
+void WebInspectorProxy::openURLExternally(const String& url)
+{
+ m_inspectorClient->openURLExternally(*this, url);
+}
+
void WebInspectorProxy::inspectedURLChanged(const String& urlString)
{
platformInspectedURLChanged(urlString);
@@ -711,6 +716,14 @@
return inspectorPagePreferences().inspectorStartsAttached() && canAttach();
}
+void WebInspectorProxy::evaluateInFrontendForTesting(const String& _expression_)
+{
+ if (!m_inspectorPage)
+ return;
+
+ m_inspectorPage->send(Messages::WebInspectorUI::EvaluateInFrontendForTesting(_expression_));
+}
+
// Unsupported configurations can use the stubs provided here.
#if !PLATFORM(MAC) && !PLATFORM(GTK) && !PLATFORM(WIN)
Modified: trunk/Source/WebKit/UIProcess/Inspector/WebInspectorProxy.h (267410 => 267411)
--- trunk/Source/WebKit/UIProcess/Inspector/WebInspectorProxy.h 2020-09-22 16:00:50 UTC (rev 267410)
+++ trunk/Source/WebKit/UIProcess/Inspector/WebInspectorProxy.h 2020-09-22 16:14:08 UTC (rev 267411)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010, 2014, 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2010-2020 Apple Inc. All rights reserved.
* Portions Copyright (c) 2011 Motorola Mobility, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -128,7 +128,7 @@
void inspectedViewFrameDidChange(CGFloat = 0);
void windowFrameDidChange();
void windowFullScreenDidChange();
- NSWindow* inspectorWindow() const { return m_inspectorWindow.get(); }
+ NSWindow *inspectorWindow() const { return m_inspectorWindow.get(); }
void closeFrontendPage();
void closeFrontendAfterInactivityTimerFired();
@@ -148,6 +148,7 @@
void showConsole();
void showResources();
void showMainResourceForFrame(WebFrameProxy*);
+ void openURLExternally(const String& url);
AttachmentSide attachmentSide() const { return m_attachmentSide; }
bool isAttached() const { return m_isAttached; }
@@ -191,6 +192,9 @@
static const unsigned initialWindowWidth;
static const unsigned initialWindowHeight;
+ // Testing methods.
+ void evaluateInFrontendForTesting(const String&);
+
private:
void createFrontendPage();
void closeFrontendPageAndWindow();
@@ -215,6 +219,7 @@
bool platformIsFront();
void platformAttachAvailabilityChanged(bool);
void platformSetForcedAppearance(WebCore::InspectorFrontendClient::Appearance);
+ void platformOpenURLExternally(const String&);
void platformInspectedURLChanged(const String&);
void platformShowCertificate(const WebCore::CertificateInfo&);
unsigned platformInspectedWindowHeight();
Modified: trunk/Source/WebKit/UIProcess/Inspector/WebInspectorProxy.messages.in (267410 => 267411)
--- trunk/Source/WebKit/UIProcess/Inspector/WebInspectorProxy.messages.in 2020-09-22 16:00:50 UTC (rev 267410)
+++ trunk/Source/WebKit/UIProcess/Inspector/WebInspectorProxy.messages.in 2020-09-22 16:14:08 UTC (rev 267411)
@@ -1,4 +1,4 @@
-# Copyright (C) 2010, 2014 Apple Inc. All rights reserved.
+# Copyright (C) 2010-2020 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
@@ -34,6 +34,7 @@
ResetState()
SetForcedAppearance(WebCore::InspectorFrontendClient::Appearance appearance)
+ OpenURLExternally(String url)
InspectedURLChanged(String urlString)
ShowCertificate(WebCore::CertificateInfo certificateInfo)
Modified: trunk/Source/WebKit/UIProcess/Inspector/gtk/RemoteWebInspectorProxyGtk.cpp (267410 => 267411)
--- trunk/Source/WebKit/UIProcess/Inspector/gtk/RemoteWebInspectorProxyGtk.cpp 2020-09-22 16:00:50 UTC (rev 267410)
+++ trunk/Source/WebKit/UIProcess/Inspector/gtk/RemoteWebInspectorProxyGtk.cpp 2020-09-22 16:14:08 UTC (rev 267411)
@@ -172,7 +172,7 @@
{
}
-void RemoteWebInspectorProxy::platformOpenInNewTab(const String&)
+void RemoteWebInspectorProxy::platformOpenURLExternally(const String&)
{
}
Modified: trunk/Source/WebKit/UIProcess/Inspector/mac/RemoteWebInspectorProxyMac.mm (267410 => 267411)
--- trunk/Source/WebKit/UIProcess/Inspector/mac/RemoteWebInspectorProxyMac.mm 2020-09-22 16:00:50 UTC (rev 267410)
+++ trunk/Source/WebKit/UIProcess/Inspector/mac/RemoteWebInspectorProxyMac.mm 2020-09-22 16:14:08 UTC (rev 267411)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010-2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2010-2020 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -261,7 +261,7 @@
webView()->_page->startWindowDrag();
}
-void RemoteWebInspectorProxy::platformOpenInNewTab(const String& url)
+void RemoteWebInspectorProxy::platformOpenURLExternally(const String& url)
{
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:url]];
}
Modified: trunk/Source/WebKit/UIProcess/Inspector/mac/WKInspectorViewController.h (267410 => 267411)
--- trunk/Source/WebKit/UIProcess/Inspector/mac/WKInspectorViewController.h 2020-09-22 16:00:50 UTC (rev 267410)
+++ trunk/Source/WebKit/UIProcess/Inspector/mac/WKInspectorViewController.h 2020-09-22 16:14:08 UTC (rev 267411)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2017-2020 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -56,6 +56,7 @@
- (BOOL)inspectorViewControllerInspectorIsUnderTest:(WKInspectorViewController *)inspectorViewController;
- (void)inspectorViewController:(WKInspectorViewController *)inspectorViewController willMoveToWindow:(NSWindow *)newWindow;
- (void)inspectorViewControllerDidMoveToWindow:(WKInspectorViewController *)inspectorViewController;
+- (void)inspectorViewController:(WKInspectorViewController *)inspectorViewController openURLExternally:(NSURL *)url;
@end
NS_ASSUME_NONNULL_END
Modified: trunk/Source/WebKit/UIProcess/Inspector/mac/WKInspectorViewController.mm (267410 => 267411)
--- trunk/Source/WebKit/UIProcess/Inspector/mac/WKInspectorViewController.mm 2020-09-22 16:00:50 UTC (rev 267410)
+++ trunk/Source/WebKit/UIProcess/Inspector/mac/WKInspectorViewController.mm 2020-09-22 16:14:08 UTC (rev 267411)
@@ -227,8 +227,13 @@
// Prevent everything else.
decisionHandler(WKNavigationActionPolicyCancel);
-
- // And instead load it in the inspected page.
+
+ if (!!_delegate && [_delegate respondsToSelector:@selector(inspectorViewController:openURLExternally:)]) {
+ [_delegate inspectorViewController:self openURLExternally:navigationAction.request.URL];
+ return;
+ }
+
+ // Try to load the request in the inspected page if the delegate can't handle it.
if (_inspectedPage)
_inspectedPage->loadRequest(navigationAction.request);
}
Modified: trunk/Source/WebKit/UIProcess/Inspector/mac/WebInspectorProxyMac.mm (267410 => 267411)
--- trunk/Source/WebKit/UIProcess/Inspector/mac/WebInspectorProxyMac.mm 2020-09-22 16:00:50 UTC (rev 267410)
+++ trunk/Source/WebKit/UIProcess/Inspector/mac/WebInspectorProxyMac.mm 2020-09-22 16:14:08 UTC (rev 267411)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010-2019 Apple Inc. All rights reserved.
+ * Copyright (C) 2010-2020 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -193,6 +193,12 @@
_inspectorProxy->attachmentDidMoveToWindow(inspectorViewController.webView.window);
}
+- (void)inspectorViewController:(WKInspectorViewController *)inspectorViewController openURLExternally:(NSURL *)url
+{
+ if (_inspectorProxy)
+ _inspectorProxy->openURLExternally(url.absoluteString);
+}
+
@end
namespace WebKit {
Modified: trunk/Source/WebKit/UIProcess/Inspector/win/RemoteWebInspectorProxyWin.cpp (267410 => 267411)
--- trunk/Source/WebKit/UIProcess/Inspector/win/RemoteWebInspectorProxyWin.cpp 2020-09-22 16:00:50 UTC (rev 267410)
+++ trunk/Source/WebKit/UIProcess/Inspector/win/RemoteWebInspectorProxyWin.cpp 2020-09-22 16:14:08 UTC (rev 267411)
@@ -137,7 +137,7 @@
void RemoteWebInspectorProxy::platformSetSheetRect(const WebCore::FloatRect&) { }
void RemoteWebInspectorProxy::platformSetForcedAppearance(WebCore::InspectorFrontendClient::Appearance) { }
void RemoteWebInspectorProxy::platformStartWindowDrag() { }
-void RemoteWebInspectorProxy::platformOpenInNewTab(const String&) { }
+void RemoteWebInspectorProxy::platformOpenURLExternally(const String&) { }
void RemoteWebInspectorProxy::platformShowCertificate(const WebCore::CertificateInfo&) { }
void RemoteWebInspectorProxy::platformCloseFrontendPageAndWindow()
Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (267410 => 267411)
--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2020-09-22 16:00:50 UTC (rev 267410)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2020-09-22 16:14:08 UTC (rev 267411)
@@ -1406,6 +1406,7 @@
9955A6F71C7986E500EB6A93 /* AutomationProtocolObjects.h in Headers */ = {isa = PBXBuildFile; fileRef = 9955A6F31C79866400EB6A93 /* AutomationProtocolObjects.h */; };
99788ACB1F421DDA00C08000 /* _WKAutomationSessionConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = 99788AC91F421DCA00C08000 /* _WKAutomationSessionConfiguration.h */; settings = {ATTRIBUTES = (Private, ); }; };
9979CA58237F49F10039EC05 /* _WKInspectorPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 9979CA57237F49F00039EC05 /* _WKInspectorPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 99996A9F25004BCC004F7559 /* _WKInspectorPrivateForTesting.h in Headers */ = {isa = PBXBuildFile; fileRef = 99996A9D25004BCB004F7559 /* _WKInspectorPrivateForTesting.h */; settings = {ATTRIBUTES = (Private, ); }; };
99C3AE2D1DADA6AD00AF5C16 /* WebAutomationSessionMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = 99C3AE2C1DADA6A700AF5C16 /* WebAutomationSessionMacros.h */; };
99C81D5A1C20E7E2005C4C82 /* AutomationClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 99C81D551C20DFBE005C4C82 /* AutomationClient.h */; };
99C81D5D1C21F38B005C4C82 /* APIAutomationClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 99C81D5B1C20E817005C4C82 /* APIAutomationClient.h */; };
@@ -4478,6 +4479,8 @@
99788AC91F421DCA00C08000 /* _WKAutomationSessionConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKAutomationSessionConfiguration.h; sourceTree = "<group>"; };
99788ACA1F421DCA00C08000 /* _WKAutomationSessionConfiguration.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = _WKAutomationSessionConfiguration.mm; sourceTree = "<group>"; };
9979CA57237F49F00039EC05 /* _WKInspectorPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKInspectorPrivate.h; sourceTree = "<group>"; };
+ 99996A9D25004BCB004F7559 /* _WKInspectorPrivateForTesting.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKInspectorPrivateForTesting.h; sourceTree = "<group>"; };
+ 99996A9E25004BCB004F7559 /* _WKInspectorTesting.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = _WKInspectorTesting.mm; sourceTree = "<group>"; };
99C3AE231DAD8E3400AF5C16 /* WebAutomationSessionMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebAutomationSessionMac.mm; sourceTree = "<group>"; };
99C3AE261DAD948500AF5C16 /* WebAutomationSessionCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebAutomationSessionCocoa.mm; sourceTree = "<group>"; };
99C3AE2C1DADA6A700AF5C16 /* WebAutomationSessionMacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebAutomationSessionMacros.h; sourceTree = "<group>"; };
@@ -7253,6 +7256,8 @@
9197940B23DBC50300257892 /* _WKInspectorDelegate.h */,
5CAFDE442130843600B1F7E1 /* _WKInspectorInternal.h */,
9979CA57237F49F00039EC05 /* _WKInspectorPrivate.h */,
+ 99996A9D25004BCB004F7559 /* _WKInspectorPrivateForTesting.h */,
+ 99996A9E25004BCB004F7559 /* _WKInspectorTesting.mm */,
A5C0F0AA2000656E00536536 /* _WKInspectorWindow.h */,
A5C0F0A92000656E00536536 /* _WKInspectorWindow.mm */,
31B362942141EBAD007BFA53 /* _WKInternalDebugFeature.h */,
@@ -10618,6 +10623,7 @@
9197940C23DBC50300257892 /* _WKInspectorDelegate.h in Headers */,
5CAFDE472130846A00B1F7E1 /* _WKInspectorInternal.h in Headers */,
9979CA58237F49F10039EC05 /* _WKInspectorPrivate.h in Headers */,
+ 99996A9F25004BCC004F7559 /* _WKInspectorPrivateForTesting.h in Headers */,
A5C0F0AB2000658200536536 /* _WKInspectorWindow.h in Headers */,
31B362952141EBCD007BFA53 /* _WKInternalDebugFeature.h in Headers */,
31B362972141EBD9007BFA53 /* _WKInternalDebugFeatureInternal.h in Headers */,
Modified: trunk/Source/WebKit/WebProcess/Inspector/RemoteWebInspectorUI.cpp (267410 => 267411)
--- trunk/Source/WebKit/WebProcess/Inspector/RemoteWebInspectorUI.cpp 2020-09-22 16:00:50 UTC (rev 267410)
+++ trunk/Source/WebKit/WebProcess/Inspector/RemoteWebInspectorUI.cpp 2020-09-22 16:14:08 UTC (rev 267411)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2016-2020 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -179,9 +179,9 @@
WebProcess::singleton().parentProcessConnection()->send(Messages::RemoteWebInspectorProxy::ResetState(), m_page.identifier());
}
-void RemoteWebInspectorUI::openInNewTab(const String& url)
+void RemoteWebInspectorUI::openURLExternally(const String& url)
{
- WebProcess::singleton().parentProcessConnection()->send(Messages::RemoteWebInspectorProxy::OpenInNewTab(url), m_page.identifier());
+ WebProcess::singleton().parentProcessConnection()->send(Messages::RemoteWebInspectorProxy::OpenURLExternally(url), m_page.identifier());
}
void RemoteWebInspectorUI::save(const String& filename, const String& content, bool base64Encoded, bool forceSaveAs)
Modified: trunk/Source/WebKit/WebProcess/Inspector/RemoteWebInspectorUI.h (267410 => 267411)
--- trunk/Source/WebKit/WebProcess/Inspector/RemoteWebInspectorUI.h 2020-09-22 16:00:50 UTC (rev 267410)
+++ trunk/Source/WebKit/WebProcess/Inspector/RemoteWebInspectorUI.h 2020-09-22 16:14:08 UTC (rev 267411)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2016-2020 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -86,7 +86,7 @@
void reopen() override;
void resetState() override;
- void openInNewTab(const String& url) override;
+ void openURLExternally(const String& url) override;
void save(const String& url, const String& content, bool base64Encoded, bool forceSaveAs) override;
void append(const String& url, const String& content) override;
void inspectedURLChanged(const String&) override;
Modified: trunk/Source/WebKit/WebProcess/Inspector/WebInspector.cpp (267410 => 267411)
--- trunk/Source/WebKit/WebProcess/Inspector/WebInspector.cpp 2020-09-22 16:00:50 UTC (rev 267410)
+++ trunk/Source/WebKit/WebProcess/Inspector/WebInspector.cpp 2020-09-22 16:14:08 UTC (rev 267411)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010, 2014-2018 Apple Inc. All rights reserved.
+ * Copyright (C) 2010-2020 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -158,25 +158,6 @@
closeFrontendConnection();
}
-void WebInspector::openInNewTab(const String& urlString)
-{
- UserGestureIndicator indicator { ProcessingUserGesture };
-
- Page* inspectedPage = m_page->corePage();
- if (!inspectedPage)
- return;
-
- Frame& inspectedMainFrame = inspectedPage->mainFrame();
- FrameLoadRequest frameLoadRequest { *inspectedMainFrame.document(), inspectedMainFrame.document()->securityOrigin(), ResourceRequest { urlString }, "_blank"_s, InitiatedByMainFrame::Unknown };
-
- NavigationAction action { *inspectedMainFrame.document(), frameLoadRequest.resourceRequest(), frameLoadRequest.initiatedByMainFrame(), NavigationType::LinkClicked };
- Page* newPage = inspectedPage->chrome().createWindow(inspectedMainFrame, { }, action);
- if (!newPage)
- return;
-
- newPage->mainFrame().loader().load(WTFMove(frameLoadRequest));
-}
-
void WebInspector::evaluateScriptForTest(const String& script)
{
if (!m_page->corePage())
Modified: trunk/Source/WebKit/WebProcess/Inspector/WebInspector.h (267410 => 267411)
--- trunk/Source/WebKit/WebProcess/Inspector/WebInspector.h 2020-09-22 16:00:50 UTC (rev 267410)
+++ trunk/Source/WebKit/WebProcess/Inspector/WebInspector.h 2020-09-22 16:14:08 UTC (rev 267411)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010, 2014, 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2010-2020 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -55,8 +55,6 @@
void show();
void close();
- void openInNewTab(const String& urlString);
-
void canAttachWindow(bool& result);
void showConsole();
Modified: trunk/Source/WebKit/WebProcess/Inspector/WebInspector.messages.in (267410 => 267411)
--- trunk/Source/WebKit/WebProcess/Inspector/WebInspector.messages.in 2020-09-22 16:00:50 UTC (rev 267410)
+++ trunk/Source/WebKit/WebProcess/Inspector/WebInspector.messages.in 2020-09-22 16:14:08 UTC (rev 267411)
@@ -1,4 +1,4 @@
-# Copyright (C) 2010, 2014 Apple Inc. All rights reserved.
+# Copyright (C) 2010-2020 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
@@ -31,8 +31,6 @@
ShowMainResourceForFrame(WebCore::FrameIdentifier frameIdentifier)
- OpenInNewTab(String url)
-
StartPageProfiling()
StopPageProfiling()
Modified: trunk/Source/WebKit/WebProcess/Inspector/WebInspectorFrontendAPIDispatcher.cpp (267410 => 267411)
--- trunk/Source/WebKit/WebProcess/Inspector/WebInspectorFrontendAPIDispatcher.cpp 2020-09-22 16:00:50 UTC (rev 267410)
+++ trunk/Source/WebKit/WebProcess/Inspector/WebInspectorFrontendAPIDispatcher.cpp 2020-09-22 16:14:08 UTC (rev 267411)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014, 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2014-2020 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -115,4 +115,9 @@
m_queue.clear();
}
+void WebInspectorFrontendAPIDispatcher::evaluateExpressionForTesting(const String& _expression_)
+{
+ evaluateOrQueueExpression(_expression_);
+}
+
} // namespace WebKit
Modified: trunk/Source/WebKit/WebProcess/Inspector/WebInspectorFrontendAPIDispatcher.h (267410 => 267411)
--- trunk/Source/WebKit/WebProcess/Inspector/WebInspectorFrontendAPIDispatcher.h 2020-09-22 16:00:50 UTC (rev 267410)
+++ trunk/Source/WebKit/WebProcess/Inspector/WebInspectorFrontendAPIDispatcher.h 2020-09-22 16:14:08 UTC (rev 267411)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014, 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2014-2020 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -47,6 +47,7 @@
void dispatchCommand(const String& command, bool argument);
void dispatchMessageAsync(const String& message);
+ void evaluateExpressionForTesting(const String&);
private:
void evaluateOrQueueExpression(const String&);
void evaluateQueuedExpressions();
Modified: trunk/Source/WebKit/WebProcess/Inspector/WebInspectorUI.cpp (267410 => 267411)
--- trunk/Source/WebKit/WebProcess/Inspector/WebInspectorUI.cpp 2020-09-22 16:00:50 UTC (rev 267410)
+++ trunk/Source/WebKit/WebProcess/Inspector/WebInspectorUI.cpp 2020-09-22 16:14:08 UTC (rev 267411)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014-2018 Apple Inc. All rights reserved.
+ * Copyright (C) 2014-2020 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -82,11 +82,6 @@
void WebInspectorUI::updateConnection()
{
- if (m_backendConnection) {
- m_backendConnection->invalidate();
- m_backendConnection = nullptr;
- }
-
#if USE(UNIX_DOMAIN_SOCKETS)
IPC::Connection::SocketPair socketPair = IPC::Connection::createPlatformConnection();
IPC::Connection::Identifier connectionIdentifier(socketPair.server);
@@ -110,11 +105,6 @@
return;
#endif
-#if USE(UNIX_DOMAIN_SOCKETS) || OS(DARWIN) || PLATFORM(WIN)
- m_backendConnection = IPC::Connection::createServerConnection(connectionIdentifier, *this);
- m_backendConnection->open();
-#endif
-
WebProcess::singleton().parentProcessConnection()->send(Messages::WebInspectorProxy::SetFrontendConnection(connectionClientPort), m_inspectedPageIdentifier);
}
@@ -163,11 +153,6 @@
{
WebProcess::singleton().parentProcessConnection()->send(Messages::WebInspectorProxy::DidClose(), m_inspectedPageIdentifier);
- if (m_backendConnection) {
- m_backendConnection->invalidate();
- m_backendConnection = nullptr;
- }
-
if (m_frontendController) {
m_frontendController->setInspectorFrontendClient(nullptr);
m_frontendController = nullptr;
@@ -296,12 +281,9 @@
WebProcess::singleton().parentProcessConnection()->send(Messages::WebInspectorProxy::SetSheetRect(rect), m_inspectedPageIdentifier);
}
-void WebInspectorUI::openInNewTab(const String& url)
+void WebInspectorUI::openURLExternally(const String& url)
{
- if (m_backendConnection) {
- m_backendConnection->send(Messages::WebInspector::OpenInNewTab(url), 0);
- WebProcess::singleton().parentProcessConnection()->send(Messages::WebInspectorProxy::BringInspectedPageToFront(), m_inspectedPageIdentifier);
- }
+ WebProcess::singleton().parentProcessConnection()->send(Messages::WebInspectorProxy::OpenURLExternally(url), m_inspectedPageIdentifier);
}
void WebInspectorUI::save(const WTF::String& filename, const WTF::String& content, bool base64Encoded, bool forceSaveAs)
@@ -395,6 +377,11 @@
m_frontendAPIDispatcher.dispatchMessageAsync(message);
}
+void WebInspectorUI::evaluateInFrontendForTesting(const String& _expression_)
+{
+ m_frontendAPIDispatcher.evaluateExpressionForTesting(_expression_);
+}
+
void WebInspectorUI::pagePaused()
{
m_frontendAPIDispatcher.suspend();
Modified: trunk/Source/WebKit/WebProcess/Inspector/WebInspectorUI.h (267410 => 267411)
--- trunk/Source/WebKit/WebProcess/Inspector/WebInspectorUI.h 2020-09-22 16:00:50 UTC (rev 267410)
+++ trunk/Source/WebKit/WebProcess/Inspector/WebInspectorUI.h 2020-09-22 16:14:08 UTC (rev 267411)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014-2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2014-2020 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -86,10 +86,11 @@
void didSave(const String& url);
void didAppend(const String& url);
- void sendMessageToFrontend(const String&);
+ void sendMessageToFrontend(const String& message);
+ void evaluateInFrontendForTesting(const String& _expression_);
#if ENABLE(INSPECTOR_TELEMETRY)
- void setDiagnosticLoggingAvailable(bool avaliable);
+ void setDiagnosticLoggingAvailable(bool);
#endif
// WebCore::InspectorFrontendClient
@@ -125,7 +126,7 @@
void changeSheetRect(const WebCore::FloatRect&) override;
- void openInNewTab(const String& url) override;
+ void openURLExternally(const String& url) override;
bool canSave() override;
void save(const WTF::String& url, const WTF::String& content, bool base64Encoded, bool forceSaveAs) override;
@@ -153,7 +154,6 @@
WebPage& m_page;
WebInspectorFrontendAPIDispatcher m_frontendAPIDispatcher;
RefPtr<WebCore::InspectorFrontendHost> m_frontendHost;
- RefPtr<IPC::Connection> m_backendConnection;
// Keep a pointer to the frontend's inspector controller rather than going through
// corePage(), since we may need it after the frontend's page has started destruction.
Modified: trunk/Source/WebKit/WebProcess/Inspector/WebInspectorUI.messages.in (267410 => 267411)
--- trunk/Source/WebKit/WebProcess/Inspector/WebInspectorUI.messages.in 2020-09-22 16:00:50 UTC (rev 267410)
+++ trunk/Source/WebKit/WebProcess/Inspector/WebInspectorUI.messages.in 2020-09-22 16:14:08 UTC (rev 267411)
@@ -1,4 +1,4 @@
-# Copyright (C) 2014, 2016 Apple Inc. All rights reserved.
+# Copyright (C) 2014-2020 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
@@ -51,4 +51,5 @@
DidAppend(String url)
SendMessageToFrontend(String message)
+ EvaluateInFrontendForTesting(String _expression_)
}
Modified: trunk/Tools/ChangeLog (267410 => 267411)
--- trunk/Tools/ChangeLog 2020-09-22 16:00:50 UTC (rev 267410)
+++ trunk/Tools/ChangeLog 2020-09-22 16:14:08 UTC (rev 267411)
@@ -1,3 +1,16 @@
+2020-09-22 Brian Burg <[email protected]>
+
+ [Cocoa] _WKInspectorDelegate should handle showing external resources
+ https://bugs.webkit.org/show_bug.cgi?id=216334
+
+ Reviewed by Devin Rousso.
+
+ Test the delegate using WebKit API and using InspectorFrontendHost API.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/WKInspectorDelegate.mm:
+ (-[InspectorDelegate inspector:openURLExternally:]): Added.
+ (TEST):
+
2020-09-22 Truitt Savell <[email protected]>
Unreviewed, reverting r267380.
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKInspectorDelegate.mm (267410 => 267411)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKInspectorDelegate.mm 2020-09-22 16:00:50 UTC (rev 267410)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKInspectorDelegate.mm 2020-09-22 16:14:08 UTC (rev 267411)
@@ -32,6 +32,7 @@
#import <WebKit/WKWebViewPrivateForTesting.h>
#import <WebKit/_WKInspector.h>
#import <WebKit/_WKInspectorDelegate.h>
+#import <WebKit/_WKInspectorPrivateForTesting.h>
#import <wtf/RetainPtr.h>
#if PLATFORM(MAC)
@@ -41,7 +42,9 @@
static bool didAttachLocalInspectorCalled = false;
static bool browserDomainEnabledForInspectorCalled = false;
static bool browserDomainDisabledForInspectorCalled = false;
-static RetainPtr<InspectorDelegate> sharedInspectorDelegate;
+static bool openURLExternallyCalled = false;
+static RetainPtr<id <_WKInspectorDelegate>> sharedInspectorDelegate;
+static RetainPtr<NSURL> urlToOpen;
@interface InspectorDelegate : NSObject <_WKInspectorDelegate>
@end
@@ -62,6 +65,12 @@
browserDomainDisabledForInspectorCalled = true;
}
+- (void)inspector:(_WKInspector *)inspector openURLExternally:(NSURL *)url
+{
+ EXPECT_STREQ(url.absoluteString.UTF8String, urlToOpen.get().absoluteString.UTF8String);
+ openURLExternallyCalled = true;
+}
+
@end
@interface UIDelegate : NSObject <WKUIDelegate>
@@ -85,7 +94,7 @@
@end
-TEST(WebKit_WKInspectorDelegate, DidNotifyForLocalInspector)
+TEST(WKInspectorDelegate, DidNotifyForLocalInspector)
{
auto webViewConfiguration = adoptNS([WKWebViewConfiguration new]);
webViewConfiguration.get().preferences._developerExtrasEnabled = YES;
@@ -104,4 +113,28 @@
TestWebKitAPI::Util::run(&browserDomainDisabledForInspectorCalled);
}
+TEST(WKInspectorDelegate, ShowURLExternally)
+{
+ 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([UIDelegate 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);
+
+ urlToOpen = [NSURL URLWithString:@"https://www.webkit.org/"];
+
+ // Check the case where the load is intercepted by the navigation delegate.
+ [[webView _inspector] _openURLExternallyForTesting:urlToOpen.get() useFrontendAPI:NO];
+ TestWebKitAPI::Util::run(&openURLExternallyCalled);
+
+ // Check the case where the frontend calls InspectorFrontendHost.openURLExternally().
+ [[webView _inspector] _openURLExternallyForTesting:urlToOpen.get() useFrontendAPI:YES];
+ TestWebKitAPI::Util::run(&openURLExternallyCalled);
+}
+
#endif // PLATFORM(MAC)