Bug 1430575 - Document interaction.clearElement. r?automatedtester
MozReview-Commit-ID: 6bwVFiJP6ej
--- 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><input type=file></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)) {