Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test gets skipped with pattern: os == 'android' OR http3 OR http2
- Manifest: toolkit/components/passwordmgr/test/mochitest/mochitest.toml
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Test we don't autofill on an HTTP page using HTTPS logins</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="/tests/SimpleTest/EventUtils.js"></script>
<script type="text/javascript" src="pwmgr_common.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<script>
const MISSING_ACTION_PATH = TESTS_DIR + "mochitest/form_basic.html";
const SAME_ORIGIN_ACTION_PATH = TESTS_DIR + "mochitest/form_same_origin_action.html";
const chromeScript = runChecksAfterCommonInit(false);
let nsLoginInfo = SpecialPowers.wrap(SpecialPowers.Components).Constructor("@mozilla.org/login-manager/loginInfo;1",
SpecialPowers.Ci.nsILoginInfo,
"init");
</script>
<p id="display"></p>
<!-- we presumably can't hide the content for this test. -->
<div id="content">
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
let win = window.open("about:blank");
SimpleTest.registerCleanupFunction(() => win.close());
async function prepareAndProcessForm(url) {
let processedPromise = promiseFormsProcessed();
win.location = url;
info("prepareAndProcessForm, assigned window location: " + url);
await processedPromise;
}
async function checkFormsWithLogin(formUrls, login, expectedUsername, expectedPassword) {
await LoginManager.removeAllUserFacingLogins();
await LoginManager.addLoginAsync(login);
for (let url of formUrls) {
info("start test_checkNoAutofillOnDowngrade w. url: " + url);
await prepareAndProcessForm(url);
info("form was processed");
await SpecialPowers.spawn(win, [url, expectedUsername, expectedPassword],
function(urlContent, expectedUsernameContent, expectedPasswordContent) {
let doc = this.content.document;
let uname = doc.getElementById("form-basic-username");
let pword = doc.getElementById("form-basic-password");
Assert.equal(uname.value, expectedUsernameContent, `username ${expectedUsernameContent ? "filled" : "not filled"} on ${urlContent}`);
Assert.equal(pword.value, expectedPasswordContent, `password ${expectedPasswordContent ? "filled" : "not filled"} on ${urlContent}`);
});
}
}
add_setup(async () => {
await SpecialPowers.pushPrefEnv({"set": [
["signon.schemeUpgrades", true],
["dom.security.https_first", false],
]});
});
add_task(async function test_sanityCheckHTTPS() {
"name1", "pass1", "uname", "pword");
await checkFormsWithLogin([
], login, "name1", "pass1");
});
add_task(async function test_checkNoAutofillOnDowngrade() {
"name1", "pass1", "uname", "pword");
await checkFormsWithLogin([
], login, "", "");
});
add_task(async function test_checkNoAutofillOnDowngradeSubdomain() {
"name1", "pass1", "uname", "pword");
todo(false, "await promiseFormsProcessed timesout when test is run with scheme=https");
await checkFormsWithLogin([
], login, "", "");
});
add_task(async function test_checkNoAutofillOnDowngradeDifferentPort() {
"name1", "pass1", "uname", "pword");
await checkFormsWithLogin([
], login, "", "");
});
add_task(async function test_checkNoAutofillOnDowngradeSubdomainDifferentPort() {
"name1", "pass1", "uname", "pword");
await checkFormsWithLogin([
], login, "", "");
});
</script>
</pre>
</body>
</html>