Bug 1087038 - Properly check for found element(s) in marionette ElementManager.p.find, r=dburns
☠☠ backed out by 4243e118f58d ☠ ☠
authorTim Chien <timdream@gmail.com>
Wed, 22 Oct 2014 03:25:00 +0200
changeset 211676 04a18f29f77478f5228752c78a7e77ea42ae1af1
parent 211675 3b63378162d709eba82b3ee0c32aad53aa425088
child 211677 cdaf3cf65e3144ebe02a32e3629aea1a7cc29a05
push id27686
push userryanvm@gmail.com
push dateWed, 22 Oct 2014 20:01:01 +0000
treeherdermozilla-central@6066a2a0766f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdburns
bugs1087038
milestone36.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 1087038 - Properly check for found element(s) in marionette ElementManager.p.find, r=dburns
testing/marionette/marionette-elements.js
--- a/testing/marionette/marionette-elements.js
+++ b/testing/marionette/marionette-elements.js
@@ -288,35 +288,38 @@ ElementManager.prototype = {
     let startTime = values.time ? values.time : new Date().getTime();
     let startNode = (values.element != undefined) ?
                     this.getKnownElement(values.element, win) : win.document;
     if (this.elementStrategies.indexOf(values.using) < 0) {
       throw new ElementException("No such strategy.", 17, null);
     }
     let found = all ? this.findElements(values.using, values.value, win.document, startNode) :
                       this.findElement(values.using, values.value, win.document, startNode);
-    if (found == null || found.length <= 0) {
+    let type = Object.prototype.toString.call(found);
+    let isArrayLike = ((type == '[object Array]') || (type == '[object HTMLCollection]') || (type == '[object NodeList]'));
+    if (found == null || (isArrayLike && found.length <= 0)) {
+throw new Error(found + ', ' + type + ', ' + isArrayLike + ', ' + values.value);
+
       if (!searchTimeout || new Date().getTime() - startTime > searchTimeout) {
         if (all) {
           on_success([], command_id); // findElements should return empty list
         } else {
           on_error("Unable to locate element: " + values.value, 7, null, command_id);
         }
       } else {
         values.time = startTime;
         this.timer.initWithCallback(this.find.bind(this, win, values,
                                                    searchTimeout,
                                                    on_success, on_error, all,
                                                    command_id),
                                     100,
                                     Components.interfaces.nsITimer.TYPE_ONE_SHOT);
       }
     } else {
-      let type = Object.prototype.toString.call(found);
-      if ((type == '[object Array]') || (type == '[object HTMLCollection]') || (type == '[object NodeList]')) {
+      if (isArrayLike) {
         let ids = []
         for (let i = 0 ; i < found.length ; i++) {
           ids.push(this.addToKnownElements(found[i]));
         }
         on_success(ids, command_id);
       }
       else {
         let id = this.addToKnownElements(found);