Bug 1410799 - Catch error from element.Store#get in clickElement r=whimboo
authorAndreas Tolfsen <ato@sny.no>
Wed, 01 Nov 2017 18:06:21 +0000
changeset 443116 23589b9af885bb153ca487974f9c1c764d631f07
parent 443115 218cfcb9dbfdc528bee425477614ba5da0264e02
child 443117 7caf96c29235ac9ba9f9d6479b686d00fee37e0b
push id1618
push userCallek@gmail.com
push dateThu, 11 Jan 2018 17:45:48 +0000
treeherdermozilla-release@882ca853e05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswhimboo
bugs1410799, 1400256
milestone58.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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)) {