Bug 1738032 part 6: browser_caching_states.js: Ignore state changes for states we aren't interested in. r=eeejay

For example, when disabling an HTML input, we get an event for SUPPORTS_AUTOCOMPLETION among others.
If we continue with the test after that state change and there hasn't been an ENABLED/UNAVAILABLE state change, the cache won't be up to date.
Unfortunately, we can't use untilCacheOk here because we don't do a cache push for state changes.

Differential Revision: https://phabricator.services.mozilla.com/D129643
This commit is contained in:
James Teh 2021-11-02 23:56:36 +00:00
Родитель 6deb1a13cb
Коммит eca2f19b0d
1 изменённых файлов: 17 добавлений и 1 удалений

Просмотреть файл

@ -127,8 +127,24 @@ const extraStateTests = [
async function runStateTests(browser, accDoc, id, tests) {
let acc = findAccessibleChildByID(accDoc, id);
for (let { desc, attrs, expected } of tests) {
const [expState, expExtState, absState, absExtState] = expected;
info(desc);
let onUpdate = waitForEvent(EVENT_STATE_CHANGE, id);
let onUpdate = waitForEvent(EVENT_STATE_CHANGE, evt => {
if (getAccessibleDOMNodeID(evt.accessible) != id) {
return false;
}
// Events can be fired for states other than the ones we're interested
// in. If this happens, the states we're expecting might not be exposed
// yet.
const scEvt = evt.QueryInterface(nsIAccessibleStateChangeEvent);
if (scEvt.isExtraState) {
if (scEvt.state & expExtState || scEvt.state & absExtState) {
return true;
}
return false;
}
return scEvt.state & expState || scEvt.state & absState;
});
for (let { attr, value } of attrs) {
await invokeSetAttribute(browser, id, attr, value);
}