Bug 1529796 [wpt PR 15144] - [WPT] [wasm] Add JS-API tests for wasm threads, a=testonly
☠☠ backed out by 66b1aba3fb43 ☠ ☠
authorBen Smith <binji@chromium.org>
Wed, 06 Mar 2019 12:32:28 +0000
changeset 525246 b9c6ed34a2140f3282535705c11592ed77ea8ef7
parent 525245 7a38369a17d31dae839ecfaed990db128840f961
child 525247 d6a61db637182d6005a71fae0df9e6a730f8fff8
push id2032
push userffxbld-merge
push dateMon, 13 May 2019 09:36:57 +0000
treeherdermozilla-release@455c1065dcbe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1529796, 15144, 926307, 1443959, 629308
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1529796 [wpt PR 15144] - [WPT] [wasm] Add JS-API tests for wasm threads, 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: https://github.com/WebAssembly/threads/commit/0b80037ebc7825db0e67c2433f556dd8d07118a2 Bug: chromium:926307 Change-Id: I54decd04abfe11bdb6ac7209240b10a3f6115fb1 Reviewed-on: https://chromium-review.googlesource.com/c/1443959 Reviewed-by: Adam Klein <adamk@chromium.org> Commit-Queue: Ben Smith <binji@chromium.org> Cr-Commit-Position: refs/heads/master@{#629308} -- wpt-commits: 4e1d6d78b38f9aa0253a43b36785f53abf51832f wpt-pr: 15144
testing/web-platform/tests/wasm/jsapi/memory/grow.any.js
--- a/testing/web-platform/tests/wasm/jsapi/memory/grow.any.js
+++ b/testing/web-platform/tests/wasm/jsapi/memory/grow.any.js
@@ -1,13 +1,14 @@
 // META: global=jsshell
 
 function assert_ArrayBuffer(actual, expected, message) {
   // https://github.com/WebAssembly/spec/issues/840
-  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) {
     // https://github.com/tc39/ecma262/issues/678
     let byteLength;
     try {
       byteLength = actual.byteLength;
     } catch (e) {
       byteLength = 0;
@@ -178,8 +179,34 @@ test(() => {
   const result = memory.grow(2, {});
   assert_equals(result, 0);
 
   const newMemory = memory.buffer;
   assert_not_equals(oldMemory, newMemory);
   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");
+
+  // The old and new buffers must have the same value for the
+  // [[ArrayBufferData]] internal slot.
+  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");