Bug 1268619 - Add a mozscreenshots configuration for site permission notifications draft
authorJohann Hofmann <jhofmann@mozilla.com>
Fri, 29 Apr 2016 17:31:50 +0200
changeset 371296 58441dbb409bb9922035199d4b34f19d32891275
parent 369317 16663eb3dcfa759f25b5e27b101bc79270c156f2
child 521962 b5c527f3f182ac97296e933ddc8a0e560664c8da
push id19294
push usermail@johann-hofmann.com
push dateThu, 26 May 2016 10:12:19 +0000
bugs1268619
milestone49.0a1
Bug 1268619 - Add a mozscreenshots configuration for site permission notifications MozReview-Commit-ID: 8mryMwYOxxn
browser/tools/mozscreenshots/browser.ini
browser/tools/mozscreenshots/moz.build
browser/tools/mozscreenshots/mozscreenshots/extension/configurations/PermissionPrompts.jsm
browser/tools/mozscreenshots/mozscreenshots/extension/lib/borderify.xpi
browser/tools/mozscreenshots/mozscreenshots/extension/lib/notifications.html
browser/tools/mozscreenshots/permissionPrompts/browser.ini
browser/tools/mozscreenshots/permissionPrompts/browser_permissionPrompts.js
--- a/browser/tools/mozscreenshots/browser.ini
+++ b/browser/tools/mozscreenshots/browser.ini
@@ -1,6 +1,8 @@
 [DEFAULT]
 subsuite = screenshots
 support-files =
   head.js
+  mozscreenshots/extension/lib/notifications.html
+  mozscreenshots/extension/lib/borderify.xpi
 
 [browser_screenshots.js]
--- a/browser/tools/mozscreenshots/moz.build
+++ b/browser/tools/mozscreenshots/moz.build
@@ -4,15 +4,16 @@
 # 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',
     '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/PermissionPrompts.jsm
@@ -0,0 +1,130 @@
+/* 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 = ["PermissionPrompts"];
+
+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:///modules/E10SUtils.jsm");
+Cu.import("resource://testing-common/ContentTask.jsm");
+Cu.import("resource://testing-common/BrowserTestUtils.jsm");
+
+const URL = "https://example.com/browser/browser/tools/mozscreenshots/mozscreenshots/extension/lib/notifications.html";
+let lastTab = null;
+
+this.PermissionPrompts = {
+  init(libDir) {
+    Services.prefs.setBoolPref("media.navigator.permission.fake", true);
+    Services.prefs.setCharPref("media.getusermedia.screensharing.allowed_domains", "example.com");
+    Services.prefs.setBoolPref("extensions.install.requireBuiltInCerts", false);
+  },
+
+  configurations: {
+    shareDevices: {
+      applyConfig: Task.async(function*() {
+        yield closeLastTab();
+        yield clickOn("#webRTC-shareDevices");
+      }),
+    },
+
+    shareMicrophone: {
+      applyConfig: Task.async(function*() {
+        yield closeLastTab();
+        yield clickOn("#webRTC-shareMicrophone");
+      }),
+    },
+
+    shareVideoAndMicrophone: {
+      applyConfig: Task.async(function*() {
+        yield closeLastTab();
+        yield clickOn("#webRTC-shareDevices2");
+      }),
+    },
+
+    shareScreen: {
+      applyConfig: Task.async(function*() {
+        yield closeLastTab();
+        yield clickOn("#webRTC-shareScreen");
+      }),
+    },
+
+    geo: {
+      applyConfig: Task.async(function*() {
+        yield closeLastTab();
+        yield clickOn("#geo");
+      }),
+    },
+
+    loginCapture: {
+      applyConfig: Task.async(function*() {
+        yield closeLastTab();
+        yield clickOn("#login-capture", URL);
+      }),
+    },
+
+    notifications: {
+      applyConfig: Task.async(function*() {
+        yield closeLastTab();
+        yield clickOn("#web-notifications", URL);
+      }),
+    },
+
+    addons: {
+      applyConfig: Task.async(function*() {
+        Services.prefs.setBoolPref("xpinstall.whitelist.required", true);
+
+        yield closeLastTab();
+        yield clickOn("#addons", URL);
+      }),
+    },
+
+    addonsNoWhitelist: {
+      applyConfig: Task.async(function*() {
+        Services.prefs.setBoolPref("xpinstall.whitelist.required", false);
+
+        let browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
+        let notification = browserWindow.document.getElementById("addon-install-confirmation-notification");
+
+        yield closeLastTab();
+        yield clickOn("#addons", URL);
+
+        // we want to skip the progress-notification, so we wait for
+        // the install-confirmation screen to be "not hidden" = shown
+        yield BrowserTestUtils.waitForCondition(() => !notification.hasAttribute("hidden"),
+                                                "addon install confirmation did not show", 200);
+      }),
+    },
+  },
+};
+
+function* closeLastTab(selector) {
+  if (lastTab) {
+    let browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
+    yield BrowserTestUtils.removeTab(lastTab);
+    lastTab = null;
+  }
+}
+
+function* clickOn(selector) {
+  let browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
+
+  let tab = yield BrowserTestUtils.openNewForegroundTab(browserWindow.gBrowser, URL);
+
+  // save the tab so we can close it later
+  lastTab = tab;
+
+  yield ContentTask.spawn(tab.linkedBrowser, selector, function* (arg) {
+    E10SUtils.wrapHandlingUserInput(content, true, function() {
+      let element = content.document.querySelector(arg);
+      element.click();
+    });
+  });
+
+  // wait for the popup to actually be shown before making the screenshot
+  yield BrowserTestUtils.waitForEvent(browserWindow.PopupNotifications.panel, "popupshown");
+}
new file mode 100644
index 0000000000000000000000000000000000000000..66ae92ed21152aa799d6d0a273bae874ecb4438f
GIT binary patch
literal 1611
zc$^FHW@h1H0D;TC%RCs602>fzCg<lB>jyy9aDdf(y3;Vjjgf&Nj){SR7bu#Wn3tKB
zT3n)+Rh*v}JJHwguz^79cgxn)ve0B^t)Q!-3SU`7lNwi@*top&VEv}MK`W}tbC$PE
zd0H{=dF|(CA)y?JjE&VV7j0o%FHk3>q|nwB8l=F_wDlVI2aTvBQ=H~su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-v;s?0<kbW@*t^4*Th1vATRwj&xhjYPbWP}N=SI{^-BRK(<L^A
zGY8pJ4$rLH#;iFlN&UP4pTdfV9xoX_S#sMbbxTU@Xmy-1G4YxV=YoXI%e#|3+#cUv
z-B-iQ#dJ<wKkU!-x?2AQsjVMx)!**l^l9Cj)Qk_G>gGM(|NBKx`o`<`U2cCdin)7j
zW_;}GnSbVYrncUEdTh?~O`dPG%x^N^lil&*-LX2hW1+L2@@|qAdLmn9v_CW9@7V$`
zv&PuxYytBQT0LBFw{d5UVg2;`+h4zbaR2au6CWPf-CtGKH^YC{zR3;e5<irDEslIX
z<pK*ZAu}?GFyJoQAV2_0!wNc>9_&RO0;r%DeCS%yGc5v4Wkk)w=sMB!90CY1q2)ky
pt>_6H0q!v&C3kdf=m`Y@&N5?7HUZwOY>;qdV~7FTb(00e0{{{5ZKMDI
new file mode 100644
--- /dev/null
+++ b/browser/tools/mozscreenshots/mozscreenshots/extension/lib/notifications.html
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <meta charset="utf-8">
+  <title>Notifications Test</title>
+</head>
+<body>
+  <div>
+    <button id="geo" onclick="toggleGeo()">Geolocation</button>
+    <button id="webRTC-shareDevices" onclick="shareDevice({video: true, fake: true});">Video</button>
+    <button id="webRTC-shareMicrophone" onclick="shareDevice({audio: true, fake: true});">Audio</button>
+    <button id="webRTC-shareDevices2" onclick="shareDevice({audio: true, video: true, fake: true});">Audio and Video</button>
+    <button id="webRTC-shareScreen" onclick="shareDevice({video: {mediaSource: 'screen'}});">Screen</button>
+    <button id="web-notifications" onclick="toggleNotification()">web-notifications</button>
+    <a id="addons" href="borderify.xpi">Install Add-On</a>
+    <form>
+      <input type="email" id="email" value="email@example.com" />
+      <input type="password" id="password" value="123456" />
+      <button type="submit" id="login-capture">Submit</button>
+    </form>
+  </div>
+
+  <script type="application/javascript">
+    function toggleGeo() {
+      navigator.geolocation.getCurrentPosition(() => {});
+    }
+    function toggleNotification() {
+      Notification.requestPermission();
+    }
+    function shareDevice(config) {
+      navigator.mediaDevices.getUserMedia(config);
+    }
+  </script>
+
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/browser/tools/mozscreenshots/permissionPrompts/browser.ini
@@ -0,0 +1,6 @@
+[DEFAULT]
+subsuite = screenshots
+support-files =
+  ../head.js
+
+[browser_permissionPrompts.js]
new file mode 100644
--- /dev/null
+++ b/browser/tools/mozscreenshots/permissionPrompts/browser_permissionPrompts.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", "PermissionPrompts"];
+
+  yield TestRunner.start(sets);
+});