diff options
author | wolfbeast <mcwerewolf@wolfbeast.com> | 2020-04-14 21:49:04 +0200 |
---|---|---|
committer | wolfbeast <mcwerewolf@wolfbeast.com> | 2020-04-14 21:49:04 +0200 |
commit | 39dac57259cff8b61db0b22cb2ad0a8adb02692e (patch) | |
tree | 52a026cc8c22793eb17fd0f5e22adce1ae08a1dd /toolkit/components/passwordmgr/test/browser/browser_notifications_2.js | |
parent | a1cce3b2b00bbd9f4983013ddd8934a7bccb9e99 (diff) | |
parent | c2d9ab62f3d097c9e0e00184cab1f546554f5eaa (diff) | |
download | UXP-39dac57259cff8b61db0b22cb2ad0a8adb02692e.tar UXP-39dac57259cff8b61db0b22cb2ad0a8adb02692e.tar.gz UXP-39dac57259cff8b61db0b22cb2ad0a8adb02692e.tar.lz UXP-39dac57259cff8b61db0b22cb2ad0a8adb02692e.tar.xz UXP-39dac57259cff8b61db0b22cb2ad0a8adb02692e.zip |
Merge branch 'redwood' into 28.9-platform
Diffstat (limited to 'toolkit/components/passwordmgr/test/browser/browser_notifications_2.js')
-rw-r--r-- | toolkit/components/passwordmgr/test/browser/browser_notifications_2.js | 125 |
1 files changed, 0 insertions, 125 deletions
diff --git a/toolkit/components/passwordmgr/test/browser/browser_notifications_2.js b/toolkit/components/passwordmgr/test/browser/browser_notifications_2.js deleted file mode 100644 index 48c73b0e6..000000000 --- a/toolkit/components/passwordmgr/test/browser/browser_notifications_2.js +++ /dev/null @@ -1,125 +0,0 @@ -add_task(function* setup() { - yield SpecialPowers.pushPrefEnv({"set": [ - ["signon.rememberSignons.visibilityToggle", true] - ]}); -}); - -/** - * Test that the doorhanger main action button is disabled - * when the password field is empty. - * - * Also checks that submiting an empty password throws an error. - */ -add_task(function* test_empty_password() { - yield BrowserTestUtils.withNewTab({ - gBrowser, - url: "https://example.com/browser/toolkit/components/" + - "passwordmgr/test/browser/form_basic.html", - }, function* (browser) { - // Submit the form in the content page with the credentials from the test - // case. This will cause the doorhanger notification to be displayed. - let promiseShown = BrowserTestUtils.waitForEvent(PopupNotifications.panel, - "popupshown", - (event) => event.target == PopupNotifications.panel); - yield ContentTask.spawn(browser, null, - function* () { - let doc = content.document; - doc.getElementById("form-basic-username").value = "username"; - doc.getElementById("form-basic-password").value = "p"; - doc.getElementById("form-basic").submit(); - }); - yield promiseShown; - - let notificationElement = PopupNotifications.panel.childNodes[0]; - let passwordTextbox = notificationElement.querySelector("#password-notification-password"); - let toggleCheckbox = notificationElement.querySelector("#password-notification-visibilityToggle"); - - // Synthesize input to empty the field - passwordTextbox.focus(); - yield EventUtils.synthesizeKey("VK_RIGHT", {}); - yield EventUtils.synthesizeKey("VK_BACK_SPACE", {}); - - let mainActionButton = document.getAnonymousElementByAttribute(notificationElement.button, "anonid", "button"); - Assert.ok(mainActionButton.disabled, "Main action button is disabled"); - - // Makes sure submiting an empty password throws an error - Assert.throws(notificationElement.button.doCommand(), - "Can't add a login with a null or empty password.", - "Should fail for an empty password"); - }); -}); - -/** - * Test that the doorhanger password field shows plain or * text - * when the checkbox is checked. - */ -add_task(function* test_toggle_password() { - yield BrowserTestUtils.withNewTab({ - gBrowser, - url: "https://example.com/browser/toolkit/components/" + - "passwordmgr/test/browser/form_basic.html", - }, function* (browser) { - // Submit the form in the content page with the credentials from the test - // case. This will cause the doorhanger notification to be displayed. - let promiseShown = BrowserTestUtils.waitForEvent(PopupNotifications.panel, - "popupshown", - (event) => event.target == PopupNotifications.panel); - yield ContentTask.spawn(browser, null, - function* () { - let doc = content.document; - doc.getElementById("form-basic-username").value = "username"; - doc.getElementById("form-basic-password").value = "p"; - doc.getElementById("form-basic").submit(); - }); - yield promiseShown; - - let notificationElement = PopupNotifications.panel.childNodes[0]; - let passwordTextbox = notificationElement.querySelector("#password-notification-password"); - let toggleCheckbox = notificationElement.querySelector("#password-notification-visibilityToggle"); - - yield EventUtils.synthesizeMouseAtCenter(toggleCheckbox, {}); - Assert.ok(toggleCheckbox.checked); - Assert.equal(passwordTextbox.type, "", "Password textbox changed to plain text"); - - yield EventUtils.synthesizeMouseAtCenter(toggleCheckbox, {}); - Assert.ok(!toggleCheckbox.checked); - Assert.equal(passwordTextbox.type, "password", "Password textbox changed to * text"); - }); -}); - -/** - * Test that the doorhanger password toggle checkbox is disabled - * when the master password is set. - */ -add_task(function* test_checkbox_disabled_if_has_master_password() { - yield BrowserTestUtils.withNewTab({ - gBrowser, - url: "https://example.com/browser/toolkit/components/" + - "passwordmgr/test/browser/form_basic.html", - }, function* (browser) { - // Submit the form in the content page with the credentials from the test - // case. This will cause the doorhanger notification to be displayed. - let promiseShown = BrowserTestUtils.waitForEvent(PopupNotifications.panel, - "popupshown", - (event) => event.target == PopupNotifications.panel); - - LoginTestUtils.masterPassword.enable(); - - yield ContentTask.spawn(browser, null, function* () { - let doc = content.document; - doc.getElementById("form-basic-username").value = "username"; - doc.getElementById("form-basic-password").value = "p"; - doc.getElementById("form-basic").submit(); - }); - yield promiseShown; - - let notificationElement = PopupNotifications.panel.childNodes[0]; - let passwordTextbox = notificationElement.querySelector("#password-notification-password"); - let toggleCheckbox = notificationElement.querySelector("#password-notification-visibilityToggle"); - - Assert.equal(passwordTextbox.type, "password", "Password textbox should show * text"); - Assert.ok(toggleCheckbox.getAttribute("hidden"), "checkbox is hidden when master password is set"); - }); - - LoginTestUtils.masterPassword.disable(); -}); |