Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test gets skipped with pattern: os == 'android'
- Manifest: browser/components/backup/tests/chrome/chrome.toml
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Tests for the password-validation-inputs component</title>
<script type="application/javascript" src="head.js"></script>
<script
src="chrome://browser/content/backup/password-validation-inputs.mjs"
type="module"
></script>
<script>
const { BrowserTestUtils } = ChromeUtils.importESModule(
);
/**
* Tests that valid and invalid passwords will dispatch the expected events.
*/
add_task(async function test_valid_password() {
let passwordInputs = document.getElementById("test-password-validation-inputs");
let newPasswordInput = passwordInputs.inputNewPasswordEl;
let repeatPasswordInput = passwordInputs.inputRepeatPasswordEl;
ok(newPasswordInput, "New password input should be found");
ok(repeatPasswordInput, "Repeat password input should be found");
// Pretend we're entering a password in the new password field
let newPassPromise = createMockPassInputEventPromise(newPasswordInput, MOCK_PASSWORD)
await newPassPromise;
let content = document.getElementById("content");
let validPromise = BrowserTestUtils.waitForEvent(content, "ValidPasswordsDetected");
// Pretend we're entering a password in the repeat field
// Passwords match
let promiseMatchPass = createMockPassInputEventPromise(repeatPasswordInput, MOCK_PASSWORD);
await promiseMatchPass;
await validPromise;
ok(true, "Detected event after matching passwords");
let invalidPromise = BrowserTestUtils.waitForEvent(content, "InvalidPasswordsDetected");
// Passwords do not match
const tempPassword = `${MOCK_PASSWORD}-notMatch`;
let promiseNotMatchPass = createMockPassInputEventPromise(repeatPasswordInput, tempPassword);
await promiseNotMatchPass;
await invalidPromise;
ok(true, "Detected event after unmatching passwords");
})
</script>
</head>
<body>
<p id="display"></p>
<div id="content" style="display: none">
<password-validation-inputs id="test-password-validation-inputs"></password-validation-inputs>
</div>
<pre id="test"></pre>
</body>
</html>