Commit 05113764 authored by Anastasia Helfinstein's avatar Anastasia Helfinstein Committed by Commit Bot

[Switch Access] Add waitForPredicate to test base

Add a function to the Switch Access end-to-end test base to wait until
a tree change happens, after which a specified predicate function
return true.

This function is not yet used, but will be in a follow-up change.

AX-Relnotes: n/a.
Bug: None
Change-Id: I12802fc50cae80463f1b28adfd573abd0dacfa5b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2203641
Commit-Queue: Anastasia Helfinstein <anastasi@google.com>
Reviewed-by: default avatarKatie Dektar <katie@chromium.org>
Cr-Commit-Position: refs/heads/master@{#770349}
parent f2ad8be0
......@@ -113,6 +113,27 @@ SwitchAccessE2ETest.prototype = {
return this.findNodeMatchingPredicate(predicate, nodeString);
},
/**
* @param {function(): boolean} predicate The condition under which the
* callback should be fired.
* @param {function()} callback
*/
waitForPredicate(predicate, callback) {
if (predicate()) {
callback();
return;
}
const listener = () => {
if (predicate()) {
NavigationManager.desktopNode.removeEventListener(
'childrenChanged', listener, false /* capture */);
callback();
}
};
NavigationManager.desktopNode.addEventListener(
'childrenChanged', listener, false /* capture */);
},
/**
* From chromevox_next_e2e_test_base.js
* Gets the desktop from the automation API and Launches a new tab with
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment