Bug 1422465 - Add regression test to ensure that the awesomebar richlistbox gets the COMBOBOX_LIST role;r=surkov draft
authorBrian Grinstead <bgrinstead@mozilla.com>
Thu, 07 Dec 2017 13:05:07 -0800
changeset 709272 671b718fd010b5f6a2036a695d2c4c03c8b64654
parent 707182 5be384bcf00191f97d32b4ac3ecd1b85ec7b18e1
child 709273 f2c75902b897ecdd8704743b95b99b57f55979d0
push id92593
push userbgrinstead@mozilla.com
push dateThu, 07 Dec 2017 21:37:17 +0000
reviewerssurkov
bugs1422465
milestone59.0a1
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
accessible/tests/browser/general/browser.ini
accessible/tests/browser/general/browser_test_doc_creation.js
accessible/tests/browser/general/browser_test_urlbar.js
accessible/tests/browser/general/head.js
--- 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();