Bug 1422465 - Add regression test to ensure that the awesomebar richlistbox gets the COMBOBOX_LIST role;r=surkov
In the next changeset we will remove the nsIDOMXULPopupElement interface, which
was only used to make sure that this role is set. There wasn't a test covering
this case yet, so this changeset adds one.
Note that we are using a mochitest-browser test as opposed to directly testing
markup like `<panel><richlistbox /></panel>` in a mochitest-chrome test so that
we'll actually be able to catch a regression if the markup for the awesomebar changes.
MozReview-Commit-ID: KGaxQZTDq69
--- a/accessible/tests/browser/general/browser.ini
+++ b/accessible/tests/browser/general/browser.ini
@@ -1,7 +1,8 @@
[DEFAULT]
support-files =
!/accessible/tests/browser/shared-head.js
head.js
!/accessible/tests/mochitest/*.js
[browser_test_doc_creation.js]
+[browser_test_urlbar.js]
--- a/accessible/tests/browser/general/browser_test_doc_creation.js
+++ b/accessible/tests/browser/general/browser_test_doc_creation.js
@@ -1,26 +1,14 @@
/* 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/. */
"use strict";
-const nsIAccessibleRole = Ci.nsIAccessibleRole; // eslint-disable-line no-unused-vars
-
-/* import-globals-from ../../mochitest/role.js */
-loadScripts({ name: "role.js", dir: MOCHITESTS_DIR });
-
-async function openNewTab(url) {
- const forceNewProcess = true;
-
- return BrowserTestUtils.openNewForegroundTab(
- { gBrowser, url, forceNewProcess });
-}
-
const tab1URL = `data:text/html,
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8"/>
<title>First tab to be loaded</title>
</head>
<body>
<butotn>JUST A BUTTON</butotn>
new file mode 100644
--- /dev/null
+++ b/accessible/tests/browser/general/browser_test_urlbar.js
@@ -0,0 +1,34 @@
+/* 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/. */
+
+"use strict";
+
+// Checking that the awesomebar popup gets COMBOBOX_LIST role instead of
+// LISTBOX, since its parent is a <panel> (see Bug 1422465)
+add_task(async function testAutocompleteRichResult() {
+ let tab = await openNewTab("data:text/html;charset=utf-8,");
+ let accService = await initAccessibilityService();
+
+ info("Opening the URL bar and entering a key to show the PopupAutoCompleteRichResult panel");
+ let urlbar = document.getElementById("urlbar");
+ urlbar.focus();
+ let urlbarPopup = document.getElementById("PopupAutoCompleteRichResult");
+ let shown = BrowserTestUtils.waitForEvent(urlbarPopup, "popupshown");
+ EventUtils.synthesizeKey("a", {});
+ await shown;
+
+ info("Waiting for accessibility to be created for the richlistbox");
+ let richlistbox = document.getAnonymousElementByAttribute(urlbarPopup, "anonid", "richlistbox");
+ await BrowserTestUtils.waitForCondition(() => accService.getAccessibleFor(richlistbox));
+
+ info("Confirming that the special case is handled in XULListboxAccessible");
+ let accessible = accService.getAccessibleFor(richlistbox);
+ is(accessible.role, ROLE_COMBOBOX_LIST, "Right role");
+
+ await BrowserTestUtils.removeTab(tab);
+});
+
+registerCleanupFunction(async function() {
+ await shutdownAccessibilityService();
+});
--- a/accessible/tests/browser/general/head.js
+++ b/accessible/tests/browser/general/head.js
@@ -1,22 +1,34 @@
/* 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/. */
"use strict";
-/* exported initAccessibilityService, shutdownAccessibilityService */
+/* exported initAccessibilityService, openNewTab, shutdownAccessibilityService */
// Load the shared-head file first.
/* import-globals-from ../shared-head.js */
Services.scriptloader.loadSubScript(
"chrome://mochitests/content/browser/accessible/tests/browser/shared-head.js",
this);
+const nsIAccessibleRole = Ci.nsIAccessibleRole; // eslint-disable-line no-unused-vars
+
+/* import-globals-from ../../mochitest/role.js */
+loadScripts({ name: "role.js", dir: MOCHITESTS_DIR });
+
+async function openNewTab(url) {
+ const forceNewProcess = true;
+
+ return BrowserTestUtils.openNewForegroundTab(
+ { gBrowser, url, forceNewProcess });
+}
+
async function initAccessibilityService() {
info("Create accessibility service.");
let accService = Cc["@mozilla.org/accessibilityService;1"].getService(
Ci.nsIAccessibilityService);
await new Promise(resolve => {
if (Services.appinfo.accessibilityEnabled) {
resolve();