From 7a96c3c7cc4a4a748f2187169ba2faaaecd7dff8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fran=C3=A7ois=20Beaufort?= <beaufort.francois@gmail.com>
Date: Mon, 4 Mar 2024 13:52:32 +0100
Subject: [PATCH] Run tests

---
 src/common/runtime/helper/test_worker.ts      |   7 +-
 src/common/tools/dev_server.ts                |   2 +-
 .../tools/gen_listings_and_webworkers.ts      |  33 +--
 src/resources/cache/hashes.json               | 210 +++++++++---------
 .../cache/webgpu/shader/execution/bitcast.bin | Bin 2221448 -> 2221448 bytes
 src/webgpu/listing_meta.json                  |   1 +
 .../web_platform/worker/worker_launcher.ts    |   5 +-
 7 files changed, 131 insertions(+), 127 deletions(-)

diff --git a/src/common/runtime/helper/test_worker.ts b/src/common/runtime/helper/test_worker.ts
index 9cca049c36c7..7b5e85a0bafa 100644
--- a/src/common/runtime/helper/test_worker.ts
+++ b/src/common/runtime/helper/test_worker.ts
@@ -108,7 +108,7 @@ export class TestServiceWorker {
     query: string,
     expectations: TestQueryWithExpectation[] = []
   ): Promise<void> {
-    const [suite, name] = query.split(":", 2);
+    const [suite, name] = query.split(':', 2);
     const fileName = name.split(',').join('/');
     const serviceWorkerPath = `/out/${suite}/webworker/${fileName}.worker.js`;
 
@@ -116,7 +116,7 @@ export class TestServiceWorker {
       type: 'module',
       scope: '/',
     });
-    await navigator.serviceWorker.ready;
+    await registration.update();
 
     navigator.serviceWorker.onmessage = ev => {
       const query: string = ev.data.query;
@@ -132,13 +132,14 @@ export class TestServiceWorker {
       // update the entire results JSON somehow at some point).
     };
 
-    registration.active.postMessage({
+    registration.active?.postMessage({
       query,
       expectations,
       ctsOptions: this.ctsOptions,
     });
     const serviceWorkerResult = await new Promise<LiveTestCaseResult>(resolve => {
       this.resolvers.set(query, resolve);
+      void registration.unregister();
     });
     rec.injectResult(serviceWorkerResult);
   }
diff --git a/src/common/tools/dev_server.ts b/src/common/tools/dev_server.ts
index 535b99d9346e..2845a2375524 100644
--- a/src/common/tools/dev_server.ts
+++ b/src/common/tools/dev_server.ts
@@ -155,7 +155,7 @@ app.get('/out/**/*.js', async (req, res, next) => {
     return;
   }
 
-  // FIXME: I'm not sure if this is the way I should handle it...
+  // I'm not sure if this is the way I should handle it...
   const dir = jsUrl.endsWith('worker.js') ? path.resolve(srcDir, '../out') : srcDir;
   let absPath = path.join(dir, tsUrl);
   if (!fs.existsSync(absPath)) {
diff --git a/src/common/tools/gen_listings_and_webworkers.ts b/src/common/tools/gen_listings_and_webworkers.ts
index c46232f9c1ee..b922cb763fb8 100644
--- a/src/common/tools/gen_listings_and_webworkers.ts
+++ b/src/common/tools/gen_listings_and_webworkers.ts
@@ -78,16 +78,15 @@ export const listing = ${JSON.stringify(listing, undefined, 2)};
         `\
 // AUTO-GENERATED - DO NOT EDIT. See ${myself}.
 
-// oldG is a TestGroup<Fixture> object (defined in common/internal/test_group.ts).
-import { g as oldG } from '${relPathToSuiteRoot}/${entry.file.join('/')}.spec.js';
-
-// FIXME: Expose a proxied test interface. I think this can completely replace test_worker-worker.js
-// (using this instead of that), but if not then hopefully it can at least share code with it.
-console.log(oldG.iterate());
+// g is a TestGroup<Fixture> object (defined in common/internal/test_group.ts).
+import { g } from '${relPathToSuiteRoot}/${entry.file.join('/')}.spec.js';
 
 import { globalTestConfig } from '/out/common/framework/test_config.js';
 import { Logger } from '/out/common/internal/logging/logger.js';
 import { setDefaultRequestAdapterOptions } from '/out/common/util/navigator_gpu.js';
+import { parseQuery } from '/out/common/internal/query/parseQuery.js';
+import { comparePublicParamsPaths, Ordering } from '/out/common/internal/query/compare.js';
+import { assert } from '/out/common/util/util.js';
 
 async function reportTestResults(ev) {
   const query = ev.data.query;
@@ -109,17 +108,19 @@ async function reportTestResults(ev) {
     });
   }
 
-  // const testcases = Array.from(await loader.loadCases(parseQuery(query)));
-  // assert(testcases.length === 1, 'worker query resulted in != 1 cases');
-
-  // const testcase = testcases[0];
-  const testcase = { query }; // FIXME! I failed to figure out how to get a testcase from oldG and query ;(
-  const [rec, result] = log.record(testcase.query.toString());
-  // await testcase.run(rec, expectations);
-  result.status = 'pass'; // FIXME
-  result.timems = 42; // FIXME
+  const testQuerySingleCase = parseQuery(query);
+  let testcase = null;
+  for (const t of g.iterate()) {
+    for (const c of t.iterate(testQuerySingleCase.params)) {
+      if (comparePublicParamsPaths(c.id.params, testQuerySingleCase.params) === Ordering.Equal) {
+        testcase = c;
+      }
+    }
+  }
+  assert(testcase);
+  const [rec, result] = log.record(query);
+  await testcase.run(rec, testQuerySingleCase, expectations);
   this.postMessage({ query, result });
-
 }
 
 self.onmessage = (ev) => {
diff --git a/src/resources/cache/hashes.json b/src/resources/cache/hashes.json
index 9476d8431f41..5a5316cda1f6 100644
--- a/src/resources/cache/hashes.json
+++ b/src/resources/cache/hashes.json
@@ -1,107 +1,107 @@
 {
-  "webgpu/shader/execution/binary/af_addition.bin": "38b261fa",
-  "webgpu/shader/execution/binary/af_logical.bin": "a483b968",
-  "webgpu/shader/execution/binary/af_division.bin": "ec39b0da",
-  "webgpu/shader/execution/binary/af_matrix_addition.bin": "ca1373a8",
-  "webgpu/shader/execution/binary/af_matrix_subtraction.bin": "406d99af",
-  "webgpu/shader/execution/binary/af_multiplication.bin": "2eb6d50d",
-  "webgpu/shader/execution/binary/af_remainder.bin": "e2b6b21",
-  "webgpu/shader/execution/binary/af_subtraction.bin": "84794350",
-  "webgpu/shader/execution/binary/f16_addition.bin": "19e8823d",
-  "webgpu/shader/execution/binary/f16_logical.bin": "b89ca9b9",
-  "webgpu/shader/execution/binary/f16_division.bin": "6dc4b748",
-  "webgpu/shader/execution/binary/f16_matrix_addition.bin": "7533842",
-  "webgpu/shader/execution/binary/f16_matrix_matrix_multiplication.bin": "2d799920",
-  "webgpu/shader/execution/binary/f16_matrix_scalar_multiplication.bin": "44e3b295",
-  "webgpu/shader/execution/binary/f16_matrix_subtraction.bin": "412f0911",
-  "webgpu/shader/execution/binary/f16_matrix_vector_multiplication.bin": "a231201b",
-  "webgpu/shader/execution/binary/f16_multiplication.bin": "94b11030",
-  "webgpu/shader/execution/binary/f16_remainder.bin": "de68a200",
-  "webgpu/shader/execution/binary/f16_subtraction.bin": "f308327a",
-  "webgpu/shader/execution/binary/f32_addition.bin": "c87c8c08",
-  "webgpu/shader/execution/binary/f32_logical.bin": "c7370c09",
-  "webgpu/shader/execution/binary/f32_division.bin": "34ce65ae",
-  "webgpu/shader/execution/binary/f32_matrix_addition.bin": "f3808d0c",
-  "webgpu/shader/execution/binary/f32_matrix_matrix_multiplication.bin": "e33e7fe5",
-  "webgpu/shader/execution/binary/f32_matrix_scalar_multiplication.bin": "41091ebf",
-  "webgpu/shader/execution/binary/f32_matrix_subtraction.bin": "37ccb101",
-  "webgpu/shader/execution/binary/f32_matrix_vector_multiplication.bin": "4d67866",
-  "webgpu/shader/execution/binary/f32_multiplication.bin": "5d85a36c",
-  "webgpu/shader/execution/binary/f32_remainder.bin": "62f591b2",
-  "webgpu/shader/execution/binary/f32_subtraction.bin": "60fc275a",
-  "webgpu/shader/execution/binary/i32_arithmetic.bin": "a0b0a016",
-  "webgpu/shader/execution/binary/i32_comparison.bin": "f3d9b3f9",
-  "webgpu/shader/execution/binary/u32_arithmetic.bin": "16e32fd",
-  "webgpu/shader/execution/binary/u32_comparison.bin": "da33cc5d",
-  "webgpu/shader/execution/abs.bin": "1ead834c",
-  "webgpu/shader/execution/acos.bin": "e25802ba",
-  "webgpu/shader/execution/acosh.bin": "2321726f",
-  "webgpu/shader/execution/asin.bin": "d554a73b",
-  "webgpu/shader/execution/asinh.bin": "d2bdb21b",
-  "webgpu/shader/execution/atan.bin": "eb6476f3",
-  "webgpu/shader/execution/atan2.bin": "cf15e7fa",
-  "webgpu/shader/execution/atanh.bin": "6c57cc3",
-  "webgpu/shader/execution/bitcast.bin": "a25e9714",
-  "webgpu/shader/execution/ceil.bin": "8d120ea3",
-  "webgpu/shader/execution/clamp.bin": "a762ef58",
-  "webgpu/shader/execution/cos.bin": "a859da89",
-  "webgpu/shader/execution/cosh.bin": "86abdd85",
-  "webgpu/shader/execution/cross.bin": "e4556729",
-  "webgpu/shader/execution/degrees.bin": "1fa19a41",
-  "webgpu/shader/execution/determinant.bin": "108c3d65",
-  "webgpu/shader/execution/distance.bin": "77a1baa6",
-  "webgpu/shader/execution/dot.bin": "d4ac2e8a",
-  "webgpu/shader/execution/exp.bin": "15539afd",
-  "webgpu/shader/execution/exp2.bin": "7f6a8523",
-  "webgpu/shader/execution/faceForward.bin": "e7b35f43",
-  "webgpu/shader/execution/floor.bin": "b26656ca",
-  "webgpu/shader/execution/fma.bin": "5a70c683",
-  "webgpu/shader/execution/fract.bin": "23c0d5ec",
-  "webgpu/shader/execution/frexp.bin": "d28e66be",
-  "webgpu/shader/execution/inverseSqrt.bin": "9f297854",
-  "webgpu/shader/execution/ldexp.bin": "638db0c7",
-  "webgpu/shader/execution/length.bin": "7d237c62",
-  "webgpu/shader/execution/log.bin": "70720bf0",
-  "webgpu/shader/execution/log2.bin": "93a309be",
-  "webgpu/shader/execution/max.bin": "36eb4779",
-  "webgpu/shader/execution/min.bin": "ca772bf1",
-  "webgpu/shader/execution/mix.bin": "ecbf61ae",
-  "webgpu/shader/execution/modf.bin": "6ddea900",
-  "webgpu/shader/execution/normalize.bin": "d3e47c61",
-  "webgpu/shader/execution/pack2x16float.bin": "e6859c1a",
-  "webgpu/shader/execution/pow.bin": "a58be71c",
-  "webgpu/shader/execution/quantizeToF16.bin": "eca85bca",
-  "webgpu/shader/execution/radians.bin": "a216c9aa",
-  "webgpu/shader/execution/reflect.bin": "ebce9830",
-  "webgpu/shader/execution/refract.bin": "59d1e5d6",
-  "webgpu/shader/execution/round.bin": "9389a090",
-  "webgpu/shader/execution/saturate.bin": "7ca4b681",
-  "webgpu/shader/execution/sign.bin": "1f4eeb34",
-  "webgpu/shader/execution/sin.bin": "a1e234b4",
-  "webgpu/shader/execution/sinh.bin": "1a62054b",
-  "webgpu/shader/execution/smoothstep.bin": "d5824fd6",
-  "webgpu/shader/execution/sqrt.bin": "66f21d02",
-  "webgpu/shader/execution/step.bin": "310cb6c7",
-  "webgpu/shader/execution/tan.bin": "1e26f533",
-  "webgpu/shader/execution/tanh.bin": "4c546d1c",
-  "webgpu/shader/execution/transpose.bin": "7bef2494",
-  "webgpu/shader/execution/trunc.bin": "e72535eb",
-  "webgpu/shader/execution/unpack2x16float.bin": "593d88c6",
-  "webgpu/shader/execution/unpack2x16snorm.bin": "9ebd3e40",
-  "webgpu/shader/execution/unpack2x16unorm.bin": "83a36fa9",
-  "webgpu/shader/execution/unpack4x8snorm.bin": "41b12606",
-  "webgpu/shader/execution/unpack4x8unorm.bin": "96f1850b",
-  "webgpu/shader/execution/unary/af_arithmetic.bin": "6fa1d84a",
-  "webgpu/shader/execution/unary/af_assignment.bin": "98c8f82a",
-  "webgpu/shader/execution/unary/bool_conversion.bin": "dd71f171",
-  "webgpu/shader/execution/unary/f16_arithmetic.bin": "2f2d38fc",
-  "webgpu/shader/execution/unary/f16_conversion.bin": "70c94538",
-  "webgpu/shader/execution/unary/f32_arithmetic.bin": "db90c01c",
-  "webgpu/shader/execution/unary/f32_conversion.bin": "81912140",
-  "webgpu/shader/execution/unary/i32_arithmetic.bin": "c69716e2",
-  "webgpu/shader/execution/unary/i32_conversion.bin": "83218e69",
-  "webgpu/shader/execution/unary/u32_conversion.bin": "8f5bad00",
-  "webgpu/shader/execution/unary/ai_assignment.bin": "c7e6ac33",
-  "webgpu/shader/execution/binary/ai_arithmetic.bin": "81c11ec2",
-  "webgpu/shader/execution/unary/ai_arithmetic.bin": "3d27dc97"
+  "webgpu/shader/execution/binary/af_addition.bin": "fc43d206",
+  "webgpu/shader/execution/binary/af_logical.bin": "3dc912ac",
+  "webgpu/shader/execution/binary/af_division.bin": "6cbdaf09",
+  "webgpu/shader/execution/binary/af_matrix_addition.bin": "d61fe049",
+  "webgpu/shader/execution/binary/af_matrix_subtraction.bin": "16d18276",
+  "webgpu/shader/execution/binary/af_multiplication.bin": "ce2a0e9e",
+  "webgpu/shader/execution/binary/af_remainder.bin": "4032e3cf",
+  "webgpu/shader/execution/binary/af_subtraction.bin": "67a1c189",
+  "webgpu/shader/execution/binary/f16_addition.bin": "3edd84a3",
+  "webgpu/shader/execution/binary/f16_logical.bin": "adcc36e9",
+  "webgpu/shader/execution/binary/f16_division.bin": "81168258",
+  "webgpu/shader/execution/binary/f16_matrix_addition.bin": "3497729d",
+  "webgpu/shader/execution/binary/f16_matrix_matrix_multiplication.bin": "767e22c7",
+  "webgpu/shader/execution/binary/f16_matrix_scalar_multiplication.bin": "356acec0",
+  "webgpu/shader/execution/binary/f16_matrix_subtraction.bin": "ed00c0e4",
+  "webgpu/shader/execution/binary/f16_matrix_vector_multiplication.bin": "f089b873",
+  "webgpu/shader/execution/binary/f16_multiplication.bin": "4675c758",
+  "webgpu/shader/execution/binary/f16_remainder.bin": "5ea2af46",
+  "webgpu/shader/execution/binary/f16_subtraction.bin": "a7962472",
+  "webgpu/shader/execution/binary/f32_addition.bin": "ef624c29",
+  "webgpu/shader/execution/binary/f32_logical.bin": "68c1e846",
+  "webgpu/shader/execution/binary/f32_division.bin": "cc886305",
+  "webgpu/shader/execution/binary/f32_matrix_addition.bin": "b3bab14a",
+  "webgpu/shader/execution/binary/f32_matrix_matrix_multiplication.bin": "afccd9d5",
+  "webgpu/shader/execution/binary/f32_matrix_scalar_multiplication.bin": "c8a022a1",
+  "webgpu/shader/execution/binary/f32_matrix_subtraction.bin": "b0db93fb",
+  "webgpu/shader/execution/binary/f32_matrix_vector_multiplication.bin": "d90fbe21",
+  "webgpu/shader/execution/binary/f32_multiplication.bin": "693597cf",
+  "webgpu/shader/execution/binary/f32_remainder.bin": "fe630a4b",
+  "webgpu/shader/execution/binary/f32_subtraction.bin": "e3409ba2",
+  "webgpu/shader/execution/binary/i32_arithmetic.bin": "bd8d0b9b",
+  "webgpu/shader/execution/binary/i32_comparison.bin": "aec6e622",
+  "webgpu/shader/execution/binary/u32_arithmetic.bin": "f5907c7e",
+  "webgpu/shader/execution/binary/u32_comparison.bin": "7160f1c7",
+  "webgpu/shader/execution/abs.bin": "c884966",
+  "webgpu/shader/execution/acos.bin": "3e371b22",
+  "webgpu/shader/execution/acosh.bin": "25b25012",
+  "webgpu/shader/execution/asin.bin": "75d5b677",
+  "webgpu/shader/execution/asinh.bin": "92fe4ad3",
+  "webgpu/shader/execution/atan.bin": "5a7834a4",
+  "webgpu/shader/execution/atan2.bin": "79487bb",
+  "webgpu/shader/execution/atanh.bin": "804ad33f",
+  "webgpu/shader/execution/bitcast.bin": "69a86c70",
+  "webgpu/shader/execution/ceil.bin": "46bca9a0",
+  "webgpu/shader/execution/clamp.bin": "620739ae",
+  "webgpu/shader/execution/cos.bin": "bd7467e4",
+  "webgpu/shader/execution/cosh.bin": "315aad98",
+  "webgpu/shader/execution/cross.bin": "d9a91811",
+  "webgpu/shader/execution/degrees.bin": "27df6eb0",
+  "webgpu/shader/execution/determinant.bin": "67380eba",
+  "webgpu/shader/execution/distance.bin": "91d94128",
+  "webgpu/shader/execution/dot.bin": "3644a88a",
+  "webgpu/shader/execution/exp.bin": "786e68bc",
+  "webgpu/shader/execution/exp2.bin": "454ee68d",
+  "webgpu/shader/execution/faceForward.bin": "625903d3",
+  "webgpu/shader/execution/floor.bin": "db4c92f7",
+  "webgpu/shader/execution/fma.bin": "b049ac43",
+  "webgpu/shader/execution/fract.bin": "84ce9ec3",
+  "webgpu/shader/execution/frexp.bin": "5320c481",
+  "webgpu/shader/execution/inverseSqrt.bin": "7aeff2c0",
+  "webgpu/shader/execution/ldexp.bin": "71b3930f",
+  "webgpu/shader/execution/length.bin": "e96b503a",
+  "webgpu/shader/execution/log.bin": "eba7ec7d",
+  "webgpu/shader/execution/log2.bin": "54ddf967",
+  "webgpu/shader/execution/max.bin": "a83a582a",
+  "webgpu/shader/execution/min.bin": "7c2811c1",
+  "webgpu/shader/execution/mix.bin": "9aa0305f",
+  "webgpu/shader/execution/modf.bin": "ca3173c2",
+  "webgpu/shader/execution/normalize.bin": "3c3a347f",
+  "webgpu/shader/execution/pack2x16float.bin": "73ddf92f",
+  "webgpu/shader/execution/pow.bin": "d2c3fd97",
+  "webgpu/shader/execution/quantizeToF16.bin": "ad3587f0",
+  "webgpu/shader/execution/radians.bin": "d5f10c52",
+  "webgpu/shader/execution/reflect.bin": "219e2df",
+  "webgpu/shader/execution/refract.bin": "fa841745",
+  "webgpu/shader/execution/round.bin": "74f863ec",
+  "webgpu/shader/execution/saturate.bin": "457fd49d",
+  "webgpu/shader/execution/sign.bin": "e44d954c",
+  "webgpu/shader/execution/sin.bin": "67bac1fd",
+  "webgpu/shader/execution/sinh.bin": "e37cb02b",
+  "webgpu/shader/execution/smoothstep.bin": "d279bc42",
+  "webgpu/shader/execution/sqrt.bin": "551939af",
+  "webgpu/shader/execution/step.bin": "72cf60af",
+  "webgpu/shader/execution/tan.bin": "f632f032",
+  "webgpu/shader/execution/tanh.bin": "72c375cb",
+  "webgpu/shader/execution/transpose.bin": "e968d355",
+  "webgpu/shader/execution/trunc.bin": "16f79aa5",
+  "webgpu/shader/execution/unpack2x16float.bin": "c85da768",
+  "webgpu/shader/execution/unpack2x16snorm.bin": "3f3dbc81",
+  "webgpu/shader/execution/unpack2x16unorm.bin": "2862cb20",
+  "webgpu/shader/execution/unpack4x8snorm.bin": "b4c90280",
+  "webgpu/shader/execution/unpack4x8unorm.bin": "ab1a627b",
+  "webgpu/shader/execution/unary/af_arithmetic.bin": "67d2b7eb",
+  "webgpu/shader/execution/unary/af_assignment.bin": "7964e983",
+  "webgpu/shader/execution/unary/bool_conversion.bin": "349303eb",
+  "webgpu/shader/execution/unary/f16_arithmetic.bin": "95908291",
+  "webgpu/shader/execution/unary/f16_conversion.bin": "df34e3f9",
+  "webgpu/shader/execution/unary/f32_arithmetic.bin": "dea317cd",
+  "webgpu/shader/execution/unary/f32_conversion.bin": "fb0ff55a",
+  "webgpu/shader/execution/unary/i32_arithmetic.bin": "d1b09384",
+  "webgpu/shader/execution/unary/i32_conversion.bin": "7ae3fc76",
+  "webgpu/shader/execution/unary/u32_conversion.bin": "a1c35c09",
+  "webgpu/shader/execution/unary/ai_assignment.bin": "bde2f00d",
+  "webgpu/shader/execution/binary/ai_arithmetic.bin": "f99fb5b7",
+  "webgpu/shader/execution/unary/ai_arithmetic.bin": "5784ac67"
 }
\ No newline at end of file
diff --git a/src/resources/cache/webgpu/shader/execution/bitcast.bin b/src/resources/cache/webgpu/shader/execution/bitcast.bin
index d3954903ac89afcfbe5049a356005ed02cf10aae..ab435f3902a6e2124845cfba3625a2184be02b02 100644
GIT binary patch
delta 159
zcmWN=xe<au7=Y0MMLFeC4iAnJ_zN^4U?URxV0K6>!UpJO`QFS^|H)F+Us={6S!U^M
yV@55L7K=7dJk#NYSGx4*GhoPwH^xkuGGop=A1qk1V$COCeDlMGExVtVe%}s}89n6y

delta 159
zcmWN=OA3Nu6o65*G|PPFD<A0wg6;xCXrOcVA<@LyzW{Yj;dkH+Yp)IbzD3{uV<*pX
zdiftEy%LQ&4?NPK$rCM}d7;fK9lG@BGhoPwH^xkuGGop=3zn={^TB3T(k{Op{oy}<

diff --git a/src/webgpu/listing_meta.json b/src/webgpu/listing_meta.json
index f0585f3365e3..0581c09c0153 100644
--- a/src/webgpu/listing_meta.json
+++ b/src/webgpu/listing_meta.json
@@ -2195,6 +2195,7 @@
   "webgpu:web_platform,external_texture,video:importExternalTexture,sample:*": { "subcaseMS": 34.968 },
   "webgpu:web_platform,external_texture,video:importExternalTexture,sampleWithVideoFrameWithVisibleRectParam:*": { "subcaseMS": 29.160 },
   "webgpu:web_platform,worker,worker:dedicated_worker:*": { "subcaseMS": 245.901 },
+  "webgpu:web_platform,worker,worker:service_worker:*": { "subcaseMS": 102.800 },
   "webgpu:web_platform,worker,worker:shared_worker:*": { "subcaseMS": 26.801 },
   "_end": ""
 }
diff --git a/src/webgpu/web_platform/worker/worker_launcher.ts b/src/webgpu/web_platform/worker/worker_launcher.ts
index 8ea652ac0efe..1fa62ba5b1e0 100644
--- a/src/webgpu/web_platform/worker/worker_launcher.ts
+++ b/src/webgpu/web_platform/worker/worker_launcher.ts
@@ -42,18 +42,19 @@ export async function launchServiceWorker() {
     type: 'module',
     scope: '/',
   });
-  await navigator.serviceWorker.ready;
+  await registration.update();
 
   const promise = new Promise<TestResult>(resolve => {
     navigator.serviceWorker.addEventListener(
       'message',
       ev => {
         resolve(ev.data as TestResult);
+        void registration.unregister();
       },
       { once: true }
     );
   });
-  registration.active.postMessage({
+  registration.active?.postMessage({
     defaultRequestAdapterOptions: getDefaultRequestAdapterOptions(),
   });
   return await promise;