Open Bug 1984864 Opened 28 days ago Updated 24 days ago

SharedWorker does not provide SharedArrayBuffer

Categories

(Core :: DOM: Workers, defect, P3)

Firefox 144
defect

Tracking

()

UNCONFIRMED

People

(Reporter: sberg.fun, Unassigned)

References

(Depends on 1 open bug, Blocks 1 open bug)

Details

Steps to reproduce:

As originally asked about at https://discourse.mozilla.org/t/support-for-sharedarraybuffer-in-sharedworker/145358 "Support for SharedArrayBuffer in SharedWorker?": When serving content with Cross-Origin-Opener-Policy: same-origin and Cross-Origin-Embedder-Policy: require-corp, a SharedWorker does not provide SharedArrayBuffer, and while it allows to create a shared WebAssembly.Memory, that is effectively useless, as that memory object cannot be passed over a channel.

Consider test.js

console.log('test 1:');
console.assert(typeof SharedArrayBuffer !== 'undefined');
console.log('test 2:');
const mem = new WebAssembly.Memory({initial: 1, maximum: 1, shared: true});
const ch = new MessageChannel();
try {
 ch.port1.postMessage(mem);
} catch (e) {
 console.error(e);
}
console.log('done');

and the two scenarios window.html

<html>
 <body>
  <script type="text/javascript" src="test.js"></script>
 </body>
</html>

and sharedworker.html

<html>
 <body>
  <script type="text/javascript">
    new SharedWorker('test.js');
  </script>
 </body>
</html>

Actual results:

While window.html succeeds, sharedworker.html fails with

test 1: test.js:1:9
Assertion failed: test.js:2:9
test 2: test.js:3:9
Error: undefined test.js:9:10
    <anonymous> http://localhost:6931/test.js:9
done test.js:11:9

Expected results:

When setting dom.postMessage.sharedArrayBuffer.bypassCOOP_COEP.insecure.enabled to true (which can only be done in Nightly), sharedworker.html succeeds as well with

test 1: test.js:1:9
test 2: test.js:3:9
done test.js:11:9

The Bugbug bot thinks this bug should belong to the 'Core::JavaScript: WebAssembly' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → JavaScript: WebAssembly
Product: Firefox → Core
Component: JavaScript: WebAssembly → DOM: Workers
Component: DOM: Workers → JavaScript: Standard Library
Severity: -- → S3
Priority: -- → P3
Component: JavaScript: Standard Library → DOM: Workers
Depends on: 1613912

The component has been changed since the backlog priority was decided, so we're resetting it.
For more information, please visit BugBot documentation.

Priority: P3 → --
Priority: -- → P3
You need to log in before you can comment on or make changes to this bug.