Web Inspector: Layers: Uncaught Exception: Request with id = 2 failed. {"code":-32601...
authordrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 11 Jul 2019 18:36:57 +0000 (18:36 +0000)
committerdrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 11 Jul 2019 18:36:57 +0000 (18:36 +0000)
https://bugs.webkit.org/show_bug.cgi?id=199555

Reviewed by Joseph Pecoraro.

Use modern inspected target support checking, and defer agent commands until a target is
available.

* UserInterface/Views/Layers3DContentView.js:
(WI.Layers3DContentView):
(WI.Layers3DContentView.prototype._showPaintRectsSettingChanged):
(WI.Layers3DContentView.prototype._updateCompositingBordersButtonState):
(WI.Layers3DContentView.prototype._toggleCompositingBorders):

* UserInterface/Views/DOMTreeContentView.js:
(WI.DOMTreeContentView):
(WI.DOMTreeContentView.prototype._toggleCompositingBorders):
(WI.DOMTreeContentView.prototype._updateCompositingBordersButtonToMatchPageSettings):
(WI.DOMTreeContentView.prototype._showPaintRectsSettingChanged):
(WI.DOMTreeContentView.prototype._showPrintStylesChanged):
(WI.DOMTreeContentView.prototype._showRulersChanged):
Drive-by: apply the same changes to the Elements tab for when the Layers tab isn't enabled.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@247356 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Views/DOMTreeContentView.js
Source/WebInspectorUI/UserInterface/Views/Layers3DContentView.js

index 682145d..6a692dc 100644 (file)
@@ -1,3 +1,28 @@
+2019-07-11  Devin Rousso  <drousso@apple.com>
+
+        Web Inspector: Layers: Uncaught Exception: Request with id = 2 failed. {"code":-32601,"message":"'Page' domain was not found","data":[{"code":-32601,"message":"'Page' domain was not found"}]}
+        https://bugs.webkit.org/show_bug.cgi?id=199555
+
+        Reviewed by Joseph Pecoraro.
+
+        Use modern inspected target support checking, and defer agent commands until a target is
+        available.
+
+        * UserInterface/Views/Layers3DContentView.js:
+        (WI.Layers3DContentView):
+        (WI.Layers3DContentView.prototype._showPaintRectsSettingChanged):
+        (WI.Layers3DContentView.prototype._updateCompositingBordersButtonState):
+        (WI.Layers3DContentView.prototype._toggleCompositingBorders):
+
+        * UserInterface/Views/DOMTreeContentView.js:
+        (WI.DOMTreeContentView):
+        (WI.DOMTreeContentView.prototype._toggleCompositingBorders):
+        (WI.DOMTreeContentView.prototype._updateCompositingBordersButtonToMatchPageSettings):
+        (WI.DOMTreeContentView.prototype._showPaintRectsSettingChanged):
+        (WI.DOMTreeContentView.prototype._showPrintStylesChanged):
+        (WI.DOMTreeContentView.prototype._showRulersChanged):
+        Drive-by: apply the same changes to the Elements tab for when the Layers tab isn't enabled.
+
 2019-07-09  Devin Rousso  <drousso@apple.com>
 
         Web Inspector: Canvas: replace WTF::Vector with std::initializer_list in CallTracer to avoid dynamic allocations
index 850c934..1916d74 100644 (file)
@@ -34,7 +34,7 @@ WI.DOMTreeContentView = class DOMTreeContentView extends WI.ContentView
         if (InspectorBackend.domains.Page) {
             this._compositingBordersButtonNavigationItem = new WI.ActivateButtonNavigationItem("layer-borders", WI.UIString("Show compositing borders"), WI.UIString("Hide compositing borders"), "Images/LayerBorders.svg", 13, 13);
             this._compositingBordersButtonNavigationItem.addEventListener(WI.ButtonNavigationItem.Event.Clicked, this._toggleCompositingBorders, this);
-            this._compositingBordersButtonNavigationItem.enabled = !!PageAgent.getCompositingBordersVisible;
+            this._compositingBordersButtonNavigationItem.enabled = !!InspectorBackend.domains.Page.getCompositingBordersVisible;
             this._compositingBordersButtonNavigationItem.visibilityPriority = WI.NavigationItem.VisibilityPriority.Low;
         }
 
@@ -42,8 +42,8 @@ WI.DOMTreeContentView = class DOMTreeContentView extends WI.ContentView
             WI.settings.showPaintRects.addEventListener(WI.Setting.Event.Changed, this._showPaintRectsSettingChanged, this);
             this._paintFlashingButtonNavigationItem = new WI.ActivateButtonNavigationItem("paint-flashing", WI.UIString("Enable paint flashing"), WI.UIString("Disable paint flashing"), "Images/Paint.svg", 16, 16);
             this._paintFlashingButtonNavigationItem.addEventListener(WI.ButtonNavigationItem.Event.Clicked, this._togglePaintFlashing, this);
-            this._paintFlashingButtonNavigationItem.enabled = !!PageAgent.setShowPaintRects;
-            this._paintFlashingButtonNavigationItem.activated = PageAgent.setShowPaintRects && WI.settings.showPaintRects.value;
+            this._paintFlashingButtonNavigationItem.enabled = !!InspectorBackend.domains.Page.setShowPaintRects;
+            this._paintFlashingButtonNavigationItem.activated = InspectorBackend.domains.Page.setShowPaintRects && WI.settings.showPaintRects.value;
             this._paintFlashingButtonNavigationItem.visibilityPriority = WI.NavigationItem.VisibilityPriority.Low;
         }
 
@@ -590,11 +590,13 @@ WI.DOMTreeContentView = class DOMTreeContentView extends WI.ContentView
 
     _toggleCompositingBorders(event)
     {
-        console.assert(PageAgent.setCompositingBordersVisible);
-
         var activated = !this._compositingBordersButtonNavigationItem.activated;
         this._compositingBordersButtonNavigationItem.activated = activated;
-        PageAgent.setCompositingBordersVisible(activated);
+
+        for (let target of WI.targets) {
+            if (target.PageAgent)
+                target.PageAgent.setCompositingBordersVisible(activated);
+        }
     }
 
     _togglePaintFlashing(event)
@@ -604,6 +606,16 @@ WI.DOMTreeContentView = class DOMTreeContentView extends WI.ContentView
 
     _updateCompositingBordersButtonToMatchPageSettings()
     {
+        if (!WI.targetsAvailable()) {
+            WI.whenTargetsAvailable().then(() => {
+                this._updateCompositingBordersButtonToMatchPageSettings();
+            });
+            return;
+        }
+
+        if (!window.PageAgent)
+            return;
+
         var button = this._compositingBordersButtonNavigationItem;
 
         // We need to sync with the page settings since these can be controlled
@@ -616,11 +628,13 @@ WI.DOMTreeContentView = class DOMTreeContentView extends WI.ContentView
 
     _showPaintRectsSettingChanged(event)
     {
-        console.assert(PageAgent.setShowPaintRects);
-
-        this._paintFlashingButtonNavigationItem.activated = WI.settings.showPaintRects.value;
+        let activated = WI.settings.showPaintRects.value;
+        this._paintFlashingButtonNavigationItem.activated = activated;
 
-        PageAgent.setShowPaintRects(this._paintFlashingButtonNavigationItem.activated);
+        for (let target of WI.targets) {
+            if (target.PageAgent && target.PageAgent.setShowPaintRects)
+                target.PageAgent.setShowPaintRects(activated);
+        }
     }
 
     _showShadowDOMSettingChanged(event)
@@ -638,7 +652,10 @@ WI.DOMTreeContentView = class DOMTreeContentView extends WI.ContentView
         this._showPrintStylesButtonNavigationItem.activated = WI.printStylesEnabled;
 
         let mediaType = WI.printStylesEnabled ? "print" : "";
-        PageAgent.setEmulatedMedia(mediaType);
+        for (let target of WI.targets) {
+            if (target.PageAgent)
+                target.PageAgent.setEmulatedMedia(mediaType);
+        }
 
         WI.cssManager.mediaTypeChanged();
     }
@@ -716,11 +733,13 @@ WI.DOMTreeContentView = class DOMTreeContentView extends WI.ContentView
 
     _showRulersChanged()
     {
-        console.assert(PageAgent.setShowRulers);
-
-        this._showRulersButtonNavigationItem.activated = WI.settings.showRulers.value;
+        let activated = WI.settings.showRulers.value;
+        this._showRulersButtonNavigationItem.activated = activated;
 
-        PageAgent.setShowRulers(this._showRulersButtonNavigationItem.activated);
+        for (let target of WI.targets) {
+            if (target.PageAgent && target.PageAgent.setShowRulers)
+                target.PageAgent.setShowRulers(activated);
+        }
     }
 
     _toggleShowRulers(event)
index a53667a..b642937 100644 (file)
@@ -33,13 +33,14 @@ WI.Layers3DContentView = class Layers3DContentView extends WI.ContentView
 
         this._compositingBordersButtonNavigationItem = new WI.ActivateButtonNavigationItem("layer-borders", WI.UIString("Show compositing borders"), WI.UIString("Hide compositing borders"), "Images/LayerBorders.svg", 13, 13);
         this._compositingBordersButtonNavigationItem.addEventListener(WI.ButtonNavigationItem.Event.Clicked, this._toggleCompositingBorders, this);
+        this._compositingBordersButtonNavigationItem.enabled = !!InspectorBackend.domains.Page;
         this._compositingBordersButtonNavigationItem.visibilityPriority = WI.NavigationItem.VisibilityPriority.Low;
 
         WI.settings.showPaintRects.addEventListener(WI.Setting.Event.Changed, this._showPaintRectsSettingChanged, this);
         this._paintFlashingButtonNavigationItem = new WI.ActivateButtonNavigationItem("paint-flashing", WI.UIString("Enable paint flashing"), WI.UIString("Disable paint flashing"), "Images/Paint.svg", 16, 16);
         this._paintFlashingButtonNavigationItem.addEventListener(WI.ButtonNavigationItem.Event.Clicked, this._togglePaintFlashing, this);
-        this._paintFlashingButtonNavigationItem.enabled = !!PageAgent.setShowPaintRects;
-        this._paintFlashingButtonNavigationItem.activated = PageAgent.setShowPaintRects && WI.settings.showPaintRects.value;
+        this._paintFlashingButtonNavigationItem.enabled = InspectorBackend.domains.Page && !!InspectorBackend.domains.Page.setShowPaintRects;
+        this._paintFlashingButtonNavigationItem.activated = InspectorBackend.domains.Page.setShowPaintRects && WI.settings.showPaintRects.value;
         this._paintFlashingButtonNavigationItem.visibilityPriority = WI.NavigationItem.VisibilityPriority.Low;
 
         this._layers = [];
@@ -392,10 +393,13 @@ WI.Layers3DContentView = class Layers3DContentView extends WI.ContentView
 
     _showPaintRectsSettingChanged(event)
     {
-        console.assert(PageAgent.setShowPaintRects);
+        let activated = WI.settings.showPaintRects.value;
+        this._paintFlashingButtonNavigationItem.activated = activated;
 
-        this._paintFlashingButtonNavigationItem.activated = WI.settings.showPaintRects.value;
-        PageAgent.setShowPaintRects(this._paintFlashingButtonNavigationItem.activated);
+        for (let target of WI.targets) {
+            if (target.PageAgent && target.PageAgent.setShowPaintRects)
+                target.PageAgent.setShowPaintRects(activated);
+        }
     }
 
     _togglePaintFlashing(event)
@@ -405,6 +409,16 @@ WI.Layers3DContentView = class Layers3DContentView extends WI.ContentView
 
     _updateCompositingBordersButtonState()
     {
+        if (!WI.targetsAvailable()) {
+            WI.whenTargetsAvailable().then(() => {
+                this._updateCompositingBordersButtonState();
+            });
+            return;
+        }
+
+        if (!window.PageAgent)
+            return;
+
         // This value can be changed outside of Web Inspector.
         // FIXME: Have PageAgent dispatch a change event instead?
         PageAgent.getCompositingBordersVisible((error, compositingBordersVisible) => {
@@ -415,8 +429,13 @@ WI.Layers3DContentView = class Layers3DContentView extends WI.ContentView
 
     _toggleCompositingBorders(event)
     {
-        this._compositingBordersButtonNavigationItem.activated = !this._compositingBordersButtonNavigationItem.activated;
-        PageAgent.setCompositingBordersVisible(this._compositingBordersButtonNavigationItem.activated);
+        let activated = !this._compositingBordersButtonNavigationItem.activated;
+        this._compositingBordersButtonNavigationItem.activated = activated;
+
+        for (let target of WI.targets) {
+            if (target.PageAgent)
+                target.PageAgent.setCompositingBordersVisible(activated);
+        }
     }
 
     _buildLayerInfoElement()