Bug 1410799 - Catch error from element.Store#get in clickElement r=whimboo
Because the content frame script's clickElement function uses
the old-style despatch technique, all code lines that have the
potential of throwing must be encapsualted in try...catch blocks.
Bug 1400256 accidentally moved them outside this block, and we did
not have any tests for stale elements in web content.
This ensures errors from WebElement.fromJSON and seenEls.get get
returned to the WebDriver service in testing/marionette/driver.js.
MozReview-Commit-ID: 49qjWhXWy69
--- a/testing/marionette/listener.js
+++ b/testing/marionette/listener.js
@@ -1299,36 +1299,35 @@ function getActiveElement() {
* @param {WebElement} el
* Reference to the web element to click.
* @param {number} pageTimeout
* Timeout in milliseconds the method has to wait for the page being
* finished loading.
*/
function clickElement(msg) {
let {commandID, webElRef, pageTimeout} = msg.json;
- let webEl = WebElement.fromJSON(webElRef);
- let el = seenEls.get(webEl, curContainer.frame);
try {
+ let webEl = WebElement.fromJSON(webElRef);
+ let el = seenEls.get(webEl, curContainer.frame);
+
let loadEventExpected = true;
-
let target = getElementAttribute(el, "target");
if (target === "_blank") {
loadEventExpected = false;
}
loadListener.navigate(() => {
return interaction.clickElement(
el,
capabilities.get("moz:accessibilityChecks"),
capabilities.get("moz:webdriverClick")
);
}, commandID, pageTimeout, loadEventExpected, true);
-
} catch (e) {
sendError(e, commandID);
}
}
function getElementAttribute(el, name) {
if (element.isBooleanAttribute(el, name)) {
if (el.hasAttribute(name)) {