Web Inspector: add InspectedTargetTypes diagnostic event and related hooks
authorbburg@apple.com <bburg@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 22 Dec 2019 04:19:53 +0000 (04:19 +0000)
committerbburg@apple.com <bburg@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 22 Dec 2019 04:19:53 +0000 (04:19 +0000)
https://bugs.webkit.org/show_bug.cgi?id=205174
<rdar://problem/57887953>

Reviewed by Devin Rousso.

Source/WebCore:

Expose debuggable information via InspectorFrontendHost.

* WebCore.xcodeproj/project.pbxproj: Add new files.

* inspector/InspectorFrontendClient.h: Add new methods.
* testing/Internals.cpp: Implement new methods.

* inspector/InspectorFrontendHost.idl:
* inspector/InspectorFrontendHost.h:
* inspector/InspectorFrontendHost.cpp:
(WebCore::debuggableTypeToString):
(WebCore::InspectorFrontendHost::debuggableInfo const):
(WebCore::InspectorFrontendHost::debuggableType): Deleted.
Expose a `DebuggableInfo` dictionary via the .debuggableInfo getter.

Source/WebInspectorUI:

This change adds a new diagnostic recorder that reports information about
inspected targets and their type / version information.

* UserInterface/Base/DebuggableType.js:
(WI.DebuggableType.fromString):
Move the static parsing factory method to DebuggableType class.

* UserInterface/Main.html: Add new files.
* UserInterface/Base/Main.js:
(WI.contentLoaded): Add new diagnostic recorder.

* UserInterface/Protocol/InspectorBackend.js:
(InspectorBackendClass.prototype.activateDomain):
Adapt to InspectorFrontendHost changes.

* UserInterface/Test/TestAppController.js:
(WI.TestAppController):
* UserInterface/Controllers/AppController.js:
(WI.AppController):
Adapt to InspectorFrontendHost changes.

Source/WebKit:

This change supplies Web Inspector with information about the debuggable that
it is connected to. This is used for diagnostics and to customize the UI based
on the target type being inspected.

For remote Web Inspector, WebKit clients can populate an instance of
_WKInspectorDebuggableInfo and use it when calling into
-[_WKRemoteWebInspectorViewController loadForDebuggable:backendCommandsURL:].

For local Web Inspector, WebInspectorProxy fills in information for the local
debuggable by consulting SystemVersion.plist (on Mac port).

The new enum _WKInspectorDebuggableType replaces _WKRemoteWebInspectorDebuggableType.
Its WebCore equivalent is Inspector::DebuggableType. The type and other information
are carried around in a _WKInspectorDebuggableInfo class. The equivalents for this
class are API::DebuggableInfo and DebuggableInfoData (for sending over IPC).

The DebuggableInfoData is sent as part of the initial message from UIProcess
to an Inspector WebProcess, similar to how a debuggableType string was sent before.

* Sources.txt:
* SourcesCocoa.txt:
* WebKit.xcodeproj/project.pbxproj:
Add new files.

* Shared/API/APIObject.h:
* Shared/Cocoa/APIObject.mm:
(API::Object::newObject): Add new object type.
* Shared/WebCoreArgumentCoders.h: Add EnumTraits for Inspector::DebuggableType.

* UIProcess/API/Cocoa/_WKRemoteWebInspectorViewControllerPrivate.h:
* UIProcess/API/Cocoa/_WKRemoteWebInspectorViewController.mm:
(legacyDebuggableTypeToModernDebuggableType):
(-[_WKRemoteWebInspectorViewController loadForDebuggableType:backendCommandsURL:]):
(-[_WKRemoteWebInspectorViewController loadForDebuggable:backendCommandsURL:]):
(debuggableTypeString): Deleted.
Use the new enum in a new method that clients can switch over to. The old method
can be removed when it is no longer being used.

* UIProcess/RemoteWebInspectorProxy.h:
* UIProcess/RemoteWebInspectorProxy.cpp:
(WebKit::RemoteWebInspectorProxy::RemoteWebInspectorProxy):
(WebKit::RemoteWebInspectorProxy::load):
(WebKit::RemoteWebInspectorProxy::reopen):
Send DebuggableInfoData struct to RemoteWebInspectorUI.

* UIProcess/WebInspectorProxy.h:
* UIProcess/WebInspectorProxy.cpp:
(WebKit::WebInspectorProxy::openLocalInspectorFrontend):
(WebKit::WebInspectorProxy::infoForLocalDebuggable):
Send DebuggableInfoData struct to WebInspectorUI.

* UIProcess/mac/WebInspectorProxyMac.mm:
(WebKit::systemVersionPlist):
(WebKit::WebInspectorProxy::infoForLocalDebuggable):
Add Mac implementation for local debuggables.

* UIProcess/gtk/WebInspectorProxyGtk.cpp:
(WebKit::WebInspectorProxy::infoForLocalDebuggable):
* UIProcess/win/WebInspectorProxyWin.cpp:
(WebKit::WebInspectorProxy::infoForLocalDebuggable):
* UIProcess/wpe/WebInspectorProxyWPE.cpp:
(WebKit::WebInspectorProxy::infoForLocalDebuggable):
Add stubs for other platforms.

* UIProcess/glib/RemoteInspectorClient.cpp:
* UIProcess/socket/RemoteInspectorClient.h:
* UIProcess/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::inspect):
(WebKit::debuggableTypeToString):
(WebKit::RemoteInspectorClient::setTargetList):
Use Inspector::DebuggableType instead of String for debuggable type.

* WebProcess/WebPage/RemoteWebInspectorUI.messages.in:
* WebProcess/WebPage/RemoteWebInspectorUI.h:
* WebProcess/WebPage/RemoteWebInspectorUI.cpp:
(WebKit::RemoteWebInspectorUI::initialize):
(WebKit::RemoteWebInspectorUI::debuggableType const):
(WebKit::RemoteWebInspectorUI::targetPlatformName const):
(WebKit::RemoteWebInspectorUI::targetBuildVersion const):
(WebKit::RemoteWebInspectorUI::targetProductVersion const):
(WebKit::RemoteWebInspectorUI::targetIsSimulator const):
Implement new methods needed by InspectorFrontendClient / InspectorFrontendHost.

* WebProcess/WebPage/WebInspectorUI.messages.in:
* WebProcess/WebPage/WebInspectorUI.h:
* WebProcess/WebPage/WebInspectorUI.cpp:
(WebKit::WebInspectorUI::establishConnection):
(WebKit::WebInspectorUI::targetPlatformName const):
(WebKit::WebInspectorUI::targetBuildVersion const):
(WebKit::WebInspectorUI::targetProductVersion const):
Implement new methods needed by InspectorFrontendClient / InspectorFrontendHost.

Source/WebKitLegacy/win:

* WebCoreSupport/WebInspectorClient.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@253868 268f45cc-cd09-0410-ab3c-d52691b4dbfc

53 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Headers.cmake
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/inspector/InspectorDebuggableType.h [new file with mode: 0644]
Source/WebCore/inspector/InspectorFrontendClient.h
Source/WebCore/inspector/InspectorFrontendHost.cpp
Source/WebCore/inspector/InspectorFrontendHost.h
Source/WebCore/inspector/InspectorFrontendHost.idl
Source/WebCore/testing/Internals.cpp
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Base/DebuggableType.js
Source/WebInspectorUI/UserInterface/Base/Main.js
Source/WebInspectorUI/UserInterface/Controllers/AppController.js
Source/WebInspectorUI/UserInterface/Controllers/InspectedTargetTypesDiagnosticEventRecorder.js [new file with mode: 0644]
Source/WebInspectorUI/UserInterface/Main.html
Source/WebInspectorUI/UserInterface/Protocol/InspectorBackend.js
Source/WebInspectorUI/UserInterface/Test/TestAppController.js
Source/WebKit/ChangeLog
Source/WebKit/Shared/API/APIObject.h
Source/WebKit/Shared/Cocoa/APIObject.mm
Source/WebKit/Shared/DebuggableInfoData.cpp [new file with mode: 0644]
Source/WebKit/Shared/DebuggableInfoData.h [new file with mode: 0644]
Source/WebKit/Sources.txt
Source/WebKit/SourcesCocoa.txt
Source/WebKit/UIProcess/API/APIDebuggableInfo.cpp [new file with mode: 0644]
Source/WebKit/UIProcess/API/APIDebuggableInfo.h [new file with mode: 0644]
Source/WebKit/UIProcess/API/Cocoa/_WKInspectorDebuggableInfo.h [new file with mode: 0644]
Source/WebKit/UIProcess/API/Cocoa/_WKInspectorDebuggableInfo.mm [new file with mode: 0644]
Source/WebKit/UIProcess/API/Cocoa/_WKInspectorDebuggableInfoInternal.h [new file with mode: 0644]
Source/WebKit/UIProcess/API/Cocoa/_WKRemoteWebInspectorViewController.mm
Source/WebKit/UIProcess/API/Cocoa/_WKRemoteWebInspectorViewControllerPrivate.h
Source/WebKit/UIProcess/RemoteWebInspectorProxy.cpp
Source/WebKit/UIProcess/RemoteWebInspectorProxy.h
Source/WebKit/UIProcess/WebInspectorProxy.cpp
Source/WebKit/UIProcess/WebInspectorProxy.h
Source/WebKit/UIProcess/glib/RemoteInspectorClient.cpp
Source/WebKit/UIProcess/gtk/WebInspectorProxyGtk.cpp
Source/WebKit/UIProcess/mac/WebInspectorProxyMac.mm
Source/WebKit/UIProcess/socket/RemoteInspectorClient.cpp
Source/WebKit/UIProcess/socket/RemoteInspectorClient.h
Source/WebKit/UIProcess/socket/RemoteInspectorProtocolHandler.cpp
Source/WebKit/UIProcess/win/WebInspectorProxyWin.cpp
Source/WebKit/UIProcess/wpe/WebInspectorProxyWPE.cpp
Source/WebKit/WebKit.xcodeproj/project.pbxproj
Source/WebKit/WebProcess/WebPage/RemoteWebInspectorUI.cpp
Source/WebKit/WebProcess/WebPage/RemoteWebInspectorUI.h
Source/WebKit/WebProcess/WebPage/RemoteWebInspectorUI.messages.in
Source/WebKit/WebProcess/WebPage/WebInspectorUI.cpp
Source/WebKit/WebProcess/WebPage/WebInspectorUI.h
Source/WebKit/WebProcess/WebPage/WebInspectorUI.messages.in
Source/WebKitLegacy/mac/WebCoreSupport/WebInspectorClient.h
Source/WebKitLegacy/win/ChangeLog
Source/WebKitLegacy/win/WebCoreSupport/WebInspectorClient.h

index a27c3d7..4f68840 100644 (file)
@@ -1,3 +1,27 @@
+2019-12-21  Brian Burg  <bburg@apple.com>
+
+        Web Inspector: add InspectedTargetTypes diagnostic event and related hooks
+        https://bugs.webkit.org/show_bug.cgi?id=205174
+        <rdar://problem/57887953>
+
+        Reviewed by Devin Rousso.
+
+        Expose debuggable information via InspectorFrontendHost.
+
+        * WebCore.xcodeproj/project.pbxproj: Add new files.
+
+        * inspector/InspectorFrontendClient.h: Add new methods.
+        * testing/Internals.cpp: Implement new methods.
+
+        * inspector/InspectorFrontendHost.idl:
+        * inspector/InspectorFrontendHost.h:
+        * inspector/InspectorFrontendHost.cpp:
+        (WebCore::debuggableTypeToString):
+        (WebCore::InspectorFrontendHost::debuggableInfo const):
+        (WebCore::InspectorFrontendHost::debuggableType): Deleted.
+        Expose a `DebuggableInfo` dictionary via the .debuggableInfo getter.
+
+
 2019-12-21  Antti Koivisto  <antti@apple.com>
 
         Move Vector HashTraits to HashTraits.h to fix GCC build
index 2d7c2ce..8c7e5c5 100644 (file)
@@ -658,6 +658,7 @@ set(WebCore_PRIVATE_FRAMEWORK_HEADERS
 
     inspector/InspectorClient.h
     inspector/InspectorController.h
+    inspector/InspectorDebuggableType.h
     inspector/InspectorFrontendClient.h
     inspector/InspectorFrontendClientLocal.h
     inspector/InspectorFrontendHost.h
index 7767ed6..5c062f7 100644 (file)
                98EB1F951313FE0500D0E1EA /* NotImplemented.h in Headers */ = {isa = PBXBuildFile; fileRef = 98EB1F941313FE0500D0E1EA /* NotImplemented.h */; settings = {ATTRIBUTES = (Private, ); }; };
                9920398318B95BC600B39AF9 /* UserInputBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 9920398118B95BC600B39AF9 /* UserInputBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };
                996E59DF1DF0128D006612B9 /* NavigatorWebDriver.h in Headers */ = {isa = PBXBuildFile; fileRef = 996E59DC1DF00D90006612B9 /* NavigatorWebDriver.h */; };
+               99D1B2D323AC143100811CF0 /* InspectorDebuggableType.h in Headers */ = {isa = PBXBuildFile; fileRef = 99D1B2D123AC143000811CF0 /* InspectorDebuggableType.h */; settings = {ATTRIBUTES = (Private, ); }; };
                9A528E8417D7F52F00AA9518 /* FloatingObjects.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A528E8217D7F52F00AA9518 /* FloatingObjects.h */; settings = {ATTRIBUTES = (Private, ); }; };
                9AB1F38018E2489A00534743 /* CSSToLengthConversionData.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AB1F37E18E2489A00534743 /* CSSToLengthConversionData.h */; settings = {ATTRIBUTES = (Private, ); }; };
                9B02E0C8235EAD2A004044B2 /* TextManipulationController.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B02E0C3235E76AA004044B2 /* TextManipulationController.h */; settings = {ATTRIBUTES = (Private, ); }; };
                996E59DB1DF00D90006612B9 /* NavigatorWebDriver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NavigatorWebDriver.cpp; sourceTree = "<group>"; };
                996E59DC1DF00D90006612B9 /* NavigatorWebDriver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NavigatorWebDriver.h; sourceTree = "<group>"; };
                996E59DD1DF00D90006612B9 /* NavigatorWebDriver.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = NavigatorWebDriver.idl; sourceTree = "<group>"; };
+               99D1B2D123AC143000811CF0 /* InspectorDebuggableType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorDebuggableType.h; sourceTree = "<group>"; };
                9A528E8117D7F52F00AA9518 /* FloatingObjects.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FloatingObjects.cpp; sourceTree = "<group>"; };
                9A528E8217D7F52F00AA9518 /* FloatingObjects.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FloatingObjects.h; sourceTree = "<group>"; };
                9AB1F37E18E2489A00534743 /* CSSToLengthConversionData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSToLengthConversionData.h; sourceTree = "<group>"; };
                                1C81B9560E97330800266E07 /* InspectorController.h */,
                                41F062130F5F192600A07EAC /* InspectorDatabaseResource.cpp */,
                                41F062120F5F192600A07EAC /* InspectorDatabaseResource.h */,
+                               99D1B2D123AC143000811CF0 /* InspectorDebuggableType.h */,
                                F344C7121125B82C00F26EEE /* InspectorFrontendClient.h */,
                                F344C75711294FF600F26EEE /* InspectorFrontendClientLocal.cpp */,
                                F344C75211294D9D00F26EEE /* InspectorFrontendClientLocal.h */,
                                4A9CC82116BF9BB400EC645A /* InspectorCSSOMWrappers.h in Headers */,
                                A5B81CAA1FAA44620037D1E6 /* InspectorDatabaseAgent.h in Headers */,
                                41F062140F5F192600A07EAC /* InspectorDatabaseResource.h in Headers */,
+                               99D1B2D323AC143100811CF0 /* InspectorDebuggableType.h in Headers */,
                                A5B81CAB1FAA44620037D1E6 /* InspectorDOMAgent.h in Headers */,
                                A5B81CAC1FAA44620037D1E6 /* InspectorDOMDebuggerAgent.h in Headers */,
                                A5B81CAD1FAA44620037D1E6 /* InspectorDOMStorageAgent.h in Headers */,
diff --git a/Source/WebCore/inspector/InspectorDebuggableType.h b/Source/WebCore/inspector/InspectorDebuggableType.h
new file mode 100644 (file)
index 0000000..5ad5a21
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2019 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.
+ */
+
+#pragma once
+
+namespace Inspector {
+
+enum class DebuggableType : uint8_t {
+    JavaScript,    // JSC::JSGlobalObject
+    Page,          // WebCore::Page
+    ServiceWorker, // WebCore::ServiceWorkerThreadProxy
+    WebPage,       // WebKit::WebPageProxy
+};
+
+} // namespace Inspector
+
+namespace WTF {
+
+template<> struct EnumTraits<Inspector::DebuggableType> {
+    using values = EnumValues<
+    Inspector::DebuggableType,
+    Inspector::DebuggableType::JavaScript,
+    Inspector::DebuggableType::Page,
+    Inspector::DebuggableType::ServiceWorker,
+    Inspector::DebuggableType::WebPage
+    >;
+};
+
+} // namespace WTF
index 948a47e..137d0e6 100644 (file)
@@ -32,6 +32,7 @@
 
 #include "CertificateInfo.h"
 #include "DiagnosticLoggingClient.h"
+#include "InspectorDebuggableType.h"
 #include "UserInterfaceLayoutDirection.h"
 #include <wtf/Forward.h>
 #include <wtf/text/WTFString.h>
@@ -57,10 +58,15 @@ public:
     virtual void startWindowDrag() = 0;
     virtual void moveWindowBy(float x, float y) = 0;
 
+    // Information about the debuggable.
     virtual bool isRemote() const = 0;
     virtual String localizedStringsURL() const = 0;
     virtual String backendCommandsURL() const = 0;
-    virtual String debuggableType() const = 0;
+    virtual Inspector::DebuggableType debuggableType() const = 0;
+    virtual String targetPlatformName() const = 0;
+    virtual String targetBuildVersion() const = 0;
+    virtual String targetProductVersion() const = 0;
+    virtual bool targetIsSimulator() const = 0;
     virtual unsigned inspectionLevel() const = 0;
 
     virtual void bringToFront() = 0;
index 79c60dd..4168389 100644 (file)
@@ -44,6 +44,7 @@
 #include "Frame.h"
 #include "HitTestResult.h"
 #include "InspectorController.h"
+#include "InspectorDebuggableType.h"
 #include "InspectorFrontendClient.h"
 #include "JSDOMConvertInterface.h"
 #include "JSDOMExceptionHandling.h"
@@ -284,9 +285,35 @@ String InspectorFrontendHost::backendCommandsURL() const
     return m_client ? m_client->backendCommandsURL() : String();
 }
 
-String InspectorFrontendHost::debuggableType()
+static String debuggableTypeToString(DebuggableType debuggableType)
 {
-    return m_client ? m_client->debuggableType() : String();
+    switch (debuggableType) {
+    case DebuggableType::JavaScript:
+        return "javascript"_s;
+    case DebuggableType::Page:
+        return "page"_s;
+    case DebuggableType::ServiceWorker:
+        return "service-worker"_s;
+    case DebuggableType::WebPage:
+        return "web-page"_s;
+    }
+
+    ASSERT_NOT_REACHED();
+    return String();
+}
+
+InspectorFrontendHost::DebuggableInfo InspectorFrontendHost::debuggableInfo() const
+{
+    if (!m_client)
+        return {debuggableTypeToString(DebuggableType::JavaScript), "Unknown"_s, "Unknown"_s, "Unknown"_s, false};
+
+    return {
+        debuggableTypeToString(m_client->debuggableType()),
+        m_client->targetPlatformName(),
+        m_client->targetBuildVersion(),
+        m_client->targetProductVersion(),
+        m_client->targetIsSimulator(),
+    };
 }
 
 unsigned InspectorFrontendHost::inspectionLevel() const
index 9f6df55..9806984 100644 (file)
@@ -81,7 +81,6 @@ public:
     void moveWindowBy(float x, float y) const;
 
     bool isRemote() const;
-    String debuggableType();
     String localizedStringsURL() const;
     String backendCommandsURL() const;
     unsigned inspectionLevel() const;
@@ -89,6 +88,15 @@ public:
     String platform() const;
     String port() const;
 
+    struct DebuggableInfo {
+        String debuggableType;
+        String targetPlatformName;
+        String targetBuildVersion;
+        String targetProductVersion;
+        bool targetIsSimulator;
+    };
+    DebuggableInfo debuggableInfo() const;
+
     void copyText(const String& text);
     void killText(const String& text, bool shouldPrependToKillRing, bool shouldStartNewSequence);
     void openInNewTab(const String& url);
index dec5338..d6c08ee 100644 (file)
     void moveWindowBy(unrestricted float x, unrestricted float y);
 
     readonly attribute boolean isRemote;
-    DOMString debuggableType();
     readonly attribute DOMString localizedStringsURL;
     readonly attribute DOMString backendCommandsURL;
     readonly attribute unsigned long inspectionLevel;
+    readonly attribute DebuggableInfo debuggableInfo;
 
     void copyText(DOMString text);
     void killText(DOMString text, boolean shouldPrependToKillRing, boolean shouldStartNewSequence);
@@ -103,3 +103,14 @@ dictionary ContextMenuItem {
     boolean checked;
     sequence<ContextMenuItem> subItems;
 };
+
+[
+    JSGenerateToJSObject,
+]
+dictionary DebuggableInfo {
+    DOMString debuggableType;
+    DOMString targetPlatformName;
+    DOMString targetBuildVersion;
+    DOMString targetProductVersion;
+    boolean targetIsSimulator;
+};
index d950870..e5d5139 100644 (file)
 #include "HitTestResult.h"
 #include "InspectorClient.h"
 #include "InspectorController.h"
+#include "InspectorDebuggableType.h"
 #include "InspectorFrontendClientLocal.h"
 #include "InspectorOverlay.h"
 #include "InstrumentingAgents.h"
@@ -338,8 +339,12 @@ private:
     void closeWindow() final;
     void reopen() final { }
     void bringToFront() final { }
-    String debuggableType() const final { return "page"_s; };
     String localizedStringsURL() const final { return String(); }
+    DebuggableType debuggableType() const final { return DebuggableType::Page; }
+    String targetPlatformName() const { return "Unknown"_s; }
+    String targetBuildVersion() const { return "Unknown"_s; }
+    String targetProductVersion() const { return "Unknown"_s; }
+    bool targetIsSimulator() const { return false; }
     void inspectedURLChanged(const String&) final { }
     void showCertificate(const CertificateInfo&) final { }
     void setAttachedWindowHeight(unsigned) final { }
index 6981d73..a1816bf 100644 (file)
@@ -1,3 +1,32 @@
+2019-12-21  Brian Burg  <bburg@apple.com>
+
+        Web Inspector: add InspectedTargetTypes diagnostic event and related hooks
+        https://bugs.webkit.org/show_bug.cgi?id=205174
+        <rdar://problem/57887953>
+
+        Reviewed by Devin Rousso.
+
+        This change adds a new diagnostic recorder that reports information about
+        inspected targets and their type / version information.
+
+        * UserInterface/Base/DebuggableType.js:
+        (WI.DebuggableType.fromString):
+        Move the static parsing factory method to DebuggableType class.
+
+        * UserInterface/Main.html: Add new files.
+        * UserInterface/Base/Main.js:
+        (WI.contentLoaded): Add new diagnostic recorder.
+
+        * UserInterface/Protocol/InspectorBackend.js:
+        (InspectorBackendClass.prototype.activateDomain):
+        Adapt to InspectorFrontendHost changes.
+
+        * UserInterface/Test/TestAppController.js:
+        (WI.TestAppController):
+        * UserInterface/Controllers/AppController.js:
+        (WI.AppController):
+        Adapt to InspectorFrontendHost changes.
+
 2019-12-20  Nikita Vasilyev  <nvasilyev@apple.com>
 
         Web Inspector: Gradient editor: opacity slider is too close to the right edge of the popover
index 215f36b..7b31e2b 100644 (file)
@@ -29,3 +29,19 @@ WI.DebuggableType = {
     ServiceWorker: "service-worker",
     WebPage: "web-page",
 };
+
+WI.DebuggableType.fromString = function(type) {
+    switch (type) {
+    case "javascript":
+        return WI.DebuggableType.JavaScript;
+    case "page":
+        return WI.DebuggableType.Page;
+    case "service-worker":
+        return WI.DebuggableType.ServiceWorker;
+    case "web-page":
+        return WI.DebuggableType.WebPage;
+    }
+
+    console.assert(false, "Unknown debuggable type", type);
+    return null;
+};
index 9c492af..ff22801 100644 (file)
@@ -552,6 +552,7 @@ WI.contentLoaded = function()
 
     if (InspectorFrontendHost.supportsDiagnosticLogging) {
         WI.diagnosticController = new WI.DiagnosticController;
+        WI.diagnosticController.addRecorder(new WI.InspectedTargetTypesDiagnosticEventRecorder(WI.diagnosticController));
         WI.diagnosticController.addRecorder(new WI.TabActivityDiagnosticEventRecorder(WI.diagnosticController));
         WI.diagnosticController.addRecorder(new WI.TabNavigationDiagnosticEventRecorder(WI.diagnosticController));
     }
index 26ea305..aedaad2 100644 (file)
@@ -31,23 +31,7 @@ WI.AppController = class AppController extends WI.AppControllerBase
 
         this._hasExtraDomains = false;
 
-        switch (InspectorFrontendHost.debuggableType()) {
-        case "javascript":
-            this._debuggableType = WI.DebuggableType.JavaScript;
-            break;
-
-        case "page":
-            this._debuggableType = WI.DebuggableType.Page;
-            break;
-
-        case "service-worker":
-            this._debuggableType = WI.DebuggableType.ServiceWorker;
-            break;
-
-        case "web-page":
-            this._debuggableType = WI.DebuggableType.WebPage;
-            break;
-        }
+        this._debuggableType = WI.DebuggableType.fromString(InspectorFrontendHost.debuggableInfo.debuggableType);
         console.assert(this._debuggableType);
         if (!this._debuggableType)
             this._debuggableType = WI.DebuggableType.JavaScript;
diff --git a/Source/WebInspectorUI/UserInterface/Controllers/InspectedTargetTypesDiagnosticEventRecorder.js b/Source/WebInspectorUI/UserInterface/Controllers/InspectedTargetTypesDiagnosticEventRecorder.js
new file mode 100644 (file)
index 0000000..d012d08
--- /dev/null
@@ -0,0 +1,146 @@
+/*
+ * Copyright (C) 2019 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.
+ */
+
+WI.InspectedTargetTypesDiagnosticEventRecorder = class InspectedTargetTypesDiagnosticEventRecorder extends WI.DiagnosticEventRecorder
+{
+    constructor(controller)
+    {
+        super("InspectedTargetTypes", controller);
+
+        this._initialDelayBeforeSamplingTimerIdentifier = undefined;
+    }
+
+    // Static
+
+    static get initialDelayBeforeSamplingInterval()
+    {
+        return 5 * 1000; // In milliseconds.
+    }
+
+    // Protected
+
+    setup()
+    {
+        // If it's been less than 5 seconds since the frontend loaded, wait a bit.
+        if (performance.now() - WI.frontendCompletedLoadTimestamp < InspectedTargetTypesDiagnosticEventRecorder.initialDelayBeforeSamplingInterval)
+            this._startInitialDelayBeforeSamplingTimer();
+        else
+            this._sampleInspectedTarget();
+
+    }
+
+    teardown()
+    {
+        this._stopInitialDelayBeforeSamplingTimer();
+    }
+
+    // Private
+
+    _startInitialDelayBeforeSamplingTimer()
+    {
+        if (this._initialDelayBeforeSamplingTimerIdentifier) {
+            clearTimeout(this._initialDelayBeforeSamplingTimerIdentifier);
+            this._initialDelayBeforeSamplingTimerIdentifier = undefined;
+        }
+
+        // All intervals are in milliseconds.
+        let maximumInitialDelay = InspectedTargetTypesDiagnosticEventRecorder.initialDelayBeforeSamplingInterval;
+        let elapsedTime = performance.now() - WI.frontendCompletedLoadTimestamp;
+        let remainingTime = maximumInitialDelay - elapsedTime;
+        let initialDelay = Number.constrain(remainingTime, 0, maximumInitialDelay);
+        this._initialDelayBeforeSamplingTimerIdentifier = setTimeout(this._sampleInspectedTarget.bind(this), initialDelay);
+    }
+
+    _stopInitialDelayBeforeSamplingTimer()
+    {
+        if (this._initialDelayBeforeSamplingTimerIdentifier) {
+            clearTimeout(this._initialDelayBeforeSamplingTimerIdentifier);
+            this._initialDelayBeforeSamplingTimerIdentifier = undefined;
+        }
+    }
+
+    _sampleInspectedTarget()
+    {
+        this._stopInitialDelayBeforeSamplingTimer();
+
+        this.logDiagnosticEvent(this.name, {
+            debuggableType: this._determineDebuggableType(),
+            targetPlatformName: this._determineTargetPlatformName(),
+            targetBuildVersion: this._determineTargetBuildVersion(),
+            targetProductVersion: this._determineTargetProductVersion(),
+            targetIsSimulator: this._determineTargetIsSimulator(),
+        });
+    }
+
+    _determineDebuggableType()
+    {
+        this._ensureCachedDebuggableInfo();
+
+        return this._cachedDebuggableInfo.debuggableType;
+    }
+
+    _determineTargetPlatformName()
+    {
+        this._ensureCachedDebuggableInfo();
+
+        return this._cachedDebuggableInfo.targetPlatformName;
+    }
+
+    _determineTargetBuildVersion()
+    {
+        this._ensureCachedDebuggableInfo();
+
+        return this._cachedDebuggableInfo.targetBuildVersion;
+    }
+
+    _determineTargetProductVersion()
+    {
+        this._ensureCachedDebuggableInfo();
+
+        return this._cachedDebuggableInfo.targetProductVersion;
+    }
+
+    _determineTargetIsSimulator()
+    {
+        this._ensureCachedDebuggableInfo();
+
+        return !!this._cachedDebuggableInfo.targetIsSimulator;
+    }
+
+    _ensureCachedDebuggableInfo()
+    {
+        if (this._cachedDebuggableInfo)
+            return;
+
+        let debuggableInfo = InspectorFrontendHost.debuggableInfo;
+        this._cachedDebuggableInfo = {
+            debuggableType: WI.DebuggableType.fromString(debuggableInfo.debuggableType) || WI.DebuggableType.JavaScript,
+            targetPlatformName: debuggableInfo.targetPlatformName || "Unknown",
+            targetBuildVersion: debuggableInfo.targetBuildVersion || "Unknown",
+            targetProductVersion: debuggableInfo.targetProductVersion || "Unknown",
+            targetIsSimulator: debuggableInfo.targetIsSimulator,
+        };
+    }
+};
index c826d51..e33d122 100644 (file)
 
     <script src="Controllers/DiagnosticController.js"></script>
     <script src="Controllers/DiagnosticEventRecorder.js"></script>
+    <script src="Controllers/InspectedTargetTypesDiagnosticEventRecorder.js"></script>
     <script src="Controllers/TabActivityDiagnosticEventRecorder.js"></script>
     <script src="Controllers/TabNavigationDiagnosticEventRecorder.js"></script>
 
index b466212..c9e85a1 100644 (file)
@@ -186,7 +186,7 @@ InspectorBackendClass = class InspectorBackendClass
     {
         // FIXME: <https://webkit.org/b/201150> Web Inspector: remove "extra domains" concept now that domains can be added based on the debuggable type
 
-        if (debuggableTypes && !debuggableTypes.includes(InspectorFrontendHost.debuggableType()))
+        if (debuggableTypes && !debuggableTypes.includes(InspectorFrontendHost.debuggableInfo.debuggableType))
             return;
 
         console.assert(domainName in this._registeredDomains);
index 015af2e..4a90515 100644 (file)
@@ -29,15 +29,7 @@ WI.TestAppController = class TestAppController extends WI.AppControllerBase
     {
         super();
 
-        switch (InspectorFrontendHost.debuggableType()) {
-        case "page":
-            this._debuggableType = WI.DebuggableType.Page;
-            break;
-
-        case "web-page":
-            this._debuggableType = WI.DebuggableType.WebPage;
-            break;
-        }
+        this._debuggableType = WI.DebuggableType.fromString(InspectorFrontendHost.debuggableInfo.debuggableType);
         console.assert(this._debuggableType);
     }
 
index b5b6263..6710d3d 100644 (file)
@@ -1,3 +1,103 @@
+2019-12-21  Brian Burg  <bburg@apple.com>
+
+        Web Inspector: add InspectedTargetTypes diagnostic event and related hooks
+        https://bugs.webkit.org/show_bug.cgi?id=205174
+        <rdar://problem/57887953>
+
+        Reviewed by Devin Rousso.
+
+        This change supplies Web Inspector with information about the debuggable that
+        it is connected to. This is used for diagnostics and to customize the UI based
+        on the target type being inspected.
+
+        For remote Web Inspector, WebKit clients can populate an instance of 
+        _WKInspectorDebuggableInfo and use it when calling into
+        -[_WKRemoteWebInspectorViewController loadForDebuggable:backendCommandsURL:].
+
+        For local Web Inspector, WebInspectorProxy fills in information for the local
+        debuggable by consulting SystemVersion.plist (on Mac port).
+
+        The new enum _WKInspectorDebuggableType replaces _WKRemoteWebInspectorDebuggableType.
+        Its WebCore equivalent is Inspector::DebuggableType. The type and other information
+        are carried around in a _WKInspectorDebuggableInfo class. The equivalents for this
+        class are API::DebuggableInfo and DebuggableInfoData (for sending over IPC).
+
+        The DebuggableInfoData is sent as part of the initial message from UIProcess
+        to an Inspector WebProcess, similar to how a debuggableType string was sent before.
+
+        * Sources.txt:
+        * SourcesCocoa.txt:
+        * WebKit.xcodeproj/project.pbxproj:
+        Add new files.
+
+        * Shared/API/APIObject.h:
+        * Shared/Cocoa/APIObject.mm:
+        (API::Object::newObject): Add new object type.
+        * Shared/WebCoreArgumentCoders.h: Add EnumTraits for Inspector::DebuggableType.
+
+        * UIProcess/API/Cocoa/_WKRemoteWebInspectorViewControllerPrivate.h:
+        * UIProcess/API/Cocoa/_WKRemoteWebInspectorViewController.mm:
+        (legacyDebuggableTypeToModernDebuggableType):
+        (-[_WKRemoteWebInspectorViewController loadForDebuggableType:backendCommandsURL:]):
+        (-[_WKRemoteWebInspectorViewController loadForDebuggable:backendCommandsURL:]):
+        (debuggableTypeString): Deleted.
+        Use the new enum in a new method that clients can switch over to. The old method
+        can be removed when it is no longer being used.
+
+        * UIProcess/RemoteWebInspectorProxy.h:
+        * UIProcess/RemoteWebInspectorProxy.cpp:
+        (WebKit::RemoteWebInspectorProxy::RemoteWebInspectorProxy):
+        (WebKit::RemoteWebInspectorProxy::load):
+        (WebKit::RemoteWebInspectorProxy::reopen):
+        Send DebuggableInfoData struct to RemoteWebInspectorUI.
+
+        * UIProcess/WebInspectorProxy.h:
+        * UIProcess/WebInspectorProxy.cpp:
+        (WebKit::WebInspectorProxy::openLocalInspectorFrontend):
+        (WebKit::WebInspectorProxy::infoForLocalDebuggable):
+        Send DebuggableInfoData struct to WebInspectorUI.
+
+        * UIProcess/mac/WebInspectorProxyMac.mm:
+        (WebKit::systemVersionPlist):
+        (WebKit::WebInspectorProxy::infoForLocalDebuggable):
+        Add Mac implementation for local debuggables.
+
+        * UIProcess/gtk/WebInspectorProxyGtk.cpp:
+        (WebKit::WebInspectorProxy::infoForLocalDebuggable):
+        * UIProcess/win/WebInspectorProxyWin.cpp:
+        (WebKit::WebInspectorProxy::infoForLocalDebuggable):
+        * UIProcess/wpe/WebInspectorProxyWPE.cpp:
+        (WebKit::WebInspectorProxy::infoForLocalDebuggable):
+        Add stubs for other platforms.
+
+        * UIProcess/glib/RemoteInspectorClient.cpp:
+        * UIProcess/socket/RemoteInspectorClient.h:
+        * UIProcess/socket/RemoteInspectorClient.cpp:
+        (WebKit::RemoteInspectorClient::inspect):
+        (WebKit::debuggableTypeToString):
+        (WebKit::RemoteInspectorClient::setTargetList):
+        Use Inspector::DebuggableType instead of String for debuggable type.
+
+        * WebProcess/WebPage/RemoteWebInspectorUI.messages.in:
+        * WebProcess/WebPage/RemoteWebInspectorUI.h:
+        * WebProcess/WebPage/RemoteWebInspectorUI.cpp:
+        (WebKit::RemoteWebInspectorUI::initialize):
+        (WebKit::RemoteWebInspectorUI::debuggableType const):
+        (WebKit::RemoteWebInspectorUI::targetPlatformName const):
+        (WebKit::RemoteWebInspectorUI::targetBuildVersion const):
+        (WebKit::RemoteWebInspectorUI::targetProductVersion const):
+        (WebKit::RemoteWebInspectorUI::targetIsSimulator const):
+        Implement new methods needed by InspectorFrontendClient / InspectorFrontendHost.
+
+        * WebProcess/WebPage/WebInspectorUI.messages.in:
+        * WebProcess/WebPage/WebInspectorUI.h:
+        * WebProcess/WebPage/WebInspectorUI.cpp:
+        (WebKit::WebInspectorUI::establishConnection):
+        (WebKit::WebInspectorUI::targetPlatformName const):
+        (WebKit::WebInspectorUI::targetBuildVersion const):
+        (WebKit::WebInspectorUI::targetProductVersion const):
+        Implement new methods needed by InspectorFrontendClient / InspectorFrontendHost. 
+
 2019-12-21  Eric Carlson  <eric.carlson@apple.com>
 
         [Media in GPU process] Add remote media player configuration
index a6d088d..8b71fe0 100644 (file)
@@ -116,6 +116,7 @@ public:
         CookieManager,
         CustomHeaderFields,
         InternalDebugFeature,
+        DebuggableInfo,
         Download,
         ExperimentalFeature,
         FormSubmissionListener,
index 218abe7..db65e6f 100644 (file)
@@ -77,6 +77,7 @@
 #import "_WKFrameHandleInternal.h"
 #import "_WKGeolocationPositionInternal.h"
 #import "_WKHitTestResultInternal.h"
+#import "_WKInspectorDebuggableInfoInternal.h"
 #import "_WKInspectorInternal.h"
 #import "_WKInternalDebugFeatureInternal.h"
 #import "_WKProcessPoolConfigurationInternal.h"
@@ -189,6 +190,10 @@ void* Object::newObject(size_t size, Type type)
         ALLOW_DEPRECATED_DECLARATIONS_END
         break;
 
+    case Type::DebuggableInfo:
+        wrapper = [_WKInspectorDebuggableInfo alloc];
+        break;
+
     case Type::Preferences:
         wrapper = [WKPreferences alloc];
         break;
diff --git a/Source/WebKit/Shared/DebuggableInfoData.cpp b/Source/WebKit/Shared/DebuggableInfoData.cpp
new file mode 100644 (file)
index 0000000..ed743af
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+
+#include "config.h"
+#include "DebuggableInfoData.h"
+
+#include "WebCoreArgumentCoders.h"
+#include <WebCore/InspectorDebuggableType.h>
+
+namespace WebKit {
+
+DebuggableInfoData DebuggableInfoData::empty()
+{
+    return {
+        Inspector::DebuggableType::Page,
+        "Unknown"_s,
+        "Unknown"_s,
+        "Unknown"_s,
+        false
+    };
+}
+
+void DebuggableInfoData::encode(IPC::Encoder& encoder) const
+{
+    encoder << debuggableType;
+    encoder << targetPlatformName;
+    encoder << targetBuildVersion;
+    encoder << targetProductVersion;
+    encoder << targetIsSimulator;
+}
+
+Optional<DebuggableInfoData> DebuggableInfoData::decode(IPC::Decoder& decoder)
+{
+    Optional<Inspector::DebuggableType> debuggableType;
+    decoder >> debuggableType;
+    if (!debuggableType)
+        return WTF::nullopt;
+
+    Optional<String> targetPlatformName;
+    decoder >> targetPlatformName;
+    if (!targetPlatformName)
+        return WTF::nullopt;
+
+    Optional<String> targetBuildVersion;
+    decoder >> targetBuildVersion;
+    if (!targetBuildVersion)
+        return WTF::nullopt;
+
+    Optional<String> targetProductVersion;
+    decoder >> targetProductVersion;
+    if (!targetProductVersion)
+        return WTF::nullopt;
+
+    Optional<bool> targetIsSimulator;
+    decoder >> targetIsSimulator;
+    if (!targetIsSimulator)
+        return WTF::nullopt;
+
+    return {{
+        *debuggableType,
+        *targetPlatformName,
+        *targetBuildVersion,
+        *targetProductVersion,
+        *targetIsSimulator
+    }};
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/Shared/DebuggableInfoData.h b/Source/WebKit/Shared/DebuggableInfoData.h
new file mode 100644 (file)
index 0000000..7ab757a
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2019 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.
+ */
+
+#pragma once
+
+#include <wtf/text/WTFString.h>
+
+
+namespace IPC {
+class Decoder;
+class Encoder;
+}
+
+namespace Inspector {
+enum class DebuggableType : uint8_t;
+}
+
+namespace WebKit {
+
+struct DebuggableInfoData {
+    Inspector::DebuggableType debuggableType;
+    String targetPlatformName;
+    String targetBuildVersion;
+    String targetProductVersion;
+    bool targetIsSimulator { false };
+
+    static DebuggableInfoData empty();
+
+    void encode(IPC::Encoder&) const;
+    static Optional<DebuggableInfoData> decode(IPC::Decoder&);
+};
+
+} // namespace WebKit
index 5424e5d..1916db3 100644 (file)
@@ -128,6 +128,7 @@ Shared/AuxiliaryProcess.cpp @no-unify
 Shared/BlobDataFileReferenceWithSandboxExtension.cpp @no-unify
 Shared/CacheModel.cpp
 Shared/ContextMenuContextData.cpp
+Shared/DebuggableInfoData.cpp
 Shared/EditingRange.cpp
 Shared/EditorState.cpp
 Shared/FontInfo.cpp
@@ -313,6 +314,7 @@ UIProcess/API/APIContentRuleList.cpp
 UIProcess/API/APIContentRuleListAction.cpp
 UIProcess/API/APIContentRuleListStore.cpp
 UIProcess/API/APIContextMenuElementInfo.cpp
+UIProcess/API/APIDebuggableInfo.cpp
 UIProcess/API/APIExperimentalFeature.cpp
 UIProcess/API/APIFrameInfo.cpp
 UIProcess/API/APIHTTPCookieStore.cpp
index 65184ed..a4aa55e 100644 (file)
@@ -258,6 +258,7 @@ UIProcess/API/Cocoa/_WKErrorRecoveryAttempting.mm
 UIProcess/API/Cocoa/_WKExperimentalFeature.mm
 UIProcess/API/Cocoa/_WKGeolocationPosition.mm
 UIProcess/API/Cocoa/_WKInspector.mm
+UIProcess/API/Cocoa/_WKInspectorDebuggableInfo.mm
 UIProcess/API/Cocoa/_WKInspectorWindow.mm
 UIProcess/API/Cocoa/_WKInternalDebugFeature.mm
 UIProcess/API/Cocoa/_WKLinkIconParameters.mm
diff --git a/Source/WebKit/UIProcess/API/APIDebuggableInfo.cpp b/Source/WebKit/UIProcess/API/APIDebuggableInfo.cpp
new file mode 100644 (file)
index 0000000..523b185
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2019 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.
+ */
+
+#include "config.h"
+#include "APIDebuggableInfo.h"
+
+#include "DebuggableInfoData.h"
+
+namespace API {
+
+Ref<DebuggableInfo> DebuggableInfo::create(const WebKit::DebuggableInfoData& debuggableInfoData)
+{
+    return adoptRef(*new DebuggableInfo(debuggableInfoData));
+}
+
+DebuggableInfo::DebuggableInfo(const WebKit::DebuggableInfoData& data)
+    : m_data(data)
+{
+}
+
+DebuggableInfo::~DebuggableInfo() = default;
+
+} // namespace API
diff --git a/Source/WebKit/UIProcess/API/APIDebuggableInfo.h b/Source/WebKit/UIProcess/API/APIDebuggableInfo.h
new file mode 100644 (file)
index 0000000..3c20388
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2019 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.
+ */
+
+#pragma once
+
+#include "APIObject.h"
+#include "DebuggableInfoData.h"
+#include <WebCore/InspectorDebuggableType.h>
+
+namespace API {
+
+class DebuggableInfo final : public ObjectImpl<Object::Type::DebuggableInfo> {
+public:
+    static Ref<DebuggableInfo> create(const WebKit::DebuggableInfoData&);
+    DebuggableInfo() = default;
+    virtual ~DebuggableInfo();
+
+    Inspector::DebuggableType debuggableType() const { return m_data.debuggableType; }
+    void setDebuggableType(Inspector::DebuggableType debuggableType) { m_data.debuggableType = debuggableType; }
+
+    const WTF::String& targetPlatformName() const { return m_data.targetPlatformName; }
+    void setTargetPlatformName(const WTF::String& targetPlatformName) { m_data.targetPlatformName = targetPlatformName; }
+
+    const WTF::String& targetBuildVersion() const { return m_data.targetBuildVersion; }
+    void setTargetBuildVersion(const WTF::String& targetBuildVersion) { m_data.targetBuildVersion = targetBuildVersion; }
+
+    const WTF::String& targetProductVersion() const { return m_data.targetProductVersion; }
+    void setTargetProductVersion(const WTF::String& targetProductVersion) { m_data.targetProductVersion = targetProductVersion; }
+
+    bool targetIsSimulator() const { return m_data.targetIsSimulator; }
+    void setTargetIsSimulator(bool targetIsSimulator) { m_data.targetIsSimulator = targetIsSimulator; }
+
+    const WebKit::DebuggableInfoData& debuggableInfoData() const { return m_data; }
+
+private:
+    explicit DebuggableInfo(const WebKit::DebuggableInfoData&);
+
+    WebKit::DebuggableInfoData m_data;
+};
+
+} // namespace API
diff --git a/Source/WebKit/UIProcess/API/Cocoa/_WKInspectorDebuggableInfo.h b/Source/WebKit/UIProcess/API/Cocoa/_WKInspectorDebuggableInfo.h
new file mode 100644 (file)
index 0000000..a3bc5e7
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2019 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 <WebKit/WKFoundation.h>
+
+/*! A _WKInspectorDebuggableInfo object contains information about a debuggable target.
+ @discussion An instance of this class is a transient, data-only object;
+ it does not uniquely identify a debuggable across multiple method calls.
+ */
+
+NS_ASSUME_NONNULL_BEGIN
+
+typedef NS_ENUM(NSInteger, _WKInspectorDebuggableType) {
+    _WKInspectorDebuggableTypeJavaScript,
+    _WKInspectorDebuggableTypeServiceWorker,
+    _WKInspectorDebuggableTypePage,
+    _WKInspectorDebuggableTypeWebPage,
+} WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
+
+WK_CLASS_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA))
+@interface _WKInspectorDebuggableInfo : NSObject <NSCopying>
+@property (nonatomic) _WKInspectorDebuggableType debuggableType;
+@property (nonatomic, copy) NSString *targetPlatformName;
+@property (nonatomic, copy) NSString *targetBuildVersion;
+@property (nonatomic, copy) NSString *targetProductVersion;
+@property (nonatomic) BOOL targetIsSimulator;
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/Source/WebKit/UIProcess/API/Cocoa/_WKInspectorDebuggableInfo.mm b/Source/WebKit/UIProcess/API/Cocoa/_WKInspectorDebuggableInfo.mm
new file mode 100644 (file)
index 0000000..2f61f01
--- /dev/null
@@ -0,0 +1,118 @@
+/*
+ * Copyright (C) 2019 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 "_WKInspectorDebuggableInfoInternal.h"
+
+@implementation _WKInspectorDebuggableInfo
+
+- (instancetype)init
+{
+    if (!(self = [super init]))
+        return nil;
+
+    API::Object::constructInWrapper<API::DebuggableInfo>(self);
+
+    return self;
+}
+
+- (_WKInspectorDebuggableType)debuggableType
+{
+    return toWKInspectorDebuggableType(_debuggableInfo->debuggableType());
+}
+
+- (void)setDebuggableType:(_WKInspectorDebuggableType)debuggableType
+{
+    _debuggableInfo->setDebuggableType(fromWKInspectorDebuggableType(debuggableType));
+}
+
+- (NSString *)targetPlatformName
+{
+    return _debuggableInfo->targetPlatformName();
+}
+
+- (void)setTargetPlatformName:(NSString *)targetPlatformName
+{
+    _debuggableInfo->setTargetPlatformName(targetPlatformName);
+}
+
+- (NSString *)targetBuildVersion
+{
+    return _debuggableInfo->targetBuildVersion();
+}
+
+- (void)setTargetBuildVersion:(NSString *)targetBuildVersion
+{
+    _debuggableInfo->setTargetBuildVersion(targetBuildVersion);
+}
+
+- (NSString *)targetProductVersion
+{
+    return _debuggableInfo->targetProductVersion();
+}
+
+- (void)setTargetProductVersion:(NSString *)targetProductVersion
+{
+    _debuggableInfo->setTargetProductVersion(targetProductVersion);
+}
+
+- (BOOL)targetIsSimulator
+{
+    return _debuggableInfo->targetIsSimulator();
+}
+
+- (void)setTargetIsSimulator:(BOOL)targetIsSimulator
+{
+    _debuggableInfo->setTargetIsSimulator(targetIsSimulator);
+}
+
+- (void)dealloc
+{
+    _debuggableInfo->~DebuggableInfo();
+
+    [super dealloc];
+}
+
+- (id)copyWithZone:(NSZone *)zone
+{
+    _WKInspectorDebuggableInfo *debuggableInfo = [(_WKInspectorDebuggableInfo *)[[self class] allocWithZone:zone] init];
+
+    debuggableInfo.debuggableType = self.debuggableType;
+    debuggableInfo.targetPlatformName = self.targetPlatformName;
+    debuggableInfo.targetBuildVersion = self.targetBuildVersion;
+    debuggableInfo.targetProductVersion = self.targetProductVersion;
+    debuggableInfo.targetIsSimulator = self.targetIsSimulator;
+
+    return debuggableInfo;
+}
+
+#pragma mark WKObject protocol implementation
+
+- (API::Object&)_apiObject
+{
+    return *_debuggableInfo;
+}
+
+@end
diff --git a/Source/WebKit/UIProcess/API/Cocoa/_WKInspectorDebuggableInfoInternal.h b/Source/WebKit/UIProcess/API/Cocoa/_WKInspectorDebuggableInfoInternal.h
new file mode 100644 (file)
index 0000000..60e15d4
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2019 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 "_WKInspectorDebuggableInfo.h"
+
+#import "APIDebuggableInfo.h"
+#import "WKObject.h"
+
+namespace WebKit {
+
+template<> struct WrapperTraits<API::DebuggableInfo> {
+    using WrapperClass = _WKInspectorDebuggableInfo;
+};
+
+}
+
+@interface _WKInspectorDebuggableInfo () <WKObject> {
+@package
+    API::ObjectStorage<API::DebuggableInfo> _debuggableInfo;
+}
+@end
+
+inline Inspector::DebuggableType fromWKInspectorDebuggableType(_WKInspectorDebuggableType debuggableType)
+{
+    switch (debuggableType) {
+    case _WKInspectorDebuggableTypeJavaScript:
+        return Inspector::DebuggableType::JavaScript;
+    case _WKInspectorDebuggableTypePage:
+        return Inspector::DebuggableType::Page;
+    case _WKInspectorDebuggableTypeServiceWorker:
+        return Inspector::DebuggableType::ServiceWorker;
+    case _WKInspectorDebuggableTypeWebPage:
+        return Inspector::DebuggableType::WebPage;
+    }
+
+    ASSERT_NOT_REACHED();
+    return Inspector::DebuggableType::JavaScript;
+}
+
+inline _WKInspectorDebuggableType toWKInspectorDebuggableType(Inspector::DebuggableType debuggableType)
+{
+    switch (debuggableType) {
+    case Inspector::DebuggableType::JavaScript:
+        return _WKInspectorDebuggableTypeJavaScript;
+    case Inspector::DebuggableType::Page:
+        return _WKInspectorDebuggableTypePage;
+    case Inspector::DebuggableType::ServiceWorker:
+        return _WKInspectorDebuggableTypeServiceWorker;
+    case Inspector::DebuggableType::WebPage:
+        return _WKInspectorDebuggableTypeWebPage;
+    }
+
+    ASSERT_NOT_REACHED();
+    return _WKInspectorDebuggableTypeJavaScript;
+}
index 9c1ffed..2bdb8b9 100644 (file)
 
 #if PLATFORM(MAC)
 
+#import "APIDebuggableInfo.h"
+#import "DebuggableInfoData.h"
 #import "RemoteWebInspectorProxy.h"
+#import "WKWebViewInternal.h"
+#import "_WKInspectorDebuggableInfoInternal.h"
 
 @interface _WKRemoteWebInspectorViewController ()
 - (void)sendMessageToBackend:(NSString *)message;
@@ -92,28 +96,39 @@ private:
     return m_remoteInspectorProxy->webView();
 }
 
-static String debuggableTypeString(WKRemoteWebInspectorDebuggableType debuggableType)
+static _WKInspectorDebuggableType legacyDebuggableTypeToModernDebuggableType(WKRemoteWebInspectorDebuggableType debuggableType)
 {
     switch (debuggableType) {
     case WKRemoteWebInspectorDebuggableTypeJavaScript:
-        return "javascript"_s;
+        return _WKInspectorDebuggableTypeJavaScript;
     case WKRemoteWebInspectorDebuggableTypePage:
-        return "page"_s;
+        return _WKInspectorDebuggableTypePage;
     case WKRemoteWebInspectorDebuggableTypeServiceWorker:
-        return "service-worker"_s;
+        return _WKInspectorDebuggableTypeServiceWorker;
     case WKRemoteWebInspectorDebuggableTypeWebPage:
-        return "web-page"_s;
-
+        return _WKInspectorDebuggableTypeWebPage;
 ALLOW_DEPRECATED_DECLARATIONS_BEGIN
     case WKRemoteWebInspectorDebuggableTypeWeb:
-        return "web-page"_s;
+        return _WKInspectorDebuggableTypeWebPage;
 ALLOW_DEPRECATED_DECLARATIONS_END
     }
 }
 
+// FIXME: remove this variant when all callers have moved off of it.
 - (void)loadForDebuggableType:(WKRemoteWebInspectorDebuggableType)debuggableType backendCommandsURL:(NSURL *)backendCommandsURL
 {
-    m_remoteInspectorProxy->load(debuggableTypeString(debuggableType), backendCommandsURL.absoluteString);
+    _WKInspectorDebuggableInfo *debuggableInfo = [_WKInspectorDebuggableInfo new];
+    debuggableInfo.debuggableType = legacyDebuggableTypeToModernDebuggableType(debuggableType);
+    debuggableInfo.targetPlatformName = @"macOS";
+    debuggableInfo.targetBuildVersion = @"Unknown";
+    debuggableInfo.targetProductVersion = @"Unknown";
+    debuggableInfo.targetIsSimulator = false;
+    [self loadForDebuggable:debuggableInfo backendCommandsURL:backendCommandsURL];
+}
+
+- (void)loadForDebuggable:(_WKInspectorDebuggableInfo *)debuggableInfo backendCommandsURL:(NSURL *)backendCommandsURL
+{
+    m_remoteInspectorProxy->load(static_cast<API::DebuggableInfo&>([debuggableInfo _apiObject]), backendCommandsURL.absoluteString);
 }
 
 - (void)close
index ce8e31f..3a9c710 100644 (file)
 
 NS_ASSUME_NONNULL_BEGIN
 
+@class _WKInspectorDebuggableInfo;
+
 @interface _WKRemoteWebInspectorViewController (WKPrivate)
 
 @property (nonatomic, weak, setter=_setDiagnosticLoggingDelegate:) id<_WKDiagnosticLoggingDelegate> _diagnosticLoggingDelegate;
 
+- (void)loadForDebuggable:(_WKInspectorDebuggableInfo *)debuggableInfo backendCommandsURL:(NSURL *)backendCommandsURL;
+
 @end
 
 
index fcdae16..5b0fcb4 100644 (file)
@@ -26,6 +26,7 @@
 #include "config.h"
 #include "RemoteWebInspectorProxy.h"
 
+#include "APIDebuggableInfo.h"
 #include "APINavigation.h"
 #include "RemoteWebInspectorProxyMessages.h"
 #include "RemoteWebInspectorUIMessages.h"
@@ -39,6 +40,7 @@ namespace WebKit {
 using namespace WebCore;
 
 RemoteWebInspectorProxy::RemoteWebInspectorProxy()
+    : m_debuggableInfo(API::DebuggableInfo::create(DebuggableInfoData::empty()))
 {
 }
 
@@ -61,14 +63,14 @@ void RemoteWebInspectorProxy::setDiagnosticLoggingAvailable(bool available)
 #endif
 }
 
-void RemoteWebInspectorProxy::load(const String& debuggableType, const String& backendCommandsURL)
+void RemoteWebInspectorProxy::load(Ref<API::DebuggableInfo>&& debuggableInfo, const String& backendCommandsURL)
 {
     createFrontendPageAndWindow();
 
-    m_debuggableType = debuggableType;
+    m_debuggableInfo = WTFMove(debuggableInfo);
     m_backendCommandsURL = backendCommandsURL;
 
-    m_inspectorPage->send(Messages::RemoteWebInspectorUI::Initialize(debuggableType, backendCommandsURL));
+    m_inspectorPage->send(Messages::RemoteWebInspectorUI::Initialize(m_debuggableInfo->debuggableInfoData(), backendCommandsURL));
     m_inspectorPage->loadRequest(URL(URL(), WebInspectorProxy::inspectorPageURL()));
 }
 
@@ -105,10 +107,10 @@ void RemoteWebInspectorProxy::frontendDidClose()
 
 void RemoteWebInspectorProxy::reopen()
 {
-    ASSERT(!m_debuggableType.isEmpty());
+    ASSERT(!m_backendCommandsURL.isEmpty());
 
     closeFrontendPageAndWindow();
-    load(m_debuggableType, m_backendCommandsURL);
+    load(m_debuggableInfo.copyRef(), m_backendCommandsURL);
 }
 
 void RemoteWebInspectorProxy::resetState()
index 84cf8d8..fab58f8 100644 (file)
@@ -45,6 +45,10 @@ namespace WebCore {
 class CertificateInfo;
 }
 
+namespace API {
+class DebuggableInfo;
+}
+
 namespace WebKit {
 
 class WebPageProxy;
@@ -74,7 +78,7 @@ public:
 
     void invalidate();
 
-    void load(const String& debuggableType, const String& backendCommandsURL);
+    void load(Ref<API::DebuggableInfo>&&, const String& backendCommandsURL);
     void closeFromBackend();
     void show();
 
@@ -137,7 +141,7 @@ private:
     RemoteWebInspectorProxyClient* m_client { nullptr };
     WebPageProxy* m_inspectorPage { nullptr };
 
-    String m_debuggableType;
+    Ref<API::DebuggableInfo> m_debuggableInfo;
     String m_backendCommandsURL;
 
 #if PLATFORM(MAC)
index 53ab330..8b526dd 100644 (file)
@@ -412,7 +412,7 @@ void WebInspectorProxy::openLocalInspectorFrontend(bool canAttach, bool underTes
     if (!m_inspectorPage)
         return;
 
-    m_inspectorPage->send(Messages::WebInspectorUI::EstablishConnection(m_inspectedPage->identifier(), m_underTest, inspectionLevel()));
+    m_inspectorPage->send(Messages::WebInspectorUI::EstablishConnection(m_inspectedPage->identifier(), infoForLocalDebuggable(), m_underTest, inspectionLevel()));
 
     ASSERT(!m_isActiveFrontend);
     m_isActiveFrontend = true;
@@ -765,6 +765,12 @@ String WebInspectorProxy::inspectorBaseURL()
     return String();
 }
 
+DebuggableInfoData WebInspectorProxy::infoForLocalDebuggable()
+{
+    notImplemented();
+    return DebuggableInfoData::empty();
+}
+
 void WebInspectorProxy::platformSetAttachedWindowWidth(unsigned)
 {
     notImplemented();
index 3fb25de..2b1fdfc 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "APIObject.h"
 #include "Attachment.h"
+#include "DebuggableInfoData.h"
 #include "MessageReceiver.h"
 #include "WebInspectorUtilities.h"
 #include <JavaScriptCore/InspectorFrontendChannel.h>
@@ -166,6 +167,7 @@ public:
     static String inspectorTestPageURL();
     static String inspectorBaseURL();
     static bool isMainOrTestInspectorPage(const URL&);
+    static DebuggableInfoData infoForLocalDebuggable();
 
     static const unsigned minimumWindowWidth;
     static const unsigned minimumWindowHeight;
index 25030a2..d9d50dc 100644 (file)
 
 #if ENABLE(REMOTE_INSPECTOR)
 
+#include "APIDebuggableInfo.h"
 #include "RemoteWebInspectorProxy.h"
 #include <JavaScriptCore/RemoteInspectorUtils.h>
+#include <WebCore/InspectorDebuggableType.h>
 #include <gio/gio.h>
 #include <wtf/NeverDestroyed.h>
 #include <wtf/glib/GUniquePtr.h>
@@ -57,7 +59,10 @@ public:
 
     void load()
     {
-        m_proxy->load("web-page", m_inspectorClient.backendCommandsURL());
+        // FIXME <https://webkit.org/b/205536>: this should infer more useful data about the debug target.
+        Ref<API::DebuggableInfo> debuggableInfo = API::DebuggableInfo::create(DebuggableInfoData::empty());
+        debuggableInfo->setDebuggableType(Inspector::DebuggableType::WebPage);
+        m_proxy->load(WTFMove(debuggableInfo), m_inspectorClient.backendCommandsURL());
     }
 
     void show()
index 4f8de43..cfde349 100644 (file)
@@ -364,6 +364,12 @@ String WebInspectorProxy::inspectorBaseURL()
     return String("resource:///org/webkit/inspector/UserInterface/");
 }
 
+DebuggableInfoData WebInspectorProxy::infoForLocalDebuggable()
+{
+    // FIXME <https://webkit.org/b/205536>: this should infer more useful data about the debug target.
+    return DebuggableInfoData::empty();
+}
+
 unsigned WebInspectorProxy::platformInspectedWindowHeight()
 {
     return gtk_widget_get_allocated_height(inspectedPage()->viewWidget());
index e537974..bbe728d 100644 (file)
@@ -779,6 +779,28 @@ String WebInspectorProxy::inspectorBaseURL()
     return [NSURL fileURLWithPath:path isDirectory:YES].absoluteString;
 }
 
+static NSDictionary *systemVersionPlist()
+{
+    NSString *systemLibraryPath = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSSystemDomainMask, YES) objectAtIndex:0];
+    NSString *systemVersionPlistPath = [systemLibraryPath stringByAppendingPathComponent:@"CoreServices/SystemVersion.plist"];
+    NSDictionary *systemVersionInfo = [NSDictionary dictionaryWithContentsOfFile:systemVersionPlistPath];
+    return systemVersionInfo;
+}
+
+DebuggableInfoData WebInspectorProxy::infoForLocalDebuggable()
+{
+    NSDictionary *plist = systemVersionPlist();
+
+    DebuggableInfoData result;
+    result.debuggableType = Inspector::DebuggableType::WebPage;
+    result.targetPlatformName = "macOS"_s;
+    result.targetBuildVersion = plist[@"ProductBuildVersion"];
+    result.targetProductVersion = plist[@"ProductUserVisibleVersion"];
+    result.targetIsSimulator = false;
+
+    return result;
+}
+
 } // namespace WebKit
 
 #endif // PLATFORM(MAC)
index bf1f5fe..a4d96d1 100644 (file)
@@ -28,6 +28,7 @@
 
 #if ENABLE(REMOTE_INSPECTOR)
 
+#include "APIDebuggableInfo.h"
 #include "RemoteWebInspectorProxy.h"
 #include <wtf/MainThread.h>
 #include <wtf/text/Base64.h>
@@ -37,12 +38,12 @@ namespace WebKit {
 class RemoteInspectorProxy final : public RemoteWebInspectorProxyClient {
     WTF_MAKE_FAST_ALLOCATED();
 public:
-    RemoteInspectorProxy(RemoteInspectorClient& inspectorClient, ConnectionID connectionID, TargetID targetID, const String& type)
+    RemoteInspectorProxy(RemoteInspectorClient& inspectorClient, ConnectionID connectionID, TargetID targetID, Inspector::DebuggableType debuggableType)
         : m_proxy(RemoteWebInspectorProxy::create())
         , m_inspectorClient(inspectorClient)
         , m_connectionID(connectionID)
         , m_targetID(targetID)
-        , m_debuggableType(type)
+        , m_debuggableType(debuggableType)
     {
         m_proxy->setClient(this);
     }
@@ -55,7 +56,10 @@ public:
 
     void load()
     {
-        m_proxy->load(m_debuggableType, m_inspectorClient.backendCommandsURL());
+        // FIXME <https://webkit.org/b/205537>: this should infer more useful data about the debug target.
+        Ref<API::DebuggableInfo> debuggableInfo = API::DebuggableInfo::create(DebuggableInfoData::empty());
+        debuggableInfo->setDebuggableType(m_debuggableType);
+        m_proxy->load(WTFMove(debuggableInfo), m_inspectorClient.backendCommandsURL());
     }
 
     void show()
@@ -83,7 +87,7 @@ private:
     RemoteInspectorClient& m_inspectorClient;
     ConnectionID m_connectionID;
     TargetID m_targetID;
-    String m_debuggableType;
+    Inspector::DebuggableType m_debuggableType;
 };
 
 RemoteInspectorClient::RemoteInspectorClient(URL url, RemoteInspectorObserver& observer)
@@ -148,10 +152,10 @@ void RemoteInspectorClient::didClose(ConnectionID)
     });
 }
 
-void RemoteInspectorClient::inspect(ConnectionID connectionID, TargetID targetID, const String& type)
+void RemoteInspectorClient::inspect(ConnectionID connectionID, TargetID targetID, Inspector::DebuggableType debuggableType)
 {
-    auto addResult = m_inspectorProxyMap.ensure(std::make_pair(connectionID, targetID), [this, connectionID, targetID, &type] {
-        return makeUnique<RemoteInspectorProxy>(*this, connectionID, targetID, type);
+    auto addResult = m_inspectorProxyMap.ensure(std::make_pair(connectionID, targetID), [this, connectionID, targetID, debuggableType] {
+        return makeUnique<RemoteInspectorProxy>(*this, connectionID, targetID, debuggableType);
     });
 
     if (!addResult.isNewEntry) {
@@ -197,6 +201,23 @@ void RemoteInspectorClient::setBackendCommands(const Event& event)
     m_backendCommandsURL = makeString("data:text/javascript;base64,", base64Encode(event.message->utf8()));
 }
 
+static String debuggableTypeToString(Inspector::DebuggableType debuggableType)
+{
+    switch (debuggableType) {
+    case Inspector::DebuggableType::JavaScript:
+        return "javascript"_s;
+    case Inspector::DebuggableType::Page:
+        return "page"_s;
+    case Inspector::DebuggableType::ServiceWorker:
+        return "service-worker"_s;
+    case Inspector::DebuggableType::WebPage:
+        return "web-page"_s;
+    }
+
+    ASSERT_NOT_REACHED();
+    return String();
+}
+
 void RemoteInspectorClient::setTargetList(const Event& event)
 {
     if (!event.connectionID || !event.message)
@@ -220,7 +241,7 @@ void RemoteInspectorClient::setTargetList(const Event& event)
         if (!itemObject->getInteger("targetID"_s, target.id)
             || !itemObject->getString("name"_s, target.name)
             || !itemObject->getString("url"_s, target.url)
-            || !itemObject->getString("type"_s, target.type))
+            || !itemObject->getString("type"_s, debuggableTypeToString(target.type)))
             continue;
 
         targetList.append(WTFMove(target));
index daad4b2..3635e69 100644 (file)
@@ -29,6 +29,7 @@
 
 #include <JavaScriptCore/RemoteControllableTarget.h>
 #include <JavaScriptCore/RemoteInspectorConnectionClient.h>
+#include <WebCore/InspectorDebuggableType.h>
 #include <wtf/HashMap.h>
 #include <wtf/URL.h>
 #include <wtf/Vector.h>
@@ -57,7 +58,7 @@ public:
 
     struct Target {
         TargetID id;
-        String type;
+        Inspector::DebuggableType type;
         String name;
         String url;
     };
@@ -65,7 +66,7 @@ public:
     const HashMap<ConnectionID, Vector<Target>>& targets() const { return m_targets; }
     const String& backendCommandsURL() const { return m_backendCommandsURL; }
 
-    void inspect(ConnectionID, TargetID, const String&);
+    void inspect(ConnectionID, TargetID, Inspector::DebuggableType);
     void sendMessageToBackend(ConnectionID, TargetID, const String&);
     void closeFromFrontend(ConnectionID, TargetID);
 
index 3abee48..7bc18ff 100644 (file)
@@ -81,10 +81,47 @@ private:
     Function<void()> m_loadedCallback;
 };
 
+static Optional<Inspector::DebuggableType> parseDebuggableTypeFromString(const String& debuggableTypeString)
+{
+    if (debuggableTypeString == "javascript"_s)
+        return Inspector::DebuggableType::JavaScript;
+    if (debuggableTypeString == "page"_s)
+        return Inspector::DebuggableType::Page;
+    if (debuggableTypeString == "service-worker"_s)
+        return Inspector::DebuggableType::ServiceWorker;
+    if (debuggableTypeString == "web-page"_s)
+        return Inspector::DebuggableType::WebPage;
+
+    return WTF::nullopt;
+}
+
+static String debuggableTypeToString(Inspector::DebuggableType debuggableType)
+{
+    switch (debuggableType) {
+    case Inspector::DebuggableType::JavaScript:
+        return "javascript"_s;
+    case Inspector::DebuggableType::Page:
+        return "page"_s;
+    case Inspector::DebuggableType::ServiceWorker:
+        return "service-worker"_s;
+    case Inspector::DebuggableType::WebPage:
+        return "web-page"_s;
+    }
+
+    ASSERT_NOT_REACHED();
+    return String();
+}
+
 void RemoteInspectorProtocolHandler::inspect(const String& hostAndPort, ConnectionID connectionID, TargetID targetID, const String& type)
 {
+    auto debuggableType = parseDebuggableTypeFromString(type);
+    if (!debuggableType) {
+        LOG_ERROR("Unknown debuggable type: \"%s\"", type.utf8().data());
+        return;
+    }
+
     if (m_inspectorClient)
-        m_inspectorClient->inspect(connectionID, targetID, type);
+        m_inspectorClient->inspect(connectionID, targetID, debuggableType.value());
 }
 
 void RemoteInspectorProtocolHandler::runScript(const String& script)
@@ -108,7 +145,7 @@ void RemoteInspectorProtocolHandler::targetListChanged(RemoteInspectorClient& cl
                 html.append(makeString(
                     "<tbody><tr>"
                     "<td class=\"data\"><div class=\"targetname\">", target.name, "</div><div class=\"targeturl\">", target.url, "</div></td>"
-                    "<td class=\"input\"><input type=\"button\" value=\"Inspect\" onclick=\"window.webkit.messageHandlers.inspector.postMessage(\\'", connectionID, ":", target.id, ":", target.type, "\\');\"></td>"
+                    "<td class=\"input\"><input type=\"button\" value=\"Inspect\" onclick=\"window.webkit.messageHandlers.inspector.postMessage(\\'", connectionID, ":", target.id, ":", debuggableTypeToString(target.type), "\\');\"></td>"
                     "</tr></tbody>"
                 ));
             }
index db92e12..2deac97 100644 (file)
@@ -296,6 +296,12 @@ String WebInspectorProxy::inspectorBaseURL()
 #endif
 }
 
+DebuggableInfoData WebInspectorProxy::infoForLocalDebuggable()
+{
+    // FIXME <https://webkit.org/b/205537>: this should infer more useful data.
+    return DebuggableInfoData::empty();
+}
+
 unsigned WebInspectorProxy::platformInspectedWindowHeight()
 {
     RECT rect;
index f33e3b4..8f8ff3a 100644 (file)
@@ -111,6 +111,12 @@ String WebInspectorProxy::inspectorBaseURL()
     return String("resource:///org/webkit/inspector/UserInterface/");
 }
 
+DebuggableInfoData WebInspectorProxy::infoForLocalDebuggable()
+{
+    // FIXME <https://webkit.org/b/205538>: this should infer more useful data.
+    return DebuggableInfoData::empty();
+}
+
 unsigned WebInspectorProxy::platformInspectedWindowHeight()
 {
     notImplemented();
index 52b4004..2a0ccde 100644 (file)
                93BDEB01171DD7AF00BFEE1B /* WKPageLoadTypesPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 93BDEB00171DD7AF00BFEE1B /* WKPageLoadTypesPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
                93E6A4EE1BC5DD3900F8A0E7 /* _WKHitTestResult.h in Headers */ = {isa = PBXBuildFile; fileRef = 93E6A4ED1BC5DD3900F8A0E7 /* _WKHitTestResult.h */; settings = {ATTRIBUTES = (Private, ); }; };
                93F549B41E3174B7000E7239 /* WKSnapshotConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = 93F549B31E3174B7000E7239 /* WKSnapshotConfiguration.h */; settings = {ATTRIBUTES = (Public, ); }; };
+               99036AE223A949CF0000B06A /* _WKInspectorDebuggableInfoInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 99036AE123A949CE0000B06A /* _WKInspectorDebuggableInfoInternal.h */; };
+               99036AE523A958750000B06A /* APIDebuggableInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 99036AE323A958740000B06A /* APIDebuggableInfo.h */; };
+               99036AE923A970870000B06A /* DebuggableInfoData.h in Headers */ = {isa = PBXBuildFile; fileRef = 99036AE723A970870000B06A /* DebuggableInfoData.h */; };
                990D28AB1C6420C600986977 /* _WKAutomationSession.h in Headers */ = {isa = PBXBuildFile; fileRef = 990D28A71C6404B000986977 /* _WKAutomationSession.h */; settings = {ATTRIBUTES = (Private, ); }; };
                990D28AC1C6420CF00986977 /* _WKAutomationSessionDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 990D28A81C6404B000986977 /* _WKAutomationSessionDelegate.h */; settings = {ATTRIBUTES = (Private, ); }; };
                990D28B11C65208D00986977 /* _WKAutomationSessionInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 990D28AF1C65203900986977 /* _WKAutomationSessionInternal.h */; };
                990D28BB1C6539D300986977 /* AutomationSessionClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 990D28B71C6539A000986977 /* AutomationSessionClient.h */; };
                990D28C01C6553F100986977 /* APIAutomationSessionClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 990D28B31C6526D400986977 /* APIAutomationSessionClient.h */; };
                990E1E092384AA57004602DF /* _WKRemoteWebInspectorViewControllerPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 990E1E082384A88B004602DF /* _WKRemoteWebInspectorViewControllerPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               991F492F23A812C60054642B /* _WKInspectorDebuggableInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 991F492D23A812C50054642B /* _WKInspectorDebuggableInfo.h */; settings = {ATTRIBUTES = (Private, ); }; };
                99249AD51F1F1E5600B62FBB /* AutomationFrontendDispatchers.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 99249AD31F1F1E3300B62FBB /* AutomationFrontendDispatchers.cpp */; };
                99249AD61F1F1E5F00B62FBB /* AutomationFrontendDispatchers.h in Headers */ = {isa = PBXBuildFile; fileRef = 99249AD41F1F1E3300B62FBB /* AutomationFrontendDispatchers.h */; };
                994BADF41F7D781400B571E7 /* WKInspectorViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 994BADF11F7D77EA00B571E7 /* WKInspectorViewController.h */; };
                93E6A4ED1BC5DD3900F8A0E7 /* _WKHitTestResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKHitTestResult.h; sourceTree = "<group>"; };
                93F549B31E3174B7000E7239 /* WKSnapshotConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKSnapshotConfiguration.h; sourceTree = "<group>"; };
                93F549B51E3174DA000E7239 /* WKSnapshotConfiguration.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKSnapshotConfiguration.mm; sourceTree = "<group>"; };
+               99036AE123A949CE0000B06A /* _WKInspectorDebuggableInfoInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKInspectorDebuggableInfoInternal.h; sourceTree = "<group>"; };
+               99036AE323A958740000B06A /* APIDebuggableInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIDebuggableInfo.h; sourceTree = "<group>"; };
+               99036AE423A958740000B06A /* APIDebuggableInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = APIDebuggableInfo.cpp; sourceTree = "<group>"; };
+               99036AE723A970870000B06A /* DebuggableInfoData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DebuggableInfoData.h; sourceTree = "<group>"; };
+               99036AE823A970870000B06A /* DebuggableInfoData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DebuggableInfoData.cpp; sourceTree = "<group>"; };
                990657311F323CBF00944F9C /* FindNodes.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = FindNodes.js; sourceTree = "<group>"; };
                990657321F323CBF00944F9C /* FormElementClear.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = FormElementClear.js; sourceTree = "<group>"; };
                990657331F323CBF00944F9C /* ElementDisplayed.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = ElementDisplayed.js; sourceTree = "<group>"; };
                990D28B71C6539A000986977 /* AutomationSessionClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AutomationSessionClient.h; sourceTree = "<group>"; };
                990D28B81C6539A000986977 /* AutomationSessionClient.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AutomationSessionClient.mm; sourceTree = "<group>"; };
                990E1E082384A88B004602DF /* _WKRemoteWebInspectorViewControllerPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKRemoteWebInspectorViewControllerPrivate.h; sourceTree = "<group>"; };
+               991F492D23A812C50054642B /* _WKInspectorDebuggableInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKInspectorDebuggableInfo.h; sourceTree = "<group>"; };
+               991F492E23A812C60054642B /* _WKInspectorDebuggableInfo.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = _WKInspectorDebuggableInfo.mm; sourceTree = "<group>"; };
                99249AD31F1F1E3300B62FBB /* AutomationFrontendDispatchers.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = AutomationFrontendDispatchers.cpp; path = DerivedSources/WebKit2/AutomationFrontendDispatchers.cpp; sourceTree = BUILT_PRODUCTS_DIR; };
                99249AD41F1F1E3300B62FBB /* AutomationFrontendDispatchers.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = AutomationFrontendDispatchers.h; path = DerivedSources/WebKit2/AutomationFrontendDispatchers.h; sourceTree = BUILT_PRODUCTS_DIR; };
                9946EF851E7B026600541E79 /* WebAutomationSessionIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebAutomationSessionIOS.mm; sourceTree = "<group>"; };
                                5106D7BF18BDBE73000AB166 /* ContextMenuContextData.cpp */,
                                5106D7C018BDBE73000AB166 /* ContextMenuContextData.h */,
                                99F642D21FABE378009621E9 /* CoordinateSystem.h */,
+                               99036AE823A970870000B06A /* DebuggableInfoData.cpp */,
+                               99036AE723A970870000B06A /* DebuggableInfoData.h */,
                                2D7FD190223C730F007887F1 /* DocumentEditingContext.h */,
                                2D7FD191223C7310007887F1 /* DocumentEditingContext.mm */,
                                C517388012DF8F4F00EE3F47 /* DragControllerAction.h */,
                                37A64E5418F38E3C00EB30F1 /* _WKInputDelegate.h */,
                                5CAFDE422130843500B1F7E1 /* _WKInspector.h */,
                                5CAFDE432130843600B1F7E1 /* _WKInspector.mm */,
+                               991F492D23A812C50054642B /* _WKInspectorDebuggableInfo.h */,
+                               991F492E23A812C60054642B /* _WKInspectorDebuggableInfo.mm */,
+                               99036AE123A949CE0000B06A /* _WKInspectorDebuggableInfoInternal.h */,
                                5CAFDE442130843600B1F7E1 /* _WKInspectorInternal.h */,
                                9979CA57237F49F00039EC05 /* _WKInspectorPrivate.h */,
                                A5C0F0AA2000656E00536536 /* _WKInspectorWindow.h */,
                                5CE0C367229F2D3E003695F0 /* APIContextMenuElementInfo.h */,
                                5C5D238A227A1D9B000B9BDA /* APICustomHeaderFields.h */,
                                7A821F4F1E2F7A5C00604577 /* APICustomProtocolManagerClient.h */,
+                               99036AE423A958740000B06A /* APIDebuggableInfo.cpp */,
+                               99036AE323A958740000B06A /* APIDebuggableInfo.h */,
                                83891B621A68B3420030F386 /* APIDiagnosticLoggingClient.h */,
                                1F7D36C018DA513F00D9D659 /* APIDownloadClient.h */,
                                317FE7C11C487A6600A0CA89 /* APIExperimentalFeature.cpp */,
                                510F59101DDE296900412FF5 /* _WKIconLoadingDelegate.h in Headers */,
                                37A64E5518F38E3C00EB30F1 /* _WKInputDelegate.h in Headers */,
                                5CAFDE452130846300B1F7E1 /* _WKInspector.h in Headers */,
+                               991F492F23A812C60054642B /* _WKInspectorDebuggableInfo.h in Headers */,
+                               99036AE223A949CF0000B06A /* _WKInspectorDebuggableInfoInternal.h in Headers */,
                                5CAFDE472130846A00B1F7E1 /* _WKInspectorInternal.h in Headers */,
                                9979CA58237F49F10039EC05 /* _WKInspectorPrivate.h in Headers */,
                                A5C0F0AB2000658200536536 /* _WKInspectorWindow.h in Headers */,
                                076E884E1A13CADF005E90FC /* APIContextMenuClient.h in Headers */,
                                7A821F501E2F7A7500604577 /* APICustomProtocolManagerClient.h in Headers */,
                                51578B831209ECEF00A37C4A /* APIData.h in Headers */,
+                               99036AE523A958750000B06A /* APIDebuggableInfo.h in Headers */,
                                83891B631A68B3420030F386 /* APIDiagnosticLoggingClient.h in Headers */,
                                7C1BA33E1A4A0E600043E249 /* APIDictionary.h in Headers */,
                                1F7D36C118DA513F00D9D659 /* APIDownloadClient.h in Headers */,
                                570DAACA230385FD00E8FC04 /* CtapNfcDriver.h in Headers */,
                                C55F91711C59676E0029E92D /* DataDetectionResult.h in Headers */,
                                1AC75380183BE50F0072CB15 /* DataReference.h in Headers */,
+                               99036AE923A970870000B06A /* DebuggableInfoData.h in Headers */,
                                BC032DA610F437D10058C15A /* Decoder.h in Headers */,
                                57DCEDAB214C60090016B847 /* DeviceIdentitySPI.h in Headers */,
                                07297F9F1C17BBEA015F0735 /* DeviceIdHashSaltStorage.h in Headers */,
index 326a5d1..1fa907c 100644 (file)
@@ -52,9 +52,9 @@ RemoteWebInspectorUI::RemoteWebInspectorUI(WebPage& page)
 {
 }
 
-void RemoteWebInspectorUI::initialize(const String& debuggableType, const String& backendCommandsURL)
+void RemoteWebInspectorUI::initialize(DebuggableInfoData&& debuggableInfo, const String& backendCommandsURL)
 {
-    m_debuggableType = debuggableType;
+    m_debuggableInfo = WTFMove(debuggableInfo);
     m_backendCommandsURL = backendCommandsURL;
 
     m_page.corePage()->inspectorController().setInspectorFrontendClient(this);
@@ -170,6 +170,31 @@ void RemoteWebInspectorUI::showCertificate(const CertificateInfo& certificateInf
     WebProcess::singleton().parentProcessConnection()->send(Messages::RemoteWebInspectorProxy::ShowCertificate(certificateInfo), m_page.identifier());
 }
 
+Inspector::DebuggableType RemoteWebInspectorUI::debuggableType() const
+{
+    return m_debuggableInfo.debuggableType;
+}
+
+String RemoteWebInspectorUI::targetPlatformName() const
+{
+    return m_debuggableInfo.targetPlatformName;
+}
+
+String RemoteWebInspectorUI::targetBuildVersion() const
+{
+    return m_debuggableInfo.targetBuildVersion;
+}
+
+String RemoteWebInspectorUI::targetProductVersion() const
+{
+    return m_debuggableInfo.targetProductVersion;
+}
+
+bool RemoteWebInspectorUI::targetIsSimulator() const
+{
+    return m_debuggableInfo.targetIsSimulator;
+}
+
 #if ENABLE(INSPECTOR_TELEMETRY)
 bool RemoteWebInspectorUI::supportsDiagnosticLogging()
 {
index df849fc..b4ae1c1 100644 (file)
@@ -25,6 +25,7 @@
 
 #pragma once
 
+#include "DebuggableInfoData.h"
 #include "MessageReceiver.h"
 #include "WebInspectorFrontendAPIDispatcher.h"
 #include <WebCore/InspectorFrontendClient.h>
@@ -48,7 +49,7 @@ public:
     void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
 
     // Called by RemoteWebInspectorUI messages
-    void initialize(const String& debuggableType, const String& backendCommandsURL);
+    void initialize(DebuggableInfoData&&, const String& backendCommandsURL);
     void didSave(const String& url);
     void didAppend(const String& url);
     void sendMessageToFrontend(const String&);
@@ -67,7 +68,11 @@ public:
     bool isRemote() const final { return true; }
     String localizedStringsURL() const override;
     String backendCommandsURL() const final { return m_backendCommandsURL; }
-    String debuggableType() const final { return m_debuggableType; }
+    Inspector::DebuggableType debuggableType() const override;
+    String targetPlatformName() const override;
+    String targetBuildVersion() const override;
+    String targetProductVersion() const override;
+    bool targetIsSimulator() const override;
 
     WebCore::UserInterfaceLayoutDirection userInterfaceLayoutDirection() const override;
 
@@ -102,7 +107,7 @@ private:
     WebPage& m_page;
     WebInspectorFrontendAPIDispatcher m_frontendAPIDispatcher;
     RefPtr<WebCore::InspectorFrontendHost> m_frontendHost;
-    String m_debuggableType;
+    DebuggableInfoData m_debuggableInfo;
     String m_backendCommandsURL;
 
 #if ENABLE(INSPECTOR_TELEMETRY)
index 27e9e50..2bf7e4c 100644 (file)
@@ -21,7 +21,7 @@
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 messages -> RemoteWebInspectorUI {
-    Initialize(String debuggableType, String backendCommandsURL)
+    Initialize(struct WebKit::DebuggableInfoData debuggableInfo, String backendCommandsURL)
 
 #if ENABLE(INSPECTOR_TELEMETRY)
     SetDiagnosticLoggingAvailable(bool available)
index a1efc28..0864461 100644 (file)
@@ -51,6 +51,7 @@ Ref<WebInspectorUI> WebInspectorUI::create(WebPage& page)
 WebInspectorUI::WebInspectorUI(WebPage& page)
     : m_page(page)
     , m_frontendAPIDispatcher(page)
+    , m_debuggableInfo(DebuggableInfoData::empty())
 {
     RuntimeEnabledFeatures::sharedFeatures().setInspectorAdditionsEnabled(true);
     RuntimeEnabledFeatures::sharedFeatures().setImageBitmapEnabled(true);
@@ -59,13 +60,15 @@ WebInspectorUI::WebInspectorUI(WebPage& page)
 #endif
 }
 
-void WebInspectorUI::establishConnection(WebPageProxyIdentifier inspectedPageIdentifier, bool underTest, unsigned inspectionLevel)
+void WebInspectorUI::establishConnection(WebPageProxyIdentifier inspectedPageIdentifier, const DebuggableInfoData& debuggableInfo, bool underTest, unsigned inspectionLevel)
 {
     m_inspectedPageIdentifier = inspectedPageIdentifier;
-    m_frontendAPIDispatcher.reset();
+    m_debuggableInfo = debuggableInfo;
     m_underTest = underTest;
     m_inspectionLevel = inspectionLevel;
 
+    m_frontendAPIDispatcher.reset();
+
     m_frontendController = &m_page.corePage()->inspectorController();
     m_frontendController->setInspectorFrontendClient(this);
 
@@ -376,4 +379,19 @@ void WebInspectorUI::sendMessageToBackend(const String& message)
     WebProcess::singleton().parentProcessConnection()->send(Messages::WebInspectorProxy::SendMessageToBackend(message), m_inspectedPageIdentifier);
 }
 
+String WebInspectorUI::targetPlatformName() const
+{
+    return m_debuggableInfo.targetPlatformName;
+}
+
+String WebInspectorUI::targetBuildVersion() const
+{
+    return m_debuggableInfo.targetBuildVersion;
+}
+
+String WebInspectorUI::targetProductVersion() const
+{
+    return m_debuggableInfo.targetProductVersion;
+}
+
 } // namespace WebKit
index 4c55239..639f21c 100644 (file)
 #pragma once
 
 #include "Connection.h"
+#include "DebuggableInfoData.h"
 #include "WebInspectorFrontendAPIDispatcher.h"
 #include "WebPageProxyIdentifier.h"
+#include <WebCore/InspectorDebuggableType.h>
 #include <WebCore/InspectorFrontendClient.h>
 #include <WebCore/InspectorFrontendHost.h>
 
@@ -53,7 +55,7 @@ public:
     void didReceiveInvalidMessage(IPC::Connection&, IPC::StringReference, IPC::StringReference) override { closeWindow(); }
 
     // Called by WebInspectorUI messages
-    void establishConnection(WebPageProxyIdentifier inspectedPageIdentifier, bool underTest, unsigned inspectionLevel);
+    void establishConnection(WebPageProxyIdentifier inspectedPageIdentifier, const DebuggableInfoData&, bool underTest, unsigned inspectionLevel);
     void updateConnection();
 
     void showConsole();
@@ -96,7 +98,11 @@ public:
     bool isRemote() const final { return false; }
     String localizedStringsURL() const override;
     String backendCommandsURL() const final { return String(); }
-    String debuggableType() const final { return "web-page"_s; }
+    Inspector::DebuggableType debuggableType() const final { return Inspector::DebuggableType::WebPage; }
+    String targetPlatformName() const override;
+    String targetBuildVersion() const override;
+    String targetProductVersion() const override;
+    bool targetIsSimulator() const final { return false; }
     unsigned inspectionLevel() const override { return m_inspectionLevel; }
 
     void bringToFront() override;
@@ -148,6 +154,7 @@ private:
 
     WebPageProxyIdentifier m_inspectedPageIdentifier;
     bool m_underTest { false };
+    DebuggableInfoData m_debuggableInfo;
     bool m_dockingUnavailable { false };
     bool m_isVisible { false };
 #if ENABLE(INSPECTOR_TELEMETRY)
index b4a19b3..94f1385 100644 (file)
@@ -21,7 +21,7 @@
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 messages -> WebInspectorUI {
-    EstablishConnection(WebKit::WebPageProxyIdentifier inspectedPageIdentifier, bool underTest, unsigned inspectionLevel)
+    EstablishConnection(WebKit::WebPageProxyIdentifier inspectedPageIdentifier, struct WebKit::DebuggableInfoData debuggableInfo, bool underTest, unsigned inspectionLevel)
     UpdateConnection()
 
     AttachedBottom()
index d269d5b..653e910 100644 (file)
@@ -29,6 +29,7 @@
 #import <JavaScriptCore/InspectorFrontendChannel.h>
 #import <WebCore/FloatRect.h>
 #import <WebCore/InspectorClient.h>
+#import <WebCore/InspectorDebuggableType.h>
 #import <WebCore/InspectorFrontendClientLocal.h>
 #import <wtf/Forward.h>
 #import <wtf/HashMap.h>
@@ -117,8 +118,13 @@ public:
 
     void startWindowDrag() override;
 
-    String debuggableType() const final { return "page"_s; };
     String localizedStringsURL() const override;
+    Inspector::DebuggableType debuggableType() const final { return Inspector::DebuggableType::Page; };
+    String targetPlatformName() const final { return "macOS"_s; };
+    String targetBuildVersion() const final { return "Unknown"_s; };
+    String targetProductVersion() const final { return "Unknown"_s; };
+    bool targetIsSimulator() const final { return false; }
+
 
     void bringToFront() override;
     void closeWindow() override;
index 69628cb..42b7576 100644 (file)
@@ -1,3 +1,13 @@
+2019-12-21  Brian Burg  <bburg@apple.com>
+
+        Web Inspector: add InspectedTargetTypes diagnostic event and related hooks
+        https://bugs.webkit.org/show_bug.cgi?id=205174
+        <rdar://problem/57887953>
+
+        Reviewed by Devin Rousso.
+
+        * WebCoreSupport/WebInspectorClient.h:
+
 2019-12-20  Brian Burg  <bburg@apple.com>
 
         Web Inspector: convert some InspectorFrontendHost methods to getters
index d5f5d65..27740ed 100644 (file)
@@ -32,6 +32,7 @@
 #include <JavaScriptCore/InspectorFrontendChannel.h>
 #include <WebCore/COMPtr.h>
 #include <WebCore/InspectorClient.h>
+#include <WebCore/InspectorDebuggableType.h>
 #include <WebCore/InspectorFrontendClientLocal.h>
 #include <WebCore/WindowMessageListener.h>
 #include <windows.h>
@@ -104,7 +105,11 @@ public:
     void frontendLoaded() override;
 
     WTF::String localizedStringsURL() const override;
-    String debuggableType() const final { return "page"_s; };
+    Inspector::DebuggableType debuggableType() const final { return Inspector::DebuggableType::Page; };
+    String targetPlatformName() const final { return "Windows"_s; }
+    String targetBuildVersion() const final { return "Unknown"_s; }
+    String targetProductVersion() const final { return "Unknown"_s; }
+    bool targetIsSimulator() const final { return false; }
 
     void bringToFront() override;
     void closeWindow() override;