Bug 1385873 - Better error on wrong element to interaction.selectOption. r?automatedtester draft
authorAndreas Tolfsen <ato@sny.no>
Mon, 31 Jul 2017 14:04:50 +0100
changeset 618470 aefe2f061329eda5233132b26f8eded492374d39
parent 618383 26516ba270816a6cc90f5c42a9b66701369a551f
child 618471 2e9ccc68221718f5bdb7e82774ad16417f953a76
push id71347
push userbmo:ato@sny.no
push dateMon, 31 Jul 2017 14:56:01 +0000
reviewersautomatedtester
bugs1385873
milestone56.0a1
Bug 1385873 - Better error on wrong element to interaction.selectOption. r?automatedtester Throw a better error message when the wrong element type is passed to interaction.selectOption. MozReview-Commit-ID: G1NIZ25umm2
testing/marionette/interaction.js
--- a/testing/marionette/interaction.js
+++ b/testing/marionette/interaction.js
@@ -4,22 +4,23 @@
 
 "use strict";
 
 const {utils: Cu} = Components;
 
 Cu.import("chrome://marionette/content/accessibility.js");
 Cu.import("chrome://marionette/content/atom.js");
 const {
+  ElementClickInterceptedError,
+  ElementNotInteractableError,
   error,
   InvalidArgument,
-  ElementNotInteractableError,
-  ElementClickInterceptedError,
+  InvalidArgumentError,
   InvalidElementStateError,
-  InvalidArgumentError,
+  pprint,
 } = Cu.import("chrome://marionette/content/error.js", {});
 Cu.import("chrome://marionette/content/element.js");
 Cu.import("chrome://marionette/content/event.js");
 
 Cu.importGlobalProperties(["File"]);
 
 this.EXPORTED_SYMBOLS = ["interaction"];
 
@@ -279,17 +280,17 @@ function* seleniumClickElement(el, a11y)
  *     If unable to find <var>el</var>'s parent <tt>&lt;select&gt;</tt>
  *     element.
  */
 interaction.selectOption = function(el) {
   if (element.isXULElement(el)) {
     throw new Error("XUL dropdowns not supported");
   }
   if (el.localName != "option") {
-    throw new TypeError("Invalid elements");
+    throw new TypeError(pprint`Expected <option> element, got ${el}`);
   }
 
   let containerEl = element.getContainer(el);
 
   event.mouseover(containerEl);
   event.mousemove(containerEl);
   event.mousedown(containerEl);
   event.focus(containerEl);