VulpesOS/gaia/apps/verticalhome/test/marionette/lib/launch_icon.js
OverSu b38dea0597 Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
2026-09-30 23:13:03 +02:00

38 lines
1,019 B
JavaScript
Executable file

/* global module */
'use strict';
/**
Launches an icon (which may be a real app launch or download retry)
@param {Marionette.Element} element of particular icon.
*/
module.exports = function launchIcon(element) {
// XXX: work around focus issues by ensuring we clicked the thing
element.scriptWith(function(e) {
e.scrollIntoView(false);
e.__ensureClick__ = function() {
e.removeEventListener('click', e.__ensureClick__);
e.setAttribute('data-test-was-clicked', true);
};
e.addEventListener('click', e.__ensureClick__);
});
element.client.waitFor(function() {
// try to click it
element.tap();
return element.scriptWith(function(e) {
// if it was clicked clear the state if we want to run this again
if (e.getAttribute('data-test-was-clicked')) {
e.removeEventListener('click', e.__ensureClick__);
e.removeAttribute('data-test-was-clicked');
return true;
}
// otherwise try again
return false;
});
});
};