2016-01-15 00:12:13 +03:00
|
|
|
/* 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/. */
|
|
|
|
|
2016-03-03 16:58:13 +03:00
|
|
|
"use strict";
|
2016-01-15 00:12:13 +03:00
|
|
|
|
2019-01-17 21:18:31 +03:00
|
|
|
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
|
|
|
const { XPCOMUtils } = ChromeUtils.import(
|
|
|
|
"resource://gre/modules/XPCOMUtils.jsm"
|
|
|
|
);
|
2016-01-15 00:12:13 +03:00
|
|
|
|
2019-01-17 21:18:31 +03:00
|
|
|
const { ElementNotAccessibleError } = ChromeUtils.import(
|
|
|
|
"chrome://marionette/content/error.js"
|
|
|
|
);
|
|
|
|
const { Log } = ChromeUtils.import("chrome://marionette/content/log.js");
|
2016-11-07 20:15:08 +03:00
|
|
|
|
2018-06-06 16:40:05 +03:00
|
|
|
XPCOMUtils.defineLazyGetter(this, "logger", Log.get);
|
2016-01-15 00:12:13 +03:00
|
|
|
|
2016-11-07 20:15:08 +03:00
|
|
|
XPCOMUtils.defineLazyGetter(this, "service", () => {
|
|
|
|
try {
|
2017-06-28 21:09:40 +03:00
|
|
|
return Cc["@mozilla.org/accessibilityService;1"].getService(
|
|
|
|
Ci.nsIAccessibilityService
|
|
|
|
);
|
2016-11-07 20:15:08 +03:00
|
|
|
} catch (e) {
|
|
|
|
logger.warn("Accessibility module is not present");
|
2017-06-28 21:09:40 +03:00
|
|
|
return undefined;
|
2016-11-07 20:15:08 +03:00
|
|
|
}
|
|
|
|
});
|
2016-03-03 16:58:13 +03:00
|
|
|
|
|
|
|
this.EXPORTED_SYMBOLS = ["accessibility"];
|
|
|
|
|
2017-07-26 15:11:53 +03:00
|
|
|
/** @namespace */
|
2016-11-07 20:15:08 +03:00
|
|
|
this.accessibility = {
|
|
|
|
get service() {
|
|
|
|
return service;
|
2017-06-30 02:40:24 +03:00
|
|
|
},
|
2016-11-07 20:15:08 +03:00
|
|
|
};
|
2016-01-15 00:12:13 +03:00
|
|
|
|
2016-03-03 16:58:13 +03:00
|
|
|
/**
|
2016-03-03 16:58:13 +03:00
|
|
|
* Accessible states used to check element"s state from the accessiblity API
|
|
|
|
* perspective.
|
2017-06-30 02:40:24 +03:00
|
|
|
*
|
|
|
|
* Note: if gecko is built with --disable-accessibility, the interfaces
|
|
|
|
* are not defined. This is why we use getters instead to be able to use
|
|
|
|
* these statically.
|
2016-03-03 16:58:13 +03:00
|
|
|
*/
|
2016-03-03 16:58:13 +03:00
|
|
|
accessibility.State = {
|
2016-08-24 22:52:20 +03:00
|
|
|
get Unavailable() {
|
|
|
|
return Ci.nsIAccessibleStates.STATE_UNAVAILABLE;
|
|
|
|
},
|
|
|
|
get Focusable() {
|
|
|
|
return Ci.nsIAccessibleStates.STATE_FOCUSABLE;
|
|
|
|
},
|
|
|
|
get Selectable() {
|
|
|
|
return Ci.nsIAccessibleStates.STATE_SELECTABLE;
|
|
|
|
},
|
|
|
|
get Selected() {
|
|
|
|
return Ci.nsIAccessibleStates.STATE_SELECTED;
|
2017-06-30 02:40:24 +03:00
|
|
|
},
|
2016-03-03 16:58:13 +03:00
|
|
|
};
|
|
|
|
|
2016-03-03 16:58:13 +03:00
|
|
|
/**
|
|
|
|
* Accessible object roles that support some action.
|
|
|
|
*/
|
|
|
|
accessibility.ActionableRoles = new Set([
|
|
|
|
"checkbutton",
|
|
|
|
"check menu item",
|
|
|
|
"check rich option",
|
|
|
|
"combobox",
|
|
|
|
"combobox option",
|
|
|
|
"entry",
|
|
|
|
"key",
|
|
|
|
"link",
|
|
|
|
"listbox option",
|
|
|
|
"listbox rich option",
|
|
|
|
"menuitem",
|
|
|
|
"option",
|
|
|
|
"outlineitem",
|
|
|
|
"pagetab",
|
|
|
|
"pushbutton",
|
|
|
|
"radiobutton",
|
|
|
|
"radio menu item",
|
|
|
|
"rowheader",
|
|
|
|
"slider",
|
|
|
|
"spinbutton",
|
|
|
|
"switch",
|
|
|
|
]);
|
2016-01-15 00:12:13 +03:00
|
|
|
|
2016-03-03 16:58:13 +03:00
|
|
|
/**
|
|
|
|
* Factory function that constructs a new {@code accessibility.Checks}
|
|
|
|
* object with enforced strictness or not.
|
|
|
|
*/
|
2017-06-30 02:40:24 +03:00
|
|
|
accessibility.get = function(strict = false) {
|
2016-03-03 16:58:13 +03:00
|
|
|
return new accessibility.Checks(!!strict);
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Component responsible for interacting with platform accessibility
|
|
|
|
* API.
|
|
|
|
*
|
|
|
|
* Its methods serve as wrappers for testing content and chrome
|
|
|
|
* accessibility as well as accessibility of user interactions.
|
|
|
|
*/
|
|
|
|
accessibility.Checks = class {
|
2016-03-09 16:03:28 +03:00
|
|
|
/**
|
2016-03-03 16:58:13 +03:00
|
|
|
* @param {boolean} strict
|
|
|
|
* Flag indicating whether the accessibility issue should be logged
|
|
|
|
* or cause an error to be thrown. Default is to log to stdout.
|
2016-03-09 16:03:28 +03:00
|
|
|
*/
|
2016-03-03 16:58:13 +03:00
|
|
|
constructor(strict) {
|
|
|
|
this.strict = strict;
|
|
|
|
}
|
2016-03-09 16:03:28 +03:00
|
|
|
|
|
|
|
/**
|
2016-03-03 16:58:13 +03:00
|
|
|
* Get an accessible object for an element.
|
|
|
|
*
|
|
|
|
* @param {DOMElement|XULElement} element
|
|
|
|
* Element to get the accessible object for.
|
|
|
|
* @param {boolean=} mustHaveAccessible
|
|
|
|
* Flag indicating that the element must have an accessible object.
|
|
|
|
* Defaults to not require this.
|
|
|
|
*
|
2017-07-26 15:11:53 +03:00
|
|
|
* @return {Promise.<nsIAccessible>}
|
2016-11-07 20:15:08 +03:00
|
|
|
* Promise with an accessibility object for the given element.
|
2016-03-09 16:03:28 +03:00
|
|
|
*/
|
2016-03-03 16:58:13 +03:00
|
|
|
getAccessible(element, mustHaveAccessible = false) {
|
2016-11-07 20:15:08 +03:00
|
|
|
if (!this.strict) {
|
|
|
|
return Promise.resolve();
|
|
|
|
}
|
|
|
|
|
2016-01-15 00:12:13 +03:00
|
|
|
return new Promise((resolve, reject) => {
|
2016-11-07 20:15:08 +03:00
|
|
|
if (!accessibility.service) {
|
|
|
|
reject();
|
|
|
|
return;
|
|
|
|
}
|
2016-01-15 00:12:13 +03:00
|
|
|
|
2017-06-16 00:53:14 +03:00
|
|
|
// First, check if accessibility is ready.
|
2017-06-30 02:40:24 +03:00
|
|
|
let docAcc = accessibility.service.getAccessibleFor(
|
|
|
|
element.ownerDocument
|
|
|
|
);
|
2017-06-16 00:53:14 +03:00
|
|
|
let state = {};
|
|
|
|
docAcc.getState(state, {});
|
|
|
|
if ((state.value & Ci.nsIAccessibleStates.STATE_BUSY) == 0) {
|
|
|
|
// Accessibility is ready, resolve immediately.
|
|
|
|
let acc = accessibility.service.getAccessibleFor(element);
|
|
|
|
if (mustHaveAccessible && !acc) {
|
|
|
|
reject();
|
|
|
|
} else {
|
|
|
|
resolve(acc);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// Accessibility for the doc is busy, so wait for the state to change.
|
|
|
|
let eventObserver = {
|
2017-10-03 16:35:47 +03:00
|
|
|
observe(subject, topic) {
|
2017-06-16 00:53:14 +03:00
|
|
|
if (topic !== "accessible-event") {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If event type does not match expected type, skip the event.
|
2017-06-30 02:40:24 +03:00
|
|
|
let event = subject.QueryInterface(Ci.nsIAccessibleEvent);
|
2017-06-16 00:53:14 +03:00
|
|
|
if (event.eventType !== Ci.nsIAccessibleEvent.EVENT_STATE_CHANGE) {
|
|
|
|
return;
|
|
|
|
}
|
2017-06-30 02:40:24 +03:00
|
|
|
|
|
|
|
// If event's accessible does not match expected accessible,
|
|
|
|
// skip the event.
|
2017-06-16 00:53:14 +03:00
|
|
|
if (event.accessible !== docAcc) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Services.obs.removeObserver(this, "accessible-event");
|
2016-11-07 20:15:08 +03:00
|
|
|
let acc = accessibility.service.getAccessibleFor(element);
|
2017-06-16 00:53:14 +03:00
|
|
|
if (mustHaveAccessible && !acc) {
|
|
|
|
reject();
|
|
|
|
} else {
|
|
|
|
resolve(acc);
|
2016-01-15 00:12:13 +03:00
|
|
|
}
|
2017-06-30 02:40:24 +03:00
|
|
|
},
|
2017-06-16 00:53:14 +03:00
|
|
|
};
|
|
|
|
Services.obs.addObserver(eventObserver, "accessible-event");
|
2016-01-15 00:12:13 +03:00
|
|
|
}).catch(() =>
|
2016-03-03 16:58:13 +03:00
|
|
|
this.error("Element does not have an accessible object", element)
|
|
|
|
);
|
2017-06-30 02:40:24 +03:00
|
|
|
}
|
2016-01-15 00:12:13 +03:00
|
|
|
|
|
|
|
/**
|
2016-03-03 16:58:13 +03:00
|
|
|
* Test if the accessible has a role that supports some arbitrary
|
|
|
|
* action.
|
|
|
|
*
|
|
|
|
* @param {nsIAccessible} accessible
|
|
|
|
* Accessible object.
|
|
|
|
*
|
|
|
|
* @return {boolean}
|
|
|
|
* True if an actionable role is found on the accessible, false
|
|
|
|
* otherwise.
|
2016-01-15 00:12:13 +03:00
|
|
|
*/
|
|
|
|
isActionableRole(accessible) {
|
2016-03-03 16:58:13 +03:00
|
|
|
return accessibility.ActionableRoles.has(
|
2016-11-07 20:15:08 +03:00
|
|
|
accessibility.service.getStringRole(accessible.role)
|
|
|
|
);
|
2016-03-03 16:58:13 +03:00
|
|
|
}
|
2016-01-15 00:12:13 +03:00
|
|
|
|
|
|
|
/**
|
2016-03-03 16:58:13 +03:00
|
|
|
* Test if an accessible has at least one action that it supports.
|
|
|
|
*
|
|
|
|
* @param {nsIAccessible} accessible
|
|
|
|
* Accessible object.
|
|
|
|
*
|
|
|
|
* @return {boolean}
|
|
|
|
* True if the accessible has at least one supported action,
|
|
|
|
* false otherwise.
|
2016-01-15 00:12:13 +03:00
|
|
|
*/
|
|
|
|
hasActionCount(accessible) {
|
|
|
|
return accessible.actionCount > 0;
|
2016-03-03 16:58:13 +03:00
|
|
|
}
|
2016-01-15 00:12:13 +03:00
|
|
|
|
|
|
|
/**
|
2016-03-03 16:58:13 +03:00
|
|
|
* Test if an accessible has a valid name.
|
|
|
|
*
|
|
|
|
* @param {nsIAccessible} accessible
|
|
|
|
* Accessible object.
|
|
|
|
*
|
|
|
|
* @return {boolean}
|
|
|
|
* True if the accessible has a non-empty valid name, or false if
|
|
|
|
* this is not the case.
|
2016-01-15 00:12:13 +03:00
|
|
|
*/
|
|
|
|
hasValidName(accessible) {
|
|
|
|
return accessible.name && accessible.name.trim();
|
2016-03-03 16:58:13 +03:00
|
|
|
}
|
2016-01-15 00:12:13 +03:00
|
|
|
|
|
|
|
/**
|
2016-03-03 16:58:13 +03:00
|
|
|
* Test if an accessible has a {@code hidden} attribute.
|
|
|
|
*
|
|
|
|
* @param {nsIAccessible} accessible
|
|
|
|
* Accessible object.
|
|
|
|
*
|
|
|
|
* @return {boolean}
|
2017-04-03 19:47:00 +03:00
|
|
|
* True if the accessible object has a {@code hidden} attribute,
|
2016-03-03 16:58:13 +03:00
|
|
|
* false otherwise.
|
2016-01-15 00:12:13 +03:00
|
|
|
*/
|
|
|
|
hasHiddenAttribute(accessible) {
|
|
|
|
let hidden = false;
|
|
|
|
try {
|
2016-03-03 16:58:13 +03:00
|
|
|
hidden = accessible.attributes.getStringProperty("hidden");
|
2017-06-28 21:08:18 +03:00
|
|
|
} catch (e) {}
|
|
|
|
// if the property is missing, error will be thrown
|
|
|
|
return hidden && hidden === "true";
|
2016-03-03 16:58:13 +03:00
|
|
|
}
|
2016-01-15 00:12:13 +03:00
|
|
|
|
|
|
|
/**
|
2016-03-03 16:58:13 +03:00
|
|
|
* Verify if an accessible has a given state.
|
|
|
|
* Test if an accessible has a given state.
|
|
|
|
*
|
|
|
|
* @param {nsIAccessible} accessible
|
|
|
|
* Accessible object to test.
|
|
|
|
* @param {number} stateToMatch
|
|
|
|
* State to match.
|
|
|
|
*
|
|
|
|
* @return {boolean}
|
|
|
|
* True if |accessible| has |stateToMatch|, false otherwise.
|
2016-01-15 00:12:13 +03:00
|
|
|
*/
|
|
|
|
matchState(accessible, stateToMatch) {
|
|
|
|
let state = {};
|
|
|
|
accessible.getState(state, {});
|
|
|
|
return !!(state.value & stateToMatch);
|
2016-03-03 16:58:13 +03:00
|
|
|
}
|
2016-01-15 00:12:13 +03:00
|
|
|
|
|
|
|
/**
|
2016-03-03 16:58:13 +03:00
|
|
|
* Test if an accessible is hidden from the user.
|
|
|
|
*
|
|
|
|
* @param {nsIAccessible} accessible
|
|
|
|
* Accessible object.
|
|
|
|
*
|
|
|
|
* @return {boolean}
|
|
|
|
* True if element is hidden from user, false otherwise.
|
2016-01-15 00:12:13 +03:00
|
|
|
*/
|
|
|
|
isHidden(accessible) {
|
2018-07-04 17:00:07 +03:00
|
|
|
if (!accessible) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-01-15 00:12:13 +03:00
|
|
|
while (accessible) {
|
|
|
|
if (this.hasHiddenAttribute(accessible)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
accessible = accessible.parent;
|
|
|
|
}
|
|
|
|
return false;
|
2016-03-03 16:58:13 +03:00
|
|
|
}
|
2016-01-15 00:12:13 +03:00
|
|
|
|
|
|
|
/**
|
2016-03-03 16:58:13 +03:00
|
|
|
* Test if the element's visible state corresponds to its accessibility
|
|
|
|
* API visibility.
|
|
|
|
*
|
|
|
|
* @param {nsIAccessible} accessible
|
|
|
|
* Accessible object.
|
|
|
|
* @param {DOMElement|XULElement} element
|
|
|
|
* Element associated with |accessible|.
|
|
|
|
* @param {boolean} visible
|
|
|
|
* Visibility state of |element|.
|
|
|
|
*
|
|
|
|
* @throws ElementNotAccessibleError
|
|
|
|
* If |element|'s visibility state does not correspond to
|
|
|
|
* |accessible|'s.
|
2016-01-15 00:12:13 +03:00
|
|
|
*/
|
2016-08-05 13:43:40 +03:00
|
|
|
assertVisible(accessible, element, visible) {
|
2016-01-15 00:12:13 +03:00
|
|
|
let hiddenAccessibility = this.isHidden(accessible);
|
2016-03-03 16:58:13 +03:00
|
|
|
|
2016-01-15 00:12:13 +03:00
|
|
|
let message;
|
|
|
|
if (visible && hiddenAccessibility) {
|
2016-03-03 16:58:13 +03:00
|
|
|
message =
|
|
|
|
"Element is not currently visible via the accessibility API " +
|
|
|
|
"and may not be manipulated by it";
|
2016-01-15 00:12:13 +03:00
|
|
|
} else if (!visible && !hiddenAccessibility) {
|
2016-03-03 16:58:13 +03:00
|
|
|
message =
|
|
|
|
"Element is currently only visible via the accessibility API " +
|
|
|
|
"and can be manipulated by it";
|
2016-01-15 00:12:13 +03:00
|
|
|
}
|
|
|
|
this.error(message, element);
|
2016-03-03 16:58:13 +03:00
|
|
|
}
|
2016-01-15 00:12:13 +03:00
|
|
|
|
|
|
|
/**
|
2016-03-03 16:58:13 +03:00
|
|
|
* Test if the element's unavailable accessibility state matches the
|
|
|
|
* enabled state.
|
|
|
|
*
|
|
|
|
* @param {nsIAccessible} accessible
|
|
|
|
* Accessible object.
|
|
|
|
* @param {DOMElement|XULElement} element
|
|
|
|
* Element associated with |accessible|.
|
|
|
|
* @param {boolean} enabled
|
|
|
|
* Enabled state of |element|.
|
|
|
|
*
|
|
|
|
* @throws ElementNotAccessibleError
|
|
|
|
* If |element|'s enabled state does not match |accessible|'s.
|
2016-01-15 00:12:13 +03:00
|
|
|
*/
|
2016-08-05 13:43:40 +03:00
|
|
|
assertEnabled(accessible, element, enabled) {
|
2016-01-15 00:12:13 +03:00
|
|
|
if (!accessible) {
|
|
|
|
return;
|
|
|
|
}
|
2016-03-09 16:03:28 +03:00
|
|
|
|
2016-03-03 16:58:13 +03:00
|
|
|
let win = element.ownerGlobal;
|
|
|
|
let disabledAccessibility = this.matchState(
|
|
|
|
accessible,
|
|
|
|
accessibility.State.Unavailable
|
|
|
|
);
|
|
|
|
let explorable =
|
|
|
|
win.getComputedStyle(element).getPropertyValue("pointer-events") !==
|
|
|
|
"none";
|
|
|
|
|
|
|
|
let message;
|
2016-01-15 00:12:13 +03:00
|
|
|
if (!explorable && !disabledAccessibility) {
|
2016-03-03 16:58:13 +03:00
|
|
|
message =
|
|
|
|
"Element is enabled but is not explorable via the " +
|
|
|
|
"accessibility API";
|
2016-01-15 00:12:13 +03:00
|
|
|
} else if (enabled && disabledAccessibility) {
|
2016-03-03 16:58:13 +03:00
|
|
|
message = "Element is enabled but disabled via the accessibility API";
|
2016-01-15 00:12:13 +03:00
|
|
|
} else if (!enabled && !disabledAccessibility) {
|
2016-03-03 16:58:13 +03:00
|
|
|
message = "Element is disabled but enabled via the accessibility API";
|
2016-01-15 00:12:13 +03:00
|
|
|
}
|
|
|
|
this.error(message, element);
|
2016-03-03 16:58:13 +03:00
|
|
|
}
|
2016-01-15 00:12:13 +03:00
|
|
|
|
|
|
|
/**
|
2016-03-03 16:58:13 +03:00
|
|
|
* Test if it is possible to activate an element with the accessibility
|
|
|
|
* API.
|
|
|
|
*
|
|
|
|
* @param {nsIAccessible} accessible
|
|
|
|
* Accessible object.
|
|
|
|
* @param {DOMElement|XULElement} element
|
|
|
|
* Element associated with |accessible|.
|
|
|
|
*
|
|
|
|
* @throws ElementNotAccessibleError
|
|
|
|
* If it is impossible to activate |element| with |accessible|.
|
2016-01-15 00:12:13 +03:00
|
|
|
*/
|
2016-08-05 13:43:40 +03:00
|
|
|
assertActionable(accessible, element) {
|
2016-01-15 00:12:13 +03:00
|
|
|
if (!accessible) {
|
|
|
|
return;
|
|
|
|
}
|
2016-03-03 16:58:13 +03:00
|
|
|
|
2016-01-15 00:12:13 +03:00
|
|
|
let message;
|
|
|
|
if (!this.hasActionCount(accessible)) {
|
2016-03-03 16:58:13 +03:00
|
|
|
message = "Element does not support any accessible actions";
|
2016-01-15 00:12:13 +03:00
|
|
|
} else if (!this.isActionableRole(accessible)) {
|
2016-03-03 16:58:13 +03:00
|
|
|
message =
|
|
|
|
"Element does not have a correct accessibility role " +
|
|
|
|
"and may not be manipulated via the accessibility API";
|
2016-01-15 00:12:13 +03:00
|
|
|
} else if (!this.hasValidName(accessible)) {
|
2016-03-03 16:58:13 +03:00
|
|
|
message = "Element is missing an accessible name";
|
|
|
|
} else if (!this.matchState(accessible, accessibility.State.Focusable)) {
|
|
|
|
message = "Element is not focusable via the accessibility API";
|
2016-01-15 00:12:13 +03:00
|
|
|
}
|
2016-03-03 16:58:13 +03:00
|
|
|
|
2016-01-15 00:12:13 +03:00
|
|
|
this.error(message, element);
|
2016-03-03 16:58:13 +03:00
|
|
|
}
|
2016-01-15 00:12:13 +03:00
|
|
|
|
|
|
|
/**
|
2016-03-03 16:58:13 +03:00
|
|
|
* Test that an element's selected state corresponds to its
|
|
|
|
* accessibility API selected state.
|
|
|
|
*
|
|
|
|
* @param {nsIAccessible} accessible
|
|
|
|
* Accessible object.
|
|
|
|
* @param {DOMElement|XULElement}
|
|
|
|
* Element associated with |accessible|.
|
|
|
|
* @param {boolean} selected
|
|
|
|
* The |element|s selected state.
|
|
|
|
*
|
|
|
|
* @throws ElementNotAccessibleError
|
|
|
|
* If |element|'s selected state does not correspond to
|
|
|
|
* |accessible|'s.
|
2016-01-15 00:12:13 +03:00
|
|
|
*/
|
2016-08-05 13:43:40 +03:00
|
|
|
assertSelected(accessible, element, selected) {
|
2016-01-15 00:12:13 +03:00
|
|
|
if (!accessible) {
|
|
|
|
return;
|
|
|
|
}
|
2016-03-03 16:58:13 +03:00
|
|
|
|
|
|
|
// element is not selectable via the accessibility API
|
|
|
|
if (!this.matchState(accessible, accessibility.State.Selectable)) {
|
2016-01-15 00:12:13 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-06-30 02:40:24 +03:00
|
|
|
let selectedAccessibility = this.matchState(
|
|
|
|
accessible,
|
|
|
|
accessibility.State.Selected
|
|
|
|
);
|
2016-03-03 16:58:13 +03:00
|
|
|
|
2016-01-15 00:12:13 +03:00
|
|
|
let message;
|
|
|
|
if (selected && !selectedAccessibility) {
|
2016-03-03 16:58:13 +03:00
|
|
|
message =
|
|
|
|
"Element is selected but not selected via the accessibility API";
|
2016-01-15 00:12:13 +03:00
|
|
|
} else if (!selected && selectedAccessibility) {
|
2016-03-03 16:58:13 +03:00
|
|
|
message =
|
|
|
|
"Element is not selected but selected via the accessibility API";
|
2016-01-15 00:12:13 +03:00
|
|
|
}
|
|
|
|
this.error(message, element);
|
|
|
|
}
|
2016-03-03 16:58:13 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Throw an error if strict accessibility checks are enforced and log
|
|
|
|
* the error to the log.
|
|
|
|
*
|
|
|
|
* @param {string} message
|
|
|
|
* @param {DOMElement|XULElement} element
|
|
|
|
* Element that caused an error.
|
|
|
|
*
|
|
|
|
* @throws ElementNotAccessibleError
|
|
|
|
* If |strict| is true.
|
|
|
|
*/
|
|
|
|
error(message, element) {
|
2016-11-07 20:15:08 +03:00
|
|
|
if (!message || !this.strict) {
|
2016-03-03 16:58:13 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (element) {
|
|
|
|
let { id, tagName, className } = element;
|
|
|
|
message += `: id: ${id}, tagName: ${tagName}, className: ${className}`;
|
|
|
|
}
|
2016-11-07 20:15:08 +03:00
|
|
|
|
|
|
|
throw new ElementNotAccessibleError(message);
|
2016-03-03 16:58:13 +03:00
|
|
|
}
|
2016-01-15 00:12:13 +03:00
|
|
|
};
|