TestWebKitAPI.WebKit2.CrashGPUProcessWhileCapturingAndCalling is failing on BigSur bot
https://bugs.webkit.org/show_bug.cgi?id=241798

Patch by Youenn Fablet <youennf@gmail.com> on 2022-06-21
Reviewed by Eric Carlson.

* Tools/TestWebKitAPI/Tests/WebKit/GetUserMedia.mm:
* Tools/TestWebKitAPI/Tests/WebKit/getUserMedia.html:
Adding some more tests and logging to investigate what is wrong with the test in BigSur.

Canonical link: https://commits.webkit.org/251692@main

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@295687 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Tools/TestWebKitAPI/Tests/WebKit/GetUserMedia.mm b/Tools/TestWebKitAPI/Tests/WebKit/GetUserMedia.mm
index 39e739a..f4d8fb5 100644
--- a/Tools/TestWebKitAPI/Tests/WebKit/GetUserMedia.mm
+++ b/Tools/TestWebKitAPI/Tests/WebKit/GetUserMedia.mm
@@ -748,6 +748,10 @@
     [webView stringByEvaluatingJavaScript:@"createConnection()"];
     TestWebKitAPI::Util::run(&done);
 
+    done = false;
+    [webView stringByEvaluatingJavaScript:@"checkDecodingVideo('first')"];
+    TestWebKitAPI::Util::run(&done);
+
     auto webViewPID = [webView _webProcessIdentifier];
 
     // The GPU process should get launched.
@@ -776,7 +780,15 @@
     EXPECT_EQ(webViewPID, [webView _webProcessIdentifier]);
 
     done = false;
-    [webView stringByEvaluatingJavaScript:@"checkDecodingVideo()"];
+    [webView stringByEvaluatingJavaScript:@"checkVideoStatus()"];
+    TestWebKitAPI::Util::run(&done);
+
+    done = false;
+    [webView stringByEvaluatingJavaScript:@"checkAudioStatus()"];
+    TestWebKitAPI::Util::run(&done);
+
+    done = false;
+    [webView stringByEvaluatingJavaScript:@"checkDecodingVideo('second')"];
     TestWebKitAPI::Util::run(&done);
 
     EXPECT_EQ(gpuProcessPID, [processPool _gpuProcessIdentifier]);
diff --git a/Tools/TestWebKitAPI/Tests/WebKit/getUserMedia.html b/Tools/TestWebKitAPI/Tests/WebKit/getUserMedia.html
index 36e3415..ee4608e 100644
--- a/Tools/TestWebKitAPI/Tests/WebKit/getUserMedia.html
+++ b/Tools/TestWebKitAPI/Tests/WebKit/getUserMedia.html
@@ -170,7 +170,7 @@
                 });
             }
 
-            function checkDecodingVideo(counter) {
+            function checkDecodingVideo(message, counter) {
                 if (!counter)
                     counter = 0;
                 getStats(pc2, "inbound-rtp", "video").then((stats) => {
@@ -179,10 +179,10 @@
                         return;
                     }
                     if (counter > 100) {
-                        window.webkit.messageHandlers.gum.postMessage("FAIL checkDecodingVideo " + JSON.stringify(stats));
+                        window.webkit.messageHandlers.gum.postMessage("FAIL checkDecodingVideo for " + message + ": " + JSON.stringify(stats));
                         return;
                     }
-                    setTimeout(() => checkDecodingVideo(++counter), 50);
+                    setTimeout(() => checkDecodingVideo(message, ++counter), 50);
                 });
             }