Bug 1178163 - Convert browser_bug590206.js to add_task format;r=ttaubert
authorBrian Grinstead <bgrinstead@mozilla.com>
Tue, 28 Jul 2015 14:48:43 -0700
changeset 286853 b1151fef26d49e5cf1ced478b4b87e117e221ba1
parent 286852 5f27cc13a2c2e62fb18ee8dc1d5c9bade4862446
child 286854 f66d51333f6fba0e7ca0f9d87046832fb9fc5750
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersttaubert
bugs1178163, 590206
milestone42.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 1178163 - Convert browser_bug590206.js to add_task format;r=ttaubert
browser/base/content/test/general/browser_bug590206.js
--- a/browser/base/content/test/general/browser_bug590206.js
+++ b/browser/base/content/test/general/browser_bug590206.js
@@ -1,184 +1,140 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
+/*
+ * Test the identity mode UI for a variety of page types
  */
 
 const DUMMY = "browser/browser/base/content/test/general/dummy_page.html";
 
-function loadNewTab(aURL, aCallback) {
-  BrowserTestUtils.openNewForegroundTab(gBrowser, aURL).then(aCallback);
+function loadNewTab(url) {
+  return BrowserTestUtils.openNewForegroundTab(gBrowser, url);
 }
 
 function getIdentityMode() {
   return document.getElementById("identity-box").className;
 }
 
-var TESTS = [
-function test_webpage() {
+// This test is slow on Linux debug e10s
+requestLongerTimeout(2);
+
+add_task(function* test_webpage() {
   let oldTab = gBrowser.selectedTab;
 
-  loadNewTab("http://example.com/" + DUMMY, function(aNewTab) {
-    is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
+  let newTab = yield loadNewTab("http://example.com/" + DUMMY);
+  is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
 
-    gBrowser.selectedTab = oldTab;
-    is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
+  gBrowser.selectedTab = oldTab;
+  is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
 
-    gBrowser.selectedTab = aNewTab;
-    is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
-
-    gBrowser.removeTab(aNewTab);
+  gBrowser.selectedTab = newTab;
+  is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
 
-    runNextTest();
-  });
-},
+  gBrowser.removeTab(newTab);
+});
 
-function test_blank() {
+add_task(function* test_blank() {
   let oldTab = gBrowser.selectedTab;
 
-  loadNewTab("about:blank", function(aNewTab) {
-    is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
+  let newTab = yield loadNewTab("about:blank");
+  is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
 
-    gBrowser.selectedTab = oldTab;
-    is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
+  gBrowser.selectedTab = oldTab;
+  is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
 
-    gBrowser.selectedTab = aNewTab;
-    is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
-
-    gBrowser.removeTab(aNewTab);
+  gBrowser.selectedTab = newTab;
+  is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
 
-    runNextTest();
-  });
-},
+  gBrowser.removeTab(newTab);
+});
 
-function test_chrome() {
+add_task(function* test_chrome() {
   let oldTab = gBrowser.selectedTab;
 
-  loadNewTab("chrome://mozapps/content/extensions/extensions.xul", function(aNewTab) {
-    is(getIdentityMode(), "fileURI", "Identity should be file");
+  let newTab = yield loadNewTab("chrome://mozapps/content/extensions/extensions.xul");
+  is(getIdentityMode(), "fileURI", "Identity should be file");
 
-    gBrowser.selectedTab = oldTab;
-    is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
+  gBrowser.selectedTab = oldTab;
+  is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
 
-    gBrowser.selectedTab = aNewTab;
-    is(getIdentityMode(), "fileURI", "Identity should be file");
-
-    gBrowser.removeTab(aNewTab);
+  gBrowser.selectedTab = newTab;
+  is(getIdentityMode(), "fileURI", "Identity should be file");
 
-    runNextTest();
-  });
-},
+  gBrowser.removeTab(newTab);
+});
 
-function test_https() {
+add_task(function* test_https() {
   let oldTab = gBrowser.selectedTab;
 
-  loadNewTab("https://example.com/" + DUMMY, function(aNewTab) {
-    is(getIdentityMode(), "verifiedDomain", "Identity should be verified");
+  let newTab = yield loadNewTab("https://example.com/" + DUMMY);
+  is(getIdentityMode(), "verifiedDomain", "Identity should be verified");
 
-    gBrowser.selectedTab = oldTab;
-    is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
+  gBrowser.selectedTab = oldTab;
+  is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
 
-    gBrowser.selectedTab = aNewTab;
-    is(getIdentityMode(), "verifiedDomain", "Identity should be verified");
-
-    gBrowser.removeTab(aNewTab);
+  gBrowser.selectedTab = newTab;
+  is(getIdentityMode(), "verifiedDomain", "Identity should be verified");
 
-    runNextTest();
-  });
-},
+  gBrowser.removeTab(newTab);
+});
 
-function test_addons() {
+add_task(function* test_addons() {
   let oldTab = gBrowser.selectedTab;
 
-  loadNewTab("about:addons", function(aNewTab) {
-    is(getIdentityMode(), "chromeUI", "Identity should be chrome");
+  let newTab = yield loadNewTab("about:addons");
+  is(getIdentityMode(), "chromeUI", "Identity should be chrome");
 
-    gBrowser.selectedTab = oldTab;
-    is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
+  gBrowser.selectedTab = oldTab;
+  is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
 
-    gBrowser.selectedTab = aNewTab;
-    is(getIdentityMode(), "chromeUI", "Identity should be chrome");
-
-    gBrowser.removeTab(aNewTab);
+  gBrowser.selectedTab = newTab;
+  is(getIdentityMode(), "chromeUI", "Identity should be chrome");
 
-    runNextTest();
-  });
-},
+  gBrowser.removeTab(newTab);
+});
 
-function test_file() {
+add_task(function* test_file() {
   let oldTab = gBrowser.selectedTab;
   let fileURI = getTestFilePath("");
 
-  loadNewTab(fileURI, function(aNewTab) {
-    is(getIdentityMode(), "fileURI", "Identity should be file");
+  let newTab = yield loadNewTab(fileURI);
+  is(getIdentityMode(), "fileURI", "Identity should be file");
 
-    gBrowser.selectedTab = oldTab;
-    is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
+  gBrowser.selectedTab = oldTab;
+  is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
 
-    gBrowser.selectedTab = aNewTab;
-    is(getIdentityMode(), "fileURI", "Identity should be file");
-
-    gBrowser.removeTab(aNewTab);
+  gBrowser.selectedTab = newTab;
+  is(getIdentityMode(), "fileURI", "Identity should be file");
 
-    runNextTest();
-  });
-},
+  gBrowser.removeTab(newTab);
+});
 
-function test_resource_uri() {
+add_task(function test_resource_uri() {
   let oldTab = gBrowser.selectedTab;
   let dataURI = "resource://gre/modules/Services.jsm"
 
-  loadNewTab(dataURI, function(aNewTab) {
-    is(getIdentityMode(), "fileURI", "Identity should be unknown");
+  let newTab = yield loadNewTab(dataURI);
 
-    gBrowser.selectedTab = oldTab;
-    is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
+  is(getIdentityMode(), "fileURI", "Identity should be unknown");
+
+  gBrowser.selectedTab = oldTab;
+  is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
 
-    gBrowser.selectedTab = aNewTab;
-    is(getIdentityMode(), "fileURI", "Identity should be unknown");
-
-    gBrowser.removeTab(aNewTab);
+  gBrowser.selectedTab = newTab;
+  is(getIdentityMode(), "fileURI", "Identity should be unknown");
 
-    runNextTest();
-  });
-},
+  gBrowser.removeTab(newTab);
+});
 
-function test_data_uri() {
+add_task(function test_data_uri() {
   let oldTab = gBrowser.selectedTab;
   let dataURI = "data:text/html,hi"
 
-  loadNewTab(dataURI, function(aNewTab) {
-    is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
-
-    gBrowser.selectedTab = oldTab;
-    is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
-
-    gBrowser.selectedTab = aNewTab;
-    is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
+  let newTab = yield loadNewTab(dataURI);
+  is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
 
-    gBrowser.removeTab(aNewTab);
-
-    runNextTest();
-  });
-},
-];
-
-var gTestStart = null;
+  gBrowser.selectedTab = oldTab;
+  is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
 
-function runNextTest() {
-  if (gTestStart)
-    info("Test part took " + (Date.now() - gTestStart) + "ms");
-
-  if (TESTS.length == 0) {
-    finish();
-    return;
-  }
+  gBrowser.selectedTab = newTab;
+  is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
 
-  info("Running " + TESTS[0].name);
-  gTestStart = Date.now();
-  TESTS.shift()();
-};
-
-function test() {
-  waitForExplicitFinish();
-
-  runNextTest();
-}
+  gBrowser.removeTab(newTab);
+});