Index: LayoutTests/fast/forms/resources/common-setrangetext.js |
diff --git a/LayoutTests/fast/forms/resources/common-setrangetext.js b/LayoutTests/fast/forms/resources/common-setrangetext.js |
index 6861347fab84f8211e1f9e7f54e47b0ab9bbacd6..cbc3b54a897e872348eb46a27def00988544ec9b 100644 |
--- a/LayoutTests/fast/forms/resources/common-setrangetext.js |
+++ b/LayoutTests/fast/forms/resources/common-setrangetext.js |
@@ -162,4 +162,30 @@ function runTestsShouldFail(tagName, attributes) |
shouldBeEqualToString("element.value", initialValue); |
} |
+function runTestsShouldNotThrow(tagName, attributes) |
+{ |
+ attributes = attributes || {}; |
+ window.element = document.createElement(tagName); |
+ for (var key in attributes) |
+ element.setAttribute(key, attributes[key]); |
+ |
+ document.body.appendChild(element); |
+ debug("<hr>"); |
+ debug("Running tests on " + tagName + " with attributes: " + JSON.stringify(attributes) + "\n"); |
+ |
+ var initialValue = element.value; |
+ if (element.getAttribute("type") == "file") |
+ shouldThrow("element.value = '0123456789'"); |
+ else |
+ evalAndLog("element.value = '0123456789'"); |
+ evalAndLog("element.setSelectionRange(2, 5)"); |
+ evalAndLog("element.setRangeText('432')"); |
+ |
+ // setRangeText() shouldn't do anything on non-text form controls. |
+ if (element.getAttribute("type") == "color") |
+ shouldBeEqualToString("element.value", "#000000"); |
+ else |
+ shouldBeEqualToString("element.value", initialValue); |
+ shouldNotBe("element.value", "0143256789"); |
+} |