зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 4 changesets (bug 1541666, bug 1541446, bug 1540904, bug 1540601) for dt failures at browser_accessibility_node_audit.js
Backed out changeset 7bcd00bbcb71 (bug 1541666) Backed out changeset a27b2d203885 (bug 1540904) Backed out changeset 9f43419c7b40 (bug 1541446) Backed out changeset e3294a1be947 (bug 1540601)
This commit is contained in:
Родитель
ab80016442
Коммит
04da27ce4e
|
@ -108,14 +108,13 @@ class AccessibilityRow extends Component {
|
|||
}
|
||||
|
||||
updateAndScrollIntoViewIfNeeded() {
|
||||
const { dispatch, member: { object }, supports } = this.props;
|
||||
if (!gToolbox || !object.actorID) {
|
||||
return;
|
||||
const { dispatch, member, supports } = this.props;
|
||||
if (gToolbox) {
|
||||
dispatch(updateDetails(gToolbox.walker, member.object, supports));
|
||||
}
|
||||
|
||||
dispatch(updateDetails(gToolbox.walker, object, supports));
|
||||
this.scrollIntoView();
|
||||
window.emit(EVENTS.NEW_ACCESSIBLE_FRONT_SELECTED, object);
|
||||
window.emit(EVENTS.NEW_ACCESSIBLE_FRONT_SELECTED, member.object);
|
||||
}
|
||||
|
||||
flashValue() {
|
||||
|
|
|
@ -139,11 +139,9 @@ class Accessible extends Component {
|
|||
|
||||
update() {
|
||||
const { dispatch, accessible, supports } = this.props;
|
||||
if (!gToolbox || !accessible.actorID) {
|
||||
return;
|
||||
if (gToolbox) {
|
||||
dispatch(updateDetails(gToolbox.walker, accessible, supports));
|
||||
}
|
||||
|
||||
dispatch(updateDetails(gToolbox.walker, accessible, supports));
|
||||
}
|
||||
|
||||
setExpanded(item, isExpanded) {
|
||||
|
|
|
@ -14,8 +14,6 @@ const ColorContrastCheck =
|
|||
createFactory(require("./ColorContrastAccessibility").ColorContrastCheck);
|
||||
const { L10N } = require("../utils/l10n");
|
||||
|
||||
const { accessibility: { AUDIT_TYPE } } = require("devtools/shared/constants");
|
||||
|
||||
function EmptyChecks() {
|
||||
return (
|
||||
div({
|
||||
|
@ -35,7 +33,7 @@ class Checks extends Component {
|
|||
};
|
||||
}
|
||||
|
||||
[AUDIT_TYPE.CONTRAST](contrastRatio) {
|
||||
contrastRatio(contrastRatio) {
|
||||
return ColorContrastCheck(contrastRatio);
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ class Provider {
|
|||
* @returns {Array} arraof of accessible children.
|
||||
*/
|
||||
getChildren(accessible) {
|
||||
if (!accessible || !accessible.actorID || accessible.childCount === 0) {
|
||||
if (!accessible || !accessible.actor || accessible.childCount === 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
|
|
|
@ -3,12 +3,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
"use strict";
|
||||
|
||||
const {
|
||||
FETCH_CHILDREN,
|
||||
HIGHLIGHT,
|
||||
RESET,
|
||||
SELECT,
|
||||
} = require("../constants");
|
||||
const { FETCH_CHILDREN, RESET, SELECT, HIGHLIGHT } = require("../constants");
|
||||
|
||||
/**
|
||||
* Initial state definition
|
||||
|
@ -34,10 +29,6 @@ function accessibles(state = getInitialState(), action) {
|
|||
}
|
||||
}
|
||||
|
||||
function getActorID(accessible) {
|
||||
return accessible.actorID || accessible._form.actor;
|
||||
}
|
||||
|
||||
/**
|
||||
* If accessible is cached recursively remove all its children and remove itself
|
||||
* from cache.
|
||||
|
@ -46,8 +37,7 @@ function getActorID(accessible) {
|
|||
* @param {Object} accessible Accessible object to remove from cache.
|
||||
*/
|
||||
function cleanupChild(cache, accessible) {
|
||||
const actorID = getActorID(accessible);
|
||||
const cached = cache.get(actorID);
|
||||
const cached = cache.get(accessible.actorID);
|
||||
if (!cached) {
|
||||
return;
|
||||
}
|
||||
|
@ -56,7 +46,7 @@ function cleanupChild(cache, accessible) {
|
|||
cleanupChild(cache, child);
|
||||
}
|
||||
|
||||
cache.delete(actorID);
|
||||
cache.delete(accessible.actorID);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -68,7 +58,7 @@ function cleanupChild(cache, accessible) {
|
|||
* @param {Object} accessible Accessible object to test for staleness.
|
||||
*/
|
||||
function staleChildren(cache, accessible) {
|
||||
const cached = cache.get(getActorID(accessible));
|
||||
const cached = cache.get(accessible.actorID);
|
||||
if (!cached) {
|
||||
return false;
|
||||
}
|
||||
|
@ -77,7 +67,7 @@ function staleChildren(cache, accessible) {
|
|||
}
|
||||
|
||||
function updateChildrenCache(cache, accessible, children) {
|
||||
const actorID = getActorID(accessible);
|
||||
const { actorID } = accessible;
|
||||
|
||||
if (cache.has(actorID)) {
|
||||
const cached = cache.get(actorID);
|
||||
|
@ -98,13 +88,6 @@ function updateChildrenCache(cache, accessible, children) {
|
|||
return cache;
|
||||
}
|
||||
|
||||
function updateAncestry(cache, ancestry) {
|
||||
ancestry.forEach(({ accessible, children }) =>
|
||||
updateChildrenCache(cache, accessible, children));
|
||||
|
||||
return cache;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles fetching of accessible children.
|
||||
* @param {Map} cache Previous state maintaining a cache of previously
|
||||
|
@ -113,29 +96,29 @@ function updateAncestry(cache, ancestry) {
|
|||
* @return {Object} updated state
|
||||
*/
|
||||
function onReceiveChildren(cache, action) {
|
||||
const { error, accessible, response: children } = action;
|
||||
if (!error) {
|
||||
return updateChildrenCache(new Map(cache), accessible, children);
|
||||
const { accessible, response: children, error } = action;
|
||||
|
||||
if (error) {
|
||||
console.warn("Error fetching children", accessible, error);
|
||||
return cache;
|
||||
}
|
||||
|
||||
if (accessible.actorID) {
|
||||
console.warn(`Error fetching children: `, accessible, error);
|
||||
return updateChildrenCache(new Map(cache), accessible, children);
|
||||
}
|
||||
|
||||
function onReceiveAncestry(cache, action) {
|
||||
const { accessible: acc, response: ancestry, error } = action;
|
||||
|
||||
if (error) {
|
||||
console.warn("Error fetching ancestry", acc, error);
|
||||
return cache;
|
||||
}
|
||||
|
||||
const newCache = new Map(cache);
|
||||
cleanupChild(newCache, accessible);
|
||||
ancestry.forEach(({ accessible, children }) =>
|
||||
updateChildrenCache(newCache, accessible, children));
|
||||
|
||||
return newCache;
|
||||
}
|
||||
|
||||
function onReceiveAncestry(cache, action) {
|
||||
const { error, response: ancestry } = action;
|
||||
if (error) {
|
||||
console.warn(`Error fetching ancestry: `, error);
|
||||
return cache;
|
||||
}
|
||||
|
||||
return updateAncestry(new Map(cache), ancestry);
|
||||
}
|
||||
|
||||
exports.accessibles = accessibles;
|
||||
|
|
|
@ -35,11 +35,8 @@ function details(state = getInitialState(), action) {
|
|||
function onUpdateDetails(state, action) {
|
||||
const { accessible, response, error } = action;
|
||||
if (error) {
|
||||
if (accessible.actorID) {
|
||||
console.warn(`Error fetching accessible details: `, accessible, error);
|
||||
}
|
||||
|
||||
return getInitialState();
|
||||
console.warn("Error fetching DOMNode for accessible", accessible, error);
|
||||
return state;
|
||||
}
|
||||
|
||||
const [ DOMNode, relationObjects, audit ] = response;
|
||||
|
|
|
@ -27,7 +27,7 @@ const TEST_URI = `<html>
|
|||
const tests = [{
|
||||
desc: "Test the initial accessibility audit state.",
|
||||
expected: {
|
||||
audit: { CONTRAST: null },
|
||||
audit: { contrastRatio: null },
|
||||
},
|
||||
}, {
|
||||
desc: "Check accessible representing text node in red.",
|
||||
|
@ -38,7 +38,7 @@ const tests = [{
|
|||
},
|
||||
expected: {
|
||||
audit: {
|
||||
"CONTRAST": {
|
||||
"contrastRatio": {
|
||||
"value": 4.00,
|
||||
"color": [255, 0, 0, 1],
|
||||
"backgroundColor": [255, 255, 255, 1],
|
||||
|
@ -54,7 +54,7 @@ const tests = [{
|
|||
},
|
||||
expected: {
|
||||
audit: {
|
||||
"CONTRAST": {
|
||||
"contrastRatio": {
|
||||
"value": 8.59,
|
||||
"color": [0, 0, 255, 1],
|
||||
"backgroundColor": [255, 255, 255, 1],
|
||||
|
|
|
@ -39,4 +39,3 @@ support-files =
|
|||
[test_tree_15.html]
|
||||
[test_tree_16.html]
|
||||
[test_tree-view_01.html]
|
||||
[test_tree-view_02.html]
|
||||
|
|
|
@ -1,135 +0,0 @@
|
|||
<!-- 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/. -->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
Test that TreeView component filtering works with keyboard.
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>TreeView component filtering keyboard test</title>
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
|
||||
<link rel="stylesheet" href="chrome://devtools/skin/light-theme.css" type="text/css">
|
||||
<link rel="stylesheet" href="resource://devtools/client/shared/components/tree/TreeView.css" type="text/css">
|
||||
<style>
|
||||
.treeRow.hide {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script src="head.js" type="application/javascript"></script>
|
||||
<script type="application/javascript">
|
||||
|
||||
"use strict";
|
||||
|
||||
window.onload = function() {
|
||||
try {
|
||||
const React = browserRequire("devtools/client/shared/vendor/react");
|
||||
const {
|
||||
Simulate,
|
||||
findRenderedDOMComponentWithClass,
|
||||
scryRenderedDOMComponentsWithClass,
|
||||
} = browserRequire("devtools/client/shared/vendor/react-dom-test-utils");
|
||||
const TreeView =
|
||||
browserRequire("devtools/client/shared/components/tree/TreeView");
|
||||
|
||||
function testKeyboardInteraction(tree, treeViewEl, rows) {
|
||||
// Expected tree when filtered (C is filtered)
|
||||
//
|
||||
// A
|
||||
// |-- B
|
||||
// `-- D
|
||||
is(window.getComputedStyle(rows[1]).getPropertyValue("display"), "none",
|
||||
"Row C must be hidden by default.");
|
||||
|
||||
const tests = [{
|
||||
name: "Selected row must be set to the first row on initial focus. " +
|
||||
"Keyboard focus must be set on TreeView's conatiner.",
|
||||
action: () => {
|
||||
Simulate.click(rows[0]);
|
||||
},
|
||||
activeElement: treeViewEl,
|
||||
state: { selected: "/B" },
|
||||
}, {
|
||||
name: "Selecting next row must skip hidden row on ArrowDown.",
|
||||
event: {
|
||||
type: "keyDown",
|
||||
el: treeViewEl,
|
||||
options: { key: "ArrowDown" },
|
||||
},
|
||||
state: { selected: "/D" },
|
||||
}, {
|
||||
name: "Selecting previous row must be skip hidden row on ArrowUp.",
|
||||
event: {
|
||||
type: "keyDown",
|
||||
el: treeViewEl,
|
||||
options: { key: "ArrowUp" },
|
||||
},
|
||||
state: { selected: "/B" },
|
||||
}];
|
||||
|
||||
for (const test of tests) {
|
||||
const { action, condition, event, state, name } = test;
|
||||
|
||||
info(name);
|
||||
if (event) {
|
||||
const { type, options, el } = event;
|
||||
Simulate[type](el, options);
|
||||
} else if (action) {
|
||||
action();
|
||||
}
|
||||
|
||||
for (let key in state) {
|
||||
is(tree.state[key], state[key], `${key} state is correct.`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
info("Test hiding rows via decorator.");
|
||||
const props = {
|
||||
...TEST_TREE_VIEW_INTERFACE,
|
||||
decorator: {
|
||||
getRowClass: ({ label }) => {
|
||||
if (label === "C") {
|
||||
return ["hide"];
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
let treeView = React.createElement(TreeView, props);
|
||||
let tree = ReactDOM.render(treeView, document.body);
|
||||
let treeViewEl = findRenderedDOMComponentWithClass(tree, "treeTable");
|
||||
let rows = scryRenderedDOMComponentsWithClass(tree, "treeRow");
|
||||
|
||||
testKeyboardInteraction(tree, treeViewEl, rows);
|
||||
|
||||
// Remove TreeView component.
|
||||
ReactDOM.unmountComponentAtNode(document.body);
|
||||
|
||||
info("Test hiding rows via onFilter.");
|
||||
props.decorator = null;
|
||||
props.onFilter = ({ label }) => {
|
||||
console.log(`onFILTER ${label !== "C"}`)
|
||||
return label !== "C";
|
||||
};
|
||||
treeView = React.createElement(TreeView, props);
|
||||
tree = ReactDOM.render(treeView, document.body);
|
||||
treeViewEl = findRenderedDOMComponentWithClass(tree, "treeTable");
|
||||
rows = scryRenderedDOMComponentsWithClass(tree, "treeRow");
|
||||
|
||||
testKeyboardInteraction(tree, treeViewEl, rows);
|
||||
} catch (e) {
|
||||
ok(false, "Got an error: " + DevToolsUtils.safeErrorString(e));
|
||||
} finally {
|
||||
SimpleTest.finish();
|
||||
}
|
||||
};
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
|
@ -546,20 +546,7 @@ define(function(require, exports, module) {
|
|||
member: member,
|
||||
columns: this.state.columns,
|
||||
id: member.path,
|
||||
ref: row => {
|
||||
if (!row) {
|
||||
return;
|
||||
}
|
||||
|
||||
const rowEl = findDOMNode(row);
|
||||
if (!rowEl || !rowEl.offsetParent) {
|
||||
// offsetParent returns null when the element has style.display
|
||||
// set to none (done by TreeView filtering).
|
||||
return;
|
||||
}
|
||||
|
||||
this.rows.push(row);
|
||||
},
|
||||
ref: row => row && this.rows.push(row),
|
||||
onClick: this.onClickRow.bind(this, member.path),
|
||||
onContextMenu: this.onContextMenu.bind(this, member),
|
||||
});
|
||||
|
|
|
@ -7,12 +7,10 @@
|
|||
const { Ci, Cu } = require("chrome");
|
||||
const { Actor, ActorClassWithSpec } = require("devtools/shared/protocol");
|
||||
const { accessibleSpec } = require("devtools/shared/specs/accessibility");
|
||||
const { accessibility: { AUDIT_TYPE } } = require("devtools/shared/constants");
|
||||
|
||||
loader.lazyRequireGetter(this, "getContrastRatioFor", "devtools/server/actors/accessibility/contrast", true);
|
||||
loader.lazyRequireGetter(this, "isDefunct", "devtools/server/actors/utils/accessibility", true);
|
||||
loader.lazyRequireGetter(this, "findCssSelector", "devtools/shared/inspector/css-logic", true);
|
||||
loader.lazyRequireGetter(this, "events", "devtools/shared/event-emitter");
|
||||
|
||||
const RELATIONS_TO_IGNORE = new Set([
|
||||
Ci.nsIAccessibleRelation.RELATION_CONTAINING_APPLICATION,
|
||||
|
@ -157,10 +155,6 @@ const AccessibleActor = ActorClassWithSpec(accessibleSpec, {
|
|||
this.rawAccessible = null;
|
||||
},
|
||||
|
||||
get isDestroyed() {
|
||||
return this.actorID == null;
|
||||
},
|
||||
|
||||
get role() {
|
||||
if (this.isDefunct) {
|
||||
return null;
|
||||
|
@ -375,7 +369,6 @@ const AccessibleActor = ActorClassWithSpec(accessibleSpec, {
|
|||
states: this.states,
|
||||
actions: this.actions,
|
||||
attributes: this.attributes,
|
||||
checks: this._lastAudit,
|
||||
};
|
||||
},
|
||||
|
||||
|
@ -395,16 +388,13 @@ const AccessibleActor = ActorClassWithSpec(accessibleSpec, {
|
|||
|
||||
const { DOMNode: rawNode } = this.rawAccessible;
|
||||
const win = rawNode.ownerGlobal;
|
||||
// Keep the reference to the walker actor in case the actor gets destroyed
|
||||
// during the colour contrast ratio calculation.
|
||||
const { walker } = this;
|
||||
walker.clearStyles(win);
|
||||
this.walker.clearStyles(win);
|
||||
const contrastRatio = await getContrastRatioFor(rawNode.parentNode, {
|
||||
bounds: this.bounds,
|
||||
win,
|
||||
});
|
||||
|
||||
walker.restoreStyles(win);
|
||||
this.walker.restoreStyles(win);
|
||||
|
||||
return contrastRatio;
|
||||
},
|
||||
|
@ -415,7 +405,7 @@ const AccessibleActor = ActorClassWithSpec(accessibleSpec, {
|
|||
* @return {Object|null}
|
||||
* Audit results for the accessible object.
|
||||
*/
|
||||
audit() {
|
||||
async audit() {
|
||||
if (this._auditing) {
|
||||
return this._auditing;
|
||||
}
|
||||
|
@ -428,23 +418,12 @@ const AccessibleActor = ActorClassWithSpec(accessibleSpec, {
|
|||
]).then(([
|
||||
contrastRatio,
|
||||
]) => {
|
||||
let audit = null;
|
||||
if (!this.isDefunct && !this.isDestroyed) {
|
||||
audit = {
|
||||
[AUDIT_TYPE.CONTRAST]: contrastRatio,
|
||||
};
|
||||
this._lastAudit = audit;
|
||||
events.emit(this, "audited", audit);
|
||||
}
|
||||
const audit = this.isDefunct ? null : {
|
||||
contrastRatio,
|
||||
};
|
||||
|
||||
return audit;
|
||||
}).catch(error => {
|
||||
if (!this.isDefunct && !this.isDestroyed) {
|
||||
throw error;
|
||||
}
|
||||
return null;
|
||||
}).finally(() => {
|
||||
this._auditing = null;
|
||||
return audit;
|
||||
});
|
||||
|
||||
return this._auditing;
|
||||
|
|
|
@ -122,27 +122,6 @@ function isStale(accessible) {
|
|||
return !!(extraState.value & Ci.nsIAccessibleStates.EXT_STATE_STALE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get accessibility audit starting with the passed accessible object as a root.
|
||||
*
|
||||
* @param {Object} acc
|
||||
* AccessibileActor to be used as the root for the audit.
|
||||
* @param {Map} report
|
||||
* An accumulator map to be used to store audit information.
|
||||
*/
|
||||
function getAudit(acc, report) {
|
||||
if (acc.isDefunct) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Audit returns a promise, save the actual value in the report.
|
||||
report.set(acc, acc.audit().then(result => report.set(acc, result)));
|
||||
|
||||
for (const child of acc.children()) {
|
||||
getAudit(child, report);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The AccessibleWalkerActor stores a cache of AccessibleActors that represent
|
||||
* accessible objects in a given document.
|
||||
|
@ -388,30 +367,6 @@ const AccessibleWalkerActor = ActorClassWithSpec(accessibleWalkerSpec, {
|
|||
{ accessible: parent, children: parent.children() }));
|
||||
},
|
||||
|
||||
/**
|
||||
* Run accessibility audit and return relevant ancestries for AccessibleActors
|
||||
* that have non-empty audit checks.
|
||||
*
|
||||
* @return {Promise}
|
||||
* A promise that resolves when the audit is complete and all relevant
|
||||
* ancestries are calculated.
|
||||
*/
|
||||
async audit() {
|
||||
const doc = await this.getDocument();
|
||||
const report = new Map();
|
||||
getAudit(doc, report);
|
||||
await Promise.all(report.values());
|
||||
|
||||
const ancestries = [];
|
||||
for (const [acc, audit] of report.entries()) {
|
||||
if (audit && Object.values(audit).filter(check => check != null).length > 0) {
|
||||
ancestries.push(this.getAncestry(acc));
|
||||
}
|
||||
}
|
||||
|
||||
return Promise.all(ancestries);
|
||||
},
|
||||
|
||||
onHighlighterEvent: function(data) {
|
||||
this.emit("highlighter-event", data);
|
||||
},
|
||||
|
|
|
@ -13,8 +13,6 @@ const STRINGS_URI = "devtools/shared/locales/accessibility.properties";
|
|||
loader.lazyRequireGetter(this, "LocalizationHelper", "devtools/shared/l10n", true);
|
||||
DevToolsUtils.defineLazyGetter(this, "L10N", () => new LocalizationHelper(STRINGS_URI));
|
||||
|
||||
const { accessibility: { AUDIT_TYPE } } = require("devtools/shared/constants");
|
||||
|
||||
// Max string length for truncating accessible name values.
|
||||
const MAX_STRING_LENGTH = 50;
|
||||
|
||||
|
@ -544,7 +542,7 @@ class ContrastRatio extends AuditReport {
|
|||
* True if the contrast ratio markup was updated correctly and infobar audit
|
||||
* block should be visible.
|
||||
*/
|
||||
update({ [AUDIT_TYPE.CONTRAST]: contrastRatio }) {
|
||||
update({ contrastRatio }) {
|
||||
const els = {};
|
||||
for (const key of ["label", "min", "max", "error", "separator"]) {
|
||||
const el = els[key] = this.getElement(`contrast-ratio-${key}`);
|
||||
|
|
|
@ -42,12 +42,10 @@ skip-if = (os == 'win' && processor == 'aarch64') # bug 1533184
|
|||
[browser_accessibility_infobar_show.js]
|
||||
[browser_accessibility_node.js]
|
||||
skip-if = (os == 'win' && processor == 'aarch64') # bug 1533184
|
||||
[browser_accessibility_node_audit.js]
|
||||
[browser_accessibility_node_events.js]
|
||||
skip-if = (os == 'win' && processor == 'aarch64') # bug 1533184
|
||||
[browser_accessibility_simple.js]
|
||||
skip-if = (os == 'win' && processor == 'aarch64') # bug 1533184
|
||||
[browser_accessibility_walker_audit.js]
|
||||
[browser_accessibility_walker.js]
|
||||
skip-if = (os == 'win' && processor == 'aarch64') # bug 1533487
|
||||
[browser_actor_error.js]
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
/* 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";
|
||||
|
||||
/**
|
||||
* Checks functionality around audit for the AccessibleActor. This includes
|
||||
* tests for the return value when calling the audit method, payload of the
|
||||
* corresponding event as well as the AccesibleFront state being up to date.
|
||||
*/
|
||||
|
||||
add_task(async function() {
|
||||
const {target, walker, accessibility} =
|
||||
await initAccessibilityFrontForUrl(MAIN_DOMAIN + "doc_accessibility_infobar.html");
|
||||
|
||||
const a11yWalker = await accessibility.getWalker();
|
||||
await accessibility.enable();
|
||||
const buttonNode = await walker.querySelector(walker.rootNode, "#button");
|
||||
const buttonFront = await a11yWalker.getAccessibleFor(buttonNode);
|
||||
const [textLeafNode] = await buttonFront.children();
|
||||
|
||||
const onAudited = textLeafNode.once("audited");
|
||||
const audit = await textLeafNode.audit();
|
||||
const auditFromEvent = await onAudited;
|
||||
|
||||
const expectedAudit = {
|
||||
"CONTRAST": {
|
||||
"value": 21,
|
||||
"color": [0, 0, 0, 1],
|
||||
"backgroundColor": [255, 255, 255, 1],
|
||||
"isLargeText": false,
|
||||
},
|
||||
};
|
||||
|
||||
Assert.deepEqual(audit, expectedAudit, "Audit results are correct.");
|
||||
Assert.deepEqual(textLeafNode.checks, expectedAudit, "Checks are correct.");
|
||||
Assert.deepEqual(auditFromEvent, expectedAudit,
|
||||
"Audit results from event are correct.");
|
||||
|
||||
await accessibility.disable();
|
||||
await waitForA11yShutdown();
|
||||
await target.destroy();
|
||||
gBrowser.removeCurrentTab();
|
||||
});
|
|
@ -1,162 +0,0 @@
|
|||
/* 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";
|
||||
|
||||
// Checks for the AccessibleWalkerActor audit.
|
||||
add_task(async function() {
|
||||
const {target, accessibility} =
|
||||
await initAccessibilityFrontForUrl(MAIN_DOMAIN + "doc_accessibility_infobar.html");
|
||||
|
||||
const accessibles = [{
|
||||
name: "",
|
||||
role: "document",
|
||||
value: "",
|
||||
description: "",
|
||||
keyboardShortcut: "",
|
||||
childCount: 2,
|
||||
domNodeType: 9,
|
||||
indexInParent: 0,
|
||||
states: [
|
||||
"focused", "readonly", "focusable", "active", "opaque", "enabled", "sensitive",
|
||||
],
|
||||
actions: [],
|
||||
attributes: {
|
||||
display: "block",
|
||||
"explicit-name": "true",
|
||||
"margin-bottom": "8px",
|
||||
"margin-left": "8px",
|
||||
"margin-right": "8px",
|
||||
"margin-top": "8px",
|
||||
tag: "body",
|
||||
"text-align": "start",
|
||||
"text-indent": "0px",
|
||||
},
|
||||
checks: {
|
||||
"CONTRAST": null,
|
||||
},
|
||||
}, {
|
||||
name: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do " +
|
||||
"eiusmod tempor incididunt ut labore et dolore magna aliqua.",
|
||||
role: "heading",
|
||||
value: "",
|
||||
description: "",
|
||||
keyboardShortcut: "",
|
||||
childCount: 1,
|
||||
domNodeType: 1,
|
||||
indexInParent: 0,
|
||||
states: [ "selectable text", "opaque", "enabled", "sensitive" ],
|
||||
actions: [],
|
||||
attributes: {
|
||||
display: "block",
|
||||
formatting: "block",
|
||||
id: "h1",
|
||||
level: "1",
|
||||
"margin-bottom": "21.4333px",
|
||||
"margin-left": "0px",
|
||||
"margin-right": "0px",
|
||||
"margin-top": "21.4333px",
|
||||
tag: "h1",
|
||||
"text-align": "start",
|
||||
"text-indent": "0px",
|
||||
},
|
||||
checks: {
|
||||
"CONTRAST": null,
|
||||
},
|
||||
}, {
|
||||
name: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do " +
|
||||
"eiusmod tempor incididunt ut labore et dolore magna aliqua.",
|
||||
role: "text leaf",
|
||||
value: "",
|
||||
description: "",
|
||||
keyboardShortcut: "",
|
||||
childCount: 0,
|
||||
domNodeType: 3,
|
||||
indexInParent: 0,
|
||||
states: [ "opaque", "enabled", "sensitive" ],
|
||||
actions: [],
|
||||
attributes: { "explicit-name": "true" },
|
||||
checks: {
|
||||
"CONTRAST": {
|
||||
"value": 21,
|
||||
"color": [0, 0, 0, 1],
|
||||
"backgroundColor": [255, 255, 255, 1],
|
||||
"isLargeText": true,
|
||||
},
|
||||
},
|
||||
}, {
|
||||
name: "Accessible Button",
|
||||
role: "pushbutton",
|
||||
value: "",
|
||||
description: "",
|
||||
keyboardShortcut: "",
|
||||
childCount: 1,
|
||||
domNodeType: 1,
|
||||
indexInParent: 1,
|
||||
states: [ "focusable", "selectable text", "opaque", "enabled", "sensitive" ],
|
||||
actions: [ "Press" ],
|
||||
attributes: {
|
||||
display: "inline-block",
|
||||
id: "button",
|
||||
"margin-bottom": "0px",
|
||||
"margin-left": "0px",
|
||||
"margin-right": "0px",
|
||||
"margin-top": "0px",
|
||||
tag: "button",
|
||||
"text-align": "center",
|
||||
"text-indent": "0px",
|
||||
},
|
||||
checks: {
|
||||
"CONTRAST": null,
|
||||
},
|
||||
}, {
|
||||
name: "Accessible Button",
|
||||
role: "text leaf",
|
||||
value: "",
|
||||
description: "",
|
||||
keyboardShortcut: "",
|
||||
childCount: 0,
|
||||
domNodeType: 3,
|
||||
indexInParent: 0,
|
||||
states: [ "opaque", "enabled", "sensitive" ],
|
||||
actions: [],
|
||||
attributes: { "explicit-name": "true" },
|
||||
checks: {
|
||||
"CONTRAST": {
|
||||
"value": 21,
|
||||
"color": [0, 0, 0, 1],
|
||||
"backgroundColor": [255, 255, 255, 1],
|
||||
"isLargeText": false,
|
||||
},
|
||||
},
|
||||
}];
|
||||
|
||||
function findAccessible(name, role) {
|
||||
return accessibles.find(accessible =>
|
||||
accessible.name === name && accessible.role === role);
|
||||
}
|
||||
|
||||
const a11yWalker = await accessibility.getWalker();
|
||||
ok(a11yWalker, "The AccessibleWalkerFront was returned");
|
||||
await accessibility.enable();
|
||||
|
||||
info("Checking AccessibleWalker audit functionality");
|
||||
const ancestries = await a11yWalker.audit();
|
||||
|
||||
for (const ancestry of ancestries) {
|
||||
for (const { accessible, children } of ancestry) {
|
||||
checkA11yFront(accessible,
|
||||
findAccessible(accessibles.name, accessibles.role));
|
||||
for (const child of children) {
|
||||
checkA11yFront(child,
|
||||
findAccessible(child.name, child.role));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
await accessibility.disable();
|
||||
await waitForA11yShutdown();
|
||||
await target.destroy();
|
||||
gBrowser.removeCurrentTab();
|
||||
});
|
|
@ -272,7 +272,7 @@ function checkA11yFront(front, expected, expectedFront) {
|
|||
}
|
||||
|
||||
for (const key in expected) {
|
||||
if (["actions", "states", "attributes", "checks"].includes(key)) {
|
||||
if (["actions", "states", "attributes"].includes(key)) {
|
||||
SimpleTest.isDeeply(front[key], expected[key],
|
||||
`Accessible Front has correct ${key}`);
|
||||
} else {
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
/* 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";
|
||||
|
||||
/**
|
||||
* Constants used in various panels, shared between client and the server.
|
||||
*/
|
||||
|
||||
/* Accessibility Panel ====================================================== */
|
||||
|
||||
exports.accessibility = {
|
||||
// List of audit types.
|
||||
AUDIT_TYPE: {
|
||||
CONTRAST: "CONTRAST",
|
||||
},
|
||||
};
|
|
@ -18,7 +18,6 @@ class AccessibleFront extends FrontClassWithSpec(accessibleSpec) {
|
|||
constructor(client) {
|
||||
super(client);
|
||||
|
||||
this.before("audited", this.audited.bind(this));
|
||||
this.before("name-change", this.nameChange.bind(this));
|
||||
this.before("value-change", this.valueChange.bind(this));
|
||||
this.before("description-change", this.descriptionChange.bind(this));
|
||||
|
@ -79,10 +78,6 @@ class AccessibleFront extends FrontClassWithSpec(accessibleSpec) {
|
|||
return this._form.attributes;
|
||||
}
|
||||
|
||||
get checks() {
|
||||
return this._form.checks;
|
||||
}
|
||||
|
||||
form(form) {
|
||||
this.actorID = form.actor;
|
||||
this._form = form;
|
||||
|
@ -141,10 +136,6 @@ class AccessibleFront extends FrontClassWithSpec(accessibleSpec) {
|
|||
attributesChange(attributes) {
|
||||
this._form.attributes = attributes;
|
||||
}
|
||||
|
||||
audited(checks) {
|
||||
this._form.checks = checks;
|
||||
}
|
||||
}
|
||||
|
||||
class AccessibleWalkerFront extends FrontClassWithSpec(accessibleWalkerSpec) {
|
||||
|
|
|
@ -47,7 +47,6 @@ DevToolsModules(
|
|||
'async-utils.js',
|
||||
'base-loader.js',
|
||||
'builtin-modules.js',
|
||||
'constants.js',
|
||||
'content-observer.js',
|
||||
'debounce.js',
|
||||
'defer.js',
|
||||
|
|
|
@ -77,10 +77,6 @@ const accessibleSpec = generateActorSpec({
|
|||
type: "indexInParentChange",
|
||||
indexInParent: Arg(0, "number"),
|
||||
},
|
||||
"audited": {
|
||||
type: "audited",
|
||||
audit: Arg(0, "nullable:json"),
|
||||
},
|
||||
},
|
||||
|
||||
methods: {
|
||||
|
@ -162,12 +158,6 @@ const accessibleWalkerSpec = generateActorSpec({
|
|||
ancestry: RetVal("array:accessibleWithChildren"),
|
||||
},
|
||||
},
|
||||
audit: {
|
||||
request: {},
|
||||
response: {
|
||||
audit: RetVal("array:array:accessibleWithChildren"),
|
||||
},
|
||||
},
|
||||
highlightAccessible: {
|
||||
request: {
|
||||
accessible: Arg(0, "accessible"),
|
||||
|
|
Загрузка…
Ссылка в новой задаче