WebGPU CTS: Add handling of CONNECTION_ACK message

This is a message the test page should send after the websocket
connection has opened.

Bug: 1434762
Change-Id: I55e85acf6789ef997c3a4e3fe66606f34be66161
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4500329
Reviewed-by: Brian Sheedy <bsheedy@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1139210}
diff --git a/content/test/gpu/gpu_tests/webgpu_cts_integration_test.py b/content/test/gpu/gpu_tests/webgpu_cts_integration_test.py
index 35c6738..ce45c3e4 100644
--- a/content/test/gpu/gpu_tests/webgpu_cts_integration_test.py
+++ b/content/test/gpu/gpu_tests/webgpu_cts_integration_test.py
@@ -35,6 +35,7 @@
 BACKEND_VALIDATION_MULTIPLIER = 6
 FIRST_LOAD_TEST_STARTED_MULTIPLER = 3
 
+MESSAGE_TIMEOUT_CONNECTION_ACK = 5
 # In most cases, this should be very fast, but the first test run after a page
 # load can be slow.
 MESSAGE_TIMEOUT_TEST_STARTED = 10
@@ -45,6 +46,7 @@
 
 JAVASCRIPT_DURATION = 'javascript_duration'
 MAY_EXONERATE = 'may_exonerate'
+MESSAGE_TYPE_CONNECTION_ACK = 'CONNECTION_ACK'
 MESSAGE_TYPE_TEST_STARTED = 'TEST_STARTED'
 MESSAGE_TYPE_TEST_HEARTBEAT = 'TEST_HEARTBEAT'
 MESSAGE_TYPE_TEST_STATUS = 'TEST_STATUS'
@@ -493,6 +495,15 @@
         'window.setupWebsocket("%s")' %
         WebGpuCtsIntegrationTest.websocket_server.server_port)
     WebGpuCtsIntegrationTest.websocket_server.WaitForConnection()
+    try:
+      response = WebGpuCtsIntegrationTest.websocket_server.Receive(
+          MESSAGE_TIMEOUT_CONNECTION_ACK)
+      assert json.loads(response)['type'] == MESSAGE_TYPE_CONNECTION_ACK
+    except websocket_server.WebsocketReceiveMessageTimeoutError:
+      # for now, ignore any timeouts because the test page doesn't send
+      # CONNECTION_ACK yet
+      pass
+
     WebGpuCtsIntegrationTest._page_loaded = True
     return True