summaryrefslogtreecommitdiffstats
path: root/toolkit/components/passwordmgr/test/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'toolkit/components/passwordmgr/test/chrome')
-rw-r--r--toolkit/components/passwordmgr/test/chrome/chrome.ini13
-rw-r--r--toolkit/components/passwordmgr/test/chrome/notification_common.js111
-rw-r--r--toolkit/components/passwordmgr/test/chrome/privbrowsing_perwindowpb_iframe.html9
-rw-r--r--toolkit/components/passwordmgr/test/chrome/subtst_privbrowsing_1.html33
-rw-r--r--toolkit/components/passwordmgr/test/chrome/subtst_privbrowsing_2.html33
-rw-r--r--toolkit/components/passwordmgr/test/chrome/subtst_privbrowsing_3.html29
-rw-r--r--toolkit/components/passwordmgr/test/chrome/subtst_privbrowsing_4.html40
-rw-r--r--toolkit/components/passwordmgr/test/chrome/test_privbrowsing_perwindowpb.html322
8 files changed, 0 insertions, 590 deletions
diff --git a/toolkit/components/passwordmgr/test/chrome/chrome.ini b/toolkit/components/passwordmgr/test/chrome/chrome.ini
deleted file mode 100644
index 093b87b7d..000000000
--- a/toolkit/components/passwordmgr/test/chrome/chrome.ini
+++ /dev/null
@@ -1,13 +0,0 @@
-[DEFAULT]
-skip-if = os == 'android'
-
-[test_privbrowsing_perwindowpb.html]
-skip-if = true # Bug 1173337
-support-files =
- ../formsubmit.sjs
- notification_common.js
- privbrowsing_perwindowpb_iframe.html
- subtst_privbrowsing_1.html
- subtst_privbrowsing_2.html
- subtst_privbrowsing_3.html
- subtst_privbrowsing_4.html
diff --git a/toolkit/components/passwordmgr/test/chrome/notification_common.js b/toolkit/components/passwordmgr/test/chrome/notification_common.js
deleted file mode 100644
index e8a52929d..000000000
--- a/toolkit/components/passwordmgr/test/chrome/notification_common.js
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Initialization: for each test, remove any prior notifications.
- */
-function cleanUpPopupNotifications() {
- var container = getPopupNotifications(window.top);
- var notes = container._currentNotifications;
- info(true, "Removing " + notes.length + " popup notifications.");
- for (var i = notes.length - 1; i >= 0; i--) {
- notes[i].remove();
- }
-}
-cleanUpPopupNotifications();
-
-/*
- * getPopupNotifications
- *
- * Fetches the popup notification for the specified window.
- */
-function getPopupNotifications(aWindow) {
- var Ci = SpecialPowers.Ci;
- var Cc = SpecialPowers.Cc;
- ok(Ci != null, "Access Ci");
- ok(Cc != null, "Access Cc");
-
- var chromeWin = SpecialPowers.wrap(aWindow)
- .QueryInterface(Ci.nsIInterfaceRequestor)
- .getInterface(Ci.nsIWebNavigation)
- .QueryInterface(Ci.nsIDocShell)
- .chromeEventHandler.ownerDocument.defaultView;
-
- var popupNotifications = chromeWin.PopupNotifications;
- return popupNotifications;
-}
-
-
-/**
- * Checks if we have a password popup notification
- * of the right type and with the right label.
- *
- * @deprecated Write a browser-chrome test instead and use the fork of this method there.
- * @returns the found password popup notification.
- */
-function getPopup(aPopupNote, aKind) {
- ok(true, "Looking for " + aKind + " popup notification");
- var notification = aPopupNote.getNotification("password");
- if (notification) {
- is(notification.options.passwordNotificationType, aKind, "Notification type matches.");
- if (aKind == "password-change") {
- is(notification.mainAction.label, "Update", "Main action label matches update doorhanger.");
- } else if (aKind == "password-save") {
- is(notification.mainAction.label, "Remember", "Main action label matches save doorhanger.");
- }
- }
- return notification;
-}
-
-
-/**
- * @deprecated - Use a browser chrome test instead.
- *
- * Clicks the specified popup notification button.
- */
-function clickPopupButton(aPopup, aButtonIndex) {
- ok(true, "Looking for action at index " + aButtonIndex);
-
- var notifications = SpecialPowers.wrap(aPopup.owner).panel.childNodes;
- ok(notifications.length > 0, "at least one notification displayed");
- ok(true, notifications.length + " notifications");
- var notification = notifications[0];
-
- if (aButtonIndex == 0) {
- ok(true, "Triggering main action");
- notification.button.doCommand();
- } else if (aButtonIndex <= aPopup.secondaryActions.length) {
- var index = aButtonIndex;
- ok(true, "Triggering secondary action " + index);
- notification.childNodes[index].doCommand();
- }
-}
-
-const kRememberButton = 0;
-const kNeverButton = 1;
-
-const kChangeButton = 0;
-const kDontChangeButton = 1;
-
-function dumpNotifications() {
- try {
- // PopupNotifications
- var container = getPopupNotifications(window.top);
- ok(true, "is popup panel open? " + container.isPanelOpen);
- var notes = container._currentNotifications;
- ok(true, "Found " + notes.length + " popup notifications.");
- for (let i = 0; i < notes.length; i++) {
- ok(true, "#" + i + ": " + notes[i].id);
- }
-
- // Notification bars
- var chromeWin = SpecialPowers.wrap(window.top)
- .QueryInterface(Ci.nsIInterfaceRequestor)
- .getInterface(Ci.nsIWebNavigation)
- .QueryInterface(Ci.nsIDocShell)
- .chromeEventHandler.ownerDocument.defaultView;
- var nb = chromeWin.getNotificationBox(window.top);
- notes = nb.allNotifications;
- ok(true, "Found " + notes.length + " notification bars.");
- for (let i = 0; i < notes.length; i++) {
- ok(true, "#" + i + ": " + notes[i].getAttribute("value"));
- }
- } catch (e) { todo(false, "WOAH! " + e); }
-}
diff --git a/toolkit/components/passwordmgr/test/chrome/privbrowsing_perwindowpb_iframe.html b/toolkit/components/passwordmgr/test/chrome/privbrowsing_perwindowpb_iframe.html
deleted file mode 100644
index 2efdab265..000000000
--- a/toolkit/components/passwordmgr/test/chrome/privbrowsing_perwindowpb_iframe.html
+++ /dev/null
@@ -1,9 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
- <meta charset="utf-8">
-</head>
-<body>
-<iframe id="iframe"></iframe>
-</body>
-</html>
diff --git a/toolkit/components/passwordmgr/test/chrome/subtst_privbrowsing_1.html b/toolkit/components/passwordmgr/test/chrome/subtst_privbrowsing_1.html
deleted file mode 100644
index 8c7202dd0..000000000
--- a/toolkit/components/passwordmgr/test/chrome/subtst_privbrowsing_1.html
+++ /dev/null
@@ -1,33 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
- <meta charset="utf-8">
- <title>Subtest for Login Manager notifications (private browsing)</title>
-</head>
-<body>
-<h2>Subtest 1</h2>
-<!--
- Make sure that the password-save notification appears outside of
- the private mode, but not inside it.
--->
-<form id="form" action="formsubmit.sjs">
- <input id="user" name="user" type="text">
- <input id="pass" name="pass" type="password">
- <button type='submit'>Submit</button>
-</form>
-
-<script>
-function submitForm() {
- userField.value = "notifyu1";
- passField.value = "notifyp1";
- form.submit();
-}
-
-window.onload = submitForm;
-var form = document.getElementById("form");
-var userField = document.getElementById("user");
-var passField = document.getElementById("pass");
-
-</script>
-</body>
-</html>
diff --git a/toolkit/components/passwordmgr/test/chrome/subtst_privbrowsing_2.html b/toolkit/components/passwordmgr/test/chrome/subtst_privbrowsing_2.html
deleted file mode 100644
index bf3b85159..000000000
--- a/toolkit/components/passwordmgr/test/chrome/subtst_privbrowsing_2.html
+++ /dev/null
@@ -1,33 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
- <meta charset="utf-8">
- <title>Subtest for Login Manager notifications (private browsing)</title>
-</head>
-<body>
-<h2>Subtest 2</h2>
-<!--
- Make sure that the password-change notification appears outside of
- the private mode, but not inside it.
--->
-<form id="form" action="formsubmit.sjs">
- <input id="pass" name="pass" type="password">
- <input id="newpass" name="newpass" type="password">
- <button type='submit'>Submit</button>
-</form>
-
-<script>
-function submitForm() {
- passField.value = "notifyp1";
- passField2.value = "notifyp2";
- form.submit();
-}
-
-window.onload = submitForm;
-var form = document.getElementById("form");
-var passField = document.getElementById("pass");
-var passField2 = document.getElementById("newpass");
-
-</script>
-</body>
-</html>
diff --git a/toolkit/components/passwordmgr/test/chrome/subtst_privbrowsing_3.html b/toolkit/components/passwordmgr/test/chrome/subtst_privbrowsing_3.html
deleted file mode 100644
index e88a302e0..000000000
--- a/toolkit/components/passwordmgr/test/chrome/subtst_privbrowsing_3.html
+++ /dev/null
@@ -1,29 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
- <meta charset="utf-8">
- <title>Subtest for Login Manager notifications (private browsing)</title>
-</head>
-<body>
-<h2>Subtest 3</h2>
-<!--
- Make sure that the user/pass fields are auto-filled outside of
- the private mode, but not inside it.
--->
-<form id="form" action="formsubmit.sjs">
- <input id="user" name="user" type="text">
- <input id="pass" name="pass" type="password">
- <button type='submit'>Submit</button>
-</form>
-
-<script>
-function submitForm() {
- form.submit();
-}
-
-var form = document.getElementById("form");
-window.addEventListener('message', () => { submitForm(); });
-
-</script>
-</body>
-</html>
diff --git a/toolkit/components/passwordmgr/test/chrome/subtst_privbrowsing_4.html b/toolkit/components/passwordmgr/test/chrome/subtst_privbrowsing_4.html
deleted file mode 100644
index 184142743..000000000
--- a/toolkit/components/passwordmgr/test/chrome/subtst_privbrowsing_4.html
+++ /dev/null
@@ -1,40 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
- <meta charset="utf-8">
- <title>Subtest for Login Manager notifications (private browsing)</title>
- <script type="text/javascript" src="pwmgr_common.js"></script>
-</head>
-<body>
-<h2>Subtest 4</h2>
-<!--
- Make sure that the user/pass fields have manual filling enabled
- in private mode.
--->
-<form id="form" action="formsubmit.sjs">
- <input id="user" name="user" type="text">
- <input id="pass" name="pass" type="password">
- <button type='submit'>Submit</button>
-</form>
-
-<script>
-function startAutocomplete() {
- userField.focus();
- doKey("down");
- setTimeout(submitForm, 100);
-}
-
-function submitForm() {
- doKey("down");
- doKey("return");
- setTimeout(function() { form.submit(); }, 100);
-}
-
-var form = document.getElementById("form");
-var userField = document.getElementById("user");
-
-window.addEventListener('message', () => { startAutocomplete(); });
-
-</script>
-</body>
-</html>
diff --git a/toolkit/components/passwordmgr/test/chrome/test_privbrowsing_perwindowpb.html b/toolkit/components/passwordmgr/test/chrome/test_privbrowsing_perwindowpb.html
deleted file mode 100644
index 6b7d4abb3..000000000
--- a/toolkit/components/passwordmgr/test/chrome/test_privbrowsing_perwindowpb.html
+++ /dev/null
@@ -1,322 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=248970
--->
-<head>
- <meta charset="utf-8">
- <title>Test for Private Browsing</title>
- <script type="application/javascript"
- src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
- <script type="text/javascript" src="notification_common.js"></script>
- <link rel="stylesheet" type="text/css"
- href="chrome://mochikit/content/tests/SimpleTest/test.css">
-</head>
-<body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=248970">Mozilla Bug 248970</a>
-<p id="display"></p>
-<pre id="test">
-<script class="testbody" type="text/javascript">
-
-/** Test for Bug 248970 **/
-// based on test_notifications.html
-
-const Ci = SpecialPowers.Ci;
-const Cc = SpecialPowers.Cc;
-const Cr = SpecialPowers.Cr;
-
-Components.utils.import("resource://gre/modules/Services.jsm");
-
-var testpath = "/chrome/toolkit/components/passwordmgr/test/chrome/";
-var prefix = "http://test2.example.com" + testpath;
-var subtests = [
- "subtst_privbrowsing_1.html", // 1
- "subtst_privbrowsing_1.html", // 2
- "subtst_privbrowsing_1.html", // 3
- "subtst_privbrowsing_2.html", // 4
- "subtst_privbrowsing_2.html", // 5
- "subtst_privbrowsing_2.html", // 6
- "subtst_privbrowsing_3.html", // 7
- "subtst_privbrowsing_3.html", // 8
- "subtst_privbrowsing_4.html", // 9
- "subtst_privbrowsing_3.html" // 10
- ];
-var observer;
-
-var testNum = 0;
-function loadNextTest() {
- // run the initialization code for each test
- switch (++ testNum) {
- case 1:
- popupNotifications = normalWindowPopupNotifications;
- iframe = normalWindowIframe;
- break;
-
- case 2:
- popupNotifications = privateWindowPopupNotifications;
- iframe = privateWindowIframe;
- break;
-
- case 3:
- popupNotifications = normalWindowPopupNotifications;
- iframe = normalWindowIframe;
- break;
-
- case 4:
- pwmgr.addLogin(login);
- break;
-
- case 5:
- popupNotifications = privateWindowPopupNotifications;
- iframe = privateWindowIframe;
- break;
-
- case 6:
- popupNotifications = normalWindowPopupNotifications;
- iframe = normalWindowIframe;
- break;
-
- case 7:
- pwmgr.addLogin(login);
- break;
-
- case 8:
- popupNotifications = privateWindowPopupNotifications;
- iframe = privateWindowIframe;
- break;
-
- case 9:
- break;
-
- case 10:
- popupNotifications = normalWindowPopupNotifications;
- iframe = normalWindowIframe;
- break;
-
- default:
- ok(false, "Unexpected call to loadNextTest for test #" + testNum);
- }
-
- if (testNum === 7) {
- observer = SpecialPowers.wrapCallback(function(subject, topic, data) {
- SimpleTest.executeSoon(() => { iframe.contentWindow.postMessage("go", "*"); });
- });
- SpecialPowers.addObserver(observer, "passwordmgr-processed-form", false);
- }
-
- ok(true, "Starting test #" + testNum);
- iframe.src = prefix + subtests[testNum - 1];
-}
-
-function checkTest() {
- var popup;
- var gotUser;
- var gotPass;
-
- switch (testNum) {
- case 1:
- // run outside of private mode, popup notification should appear
- popup = getPopup(popupNotifications, "password-save");
- ok(popup, "got popup notification");
- popup.remove();
- break;
-
- case 2:
- // run inside of private mode, popup notification should not appear
- popup = getPopup(popupNotifications, "password-save");
- ok(!popup, "checking for no popup notification");
- break;
-
- case 3:
- // run outside of private mode, popup notification should appear
- popup = getPopup(popupNotifications, "password-save");
- ok(popup, "got popup notification");
- popup.remove();
- break;
-
- case 4:
- // run outside of private mode, popup notification should appear
- popup = getPopup(popupNotifications, "password-change");
- ok(popup, "got popup notification");
- popup.remove();
- break;
-
- case 5:
- // run inside of private mode, popup notification should not appear
- popup = getPopup(popupNotifications, "password-change");
- ok(!popup, "checking for no popup notification");
- break;
-
- case 6:
- // run outside of private mode, popup notification should appear
- popup = getPopup(popupNotifications, "password-change");
- ok(popup, "got popup notification");
- popup.remove();
- pwmgr.removeLogin(login);
- break;
-
- case 7:
- // verify that the user/pass pair was autofilled
- gotUser = iframe.contentDocument.getElementById("user").textContent;
- gotPass = iframe.contentDocument.getElementById("pass").textContent;
- is(gotUser, "notifyu1", "Checking submitted username");
- is(gotPass, "notifyp1", "Checking submitted password");
- break;
-
- case 8:
- // verify that the user/pass pair was not autofilled
- gotUser = iframe.contentDocument.getElementById("user").textContent;
- gotPass = iframe.contentDocument.getElementById("pass").textContent;
- is(gotUser, "", "Checking submitted username");
- is(gotPass, "", "Checking submitted password");
- break;
-
- case 9:
- // verify that the user/pass pair was available for autocomplete
- gotUser = iframe.contentDocument.getElementById("user").textContent;
- gotPass = iframe.contentDocument.getElementById("pass").textContent;
- is(gotUser, "notifyu1", "Checking submitted username");
- is(gotPass, "notifyp1", "Checking submitted password");
- break;
-
- case 10:
- // verify that the user/pass pair was autofilled
- gotUser = iframe.contentDocument.getElementById("user").textContent;
- gotPass = iframe.contentDocument.getElementById("pass").textContent;
- is(gotUser, "notifyu1", "Checking submitted username");
- is(gotPass, "notifyp1", "Checking submitted password");
- pwmgr.removeLogin(login);
- break;
-
- default:
- ok(false, "Unexpected call to checkTest for test #" + testNum);
-
- }
-}
-
-var mainWindow = window.QueryInterface(Ci.nsIInterfaceRequestor)
- .getInterface(Ci.nsIWebNavigation)
- .QueryInterface(Ci.nsIDocShellTreeItem)
- .rootTreeItem
- .QueryInterface(Ci.nsIInterfaceRequestor)
- .getInterface(Ci.nsIDOMWindow);
-var contentPage = "http://mochi.test:8888/chrome/toolkit/components/passwordmgr/test/chrome/privbrowsing_perwindowpb_iframe.html";
-var testWindows = [];
-
-function whenDelayedStartupFinished(aWindow, aCallback) {
- Services.obs.addObserver(function obs(aSubject, aTopic) {
- if (aWindow == aSubject) {
- Services.obs.removeObserver(obs, aTopic);
- setTimeout(aCallback, 0);
- }
- }, "browser-delayed-startup-finished", false);
-}
-
-function testOnWindow(aIsPrivate, aCallback) {
- var win = mainWindow.OpenBrowserWindow({private: aIsPrivate});
- win.addEventListener("load", function onLoad() {
- win.removeEventListener("load", onLoad, false);
- whenDelayedStartupFinished(win, function() {
- win.addEventListener("DOMContentLoaded", function onInnerLoad() {
- if (win.content.location.href != contentPage) {
- win.gBrowser.loadURI(contentPage);
- return;
- }
- win.removeEventListener("DOMContentLoaded", onInnerLoad, true);
-
- win.content.addEventListener('load', function innerLoad2() {
- win.content.removeEventListener('load', innerLoad2, false);
- testWindows.push(win);
- SimpleTest.executeSoon(function() { aCallback(win); });
- }, false, true);
- }, true);
- SimpleTest.executeSoon(function() { win.gBrowser.loadURI(contentPage); });
- });
- }, true);
-}
-
-var ignoreLoad = false;
-function handleLoad(aEvent) {
- // ignore every other load event ... We get one for loading the subtest (which
- // we want to ignore), and another when the subtest's form submits itself
- // (which we want to handle, to start the next test).
- ignoreLoad = !ignoreLoad;
- if (ignoreLoad) {
- ok(true, "Ignoring load of subtest #" + testNum);
- return;
- }
- ok(true, "Processing submission of subtest #" + testNum);
-
- checkTest();
-
- if (testNum < subtests.length) {
- loadNextTest();
- } else {
- ok(true, "private browsing notification tests finished.");
-
- testWindows.forEach(function(aWin) {
- aWin.close();
- });
-
- SpecialPowers.removeObserver(observer, "passwordmgr-processed-form");
- SimpleTest.finish();
- }
-}
-
-var pwmgr = Cc["@mozilla.org/login-manager;1"].
- getService(Ci.nsILoginManager);
-ok(pwmgr != null, "Access pwmgr");
-
-// We need to make sure no logins have been stored by previous tests
-// for forms in |url|, otherwise the change password notification
-// would turn into a prompt, and the test will fail.
-var url = "http://test2.example.com";
-is(pwmgr.countLogins(url, "", null), 0, "No logins should be stored for " + url);
-
-var nsLoginInfo = new SpecialPowers.wrap(SpecialPowers.Components).Constructor("@mozilla.org/login-manager/loginInfo;1",
- Ci.nsILoginInfo, "init");
-var login = new nsLoginInfo(url, url, null, "notifyu1", "notifyp1", "user", "pass");
-
-var normalWindow;
-var privateWindow;
-
-var iframe;
-var normalWindowIframe;
-var privateWindowIframe;
-
-var popupNotifications;
-var normalWindowPopupNotifications;
-var privateWindowPopupNotifications;
-
-testOnWindow(false, function(aWin) {
- var selectedBrowser = aWin.gBrowser.selectedBrowser;
- normalWindowIframe = selectedBrowser.contentDocument.getElementById("iframe");
- normalWindowIframe.onload = handleLoad;
- selectedBrowser.focus();
-
- normalWindowPopupNotifications = getPopupNotifications(selectedBrowser.contentWindow.top);
- ok(normalWindowPopupNotifications, "Got popupNotifications in normal window");
- // ignore the first load for this window;
- ignoreLoad = false;
-
- testOnWindow(true, function(aPrivateWin) {
- selectedBrowser = aPrivateWin.gBrowser.selectedBrowser;
- privateWindowIframe = selectedBrowser.contentDocument.getElementById("iframe");
- privateWindowIframe.onload = handleLoad;
- selectedBrowser.focus();
-
- privateWindowPopupNotifications = getPopupNotifications(selectedBrowser.contentWindow.top);
- ok(privateWindowPopupNotifications, "Got popupNotifications in private window");
- // ignore the first load for this window;
- ignoreLoad = false;
-
- SimpleTest.executeSoon(loadNextTest);
- });
-});
-
-SimpleTest.waitForExplicitFinish();
-</script>
-</pre>
-</body>
-</html>
-