Bug 1586139 - enable reader mode tests in fission, r=mccr8
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Sat, 16 Nov 2019 01:36:09 +0000
changeset 502336 adfdc1b55325d4b7e93381b903d186d73f2cd8f2
parent 502335 69ee727d5b4588e9f666bd99e89ae230b8fcb8e6
child 502337 5ea9b3f1de720e8500ad9dc4c1511ddbad2d02b0
push id114172
push userdluca@mozilla.com
push dateTue, 19 Nov 2019 11:31:10 +0000
treeherdermozilla-inbound@b5c5ba07d3db [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmccr8
bugs1586139
milestone72.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 1586139 - enable reader mode tests in fission, r=mccr8 Differential Revision: https://phabricator.services.mozilla.com/D53180
toolkit/components/reader/test/browser.ini
toolkit/components/reader/test/browser_readerMode.js
toolkit/components/reader/test/browser_readerMode_hidden_nodes.js
--- a/toolkit/components/reader/test/browser.ini
+++ b/toolkit/components/reader/test/browser.ini
@@ -1,34 +1,28 @@
 [DEFAULT]
 support-files = head.js
 [browser_readerMode.js]
 support-files =
   readerModeNonArticle.html
   readerModeArticle.html
   readerModeArticleHiddenNodes.html
-skip-if = fission
 [browser_readerMode_hidden_nodes.js]
 support-files =
   readerModeArticleHiddenNodes.html
-skip-if = fission
 [browser_readerMode_with_anchor.js]
 support-files =
   readerModeArticle.html
 uses-unsafe-cpows = true
-skip-if = fission
 [browser_bug1124271_readerModePinnedTab.js]
 support-files =
   readerModeArticle.html
-skip-if = fission
 [browser_bug1453818_samesite_cookie.js]
 support-files =
   getCookies.html
   linkToGetCookies.html
   setSameSiteCookie.html
   setSameSiteCookie.html^headers^
-skip-if = fission
 [browser_readerMode_readingTime.js]
 support-files =
   readerModeArticle.html
   readerModeArticleShort.html
   readerModeArticleMedium.html
-skip-if = fission
--- a/toolkit/components/reader/test/browser_readerMode.js
+++ b/toolkit/components/reader/test/browser_readerMode.js
@@ -109,17 +109,19 @@ add_task(async function test_reader_butt
     );
   });
 
   info("Got correct URL when copying");
 
   // Switch page back out of reader mode.
   let promisePageShow = BrowserTestUtils.waitForContentEvent(
     tab.linkedBrowser,
-    "pageshow"
+    "pageshow",
+    false,
+    e => e.target.location.href != "about:blank"
   );
   readerButton.click();
   await promisePageShow;
   is(
     gBrowser.selectedBrowser.currentURI.spec,
     url,
     "Back to the original page after clicking active reader mode button"
   );
@@ -159,17 +161,19 @@ add_task(async function test_reader_butt
   is_element_visible(
     readerButton,
     "Reader mode button is present on about:reader even in error state"
   );
 
   // Switch page back out of reader mode.
   promisePageShow = BrowserTestUtils.waitForContentEvent(
     newTab.linkedBrowser,
-    "pageshow"
+    "pageshow",
+    false,
+    e => e.target.location.href != "about:blank"
   );
   readerButton.click();
   await promisePageShow;
   is(
     gBrowser.selectedBrowser.currentURI.spec,
     nonReadableUrl,
     "Back to the original non-reader-able page after clicking active reader mode button"
   );
@@ -222,19 +226,20 @@ add_task(async function test_reader_view
     }
   });
 
   function observeAttribute(element, attribute, triggerFn, checkFn) {
     return new Promise(resolve => {
       let observer = new MutationObserver(mutations => {
         mutations.forEach(mu => {
           if (element.getAttribute(attribute) !== mu.oldValue) {
-            checkFn();
-            resolve();
-            observer.disconnect();
+            if (checkFn()) {
+              resolve();
+              observer.disconnect();
+            }
           }
         });
       });
 
       observer.observe(element, {
         attributes: true,
         attributeOldValue: true,
         attributeFilter: [attribute],
@@ -248,137 +253,120 @@ add_task(async function test_reader_view
   let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser);
   is(
     menuitem.hidden,
     true,
     "menuitem element should have the hidden attribute"
   );
 
   info("Navigate a reader-able page");
-  let waitForPageshow = BrowserTestUtils.waitForContentEvent(
-    tab.linkedBrowser,
-    "pageshow"
-  );
+  function waitForNonBlankPage() {
+    return BrowserTestUtils.waitForContentEvent(
+      tab.linkedBrowser,
+      "pageshow",
+      false,
+      e => e.target.location.href != "about:blank"
+    );
+  }
+  let waitForPageshow = waitForNonBlankPage();
   await observeAttribute(
     menuitem,
     "hidden",
     () => {
       let url = TEST_PATH + "readerModeArticle.html";
       BrowserTestUtils.loadURI(tab.linkedBrowser, url);
     },
-    () => {
-      is(
-        menuitem.hidden,
-        false,
-        "menuitem's hidden attribute should be false on a reader-able page"
-      );
-    }
+    () => !menuitem.hidden
+  );
+  is(
+    menuitem.hidden,
+    false,
+    "menuitem's hidden attribute should be false on a reader-able page"
   );
   await waitForPageshow;
 
   info("Navigate a non-reader-able page");
-  waitForPageshow = BrowserTestUtils.waitForContentEvent(
-    tab.linkedBrowser,
-    "pageshow"
-  );
+  waitForPageshow = waitForNonBlankPage();
   await observeAttribute(
     menuitem,
     "hidden",
     () => {
       let url = TEST_PATH + "readerModeArticleHiddenNodes.html";
       BrowserTestUtils.loadURI(tab.linkedBrowser, url);
     },
-    () => {
-      is(
-        menuitem.hidden,
-        true,
-        "menuitem's hidden attribute should be true on a non-reader-able page"
-      );
-    }
+    () => menuitem.hidden
+  );
+  is(
+    menuitem.hidden,
+    true,
+    "menuitem's hidden attribute should be true on a non-reader-able page"
   );
   await waitForPageshow;
 
   info("Navigate a reader-able page");
-  waitForPageshow = BrowserTestUtils.waitForContentEvent(
-    tab.linkedBrowser,
-    "pageshow"
-  );
+  waitForPageshow = waitForNonBlankPage();
   await observeAttribute(
     menuitem,
     "hidden",
     () => {
       let url = TEST_PATH + "readerModeArticle.html";
       BrowserTestUtils.loadURI(tab.linkedBrowser, url);
     },
-    () => {
-      is(
-        menuitem.hidden,
-        false,
-        "menuitem's hidden attribute should be false on a reader-able page"
-      );
-    }
+    () => !menuitem.hidden
+  );
+  is(
+    menuitem.hidden,
+    false,
+    "menuitem's hidden attribute should be false on a reader-able page"
   );
   await waitForPageshow;
 
   info("Enter Reader Mode");
-  waitForPageshow = BrowserTestUtils.waitForContentEvent(
-    tab.linkedBrowser,
-    "pageshow"
-  );
+  waitForPageshow = waitForNonBlankPage();
   await observeAttribute(
     readerButton,
     "readeractive",
     () => {
       readerButton.click();
     },
-    () => {
-      is(
-        readerButton.getAttribute("readeractive"),
-        "true",
-        "readerButton's readeractive attribute should be true when entering reader mode"
-      );
-    }
+    () => readerButton.getAttribute("readeractive") == "true"
+  );
+  is(
+    readerButton.getAttribute("readeractive"),
+    "true",
+    "readerButton's readeractive attribute should be true when entering reader mode"
   );
   await waitForPageshow;
 
   info("Exit Reader Mode");
-  waitForPageshow = BrowserTestUtils.waitForContentEvent(
-    tab.linkedBrowser,
-    "pageshow"
-  );
+  waitForPageshow = waitForNonBlankPage();
   await observeAttribute(
     readerButton,
     "readeractive",
     () => {
       readerButton.click();
     },
-    () => {
-      is(
-        readerButton.getAttribute("readeractive"),
-        "",
-        "readerButton's readeractive attribute should be empty when reader mode is exited"
-      );
-    }
+    () => !readerButton.getAttribute("readeractive")
+  );
+  ok(
+    !readerButton.getAttribute("readeractive"),
+    "readerButton's readeractive attribute should be empty when reader mode is exited"
   );
   await waitForPageshow;
 
   info("Navigate a non-reader-able page");
-  waitForPageshow = BrowserTestUtils.waitForContentEvent(
-    tab.linkedBrowser,
-    "pageshow"
-  );
+  waitForPageshow = waitForNonBlankPage();
   await observeAttribute(
     menuitem,
     "hidden",
     () => {
       let url = TEST_PATH + "readerModeArticleHiddenNodes.html";
       BrowserTestUtils.loadURI(tab.linkedBrowser, url);
     },
-    () => {
-      is(
-        menuitem.hidden,
-        true,
-        "menuitem's hidden attribute should be true on a non-reader-able page"
-      );
-    }
+    () => menuitem.hidden
+  );
+  is(
+    menuitem.hidden,
+    true,
+    "menuitem's hidden attribute should be true on a non-reader-able page"
   );
   await waitForPageshow;
 });
--- a/toolkit/components/reader/test/browser_readerMode_hidden_nodes.js
+++ b/toolkit/components/reader/test/browser_readerMode_hidden_nodes.js
@@ -33,27 +33,24 @@ add_task(async function test_reader_butt
 
   let tab = (gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser));
   is_element_hidden(
     readerButton,
     "Reader mode button is not present on a new tab"
   );
   // Point tab to a test page that is not reader-able due to hidden nodes.
   let url = TEST_PATH + "readerModeArticleHiddenNodes.html";
-  let paintPromise = ContentTask.spawn(tab.linkedBrowser, "", function() {
-    return new Promise(resolve => {
-      addEventListener("DOMContentLoaded", function onDCL() {
-        removeEventListener("DOMContentLoaded", onDCL);
-        addEventListener("MozAfterPaint", function onPaint() {
-          removeEventListener("MozAfterPaint", onPaint);
-          resolve();
-        });
-      });
-    });
-  });
+  let paintPromise = BrowserTestUtils.waitForContentEvent(
+    tab.linkedBrowser,
+    "MozAfterPaint",
+    false,
+    e =>
+      e.originalTarget.location.href.endsWith("HiddenNodes.html") &&
+      e.originalTarget.document.readyState == "complete"
+  );
   BrowserTestUtils.loadURI(tab.linkedBrowser, url);
   await paintPromise;
 
   is_element_hidden(
     readerButton,
     "Reader mode button is still not present on tab with unreadable content."
   );
 });