-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Matching] Update newPassword form regex (#628)
This PR removes `reset` from `newPassword` regexes, as that keyword likely exists in login forms e.g https://camelcamelcamel.com/login Currently (on camelcamelcamel), the password input misses on https://github.com/duckduckgo/duckduckgo-autofill/blob/5c8abec8b6e8a7676b81db8839072454ea48a14c/src/Form/matching.js#L426 check since the regex only matches "current password" or "password current". Following that it immediately matches in https://github.com/duckduckgo/duckduckgo-autofill/blob/5c8abec8b6e8a7676b81db8839072454ea48a14c/src/Form/matching.js#L432 for `newPassword`. This works, as there's a `labelText` for the password input that has the word "reset" in it. I think this is a valid use case, for password reset label to be linked with a password input. We shouldn't consider `reset` to be a token related to new passwords only.
- Loading branch information
Showing
13 changed files
with
76 additions
and
50 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,22 @@ async function mocks (page) { | |
return {personalAddress, password} | ||
} | ||
|
||
/** | ||
* @param {import("@playwright/test").Page} page | ||
* @param {{ | ||
* overlay?: boolean, | ||
* clickLabel?: boolean, | ||
* pageType?: keyof typeof constants.pages, | ||
* availableInputTypes?: import('./login-form.android.spec.js').AvailableInputTypes | ||
* }} [opts] | ||
*/ | ||
async function loadAutofillWithReplacements (page, opts) { | ||
await createAutofillScript() | ||
.replaceAll(macosContentScopeReplacements(opts)) | ||
.platform('macos') | ||
.applyTo(page) | ||
} | ||
|
||
/** | ||
* @param {import("@playwright/test").Page} page | ||
* @param {{overlay?: boolean, clickLabel?: boolean, pageType?: keyof typeof constants.pages}} [opts] | ||
|
@@ -45,10 +61,7 @@ async function testLoginPage (page, opts = {}) { | |
const {personalAddress, password} = await mocks(page) | ||
|
||
// Load the autofill.js script with replacements | ||
await createAutofillScript() | ||
.replaceAll(macosContentScopeReplacements({overlay})) | ||
.platform('macos') | ||
.applyTo(page) | ||
await loadAutofillWithReplacements(page, {overlay}) | ||
|
||
const login = loginPage(page, {overlay, clickLabel}) | ||
await login.navigate(pageType) | ||
|
@@ -67,10 +80,7 @@ async function createLoginFormInModalPage (page) { | |
await mocks(page) | ||
|
||
// Pretend we're running in a top-frame scenario | ||
await createAutofillScript() | ||
.replaceAll(macosContentScopeReplacements()) | ||
.platform('macos') | ||
.applyTo(page) | ||
await loadAutofillWithReplacements(page) | ||
|
||
const login = loginPage(page) | ||
await login.navigate('loginWithFormInModal') | ||
|
@@ -86,10 +96,8 @@ test.describe('Auto-fill a login form on macOS', () => { | |
test('clicking on username should fill the username and password field', async ({page}) => { | ||
await forwardConsoleMessages(page) | ||
await mocks(page) | ||
await createAutofillScript() | ||
.replaceAll(macosContentScopeReplacements({})) | ||
.platform('macos') | ||
.applyTo(page) | ||
await loadAutofillWithReplacements(page, {}) | ||
|
||
const login = shadowInputsLoginPage(page) | ||
await login.navigate() | ||
await login.clickTheUsernameField(personalAddress) | ||
|
@@ -118,10 +126,7 @@ test.describe('Auto-fill a login form on macOS', () => { | |
await mocks(page) | ||
|
||
// Load the autofill.js script with replacements | ||
await createAutofillScript() | ||
.replaceAll(macosContentScopeReplacements({overlay: true})) | ||
.platform('macos') | ||
.applyTo(page) | ||
await loadAutofillWithReplacements(page, {overlay: true}) | ||
|
||
const login = loginPage(page, {overlay: true}) | ||
|
||
|
@@ -139,10 +144,7 @@ test.describe('Auto-fill a login form on macOS', () => { | |
await mocks(page) | ||
|
||
// Load the autofill.js script with replacements | ||
await createAutofillScript() | ||
.replaceAll(macosContentScopeReplacements({overlay: true})) | ||
.platform('macos') | ||
.applyTo(page) | ||
await loadAutofillWithReplacements(page, {overlay: true}) | ||
|
||
const login = loginPage(page, {overlay: true}) | ||
|
||
|
@@ -257,10 +259,7 @@ test.describe('Auto-fill a login form on macOS', () => { | |
await forwardConsoleMessages(page) | ||
const {personalAddress, password} = await mocks(page) | ||
|
||
await createAutofillScript() | ||
.replaceAll(macosContentScopeReplacements()) | ||
.platform('macos') | ||
.applyTo(page) | ||
await loadAutofillWithReplacements(page) | ||
|
||
const login = loginPage(page) | ||
await login.navigate('loginWithText') | ||
|
@@ -292,14 +291,11 @@ test.describe('Auto-fill a login form on macOS', () => { | |
await createWebkitMocks() | ||
.applyTo(page) | ||
|
||
await createAutofillScript() | ||
.replaceAll(macosContentScopeReplacements({ | ||
availableInputTypes: { | ||
credentials: {username: false, password: false} | ||
} | ||
})) | ||
.platform('macos') | ||
.applyTo(page) | ||
await loadAutofillWithReplacements(page, { | ||
availableInputTypes: { | ||
credentials: {username: false, password: false} | ||
} | ||
}) | ||
|
||
const login = loginPage(page) | ||
await login.navigate() | ||
|
@@ -317,10 +313,7 @@ test.describe('Auto-fill a login form on macOS', () => { | |
.withPrivateEmail('[email protected]') | ||
.applyTo(page) | ||
|
||
await createAutofillScript() | ||
.replaceAll(macosContentScopeReplacements()) | ||
.platform('macos') | ||
.applyTo(page) | ||
await loadAutofillWithReplacements(page) | ||
|
||
const login = loginPage(page) | ||
await login.navigate() | ||
|
2 changes: 1 addition & 1 deletion
2
src/Form/matching-config/__generated__/compiled-matching-config.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,17 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Replicating camelcamelcamel.com's login page, which has a password reset message in a label, linked to the password field</title> | ||
</head> | ||
<body> | ||
<form method="post" action="/sessions/create" target="_parent" id="loginform"> | ||
<input type="hidden" name="return_to" value=""> | ||
<input type="hidden" name="remember_me" value="1"> | ||
<label class="first" for="login">Username or Email</label> | ||
<input type="text" name="login" id="login" value="" tabindex="1" data-manual-scoring="username"> | ||
<label for="password">Password (Forgot your password? <a href="/forgot_password" tabindex="3">Reset it.</a>)</label> | ||
<input type="password" name="password" id="password" tabindex="2" data-manual-scoring="password.current"> | ||
<input class="button large expanded" type="submit" value="Log in" data-manual-submit> | ||
</form> | ||
</body> | ||
</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