Title: [221765] trunk
Revision
221765
Author
[email protected]
Date
2017-09-07 15:22:38 -0700 (Thu, 07 Sep 2017)

Log Message

Augmented Inspector: Provide a way to inspect a DOM Node (DOM.inspect)
https://bugs.webkit.org/show_bug.cgi?id=176563
<rdar://problem/19639583>

Patch by Joseph Pecoraro <[email protected]> on 2017-09-07
Reviewed by Matt Baker.

Source/_javascript_Core:

* inspector/protocol/DOM.json:
Add an event that is useful for augmented inspectors to inspect
a node. Web pages will still prefer Inspector.inspect.

Source/WebInspectorUI:

* UserInterface/Base/Main.js:
(WI.contentLoaded):
Always create the element search toolbar icon. Only show it if the DOM domain
is available. With augmented agents the DOM domain may be activated later.

* UserInterface/Protocol/DOMObserver.js:
(WI.DOMObserver.prototype.inspect):
Select the node in the DOM tree outline.

LayoutTests:

* inspector/dom/inspect-expected.txt: Added.
* inspector/dom/inspect.html: Added.
Test the frontend on receiving DOM.inspect events.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (221764 => 221765)


--- trunk/LayoutTests/ChangeLog	2017-09-07 22:20:39 UTC (rev 221764)
+++ trunk/LayoutTests/ChangeLog	2017-09-07 22:22:38 UTC (rev 221765)
@@ -1,3 +1,15 @@
+2017-09-07  Joseph Pecoraro  <[email protected]>
+
+        Augmented Inspector: Provide a way to inspect a DOM Node (DOM.inspect)
+        https://bugs.webkit.org/show_bug.cgi?id=176563
+        <rdar://problem/19639583>
+
+        Reviewed by Matt Baker.
+
+        * inspector/dom/inspect-expected.txt: Added.
+        * inspector/dom/inspect.html: Added.
+        Test the frontend on receiving DOM.inspect events.
+
 2017-09-07  Per Arne Vollan  <[email protected]>
 
         Marked http/tests/misc/delete-frame-during-readystatechange.html as flaky on Windows.

Added: trunk/LayoutTests/inspector/dom/inspect-expected.txt (0 => 221765)


--- trunk/LayoutTests/inspector/dom/inspect-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/inspector/dom/inspect-expected.txt	2017-09-07 22:22:38 UTC (rev 221765)
@@ -0,0 +1,10 @@
+Test for DOM.inspect.
+
+
+== Running test suite: DOM.inspect
+-- Running test case: DOM.inspect.valid
+PASS: DOMNodeWasInspected event
+
+-- Running test case: DOM.inspect.invalid
+PASS: No error
+

Added: trunk/LayoutTests/inspector/dom/inspect.html (0 => 221765)


--- trunk/LayoutTests/inspector/dom/inspect.html	                        (rev 0)
+++ trunk/LayoutTests/inspector/dom/inspect.html	2017-09-07 22:22:38 UTC (rev 221765)
@@ -0,0 +1,55 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script>
+function test()
+{
+    let documentNode;
+
+    function dispatchDOMInspectEvent(nodeId) {
+        WI.dispatchMessageFromBackend({
+            "method": "DOM.inspect",
+            "params": {"nodeId": nodeId},
+        });
+    }
+
+    let suite = InspectorTest.createAsyncSuite("DOM.inspect");
+
+    suite.addTestCase({
+        name: "DOM.inspect.valid",
+        description: "Event given a valid nodeId should select it.",
+        test(resolve, reject) {
+            WI.domTreeManager.querySelector(documentNode.id, "#element-to-select", (nodeId) => {
+                dispatchDOMInspectEvent(nodeId);
+            });
+            WI.domTreeManager.awaitEvent(WI.DOMTreeManager.Event.DOMNodeWasInspected).then((event) => {
+                InspectorTest.pass("DOMNodeWasInspected event");
+                resolve();
+            });
+        }
+    });
+
+    suite.addTestCase({
+        name: "DOM.inspect.invalid",
+        description: "Event given an ivalid nodeId should not cause an exception.",
+        test(resolve, reject) {
+            dispatchDOMInspectEvent("DOES_NOT_EXIST");
+            setTimeout(() => {
+                InspectorTest.pass("No error");
+                resolve()
+            });
+        }
+    });
+
+    WI.domTreeManager.requestDocument((node) => {
+        documentNode = node;
+        suite.runTestCasesAndFinish();
+    });
+}
+</script>
+</head>
+<body _onload_="runTest()">
+<p id="element-to-select">Test for DOM.inspect.</p>
+</body>
+</html>

Modified: trunk/Source/_javascript_Core/ChangeLog (221764 => 221765)


--- trunk/Source/_javascript_Core/ChangeLog	2017-09-07 22:20:39 UTC (rev 221764)
+++ trunk/Source/_javascript_Core/ChangeLog	2017-09-07 22:22:38 UTC (rev 221765)
@@ -1,3 +1,15 @@
+2017-09-07  Joseph Pecoraro  <[email protected]>
+
+        Augmented Inspector: Provide a way to inspect a DOM Node (DOM.inspect)
+        https://bugs.webkit.org/show_bug.cgi?id=176563
+        <rdar://problem/19639583>
+
+        Reviewed by Matt Baker.
+
+        * inspector/protocol/DOM.json:
+        Add an event that is useful for augmented inspectors to inspect
+        a node. Web pages will still prefer Inspector.inspect.
+
 2017-09-06  Yusuke Suzuki  <[email protected]>
 
         [JSC] Remove "malloc" and "free" from JSC/API

Modified: trunk/Source/_javascript_Core/inspector/protocol/DOM.json (221764 => 221765)


--- trunk/Source/_javascript_Core/inspector/protocol/DOM.json	2017-09-07 22:20:39 UTC (rev 221764)
+++ trunk/Source/_javascript_Core/inspector/protocol/DOM.json	2017-09-07 22:22:38 UTC (rev 221765)
@@ -483,6 +483,13 @@
             "description": "Fired when <code>Document</code> has been totally updated. Node ids are no longer valid."
         },
         {
+            "name": "inspect",
+            "description": "Inspect a particular node.",
+            "parameters": [
+                { "name": "nodeId", "$ref": "NodeId", "description": "Equivalent of Inspector.inspect but with a nodeId instead of a RemoteObject. Useful for augmented contexts." }
+            ]
+        },
+        {
             "name": "setChildNodes",
             "description": "Fired when backend wants to provide client with the missing DOM structure. This happens upon most of the calls requesting node ids.",
             "parameters": [

Modified: trunk/Source/WebInspectorUI/ChangeLog (221764 => 221765)


--- trunk/Source/WebInspectorUI/ChangeLog	2017-09-07 22:20:39 UTC (rev 221764)
+++ trunk/Source/WebInspectorUI/ChangeLog	2017-09-07 22:22:38 UTC (rev 221765)
@@ -1,3 +1,20 @@
+2017-09-07  Joseph Pecoraro  <[email protected]>
+
+        Augmented Inspector: Provide a way to inspect a DOM Node (DOM.inspect)
+        https://bugs.webkit.org/show_bug.cgi?id=176563
+        <rdar://problem/19639583>
+
+        Reviewed by Matt Baker.
+
+        * UserInterface/Base/Main.js:
+        (WI.contentLoaded):
+        Always create the element search toolbar icon. Only show it if the DOM domain
+        is available. With augmented agents the DOM domain may be activated later.
+
+        * UserInterface/Protocol/DOMObserver.js:
+        (WI.DOMObserver.prototype.inspect):
+        Select the node in the DOM tree outline.
+
 2017-09-07  Devin Rousso  <[email protected]>
 
         Web Inspector: Canvas RecordingAction tree outline virtualization is broken

Modified: trunk/Source/WebInspectorUI/UserInterface/Base/Main.js (221764 => 221765)


--- trunk/Source/WebInspectorUI/UserInterface/Base/Main.js	2017-09-07 22:20:39 UTC (rev 221764)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/Main.js	2017-09-07 22:22:38 UTC (rev 221765)
@@ -389,17 +389,15 @@
     this._downloadToolbarButton = new WI.ButtonToolbarItem("download", WI.UIString("Download Web Archive"), "Images/DownloadArrow.svg");
     this._downloadToolbarButton.addEventListener(WI.ButtonNavigationItem.Event.Clicked, this._downloadWebArchive, this);
 
+    var toolTip = WI.UIString("Start element selection (%s)").format(WI._inspectModeKeyboardShortcut.displayName);
+    var activatedToolTip = WI.UIString("Stop element selection (%s)").format(WI._inspectModeKeyboardShortcut.displayName);
+    this._inspectModeToolbarButton = new WI.ActivateButtonToolbarItem("inspect", toolTip, activatedToolTip, "Images/Crosshair.svg");
+    this._inspectModeToolbarButton.addEventListener(WI.ButtonNavigationItem.Event.Clicked, this._toggleInspectMode, this);
+
     this._updateReloadToolbarButton();
     this._updateDownloadToolbarButton();
+    this._updateInspectModeToolbarButton();
 
-    // The toolbar button for node inspection.
-    if (this.debuggableType === WI.DebuggableType.Web) {
-        var toolTip = WI.UIString("Start element selection (%s)").format(WI._inspectModeKeyboardShortcut.displayName);
-        var activatedToolTip = WI.UIString("Stop element selection (%s)").format(WI._inspectModeKeyboardShortcut.displayName);
-        this._inspectModeToolbarButton = new WI.ActivateButtonToolbarItem("inspect", toolTip, activatedToolTip, "Images/Crosshair.svg");
-        this._inspectModeToolbarButton.addEventListener(WI.ButtonNavigationItem.Event.Clicked, this._toggleInspectMode, this);
-    }
-
     this._dashboardContainer = new WI.DashboardContainerView;
     this._dashboardContainer.showDashboardViewForRepresentedObject(this.dashboardManager.dashboards.default);
 
@@ -418,8 +416,7 @@
 
     this.toolbar.addToolbarItem(this._dashboardContainer.toolbarItem, WI.Toolbar.Section.Center);
 
-    if (this._inspectModeToolbarButton)
-        this.toolbar.addToolbarItem(this._inspectModeToolbarButton, WI.Toolbar.Section.CenterRight);
+    this.toolbar.addToolbarItem(this._inspectModeToolbarButton, WI.Toolbar.Section.CenterRight);
 
     this.toolbar.addToolbarItem(this._searchToolbarItem, WI.Toolbar.Section.Right);
 
@@ -720,6 +717,8 @@
 
     this._updateReloadToolbarButton();
     this._updateDownloadToolbarButton();
+    this._updateInspectModeToolbarButton();
+
     this._tryToRestorePendingTabs();
 };
 
@@ -1864,6 +1863,16 @@
     this._downloadToolbarButton.enabled = this.canArchiveMainFrame();
 };
 
+WI._updateInspectModeToolbarButton = function()
+{
+    if (!window.DOMAgent || !DOMAgent.setInspectModeEnabled) {
+        this._inspectModeToolbarButton.hidden = true;
+        return;
+    }
+
+    this._inspectModeToolbarButton.hidden = false;
+}
+
 WI._toggleInspectMode = function(event)
 {
     this.domTreeManager.inspectModeEnabled = !this.domTreeManager.inspectModeEnabled;

Modified: trunk/Source/WebInspectorUI/UserInterface/Protocol/DOMObserver.js (221764 => 221765)


--- trunk/Source/WebInspectorUI/UserInterface/Protocol/DOMObserver.js	2017-09-07 22:20:39 UTC (rev 221764)
+++ trunk/Source/WebInspectorUI/UserInterface/Protocol/DOMObserver.js	2017-09-07 22:22:38 UTC (rev 221765)
@@ -32,6 +32,11 @@
         WI.domTreeManager._documentUpdated();
     }
 
+    inspect(nodeId)
+    {
+        WI.domTreeManager.inspectElement(nodeId);
+    }
+
     setChildNodes(parentId, payloads)
     {
         WI.domTreeManager._setChildNodes(parentId, payloads);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to