Bug 1268648 - Add a mozscreenshots configuration for control center. r=MattN
authorJohann Hofmann <jhofmann@mozilla.com>
Mon, 25 Jul 2016 12:49:53 +0200
changeset 309222 61340bd78a4bf05890f4b84a6ca57ba01c0ee29b
parent 309221 dfddc9138f8848d654ee62cf6648ac3f838345dd
child 309223 6f2ba7787816fd01f77c30e3bdb68400db74bf0c
push id30558
push userkwierso@gmail.com
push dateFri, 12 Aug 2016 21:37:53 +0000
treeherdermozilla-central@2ed7e61b988d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMattN
bugs1268648
milestone51.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 1268648 - Add a mozscreenshots configuration for control center. r=MattN MozReview-Commit-ID: 1RkPqLRPUgT
browser/tools/mozscreenshots/browser.ini
browser/tools/mozscreenshots/controlCenter/browser.ini
browser/tools/mozscreenshots/controlCenter/browser_controlCenter.js
browser/tools/mozscreenshots/moz.build
browser/tools/mozscreenshots/mozscreenshots/extension/configurations/ControlCenter.jsm
browser/tools/mozscreenshots/mozscreenshots/extension/lib/controlCenter/mixed.html
browser/tools/mozscreenshots/mozscreenshots/extension/lib/controlCenter/mixed_active.html
browser/tools/mozscreenshots/mozscreenshots/extension/lib/controlCenter/mixed_passive.html
browser/tools/mozscreenshots/mozscreenshots/extension/lib/controlCenter/password.html
browser/tools/mozscreenshots/mozscreenshots/extension/lib/controlCenter/tracking.html
--- a/browser/tools/mozscreenshots/browser.ini
+++ b/browser/tools/mozscreenshots/browser.ini
@@ -1,8 +1,12 @@
 [DEFAULT]
 subsuite = screenshots
 support-files =
   head.js
   mozscreenshots/extension/lib/permissionPrompts.html
+  mozscreenshots/extension/lib/controlCenter/password.html
+  mozscreenshots/extension/lib/controlCenter/mixed.html
+  mozscreenshots/extension/lib/controlCenter/mixed_active.html
+  mozscreenshots/extension/lib/controlCenter/mixed_passive.html
   mozscreenshots/extension/lib/borderify.xpi
 
 [browser_screenshots.js]
new file mode 100644
--- /dev/null
+++ b/browser/tools/mozscreenshots/controlCenter/browser.ini
@@ -0,0 +1,6 @@
+[DEFAULT]
+subsuite = screenshots
+support-files =
+  ../head.js
+
+[browser_controlCenter.js]
new file mode 100644
--- /dev/null
+++ b/browser/tools/mozscreenshots/controlCenter/browser_controlCenter.js
@@ -0,0 +1,14 @@
+/* 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";
+
+add_task(function* capture() {
+  if (!shouldCapture()) {
+    return;
+  }
+  let sets = ["LightweightThemes", "ControlCenter"];
+
+  yield TestRunner.start(sets, "controlCenter");
+});
--- a/browser/tools/mozscreenshots/moz.build
+++ b/browser/tools/mozscreenshots/moz.build
@@ -3,16 +3,17 @@
 # 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/.
 
 BROWSER_CHROME_MANIFESTS += [
     # Each test is in it's own directory so it gets run in a clean profile with
     # run-by-dir.
     'browser.ini',
+    'controlCenter/browser.ini',
     'devtools/browser.ini',
     'permissionPrompts/browser.ini',
     'preferences/browser.ini',
     'primaryUI/browser.ini',
 ]
 
 TEST_DIRS += [
     'mozscreenshots/extension',
new file mode 100644
--- /dev/null
+++ b/browser/tools/mozscreenshots/mozscreenshots/extension/configurations/ControlCenter.jsm
@@ -0,0 +1,238 @@
+/* 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 = ["ControlCenter"];
+
+const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
+
+Cu.import("resource://gre/modules/Services.jsm");
+Cu.import("resource://gre/modules/Task.jsm");
+Cu.import("resource://gre/modules/Timer.jsm");
+Cu.import("resource://testing-common/BrowserTestUtils.jsm");
+Cu.import("resource:///modules/SitePermissions.jsm");
+
+let {UrlClassifierTestUtils} = Cu.import("resource://testing-common/UrlClassifierTestUtils.jsm", {});
+
+const RESOURCE_PATH = "extensions/mozscreenshots/browser/chrome/mozscreenshots/lib/controlCenter";
+const HTTP_PAGE = "http://example.com/";
+const HTTPS_PAGE = "https://example.com/";
+const PERMISSIONS_PAGE = "https://test1.example.com/";
+const HTTP_PASSWORD_PAGE = `http://test2.example.org/${RESOURCE_PATH}/password.html`;
+const MIXED_CONTENT_URL = `https://example.com/${RESOURCE_PATH}/mixed.html`;
+const MIXED_ACTIVE_CONTENT_URL = `https://example.com/${RESOURCE_PATH}/mixed_active.html`;
+const MIXED_PASSIVE_CONTENT_URL = `https://example.com/${RESOURCE_PATH}/mixed_passive.html`;
+const TRACKING_PAGE = `http://tracking.example.org/${RESOURCE_PATH}/tracking.html`;
+
+this.ControlCenter = {
+  init(libDir) { },
+
+  configurations: {
+    about: {
+      applyConfig: Task.async(function* () {
+        yield loadPage("about:home");
+        yield openIdentityPopup();
+      }),
+    },
+
+    localFile: {
+      applyConfig: Task.async(function* () {
+        let filePath = "file:///";
+        if (Services.appinfo.OS === "WINNT") {
+          filePath += "C:/";
+        }
+        yield loadPage(filePath);
+        yield openIdentityPopup();
+      }),
+    },
+
+    http: {
+      applyConfig: Task.async(function* () {
+        yield loadPage(HTTP_PAGE);
+        yield openIdentityPopup();
+      }),
+    },
+
+    httpSubView: {
+      applyConfig: Task.async(function* () {
+        yield loadPage(HTTP_PAGE);
+        yield openIdentityPopup(true);
+      }),
+    },
+
+    https: {
+      applyConfig: Task.async(function* () {
+        yield loadPage(HTTPS_PAGE);
+        yield openIdentityPopup();
+      }),
+    },
+
+    httpsSubView: {
+      applyConfig: Task.async(function* () {
+        yield loadPage(HTTPS_PAGE);
+        yield openIdentityPopup(true);
+      }),
+    },
+
+    singlePermission: {
+      applyConfig: Task.async(function* () {
+        let uri = Services.io.newURI(PERMISSIONS_PAGE, null, null)
+        SitePermissions.set(uri, "camera", SitePermissions.ALLOW);
+
+        yield loadPage(PERMISSIONS_PAGE);
+        yield openIdentityPopup();
+      }),
+    },
+
+    allPermissions: {
+      applyConfig: Task.async(function* () {
+        // there are 3 possible non-default permission states, so we alternate between them
+        let states = [SitePermissions.ALLOW, SitePermissions.BLOCK, SitePermissions.SESSION];
+        let uri = Services.io.newURI(PERMISSIONS_PAGE, null, null)
+        SitePermissions.listPermissions().forEach(function (permission, index) {
+          SitePermissions.set(uri, permission, states[index % 3]);
+        });
+
+        yield loadPage(PERMISSIONS_PAGE);
+        yield openIdentityPopup();
+      }),
+    },
+
+    mixed: {
+      applyConfig: Task.async(function* () {
+        yield loadPage(MIXED_CONTENT_URL);
+        yield openIdentityPopup();
+      }),
+    },
+
+    mixedSubView: {
+      applyConfig: Task.async(function* () {
+        yield loadPage(MIXED_CONTENT_URL);
+        yield openIdentityPopup(true);
+      }),
+    },
+
+    mixedPassive: {
+      applyConfig: Task.async(function* () {
+        yield loadPage(MIXED_PASSIVE_CONTENT_URL);
+        yield openIdentityPopup();
+      }),
+    },
+
+    mixedPassiveSubView: {
+      applyConfig: Task.async(function* () {
+        yield loadPage(MIXED_PASSIVE_CONTENT_URL);
+        yield openIdentityPopup(true);
+      }),
+    },
+
+    mixedActive: {
+      applyConfig: Task.async(function* () {
+        yield loadPage(MIXED_ACTIVE_CONTENT_URL);
+        yield openIdentityPopup();
+      }),
+    },
+
+    mixedActiveSubView: {
+      applyConfig: Task.async(function* () {
+        yield loadPage(MIXED_ACTIVE_CONTENT_URL);
+        yield openIdentityPopup(true);
+      }),
+    },
+
+    mixedActiveUnblocked: {
+      applyConfig: Task.async(function* () {
+        let browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
+        let gBrowser = browserWindow.gBrowser;
+        yield loadPage(MIXED_ACTIVE_CONTENT_URL);
+        gBrowser.ownerGlobal.gIdentityHandler.disableMixedContentProtection();
+        yield BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser, false, MIXED_ACTIVE_CONTENT_URL);
+        yield openIdentityPopup();
+      }),
+    },
+
+    mixedActiveUnblockedSubView: {
+      applyConfig: Task.async(function* () {
+        let browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
+        let gBrowser = browserWindow.gBrowser;
+        yield loadPage(MIXED_ACTIVE_CONTENT_URL);
+        gBrowser.ownerGlobal.gIdentityHandler.disableMixedContentProtection();
+        yield BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser, false, MIXED_ACTIVE_CONTENT_URL);
+        yield openIdentityPopup(true);
+      }),
+    },
+
+    httpPassword: {
+      applyConfig: Task.async(function* () {
+        yield loadPage(HTTP_PASSWORD_PAGE);
+        yield openIdentityPopup();
+      }),
+    },
+
+    httpPasswordSubView: {
+      applyConfig: Task.async(function* () {
+        yield loadPage(HTTP_PASSWORD_PAGE);
+        yield openIdentityPopup(true);
+      }),
+    },
+
+    trackingProtectionNoElements: {
+      applyConfig: Task.async(function* () {
+        Services.prefs.setBoolPref("privacy.trackingprotection.enabled", true);
+
+        yield loadPage(HTTP_PAGE);
+        yield openIdentityPopup();
+      }),
+    },
+
+    trackingProtectionEnabled: {
+      applyConfig: Task.async(function* () {
+        Services.prefs.setBoolPref("privacy.trackingprotection.enabled", true);
+        Services.prefs.setIntPref("privacy.trackingprotection.introCount", 20);
+        yield UrlClassifierTestUtils.addTestTrackers();
+
+        yield loadPage(TRACKING_PAGE);
+        yield openIdentityPopup();
+      }),
+    },
+
+    trackingProtectionDisabled: {
+      applyConfig: Task.async(function* () {
+        let browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
+        let gBrowser = browserWindow.gBrowser;
+        Services.prefs.setBoolPref("privacy.trackingprotection.enabled", true);
+        Services.prefs.setIntPref("privacy.trackingprotection.introCount", 20);
+        yield UrlClassifierTestUtils.addTestTrackers();
+
+        yield loadPage(TRACKING_PAGE);
+        yield openIdentityPopup();
+        // unblock the page
+        gBrowser.ownerGlobal.document.querySelector("#tracking-action-unblock").click();
+        yield BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser, false, TRACKING_PAGE);
+        yield openIdentityPopup();
+      }),
+    },
+  },
+};
+
+function* loadPage(url) {
+  let browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
+  let gBrowser = browserWindow.gBrowser;
+  BrowserTestUtils.loadURI(gBrowser.selectedBrowser, url);
+  yield BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser, false, url);
+}
+
+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
+    yield new Promise((c) => setTimeout(c, 500));
+    gIdentityHandler._identityPopup.querySelector("#identity-popup-security-expander").click();
+  }
+}
new file mode 100644
--- /dev/null
+++ b/browser/tools/mozscreenshots/mozscreenshots/extension/lib/controlCenter/mixed.html
@@ -0,0 +1,11 @@
+<!DOCTYPE HTML>
+<html>
+  <head>
+    <meta charset="utf8">
+    <title>Mixed Content test</title>
+  </head>
+  <body>
+    <iframe style="visibility:hidden" src="http://example.com"></iframe>
+    <img style="visibility:hidden" src="http://example.com/tests/image/test/mochitest/blue.png"></img>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/browser/tools/mozscreenshots/mozscreenshots/extension/lib/controlCenter/mixed_active.html
@@ -0,0 +1,10 @@
+<!DOCTYPE HTML>
+<html>
+  <head>
+    <meta charset="utf8">
+    <title>Mixed Active Content test</title>
+  </head>
+  <body>
+    <iframe style="visibility:hidden" src="http://example.com"></iframe>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/browser/tools/mozscreenshots/mozscreenshots/extension/lib/controlCenter/mixed_passive.html
@@ -0,0 +1,10 @@
+<!DOCTYPE HTML>
+<html>
+  <head>
+    <meta charset="utf8">
+    <title>Mixed Passive Content test</title>
+  </head>
+  <body>
+    <img style="visibility:hidden" src="http://example.com/tests/image/test/mochitest/blue.png"></img>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/browser/tools/mozscreenshots/mozscreenshots/extension/lib/controlCenter/password.html
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML>
+<html>
+  <head>
+    <meta charset="utf8">
+    <title>HTTP Password test</title>
+  </head>
+  <body>
+    <form>
+      <input type="password" />
+      <button type="submit">Submit</button>
+    </form>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/browser/tools/mozscreenshots/mozscreenshots/extension/lib/controlCenter/tracking.html
@@ -0,0 +1,10 @@
+<!DOCTYPE HTML>
+<html>
+  <head>
+    <meta charset="utf8">
+    <title>Tracking test</title>
+  </head>
+  <body>
+    <iframe style="visibility:hidden" src="http://tracking.example.com/"></iframe>
+  </body>
+</html>