summaryrefslogtreecommitdiffstats
path: root/third_party
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
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')
-rw-r--r--third_party/WebKit/LayoutTests/fast/forms/file/file-input-change-event.html75
-rw-r--r--third_party/WebKit/LayoutTests/fast/forms/file/file-input-empty-validation.html13
-rw-r--r--third_party/WebKit/LayoutTests/fast/forms/file/file-input-reset-validation.html13
-rw-r--r--third_party/WebKit/LayoutTests/fast/forms/file/file-input-reset.html9
-rw-r--r--third_party/WebKit/LayoutTests/fast/forms/file/file-reset-in-change.html9
-rw-r--r--third_party/WebKit/LayoutTests/fast/forms/file/input-file-value.html13
-rw-r--r--third_party/WebKit/LayoutTests/fast/forms/file/input-file-write-files.html13
-rw-r--r--third_party/WebKit/LayoutTests/fast/forms/file/recover-file-input-in-unposted-form.html13
-rw-r--r--third_party/WebKit/LayoutTests/fast/forms/file/resources/file-drag-common.js19
9 files changed, 60 insertions, 117 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) {
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
index 26c12a3..696c0c6 100644
--- 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
@@ -1,5 +1,6 @@
<!DOCTYPE html>
<script src="../../../resources/js-test.js"></script>
+<script src="resources/file-drag-common.js"></script>
<form method="GET" onsubmit="finish(false)">
<input type="file" oninvalid="finish(true)" required>
<input type="submit">
@@ -16,18 +17,6 @@ function finish(pass)
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']);
diff --git a/third_party/WebKit/LayoutTests/fast/forms/file/file-input-reset-validation.html b/third_party/WebKit/LayoutTests/fast/forms/file/file-input-reset-validation.html
index 1ba34e6..fbceb7b 100644
--- a/third_party/WebKit/LayoutTests/fast/forms/file/file-input-reset-validation.html
+++ b/third_party/WebKit/LayoutTests/fast/forms/file/file-input-reset-validation.html
@@ -1,5 +1,6 @@
<!DOCTYPE html>
<script src="../../../resources/js-test.js"></script>
+<script src="resources/file-drag-common.js"></script>
<form method="GET" onsubmit="finish(false)">
<input type="file" oninvalid="finish(true)" required>
<input type="reset">
@@ -17,18 +18,6 @@ function finish(pass)
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-reset-validation.html']);
diff --git a/third_party/WebKit/LayoutTests/fast/forms/file/file-input-reset.html b/third_party/WebKit/LayoutTests/fast/forms/file/file-input-reset.html
index 9d7cca1..c67ebbb 100644
--- a/third_party/WebKit/LayoutTests/fast/forms/file/file-input-reset.html
+++ b/third_party/WebKit/LayoutTests/fast/forms/file/file-input-reset.html
@@ -1,4 +1,5 @@
<!DOCTYPE html>
+<script src="resources/file-drag-common.js"></script>
<html>
<head>
</head>
@@ -30,14 +31,6 @@ function click(x, y) {
eventSender.mouseMoveTo(x, y);
eventSender.mouseUp();
}
-
-function dragFilesOntoElement(element, files) {
- eventSender.beginDragWithFiles(files);
- var centerX = element.offsetLeft + element.offsetWidth / 2;
- var centerY = element.offsetTop + element.offsetHeight / 2;
- eventSender.mouseMoveTo(centerX, centerY);
- eventSender.mouseUp();
-}
</script>
</body>
</html>
diff --git a/third_party/WebKit/LayoutTests/fast/forms/file/file-reset-in-change.html b/third_party/WebKit/LayoutTests/fast/forms/file/file-reset-in-change.html
index 4d6a14e..7e4952e 100644
--- a/third_party/WebKit/LayoutTests/fast/forms/file/file-reset-in-change.html
+++ b/third_party/WebKit/LayoutTests/fast/forms/file/file-reset-in-change.html
@@ -1,18 +1,11 @@
<!DOCTYPE html>
+<script src="resources/file-drag-common.js"></script>
<body>
<p>Resetting a file upload control by script should clear the icon.</p>
<p>Manual test: Select a file for the file upload control, and confirm it has no icon.</p>
<input id=file1 type=file>
</form>
<script>
-function dragFilesOntoElement(element, files) {
- eventSender.beginDragWithFiles(files);
- var centerX = element.offsetLeft + element.offsetWidth / 2;
- var centerY = element.offsetTop + element.offsetHeight / 2;
- eventSender.mouseMoveTo(centerX, centerY);
- eventSender.mouseUp();
-}
-
function handleChange() {
file1.value = '';
}
diff --git a/third_party/WebKit/LayoutTests/fast/forms/file/input-file-value.html b/third_party/WebKit/LayoutTests/fast/forms/file/input-file-value.html
index e1004d6..ad68a8b 100644
--- a/third_party/WebKit/LayoutTests/fast/forms/file/input-file-value.html
+++ b/third_party/WebKit/LayoutTests/fast/forms/file/input-file-value.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" name="file" id="file">
@@ -24,18 +25,6 @@ if (window.testRunner) {
shouldBeEqualToString("file.value", "");
shouldBe("file.files.length", "0");
}
-
-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();
-}
</script>
</body>
</html>
diff --git a/third_party/WebKit/LayoutTests/fast/forms/file/input-file-write-files.html b/third_party/WebKit/LayoutTests/fast/forms/file/input-file-write-files.html
index 43ebca3..1613b24 100644
--- a/third_party/WebKit/LayoutTests/fast/forms/file/input-file-write-files.html
+++ b/third_party/WebKit/LayoutTests/fast/forms/file/input-file-write-files.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" name="file1" id="file1">
@@ -30,18 +31,6 @@ if (window.testRunner) {
shouldBe("file1.files.length", "1");
shouldBeEqualToString("file1.files.item(0).name", "bar.txt");
}
-
-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();
-}
</script>
</body>
</html>
diff --git a/third_party/WebKit/LayoutTests/fast/forms/file/recover-file-input-in-unposted-form.html b/third_party/WebKit/LayoutTests/fast/forms/file/recover-file-input-in-unposted-form.html
index 9154a99..5a4250d 100644
--- a/third_party/WebKit/LayoutTests/fast/forms/file/recover-file-input-in-unposted-form.html
+++ b/third_party/WebKit/LayoutTests/fast/forms/file/recover-file-input-in-unposted-form.html
@@ -1,6 +1,7 @@
<html>
<head>
<script src="../../../resources/js-test.js"></script>
+<script src="resources/file-drag-common.js"></script>
</head>
<body onload="test()">
<form id="form" method="post" enctype="multipart/form-data">
@@ -84,18 +85,6 @@ function expectFileContents(file, contents) {
reader.readAsText(file, "UTF-8");
reader.onload = checkFileContents.bind(undefined, contents);
}
-
-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();
-}
</script>
</body>
</html>
diff --git a/third_party/WebKit/LayoutTests/fast/forms/file/resources/file-drag-common.js b/third_party/WebKit/LayoutTests/fast/forms/file/resources/file-drag-common.js
new file mode 100644
index 0000000..224e2b0
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/forms/file/resources/file-drag-common.js
@@ -0,0 +1,19 @@
+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 dragFilesOntoElement(element, files) {
+ eventSender.beginDragWithFiles(files);
+ var centerX = element.offsetLeft + element.offsetWidth / 2;
+ var centerY = element.offsetTop + element.offsetHeight / 2;
+ eventSender.mouseMoveTo(centerX, centerY);
+ eventSender.mouseUp();
+}