Bug 1410799 - Catch error from element.Store#get in clickElement r=whimboo draft
authorAndreas Tolfsen <ato@sny.no>
Wed, 01 Nov 2017 18:06:21 +0000
changeset 692110 ab8a900fb543b1a0bc7816c7ce4b4099f6701959
parent 692109 53f0b32914046993a720c5396b0ec03ae1248d20
child 692111 d98e943e815882fd4e64e9c6dd03d729d230fccd
push id87400
push userbmo:ato@sny.no
push dateThu, 02 Nov 2017 15:42:41 +0000
reviewerswhimboo
bugs1410799, 1400256
milestone58.0a1
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
testing/marionette/listener.js
--- 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)) {