Bug 1268648 - Add a mozscreenshots configuration for control center. r=MattN draft
authorJohann Hofmann <jhofmann@mozilla.com>
Mon, 25 Jul 2016 12:49:53 +0200
changeset 398510 3d0b55f61f00dcb5b262632c3dfcddb4a04d50a0
parent 397688 763fe887c37cee5fcfe0f00e94fdffc84a41ea1c
child 527682 6a922146288fc7cf3361480881b6985bc3ec0bf2
push id25553
push usermail@johann-hofmann.com
push dateTue, 09 Aug 2016 08:35:01 +0000
reviewersMattN
bugs1268648
milestone51.0a1
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>