[cts] Support the new binary cache file format

Once https://github.com/gpuweb/cts/pull/3094 lands and rolls, the case cache will move from JSON to binary. The fetch() needs to handle this change of encoding.

Change-Id: Iecc8ead12bdff2d64bc3bf129022bf4686ce70d9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/158061
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Kokoro: Ben Clayton <bclayton@google.com>
diff --git a/webgpu-cts/test_runner.js b/webgpu-cts/test_runner.js
index e8ab5e4..4195c4c 100644
--- a/webgpu-cts/test_runner.js
+++ b/webgpu-cts/test_runner.js
@@ -119,7 +119,13 @@
 
 dataCache.setStore({
   load: async (path) => {
-    return await (await fetch(`/third_party/webgpu-cts/cache/data/${path}`)).text();
+    if (path.endsWith('.json')) {
+      // TODO(bclayton): Remove this once https://github.com/gpuweb/cts/pull/3094 lands and rolls.
+      return await (await fetch(`/third_party/webgpu-cts/cache/data/${path}`)).text();
+    } else {
+      const response = await fetch(`/third_party/webgpu-cts/cache/data/${path}`);
+      return new Uint8Array(await response.arrayBuffer());
+    }
   }
 });
 
@@ -278,8 +284,8 @@
 
 function sendMessageInfraFailure(message) {
   socket.send(JSON.stringify({
-      'type': 'INFRA_FAILURE',
-      'message': message,
+    'type': 'INFRA_FAILURE',
+    'message': message,
   }));
 }