Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test gets skipped with pattern: os == 'android'
- Manifest: toolkit/components/passwordmgr/test/mochitest/mochitest.toml
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Test password-only forms should prefer a password-only login when present</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="pwmgr_common.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
const DEFAULT_ORIGIN = window.location.origin;
add_setup(async () => {
await setStoredLoginsAsync(
);
});
/* Test for Login Manager: 444968 (password-only forms should prefer a
* password-only login when present )
*/
add_task(async function startTest() {
const win = window.open("about:blank");
SimpleTest.registerCleanupFunction(() => win.close());
await loadFormIntoWindow(DEFAULT_ORIGIN, `
<!-- first 3 forms have matching user+pass and pass-only logins -->
<!-- user+pass form. -->
<input type="text" name="uname">
<input type="password" name="pword">
<button type="submit">Submit</button>
</form>
<!-- password-only form. -->
<input type="password" name="pword">
<button type="submit">Submit</button>
</form>
<!-- user+pass form, username prefilled -->
<input type="text" name="uname" value="testuser1A">
<input type="password" name="pword">
<button type="submit">Submit</button>
</form>
<!-- next 4 forms have matching user+pass (2x) and pass-only (1x) logins -->
<!-- user+pass form. -->
<input type="text" name="uname">
<input type="password" name="pword">
<button type="submit">Submit</button>
</form>
<!-- password-only form. -->
<input type="password" name="pword">
<button type="submit">Submit</button>
</form>
<!-- user+pass form, username prefilled -->
<input type="text" name="uname" value="testuser2A">
<input type="password" name="pword">
<button type="submit">Submit</button>
</form>
<!-- user+pass form, username prefilled -->
<input type="text" name="uname" value="testuser2C">
<input type="password" name="pword">
<button type="submit">Submit</button>
</form>`, win, 7);
await checkLoginFormInFrameWithElementValues(win, 1, "testuser1A", "testpass1A");
await checkLoginFormInFrameWithElementValues(win, 2, "testpass1B");
await checkLoginFormInFrameWithElementValues(win, 3, "testuser1A", "testpass1A");
checkUnmodifiedFormInFrame(win, 4); // 2 logins match
await checkLoginFormInFrameWithElementValues(win, 5, "testpass2B");
await checkLoginFormInFrameWithElementValues(win, 6, "testuser2A", "testpass2A");
await checkLoginFormInFrameWithElementValues(win, 7, "testuser2C", "testpass2C");
});
</script>
</pre>
</body>
</html>