Web Inspector: Canvas: in tests don't manually stop recording if a frame count is specified
https://bugs.webkit.org/show_bug.cgi?id=198457
<rdar://problem/48248697>

Reviewed by Joseph Pecoraro.

If a `frameCount` is specified, the recording will stop by itself, so if we hit the
`LastFrame`, there's no need to manually stop the recording at that point. Otherwise,
stopping it early may cause the recording to think that the last frame is incomplete.

* inspector/canvas/resources/recording-utilities.js:
* inspector/canvas/recording-webgl-snapshots.html:
* inspector/canvas/recording-webgl2-snapshots.html:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@246015 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index b258c5f..a04ee81 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,19 @@
+2019-06-01  Devin Rousso  <drousso@apple.com>
+
+        Web Inspector: Canvas: in tests don't manually stop recording if a frame count is specified
+        https://bugs.webkit.org/show_bug.cgi?id=198457
+        <rdar://problem/48248697>
+
+        Reviewed by Joseph Pecoraro.
+
+        If a `frameCount` is specified, the recording will stop by itself, so if we hit the
+        `LastFrame`, there's no need to manually stop the recording at that point. Otherwise,
+        stopping it early may cause the recording to think that the last frame is incomplete.
+
+        * inspector/canvas/resources/recording-utilities.js:
+        * inspector/canvas/recording-webgl-snapshots.html:
+        * inspector/canvas/recording-webgl2-snapshots.html:
+
 2019-05-31  Wenson Hsieh  <wenson_hsieh@apple.com>
 
         Make tests that use UIHelper more robust under certain configurations
diff --git a/LayoutTests/inspector/canvas/recording-webgl-snapshots.html b/LayoutTests/inspector/canvas/recording-webgl-snapshots.html
index 3b5f33e..b70c7c5 100644
--- a/LayoutTests/inspector/canvas/recording-webgl-snapshots.html
+++ b/LayoutTests/inspector/canvas/recording-webgl-snapshots.html
@@ -100,7 +100,7 @@
         name: "Canvas.recordingWebGL.snapshots",
         description: "Check that the snapshot taken after each visual action is different.",
         test(resolve, reject) {
-            startRecording(WI.Canvas.ContextType.WebGL, resolve, reject, {checkForContentChange: true});
+            startRecording(WI.Canvas.ContextType.WebGL, resolve, reject, {frameCount: 1, checkForContentChange: true});
         },
         timeout: -1,
     });
diff --git a/LayoutTests/inspector/canvas/recording-webgl2-snapshots.html b/LayoutTests/inspector/canvas/recording-webgl2-snapshots.html
index 0190520..82f27c9 100644
--- a/LayoutTests/inspector/canvas/recording-webgl2-snapshots.html
+++ b/LayoutTests/inspector/canvas/recording-webgl2-snapshots.html
@@ -102,7 +102,7 @@
         name: "Canvas.recordingWebGL2.snapshots",
         description: "Check that the snapshot taken after each visual action is different.",
         test(resolve, reject) {
-            startRecording(WI.Canvas.ContextType.WebGL2, resolve, reject, {checkForContentChange: true});
+            startRecording(WI.Canvas.ContextType.WebGL2, resolve, reject, {frameCount: 1, checkForContentChange: true});
         },
         timeout: -1,
     });
diff --git a/LayoutTests/inspector/canvas/resources/recording-utilities.js b/LayoutTests/inspector/canvas/resources/recording-utilities.js
index 8b99563..60146ff 100644
--- a/LayoutTests/inspector/canvas/resources/recording-utilities.js
+++ b/LayoutTests/inspector/canvas/resources/recording-utilities.js
@@ -107,9 +107,10 @@
         .then((event) => {
             lastFrame = true;
 
-            if (canvas.recordingActive)
-                CanvasAgent.stopRecording(canvas.identifier).catch(reject);
-            else {
+            if (canvas.recordingActive) {
+                if (!frameCount)
+                    CanvasAgent.stopRecording(canvas.identifier).catch(reject);
+            } else {
                 InspectorTest.evaluateInPage(`cancelActions()`)
                 .then(() => {
                     if (swizzled)