Skip to content

Commit

Permalink
Bug 1529796 [wpt PR 15144] - [WPT] [wasm] Add JS-API tests for wasm t…
Browse files Browse the repository at this point in the history
…hreads, a=testonly

Automatic update from web-platform-tests
[WPT] [wasm] Add JS-API tests for wasm threads

These are copied from the tests in the WebAssembly spec repo here:
WebAssembly/threads@0b80037

Bug: chromium:926307
Change-Id: I54decd04abfe11bdb6ac7209240b10a3f6115fb1
Reviewed-on: https://chromium-review.googlesource.com/c/1443959
Reviewed-by: Adam Klein <adamkchromium.org>
Commit-Queue: Ben Smith <binjichromium.org>
Cr-Commit-Position: refs/heads/master{#629308}

--

wpt-commits: 4e1d6d78b38f9aa0253a43b36785f53abf51832f
wpt-pr: 15144

UltraBlame original commit: b9c6ed34a2140f3282535705c11592ed77ea8ef7
  • Loading branch information
marco-c committed Oct 4, 2019
1 parent 1cf777a commit ed764b7
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion testing/web-platform/tests/wasm/jsapi/memory/grow.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

function assert_ArrayBuffer(actual, expected, message) {

assert_equals(Object.getPrototypeOf(actual), ArrayBuffer.prototype,
const bufferType = expected.shared ? self.SharedArrayBuffer : ArrayBuffer;
assert_equals(Object.getPrototypeOf(actual), bufferType.prototype,
`${message}: prototype`);
if (expected.detached) {

Expand Down Expand Up @@ -183,3 +184,29 @@ test(() => {
assert_ArrayBuffer(oldMemory, { "detached": true }, "Old buffer after growing");
assert_ArrayBuffer(newMemory, { "size": 2 }, "New buffer after growing");
}, "Stray argument");

test(() => {
const argument = { "initial": 1, "maximum": 2, "shared": true };
const memory = new WebAssembly.Memory(argument);
const oldMemory = memory.buffer;
assert_ArrayBuffer(oldMemory, { "size": 1, "shared": true }, "Buffer before growing");

const result = memory.grow(1);
assert_equals(result, 1);

const newMemory = memory.buffer;
assert_not_equals(oldMemory, newMemory);
assert_ArrayBuffer(oldMemory, { "size": 1, "shared": true }, "Old buffer after growing");
assert_ArrayBuffer(newMemory, { "size": 2, "shared": true }, "New buffer after growing");



const oldArray = new Uint8Array(oldMemory);
const newArray = new Uint8Array(newMemory);
assert_equals(oldArray[0], 0, "old first element");
assert_equals(newArray[0], 0, "new first element");
oldArray[0] = 1;
assert_equals(oldArray[0], 1, "old first element");
assert_equals(newArray[0], 1, "new first element");

}, "Growing shared memory does not detach old buffer");

0 comments on commit ed764b7

Please sign in to comment.