Skip to content

Commit

Permalink
Bug 1623924 [wpt PR 22359] - XHR/CSS/Compression: use Wasm to get at …
Browse files Browse the repository at this point in the history
…a SharedArrayBuffer instancd, a=testonly

Automatic update from web-platform-tests
XHR/CSS/Compression: use Wasm to get at a SharedArrayBuffer instance

For web-platform-tests/wpt#22358.
--

wpt-commits: c8d8f8e2d426e71c11f86512fadd5d8744413c13
wpt-pr: 22359
  • Loading branch information
annevk authored and moz-wptsync-bot committed Mar 31, 2020
1 parent f03acd3 commit ed125a5
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@ const badChunks = [
// Use a getter to postpone construction so that all tests don't fail where
// SharedArrayBuffer is not yet implemented.
get value() {
return new SharedArrayBuffer();
// See https://github.com/whatwg/html/issues/5380 for why not `new SharedArrayBuffer()`
return new WebAssembly.Memory({ shared:true, initial:1, maximum:1 }).buffer;
}
},
{
name: 'shared Uint8Array',
get value() {
return new Uint8Array(new SharedArrayBuffer())
// See https://github.com/whatwg/html/issues/5380 for why not `new SharedArrayBuffer()`
return new Uint8Array(new WebAssembly.Memory({ shared:true, initial:1, maximum:1 }).buffer)
}
},
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@ const badChunks = [
// Use a getter to postpone construction so that all tests don't fail where
// SharedArrayBuffer is not yet implemented.
get value() {
return new SharedArrayBuffer();
// See https://github.com/whatwg/html/issues/5380 for why not `new SharedArrayBuffer()`
return new WebAssembly.Memory({ shared:true, initial:1, maximum:1 }).buffer;
}
},
{
name: 'shared Uint8Array',
get value() {
return new Uint8Array(new SharedArrayBuffer())
// See https://github.com/whatwg/html/issues/5380 for why not `new SharedArrayBuffer()`
return new Uint8Array(new WebAssembly.Memory({ shared:true, initial:1, maximum:1 }).buffer)
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@

try {
childFragment = await child.layoutNextFragment({
data: { sab: new SharedArrayBuffer(4) }
// See https://github.com/whatwg/html/issues/5380 for why not `new SharedArrayBuffer()`
data: { sab: new WebAssembly.Memory({ shared:true, initial:1, maximum:1 }).buffer }
});
} catch(e) {
// Success! The structured cloning algorithm should have thrown an error.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
async layout(children, edges, constraints, styleMap) {
const childFragments = await Promise.all(children.map(child => child.layoutNextFragment()));

return {autoBlockSize: 0, childFragments, data: {sab: new SharedArrayBuffer(4) }};
// See https://github.com/whatwg/html/issues/5380 for why not `new SharedArrayBuffer()`
return {autoBlockSize: 0, childFragments, data: {sab: new WebAssembly.Memory({ shared:true, initial:1, maximum:1 }).buffer }};
}
});
</script>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// META: title=XMLHttpRequest.send(sharedarraybuffer)

test(() => {
var xhr = new XMLHttpRequest();
var buf = new SharedArrayBuffer();
const xhr = new XMLHttpRequest();
// See https://github.com/whatwg/html/issues/5380 for why not `new SharedArrayBuffer()`
const buf = new WebAssembly.Memory({ shared:true, initial:1, maximum:1 }).buffer;

xhr.open("POST", "./resources/content.py", true);
assert_throws_js(TypeError, function() {
Expand All @@ -13,8 +14,9 @@ test(() => {
["Int8Array", "Uint8Array", "Uint8ClampedArray", "Int16Array", "Uint16Array",
"Int32Array", "Uint32Array", "Float32Array", "Float64Array", "DataView"].forEach((type) => {
test(() => {
var xhr = new XMLHttpRequest();
var arr = new self[type](new SharedArrayBuffer());
const xhr = new XMLHttpRequest();
// See https://github.com/whatwg/html/issues/5380 for why not `new SharedArrayBuffer()`
const arr = new self[type](new WebAssembly.Memory({ shared:true, initial:1, maximum:1 }).buffer);

xhr.open("POST", "./resources/content.py", true);
assert_throws_js(TypeError, function() {
Expand Down

0 comments on commit ed125a5

Please sign in to comment.