Skip to content

Commit

Permalink
WebAudio/OrientationSensor/Portals: use Wasm to get a SharedArrayBuff…
Browse files Browse the repository at this point in the history
…er instance

For #22358.
  • Loading branch information
annevk committed Mar 20, 2020
1 parent 02b166f commit bd2a8a5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
4 changes: 3 additions & 1 deletion orientation-sensor/orientation-sensor-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ async function checkPopulateMatrix(t, sensorProvider, sensorType) {

// Throws if passed SharedArrayBuffer view.
assert_throws_js(TypeError,
() => sensor.populateMatrix(new Float32Array(new SharedArrayBuffer(16))));
// See https://github.com/whatwg/html/issues/5380 for why not `new SharedArrayBuffer()`
// WebAssembly.Memory's size is in multiples of 64 KiB
() => sensor.populateMatrix(new Float32Array(new WebAssembly.Memory({ shared:true, initial:1, maximum:1 }).buffer)));

sensor.start();

Expand Down
3 changes: 2 additions & 1 deletion portals/portal-activate-data.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@
const w = await openBlankPortalHost();
await promise_rejects_dom(
t, 'DataCloneError', w.DOMException,
openPortalAndActivate('', {data: new SharedArrayBuffer}, w));
// See https://github.com/whatwg/html/issues/5380 for why not `new SharedArrayBuffer()`
openPortalAndActivate('', {data: new WebAssembly.Memory({ shared:true, initial:1, maximum:1 }).buffer}, w));
}, "A SharedArrayBuffer cannot be passed through activate data.");

promise_test(async t => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@
buffer.copyFromChannel(x, 3);
}, '7: buffer.copyFromChannel(x, 3)').throw(DOMException, 'IndexSizeError');

let shared_buffer = new Float32Array(new SharedArrayBuffer(32));
// See https://github.com/whatwg/html/issues/5380 for why not `new SharedArrayBuffer()`
// WebAssembly.Memory's size is in multiples of 64 KiB
const shared_buffer = new Float32Array(new WebAssembly.Memory({ shared:true, initial:1, maximum:1 }).buffer);
should(
() => {
buffer.copyFromChannel(shared_buffer, 0);
Expand Down Expand Up @@ -202,7 +204,9 @@
buffer.copyToChannel(x, 3);
}, '6: buffer.copyToChannel(x, 3)').throw(DOMException, 'IndexSizeError');

let shared_buffer = new Float32Array(new SharedArrayBuffer(32));
// See https://github.com/whatwg/html/issues/5380 for why not `new SharedArrayBuffer()`
// WebAssembly.Memory's size is in multiples of 64 KiB
const shared_buffer = new Float32Array(new WebAssembly.Memory({ shared:true, initial:1, maximum:1 }).buffer);
should(
() => {
buffer.copyToChannel(shared_buffer, 0);
Expand Down

0 comments on commit bd2a8a5

Please sign in to comment.