result-worker.js raw
1 // SAB verification Worker. Runs inside the extension origin.
2 const r = {
3 crossOriginIsolated: self.crossOriginIsolated,
4 hasSABType: typeof SharedArrayBuffer !== 'undefined',
5 canCreate: false,
6 atomicsWait: null,
7 error: null
8 };
9 try {
10 const sab = new SharedArrayBuffer(4);
11 r.canCreate = true;
12 const i32 = new Int32Array(sab);
13 // 0ms timeout: returns 'timed-out' (matched) or throws if Atomics.wait
14 // is not available (main thread), or returns 'not-equal'.
15 const res = Atomics.wait(i32, 0, 0, 0);
16 r.atomicsWait = res;
17 } catch(e) {
18 r.error = e.message;
19 }
20 self.postMessage(r);
21