diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /devtools/client/inspector/markup/test/helper_markup_accessibility_navigation.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'devtools/client/inspector/markup/test/helper_markup_accessibility_navigation.js')
-rw-r--r-- | devtools/client/inspector/markup/test/helper_markup_accessibility_navigation.js | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/devtools/client/inspector/markup/test/helper_markup_accessibility_navigation.js b/devtools/client/inspector/markup/test/helper_markup_accessibility_navigation.js new file mode 100644 index 000000000..a49f1e7ba --- /dev/null +++ b/devtools/client/inspector/markup/test/helper_markup_accessibility_navigation.js @@ -0,0 +1,70 @@ +/* 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/. */ +/* eslint no-unused-vars: [2, {"vars": "local"}] */ +/* import-globals-from head.js */ +"use strict"; + +/** + * Execute a keyboard event and check that the state is as expected (focused element, aria + * attribute etc...). + * + * @param {InspectorPanel} inspector + * Current instance of the inspector being tested. + * @param {Object} elms + * Map of elements that will be used to retrieve live references to children + * elements + * @param {Element} focused + * Element expected to be focused + * @param {Element} activedescendant + * Element expected to be the aria activedescendant of the root node + */ +function testNavigationState(inspector, elms, focused, activedescendant) { + let doc = inspector.markup.doc; + let id = activedescendant.getAttribute("id"); + is(doc.activeElement, focused, `Keyboard focus should be set to ${focused}`); + is(elms.root.elt.getAttribute("aria-activedescendant"), id, + `Active descendant should be set to ${id}`); +} + +/** + * Execute a keyboard event and check that the state is as expected (focused element, aria + * attribute etc...). + * + * @param {InspectorPanel} inspector + * Current instance of the inspector being tested. + * @param {Object} elms + * MarkupContainers/Elements that will be used to retrieve references to other + * elements based on objects' paths. + * @param {Object} testData + * - {String} desc: description for better logging. + * - {String} key: keyboard event's key. + * - {Object} options, optional: event data such as shiftKey, etc. + * - {String} focused: path to expected focused element in elms map. + * - {String} activedescendant: path to expected aria-activedescendant element in + * elms map. + * - {String} waitFor, optional: markupview event to wait for if keyboard actions + * result in async updates. Also accepts the inspector event "inspector-updated". + */ +function* runAccessibilityNavigationTest(inspector, elms, + {desc, key, options, focused, activedescendant, waitFor}) { + info(desc); + + let markup = inspector.markup; + let doc = markup.doc; + let win = doc.defaultView; + + let updated; + if (waitFor) { + updated = waitFor === "inspector-updated" ? + inspector.once(waitFor) : markup.once(waitFor); + } else { + updated = Promise.resolve(); + } + EventUtils.synthesizeKey(key, options, win); + yield updated; + + let focusedElement = lookupPath(elms, focused); + let activeDescendantElement = lookupPath(elms, activedescendant); + testNavigationState(inspector, elms, focusedElement, activeDescendantElement); +} |