v160 · dom · workers · basic + inspection
Connect event inspector
Each button below calls new SharedWorker(…) for real. Inside the worker, the browser fires a connect MessageEvent; the worker snapshots every field of that exact event object and sends the snapshot back over the new port. The one field Chrome 160 changes is data: "" per the HTML spec, where Chrome 159 and earlier gave null.
Checking for SharedWorker…
Connect and inspect
“New” uses a unique name, so the browser creates a fresh SharedWorkerGlobalScope and fires connect from the HTML run a worker steps. “Again” reuses the last name, so the event comes from the SharedWorker constructor’s existing worker branch. The spec says data is "" on both paths.
| Field | This browser | HTML spec | Match |
|---|---|---|---|
| — | — | — | — |
the probe, verbatim
// connect-worker.js (runs inside the SharedWorkerGlobalScope)
self.addEventListener("connect", (e) => {
e.ports[0].postMessage({
data: e.data, // "" in Chrome 160+, null before
typeofData: typeof e.data, // "string" vs "object"
portsFrozen: Object.isFrozen(e.ports),
sourceIsPort0: e.source === e.ports[0],
isTrusted: e.isTrusted,
});
});
This probe returns null on Chrome 153 in this project’s test container and "" on Chrome 160, Firefox and Safari. It cannot be polyfilled: the event is created by the browser before your handler runs. To see the old value on Chrome 160+, launch with --disable-blink-features=SharedWorkerConnectEventEmptyStringData (there is no chrome://flags entry).