summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/forms/file/file-input-empty-validation.html
diff options
context:
space:
mode:
authorsigbjornf@opera.com <sigbjornf@opera.com@bbb929c8-8fbe-4397-9dbb-9b2b20218538>2014-01-30 09:51:52 +0000
committersigbjornf@opera.com <sigbjornf@opera.com@bbb929c8-8fbe-4397-9dbb-9b2b20218538>2014-01-30 09:51:52 +0000
commite14800056733fa9beed10c9a506598b943d9ee7b (patch)
tree1a0f84cf678034a00aad068cd413ddbb64f95e7f /third_party/WebKit/LayoutTests/fast/forms/file/file-input-empty-validation.html
parentde05b38517ad67a025e073e0a7fece2ce2dc086e (diff)
downloadchromium_src-e14800056733fa9beed10c9a506598b943d9ee7b.zip
chromium_src-e14800056733fa9beed10c9a506598b943d9ee7b.tar.gz
chromium_src-e14800056733fa9beed10c9a506598b943d9ee7b.tar.bz2
Synchronize is-valid flag upon programmatic clearing of file.value
If a type=file input element is cleared of its current contents by setting the "value" property to the empty string, make sure the 'is valid' flag kept on the input element is synchronized. Failure to do so could incorrectly make the element pass follow-on validation -- if it additionally has 'required' set. R=tkent@chromium.org BUG=336818 Review URL: https://codereview.chromium.org/132233059 git-svn-id: svn://svn.chromium.org/blink/trunk@166115 bbb929c8-8fbe-4397-9dbb-9b2b20218538
Diffstat (limited to 'third_party/WebKit/LayoutTests/fast/forms/file/file-input-empty-validation.html')
-rw-r--r--third_party/WebKit/LayoutTests/fast/forms/file/file-input-empty-validation.html43
1 files changed, 43 insertions, 0 deletions
diff --git a/third_party/WebKit/LayoutTests/fast/forms/file/file-input-empty-validation.html b/third_party/WebKit/LayoutTests/fast/forms/file/file-input-empty-validation.html
new file mode 100644
index 0000000..26c12a3
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/forms/file/file-input-empty-validation.html
@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<script src="../../../resources/js-test.js"></script>
+<form method="GET" onsubmit="finish(false)">
+<input type="file" oninvalid="finish(true)" required>
+<input type="submit">
+</form>
+<pre id="console"></pre>
+<script>
+description("This tests that a file input cleared of its (required) value doesn't validate.");
+
+var invalid = false;
+function finish(pass)
+{
+ invalid = pass;
+ shouldBeTrue("invalid");
+ finishJSTest();
+}
+
+function moveMouseToCenterOfElement(element) {
+ var centerX = element.offsetLeft + element.offsetWidth / 2;
+ var centerY = element.offsetTop + element.offsetHeight / 2;
+ eventSender.mouseMoveTo(centerX, centerY);
+}
+
+function dragFilesOntoInput(input, files) {
+ eventSender.beginDragWithFiles(files);
+ moveMouseToCenterOfElement(input);
+ eventSender.mouseUp();
+}
+
+function startTest()
+{
+ dragFilesOntoInput(document.forms[0].querySelector("[type=file]"), ['file-input-empty-validation.html']);
+ document.forms[0].querySelector("[type=file]").value = "";
+ document.forms[0].querySelector("[type=submit]").click();
+}
+
+if (window.eventSender) {
+ window.jsTestIsAsync = true;
+ testRunner.dumpAsText();
+ window.onload = startTest;
+}
+</script>