Bug 1605566 - MessagePort + wasm - part 5 - tests, r=smaug
☠☠ backed out by 0bb7d3150587 ☠ ☠
authorAndrea Marchesini <amarchesini@mozilla.com>
Wed, 15 Jan 2020 10:01:44 +0000
changeset 510332 39f34852842e1d58860156cba9bc05e8a133a27a
parent 510331 3427a92445c8a735f6f0f1781084ddf2372362b4
child 510333 f4bba00d59cef29deb745e608689e58d45b80394
push id37020
push userccoroiu@mozilla.com
push dateWed, 15 Jan 2020 21:36:21 +0000
treeherdermozilla-central@c35bb210b8ae [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1605566
milestone74.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 1605566 - MessagePort + wasm - part 5 - tests, r=smaug Differential Revision: https://phabricator.services.mozilla.com/D59616
dom/base/test/test_postMessages.html
dom/messagechannel/tests/mochitest.ini
dom/messagechannel/tests/test_wasm.html
testing/web-platform/meta/wasm/serialization/module/window-messagechannel-success.html.ini
testing/web-platform/meta/workers/semantics/structured-clone/shared.html.ini
--- a/dom/base/test/test_postMessages.html
+++ b/dom/base/test/test_postMessages.html
@@ -544,17 +544,17 @@ function test_messagePort() {
 
     let tmp = resolve;
     resolve = null;
     tmp({ data: e.data, ports: e.ports });
   }
 
   runTests({
     clonableObjectsEveryWhere: true,
-    clonableObjectsSameProcess: false,
+    clonableObjectsSameProcess: true,
     transferableObjects: true,
     send(what, ports) {
       return new Promise(function(r, rr) {
         resolve = r;
         try {
           mc.port1.postMessage(what, ports);
         } catch(e) {
           resolve = null;
--- a/dom/messagechannel/tests/mochitest.ini
+++ b/dom/messagechannel/tests/mochitest.ini
@@ -25,8 +25,9 @@ skip-if = (os == "win" && processor == "
 [test_messageChannel_sharedWorker.html]
 [test_messageChannel_sharedWorker2.html]
 [test_messageChannel_any.html]
 [test_messageChannel_forceClose.html]
 [test_messageChannel_bug1178076.html]
 [test_messageChannel_bug1224825.html]
 [test_messageChannel_worker_forceClose.html]
 [test_removedWindow.html]
+[test_wasm.html]
new file mode 100644
--- /dev/null
+++ b/dom/messagechannel/tests/test_wasm.html
@@ -0,0 +1,105 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <meta charset="utf-8">
+  <title>MessagePort + wasm</title>
+  <script src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+
+<script id='myWorker' type='text/worker'>
+self.onmessage = e => {
+  e.ports[0].onmessage = ee => postMessage(ee.data);
+};
+</script>
+
+<script type="application/javascript">
+
+let wasmModule;
+
+function create_wasmModule() {
+  info("Checking if we can play with WebAssembly...");
+
+  if (!SpecialPowers.Cu.getJSTestingFunctions().wasmIsSupported()) {
+    next();
+    return;
+  }
+
+  ok(WebAssembly, "WebAssembly object should exist");
+  ok(WebAssembly.compile, "WebAssembly.compile function should exist");
+
+  const wasmTextToBinary = SpecialPowers.unwrap(SpecialPowers.Cu.getJSTestingFunctions().wasmTextToBinary);
+  const fooModuleCode = wasmTextToBinary(`(module
+    (func $foo (result i32) (i32.const 42))
+    (export "foo" $foo)
+  )`);
+
+  WebAssembly.compile(fooModuleCode).then(m => {
+    ok(m instanceof WebAssembly.Module, "The WasmModule has been compiled.");
+    wasmModule = m;
+    next();
+  }, () => {
+    ok(false, "The compilation of the wasmModule failed.");
+  });
+}
+
+function test_simple() {
+  info("MessagePort without disentangling");
+
+  if (!wasmModule) {
+    next();
+    return;
+  }
+
+  const mc = new MessageChannel();
+  mc.port1.postMessage({ wasmModule });
+  mc.port2.onmessage = e => {
+    ok(e.data.wasmModule instanceof WebAssembly.Module, "WasmModule received");
+    next();
+  };
+}
+
+function test_worker() {
+  info("MessagePort sent to a worker");
+
+  if (!wasmModule) {
+    next();
+    return;
+  }
+
+  const mc = new MessageChannel();
+  mc.port1.postMessage({ wasmModule });
+
+  const blob = new Blob([document.getElementById('myWorker').textContent]);
+  const w = new Worker(URL.createObjectURL(blob));
+  w.postMessage(42, [ mc.port2 ]);
+  w.onmessage = e => {
+    ok(e.data.wasmModule instanceof WebAssembly.Module, "WasmModule received");
+    next();
+  };
+}
+
+const tests = [
+  create_wasmModule,
+
+  test_simple,
+  test_worker,
+];
+
+function next() {
+  if (tests.length === 0) {
+    SimpleTest.finish();
+    return;
+  }
+
+  const test = tests.shift();
+  test();
+}
+
+SimpleTest.waitForExplicitFinish();
+next();
+
+</script>
+</body>
+</html>
deleted file mode 100644
--- a/testing/web-platform/meta/wasm/serialization/module/window-messagechannel-success.html.ini
+++ /dev/null
@@ -1,4 +0,0 @@
-[window-messagechannel-success.html]
-  [postMessaging to a dedicated worker via MessageChannel allows them to instantiate]
-    expected: FAIL
-
deleted file mode 100644
--- a/testing/web-platform/meta/workers/semantics/structured-clone/shared.html.ini
+++ /dev/null
@@ -1,19 +0,0 @@
-[shared.html]
-  [ImageBitmap 1x1 transparent black]
-    expected: FAIL
-
-  [ImageBitmap 1x1 non-transparent non-black]
-    expected: FAIL
-
-  [Array ImageBitmap object, ImageBitmap 1x1 transparent black]
-    expected: FAIL
-
-  [Object ImageBitmap object, ImageBitmap 1x1 transparent black]
-    expected: FAIL
-
-  [Array ImageBitmap object, ImageBitmap 1x1 transparent non-black]
-    expected: FAIL
-
-  [Object ImageBitmap object, ImageBitmap 1x1 transparent non-black]
-    expected: FAIL
-