mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 15:23:51 +00:00
Bug 1298543 - Fix test_prompt_http.html for e10s. r=Dolske
Don't actually test doorhanger notifications since they are only on the desktop browser and browser chrome tests already check them. The Android notifyObservers additions aren't used in this patch but I added them for consistency and because we should start to use them for cross-platform tests that check if a doorhanger appears. MozReview-Commit-ID: B5wK8oqu0h7 --HG-- rename : toolkit/components/passwordmgr/test/notification_common.js => toolkit/components/passwordmgr/test/chrome/notification_common.js extra : rebase_source : 741f45a7dd64a1b7043040bec90bef4e5fd86c0e
This commit is contained in:
parent
fda7568661
commit
d5c4cc5f59
@ -129,6 +129,7 @@ LoginManagerPrompter.prototype = {
|
||||
promptToSavePassword : function (aLogin) {
|
||||
this._showSaveLoginNotification(aLogin);
|
||||
Services.telemetry.getHistogramById("PWMGR_PROMPT_REMEMBER_ACTION").add(PROMPT_DISPLAYED);
|
||||
Services.obs.notifyObservers(aLogin, "passwordmgr-prompt-save", null);
|
||||
},
|
||||
|
||||
/*
|
||||
@ -228,6 +229,8 @@ LoginManagerPrompter.prototype = {
|
||||
promptToChangePassword : function (aOldLogin, aNewLogin) {
|
||||
this._showChangeLoginNotification(aOldLogin, aNewLogin.password);
|
||||
Services.telemetry.getHistogramById("PWMGR_PROMPT_UPDATE_ACTION").add(PROMPT_DISPLAYED);
|
||||
let oldGUID = aOldLogin.QueryInterface(Ci.nsILoginMetaInfo).guid;
|
||||
Services.obs.notifyObservers(aNewLogin, "passwordmgr-prompt-change", oldGUID);
|
||||
},
|
||||
|
||||
/*
|
||||
|
@ -1065,6 +1065,8 @@ LoginManagerPrompter.prototype = {
|
||||
this._showLoginNotification(aNotifyObj, "password-save",
|
||||
notificationText, buttons);
|
||||
}
|
||||
|
||||
Services.obs.notifyObservers(aLogin, "passwordmgr-prompt-save", null);
|
||||
},
|
||||
|
||||
_removeLoginNotifications : function () {
|
||||
@ -1144,6 +1146,8 @@ LoginManagerPrompter.prototype = {
|
||||
// userChoice == 1 --> just ignore the login.
|
||||
this.log("Ignoring login.");
|
||||
}
|
||||
|
||||
Services.obs.notifyObservers(aLogin, "passwordmgr-prompt-save", null);
|
||||
},
|
||||
|
||||
|
||||
@ -1235,6 +1239,9 @@ LoginManagerPrompter.prototype = {
|
||||
this._showLoginNotification(aNotifyObj, "password-change",
|
||||
notificationText, buttons);
|
||||
}
|
||||
|
||||
let oldGUID = aOldLogin.QueryInterface(Ci.nsILoginMetaInfo).guid;
|
||||
Services.obs.notifyObservers(aNewLogin, "passwordmgr-prompt-change", oldGUID);
|
||||
},
|
||||
|
||||
|
||||
@ -1265,6 +1272,9 @@ LoginManagerPrompter.prototype = {
|
||||
this.log("Updating password for user " + aOldLogin.username);
|
||||
this._updateLogin(aOldLogin, aNewLogin);
|
||||
}
|
||||
|
||||
let oldGUID = aOldLogin.QueryInterface(Ci.nsILoginMetaInfo).guid;
|
||||
Services.obs.notifyObservers(aNewLogin, "passwordmgr-prompt-change", oldGUID);
|
||||
},
|
||||
|
||||
|
||||
|
@ -5,7 +5,7 @@ skip-if = buildapp == 'b2g' || os == 'android'
|
||||
skip-if = true # Bug 1173337
|
||||
support-files =
|
||||
../formsubmit.sjs
|
||||
../notification_common.js
|
||||
notification_common.js
|
||||
privbrowsing_perwindowpb_iframe.html
|
||||
subtst_privbrowsing_1.html
|
||||
subtst_privbrowsing_2.html
|
||||
|
@ -4,7 +4,6 @@ support-files =
|
||||
authenticate.sjs
|
||||
blank.html
|
||||
formsubmit.sjs
|
||||
notification_common.js
|
||||
prompt_common.js
|
||||
pwmgr_common.js
|
||||
subtst_master_pass.html
|
||||
|
@ -9,7 +9,6 @@ support-files =
|
||||
../blank.html
|
||||
../browser/form_basic.html
|
||||
../browser/form_cross_origin_secure_action.html
|
||||
../notification_common.js
|
||||
../pwmgr_common.js
|
||||
auth2/authenticate.sjs
|
||||
|
||||
@ -49,7 +48,7 @@ skip-if = toolkit == 'android' # autocomplete
|
||||
[test_prompt.html]
|
||||
skip-if = os == "linux" || toolkit == 'android' # Tests desktop prompts
|
||||
[test_prompt_http.html]
|
||||
skip-if = e10s || os == "linux" || toolkit == 'android' # Tests desktop prompts
|
||||
skip-if = os == "linux" || toolkit == 'android' # Tests desktop prompts
|
||||
[test_prompt_promptAuth.html]
|
||||
skip-if = os == "linux" || toolkit == 'android' # Tests desktop prompts
|
||||
[test_prompt_promptAuth_proxy.html]
|
||||
|
@ -7,7 +7,6 @@
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SpawnTask.js"></script>
|
||||
<script type="text/javascript" src="pwmgr_common.js"></script>
|
||||
<script type="text/javascript" src="prompt_common.js"></script>
|
||||
<script type="text/javascript" src="notification_common.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
@ -146,40 +145,13 @@ add_task(function* test_iframe() {
|
||||
};
|
||||
promptDone = handlePrompt(state, action);
|
||||
iframeLoaded = onloadPromiseFor("iframe");
|
||||
let promptShownPromise = promisePromptShown("passwordmgr-prompt-change");
|
||||
iframe.src = "authenticate.sjs?user=mochiuser1&pass=mochipass1-new";
|
||||
yield promptDone;
|
||||
yield iframeLoaded;
|
||||
checkEchoedAuthInfo({user: "mochiuser1", pass: "mochipass1-new"},
|
||||
iframe.contentDocument);
|
||||
|
||||
|
||||
var pwchanged = promiseStorageChanged(["modifyLogin"]);
|
||||
|
||||
// Check for the popup notification, and change the password.
|
||||
var popupNotifications = getPopupNotifications(window.top);
|
||||
popup = getPopup(popupNotifications, "password-change");
|
||||
ok(popup, "got popup notification");
|
||||
clickPopupButton(popup, kChangeButton);
|
||||
popup.remove();
|
||||
|
||||
yield pwchanged;
|
||||
|
||||
// Housekeeping: change it back
|
||||
runInParent(() => {
|
||||
const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
var tmpLogin = Cc["@mozilla.org/login-manager/loginInfo;1"].
|
||||
createInstance(Ci.nsILoginInfo);
|
||||
tmpLogin.init("http://mochi.test:8888", null, "mochitest",
|
||||
"mochiuser1", "mochipass1-new", "", "");
|
||||
var login3A = Cc["@mozilla.org/login-manager/loginInfo;1"].
|
||||
createInstance(Ci.nsILoginInfo);
|
||||
login3A.init("http://mochi.test:8888", null, "mochitest",
|
||||
"mochiuser1", "mochipass1", "", "");
|
||||
|
||||
Services.logins.modifyLogin(tmpLogin, login3A);
|
||||
});
|
||||
yield promptShownPromise;
|
||||
|
||||
// Same as last test, but for a realm we haven't already authenticated
|
||||
// to (but have an existing saved login for, so that we'll trigger
|
||||
@ -205,24 +177,15 @@ add_task(function* test_iframe() {
|
||||
};
|
||||
promptDone = handlePrompt(state, action);
|
||||
iframeLoaded = onloadPromiseFor("iframe");
|
||||
promptShownPromise = promisePromptShown("passwordmgr-prompt-change");
|
||||
iframe.src = "authenticate.sjs?user=mochiuser3&pass=mochipass3-new&realm=mochitest3";
|
||||
yield promptDone;
|
||||
yield iframeLoaded;
|
||||
checkEchoedAuthInfo({user: "mochiuser3", pass: "mochipass3-new"},
|
||||
iframe.contentDocument);
|
||||
yield promptShownPromise;
|
||||
|
||||
pwchanged = promiseStorageChanged(["modifyLogin"]);
|
||||
|
||||
// Check for the popup notification, and change the password.
|
||||
popup = getPopup(popupNotifications, "password-change");
|
||||
ok(popup, "got popup notification");
|
||||
clickPopupButton(popup, kChangeButton);
|
||||
popup.remove();
|
||||
|
||||
yield pwchanged;
|
||||
|
||||
// Housekeeping: change it back to the original login4. Actually,
|
||||
// just delete it and we'll re-add it as the next test.
|
||||
// Housekeeping: Delete login4 to test the save prompt in the next test.
|
||||
runInParent(() => {
|
||||
const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
@ -230,7 +193,7 @@ add_task(function* test_iframe() {
|
||||
var tmpLogin = Cc["@mozilla.org/login-manager/loginInfo;1"].
|
||||
createInstance(Ci.nsILoginInfo);
|
||||
tmpLogin.init("http://mochi.test:8888", null, "mochitest3",
|
||||
"mochiuser3", "mochipass3-new", "", "");
|
||||
"mochiuser3", "mochipass3-old", "", "");
|
||||
Services.logins.removeLogin(tmpLogin);
|
||||
|
||||
// Clear cached auth from this subtest, and avoid leaking due to bug 459620.
|
||||
@ -263,20 +226,13 @@ add_task(function* test_iframe() {
|
||||
promptDone = handlePrompt(state, action);
|
||||
|
||||
iframeLoaded = onloadPromiseFor("iframe");
|
||||
promptShownPromise = promisePromptShown("passwordmgr-prompt-save");
|
||||
iframe.src = "authenticate.sjs?user=mochiuser3&pass=mochipass3-old&realm=mochitest3";
|
||||
yield promptDone;
|
||||
yield iframeLoaded;
|
||||
checkEchoedAuthInfo({user: "mochiuser3", pass: "mochipass3-old"},
|
||||
iframe.contentDocument);
|
||||
|
||||
var pwsaved = promiseStorageChanged(["addLogin"]);
|
||||
|
||||
// Check for the popup notification, and change the password.
|
||||
popup = getPopup(popupNotifications, "password-save");
|
||||
ok(popup, "got popup notification");
|
||||
clickPopupButton(popup, kRememberButton);
|
||||
popup.remove();
|
||||
yield pwsaved;
|
||||
yield promptShownPromise;
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
|
@ -320,6 +320,17 @@ function promiseStorageChanged(expectedChangeTypes) {
|
||||
});
|
||||
}
|
||||
|
||||
function promisePromptShown(expectedTopic) {
|
||||
return new Promise((resolve, reject) => {
|
||||
function onPromptShown({ topic, data }) {
|
||||
is(topic, expectedTopic, "Check expected prompt topic");
|
||||
chromeScript.removeMessageListener("promptShown", onPromptShown);
|
||||
resolve();
|
||||
}
|
||||
chromeScript.addMessageListener("promptShown", onPromptShown);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Run a function synchronously in the parent process and destroy it in the test cleanup function.
|
||||
* @param {Function|String} aFunctionOrURL - either a function that will be stringified and run
|
||||
@ -372,6 +383,15 @@ if (this.addMessageListener) {
|
||||
}
|
||||
Services.obs.addObserver(onStorageChanged, "passwordmgr-storage-changed", false);
|
||||
|
||||
function onPrompt(subject, topic, data) {
|
||||
sendAsyncMessage("promptShown", {
|
||||
topic,
|
||||
data,
|
||||
});
|
||||
}
|
||||
Services.obs.addObserver(onPrompt, "passwordmgr-prompt-change", false);
|
||||
Services.obs.addObserver(onPrompt, "passwordmgr-prompt-save", false);
|
||||
|
||||
addMessageListener("setupParent", ({selfFilling = false} = {selfFilling: false}) => {
|
||||
// Force LoginManagerParent to init for the tests since it's normally delayed
|
||||
// by apps such as on Android.
|
||||
@ -432,6 +452,18 @@ if (this.addMessageListener) {
|
||||
if (LoginManagerParent._recipeManager) {
|
||||
LoginManagerParent._recipeManager.reset();
|
||||
}
|
||||
|
||||
// Cleanup PopupNotifications (if on a relevant platform)
|
||||
let chromeWin = Services.wm.getMostRecentWindow("navigator:browser");
|
||||
if (chromeWin && chromeWin.PopupNotifications) {
|
||||
let notes = chromeWin.PopupNotifications._currentNotifications;
|
||||
if (notes.length > 0) {
|
||||
dump("Removing " + notes.length + " popup notifications.\n");
|
||||
}
|
||||
for (let note of notes) {
|
||||
note.remove();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user