Bug 1550356 [wpt PR 16668] - Portals: Simplify tests (2/5), a=testonly
authorAdithya Srinivasan <adithyas@chromium.org>
Mon, 20 May 2019 15:00:20 +0000
changeset 477407 5a834ddbb8b83775a3f7b7276b2c402c1eb4d9fa
parent 477406 f4469299eefa33256afe3dc53ef2fd1a6eb528f6
child 477408 343976e77b445767f50e58d77f6138c87e7d5b96
push id36116
push usershindli@mozilla.com
push dateThu, 06 Jun 2019 10:00:05 +0000
treeherdermozilla-central@fee989d27558 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1550356, 16668, 1592114, 656471
milestone69.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 1550356 [wpt PR 16668] - Portals: Simplify tests (2/5), a=testonly Automatic update from web-platform-tests Portals: Simplify tests (2/5) Makes resources/simple-portal.html use PortalHost.postMessage instead of a BroadcastChannel, and simplifies some tests that use simple-portal. Change-Id: I7cae1a4412111bda65a01ef4557b5396eb799560 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1592114 Commit-Queue: Adithya Srinivasan <adithyas@chromium.org> Commit-Queue: Jeremy Roman <jbroman@chromium.org> Reviewed-by: Lucas Gadani <lfg@chromium.org> Reviewed-by: Jeremy Roman <jbroman@chromium.org> Cr-Commit-Position: refs/heads/master@{#656471} -- wpt-commits: 7ca32fcc5372f9da279bd79aa797ae33d4dea9dc wpt-pr: 16668
testing/web-platform/tests/portals/portals-activate-resolution.html
testing/web-platform/tests/portals/portals-activate-twice.html
testing/web-platform/tests/portals/portals-cross-origin-load.sub.html
testing/web-platform/tests/portals/resources/portal-activate-inside-portal.html
testing/web-platform/tests/portals/resources/portal-activate-twice-window-1.html
testing/web-platform/tests/portals/resources/portal-activate-twice-window-2.html
testing/web-platform/tests/portals/resources/portal-cross-origin.sub.html
testing/web-platform/tests/portals/resources/simple-portal.html
--- a/testing/web-platform/tests/portals/portals-activate-resolution.html
+++ b/testing/web-platform/tests/portals/portals-activate-resolution.html
@@ -3,19 +3,15 @@
 <script src="/resources/testharnessreport.js"></script>
 <script>
   promise_test(async () => {
     var win = window.open();
     var portal = win.document.createElement("portal");
     portal.src = new URL("resources/simple-portal.html", location.href)
 
     await new Promise((resolve, reject) => {
-      var bc = new BroadcastChannel("simple-portal");
-      bc.onmessage = () => {
-        bc.close();
-        resolve();
-      }
+      portal.onmessage = resolve;
       win.document.body.appendChild(portal);
     });
 
     return portal.activate();
   });
 </script>
--- a/testing/web-platform/tests/portals/portals-activate-twice.html
+++ b/testing/web-platform/tests/portals/portals-activate-twice.html
@@ -1,28 +1,22 @@
 <!DOCTYPE html>
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 <script>
 promise_test(async t => {
   let waitForMessage = new Promise((resolve, reject) => {
-    var bc = new BroadcastChannel("portals-activate-twice");
-    bc.onmessage = e => {
-      resolve(e.data);
-    }
+    window.onmessage = e => resolve(e.data);
   });
   window.open("resources/portal-activate-twice-window-1.html");
   let error = await waitForMessage;
   assert_equals(error, "InvalidStateError");
 }, "Calling activate when a portal is already activating should fail");
 
 promise_test(async t => {
   let waitForMessage = new Promise((resolve, reject) => {
-    var bc = new BroadcastChannel("portals-activate-twice");
-    bc.onmessage = e => {
-      resolve(e.data);
-    }
+    window.onmessage = e => resolve(e.data);
   });
   window.open("resources/portal-activate-twice-window-2.html");
   let error = await waitForMessage;
   assert_equals(error, "InvalidStateError");
 });
 </script>
--- a/testing/web-platform/tests/portals/portals-cross-origin-load.sub.html
+++ b/testing/web-platform/tests/portals/portals-cross-origin-load.sub.html
@@ -1,16 +1,16 @@
 <!DOCTYPE html>
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 <body>
 <script>
   promise_test(async () => {
     var portal = document.createElement("portal");
-    portal.src = "http://{{hosts[alt][www]}}:{{ports[http][0]}}/portals/resources/portal-cross-origin.sub.html";
+    portal.src = "http://{{hosts[alt][www]}}:{{ports[http][0]}}/portals/resources/simple-portal.html";
     var receiveMessage = new Promise((resolve, reject) => {
       portal.onmessage = e => { resolve(e.data) };
     });
     document.body.appendChild(portal);
     var message = await receiveMessage;
     assert_equals(message, "loaded");
   });
 </script>
--- a/testing/web-platform/tests/portals/resources/portal-activate-inside-portal.html
+++ b/testing/web-platform/tests/portals/resources/portal-activate-inside-portal.html
@@ -1,16 +1,14 @@
 <!DOCTYPE html>
 <body>
   <script>
     var portal = document.createElement("portal");
     portal.src = "simple-portal.html";
-    var bc = new BroadcastChannel("simple-portal");
-    bc.onmessage = () => {
-      bc.close();
+    portal.onmessage = () => {
       portal.activate().catch(e => {
         var bc2 = new BroadcastChannel("portals-activate-inside-portal");
         bc2.postMessage(e.name);
         bc2.close();
       });
     }
     document.body.appendChild(portal);
   </script>
--- a/testing/web-platform/tests/portals/resources/portal-activate-twice-window-1.html
+++ b/testing/web-platform/tests/portals/resources/portal-activate-twice-window-1.html
@@ -1,20 +1,12 @@
 <!DOCTYPE html>
 <body>
   <script>
     var portal = document.createElement("portal");
     portal.src = "simple-portal.html"
-
-    var bc = new BroadcastChannel("simple-portal");
-    bc.onmessage = () => {
-      bc.close();
+    portal.onmessage = () => {
       portal.activate();
-      portal.activate().catch(e => {
-        var bc2 = new BroadcastChannel("portals-activate-twice");
-        bc2.postMessage(e.name, "*");
-        bc2.close();
-      });
+      portal.activate().catch(e => window.opener.postMessage(e.name, "*"));
     }
-
     document.body.append(portal);
   </script>
 </body>
--- a/testing/web-platform/tests/portals/resources/portal-activate-twice-window-2.html
+++ b/testing/web-platform/tests/portals/resources/portal-activate-twice-window-2.html
@@ -1,33 +1,22 @@
 <!DOCTYPE html>
 <body>
   <script>
     var portal1 = document.createElement("portal");
     portal1.src = "simple-portal.html"
     var portal2 = document.createElement("portal");
     portal2.src = "simple-portal.html"
 
-    var bc = new BroadcastChannel("simple-portal");
-    var waitForPortalsToLoad = new Promise((resolve, reject) => {
-      var count = 0;
-      bc.onmessage = () => {
-        count++;
-        if (count == 2) {
-          bc.close();
-          resolve();
-        }
-      }
+    var waitForPortalToLoad = portal => new Promise((resolve, reject) => {
+      portal.onmessage = resolve;
     });
 
-    waitForPortalsToLoad.then(() => {
+    Promise.all([waitForPortalToLoad(portal1),
+                 waitForPortalToLoad(portal2)]).then(() => {
       portal1.activate();
-      portal2.activate().catch(e => {
-        var bc2 = new BroadcastChannel("portals-activate-twice");
-        bc2.postMessage(e.name, "*");
-        bc2.close();
-      });
+      portal2.activate().catch(e => window.opener.postMessage(e.name, "*"));
     });
 
     document.body.append(portal1);
     document.body.append(portal2);
   </script>
 </body>
deleted file mode 100644
--- a/testing/web-platform/tests/portals/resources/portal-cross-origin.sub.html
+++ /dev/null
@@ -1,6 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <script>
-    window.portalHost.postMessage("loaded", "*");
-  </script>
-</body>
--- a/testing/web-platform/tests/portals/resources/simple-portal.html
+++ b/testing/web-platform/tests/portals/resources/simple-portal.html
@@ -1,8 +1,6 @@
 <!DOCTYPE html>
 <body>
   <script>
-    var bc = new BroadcastChannel("simple-portal");
-    bc.postMessage("loaded");
-    bc.close();
+    window.portalHost.postMessage("loaded", "*");
   </script>
 </body>