Bug 1408754 - Created configuration for TabCrashed r?jaws draft
authorChris Cho <chochri5@msu.edu>
Sun, 15 Oct 2017 12:43:47 -0400
changeset 707923 c31a89224cbfa07d394a0d36b17464678375d362
parent 703549 da90245d47b17c750560dedb5cbe1973181166e3
child 743070 66107cfe830d2afa8f55601b06303db96aeb83f0
push id92254
push userbmo:chochri5@msu.edu
push dateWed, 06 Dec 2017 01:00:13 +0000
reviewersjaws
bugs1408754
milestone59.0a1
Bug 1408754 - Created configuration for TabCrashed r?jaws MozReview-Commit-ID: 8v4V0nrUIe2
browser/tools/mozscreenshots/head.js
browser/tools/mozscreenshots/mozscreenshots/extension/ConfigurationHelpers.jsm
browser/tools/mozscreenshots/mozscreenshots/extension/configurations/ControlCenter.jsm
browser/tools/mozscreenshots/mozscreenshots/extension/configurations/TabCrashed.jsm
browser/tools/mozscreenshots/mozscreenshots/extension/configurations/Tabs.jsm
browser/tools/mozscreenshots/mozscreenshots/extension/jar.mn
--- a/browser/tools/mozscreenshots/head.js
+++ b/browser/tools/mozscreenshots/head.js
@@ -6,32 +6,34 @@
 
 "use strict";
 
 const chromeRegistry = Cc["@mozilla.org/chrome/chrome-registry;1"].getService(Ci.nsIChromeRegistry);
 const env = Cc["@mozilla.org/process/environment;1"].getService(Ci.nsIEnvironment);
 const EXTENSION_DIR = "chrome://mochitests/content/browser/browser/tools/mozscreenshots/mozscreenshots/extension/mozscreenshots/browser/";
 
 let TestRunner;
+let ConfigurationHelpers;
 
 async function setup() {
   // This timeout doesn't actually end the job even if it is hit - the buildbot timeout will
   // handle things for us if the test actually hangs.
   requestLongerTimeout(100);
 
   info("installing extension temporarily");
   let chromeURL = Services.io.newURI(EXTENSION_DIR);
   let dir = chromeRegistry.convertChromeURL(chromeURL).QueryInterface(Ci.nsIFileURL).file;
   await AddonManager.installTemporaryAddon(dir);
 
   info("Checking for mozscreenshots extension");
   return new Promise((resolve) => {
     AddonManager.getAddonByID("mozscreenshots@mozilla.org", (aAddon) => {
       isnot(aAddon, null, "The mozscreenshots extension should be installed");
       TestRunner = Cu.import("chrome://mozscreenshots/content/TestRunner.jsm", {}).TestRunner;
+      ConfigurationHelpers = Cu.import("chrome://mozscreenshots/content/ConfigurationHelpers.jsm", {}).ConfigurationHelpers;
       TestRunner.initTest(this);
       resolve();
     });
   });
 }
 
 /**
  * Used by pre-defined sets of configurations to decide whether to run for a build.
new file mode 100644
--- /dev/null
+++ b/browser/tools/mozscreenshots/mozscreenshots/extension/ConfigurationHelpers.jsm
@@ -0,0 +1,45 @@
+"use strict";
+
+this.EXPORTED_SYMBOLS = ["ConfigurationHelpers"];
+
+const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
+const env = Cc["@mozilla.org/process/environment;1"].getService(Ci.nsIEnvironment);
+const APPLY_CONFIG_TIMEOUT_MS = 60 * 1000;
+const HOME_PAGE = "chrome://mozscreenshots/content/lib/mozscreenshots.html";
+
+Cu.import("resource://gre/modules/Services.jsm");
+Cu.import("resource://gre/modules/Timer.jsm");
+
+function closeAllButOneTab(url = "about:blank") {
+  let browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
+  let gBrowser = browserWindow.gBrowser;
+  // Close all tabs except the last so we don't quit the browser.
+  while (gBrowser.tabs.length > 1)
+    gBrowser.removeTab(gBrowser.selectedTab, {animate: false});
+  gBrowser.selectedBrowser.loadURI(url);
+  if (gBrowser.selectedTab.pinned)
+    gBrowser.unpinTab(gBrowser.selectedTab);
+  let newTabButton = browserWindow.document.getAnonymousElementByAttribute(browserWindow.gBrowser.tabContainer, "class", "tabs-newtab-button");
+  hoverTab(newTabButton, false);
+}
+
+function hoverTab(tab, hover = true) {
+  const inIDOMUtils = Cc["@mozilla.org/inspector/dom-utils;1"].getService(Ci.inIDOMUtils);
+  if (hover) {
+    inIDOMUtils.addPseudoClassLock(tab, ":hover");
+  } else {
+    inIDOMUtils.clearPseudoClassLocks(tab);
+  }
+  // XXX TODO: this isn't necessarily testing what we ship
+  if (tab.nextElementSibling)
+    tab.nextElementSibling.setAttribute("afterhovered", hover || null);
+  if (tab.previousElementSibling)
+    tab.previousElementSibling.setAttribute("beforehovered", hover || null);
+}
+
+async function loadPage(url) {
+  let browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
+  let gBrowser = browserWindow.gBrowser;
+  BrowserTestUtils.loadURI(gBrowser.selectedBrowser, url);
+  await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser, false, url);
+}
--- a/browser/tools/mozscreenshots/mozscreenshots/extension/configurations/ControlCenter.jsm
+++ b/browser/tools/mozscreenshots/mozscreenshots/extension/configurations/ControlCenter.jsm
@@ -242,23 +242,16 @@ this.ControlCenter = {
         gBrowser.ownerGlobal.document.querySelector("#tracking-action-unblock").click();
         await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser, false, TRACKING_PAGE);
         await openIdentityPopup();
       },
     },
   },
 };
 
-async function loadPage(url) {
-  let browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
-  let gBrowser = browserWindow.gBrowser;
-  BrowserTestUtils.loadURI(gBrowser.selectedBrowser, url);
-  await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser, false, url);
-}
-
 async function openIdentityPopup(expand) {
   let browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
   let gBrowser = browserWindow.gBrowser;
   let { gIdentityHandler } = gBrowser.ownerGlobal;
   gIdentityHandler._identityPopup.hidePopup();
   gIdentityHandler._identityBox.querySelector("#identity-icon").click();
   if (expand) {
     // give some time for opening to avoid weird style issues
new file mode 100644
--- /dev/null
+++ b/browser/tools/mozscreenshots/mozscreenshots/extension/configurations/TabCrashed.jsm
@@ -0,0 +1,25 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+this.EXPORTED_SYMBOLS = ["TabCrashed"];
+
+const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
+
+Cu.import("resource://gre/modules/Services.jsm");
+Cu.import("resource://gre/modules/Timer.jsm");
+
+this.TabCrashed = {
+
+  init(libDir) {},
+
+  configurations: {
+    tabCrashed: {
+      async applyConfig() {
+        await loadpage("about:tabcrashed");
+      }
+    }
+  },
+};
\ No newline at end of file
--- a/browser/tools/mozscreenshots/mozscreenshots/extension/configurations/Tabs.jsm
+++ b/browser/tools/mozscreenshots/mozscreenshots/extension/configurations/Tabs.jsm
@@ -129,36 +129,9 @@ function fiveTabsHelper() {
     CUST_TAB,
   ],
   {
     inBackground: true,
     replace: true,
     triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal()
   });
   browserWindow.gBrowser.selectTabAtIndex(1);
-}
-
-function closeAllButOneTab(url = "about:blank") {
-  let browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
-  let gBrowser = browserWindow.gBrowser;
-  // Close all tabs except the last so we don't quit the browser.
-  while (gBrowser.tabs.length > 1)
-    gBrowser.removeTab(gBrowser.selectedTab, {animate: false});
-  gBrowser.selectedBrowser.loadURI(url);
-  if (gBrowser.selectedTab.pinned)
-    gBrowser.unpinTab(gBrowser.selectedTab);
-  let newTabButton = browserWindow.document.getAnonymousElementByAttribute(browserWindow.gBrowser.tabContainer, "class", "tabs-newtab-button toolbarbutton-1");
-  hoverTab(newTabButton, false);
-}
-
-function hoverTab(tab, hover = true) {
-  const inIDOMUtils = Cc["@mozilla.org/inspector/dom-utils;1"].getService(Ci.inIDOMUtils);
-  if (hover) {
-    inIDOMUtils.addPseudoClassLock(tab, ":hover");
-  } else {
-    inIDOMUtils.clearPseudoClassLocks(tab);
-  }
-  // XXX TODO: this isn't necessarily testing what we ship
-  if (tab.nextElementSibling)
-    tab.nextElementSibling.setAttribute("afterhovered", hover || null);
-  if (tab.previousElementSibling)
-    tab.previousElementSibling.setAttribute("beforehovered", hover || null);
-}
+}
\ No newline at end of file
--- a/browser/tools/mozscreenshots/mozscreenshots/extension/jar.mn
+++ b/browser/tools/mozscreenshots/mozscreenshots/extension/jar.mn
@@ -1,6 +1,7 @@
 mozscreenshots.jar:
 % content mozscreenshots chrome/mozscreenshots/
   Screenshot.jsm
   TestRunner.jsm
+  ConfigurationHelpers.jsm
   configurations/ (configurations/*.jsm)
   lib/            (lib/*)