mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 21:01:08 +00:00
Backed out 2 changesets (bug 1828816) for wpt failures on roles.html . CLOSED TREE
Backed out changeset a7c266597175 (bug 1828816) Backed out changeset 5802edc7adc3 (bug 1828816)
This commit is contained in:
parent
7a03fa5861
commit
1a51e46de2
@ -92,6 +92,38 @@ accessibility.get = function(strict = false) {
|
||||
return new accessibility.Checks(!!strict);
|
||||
};
|
||||
|
||||
/**
|
||||
* Wait for the document accessibility state to be different from STATE_BUSY.
|
||||
*
|
||||
* @param {Document} doc
|
||||
* The document to wait for.
|
||||
* @returns {Promise}
|
||||
* A promise which resolves when the document's accessibility state is no
|
||||
* longer busy.
|
||||
*/
|
||||
function waitForDocumentAccessibility(doc) {
|
||||
const documentAccessible = accessibility.service.getAccessibleFor(doc);
|
||||
const state = {};
|
||||
documentAccessible.getState(state, {});
|
||||
if ((state.value & Ci.nsIAccessibleStates.STATE_BUSY) == 0) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
// Accessibility for the doc is busy, so wait for the state to change.
|
||||
return lazy.waitForObserverTopic("accessible-event", {
|
||||
checkFn: subject => {
|
||||
// If event type does not match expected type, skip the event.
|
||||
// If event's accessible does not match expected accessible,
|
||||
// skip the event.
|
||||
const event = subject.QueryInterface(Ci.nsIAccessibleEvent);
|
||||
return (
|
||||
event.eventType === Ci.nsIAccessibleEvent.EVENT_STATE_CHANGE &&
|
||||
event.accessible === documentAccessible
|
||||
);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the Accessible for the provided element.
|
||||
*
|
||||
@ -107,30 +139,8 @@ accessibility.getAccessible = async function(element) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const acc = accessibility.service.getAccessibleFor(element);
|
||||
if (acc) {
|
||||
return acc;
|
||||
}
|
||||
|
||||
// The Accessible doesn't exist yet. This can happen because a11y tree
|
||||
// mutations happen during refresh driver ticks. Wait for a11y events,
|
||||
// checking after each event to see if the Accessible exists yet and returning
|
||||
// it if it does. Stop waiting after a short timeout because the Accessible
|
||||
// might never be created and we want to report a failure without breaking
|
||||
// subsequent tests.
|
||||
try {
|
||||
await lazy.waitForObserverTopic("accessible-event", {
|
||||
checkFn: subject => {
|
||||
return !!accessibility.service.getAccessibleFor(element);
|
||||
},
|
||||
timeout: 100,
|
||||
});
|
||||
} catch (e) {
|
||||
// Don't treat a timeout as an error. We will most likely return null below.
|
||||
if (!(e instanceof lazy.error.TimeoutError)) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
// First, wait for accessibility to be ready for the element's document.
|
||||
await waitForDocumentAccessibility(element.ownerDocument);
|
||||
return accessibility.service.getAccessibleFor(element);
|
||||
};
|
||||
|
||||
|
@ -468,73 +468,32 @@ export function waitForMessage(
|
||||
* if the notification is the expected one, or false if it should be
|
||||
* ignored and listening should continue. If not specified, the first
|
||||
* notification for the specified topic resolves the returned promise.
|
||||
* @param {number=} options.timeout
|
||||
* Timeout duration in milliseconds, if provided.
|
||||
* If specified, then the returned promise will be rejected with
|
||||
* TimeoutError, if not already resolved, after this duration has elapsed.
|
||||
* If not specified, then no timeout is used. Defaults to null.
|
||||
*
|
||||
* @returns {Promise.<Array<string, object>>}
|
||||
* Promise which is either resolved to an array of ``subject``, and ``data``
|
||||
* from the observed notification, or rejected with TimeoutError after
|
||||
* options.timeout milliseconds if specified.
|
||||
*
|
||||
* @throws {TypeError}
|
||||
* @throws {RangeError}
|
||||
* Promise which resolves to an array of ``subject``, and ``data`` from
|
||||
* the observed notification.
|
||||
*/
|
||||
export function waitForObserverTopic(topic, options = {}) {
|
||||
const { checkFn = null, timeout = null } = options;
|
||||
export function waitForObserverTopic(topic, { checkFn = null } = {}) {
|
||||
if (typeof topic != "string") {
|
||||
throw new TypeError();
|
||||
}
|
||||
if (
|
||||
(checkFn != null && typeof checkFn != "function") ||
|
||||
(timeout !== null && typeof timeout != "number")
|
||||
) {
|
||||
if (checkFn != null && typeof checkFn != "function") {
|
||||
throw new TypeError();
|
||||
}
|
||||
if (timeout && (!Number.isInteger(timeout) || timeout < 0)) {
|
||||
throw new RangeError();
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
let timer;
|
||||
|
||||
function cleanUp() {
|
||||
Services.obs.removeObserver(observer, topic);
|
||||
timer?.cancel();
|
||||
}
|
||||
|
||||
function observer(subject, topic, data) {
|
||||
Services.obs.addObserver(function observer(subject, topic, data) {
|
||||
lazy.logger.trace(`Received observer notification ${topic}`);
|
||||
try {
|
||||
if (checkFn && !checkFn(subject, data)) {
|
||||
return;
|
||||
}
|
||||
cleanUp();
|
||||
Services.obs.removeObserver(observer, topic);
|
||||
resolve({ subject, data });
|
||||
} catch (ex) {
|
||||
cleanUp();
|
||||
Services.obs.removeObserver(observer, topic);
|
||||
reject(ex);
|
||||
}
|
||||
}
|
||||
|
||||
Services.obs.addObserver(observer, topic);
|
||||
|
||||
if (timeout !== null) {
|
||||
timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
|
||||
timer.init(
|
||||
() => {
|
||||
cleanUp();
|
||||
reject(
|
||||
new lazy.error.TimeoutError(
|
||||
`waitForObserverTopic timed out after ${timeout} ms`
|
||||
)
|
||||
);
|
||||
},
|
||||
timeout,
|
||||
TYPE_ONE_SHOT
|
||||
);
|
||||
}
|
||||
}, topic);
|
||||
});
|
||||
}
|
||||
|
@ -382,38 +382,3 @@ add_task(async function test_waitForObserverTopic_checkFnTypes() {
|
||||
equal(expected_data, result.data);
|
||||
}
|
||||
});
|
||||
|
||||
add_task(async function test_waitForObserverTopic_timeoutTypes() {
|
||||
for (let timeout of ["foo", true, [], {}]) {
|
||||
Assert.throws(
|
||||
() => waitForObserverTopic("message", { timeout }),
|
||||
/TypeError/
|
||||
);
|
||||
}
|
||||
for (let timeout of [1.2, -1]) {
|
||||
Assert.throws(
|
||||
() => waitForObserverTopic("message", { timeout }),
|
||||
/RangeError/
|
||||
);
|
||||
}
|
||||
for (let timeout of [null, undefined, 42]) {
|
||||
let data = { foo: "bar" };
|
||||
let sent = waitForObserverTopic("message", { timeout });
|
||||
Services.obs.notifyObservers(this, "message", data);
|
||||
let result = await sent;
|
||||
equal(this, result.subject);
|
||||
equal(data, result.data);
|
||||
}
|
||||
});
|
||||
|
||||
add_task(async function test_waitForObserverTopic_timeoutElapse() {
|
||||
try {
|
||||
await waitForObserverTopic("message", { timeout: 0 });
|
||||
ok(false, "Expected Timeout error not raised");
|
||||
} catch (e) {
|
||||
ok(
|
||||
e.message.includes("waitForObserverTopic timed out after"),
|
||||
"Expected error received"
|
||||
);
|
||||
}
|
||||
});
|
||||
|
@ -1,20 +1,167 @@
|
||||
[roles.html]
|
||||
[role: alertdialog]
|
||||
expected: [PASS, FAIL]
|
||||
|
||||
[role: application]
|
||||
expected: [PASS, FAIL]
|
||||
|
||||
[role: article]
|
||||
expected: [PASS, FAIL]
|
||||
|
||||
[role: banner]
|
||||
expected: [PASS, FAIL]
|
||||
|
||||
[role: button]
|
||||
expected: [PASS, FAIL]
|
||||
|
||||
[role: checkbox]
|
||||
expected: [PASS, FAIL]
|
||||
|
||||
[role: combobox]
|
||||
expected: [PASS, FAIL]
|
||||
|
||||
[role: complementary]
|
||||
expected: [PASS, FAIL]
|
||||
|
||||
[role: contentinfo]
|
||||
expected: [PASS, FAIL]
|
||||
|
||||
[role: definition]
|
||||
expected: FAIL
|
||||
bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1829028
|
||||
|
||||
[role: deletion]
|
||||
expected: [PASS, FAIL]
|
||||
|
||||
[role: document]
|
||||
expected: [PASS, FAIL]
|
||||
|
||||
[role: emphasis]
|
||||
expected: FAIL
|
||||
bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1732306
|
||||
|
||||
[role: feed]
|
||||
expected: [PASS, FAIL]
|
||||
|
||||
[role: generic]
|
||||
expected: [PASS, FAIL]
|
||||
|
||||
[role: group]
|
||||
expected: [PASS, FAIL]
|
||||
|
||||
[role: insertion]
|
||||
expected: [PASS, FAIL]
|
||||
|
||||
[role: log]
|
||||
expected: [PASS, FAIL]
|
||||
|
||||
[role: main]
|
||||
expected: [PASS, FAIL]
|
||||
|
||||
[role: marquee]
|
||||
expected: [PASS, FAIL]
|
||||
|
||||
[role: math]
|
||||
expected: [PASS, FAIL]
|
||||
|
||||
[role: navigation]
|
||||
expected: [PASS, FAIL]
|
||||
|
||||
[role: radio]
|
||||
expected: [PASS, FAIL]
|
||||
|
||||
[role: radiogroup]
|
||||
expected: [PASS, FAIL]
|
||||
|
||||
[role: search]
|
||||
expected: [PASS, FAIL]
|
||||
|
||||
[role: searchbox]
|
||||
expected: [PASS, FAIL]
|
||||
|
||||
[role: status]
|
||||
expected: [PASS, FAIL]
|
||||
|
||||
[role: strong]
|
||||
expected: FAIL
|
||||
bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1732306
|
||||
|
||||
[role: textbox]
|
||||
expected: [PASS, FAIL]
|
||||
|
||||
[role: time]
|
||||
expected: FAIL
|
||||
bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1732306
|
||||
|
||||
[role: timer]
|
||||
expected: [PASS, FAIL]
|
||||
|
||||
[role: blockquote]
|
||||
expected: [PASS, FAIL]
|
||||
|
||||
[role: caption]
|
||||
expected: [PASS, FAIL]
|
||||
|
||||
[role: code]
|
||||
expected: [PASS, FAIL]
|
||||
|
||||
[role: dialog]
|
||||
expected: [PASS, FAIL]
|
||||
|
||||
[role: figure]
|
||||
expected: [PASS, FAIL]
|
||||
|
||||
[role: form]
|
||||
expected: [PASS, FAIL]
|
||||
|
||||
[role: heading]
|
||||
expected: [PASS, FAIL]
|
||||
|
||||
[role: link]
|
||||
expected: [PASS, FAIL]
|
||||
|
||||
[role: meter]
|
||||
expected: [PASS, FAIL]
|
||||
|
||||
[role: note]
|
||||
expected: [PASS, FAIL]
|
||||
|
||||
[role: paragraph]
|
||||
expected: [PASS, FAIL]
|
||||
|
||||
[role: progressbar]
|
||||
expected: [PASS, FAIL]
|
||||
|
||||
[role: scrollbar]
|
||||
expected: [PASS, FAIL]
|
||||
|
||||
[role: separator]
|
||||
expected: [PASS, FAIL]
|
||||
|
||||
[role: slider]
|
||||
expected: [PASS, FAIL]
|
||||
|
||||
[role: spinbutton]
|
||||
expected: [PASS, FAIL]
|
||||
|
||||
[role: subscript]
|
||||
expected: [PASS, FAIL]
|
||||
|
||||
[role: suggestion]
|
||||
expected: [PASS, FAIL]
|
||||
|
||||
[role: superscript]
|
||||
expected: [PASS, FAIL]
|
||||
|
||||
[role: switch]
|
||||
expected: [PASS, FAIL]
|
||||
|
||||
[role: term]
|
||||
expected: FAIL
|
||||
bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1829028
|
||||
|
||||
[role: toolbar]
|
||||
expected: [PASS, FAIL]
|
||||
|
||||
[role: tooltip]
|
||||
expected: [PASS, FAIL]
|
||||
|
Loading…
Reference in New Issue
Block a user