Bug 1530765 - Replace waitForEvent in the browser_pageinfo_firstPartyIsolation.js by the BrowserTestUtils.waitForEvent utility function. r=johannh CLOSED TREE
authorjawad <ijawadak@gmail.com>
Wed, 27 Feb 2019 19:40:17 +0500
changeset 519624 e743e4fa9a4d174b09688eb06b9689f4589d964d
parent 519623 2abeddffd18c59dcb69420ed52b2fa798ef19c39
child 519625 584d1d57db0b1474ec36244b5024c1a24876d089
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjohannh
bugs1530765
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 1530765 - Replace waitForEvent in the browser_pageinfo_firstPartyIsolation.js by the BrowserTestUtils.waitForEvent utility function. r=johannh CLOSED TREE
browser/base/content/test/pageinfo/browser_pageinfo_firstPartyIsolation.js
--- a/browser/base/content/test/pageinfo/browser_pageinfo_firstPartyIsolation.js
+++ b/browser/base/content/test/pageinfo/browser_pageinfo_firstPartyIsolation.js
@@ -1,15 +1,10 @@
 const Cm = Components.manager;
 
-function waitForEvent(elem, event) {
-  return new Promise(resolve => {
-    elem.addEventListener(event, resolve, {capture: true, once: true});
-  });
-}
 
 function testFirstPartyDomain(pageInfo) {
   return new Promise(resolve => {
     const EXPECTED_DOMAIN = "example.com";
     info("pageInfo load");
     pageInfo.onFinished.push(async function() {
       info("pageInfo onfinished");
       let tree = pageInfo.document.getElementById("imagetree");
@@ -27,19 +22,19 @@ function testFirstPartyDomain(pageInfo) 
         let preview = pageInfo.document.getElementById("thepreviewimage");
         info("preview.src=" + preview.src);
 
         // For <img>, we will query imgIRequest.imagePrincipal later, so we wait
         // for loadend event. For <audio> and <video>, so far we only can get
         // the triggeringprincipal attribute on the node, so we simply wait for
         // loadstart.
         if (i == 0) {
-          await waitForEvent(preview, "loadend");
+          await BrowserTestUtils.waitForEvent(preview, "loadend");
         } else {
-          await waitForEvent(preview, "loadstart");
+          await BrowserTestUtils.waitForEvent(preview, "loadstart");
         }
 
         info("preview load " + i);
 
         // Originally thepreviewimage is loaded with SystemPrincipal, therefore
         // it won't have origin attributes, now we've changed to loadingPrincipal
         // to the content in bug 1376971, it should have firstPartyDomain set.
         if (i == 0) {
@@ -76,17 +71,17 @@ async function test() {
   BrowserTestUtils.loadURI(gBrowser.selectedBrowser, url);
   await loadPromise;
 
   // Pass a dummy imageElement, if there isn't an imageElement, pageInfo.js
   // will do a preview, however this sometimes will cause intermittent failures,
   // see bug 1403365.
   let pageInfo = BrowserPageInfo(url, "mediaTab", {});
   info("waitForEvent pageInfo");
-  await waitForEvent(pageInfo, "load");
+  await BrowserTestUtils.waitForEvent(pageInfo, "load");
 
   info("calling testFirstPartyDomain");
   await testFirstPartyDomain(pageInfo);
 
   pageInfo.close();
   gBrowser.removeCurrentTab();
   finish();
 }