summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/forms/file/file-input-change-event.html
diff options
context:
space:
mode:
authorsigbjornf@opera.com <sigbjornf@opera.com@bbb929c8-8fbe-4397-9dbb-9b2b20218538>2014-02-10 02:17:33 +0000
committersigbjornf@opera.com <sigbjornf@opera.com@bbb929c8-8fbe-4397-9dbb-9b2b20218538>2014-02-10 02:17:33 +0000
commit2a8b84808ce32e70afcb5bbbc9c49ee093aa1bb7 (patch)
treed90cd0be842e68f70934557535ed3c10a7e27ec9 /third_party/WebKit/LayoutTests/fast/forms/file/file-input-change-event.html
parent0ca87a0af162c2d5fe6452d12243b5d7bf63ee50 (diff)
downloadchromium_src-2a8b84808ce32e70afcb5bbbc9c49ee093aa1bb7.zip
chromium_src-2a8b84808ce32e70afcb5bbbc9c49ee093aa1bb7.tar.gz
chromium_src-2a8b84808ce32e70afcb5bbbc9c49ee093aa1bb7.tar.bz2
Reduce test code duplication in fast/forms/file
Factor out some repeatedly used functions when dragging files onto type=file elements. R= BUG= Review URL: https://codereview.chromium.org/148983008 git-svn-id: svn://svn.chromium.org/blink/trunk@166782 bbb929c8-8fbe-4397-9dbb-9b2b20218538
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.html75
1 files changed, 34 insertions, 41 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
index 070eff7..6cb16d3 100644
--- 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
@@ -2,6 +2,7 @@
<html>
<head>
<script src="../../../resources/js-test.js"></script>
+<script src="resources/file-drag-common.js"></script>
</head>
<body>
<input type="file" id="singleFile" name="upfile" onchange="singleFileSelected()" />
@@ -17,72 +18,72 @@ if (window.testRunner) {
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"]);
+ dragFilesOntoFileInput(singleFileInput, ["foo.txt"]);
shouldBeEqualToString("singleFileInput.value", "C:\\fakepath\\foo.txt");
- shouldBe("changeDispatched", "true");
+ shouldBeTrue("changeDispatched");
- dragFilesOntoInput(singleFileInput, ["bar.txt"]);
+ dragFilesOntoFileInput(singleFileInput, ["bar.txt"]);
shouldBeEqualToString("singleFileInput.value", "C:\\fakepath\\bar.txt");
- shouldBe("changeDispatched", "true");
+ shouldBeTrue("changeDispatched");
- dragFilesOntoInput(singleFileInput, ["bar.txt"]);
+ dragFilesOntoFileInput(singleFileInput, ["bar.txt"]);
shouldBeEqualToString("singleFileInput.value", "C:\\fakepath\\bar.txt");
- shouldBe("changeDispatched", "false");
+ shouldBeFalse("changeDispatched");
- dragFilesOntoInput(singleFileInput, ["foo.txt"]);
+ dragFilesOntoFileInput(singleFileInput, ["foo.txt"]);
shouldBeEqualToString("singleFileInput.value", "C:\\fakepath\\foo.txt");
- shouldBe("changeDispatched", "true");
+ shouldBeTrue("changeDispatched");
dragFilesOntoButtonInsideFileInput(singleFileInput, ["baz.png"]);
shouldBeEqualToString("singleFileInput.value", "C:\\fakepath\\baz.png");
- shouldBe("changeDispatched", "true");
+ shouldBeTrue("changeDispatched");
debug("");
debug("Test that the 'change' event is triggered on a multiple file form when a selected file is changed:");
- dragFilesOntoInput(multipleFilesInput, ["foo.txt"]);
+ dragFilesOntoFileInput(multipleFilesInput, ["foo.txt"]);
shouldBeEqualToString("multipleFilesInput.value", "C:\\fakepath\\foo.txt");
- shouldBe("changeDispatched", "true");
+ shouldBeTrue("changeDispatched");
- dragFilesOntoInput(multipleFilesInput, ["bar.txt"]);
+ dragFilesOntoFileInput(multipleFilesInput, ["bar.txt"]);
shouldBeEqualToString("multipleFilesInput.value", "C:\\fakepath\\bar.txt");
- shouldBe("changeDispatched", "true");
+ shouldBeTrue("changeDispatched");
- dragFilesOntoInput(multipleFilesInput, ["bar.txt"]);
+ dragFilesOntoFileInput(multipleFilesInput, ["bar.txt"]);
shouldBeEqualToString("multipleFilesInput.value", "C:\\fakepath\\bar.txt");
- shouldBe("changeDispatched", "false");
+ shouldBeFalse("changeDispatched");
- dragFilesOntoInput(multipleFilesInput, ["foo.txt"]);
+ dragFilesOntoFileInput(multipleFilesInput, ["foo.txt"]);
shouldBeEqualToString("multipleFilesInput.value", "C:\\fakepath\\foo.txt");
- shouldBe("changeDispatched", "true");
+ shouldBeTrue("changeDispatched");
debug("Test that the 'change' event is triggered on a multiple file form when selected files are changed:");
- dragFilesOntoInput(multipleFilesInput, ["foo.txt", "bar.txt"]);
+ dragFilesOntoFileInput(multipleFilesInput, ["foo.txt", "bar.txt"]);
shouldBeEqualToString("multipleFilesInput.value", "C:\\fakepath\\foo.txt");
- shouldBe("changeDispatched", "true");
+ shouldBeTrue("changeDispatched");
- dragFilesOntoInput(multipleFilesInput, ["foo.txt"]);
+ dragFilesOntoFileInput(multipleFilesInput, ["foo.txt"]);
shouldBeEqualToString("multipleFilesInput.value", "C:\\fakepath\\foo.txt");
- shouldBe("changeDispatched", "true");
+ shouldBeTrue("changeDispatched");
- dragFilesOntoInput(multipleFilesInput, ["foo.txt", "bar.txt"]);
+ dragFilesOntoFileInput(multipleFilesInput, ["foo.txt", "bar.txt"]);
shouldBeEqualToString("multipleFilesInput.value", "C:\\fakepath\\foo.txt");
- shouldBe("changeDispatched", "true");
+ shouldBeTrue("changeDispatched");
- dragFilesOntoInput(multipleFilesInput, ["foo.txt", "bar.txt", "baz.txt"]);
+ dragFilesOntoFileInput(multipleFilesInput, ["foo.txt", "bar.txt", "baz.txt"]);
shouldBeEqualToString("multipleFilesInput.value", "C:\\fakepath\\foo.txt");
- shouldBe("changeDispatched", "true");
+ shouldBeTrue("changeDispatched");
- dragFilesOntoInput(multipleFilesInput, ["foo.txt", "bar.txt"]);
+ dragFilesOntoFileInput(multipleFilesInput, ["foo.txt", "bar.txt"]);
shouldBeEqualToString("multipleFilesInput.value", "C:\\fakepath\\foo.txt");
- shouldBe("changeDispatched", "true");
+ shouldBeTrue("changeDispatched");
- dragFilesOntoInput(multipleFilesInput, ["bar.txt", "foo.txt"]);
+ dragFilesOntoFileInput(multipleFilesInput, ["bar.txt", "foo.txt"]);
shouldBeEqualToString("multipleFilesInput.value", "C:\\fakepath\\bar.txt");
- shouldBe("changeDispatched", "true");
+ shouldBeTrue("changeDispatched");
- dragFilesOntoInput(multipleFilesInput, ["bar.txt", "foo.txt"]);
+ dragFilesOntoFileInput(multipleFilesInput, ["bar.txt", "foo.txt"]);
shouldBeEqualToString("multipleFilesInput.value", "C:\\fakepath\\bar.txt");
- shouldBe("changeDispatched", "false");
+ shouldBeFalse("changeDispatched");
}
function singleFileSelected() {
@@ -93,17 +94,9 @@ 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) {
+function dragFilesOntoFileInput(input, files) {
changeDispatched = false;
- eventSender.beginDragWithFiles(files);
- moveMouseToCenterOfElement(input);
- eventSender.mouseUp();
+ dragFilesOntoInput(input, files);
}
function dragFilesOntoButtonInsideFileInput(input, files) {