forked from mozilla/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1753588 - Restrict the number of form looked up while checking wh…
…ether autofilling a username-only form r=tgiles,sgalich This patch adds a pref "signon.usernameOnlyForm.formThreshold" to limit the number of form we processed while receiving "PWMGR_NUM_FORM_HAS_POSSIBLE_USERNAME_EVENT_PER_DOC" event. This improves the performance while loading a page with multiple username-only likely form. Differential Revision: https://phabricator.services.mozilla.com/D138121
- Loading branch information
Showing
6 changed files
with
108 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
toolkit/components/passwordmgr/test/mochitest/test_autofill_username-only_threshold.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<!DOCTYPE HTML> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Test autofill on username-form when the number of form exceeds the lookup threshold</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> | ||
Test not autofill on username-form when the number of form exceeds the lookup threshold | ||
|
||
<script> | ||
let readyPromise = registerRunTests(); | ||
let DEFAULT_ORIGIN = window.location.origin; | ||
|
||
addLoginsInParent( | ||
[DEFAULT_ORIGIN, "https://autofill", null, "user1", "pass1"]); | ||
|
||
add_task(async function setup() { | ||
await SpecialPowers.pushPrefEnv({"set": [["signon.usernameOnlyForm.lookupThreshold", 5]]}); | ||
|
||
ok(readyPromise, "check promise is available"); | ||
await readyPromise; | ||
}); | ||
|
||
add_task(async function test_autofill_username_only_form() { | ||
let win = window.open("about:blank"); | ||
SimpleTest.registerCleanupFunction(() => win.close()); | ||
await loadFormIntoWindow(DEFAULT_ORIGIN, ` | ||
<!-- no password field, 1 username field --> | ||
<form id='form1' action='https://autofill'> 1 | ||
<input type='text' name='uname' autocomplete='username' value=''> | ||
<button type='submit'>Submit</button> | ||
<button type='reset'> Reset </button> | ||
</form> | ||
<form id='form2' action='https://autofill'> 2 | ||
<input type='text' name='uname' autocomplete='username' value=''> | ||
<button type='submit'>Submit</button> | ||
<button type='reset'> Reset </button> | ||
</form> | ||
<form id='form3' action='https://autofill'> 3 | ||
<input type='text' name='uname' autocomplete='username' value=''> | ||
<button type='submit'>Submit</button> | ||
<button type='reset'> Reset </button> | ||
</form> | ||
<form id='form4' action='https://autofill'> 4 | ||
<input type='text' name='uname' autocomplete='username' value=''> | ||
<button type='submit'>Submit</button> | ||
<button type='reset'> Reset </button> | ||
</form> | ||
<form id='form5' action='https://autofill'> 5 | ||
<input type='text' name='uname' autocomplete='username' value=''> | ||
<button type='submit'>Submit</button> | ||
<button type='reset'> Reset </button> | ||
</form> | ||
<form id='form6' action='https://autofill'> 6 | ||
<input type='text' name='uname' autocomplete='username' value=''> | ||
<button type='submit'>Submit</button> | ||
<button type='reset'> Reset </button> | ||
</form>`, win); | ||
|
||
await checkLoginFormInFrameWithElementValues(win, 1, "user1"); | ||
await checkLoginFormInFrameWithElementValues(win, 2, "user1"); | ||
await checkLoginFormInFrameWithElementValues(win, 3, "user1"); | ||
await checkLoginFormInFrameWithElementValues(win, 4, "user1"); | ||
await checkLoginFormInFrameWithElementValues(win, 5, "user1"); | ||
await checkUnmodifiedFormInFrame(win, 6); | ||
}); | ||
</script> | ||
|
||
<p id="display"></p> | ||
<div id="content"></div> | ||
<pre id="test"></pre> | ||
</pre> | ||
</body> | ||
</html> |