Bug 1529435 [wpt PR 15480] - [wasm] Add JS-API tests for wasm threads, a=testonly
authorSven Sauleau <ssauleau@igalia.com>
Wed, 06 Mar 2019 12:32:13 +0000
changeset 525523 cb2c359d2b4454a9e4138d007b71f20a6c66c90f
parent 525522 05db1c2dc74bd8f32eafb112943468741e581d1c
child 525524 9c9dfe14cdcc50dd3df6c45a991b98faee761f03
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
bugs1529435, 15480
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 1529435 [wpt PR 15480] - [wasm] Add JS-API tests for wasm threads, a=testonly Automatic update from web-platform-tests Update constructor.any.js -- wpt-commits: 7fe165e49f969b4132e70a12678ea7847f844dbf wpt-pr: 15480
testing/web-platform/tests/wasm/jsapi/memory/constructor.any.js
--- a/testing/web-platform/tests/wasm/jsapi/memory/constructor.any.js
+++ b/testing/web-platform/tests/wasm/jsapi/memory/constructor.any.js
@@ -3,25 +3,28 @@
 
 function assert_Memory(memory, expected) {
   assert_equals(Object.getPrototypeOf(memory), WebAssembly.Memory.prototype,
                 "prototype");
   assert_true(Object.isExtensible(memory), "extensible");
 
   // https://github.com/WebAssembly/spec/issues/840
   assert_equals(memory.buffer, memory.buffer, "buffer should be idempotent");
-  assert_equals(Object.getPrototypeOf(memory.buffer), ArrayBuffer.prototype,
-                "prototype of buffer");
-  assert_true(Object.isExtensible(memory.buffer), "buffer extensibility");
+  const isShared = !!expected.shared;
+  const bufferType = isShared ? self.SharedArrayBuffer : ArrayBuffer;
+  assert_equals(Object.getPrototypeOf(memory.buffer), bufferType.prototype,
+                'prototype of buffer');
   assert_equals(memory.buffer.byteLength, 0x10000 * expected.size, "size of buffer");
   if (expected.size > 0) {
     const array = new Uint8Array(memory.buffer);
     assert_equals(array[0], 0, "first element of buffer");
     assert_equals(array[array.byteLength - 1], 0, "last element of buffer");
   }
+  assert_equals(isShared, Object.isFrozen(memory.buffer), "buffer frozen");
+  assert_not_equals(Object.isExtensible(memory.buffer), isShared, "buffer extensibility");
 }
 
 test(() => {
   assert_function_name(WebAssembly.Memory, "Memory", "WebAssembly.Memory");
 }, "name");
 
 test(() => {
   assert_function_length(WebAssembly.Memory, 1, "WebAssembly.Memory");
@@ -79,16 +82,20 @@ for (const value of outOfRangeValues) {
   }, `Out-of-range maximum value in descriptor: ${format_value(value)}`);
 }
 
 test(() => {
   assert_throws(new RangeError(), () => new WebAssembly.Memory({ "initial": 10, "maximum": 9 }));
 }, "Initial value exceeds maximum");
 
 test(() => {
+  assert_throws(new TypeError(), () => new WebAssembly.Memory({ "initial": 10, "shared": true }));
+}, "Shared memory without maximum");
+
+test(() => {
   const proxy = new Proxy({}, {
     has(o, x) {
       assert_unreached(`Should not call [[HasProperty]] with ${x}`);
     },
     get(o, x) {
       return 0;
     },
   });
@@ -123,16 +130,57 @@ test(() => {
   assert_array_equals(order, [
     "initial",
     "initial valueOf",
     "maximum",
     "maximum valueOf",
   ]);
 }, "Order of evaluation for descriptor");
 
+test(t => {
+  const order = [];
+
+  new WebAssembly.Memory({
+    get maximum() {
+      order.push("maximum");
+      return {
+        valueOf() {
+          order.push("maximum valueOf");
+          return 1;
+        },
+      };
+    },
+
+    get initial() {
+      order.push("initial");
+      return {
+        valueOf() {
+          order.push("initial valueOf");
+          return 1;
+        },
+      };
+    },
+
+    get shared() {
+      order.push("shared");
+      return {
+        valueOf: t.unreached_func("should not call shared valueOf"),
+      };
+    },
+  });
+
+  assert_array_equals(order, [
+    "initial",
+    "initial valueOf",
+    "maximum",
+    "maximum valueOf",
+    "shared",
+  ]);
+}, "Order of evaluation for descriptor (with shared)");
+
 test(() => {
   const argument = { "initial": 0 };
   const memory = new WebAssembly.Memory(argument);
   assert_Memory(memory, { "size": 0 });
 }, "Zero initial");
 
 test(() => {
   const argument = { "initial": 4 };
@@ -140,8 +188,14 @@ test(() => {
   assert_Memory(memory, { "size": 4 });
 }, "Non-zero initial");
 
 test(() => {
   const argument = { "initial": 0 };
   const memory = new WebAssembly.Memory(argument, {});
   assert_Memory(memory, { "size": 0 });
 }, "Stray argument");
+
+test(() => {
+  const argument = { "initial": 4, "maximum": 10, shared: true };
+  const memory = new WebAssembly.Memory(argument);
+  assert_Memory(memory, { "size": 4, "shared": true });
+}, "Shared memory");