diff options
Diffstat (limited to 'browser/components/urlbar/tests/browser/browser_closePanelOnClick.js')
-rw-r--r-- | browser/components/urlbar/tests/browser/browser_closePanelOnClick.js | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/browser/components/urlbar/tests/browser/browser_closePanelOnClick.js b/browser/components/urlbar/tests/browser/browser_closePanelOnClick.js new file mode 100644 index 0000000000..c61bb35bb6 --- /dev/null +++ b/browser/components/urlbar/tests/browser/browser_closePanelOnClick.js @@ -0,0 +1,51 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/** + * This tests that the urlbar panel closes when clicking certain ui elements. + */ + +"use strict"; + +add_setup(function () { + // We intentionally turn off this a11y check, because the following + // clicks is purposefully targeting non-interactive elements to dismiss + // the opened URL Bar with a mouse which can be done by assistive + // technology and keyboard by pressing `Esc` key, this rule check shall + // be ignored by a11y_checks suite. + AccessibilityUtils.setEnv({ mustHaveAccessibleRule: false }); + + registerCleanupFunction(async () => { + // Usually, the AccessibilityUtils environment should be reset right after + // the click, but in this case there are no other testable interactions + // between iterations of the use case task besides those clicks that we are + // setting the environment with. + AccessibilityUtils.resetEnv(); + }); +}); + +add_task(async function () { + await BrowserTestUtils.withNewTab("about:robots", async () => { + for (let elt of [ + gBrowser.selectedBrowser, + gBrowser.tabContainer, + document.querySelector("#nav-bar toolbarspring"), + ]) { + await UrlbarTestUtils.promiseAutocompleteResultPopup({ + window, + waitForFocus, + value: "dummy", + }); + // Must have at least one test. + Assert.ok(!!elt, "Found a valid element: " + (elt.id || elt.localName)); + await UrlbarTestUtils.promisePopupClose(window, () => + EventUtils.synthesizeNativeMouseEvent({ + type: "click", + target: elt, + atCenter: true, + }) + ); + } + }); +}); |