Bug 1555487 [wpt PR 17084] - Portals: Use load event in tests, a=testonly
authorAdithya Srinivasan <adithyas@chromium.org>
Thu, 13 Jun 2019 15:11:25 +0000
changeset 479580 f6e9b2ccd4aca775452802ff96201ede20de1190
parent 479579 b0fc5e4b5a1963fbd74e971cd01c5582d0d12395
child 479581 d67f2303d56ebd8dbdfaaa060c2fcd20d1b09861
push id36179
push usercsabou@mozilla.com
push dateThu, 20 Jun 2019 22:06:31 +0000
treeherdermozilla-central@4cde299454c9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1555487, 17084, 1634723, 665136
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 1555487 [wpt PR 17084] - Portals: Use load event in tests, a=testonly Automatic update from web-platform-tests Portals: Use load event in tests Change-Id: Id1bd4f914af9eb3f35f646256fe4d2adaeca214c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1634723 Commit-Queue: Adithya Srinivasan <adithyas@chromium.org> Reviewed-by: Jeremy Roman <jbroman@chromium.org> Reviewed-by: Lucas Gadani <lfg@chromium.org> Cr-Commit-Position: refs/heads/master@{#665136} -- wp5At-commits: 94272e9bc3e9f53ac06e6fd99ae3696bb47fcda1 wpt-pr: 17084
testing/web-platform/tests/portals/portals-activate-resolution.html
testing/web-platform/tests/portals/portals-cross-origin-load.sub.html
testing/web-platform/tests/portals/portals-host-post-message.sub.html
testing/web-platform/tests/portals/portals-post-message.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-host-post-message.sub.html
testing/web-platform/tests/portals/resources/portal-post-message-after-activate-window.html
testing/web-platform/tests/portals/resources/portal-post-message-before-activate-portal.html
testing/web-platform/tests/portals/resources/portal-post-message-before-activate-window.html
testing/web-platform/tests/portals/resources/portal-post-message-during-activate-window.html
testing/web-platform/tests/portals/resources/portal-post-message-portal.html
testing/web-platform/tests/portals/resources/portals-adopt-predecessor-portal.html
testing/web-platform/tests/portals/resources/portals-adopt-predecessor.html
testing/web-platform/tests/portals/resources/portals-nested-portal.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,15 +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) => {
-      portal.onmessage = resolve;
+      portal.onload = resolve;
       win.document.body.appendChild(portal);
     });
 
     return portal.activate();
   });
 </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,17 +1,15 @@
 <!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/simple-portal.html";
-    var receiveMessage = new Promise((resolve, reject) => {
-      portal.onmessage = e => { resolve(e.data) };
+    return new Promise((resolve, reject) => {
+      portal.onload = resolve;
+      document.body.appendChild(portal);
     });
-    document.body.appendChild(portal);
-    var message = await receiveMessage;
-    assert_equals(message, "loaded");
   });
 </script>
 </body>
--- a/testing/web-platform/tests/portals/portals-host-post-message.sub.html
+++ b/testing/web-platform/tests/portals/portals-host-post-message.sub.html
@@ -4,19 +4,18 @@
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 <body>
   <script>
     function createPortal(portalSrc) {
       var portal = document.createElement("portal");
       portal.src = portalSrc;
       return new Promise((resolve, reject) => {
-        portal.onmessage = e => {
-          if (e.data == "loaded")
-            resolve(portal);
+        portal.onload = () => {
+          resolve(portal);
         };
         document.body.appendChild(portal);
       });
     }
 
     async function createPortalAndLoopMessage(portalSrc, params) {
       var portal = await createPortal(portalSrc);
       var waitForResponse = new Promise((resolve, reject) => {
--- a/testing/web-platform/tests/portals/portals-post-message.sub.html
+++ b/testing/web-platform/tests/portals/portals-post-message.sub.html
@@ -12,17 +12,17 @@
     const crossOriginUrl = "http://{{hosts[alt][www]}}:{{ports[http][0]}}/portals/resources/portal-post-message-portal.html"
 
     async function createAndInsertPortal(portalSrc) {
       var portal = document.createElement("portal");
       portal.src = portalSrc;
       document.body.append(portal);
 
       var loadPromise = new Promise((resolve, reject) => {
-        portal.onmessage = resolve;
+        portal.onload = resolve;
       });
       await loadPromise;
       return portal;
     }
 
     function postMessage(portal, ...postMessageArgs) {
       return new Promise((resolve, reject) => {
         portal.postMessage(...postMessageArgs);
--- 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,11 +1,11 @@
 <!DOCTYPE html>
 <body>
   <script>
     var portal = document.createElement("portal");
     portal.src = "simple-portal.html";
-    portal.onmessage = () => {
+    portal.onload = () => {
       portal.activate().catch(e => window.portalHost.postMessage(e.name, "*"));
     }
     document.body.appendChild(portal);
   </script>
 </body>
--- 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,12 +1,12 @@
 <!DOCTYPE html>
 <body>
   <script>
     var portal = document.createElement("portal");
     portal.src = "simple-portal.html"
-    portal.onmessage = () => {
+    portal.onload = () => {
       portal.activate();
       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
@@ -2,17 +2,17 @@
 <body>
   <script>
     var portal1 = document.createElement("portal");
     portal1.src = "simple-portal.html"
     var portal2 = document.createElement("portal");
     portal2.src = "simple-portal.html"
 
     var waitForPortalToLoad = portal => new Promise((resolve, reject) => {
-      portal.onmessage = resolve;
+      portal.onload = resolve;
     });
 
     Promise.all([waitForPortalToLoad(portal1),
                  waitForPortalToLoad(portal2)]).then(() => {
       portal1.activate();
       portal2.activate().catch(e => window.opener.postMessage(e.name, "*"));
     });
 
--- a/testing/web-platform/tests/portals/resources/portal-host-post-message.sub.html
+++ b/testing/web-platform/tests/portals/resources/portal-host-post-message.sub.html
@@ -20,17 +20,16 @@
   function postMessageAndCatchException(...params) {
     try {
       window.portalHost.postMessage(...params);
     } catch (e) {
       window.portalHost.postMessage({errorType: e.name}, "*");
     }
   }
 
-  window.portalHost.postMessage("loaded", "*");
   window.portalHost.addEventListener("message", e => {
     if (e.data.type) {
       var type = e.data.type;
       switch (type) {
         case "message-port":
           postMessageWithMessagePorts();
           return;
         case "array-buffer-without-transfer":
--- a/testing/web-platform/tests/portals/resources/portal-post-message-after-activate-window.html
+++ b/testing/web-platform/tests/portals/resources/portal-post-message-after-activate-window.html
@@ -1,16 +1,16 @@
 <!DOCTYPE html>
 <body>
   <script>
     var portal = document.createElement("portal");
     portal.src = "portal-post-message-portal.html";
     document.body.appendChild(portal);
 
-    portal.onmessage = () => {
+    portal.onload = () => {
       portal.activate().then(() => {
         error = "";
         try {
           portal.postMessage("message");
         }
         catch(err) {
           error = err.name;
         }
--- a/testing/web-platform/tests/portals/resources/portal-post-message-before-activate-portal.html
+++ b/testing/web-platform/tests/portals/resources/portal-post-message-before-activate-portal.html
@@ -7,18 +7,16 @@
   });
 
   var activatePromise = new Promise((resolve, reject) => {
     window.onportalactivate = () => {
       resolve(performance.now());
     }
   });
 
-  window.portalHost.postMessage("loaded", "*");
-
   Promise.all([postMessagePromise, activatePromise])
     .then(values => {
       bc = new BroadcastChannel("portals-post-message-before-activate");
       bc.postMessage({
         postMessageTS: values[0],
         activateTS: values[1]
       });
       bc.close();
--- a/testing/web-platform/tests/portals/resources/portal-post-message-before-activate-window.html
+++ b/testing/web-platform/tests/portals/resources/portal-post-message-before-activate-window.html
@@ -1,13 +1,13 @@
 <!DOCTYPE html>
 <body>
   <script>
     var portal = document.createElement("portal");
     portal.src = "portal-post-message-before-activate-portal.html";
     document.body.appendChild(portal);
 
-    portal.onmessage = () => {
+    portal.onload = () => {
       portal.postMessage("message");
       portal.activate();
     }
   </script>
 </body>
--- a/testing/web-platform/tests/portals/resources/portal-post-message-during-activate-window.html
+++ b/testing/web-platform/tests/portals/resources/portal-post-message-during-activate-window.html
@@ -1,16 +1,16 @@
 <!DOCTYPE html>
 <body>
   <script>
     var portal = document.createElement("portal");
     portal.src = "simple-portal.html";
     document.body.appendChild(portal);
 
-    portal.onmessage = () => {
+    portal.onload = () => {
       portal.activate();
       error = "";
       try {
         portal.postMessage("message");
       } catch (err) {
         error = err.name;
       }
       bc = new BroadcastChannel("portals-post-message-during-activate");
--- a/testing/web-platform/tests/portals/resources/portal-post-message-portal.html
+++ b/testing/web-platform/tests/portals/resources/portal-post-message-portal.html
@@ -1,12 +1,10 @@
 <!DOCTYPE html>
 <script>
-  window.portalHost.postMessage("loaded", "*");
-
   window.portalHost.onmessage = e => {
     var message = {
       origin: e.origin,
       data: e.data,
       sourceIsPortalHost: e.source === window.portalHost,
       gotUserActivation: !!e.userActivation,
       userActivation: {
         isActive: e.userActivation && e.userActivation.isActive,
--- a/testing/web-platform/tests/portals/resources/portals-adopt-predecessor-portal.html
+++ b/testing/web-platform/tests/portals/resources/portals-adopt-predecessor-portal.html
@@ -33,11 +33,9 @@
             var bc_test = new BroadcastChannel(`test-${test}`);
             bc_test.postMessage("passed");
             bc_test.close();
           }
         }
       });
     }
   }
-
-  window.portalHost.postMessage("loaded", "*");
 </script>
--- a/testing/web-platform/tests/portals/resources/portals-adopt-predecessor.html
+++ b/testing/web-platform/tests/portals/resources/portals-adopt-predecessor.html
@@ -1,17 +1,17 @@
 <!doctype html>
 <body>
 </body>
 <script>
   var searchParams = new URL(location).searchParams;
   var test = searchParams.get("test");
   var portal = document.createElement("portal");
   portal.src = `portals-adopt-predecessor-portal.html?test=${test}`;
-  portal.onmessage = e => {
+  portal.onload = () => {
     portal.activate().then(() => {
       window.portalHost.addEventListener("message", e => {
         window.opener.postMessage({test, message: e.data}, "*");
       });
     });
   }
   document.body.appendChild(portal);
 </script>
--- a/testing/web-platform/tests/portals/resources/portals-nested-portal.html
+++ b/testing/web-platform/tests/portals/resources/portals-nested-portal.html
@@ -1,9 +1,9 @@
 <!DOCTYPE html>
 <body>
   <script>
     var portal = document.createElement("portal");
     portal.src = "simple-portal.html";
-    portal.onmessage = e => window.portalHost.postMessage(e.data, "*");
+    portal.onload = e => window.portalHost.postMessage(e.data, "*");
     document.body.appendChild(portal);
   </script>
 </body>
--- a/testing/web-platform/tests/portals/resources/simple-portal.html
+++ b/testing/web-platform/tests/portals/resources/simple-portal.html
@@ -1,6 +1,6 @@
 <!DOCTYPE html>
 <body>
   <script>
-    window.portalHost.postMessage("loaded", "*");
+    window.portalHost.postMessage("ready", "*");
   </script>
 </body>