Web Inspector: Canvas: protocol error on first open
authordrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Mar 2019 20:35:54 +0000 (20:35 +0000)
committerdrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Mar 2019 20:35:54 +0000 (20:35 +0000)
https://bugs.webkit.org/show_bug.cgi?id=195059
<rdar://problem/48407871>

Reviewed by Joseph Pecoraro.

* UserInterface/Controllers/CanvasManager.js:
(WI.CanvasManager.prototype.initializeTarget):
(WI.CanvasManager.prototype.static supportsRecordingAutoCapture):
(WI.CanvasManager.prototype.setRecordingAutoCaptureFrameCount):
If targets aren't available, wait until they are and then set the auto-capture frame count.

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

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Controllers/CanvasManager.js

index b9e38cb..c21da7d 100644 (file)
@@ -1,5 +1,19 @@
 2019-03-04  Devin Rousso  <drousso@apple.com>
 
+        Web Inspector: Canvas: protocol error on first open
+        https://bugs.webkit.org/show_bug.cgi?id=195059
+        <rdar://problem/48407871>
+
+        Reviewed by Joseph Pecoraro.
+
+        * UserInterface/Controllers/CanvasManager.js:
+        (WI.CanvasManager.prototype.initializeTarget):
+        (WI.CanvasManager.prototype.static supportsRecordingAutoCapture):
+        (WI.CanvasManager.prototype.setRecordingAutoCaptureFrameCount):
+        If targets aren't available, wait until they are and then set the auto-capture frame count.
+
+2019-03-04  Devin Rousso  <drousso@apple.com>
+
         Web Inspector: Toggling Timeline "Stop when page loads" to on should stop (immediately or soon) any active recording if already past the load event
         https://bugs.webkit.org/show_bug.cgi?id=195239
 
index a9a09df..9d3911f 100644 (file)
@@ -42,15 +42,19 @@ WI.CanvasManager = class CanvasManager extends WI.Object
 
     initializeTarget(target)
     {
-        if (target.CanvasAgent)
+        if (target.CanvasAgent) {
             target.CanvasAgent.enable();
+
+            if (target.CanvasAgent.setRecordingAutoCaptureFrameCount && WI.settings.canvasRecordingAutoCaptureEnabled.value && WI.settings.canvasRecordingAutoCaptureFrameCount.value)
+                target.CanvasAgent.setRecordingAutoCaptureFrameCount(WI.settings.canvasRecordingAutoCaptureFrameCount.value);
+        }
     }
 
     // Static
 
     static supportsRecordingAutoCapture()
     {
-        return window.CanvasAgent && CanvasAgent.setRecordingAutoCaptureFrameCount;
+        return InspectorBackend.domains.CanvasAgent && InspectorBackend.domains.CanvasAgent.setRecordingAutoCaptureFrameCount;
     }
 
     // Public
@@ -97,14 +101,13 @@ WI.CanvasManager = class CanvasManager extends WI.Object
     {
         console.assert(!isNaN(count) && count >= 0);
 
-        return CanvasAgent.setRecordingAutoCaptureFrameCount(enabled ? count : 0)
-        .then(() => {
-            WI.settings.canvasRecordingAutoCaptureEnabled.value = enabled && count;
-            WI.settings.canvasRecordingAutoCaptureFrameCount.value = count;
-        })
-        .catch((error) => {
-            console.error(error);
-        });
+        for (let target of WI.targets) {
+            if (target.CanvasAgent)
+                target.CanvasAgent.setRecordingAutoCaptureFrameCount(enabled ? count : 0);
+        }
+
+        WI.settings.canvasRecordingAutoCaptureEnabled.value = enabled && count;
+        WI.settings.canvasRecordingAutoCaptureFrameCount.value = count;
     }
 
     canvasAdded(canvasPayload)