Bug 1321516 - Skip in-view checks for XUL elements
This skips the in-view checks for chrome XUL elements, and also makes
the code more readable by reducing the number of if-conditions by making
the XUL element clicking implementation a separate function.
MozReview-Commit-ID: 5UAQfoGCzFQ
--- a/testing/marionette/interaction.js
+++ b/testing/marionette/interaction.js
@@ -109,27 +109,35 @@ this.interaction = {};
* in |specCompat| mode.
* @throws {ElementNotAccessibleError}
* If |strict| is true and element is not accessible.
* @throws {InvalidElementStateError}
* If |el| is not enabled.
*/
interaction.clickElement = function* (el, strict = false) {
const a11y = accessibility.get(strict);
+
+ if (element.isXULElement(el)) {
+ yield chromeClick(el, a11y);
+ } else {
+ yield contentClick(el, a11y);
+ }
+};
+
+function* contentClick (el, a11y) {
const win = getWindow(el);
const doc = win.document;
+ const containerEl = element.getContainer(el);
// step 3
if (el.localName == "input" && el.type == "file") {
throw new InvalidArgumentError(
"Cannot click <input type=file> elements");
}
- let containerEl = element.getContainer(el);
-
// step 4
if (!element.isInView(containerEl)) {
element.scrollIntoView(containerEl);
}
// step 5
// TODO(ato): wait for containerEl to be in view
@@ -151,41 +159,43 @@ interaction.clickElement = function* (el
yield a11y.getAccessible(el, true).then(acc => {
a11y.assertVisible(acc, el, true);
a11y.assertEnabled(acc, el, true);
a11y.assertActionable(acc, el);
});
// step 8
-
- // chrome elements
- if (element.isXULElement(el)) {
- if (el.localName == "option") {
- interaction.selectOption(el);
- } else {
- el.click();
- }
-
- // content elements
+ if (el.localName == "option") {
+ interaction.selectOption(el);
} else {
- if (el.localName == "option") {
- interaction.selectOption(el);
- } else {
- event.synthesizeMouseAtPoint(clickPoint.x, clickPoint.y, {}, win);
- }
+ event.synthesizeMouseAtPoint(clickPoint.x, clickPoint.y, {}, win);
}
// step 9
yield interaction.flushEventLoop(win);
// step 10
// TODO(ato): if the click causes navigation,
// run post-navigation checks
-};
+}
+
+function* chromeClick (el, a11y) {
+ yield a11y.getAccessible(el, true).then(acc => {
+ a11y.assertVisible(acc, el, true);
+ a11y.assertEnabled(acc, el, true);
+ a11y.assertActionable(acc, el);
+ });
+
+ if (el.localName == "option") {
+ interaction.selectOption(el);
+ } else {
+ el.click();
+ }
+}
/**
* Select <option> element in a <select> list.
*
* Because the dropdown list of select elements are implemented using
* native widget technology, our trusted synthesised events are not able
* to reach them. Dropdowns are instead handled mimicking DOM events,
* which for obvious reasons is not ideal, but at the current point in