Bug 1330822 - Remove CPOWs from browser_bug633691.js r=Gijs
authorBlake Kaplan <mrbkap@gmail.com>
Wed, 30 Nov 2016 18:00:19 -0800
changeset 463634 e4a95dce8bb83f2d8d83ee72e8c060bd4ffada33
parent 463633 ef6ee3788c6bbe3c6c96f23054b0901ea09cd325
child 463635 e98f322145a5c281e72ef279f9378ade609dc9c5
push id42137
push userjichen@mozilla.com
push dateThu, 19 Jan 2017 15:08:06 +0000
reviewersGijs
bugs1330822, 633691
milestone53.0a1
Bug 1330822 - Remove CPOWs from browser_bug633691.js r=Gijs MozReview-Commit-ID: 829vnw81Xkd
browser/base/content/test/general/browser_bug633691.js
--- a/browser/base/content/test/general/browser_bug633691.js
+++ b/browser/base/content/test/general/browser_bug633691.js
@@ -1,36 +1,28 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/
  */
 
-function test() {
-  waitForExplicitFinish();
-  gBrowser.selectedTab = gBrowser.addTab("data:text/html,<iframe width='700' height='700'></iframe>");
-  // Open a html page with about:certerror in an iframe
-  BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(function() {
-    return ContentTask.spawn(gBrowser.selectedBrowser, "", function() {
-      return new Promise(resolve => {
-        info("Running content task");
-        let listener = e => {
-          removeEventListener("AboutNetErrorLoad", listener, false, true);
-          resolve();
-        };
-        addEventListener("AboutNetErrorLoad", listener, false, true);
-        let iframe = content.document.querySelector("iframe");
-        iframe.src = "https://expired.example.com/";
-      });
-    }).then(testIframeCert);
+add_task(function* test() {
+  const URL = "data:text/html,<iframe width='700' height='700'></iframe>";
+  yield BrowserTestUtils.withNewTab({ gBrowser, url: URL }, function* (browser) {
+    yield ContentTask.spawn(browser,
+                            { is_element_hidden_: is_element_hidden.toSource(),
+                              is_hidden_: is_hidden.toSource() },
+    function* ({ is_element_hidden_, is_hidden_ }) {
+      let loadError =
+        ContentTaskUtils.waitForEvent(this, "AboutNetErrorLoad", false, null, true);
+      let iframe = content.document.querySelector("iframe");
+      iframe.src = "https://expired.example.com/";
+
+      yield loadError;
+
+      let is_hidden = eval(`(() => ${is_hidden_})()`);
+      let is_element_hidden = eval(`(() => ${is_element_hidden_})()`);
+      let doc = content.document.getElementsByTagName("iframe")[0].contentDocument;
+      let aP = doc.getElementById("badCertAdvancedPanel");
+      ok(aP, "Advanced content should exist");
+      void is_hidden; // Quiet eslint warnings (actual use under is_element_hidden)
+      is_element_hidden(aP, "Advanced content should not be visible by default")
+    });
   });
-}
-
-function testIframeCert(e) {
-  // Confirm that the expert section is hidden
-  var doc = gBrowser.contentDocument.getElementsByTagName("iframe")[0].contentDocument;
-  var aP = doc.getElementById("badCertAdvancedPanel");
-  ok(aP, "Advanced content should exist");
-  is_element_hidden(aP, "Advanced content should not be visible by default")
-
-  // Clean up
-  gBrowser.removeCurrentTab();
-
-  finish();
-}
+});