Bug 1473305 - Move browser_jsterm_popup.js to devtools/client/shared/test ;r=Honza.
This test is directly calling Autocomplete popup methods and only uses the
console for the instance and the input it provides. This patch moves the
test to the shared component folder, where the autocompletion code lives
so it feels more natural.
A few test cases are added in the jsterm_accessibility test, this time in
direct relation with the console input.
MozReview-Commit-ID: Ih7rOJ3vHpb
--- a/devtools/client/shared/test/browser.ini
+++ b/devtools/client/shared/test/browser.ini
@@ -33,16 +33,17 @@ support-files =
leakhunt.js
shared-head.js
shared-redux-head.js
telemetry-test-helpers.js
test-actor-registry.js
test-actor.js
!/devtools/client/responsive.html/test/browser/devices.json
+[browser_autocomplete_popup.js]
[browser_css_angle.js]
[browser_css_color.js]
[browser_cubic-bezier-01.js]
[browser_cubic-bezier-02.js]
[browser_cubic-bezier-03.js]
[browser_cubic-bezier-04.js]
[browser_cubic-bezier-05.js]
[browser_cubic-bezier-06.js]
rename from devtools/client/webconsole/test/mochitest/browser_jsterm_popup.js
rename to devtools/client/shared/test/browser_autocomplete_popup.js
--- a/devtools/client/webconsole/test/mochitest/browser_jsterm_popup.js
+++ b/devtools/client/shared/test/browser_autocomplete_popup.js
@@ -1,25 +1,27 @@
-/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
-/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
-// See Bug 585991.
-
-const TEST_URI = "data:text/html;charset=utf-8,<p>bug 585991 - autocomplete popup test";
+add_task(async function() {
+ const AutocompletePopup = require("devtools/client/shared/autocomplete-popup");
-add_task(async function() {
- const {jsterm} = await openNewTabAndConsole(TEST_URI);
- const {
- autocompletePopup: popup,
- inputNode: input,
- } = jsterm;
+ info("Create an autocompletion popup");
+ const [,, doc] = await createHost();
+ const input = doc.createElement("input");
+ doc.body.appendChild(input);
+
+ const autocompleteOptions = {
+ position: "top",
+ autoSelect: true
+ };
+ const popup = new AutocompletePopup(doc, autocompleteOptions);
+ input.focus();
const items = [
{label: "item0", value: "value0"},
{label: "item1", value: "value1"},
{label: "item2", value: "value2"},
];
ok(!popup.isOpen, "popup is not open");
--- a/devtools/client/webconsole/test/mochitest/browser.ini
+++ b/devtools/client/webconsole/test/mochitest/browser.ini
@@ -222,17 +222,16 @@ skip-if = os != 'mac' # The tested ctrl+
[browser_jsterm_inspect.js]
[browser_jsterm_instance_of.js]
[browser_jsterm_multiline.js]
[browser_jsterm_no_autocompletion_on_defined_variables.js]
[browser_jsterm_no_input_and_tab_key_pressed.js]
[browser_jsterm_no_input_change_and_tab_key_pressed.js]
[browser_jsterm_null_undefined.js]
[browser_jsterm_popup_close_on_tab_switch.js]
-[browser_jsterm_popup.js]
[browser_jsterm_screenshot_command_clipboard.js]
subsuite = clipboard
[browser_jsterm_screenshot_command_file.js]
skip-if = (os == 'win') # Bug 1464461, disabled on Win due to timeouts
[browser_jsterm_selfxss.js]
subsuite = clipboard
[browser_webconsole_allow_mixedcontent_securityerrors.js]
tags = mcb
--- a/devtools/client/webconsole/test/mochitest/browser_jsterm_accessibility.js
+++ b/devtools/client/webconsole/test/mochitest/browser_jsterm_accessibility.js
@@ -14,18 +14,26 @@ add_task(async function() {
const hud = await openNewTabAndConsole(TEST_URI);
const jsterm = hud.jsterm;
const input = jsterm.inputNode;
info("Test that the console input is not treated as a live region");
ok(!isElementInLiveRegion(input), "Console input is not treated as a live region");
+ info("Test the console input has no aria-activedescendant attribute");
+ ok(!input.hasAttribute("aria-activedescendant"), "no aria-activedescendant");
+
info("Type 'd' to open the autocomplete popup");
- await autocomplete(jsterm, "d");
+ const onPopupOpen = jsterm.autocompletePopup.once("popup-opened");
+ autocomplete(jsterm, "d");
+ await onPopupOpen;
+
+ info("Test the console input has an aria-activedescendant attribute");
+ ok(input.hasAttribute("aria-activedescendant"), "aria-activedescendant");
// Add listeners for focus and blur events.
let wasBlurred = false;
input.addEventListener("blur", () => {
wasBlurred = true;
}, {
once: true
});
@@ -41,16 +49,19 @@ add_task(async function() {
info("Close the autocomplete popup by simulating a TAB key event");
const onPopupClosed = jsterm.autocompletePopup.once("popup-closed");
EventUtils.synthesizeKey("KEY_Tab");
info("Wait for the autocomplete popup to be closed");
await onPopupClosed;
ok(wasFocused, "jsterm input received a focus event");
+
+ info("Test the console input has no aria-activedescendant attribute no more");
+ ok(!input.hasAttribute("aria-activedescendant"), "no aria-activedescendant");
});
async function autocomplete(jsterm, value) {
const popup = jsterm.autocompletePopup;
await new Promise(resolve => {
jsterm.setInputValue(value);
jsterm.complete(jsterm.COMPLETE_HINT_ONLY, resolve);