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 392754 fb08c8d0daabe6699f4ff00434cb9a80cf28d17e
parent 392299 7c669d5d63efceb12696cd65cfa72c296013dafb
child 526411 c4ac0813df64590b75c15cc270ed968a07a885d6
push id24123
push usermail@johann-hofmann.com
push dateTue, 26 Jul 2016 09:49:07 +0000
reviewersMattN
bugs1268648
milestone50.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/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");
+});
new file mode 100644
--- /dev/null
+++ b/browser/tools/mozscreenshots/mozscreenshots/extension/configurations/ControlCenter.jsm
@@ -0,0 +1,232 @@
+/* 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 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/extensions/mozscreenshots/browser/chrome/mozscreenshots/lib/controlCenter/password.html";
+const MIXED_CONTENT_URL = "https://example.com/extensions/mozscreenshots/browser/chrome/mozscreenshots/lib/controlCenter/mixed.html";
+const MIXED_ACTIVE_CONTENT_URL = "https://example.com/extensions/mozscreenshots/browser/chrome/mozscreenshots/lib/controlCenter/mixed_active.html";
+const MIXED_PASSIVE_CONTENT_URL = "https://example.com/extensions/mozscreenshots/browser/chrome/mozscreenshots/lib/controlCenter/mixed_passive.html";
+const TRACKING_PAGE = "http://tracking.example.org/extensions/mozscreenshots/browser/chrome/mozscreenshots/lib/controlCenter/tracking.html";
+
+this.ControlCenter = {
+  init(libDir) { },
+
+  configurations: {
+    about: {
+      applyConfig: Task.async(function* http() {
+        yield loadPage("about:home");
+        yield openIdentityPopup();
+      }),
+    },
+
+    localFile: {
+      applyConfig: Task.async(function* http() {
+        yield loadPage("file:///");
+        yield openIdentityPopup();
+      }),
+    },
+
+    http: {
+      applyConfig: Task.async(function* http() {
+        yield loadPage(HTTP_PAGE);
+        yield openIdentityPopup();
+      }),
+    },
+
+    httpSubView: {
+      applyConfig: Task.async(function* () {
+        yield loadPage(HTTP_PAGE);
+        yield openIdentityPopup(true);
+      }),
+    },
+
+    https: {
+      applyConfig: Task.async(function* http() {
+        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* () {
+        let uri = Services.io.newURI(PERMISSIONS_PAGE, null, null)
+        SitePermissions.listPermissions().forEach(function (permission, index) {
+          // there are 3 possible non-default permission states, so we alternate between them
+          SitePermissions.set(uri, permission, index % 3 + 1);
+        });
+
+        yield loadPage(PERMISSIONS_PAGE);
+        yield openIdentityPopup();
+      }),
+    },
+
+    mixed: {
+      applyConfig: Task.async(function* http() {
+        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* http() {
+        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* http() {
+        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* http() {
+        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);
+        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);
+        yield openIdentityPopup(true);
+      }),
+    },
+
+    httpPassword: {
+      applyConfig: Task.async(function* http() {
+        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);
+        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);
+}
+
+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 dir="ltr" xml:lang="en-US" lang="en-US">
+  <head>
+    <meta charset="utf8">
+    <title>Mixed Content test</title>
+  </head>
+  <body>
+    <iframe src="http://example.com"></iframe>
+    <img 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 dir="ltr" xml:lang="en-US" lang="en-US">
+  <head>
+    <meta charset="utf8">
+    <title>Mixed Active Content test</title>
+  </head>
+  <body>
+    <iframe 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 dir="ltr" xml:lang="en-US" lang="en-US">
+  <head>
+    <meta charset="utf8">
+    <title>Mixed Passive Content test</title>
+  </head>
+  <body>
+    <img 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 dir="ltr" xml:lang="en-US" lang="en-US">
+  <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,13 @@
+<!DOCTYPE HTML>
+<!-- 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/. -->
+<html dir="ltr" xml:lang="en-US" lang="en-US">
+  <head>
+    <meta charset="utf8">
+    <title>Tracking test</title>
+  </head>
+  <body>
+    <iframe src="http://tracking.example.com/"></iframe>
+  </body>
+</html>