Bug 1318389 - Move single run captive portal test cases to separate test file. r=Gijs, a=test-only
authorNihanth Subramanya <nhnt11@gmail.com>
Fri, 17 Feb 2017 01:05:38 +0530
changeset 376460 4b3e3400ae190eea50b7d84596baaf5e3e65324b
parent 376459 3163a9a12db6371be57c54362ea8d4ca1d083e04
child 376461 92c51788ef5270afae43d05c9661e99fb172e4da
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs, test-only
bugs1318389
milestone53.0a2
Bug 1318389 - Move single run captive portal test cases to separate test file. r=Gijs, a=test-only MozReview-Commit-ID: Ha3w2g17BP0
browser/base/content/test/captivePortal/browser.ini
browser/base/content/test/captivePortal/browser_CaptivePortalWatcher.js
browser/base/content/test/captivePortal/browser_CaptivePortalWatcher_1.js
--- a/browser/base/content/test/captivePortal/browser.ini
+++ b/browser/base/content/test/captivePortal/browser.ini
@@ -1,7 +1,9 @@
 [DEFAULT]
 support-files =
   head.js
 
 [browser_CaptivePortalWatcher.js]
 skip-if = os == "win" # Bug 1313894
+[browser_CaptivePortalWatcher_1.js]
+skip-if = os == "win" # Bug 1313894
 [browser_captivePortal_certErrorUI.js]
--- a/browser/base/content/test/captivePortal/browser_CaptivePortalWatcher.js
+++ b/browser/base/content/test/captivePortal/browser_CaptivePortalWatcher.js
@@ -108,100 +108,12 @@ let testCasesForBothSuccessAndAbort = [
     yield freePortal(aSuccess);
     ensureNoPortalNotification(win1);
     ensureNoPortalNotification(win2);
     yield closeWindowAndWaitForXulWindowVisible(win2);
     yield closeWindowAndWaitForXulWindowVisible(win1);
   },
 ];
 
-let singleRunTestCases = [
-  /**
-   * A portal is detected when there's no browser window,
-   * then a browser window is opened, and the portal is logged into
-   * and redirects to a different page. The portal tab should be added
-   * and focused when the window is opened, and left open after login
-   * since it redirected.
-   */
-  function* test_detectedWithNoBrowserWindow_Redirect() {
-    yield portalDetected();
-    let win = yield focusWindowAndWaitForPortalUI();
-    let browser = win.gBrowser.selectedTab.linkedBrowser;
-    let loadPromise =
-      BrowserTestUtils.browserLoaded(browser, false, CANONICAL_URL_REDIRECTED);
-    BrowserTestUtils.loadURI(browser, CANONICAL_URL_REDIRECTED);
-    yield loadPromise;
-    yield freePortal(true);
-    ensurePortalTab(win);
-    ensureNoPortalNotification(win);
-    yield closeWindowAndWaitForXulWindowVisible(win);
-  },
-
-  /**
-   * Test the various expected behaviors of the "Show Login Page" button
-   * in the captive portal notification. The button should be visible for
-   * all tabs except the captive portal tab, and when clicked, should
-   * ensure a captive portal tab is open and select it.
-   */
-  function* test_showLoginPageButton() {
-    let win = yield openWindowAndWaitForFocus();
-    yield portalDetected();
-    let notification = ensurePortalNotification(win);
-    testShowLoginPageButtonVisibility(notification, "visible");
-
-    function testPortalTabSelectedAndButtonNotVisible() {
-      is(win.gBrowser.selectedTab, tab, "The captive portal tab should be selected.");
-      testShowLoginPageButtonVisibility(notification, "hidden");
-    }
-
-    let button = notification.querySelector("button.notification-button");
-    function* clickButtonAndExpectNewPortalTab() {
-      let p = BrowserTestUtils.waitForNewTab(win.gBrowser, CANONICAL_URL);
-      button.click();
-      let tab = yield p;
-      is(win.gBrowser.selectedTab, tab, "The captive portal tab should be selected.");
-      return tab;
-    }
-
-    // Simulate clicking the button. The portal tab should be opened and
-    // selected and the button should hide.
-    let tab = yield clickButtonAndExpectNewPortalTab();
-    testPortalTabSelectedAndButtonNotVisible();
-
-    // Close the tab. The button should become visible.
-    yield BrowserTestUtils.removeTab(tab);
-    ensureNoPortalTab(win);
-    testShowLoginPageButtonVisibility(notification, "visible");
-
-    // When the button is clicked, a new portal tab should be opened and
-    // selected.
-    tab = yield clickButtonAndExpectNewPortalTab();
-
-    // Open another arbitrary tab. The button should become visible. When it's clicked,
-    // the portal tab should be selected.
-    let anotherTab = yield BrowserTestUtils.openNewForegroundTab(win.gBrowser);
-    testShowLoginPageButtonVisibility(notification, "visible");
-    button.click();
-    is(win.gBrowser.selectedTab, tab, "The captive portal tab should be selected.");
-
-    // Close the portal tab and select the arbitrary tab. The button should become
-    // visible and when it's clicked, a new portal tab should be opened.
-    yield BrowserTestUtils.removeTab(tab);
-    win.gBrowser.selectedTab = anotherTab;
-    testShowLoginPageButtonVisibility(notification, "visible");
-    tab = yield clickButtonAndExpectNewPortalTab();
-
-    yield BrowserTestUtils.removeTab(anotherTab);
-    yield freePortal(true);
-    ensureNoPortalTab(win);
-    ensureNoPortalNotification(win);
-    yield closeWindowAndWaitForXulWindowVisible(win);
-  },
-];
-
 for (let testcase of testCasesForBothSuccessAndAbort) {
   add_task(testcase.bind(null, true));
   add_task(testcase.bind(null, false));
 }
-
-for (let testcase of singleRunTestCases) {
-  add_task(testcase);
-}
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/captivePortal/browser_CaptivePortalWatcher_1.js
@@ -0,0 +1,91 @@
+"use strict";
+
+add_task(setupPrefsAndRecentWindowBehavior);
+
+let testcases = [
+  /**
+   * A portal is detected when there's no browser window,
+   * then a browser window is opened, and the portal is logged into
+   * and redirects to a different page. The portal tab should be added
+   * and focused when the window is opened, and left open after login
+   * since it redirected.
+   */
+  function* test_detectedWithNoBrowserWindow_Redirect() {
+    yield portalDetected();
+    let win = yield focusWindowAndWaitForPortalUI();
+    let browser = win.gBrowser.selectedTab.linkedBrowser;
+    let loadPromise =
+      BrowserTestUtils.browserLoaded(browser, false, CANONICAL_URL_REDIRECTED);
+    BrowserTestUtils.loadURI(browser, CANONICAL_URL_REDIRECTED);
+    yield loadPromise;
+    yield freePortal(true);
+    ensurePortalTab(win);
+    ensureNoPortalNotification(win);
+    yield closeWindowAndWaitForXulWindowVisible(win);
+  },
+
+  /**
+   * Test the various expected behaviors of the "Show Login Page" button
+   * in the captive portal notification. The button should be visible for
+   * all tabs except the captive portal tab, and when clicked, should
+   * ensure a captive portal tab is open and select it.
+   */
+  function* test_showLoginPageButton() {
+    let win = yield openWindowAndWaitForFocus();
+    yield portalDetected();
+    let notification = ensurePortalNotification(win);
+    testShowLoginPageButtonVisibility(notification, "visible");
+
+    function testPortalTabSelectedAndButtonNotVisible() {
+      is(win.gBrowser.selectedTab, tab, "The captive portal tab should be selected.");
+      testShowLoginPageButtonVisibility(notification, "hidden");
+    }
+
+    let button = notification.querySelector("button.notification-button");
+    function* clickButtonAndExpectNewPortalTab() {
+      let p = BrowserTestUtils.waitForNewTab(win.gBrowser, CANONICAL_URL);
+      button.click();
+      let tab = yield p;
+      is(win.gBrowser.selectedTab, tab, "The captive portal tab should be selected.");
+      return tab;
+    }
+
+    // Simulate clicking the button. The portal tab should be opened and
+    // selected and the button should hide.
+    let tab = yield clickButtonAndExpectNewPortalTab();
+    testPortalTabSelectedAndButtonNotVisible();
+
+    // Close the tab. The button should become visible.
+    yield BrowserTestUtils.removeTab(tab);
+    ensureNoPortalTab(win);
+    testShowLoginPageButtonVisibility(notification, "visible");
+
+    // When the button is clicked, a new portal tab should be opened and
+    // selected.
+    tab = yield clickButtonAndExpectNewPortalTab();
+
+    // Open another arbitrary tab. The button should become visible. When it's clicked,
+    // the portal tab should be selected.
+    let anotherTab = yield BrowserTestUtils.openNewForegroundTab(win.gBrowser);
+    testShowLoginPageButtonVisibility(notification, "visible");
+    button.click();
+    is(win.gBrowser.selectedTab, tab, "The captive portal tab should be selected.");
+
+    // Close the portal tab and select the arbitrary tab. The button should become
+    // visible and when it's clicked, a new portal tab should be opened.
+    yield BrowserTestUtils.removeTab(tab);
+    win.gBrowser.selectedTab = anotherTab;
+    testShowLoginPageButtonVisibility(notification, "visible");
+    tab = yield clickButtonAndExpectNewPortalTab();
+
+    yield BrowserTestUtils.removeTab(anotherTab);
+    yield freePortal(true);
+    ensureNoPortalTab(win);
+    ensureNoPortalNotification(win);
+    yield closeWindowAndWaitForXulWindowVisible(win);
+  },
+];
+
+for (let testcase of testcases) {
+  add_task(testcase);
+}