ITMLKit Inspector: Elements tab does not show DOM Tree
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 20 Dec 2018 20:08:27 +0000 (20:08 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 20 Dec 2018 20:08:27 +0000 (20:08 +0000)
https://bugs.webkit.org/show_bug.cgi?id=192910
<rdar://problem/46680585>

Patch by Joseph Pecoraro <pecoraro@apple.com> on 2018-12-20
Reviewed by Brian Burg.

Source/JavaScriptCore:

* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
(Inspector::InspectorAgent::enable):
(Inspector::InspectorAgent::activateExtraDomain):
(Inspector::InspectorAgent::activateExtraDomains):
Send extra domains immediately instead of waiting until
the Inspector domain is enabled. This will ensure the frontend
hears about extra augmented domains before augmenting agents
get a chance to send any messages.

Source/WebInspectorUI:

* UserInterface/Protocol/Connection.js:
(InspectorBackend.Connection.prototype._dispatchEvent):
Better logging for errors.

* UserInterface/Base/Main.js:
* UserInterface/Controllers/AppController.js:
(WI.AppController.prototype.activateExtraDomains):
Let Targets get a chance to activate extra domains.
Perform a little more work in these cases.

* UserInterface/Protocol/Target.js:
(WI.Target):
(WI.Target.prototype.activateExtraDomain):
Expose agents for domains that are active.
Expose agents for extra domains when they are activated.

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

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/inspector/agents/InspectorAgent.cpp
Source/JavaScriptCore/inspector/agents/InspectorAgent.h
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Base/Main.js
Source/WebInspectorUI/UserInterface/Controllers/AppController.js
Source/WebInspectorUI/UserInterface/Protocol/Connection.js
Source/WebInspectorUI/UserInterface/Protocol/Target.js

index 11bffa4..d439e4b 100644 (file)
@@ -1,3 +1,21 @@
+2018-12-20  Joseph Pecoraro  <pecoraro@apple.com>
+
+        ITMLKit Inspector: Elements tab does not show DOM Tree
+        https://bugs.webkit.org/show_bug.cgi?id=192910
+        <rdar://problem/46680585>
+
+        Reviewed by Brian Burg.
+
+        * inspector/agents/InspectorAgent.h:
+        * inspector/agents/InspectorAgent.cpp:
+        (Inspector::InspectorAgent::enable):
+        (Inspector::InspectorAgent::activateExtraDomain):
+        (Inspector::InspectorAgent::activateExtraDomains):
+        Send extra domains immediately instead of waiting until
+        the Inspector domain is enabled. This will ensure the frontend
+        hears about extra augmented domains before augmenting agents
+        get a chance to send any messages.
+
 2018-12-20  Mark Lam  <mark.lam@apple.com>
 
         Fix a typo in slow_path_construct_arityCheck and operationConstructArityCheck.
index f0a0f83..c770e6d 100644 (file)
@@ -68,11 +68,6 @@ void InspectorAgent::enable(ErrorString&)
     if (m_pendingInspectData.first)
         inspect(m_pendingInspectData.first.copyRef(), m_pendingInspectData.second.copyRef());
 
-#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS)
-    if (m_pendingExtraDomainsData)
-        m_frontendDispatcher->activateExtraDomains(m_pendingExtraDomainsData);
-#endif
-
     for (auto& testCommand : m_pendingEvaluateTestCommands)
         m_frontendDispatcher->evaluateForTestInFrontend(testCommand);
 
@@ -113,12 +108,8 @@ void InspectorAgent::evaluateForTestInFrontend(const String& script)
 #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS)
 void InspectorAgent::activateExtraDomain(const String& domainName)
 {
-    if (!m_enabled) {
-        if (!m_pendingExtraDomainsData)
-            m_pendingExtraDomainsData = JSON::ArrayOf<String>::create();
-        m_pendingExtraDomainsData->addItem(domainName);
+    if (!m_enabled)
         return;
-    }
 
     auto domainNames = JSON::ArrayOf<String>::create();
     domainNames->addItem(domainName);
@@ -134,10 +125,7 @@ void InspectorAgent::activateExtraDomains(const Vector<String>& extraDomains)
     for (auto domainName : extraDomains)
         domainNames->addItem(domainName);
 
-    if (!m_enabled)
-        m_pendingExtraDomainsData = WTFMove(domainNames);
-    else
-        m_frontendDispatcher->activateExtraDomains(WTFMove(domainNames));
+    m_frontendDispatcher->activateExtraDomains(WTFMove(domainNames));
 }
 #endif
 
index d2a6d5b..26119c0 100644 (file)
@@ -71,9 +71,6 @@ private:
 
     Vector<String> m_pendingEvaluateTestCommands;
     std::pair<RefPtr<Protocol::Runtime::RemoteObject>, RefPtr<JSON::Object>> m_pendingInspectData;
-#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS)
-    RefPtr<JSON::ArrayOf<String>> m_pendingExtraDomainsData;
-#endif
     bool m_enabled { false };
 };
 
index b4d500d..b00f0bf 100644 (file)
@@ -1,5 +1,29 @@
 2018-12-20  Joseph Pecoraro  <pecoraro@apple.com>
 
+        ITMLKit Inspector: Elements tab does not show DOM Tree
+        https://bugs.webkit.org/show_bug.cgi?id=192910
+        <rdar://problem/46680585>
+
+        Reviewed by Brian Burg.
+
+        * UserInterface/Protocol/Connection.js:
+        (InspectorBackend.Connection.prototype._dispatchEvent):
+        Better logging for errors.
+
+        * UserInterface/Base/Main.js:
+        * UserInterface/Controllers/AppController.js:
+        (WI.AppController.prototype.activateExtraDomains):
+        Let Targets get a chance to activate extra domains.
+        Perform a little more work in these cases.
+
+        * UserInterface/Protocol/Target.js:
+        (WI.Target):
+        (WI.Target.prototype.activateExtraDomain):
+        Expose agents for domains that are active.
+        Expose agents for extra domains when they are activated.
+
+2018-12-20  Joseph Pecoraro  <pecoraro@apple.com>
+
         ITMLKit Inspector: Computed Style Box Model section throws exceptions
         https://bugs.webkit.org/show_bug.cgi?id=192911
         <rdar://problem/46861112>
index b10fc91..251cef7 100644 (file)
@@ -754,8 +754,19 @@ WI.activateExtraDomains = function(domains)
 {
     this.notifications.dispatchEventToListeners(WI.Notification.ExtraDomainsActivated, {domains});
 
-    if (WI.mainTarget && WI.mainTarget.CSSAgent)
-        WI.CSSCompletions.initializeCSSCompletions(WI.assumingMainTarget());
+    if (WI.mainTarget) {
+        if (!WI.pageTarget && WI.mainTarget.DOMAgent)
+            WI.pageTarget = WI.mainTarget;
+
+        if (WI.mainTarget.CSSAgent)
+            WI.CSSCompletions.initializeCSSCompletions(WI.assumingMainTarget());
+
+        if (WI.mainTarget.DOMAgent)
+            WI.domManager.ensureDocument();
+
+        if (WI.mainTarget.PageAgent)
+            WI.networkManager.initializeTarget(WI.mainTarget);
+    }
 
     this._updateReloadToolbarButton();
     this._updateDownloadToolbarButton();
index b939623..32469af 100644 (file)
@@ -65,10 +65,17 @@ WI.AppController = class AppController extends WI.AppControllerBase
 
         this._hasExtraDomains = true;
 
+        console.assert(WI.mainTarget instanceof WI.DirectBackendTarget);
+        console.assert(WI.mainTarget.type === WI.Target.Type.JSContext);
+        console.assert(WI.sharedApp.debuggableType === WI.DebuggableType.JavaScript);
+        console.assert(WI.targets.length === 1);
+
         for (let domain of domains) {
             let agent = InspectorBackend.activateDomain(domain);
             if (agent.enable)
                 agent.enable();
+            for (let target of WI.targets)
+                target.activateExtraDomain(domain);
         }
 
         // FIXME: all code within WI.activateExtraDomains should be distributed elsewhere.
index 4e2e403..d137f88 100644 (file)
@@ -165,19 +165,19 @@ InspectorBackend.Connection = class InspectorBackendConnection
         let qualifiedName = messageObject["method"];
         let [domainName, eventName] = qualifiedName.split(".");
         if (!(domainName in this._agents)) {
-            console.error("Protocol Error: Attempted to dispatch method '" + eventName + "' for non-existing domain '" + domainName + "'");
+            console.error("Protocol Error: Attempted to dispatch method '" + eventName + "' for non-existing domain '" + domainName + "'", messageObject);
             return;
         }
 
         let agent = this._agents[domainName];
         if (!agent.active) {
-            console.error("Protocol Error: Attempted to dispatch method for domain '" + domainName + "' which exists but is not active.");
+            console.error("Protocol Error: Attempted to dispatch method for domain '" + domainName + "' which exists but is not active.", messageObject);
             return;
         }
 
         let event = agent.getEvent(eventName);
         if (!event) {
-            console.error("Protocol Error: Attempted to dispatch an unspecified method '" + qualifiedName + "'");
+            console.error("Protocol Error: Attempted to dispatch an unspecified method '" + qualifiedName + "'", messageObject);
             return;
         }
 
index 3382c63..dc79952 100644 (file)
@@ -43,8 +43,11 @@ WI.Target = class Target extends WI.Object
         // supported by the target.
         this._agents = {};
         const supportedDomains = this._supportedDomainsForTargetType(this._type);
-        for (let domain of supportedDomains)
-            this._agents[domain] = this._connection._agents[domain];
+        for (let domain of supportedDomains) {
+            let agent = this._connection._agents[domain];
+            if (agent && agent.active)
+                this._agents[domain] = agent;
+        }
 
         this._connection.target = this;
 
@@ -97,6 +100,13 @@ WI.Target = class Target extends WI.Object
         });
     }
 
+    activateExtraDomain(domain)
+    {
+        let agent = this._connection._agents[domain];
+        if (agent && agent.active)
+            this._agents[domain] = agent;
+    }
+
     // Agents
 
     get ApplicationCacheAgent() { return this._agents.ApplicationCache; }