Title: [252768] trunk
- Revision
- 252768
- Author
- [email protected]
- Date
- 2019-11-22 05:09:29 -0800 (Fri, 22 Nov 2019)
Log Message
File input should fire an 'input' event before the 'change' event
https://bugs.webkit.org/show_bug.cgi?id=204292
Reviewed by Wenson Hsieh.
Source/WebCore:
"Queue a task to first update the element's selected files so that it represents the user's selection, then fire
an event named input at the input element, with the bubbles attribute initialized to true, and finally fire an
event named change at the input element, with the bubbles attribute initialized to true."
https://html.spec.whatwg.org/#file-upload-state-(type=file):event-input
This will also fix WebDriver test imported/w3c/webdriver/tests/element_send_keys/events.py::test_file_upload in
safari driver.
Test: fast/forms/file/file-input-user-selection-events.html
* html/FileInputType.cpp:
(WebCore::FileInputType::setFiles):
LayoutTests:
Add new test to check both events are fired now.
* fast/forms/file/file-input-user-selection-events-expected.txt: Added.
* fast/forms/file/file-input-user-selection-events.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (252767 => 252768)
--- trunk/LayoutTests/ChangeLog 2019-11-22 11:32:43 UTC (rev 252767)
+++ trunk/LayoutTests/ChangeLog 2019-11-22 13:09:29 UTC (rev 252768)
@@ -1,3 +1,15 @@
+2019-11-22 Carlos Garcia Campos <[email protected]>
+
+ File input should fire an 'input' event before the 'change' event
+ https://bugs.webkit.org/show_bug.cgi?id=204292
+
+ Reviewed by Wenson Hsieh.
+
+ Add new test to check both events are fired now.
+
+ * fast/forms/file/file-input-user-selection-events-expected.txt: Added.
+ * fast/forms/file/file-input-user-selection-events.html: Added.
+
2019-11-21 Jer Noble <[email protected]>
Experimental support for HDR media query
Added: trunk/LayoutTests/fast/forms/file/file-input-user-selection-events-expected.txt (0 => 252768)
--- trunk/LayoutTests/fast/forms/file/file-input-user-selection-events-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/forms/file/file-input-user-selection-events-expected.txt 2019-11-22 13:09:29 UTC (rev 252768)
@@ -0,0 +1,16 @@
+OPEN FILE PANEL
+This tests the events dispatched on user selection
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+on input
+PASS inputDispatched is false
+PASS changeDispatched is false
+on change
+PASS inputDispatched is true
+PASS changeDispatched is false
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/forms/file/file-input-user-selection-events.html (0 => 252768)
--- trunk/LayoutTests/fast/forms/file/file-input-user-selection-events.html (rev 0)
+++ trunk/LayoutTests/fast/forms/file/file-input-user-selection-events.html 2019-11-22 13:09:29 UTC (rev 252768)
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+<input type="file" name="file" id="file">
+
+<script>
+description("This tests the events dispatched on user selection");
+
+if (window.testRunner) {
+ jsTestIsAsync = true;
+ var inputDispatched = false;
+ var changeDispatched = false;
+ var file = document.getElementById("file");
+ file.addEventListener("input", function() {
+ debug("on input");
+ shouldBe("inputDispatched", "false");
+ shouldBe("changeDispatched", "false");
+ inputDispatched = true;
+ });
+ file.addEventListener("change", function() {
+ debug("on change");
+ shouldBe("inputDispatched", "true");
+ shouldBe("changeDispatched", "false");
+ changeDispatched = true;
+
+ finishJSTest();
+ });
+
+ openFilesInElement(file, ["foo.txt"]);
+}
+
+function openFilesInElement(input, files) {
+ testRunner.setOpenPanelFiles(files);
+ var centerX = input.offsetLeft + input.offsetWidth / 2;
+ var centerY = input.offsetTop + input.offsetHeight / 2;
+ UIHelper.activateAt(centerX, centerY);
+}
+</script>
+<script src=""
+</body>
+</html>
Modified: trunk/LayoutTests/platform/win/TestExpectations (252767 => 252768)
--- trunk/LayoutTests/platform/win/TestExpectations 2019-11-22 11:32:43 UTC (rev 252767)
+++ trunk/LayoutTests/platform/win/TestExpectations 2019-11-22 13:09:29 UTC (rev 252768)
@@ -3671,6 +3671,7 @@
editing/selection/character-granularity-selected-range-after-dismissing-selection.html [ Skip ]
fast/dom/FileList-iterator-using-open-panel.html [ Skip ]
fast/forms/file/file-input-reset-using-open-panel.html [ Skip ]
+fast/forms/file/file-input-user-selection-events.html [ Skip ]
fast/forms/file/file-reset-in-change-using-open-panel.html [ Skip ]
fast/forms/file/file-reset-in-change-using-open-panel-with-icon.html [ Skip ]
fast/forms/file/get-file-upload-using-open-panel.html [ Skip ]
Modified: trunk/LayoutTests/platform/wincairo/TestExpectations (252767 => 252768)
--- trunk/LayoutTests/platform/wincairo/TestExpectations 2019-11-22 11:32:43 UTC (rev 252767)
+++ trunk/LayoutTests/platform/wincairo/TestExpectations 2019-11-22 13:09:29 UTC (rev 252768)
@@ -761,6 +761,7 @@
fast/files/file-reader-directory-crash-using-open-panel.html [ Timeout ]
fast/files/filereader-zip-bundle-using-open-panel.html [ Timeout ]
fast/forms/file/file-input-reset-using-open-panel.html [ Timeout ]
+fast/forms/file/file-input-user-selection-events.html [ Timeout ]
fast/forms/file/entries-api/webkitdirectory-open-panel.html [ Timeout ]
fast/forms/file/file-reset-in-change-using-open-panel.html [ Timeout ]
fast/forms/file/file-reset-in-change-using-open-panel-with-icon.html [ Timeout ]
Modified: trunk/Source/WebCore/ChangeLog (252767 => 252768)
--- trunk/Source/WebCore/ChangeLog 2019-11-22 11:32:43 UTC (rev 252767)
+++ trunk/Source/WebCore/ChangeLog 2019-11-22 13:09:29 UTC (rev 252768)
@@ -1,3 +1,23 @@
+2019-11-22 Carlos Garcia Campos <[email protected]>
+
+ File input should fire an 'input' event before the 'change' event
+ https://bugs.webkit.org/show_bug.cgi?id=204292
+
+ Reviewed by Wenson Hsieh.
+
+ "Queue a task to first update the element's selected files so that it represents the user's selection, then fire
+ an event named input at the input element, with the bubbles attribute initialized to true, and finally fire an
+ event named change at the input element, with the bubbles attribute initialized to true."
+ https://html.spec.whatwg.org/#file-upload-state-(type=file):event-input
+
+ This will also fix WebDriver test imported/w3c/webdriver/tests/element_send_keys/events.py::test_file_upload in
+ safari driver.
+
+ Test: fast/forms/file/file-input-user-selection-events.html
+
+ * html/FileInputType.cpp:
+ (WebCore::FileInputType::setFiles):
+
2019-11-21 Jer Noble <[email protected]>
Experimental support for HDR media query
Modified: trunk/Source/WebCore/html/FileInputType.cpp (252767 => 252768)
--- trunk/Source/WebCore/html/FileInputType.cpp 2019-11-22 11:32:43 UTC (rev 252767)
+++ trunk/Source/WebCore/html/FileInputType.cpp 2019-11-22 13:09:29 UTC (rev 252768)
@@ -399,6 +399,7 @@
if (pathsChanged) {
// This call may cause destruction of this instance.
// input instance is safe since it is ref-counted.
+ protectedInputElement->dispatchInputEvent();
protectedInputElement->dispatchChangeEvent();
}
protectedInputElement->setChangedSinceLastFormControlChangeEvent(false);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes