Bug 1430575 - Document interaction.clearElement. r?automatedtester draft
authorAndreas Tolfsen <ato@sny.no>
Mon, 15 Jan 2018 17:15:10 +0000
changeset 721571 5dd13cfe669f632d556f267543695af019b92442
parent 721570 2e45e00dc9ae1564b37d9454b4bd855ee26af9db
child 721572 159d23009bb3d0c20166d84ea73cbe12e17844e7
push id95875
push userbmo:ato@sny.no
push dateWed, 17 Jan 2018 13:45:56 +0000
reviewersautomatedtester
bugs1430575
milestone59.0a1
Bug 1430575 - Document interaction.clearElement. r?automatedtester MozReview-Commit-ID: 6bwVFiJP6ej
testing/marionette/interaction.js
--- a/testing/marionette/interaction.js
+++ b/testing/marionette/interaction.js
@@ -284,16 +284,36 @@ interaction.selectOption = function(el) 
     event.input(containerEl);
     event.change(containerEl);
   }
 
   event.mouseup(containerEl);
   event.click(containerEl);
 };
 
+/**
+ * Clears the form control or the editable element, if required.
+ *
+ * Before clearing the element, it will attempt to scroll it into
+ * view if it is not already in the viewport.  An error is raised
+ * if the element cannot be brought into view.
+ *
+ * If the element is a submittable form control and it is empty
+ * (it has no value or it has no files associated with it, in the
+ * case it is a <code>&lt;input type=file&gt;</code> element) or
+ * it is an editing host and its <code>innerHTML</code> content IDL
+ * attribute is empty, this function acts as a no-op.
+ *
+ * @param {Element} el
+ *     Element to clear.
+ *
+ * @throws {InvalidElementStateError}
+ *     If element is disabled, read-only, non-editable, not a submittable
+ *     element or not an editing host, or cannot be scrolled into view.
+ */
 interaction.clearElement = function(el) {
   if (element.isDisabled(el)) {
     throw new InvalidElementStateError(pprint`Element is disabled: ${el}`);
   }
   if (element.isReadOnly(el)) {
     throw new InvalidElementStateError(pprint`Element is read-only: ${el}`);
   }
   if (!element.isEditable(el)) {