summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/forms/file/file-input-change-event.html
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/WebKit/LayoutTests/fast/forms/file/file-input-change-event.html')
-rw-r--r--third_party/WebKit/LayoutTests/fast/forms/file/file-input-change-event.html110
1 files changed, 110 insertions, 0 deletions
diff --git a/third_party/WebKit/LayoutTests/fast/forms/file/file-input-change-event.html b/third_party/WebKit/LayoutTests/fast/forms/file/file-input-change-event.html
new file mode 100644
index 0000000..b9599bb
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/forms/file/file-input-change-event.html
@@ -0,0 +1,110 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<input type="file" id="singleFile" name="upfile" onchange="singleFileSelected()" />
+<input type="file" id="multipleFiles" name="upfile[]" multiple="multiple" onchange="multipleFilesSelected()" />
+<div id="console">
+<p>
+This tests the condition that triggers a 'change' event on file input forms.
+</p>
+</div>
+<script>
+var changeDispatched;
+
+if (window.layoutTestController) {
+ var singleFileInput = document.getElementById("singleFile");
+ var multipleFilesInput = document.getElementById("multipleFiles");
+
+ debug("Test that the 'change' event is triggered on a single file form when a selected file is changed:");
+ dragFilesOntoInput(singleFileInput, ["foo.txt"]);
+ shouldBeEqualToString("singleFileInput.value", "C:\\fakepath\\foo.txt");
+ shouldBe("changeDispatched", "true");
+
+ dragFilesOntoInput(singleFileInput, ["bar.txt"]);
+ shouldBeEqualToString("singleFileInput.value", "C:\\fakepath\\bar.txt");
+ shouldBe("changeDispatched", "true");
+
+ dragFilesOntoInput(singleFileInput, ["bar.txt"]);
+ shouldBeEqualToString("singleFileInput.value", "C:\\fakepath\\bar.txt");
+ shouldBe("changeDispatched", "false");
+
+ dragFilesOntoInput(singleFileInput, ["foo.txt"]);
+ shouldBeEqualToString("singleFileInput.value", "C:\\fakepath\\foo.txt");
+ shouldBe("changeDispatched", "true");
+
+ debug("Test that the 'change' event is triggered on a multiple file form when a selected file is changed:");
+ dragFilesOntoInput(multipleFilesInput, ["foo.txt"]);
+ shouldBeEqualToString("multipleFilesInput.value", "C:\\fakepath\\foo.txt");
+ shouldBe("changeDispatched", "true");
+
+ dragFilesOntoInput(multipleFilesInput, ["bar.txt"]);
+ shouldBeEqualToString("multipleFilesInput.value", "C:\\fakepath\\bar.txt");
+ shouldBe("changeDispatched", "true");
+
+ dragFilesOntoInput(multipleFilesInput, ["bar.txt"]);
+ shouldBeEqualToString("multipleFilesInput.value", "C:\\fakepath\\bar.txt");
+ shouldBe("changeDispatched", "false");
+
+ dragFilesOntoInput(multipleFilesInput, ["foo.txt"]);
+ shouldBeEqualToString("multipleFilesInput.value", "C:\\fakepath\\foo.txt");
+ shouldBe("changeDispatched", "true");
+
+ debug("Test that the 'change' event is triggered on a multiple file form when selected files are changed:");
+ dragFilesOntoInput(multipleFilesInput, ["foo.txt", "bar.txt"]);
+ shouldBeEqualToString("multipleFilesInput.value", "C:\\fakepath\\foo.txt");
+ shouldBe("changeDispatched", "true");
+
+ dragFilesOntoInput(multipleFilesInput, ["foo.txt"]);
+ shouldBeEqualToString("multipleFilesInput.value", "C:\\fakepath\\foo.txt");
+ shouldBe("changeDispatched", "true");
+
+ dragFilesOntoInput(multipleFilesInput, ["foo.txt", "bar.txt"]);
+ shouldBeEqualToString("multipleFilesInput.value", "C:\\fakepath\\foo.txt");
+ shouldBe("changeDispatched", "true");
+
+ dragFilesOntoInput(multipleFilesInput, ["foo.txt", "bar.txt", "baz.txt"]);
+ shouldBeEqualToString("multipleFilesInput.value", "C:\\fakepath\\foo.txt");
+ shouldBe("changeDispatched", "true");
+
+ dragFilesOntoInput(multipleFilesInput, ["foo.txt", "bar.txt"]);
+ shouldBeEqualToString("multipleFilesInput.value", "C:\\fakepath\\foo.txt");
+ shouldBe("changeDispatched", "true");
+
+ dragFilesOntoInput(multipleFilesInput, ["bar.txt", "foo.txt"]);
+ shouldBeEqualToString("multipleFilesInput.value", "C:\\fakepath\\bar.txt");
+ shouldBe("changeDispatched", "true");
+
+ dragFilesOntoInput(multipleFilesInput, ["bar.txt", "foo.txt"]);
+ shouldBeEqualToString("multipleFilesInput.value", "C:\\fakepath\\bar.txt");
+ shouldBe("changeDispatched", "false");
+}
+
+function singleFileSelected() {
+ changeDispatched = true;
+}
+
+function multipleFilesSelected() {
+ changeDispatched = true;
+}
+
+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) {
+ changeDispatched = false;
+ eventSender.beginDragWithFiles(files);
+ moveMouseToCenterOfElement(input);
+ eventSender.mouseUp();
+}
+
+var successfullyParsed = true;
+</script>
+<script src="../../js/resources/js-test-post.js"></script>
+</body>
+</html>