Diff
Modified: trunk/LayoutTests/ChangeLog (132598 => 132599)
--- trunk/LayoutTests/ChangeLog 2012-10-26 10:09:01 UTC (rev 132598)
+++ trunk/LayoutTests/ChangeLog 2012-10-26 10:18:15 UTC (rev 132599)
@@ -1,3 +1,19 @@
+2012-10-26 Li Yin <[email protected]>
+
+ fast/forms/file/input-file-write-files.html should cover correct setting value
+ https://bugs.webkit.org/show_bug.cgi?id=100085
+
+ Reviewed by Kentaro Hara.
+
+ The test input-file-value.html is split from input-file-write-test.html.
+ And add correct setting value for files attribute, verify the files attribute
+ is writable or not.
+
+ * fast/forms/file/input-file-value-expected.txt: Added.
+ * fast/forms/file/input-file-value.html: Added.
+ * fast/forms/file/input-file-write-files-expected.txt:
+ * fast/forms/file/input-file-write-files.html:
+
2012-10-26 Jinwoo Song <[email protected]>
[EFL] Gardening after bug 99824
Modified: trunk/LayoutTests/fast/forms/file/file-setrangetext-expected.txt (132598 => 132599)
--- trunk/LayoutTests/fast/forms/file/file-setrangetext-expected.txt 2012-10-26 10:09:01 UTC (rev 132598)
+++ trunk/LayoutTests/fast/forms/file/file-setrangetext-expected.txt 2012-10-26 10:18:15 UTC (rev 132599)
@@ -6,7 +6,7 @@
Running tests on input with attributes: {"type":"file"}
-element.value = '0123456789XYZ'
+PASS element.value = '0123456789XYZ' threw exception Error: INVALID_STATE_ERR: DOM Exception 11.
PASS element.setRangeText('ABC', 0, 0) threw exception Error: INVALID_STATE_ERR: DOM Exception 11.
PASS element.value is ""
PASS successfullyParsed is true
Added: trunk/LayoutTests/fast/forms/file/input-file-value-expected.txt (0 => 132599)
--- trunk/LayoutTests/fast/forms/file/input-file-value-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/forms/file/input-file-value-expected.txt 2012-10-26 10:18:15 UTC (rev 132599)
@@ -0,0 +1,16 @@
+This tests the value attribute in file input forms
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS file.value is "C:\\fakepath\\foo.txt"
+PASS file.files.length is 1
+PASS file.value = 'foo' threw exception Error: INVALID_STATE_ERR: DOM Exception 11.
+PASS file.value is "C:\\fakepath\\foo.txt"
+PASS file.files.length is 1
+PASS file.value is ""
+PASS file.files.length is 0
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/forms/file/input-file-value.html (0 => 132599)
--- trunk/LayoutTests/fast/forms/file/input-file-value.html (rev 0)
+++ trunk/LayoutTests/fast/forms/file/input-file-value.html 2012-10-26 10:18:15 UTC (rev 132599)
@@ -0,0 +1,42 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<input type="file" name="file" id="file">
+
+<script>
+description("This tests the value attribute in file input forms");
+
+if (window.testRunner) {
+ var file = document.getElementById("file");
+ dragFilesOntoInput(file, ["foo.txt"]);
+
+ shouldBeEqualToString("file.value", "C:\\fakepath\\foo.txt");
+ shouldBe("file.files.length", "1");
+
+ shouldThrow("file.value = 'foo'");
+ shouldBeEqualToString("file.value", "C:\\fakepath\\foo.txt");
+ shouldBe("file.files.length", "1");
+
+ file.value = "";
+ 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>
+<script src=""
+</body>
+</html>
Modified: trunk/LayoutTests/fast/forms/file/input-file-write-files-expected.txt (132598 => 132599)
--- trunk/LayoutTests/fast/forms/file/input-file-write-files-expected.txt 2012-10-26 10:09:01 UTC (rev 132598)
+++ trunk/LayoutTests/fast/forms/file/input-file-write-files-expected.txt 2012-10-26 10:18:15 UTC (rev 132599)
@@ -1,6 +1,15 @@
-Test drops files here
+This tests the files attribute in file input forms
-PASS: 1 file after drag
-PASS: writing nonempty string to value had no effect
-PASS: writing empty string to value cleared files
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+PASS file1.files.length is 1
+PASS file1.files.item(0).name is "foo.txt"
+PASS file1.files.length is 1
+PASS file1.files.item(0).name is "foo.txt"
+PASS file1.files.length is 1
+PASS file1.files.item(0).name is "bar.txt"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Modified: trunk/LayoutTests/fast/forms/file/input-file-write-files.html (132598 => 132599)
--- trunk/LayoutTests/fast/forms/file/input-file-write-files.html 2012-10-26 10:09:01 UTC (rev 132598)
+++ trunk/LayoutTests/fast/forms/file/input-file-write-files.html 2012-10-26 10:18:15 UTC (rev 132599)
@@ -1,85 +1,48 @@
<!DOCTYPE html>
<html>
+<head>
+<script src=""
+</head>
<body>
-<div id="droptarget">Test drops files here</div>
-<form>
-<input type="file" name="files" id="files">
-</form>
-<pre id='output'></pre>
-
+<input type="file" name="file1" id="file1">
+<input type="file" name="file2" id="file2">
<script>
-function log(message)
-{
- document.getElementById('output').appendChild(document.createTextNode(message + "\n"));
-}
+description("This tests the files attribute in file input forms");
-function onInputFileChange()
-{
- var files = document.getElementById("files").files;
- if (files.length != 1)
- log("FAIL: Expected 1 file after drag.")
- else
- log("PASS: 1 file after drag");
+if (window.testRunner) {
+ var file1 = document.getElementById("file1");
+ var file2 = document.getElementById("file2");
+ dragFilesOntoInput(file1, ["foo.txt"]);
+ dragFilesOntoInput(file2, ["bar.txt"]);
- doStringTest();
+ file1.files = "foo";
+ shouldBe("file1.files.length", "1");
+ shouldBeEqualToString("file1.files.item(0).name", "foo.txt");
- if (window.testRunner)
- testRunner.notifyDone();
-}
+ file1.files = null;
+ shouldBe("file1.files.length", "1");
+ shouldBeEqualToString("file1.files.item(0).name", "foo.txt");
-function handleDragOver(e) {
- e.stopPropagation();
- e.preventDefault();
+ // From current W3C spec, files attribute should be read only,
+ // but WebKit implement it to be writable intentionally.
+ // See: https://bugs.webkit.org/show_bug.cgi?id=87154#c15
+ file1.files = file2.files;
+ shouldBe("file1.files.length", "1");
+ shouldBeEqualToString("file1.files.item(0).name", "bar.txt");
}
-function handleDrop(e) {
- e.stopPropagation();
- e.preventDefault();
- document.getElementById("files").files = e.dataTransfer.files;
+function moveMouseToCenterOfElement(element) {
+ var centerX = element.offsetLeft + element.offsetWidth / 2;
+ var centerY = element.offsetTop + element.offsetHeight / 2;
+ eventSender.mouseMoveTo(centerX, centerY);
}
-var droptarget = document.getElementById('droptarget');
-droptarget.addEventListener('dragover', handleDragOver, false);
-droptarget.addEventListener('drop', handleDrop, false);
-
-function doTest(fileList)
-{
- // This drops files on a div, which copies them to the input element, whose
- // callback calls notifyDone().
- document.getElementById("files")._onchange_ = onInputFileChange;
- var fi = document.getElementById("files");
- eventSender.beginDragWithFiles(['../resources/test.txt']);
- eventSender.mouseMoveTo(droptarget.offsetLeft + 10, droptarget.offsetTop + droptarget.offsetHeight / 2);
+function dragFilesOntoInput(input, files) {
+ eventSender.beginDragWithFiles(files);
+ moveMouseToCenterOfElement(input);
eventSender.mouseUp();
}
-
-function doStringTest()
-{
- var files = document.getElementById("files");
- files.files = "foo"; // Shouldn't crash.
-
- files.value = "foo"; // Should do nothing.
- if (files.files.length > 0)
- log("PASS: writing nonempty string to value had no effect");
- else
- log("FAIL: writing nonempty string to value cleared elements");
-
- files.value = "";
- if (files.files.length === 0)
- log("PASS: writing empty string to value cleared files");
- else
- log("FAIL: writing empty string to value did not clear files");
-}
-
-if (window.testRunner) {
- testRunner.dumpAsText();
- testRunner.waitUntilDone();
-}
-
-if (window.eventSender) {
- doTest();
-}
-
</script>
+<script src=""
</body>
</html>
Modified: trunk/LayoutTests/fast/forms/resources/common-setrangetext.js (132598 => 132599)
--- trunk/LayoutTests/fast/forms/resources/common-setrangetext.js 2012-10-26 10:09:01 UTC (rev 132598)
+++ trunk/LayoutTests/fast/forms/resources/common-setrangetext.js 2012-10-26 10:18:15 UTC (rev 132599)
@@ -145,7 +145,10 @@
document.body.appendChild(element);
debug("<hr>");
debug("Running tests on " + tagName + " with attributes: " + JSON.stringify(attributes) + "\n");
- evalAndLog("element.value = '0123456789XYZ'");
+ if (element.getAttribute("type") == "file")
+ shouldThrow("element.value = '0123456789XYZ'");
+ else
+ evalAndLog("element.value = '0123456789XYZ'");
var initialValue = element.value;
shouldThrow("element.setRangeText('ABC', 0, 0)");
// setRangeText() shouldn't do anything on non-text form controls.
Modified: trunk/Source/WebCore/ChangeLog (132598 => 132599)
--- trunk/Source/WebCore/ChangeLog 2012-10-26 10:09:01 UTC (rev 132598)
+++ trunk/Source/WebCore/ChangeLog 2012-10-26 10:18:15 UTC (rev 132599)
@@ -1,3 +1,23 @@
+2012-10-26 Li Yin <[email protected]>
+
+ fast/forms/file/input-file-write-files.html should cover correct setting value
+ https://bugs.webkit.org/show_bug.cgi?id=100085
+
+ Reviewed by Kentaro Hara.
+
+ From Spec: http://dev.w3.org/html5/spec/single-page.html#dom-input-value-filename
+ On setting, if the new value is the empty string, it must empty the list of selected
+ files; otherwise, it must throw an InvalidStateError exception.
+
+ Test: fast/forms/file/input-file-value.html
+
+ * html/HTMLInputElement.cpp:
+ (WebCore::HTMLInputElement::setValue):
+ (WebCore):
+ * html/HTMLInputElement.h:
+ (HTMLInputElement):
+ * html/HTMLInputElement.idl:
+
2012-10-26 Keishi Hattori <[email protected]>
Refactor calendar picker to remove _x/_y from DaysTable
Modified: trunk/Source/WebCore/html/HTMLInputElement.cpp (132598 => 132599)
--- trunk/Source/WebCore/html/HTMLInputElement.cpp 2012-10-26 10:09:01 UTC (rev 132598)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp 2012-10-26 10:18:15 UTC (rev 132599)
@@ -1006,6 +1006,15 @@
dispatchInputEvent();
}
+void HTMLInputElement::setValue(const String& value, ExceptionCode& ec, TextFieldEventBehavior eventBehavior)
+{
+ if (isFileUpload() && !value.isEmpty()) {
+ ec = INVALID_STATE_ERR;
+ return;
+ }
+ setValue(value, eventBehavior);
+}
+
void HTMLInputElement::setValue(const String& value, TextFieldEventBehavior eventBehavior)
{
if (!m_inputType->canSetValue(value))
Modified: trunk/Source/WebCore/html/HTMLInputElement.h (132598 => 132599)
--- trunk/Source/WebCore/html/HTMLInputElement.h 2012-10-26 10:09:01 UTC (rev 132598)
+++ trunk/Source/WebCore/html/HTMLInputElement.h 2012-10-26 10:18:15 UTC (rev 132599)
@@ -148,6 +148,7 @@
void setType(const String&);
String value() const;
+ void setValue(const String&, ExceptionCode&, TextFieldEventBehavior = DispatchNoEvent);
void setValue(const String&, TextFieldEventBehavior = DispatchNoEvent);
void setValueForUser(const String&);
// Checks if the specified string would be a valid value.
Modified: trunk/Source/WebCore/html/HTMLInputElement.idl (132598 => 132599)
--- trunk/Source/WebCore/html/HTMLInputElement.idl 2012-10-26 10:09:01 UTC (rev 132598)
+++ trunk/Source/WebCore/html/HTMLInputElement.idl 2012-10-26 10:18:15 UTC (rev 132599)
@@ -56,7 +56,7 @@
[Reflect] attribute DOMString step;
[TreatNullAs=NullString] attribute DOMString type; // readonly dropped as part of DOM level 2
[TreatNullAs=NullString] attribute DOMString defaultValue;
- [TreatNullAs=NullString] attribute DOMString value;
+ [TreatNullAs=NullString] attribute DOMString value setter raises(DOMException);
#if !defined(LANGUAGE_CPP) || !LANGUAGE_CPP
attribute Date valueAsDate setter raises(DOMException);
#endif