Bug 1492186 - make browser_pageinfo_images.js more reliable, r=florian
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Thu, 20 Sep 2018 13:51:56 +0000
changeset 437443 5a6cfbdc31fd424fa8744e41b0e3a8a6ccb3faeb
parent 437442 93d1ad43e3d3e3221f33771a5d8a85449994cac6
child 437444 9d576eb300e650b9e50fc197c3d2027291d10c29
push id34683
push userapavel@mozilla.com
push dateThu, 20 Sep 2018 21:54:05 +0000
treeherdermozilla-central@4d3cd0ab7277 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersflorian
bugs1492186
milestone64.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 1492186 - make browser_pageinfo_images.js more reliable, r=florian Differential Revision: https://phabricator.services.mozilla.com/D6323
browser/base/content/test/pageinfo/all_images.html
browser/base/content/test/pageinfo/browser.ini
browser/base/content/test/pageinfo/browser_pageinfo_images.js
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/pageinfo/all_images.html
@@ -0,0 +1,16 @@
+<html>
+  <head>
+    <title>Test for media tab</title>
+    <link rel='shortcut icon' href='dummy_icon.ico'>
+  </head>
+  <body style='background-image:url(about:logo?a);'>
+    <img src='dummy_image.gif'>
+    <ul>
+      <li style='list-style:url(about:logo?b);'>List Item 1</li>
+    </ul>
+    <div style='-moz-border-image: url(about:logo?c) 20 20 20 20;'>test</div>
+    <a href='' style='cursor: url(about:logo?d),default;'>test link</a>
+    <object type='image/svg+xml' width=20 height=20 data='dummy_object.svg'></object>
+  </body>
+</html>");
+
--- a/browser/base/content/test/pageinfo/browser.ini
+++ b/browser/base/content/test/pageinfo/browser.ini
@@ -2,16 +2,18 @@
 
 [browser_pageinfo_firstPartyIsolation.js]
 support-files =
   image.html
   ../general/audio.ogg
   ../general/moz.png
   ../general/video.ogg
 [browser_pageinfo_images.js]
+support-files =
+  all_images.html
 [browser_pageinfo_image_info.js]
 uses-unsafe-cpows = true
 skip-if = (os == 'linux' && e10s) # bug 1161699
 [browser_pageinfo_permissions.js]
 [browser_pageinfo_security.js]
 [browser_pageinfo_svg_image.js]
 support-files =
   svg_image.html
--- a/browser/base/content/test/pageinfo/browser_pageinfo_images.js
+++ b/browser/base/content/test/pageinfo/browser_pageinfo_images.js
@@ -1,48 +1,21 @@
 /* Check proper image url retrieval from all kinds of elements/styles */
 
-function test() {
-  waitForExplicitFinish();
-
-  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
-
-  BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(() => {
-    var pageInfo = BrowserPageInfo(gBrowser.selectedBrowser.currentURI.spec,
-                                   "mediaTab");
-
-    pageInfo.addEventListener("load", function() {
-      pageInfo.onFinished.push(function() {
-        executeSoon(function() {
-          var imageTree = pageInfo.document.getElementById("imagetree");
-          var imageRowsNum = imageTree.view.rowCount;
-
-          ok(imageTree, "Image tree is null (media tab is broken)");
-
-          ok(imageRowsNum == 7, "Number of images listed: " +
-                                imageRowsNum + ", should be 7");
+const TEST_PATH = getRootDirectory(gTestPath).replace("chrome://mochitests/content", "http://example.com");
 
-          pageInfo.close();
-          gBrowser.removeCurrentTab();
-          finish();
-        });
-      });
-    }, {capture: true, once: true});
-  });
+add_task(async function test_all_images_mentioned() {
+  await BrowserTestUtils.withNewTab(TEST_PATH + "all_images.html", async function() {
+    let pageInfo = BrowserPageInfo(gBrowser.selectedBrowser.currentURI.spec,
+                                   "mediaTab");
+    await BrowserTestUtils.waitForEvent(pageInfo, "load");
+    await new Promise(resolve => pageInfo.onFinished.push(() => executeSoon(resolve)));
+    let imageTree = pageInfo.document.getElementById("imagetree");
+    let imageRowsNum = imageTree.view.rowCount;
 
-  BrowserTestUtils.loadURI(gBrowser.selectedBrowser,
-    "data:text/html," +
-    "<html>" +
-    "  <head>" +
-    "    <title>Test for media tab</title>" +
-    "    <link rel='shortcut icon' href='file:///dummy_icon.ico'>" + // Icon
-    "  </head>" +
-    "  <body style='background-image:url(about:logo?a);'>" + // Background
-    "    <img src='file:///dummy_image.gif'>" + // Image
-    "    <ul>" +
-    "      <li style='list-style:url(about:logo?b);'>List Item 1</li>" + // Bullet
-    "    </ul>  " +
-    "    <div style='-moz-border-image: url(about:logo?c) 20 20 20 20;'>test</div>" + // Border
-    "    <a href='' style='cursor: url(about:logo?d),default;'>test link</a>" + // Cursor
-    "    <object type='image/svg+xml' width=20 height=20 data='file:///dummy_object.svg'></object>" + // Object
-    "  </body>" +
-    "</html>");
-}
+    ok(imageTree, "Image tree is null (media tab is broken)");
+
+    ok(imageRowsNum == 7, "Number of images listed: " +
+                          imageRowsNum + ", should be 7");
+
+    pageInfo.close();
+  });
+});