Diff
Modified: trunk/LayoutTests/ChangeLog (213041 => 213042)
--- trunk/LayoutTests/ChangeLog 2017-02-27 09:45:10 UTC (rev 213041)
+++ trunk/LayoutTests/ChangeLog 2017-02-27 09:49:29 UTC (rev 213042)
@@ -1,5 +1,76 @@
2017-02-27 Andy Estes <[email protected]>
+ Add a way to test file input without relying on drag and drop
+ https://bugs.webkit.org/show_bug.cgi?id=168848
+ <rdar://problem/22258242>
+
+ Reviewed by Tim Horton.
+
+ Added versions of existing file input tests that use TestRunner.setOpenPanelFiles() instead
+ of EventSender.beginDragWithFiles().
+
+ * fast/dom/FileList-iterator-using-open-panel-expected.txt: Added.
+ * fast/dom/FileList-iterator-using-open-panel.html: Added.
+ * fast/files/apply-blob-url-to-img-using-open-panel-expected.txt: Added.
+ * fast/files/apply-blob-url-to-img-using-open-panel.html: Added.
+ * fast/files/apply-blob-url-to-xhr-using-open-panel-expected.txt: Added.
+ * fast/files/apply-blob-url-to-xhr-using-open-panel.html: Added.
+ * fast/files/file-list-test-using-open-panel-expected.txt: Added.
+ * fast/files/file-list-test-using-open-panel.html: Added.
+ * fast/files/file-reader-abort-using-open-panel-expected.txt: Added.
+ * fast/files/file-reader-abort-using-open-panel.html: Added.
+ * fast/files/file-reader-directory-crash-using-open-panel-expected.txt: Added.
+ * fast/files/file-reader-directory-crash-using-open-panel.html: Added.
+ * fast/files/filereader-zip-bundle-using-open-panel-expected.txt: Added.
+ * fast/files/filereader-zip-bundle-using-open-panel.html: Added.
+ * fast/forms/file/file-input-reset-using-open-panel-expected.html: Added.
+ * fast/forms/file/file-input-reset-using-open-panel.html: Added.
+ * fast/forms/file/file-reset-in-change-using-open-panel-expected.html: Added.
+ * fast/forms/file/file-reset-in-change-using-open-panel.html: Added.
+ * fast/forms/file/get-file-upload-using-open-panel-expected.txt: Added.
+ * fast/forms/file/get-file-upload-using-open-panel.html: Added.
+ * fast/forms/file/input-file-value-using-open-panel-expected.txt: Added.
+ * fast/forms/file/input-file-value-using-open-panel.html: Added.
+ * fast/forms/file/input-file-write-files-using-open-panel-expected.txt: Added.
+ * fast/forms/file/input-file-write-files-using-open-panel.html: Added.
+ * fast/history/page-cache-createObjectURL-using-open-panel-expected.txt: Added.
+ * fast/history/page-cache-createObjectURL-using-open-panel.html: Added.
+ * http/tests/local/blob/resources/hybrid-blob-util.js:
+ (this.setupForTests):
+ (this.runTestsWithDrag):
+ (this.runTestsWithOpenPanel):
+ (this.runTests):
+ * http/tests/local/blob/script-tests/send-hybrid-blob-using-open-panel.js: Added.
+ (runHybridBlobTest):
+ (runTests.F):
+ (runTests.D):
+ (runTests):
+ * http/tests/local/blob/send-hybrid-blob-using-open-panel-expected.txt: Added.
+ * http/tests/local/blob/send-hybrid-blob-using-open-panel.html: Added.
+ * http/tests/local/fileapi/file-last-modified-after-delete-using-open-panel-expected.txt: Added.
+ * http/tests/local/fileapi/file-last-modified-after-delete-using-open-panel.html: Added.
+ * http/tests/local/fileapi/file-last-modified-using-open-panel-expected.txt: Added.
+ * http/tests/local/fileapi/file-last-modified-using-open-panel.html: Added.
+ * http/tests/local/fileapi/resources/setup-file-input-element-for-drag.js:
+ (setFileInputChangeCallback):
+ * http/tests/local/fileapi/script-tests/file-last-modified-after-delete-using-open-panel.js: Added.
+ (onFileChange):
+ (runTest):
+ * http/tests/local/fileapi/script-tests/file-last-modified-using-open-panel.js: Added.
+ (onFileChange):
+ (runTest):
+ * http/tests/local/fileapi/upload-zip-bundle-as-blob-using-open-panel-expected.txt: Added.
+ * http/tests/local/fileapi/upload-zip-bundle-as-blob-using-open-panel.html: Added.
+ * http/tests/local/formdata/send-form-data-constructed-from-form-using-open-panel-expected.txt: Added.
+ * http/tests/local/formdata/send-form-data-constructed-from-form-using-open-panel.html: Added.
+ * http/tests/local/formdata/send-form-data-with-empty-file-filename-using-open-panel-expected.txt: Added.
+ * http/tests/local/formdata/send-form-data-with-empty-file-filename-using-open-panel.html: Added.
+ * media/video-src-blob-using-open-panel-expected.txt: Added.
+ * media/video-src-blob-using-open-panel.html: Added.
+ * platform/ios-simulator/TestExpectations:
+
+2017-02-27 Andy Estes <[email protected]>
+
Links cannot be activated when running Mobile Safari with external SDK build of WebKit for iOS Simulator
https://bugs.webkit.org/show_bug.cgi?id=141906
Modified: trunk/LayoutTests/accessibility/axpress-on-aria-button-expected.txt (213041 => 213042)
--- trunk/LayoutTests/accessibility/axpress-on-aria-button-expected.txt 2017-02-27 09:45:10 UTC (rev 213041)
+++ trunk/LayoutTests/accessibility/axpress-on-aria-button-expected.txt 2017-02-27 09:49:29 UTC (rev 213042)
@@ -1,3 +1,4 @@
+OPEN FILE PANEL
Upload
Upload
Modified: trunk/LayoutTests/accessibility/file-upload-button-with-axpress-expected.txt (213041 => 213042)
--- trunk/LayoutTests/accessibility/file-upload-button-with-axpress-expected.txt 2017-02-27 09:45:10 UTC (rev 213041)
+++ trunk/LayoutTests/accessibility/file-upload-button-with-axpress-expected.txt 2017-02-27 09:49:29 UTC (rev 213042)
@@ -1,3 +1,4 @@
+OPEN FILE PANEL
This tests that when AXPress is used DOMActivate will be handled by the input file type.
Added: trunk/LayoutTests/fast/dom/FileList-iterator-using-open-panel-expected.txt (0 => 213042)
--- trunk/LayoutTests/fast/dom/FileList-iterator-using-open-panel-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/dom/FileList-iterator-using-open-panel-expected.txt 2017-02-27 09:49:29 UTC (rev 213042)
@@ -0,0 +1,18 @@
+OPEN FILE PANEL
+
+Tests that FileList objects have an iterator.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS fileList.__proto__ is FileList.prototype
+PASS Symbol.iterator in fileList is true
+PASS forOfSucceeded is true
+PASS 'entries' in fileList is false
+PASS 'keys' in fileList is false
+PASS 'forEach' in fileList is false
+PASS 'values' in fileList is false
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/dom/FileList-iterator-using-open-panel.html (0 => 213042)
--- trunk/LayoutTests/fast/dom/FileList-iterator-using-open-panel.html (rev 0)
+++ trunk/LayoutTests/fast/dom/FileList-iterator-using-open-panel.html 2017-02-27 09:49:29 UTC (rev 213042)
@@ -0,0 +1,51 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<script src=""
+<script src=""
+</head>
+<body>
+<input type="file" _onchange_="changed(event)"></input>
+<div id="console"></div>
+<script>
+description("Tests that FileList objects have an iterator.");
+jsTestIsAsync = true;
+
+function runTest()
+{
+ testRunner.setOpenPanelFiles(['test.txt']);
+
+ var inputElement = document.getElementsByTagName('input')[0];
+ UIHelper.activateAt(inputElement.offsetLeft + inputElement.offsetWidth / 2,
+ inputElement.offsetTop + inputElement.offsetHeight / 2);
+}
+
+function changed(event)
+{
+ fileList = event.target.files;
+ shouldBe("fileList.__proto__", "FileList.prototype");
+ shouldBeTrue("Symbol.iterator in fileList");
+ forOfSucceeded = false;
+ try {
+ for (var file of fileList) { }
+ forOfSucceeded = true;
+ } catch (e) {
+ forOfSucceeded = false;
+ }
+ shouldBeTrue("forOfSucceeded");
+
+ shouldBeFalse("'entries' in fileList");
+ shouldBeFalse("'keys' in fileList");
+ shouldBeFalse("'forEach' in fileList");
+ shouldBeFalse("'values' in fileList");
+
+ finishJSTest();
+}
+
+runTest();
+
+</script>
+<script src=""
+</body>
+</html>
Modified: trunk/LayoutTests/fast/events/domactivate-sets-underlying-click-event-as-handled-expected.txt (213041 => 213042)
--- trunk/LayoutTests/fast/events/domactivate-sets-underlying-click-event-as-handled-expected.txt 2017-02-27 09:45:10 UTC (rev 213041)
+++ trunk/LayoutTests/fast/events/domactivate-sets-underlying-click-event-as-handled-expected.txt 2017-02-27 09:49:29 UTC (rev 213042)
@@ -1,3 +1,5 @@
+OPEN FILE PANEL
+OPEN FILE PANEL
To test manually, click on all the form elements (except the textbox) and the details/summary element. The anchor shouldn't be activated (i.e. you shouldn't see any "anchor activated" messages).
Focusing [object HTMLInputElement] type=text and pressing enter
Added: trunk/LayoutTests/fast/files/apply-blob-url-to-img-using-open-panel-expected.txt (0 => 213042)
--- trunk/LayoutTests/fast/files/apply-blob-url-to-img-using-open-panel-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/files/apply-blob-url-to-img-using-open-panel-expected.txt 2017-02-27 09:49:29 UTC (rev 213042)
@@ -0,0 +1,6 @@
+OPEN FILE PANEL
+
+Old image: 0 x 0
+New image: 76 x 103
+DONE
+
Added: trunk/LayoutTests/fast/files/apply-blob-url-to-img-using-open-panel.html (0 => 213042)
--- trunk/LayoutTests/fast/files/apply-blob-url-to-img-using-open-panel.html (rev 0)
+++ trunk/LayoutTests/fast/files/apply-blob-url-to-img-using-open-panel.html 2017-02-27 09:49:29 UTC (rev 213042)
@@ -0,0 +1,50 @@
+<!DOCTYPE html>
+<html>
+<script src=""
+<body>
+<input type="file" name="file" id="file" _onchange_="onInputFileChange()">
+<img id='imgToReplace' src=''>
+<pre id='console'></pre>
+
+<script>
+function log(message)
+{
+ document.getElementById('console').appendChild(document.createTextNode(message + "\n"));
+}
+
+function onInputFileChange()
+{
+ var file = document.getElementById("file").files[0];
+ var img = document.getElementById('imgToReplace');
+ log("Old image: " + img.width + " x " + img.height);
+ img._onload_ = onImgLoad;
+ img.src = ""
+}
+
+function onImgLoad()
+{
+ var img = document.getElementById('imgToReplace');
+ log("New image: " + img.width + " x " + img.height);
+ log("DONE");
+ if (testRunner.notifyDone)
+ testRunner.notifyDone();
+}
+
+function runTests()
+{
+ testRunner.setOpenPanelFiles(['resources/abe.png']);
+
+ var element = document.getElementById('file');
+ var x = element.offsetLeft + element.offsetWidth / 2;
+ var y = element.offsetTop + element.offsetHeight / 2;
+ UIHelper.activateAt(x, y);
+}
+
+if (window.eventSender) {
+ testRunner.dumpAsText();
+ testRunner.waitUntilDone();
+ window._onload_ = runTests;
+}
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/fast/files/apply-blob-url-to-xhr-using-open-panel-expected.txt (0 => 213042)
--- trunk/LayoutTests/fast/files/apply-blob-url-to-xhr-using-open-panel-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/files/apply-blob-url-to-xhr-using-open-panel-expected.txt 2017-02-27 09:49:29 UTC (rev 213042)
@@ -0,0 +1,11 @@
+OPEN FILE PANEL
+
+Test that XMLHttpRequest GET succeeds.
+Status: 200
+Response: Hello
+Test that XMLHttpRequest POST fails.
+Received exception 19: NetworkError
+Test that XMLHttpRequest GET fails after the blob URL is revoked.
+Received exception 19: NetworkError
+DONE
+
Added: trunk/LayoutTests/fast/files/apply-blob-url-to-xhr-using-open-panel.html (0 => 213042)
--- trunk/LayoutTests/fast/files/apply-blob-url-to-xhr-using-open-panel.html (rev 0)
+++ trunk/LayoutTests/fast/files/apply-blob-url-to-xhr-using-open-panel.html 2017-02-27 09:49:29 UTC (rev 213042)
@@ -0,0 +1,64 @@
+<!DOCTYPE html>
+<html>
+<script src=""
+<body>
+<input type="file" name="file" id="file" _onchange_="onInputFileChange()">
+<pre id='console'></pre>
+
+<script>
+function log(message)
+{
+ document.getElementById('console').appendChild(document.createTextNode(message + "\n"));
+}
+
+function sendXMLHttpRequest(method, url)
+{
+ var xhr = new XMLHttpRequest();
+ xhr.open(method, url, false);
+ try {
+ xhr.send();
+ log("Status: " + xhr.status);
+ log("Response: " + xhr.responseText);
+ } catch (error) {
+ log("Received exception " + error.code + ": " + error.name);
+ }
+}
+
+function onInputFileChange()
+{
+ var file = document.getElementById("file").files[0];
+ var fileURL = window.URL.createObjectURL(file);
+
+ log("Test that XMLHttpRequest GET succeeds.");
+ sendXMLHttpRequest("GET", fileURL);
+
+ log("Test that XMLHttpRequest POST fails.");
+ sendXMLHttpRequest("POST", fileURL);
+
+ log("Test that XMLHttpRequest GET fails after the blob URL is revoked.");
+ window.URL.revokeObjectURL(fileURL);
+ sendXMLHttpRequest("GET", fileURL);
+
+ log("DONE");
+ if (testRunner.notifyDone)
+ testRunner.notifyDone();
+}
+
+function runTests()
+{
+ testRunner.setOpenPanelFiles(['resources/UTF8.txt']);
+
+ var inputElement = document.getElementById("file");
+ var centerX = inputElement.offsetLeft + inputElement.offsetWidth / 2;
+ var centerY = inputElement.offsetTop + inputElement.offsetHeight / 2;
+ UIHelper.activateAt(centerX, centerY);
+}
+
+if (window.eventSender) {
+ testRunner.dumpAsText();
+ testRunner.waitUntilDone();
+ window._onload_ = runTests;
+}
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/fast/files/file-list-test-using-open-panel-expected.txt (0 => 213042)
--- trunk/LayoutTests/fast/files/file-list-test-using-open-panel-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/files/file-list-test-using-open-panel-expected.txt 2017-02-27 09:49:29 UTC (rev 213042)
@@ -0,0 +1,26 @@
+OPEN FILE PANEL
+
+Test the attribute of FileList.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+Start
+PASS files.length is 2
+PASS files.item(0) instanceof File is true
+PASS files.item(0).name is "UTF8.txt"
+PASS files.item(1) instanceof File is true
+PASS files.item(1).name is "UTF8-2.txt"
+PASS files.item(2) is null
+PASS files.item(-1) is null
+PASS files.item(0) === files.item(4294967296) is true
+PASS files.item(1) === files.item(4294967297) is true
+PASS files.item(2) === files.item(4294967298) is true
+PASS files.item(-1) === files.item(4294967295) is true
+PASS files.item(-4294967295) === files.item(1) is true
+PASS files.item(-4294967296) === files.item(0) is true
+PASS files.item(null) === files.item(0) is true
+PASS files.item(undefined) === files.item(0) is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/files/file-list-test-using-open-panel.html (0 => 213042)
--- trunk/LayoutTests/fast/files/file-list-test-using-open-panel.html (rev 0)
+++ trunk/LayoutTests/fast/files/file-list-test-using-open-panel.html 2017-02-27 09:49:29 UTC (rev 213042)
@@ -0,0 +1,48 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+<input type="file" id="file" multiple _onchange_="onInputFileChange(this.files)">
+<div id="description"></div>
+<div id="console"></div>
+<script>
+description("Test the attribute of FileList.");
+
+debug("Start");
+
+function onInputFileChange(files)
+{
+ window.files = files;
+ shouldBe("files.length", "2");
+ shouldBeTrue("files.item(0) instanceof File");
+ shouldBeEqualToString("files.item(0).name", "UTF8.txt");
+ shouldBeTrue("files.item(1) instanceof File");
+ shouldBeEqualToString("files.item(1).name", "UTF8-2.txt");
+ shouldBeNull("files.item(2)");
+ shouldBeNull("files.item(-1)");
+ shouldBeTrue("files.item(0) === files.item(4294967296)");
+ shouldBeTrue("files.item(1) === files.item(4294967297)");
+ shouldBeTrue("files.item(2) === files.item(4294967298)");
+ shouldBeTrue("files.item(-1) === files.item(4294967295)");
+ shouldBeTrue("files.item(-4294967295) === files.item(1)");
+ shouldBeTrue("files.item(-4294967296) === files.item(0)");
+ shouldBeTrue("files.item(null) === files.item(0)");
+ shouldBeTrue("files.item(undefined) === files.item(0)");
+ finishJSTest();
+}
+
+jsTestIsAsync = true;
+testRunner.setOpenPanelFiles(["resources/UTF8.txt", "resources/UTF8-2.txt"]);
+
+var inputElement = document.getElementById("file");
+var centerX = inputElement.offsetLeft + inputElement.offsetWidth / 2;
+var centerY = inputElement.offsetTop + inputElement.offsetHeight / 2;
+UIHelper.activateAt(centerX, centerY);
+
+</script>
+</body>
+<script src=""
+</html>
Added: trunk/LayoutTests/fast/files/file-reader-abort-using-open-panel-expected.txt (0 => 213042)
--- trunk/LayoutTests/fast/files/file-reader-abort-using-open-panel-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/files/file-reader-abort-using-open-panel-expected.txt 2017-02-27 09:49:29 UTC (rev 213042)
@@ -0,0 +1,9 @@
+OPEN FILE PANEL
+
+Test that FileReader.abort works.
+Received loadstart event
+Received error event: 3
+Received abort event
+Received loadend event
+DONE
+
Added: trunk/LayoutTests/fast/files/file-reader-abort-using-open-panel.html (0 => 213042)
--- trunk/LayoutTests/fast/files/file-reader-abort-using-open-panel.html (rev 0)
+++ trunk/LayoutTests/fast/files/file-reader-abort-using-open-panel.html 2017-02-27 09:49:29 UTC (rev 213042)
@@ -0,0 +1,59 @@
+<!DOCTYPE html>
+<html>
+<script src=""
+<body>
+<input type="file" name="file" id="file" _onchange_="onInputFileChange()">
+<pre id='console'></pre>
+
+<script>
+function log(message)
+{
+ document.getElementById('console').appendChild(document.createTextNode(message + "\n"));
+}
+
+function onInputFileChange()
+{
+ log("Test that FileReader.abort works.");
+
+ var file = document.getElementById("file").files[0];
+ var reader = new FileReader();
+ reader.readAsText(file);
+ reader._onloadstart_ = function() {
+ log("Received loadstart event");
+ reader.abort();
+ };
+ reader._onload_ = function() {
+ log("Received load event");
+ };
+ reader._onloadend_ = function() {
+ log("Received loadend event");
+ log("DONE");
+ if (testRunner.notifyDone)
+ testRunner.notifyDone();
+ };
+ reader._onabort_ = function() {
+ log("Received abort event");
+ };
+ reader._onerror_ = function(event) {
+ log("Received error event: " + event.target.error.code);
+ };
+}
+
+function runTests()
+{
+ testRunner.setOpenPanelFiles(['resources/UTF8.txt']);
+
+ var inputElement = document.getElementById("file");
+ var centerX = inputElement.offsetLeft + inputElement.offsetWidth / 2;
+ var centerY = inputElement.offsetTop + inputElement.offsetHeight / 2;
+ UIHelper.activateAt(centerX, centerY);
+}
+
+if (window.eventSender) {
+ testRunner.dumpAsText();
+ testRunner.waitUntilDone();
+ window._onload_ = runTests;
+}
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/fast/files/file-reader-directory-crash-using-open-panel-expected.txt (0 => 213042)
--- trunk/LayoutTests/fast/files/file-reader-directory-crash-using-open-panel-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/files/file-reader-directory-crash-using-open-panel-expected.txt 2017-02-27 09:49:29 UTC (rev 213042)
@@ -0,0 +1,3 @@
+OPEN FILE PANEL
+
+PASS, no crash
Added: trunk/LayoutTests/fast/files/file-reader-directory-crash-using-open-panel.html (0 => 213042)
--- trunk/LayoutTests/fast/files/file-reader-directory-crash-using-open-panel.html (rev 0)
+++ trunk/LayoutTests/fast/files/file-reader-directory-crash-using-open-panel.html 2017-02-27 09:49:29 UTC (rev 213042)
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+<script src=""
+<body>
+<input type=file id=file _onchange_='onInputFileChange()'>
+<p id=status>To test manually, drag a directory to the file input above.</p>
+<script>
+var input = document.getElementsByTagName("input")[0];
+var statusElement = document.getElementById("status");
+
+function onInputFileChange()
+{
+ var file = document.getElementById('file').files[0];
+ var reader = new FileReader();
+ statusElement.textContent = "Starting test...";
+ reader.readAsText(file);
+ reader._onloadend_ = function() {
+ statusElement.textContent = "PASS, no crash";
+ if (window.testRunner)
+ testRunner.notifyDone();
+ }
+}
+
+if (window.testRunner) {
+ testRunner.dumpAsText();
+ testRunner.waitUntilDone();
+}
+
+testRunner.setOpenPanelFiles(['resources']);
+UIHelper.activateAt(input.offsetLeft + 1, input.offsetTop + 1);
+
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/fast/files/filereader-zip-bundle-using-open-panel-expected.txt (0 => 213042)
--- trunk/LayoutTests/fast/files/filereader-zip-bundle-using-open-panel-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/files/filereader-zip-bundle-using-open-panel-expected.txt 2017-02-27 09:49:29 UTC (rev 213042)
@@ -0,0 +1,12 @@
+OPEN FILE PANEL
+Test that bundles are automatically zipped when accessed via FileReader. To test manually, please select a bundle in the "Choose File" input below.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS file.size > 400 is true
+PASS reader.result is 'PK'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/files/filereader-zip-bundle-using-open-panel.html (0 => 213042)
--- trunk/LayoutTests/fast/files/filereader-zip-bundle-using-open-panel.html (rev 0)
+++ trunk/LayoutTests/fast/files/filereader-zip-bundle-using-open-panel.html 2017-02-27 09:49:29 UTC (rev 213042)
@@ -0,0 +1,51 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<script src=""
+<script src=""
+</head>
+<body>
+<div id=description></div>
+<input type=file id=fileTarget></div>
+<div id=console></div>
+<script>
+if (window.testRunner)
+ testRunner.dumpAsText();
+
+description("Test that bundles are automatically zipped when accessed via FileReader. To test manually, please select a bundle in the \"Choose File\" input below.");
+jsTestIsAsync = true;
+
+window._onload_ = function()
+{
+ var fileTarget = document.getElementById("fileTarget");
+
+ fileTarget.addEventListener("change", onchange, true);
+
+ if (!window.UIHelper || !window.testRunner)
+ return;
+
+ var x = fileTarget.offsetLeft + fileTarget.offsetWidth / 2;
+ var y = fileTarget.offsetTop + fileTarget.offsetHeight / 2
+
+ testRunner.setOpenPanelFiles(["resources/document.rtfd"]);
+ UIHelper.activateAt(x, y);
+}
+
+function onchange(event)
+{
+ file = event.target.files.item(0);
+ // We used to report 102 for the size of this file, which presumably was directory node size.
+ // Archive is 528 bytes on a system I test with.
+ shouldBeTrue("file.size > 400");
+ reader = new FileReader;
+ reader.readAsText(file.slice(0, 2));
+ reader._onloadend_ = function() {
+ shouldBe("reader.result", "'PK'");
+ finishJSTest();
+ }
+}
+</script>
+<script src=""
+</body>
+</html>
Added: trunk/LayoutTests/fast/forms/file/file-input-reset-using-open-panel-expected.html (0 => 213042)
--- trunk/LayoutTests/fast/forms/file/file-input-reset-using-open-panel-expected.html (rev 0)
+++ trunk/LayoutTests/fast/forms/file/file-input-reset-using-open-panel-expected.html 2017-02-27 09:49:29 UTC (rev 213042)
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body>
+<form id="form">
+<input id="file" type="file" />
+<input id="reset" type="reset" />
+</form>
+<div id="console">C:\fakepath\foo.txt is selected.</div>
+<p>
+This tests whether the label next to the file chooser button becomes "No file chosen"
+when we press the reset button.
+To run this test manually, choose a file and then click the reset button.
+If the label next to the file chooser button changes to "No file chosen", the test passes.
+</p>
+</body>
+</html>
Added: trunk/LayoutTests/fast/forms/file/file-input-reset-using-open-panel.html (0 => 213042)
--- trunk/LayoutTests/fast/forms/file/file-input-reset-using-open-panel.html (rev 0)
+++ trunk/LayoutTests/fast/forms/file/file-input-reset-using-open-panel.html 2017-02-27 09:49:29 UTC (rev 213042)
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<form id="form">
+<input id="file" type="file" />
+<input id="reset" type="reset" />
+</form>
+<div id="console"></div>
+<p>
+This tests whether the label next to the file chooser button becomes "No file chosen"
+when we press the reset button.
+To run this test manually, choose a file and then click the reset button.
+If the label next to the file chooser button changes to "No file chosen", the test passes.
+</p>
+<script>
+if (testRunner && eventSender) {
+ testRunner.waitUntilDone();
+ var file = document.getElementById("file");
+ var reset = document.getElementById("reset");
+
+ file.addEventListener("change", function() {
+ document.getElementById("console").innerHTML = file.value + " is selected.";
+ UIHelper.activateAt(reset.offsetLeft + reset.offsetWidth / 2, reset.offsetTop + reset.offsetHeight / 2).then(function() {
+ // Move a cursor out of the reset button.
+ UIHelper.activateAt(reset.offsetLeft + reset.offsetWidth + 10, reset.offsetTop + reset.offsetHeight + 10).then(function() {
+ testRunner.notifyDone();
+ });
+ });
+ });
+
+ openFilesInElement(file, ["foo.txt"]);
+}
+
+function openFilesInElement(element, files) {
+ testRunner.setOpenPanelFiles(files);
+ var centerX = element.offsetLeft + element.offsetWidth / 2;
+ var centerY = element.offsetTop + element.offsetHeight / 2;
+ UIHelper.activateAt(centerX, centerY);
+}
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/fast/forms/file/file-reset-in-change-using-open-panel-expected.html (0 => 213042)
--- trunk/LayoutTests/fast/forms/file/file-reset-in-change-using-open-panel-expected.html (rev 0)
+++ trunk/LayoutTests/fast/forms/file/file-reset-in-change-using-open-panel-expected.html 2017-02-27 09:49:29 UTC (rev 213042)
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<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>
+</body>
Added: trunk/LayoutTests/fast/forms/file/file-reset-in-change-using-open-panel.html (0 => 213042)
--- trunk/LayoutTests/fast/forms/file/file-reset-in-change-using-open-panel.html (rev 0)
+++ trunk/LayoutTests/fast/forms/file/file-reset-in-change-using-open-panel.html 2017-02-27 09:49:29 UTC (rev 213042)
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<script src=""
+<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 openFilesInElement(element, files) {
+ testRunner.setOpenPanelFiles(files);
+ var centerX = element.offsetLeft + element.offsetWidth / 2;
+ var centerY = element.offsetTop + element.offsetHeight / 2;
+ UIHelper.activateAt(centerX, centerY);
+}
+
+function handleChange() {
+ file1.value = '';
+ UIHelper.activateAt(1, 1).then(function() {
+ testRunner.notifyDone();
+ });
+}
+
+if (window.testRunner)
+ testRunner.waitUntilDone();
+
+var file1 = document.getElementById('file1');
+file1.addEventListener('change', handleChange);
+openFilesInElement(file1, ['foo.txt']);
+</script>
+</body>
Added: trunk/LayoutTests/fast/forms/file/get-file-upload-using-open-panel-expected.txt (0 => 213042)
--- trunk/LayoutTests/fast/forms/file/get-file-upload-using-open-panel-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/forms/file/get-file-upload-using-open-panel-expected.txt 2017-02-27 09:49:29 UTC (rev 213042)
@@ -0,0 +1,4 @@
+OPEN FILE PANEL
+
+PASS: ?file=get-file-upload.html&submitted=true
+
Added: trunk/LayoutTests/fast/forms/file/get-file-upload-using-open-panel.html (0 => 213042)
--- trunk/LayoutTests/fast/forms/file/get-file-upload-using-open-panel.html (rev 0)
+++ trunk/LayoutTests/fast/forms/file/get-file-upload-using-open-panel.html 2017-02-27 09:49:29 UTC (rev 213042)
@@ -0,0 +1,48 @@
+<!DOCTYPE html>
+<html>
+<script src=""
+<body>
+<form method="GET" action="" enctype="application/x-www-form-urlencoded">
+ <input type="file" name="file" id="file">
+ <input type="hidden" name="submitted" value="true">
+</form>
+<pre id='console'></pre>
+
+<script>
+function log(message)
+{
+ document.getElementById('console').appendChild(document.createTextNode(message + "\n"));
+}
+
+function startOrVerify()
+{
+ var query = window.location.search;
+ if (query.indexOf('submitted=true') != -1) {
+ // Verify the result
+ if (query.indexOf('file=') != -1)
+ log('PASS: ' + query);
+ else
+ log('FAIL: ' + query);
+ testRunner.notifyDone();
+ } else {
+ // Start the test
+ testRunner.setOpenPanelFiles(['get-file-upload.html']);
+ document.getElementById('file').addEventListener('change', function() {
+ document.forms[0].submit();
+ });
+
+ var inputElement = document.getElementById("file");
+ var centerX = inputElement.offsetLeft + inputElement.offsetWidth / 2;
+ var centerY = inputElement.offsetTop + inputElement.offsetHeight / 2;
+ UIHelper.activateAt(centerX, centerY);
+ }
+}
+
+if (window.eventSender) {
+ testRunner.dumpAsText();
+ testRunner.waitUntilDone();
+ window._onload_ = startOrVerify;
+}
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/fast/forms/file/input-file-value-using-open-panel-expected.txt (0 => 213042)
--- trunk/LayoutTests/fast/forms/file/input-file-value-using-open-panel-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/forms/file/input-file-value-using-open-panel-expected.txt 2017-02-27 09:49:29 UTC (rev 213042)
@@ -0,0 +1,17 @@
+OPEN FILE PANEL
+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 InvalidStateError (DOM Exception 11): The object is in an invalid state..
+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-using-open-panel.html (0 => 213042)
--- trunk/LayoutTests/fast/forms/file/input-file-value-using-open-panel.html (rev 0)
+++ trunk/LayoutTests/fast/forms/file/input-file-value-using-open-panel.html 2017-02-27 09:49:29 UTC (rev 213042)
@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<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) {
+ jsTestIsAsync = true;
+ var file = document.getElementById("file");
+ file.addEventListener("change", function() {
+ 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");
+
+ 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>
Added: trunk/LayoutTests/fast/forms/file/input-file-write-files-using-open-panel-expected.txt (0 => 213042)
--- trunk/LayoutTests/fast/forms/file/input-file-write-files-using-open-panel-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/forms/file/input-file-write-files-using-open-panel-expected.txt 2017-02-27 09:49:29 UTC (rev 213042)
@@ -0,0 +1,18 @@
+OPEN FILE PANEL
+OPEN FILE PANEL
+This tests the files attribute in file input forms
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS file1.files = "foo" threw exception TypeError: The HTMLInputElement.files attribute must be an instance of FileList.
+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
+
Added: trunk/LayoutTests/fast/forms/file/input-file-write-files-using-open-panel.html (0 => 213042)
--- trunk/LayoutTests/fast/forms/file/input-file-write-files-using-open-panel.html (rev 0)
+++ trunk/LayoutTests/fast/forms/file/input-file-write-files-using-open-panel.html 2017-02-27 09:49:29 UTC (rev 213042)
@@ -0,0 +1,57 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+<input type="file" name="file1" id="file1">
+<input type="file" name="file2" id="file2">
+<script>
+description("This tests the files attribute in file input forms");
+
+if (window.testRunner) {
+ jsTestIsAsync = true;
+
+ var file1 = document.getElementById("file1");
+ var file2 = document.getElementById("file2");
+
+ file1.addEventListener("change", function() {
+ file2.addEventListener("change", function() {
+ runTest(file1, file2);
+ finishJSTest();
+ });
+ window.setTimeout(function() {
+ dragFilesOntoInput(file2, ["bar.txt"]);
+ }, 0);
+ });
+ dragFilesOntoInput(file1, ["foo.txt"]);
+}
+
+function runTest(file1, file2) {
+ shouldThrow('file1.files = "foo"');
+ shouldBe("file1.files.length", "1");
+ shouldBeEqualToString("file1.files.item(0).name", "foo.txt");
+
+ file1.files = null;
+ shouldBe("file1.files.length", "1");
+ shouldBeEqualToString("file1.files.item(0).name", "foo.txt");
+
+ // 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 dragFilesOntoInput(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>
Added: trunk/LayoutTests/fast/history/page-cache-createObjectURL-using-open-panel-expected.txt (0 => 213042)
--- trunk/LayoutTests/fast/history/page-cache-createObjectURL-using-open-panel-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/history/page-cache-createObjectURL-using-open-panel-expected.txt 2017-02-27 09:49:29 UTC (rev 213042)
@@ -0,0 +1,22 @@
+OPEN FILE PANEL
+Tests that a page calling URL.createObjectURL() can use the page cache.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS img.width is 0
+PASS img.height is 0
+img.src = ""
+PASS Image loaded
+PASS img.width is 76
+PASS img.height is 103
+PASS Page did enter and was restored from the page cache
+Reuse the previous blobURL
+img2.src = ""
+PASS Image2 loaded
+PASS img2.width is 76
+PASS img2.height is 103
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/history/page-cache-createObjectURL-using-open-panel.html (0 => 213042)
--- trunk/LayoutTests/fast/history/page-cache-createObjectURL-using-open-panel.html (rev 0)
+++ trunk/LayoutTests/fast/history/page-cache-createObjectURL-using-open-panel.html 2017-02-27 09:49:29 UTC (rev 213042)
@@ -0,0 +1,80 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<script src=""
+
+<input type="file" name="file" id="file" _onchange_="onInputFileChange()"/>
+<img id='imgToReplace1' src=''/>
+<img id='imgToReplace2' src=''/>
+
+<script>
+description('Tests that a page calling URL.createObjectURL() can use the page cache.');
+window.jsTestIsAsync = true;
+var blobURL = null;
+
+if (window.testRunner)
+ window.testRunner.overridePreference("WebKitUsesPageCachePreferenceKey", 1);
+
+function onInputFileChange()
+{
+ var file = document.getElementById("file").files[0];
+ img = document.getElementById('imgToReplace1');
+ shouldBe("img.width", "0");
+ shouldBe("img.height", "0");
+ img._onload_ = onImgLoad;
+ blobURL = URL.createObjectURL(file);
+ evalAndLog("img.src = ""
+}
+
+function onImgLoad()
+{
+ img = document.getElementById('imgToReplace1');
+ testPassed("Image loaded");
+ shouldBe("img.width", "76");
+ shouldBe("img.height", "103");
+
+ // Force a back navigation back to this page.
+ window.location.href = ""
+}
+
+function onImg2Load()
+{
+ img2 = document.getElementById('imgToReplace2');
+ testPassed("Image2 loaded");
+ shouldBe("img2.width", "76");
+ shouldBe("img2.height", "103");
+
+ finishJSTest();
+}
+
+window.addEventListener("pageshow", function(event) {
+ if (event.persisted) {
+ testPassed("Page did enter and was restored from the page cache");
+
+ debug("Reuse the previous blobURL");
+ img2 = document.getElementById('imgToReplace2');
+ img2._onload_ = onImg2Load;
+ evalAndLog("img2.src = ""
+ }
+}, false);
+
+window.addEventListener("pagehide", function(event) {
+ if (!event.persisted) {
+ testFailed("Page did not enter the page cache.");
+ finishJSTest();
+ }
+}, false);
+
+window.addEventListener('load', function() {
+ testRunner.setOpenPanelFiles(['../files/resources/abe.png']);
+ var element = document.getElementById('file');
+ var centerX = element.offsetLeft + element.offsetWidth / 2;
+ var centerY = element.offsetTop + element.offsetHeight / 2;
+ UIHelper.activateAt(centerX, centerY);
+}, false);
+
+</script>
+<script src=""
+</body>
+</html>
Modified: trunk/LayoutTests/http/tests/local/blob/resources/hybrid-blob-util.js (213041 => 213042)
--- trunk/LayoutTests/http/tests/local/blob/resources/hybrid-blob-util.js 2017-02-27 09:45:10 UTC (rev 213041)
+++ trunk/LayoutTests/http/tests/local/blob/resources/hybrid-blob-util.js 2017-02-27 09:49:29 UTC (rev 213042)
@@ -1,7 +1,8 @@
-var HybridBlobTestUtil = function(testFunc, opt_filePaths) {
+var HybridBlobTestUtil = function(testFunc, opt_filePaths, opt_useOpenPanel) {
this.testCallbackFunc = testFunc;
this.testFilePaths = opt_filePaths;
+ this.testUseOpenPanel = opt_useOpenPanel;
this.testFiles = [];
this.testFileMap = {};
this.fileInput = null;
@@ -49,7 +50,7 @@
this.testCallbackFunc();
};
- this.runTestsWithDrag = function()
+ this.setupForTests = function()
{
this.fileInput = document.createElement("input");
this.fileInput.id = "file";
@@ -68,19 +69,34 @@
}
this.testFilePaths = filePaths;
}
+ };
+ this.runTestsWithDrag = function()
+ {
+ this.setupForTests();
+
eventSender.beginDragWithFiles(this.testFilePaths);
eventSender.mouseMoveTo(10, 10);
eventSender.mouseUp();
};
+ this.runTestsWithOpenPanel = function()
+ {
+ this.setupForTests();
+
+ testRunner.setOpenPanelFiles(this.testFilePaths);
+ UIHelper.activateAt(10, 10);
+ };
+
this.runTests = function() {
if (!this.testCallbackFunc)
testFailed("Test body function is not initialized.");
- else if (this.testFilePaths)
+ else if (!this.testFilePaths)
+ this.testCallbackFunc();
+ else if (this.testUseOpenPanel)
+ this.runTestsWithOpenPanel();
+ else
this.runTestsWithDrag();
- else
- this.testCallbackFunc();
};
this.FileItem = function(path)
Added: trunk/LayoutTests/http/tests/local/blob/script-tests/send-hybrid-blob-using-open-panel.js (0 => 213042)
--- trunk/LayoutTests/http/tests/local/blob/script-tests/send-hybrid-blob-using-open-panel.js (rev 0)
+++ trunk/LayoutTests/http/tests/local/blob/script-tests/send-hybrid-blob-using-open-panel.js 2017-02-27 09:49:29 UTC (rev 213042)
@@ -0,0 +1,95 @@
+description("Test for building blobs with multiple files combined by BlobBuilder and sending them via XMLHttpRequest.");
+
+var testFilePaths = [
+ "nonexistent",
+ "empty.txt",
+ "file-for-drag-to-send.txt",
+ "file-for-drag-to-send2.txt",
+ "abe.png"
+];
+
+var util = new HybridBlobTestUtil(runTests, testFilePaths, true /* use open panel */);
+util.dragBaseDir = "../resources/";
+util.urlPathBaseDir = "../local/resources/";
+
+function runHybridBlobTest(fileIndexOrStrings, opt_range)
+{
+ var blob = util.appendAndCreateBlob(fileIndexOrStrings);
+ var urlParameter = util.createUrlParameter(fileIndexOrStrings, opt_range);
+ if (opt_range)
+ blob = blob.slice(opt_range.start, opt_range.start + opt_range.length);
+ util.uploadBlob(blob, urlParameter);
+}
+
+function runTests()
+{
+ // Syntax sugar.
+ var F = function(path) { return util.FileItem(path); }
+ var D = function(data) { return util.DataItem(data); }
+
+ debug('* BlobBuilder.append(file) - single file');
+ for (var i = 0; i < testFilePaths.length; i++)
+ runHybridBlobTest(F(testFilePaths[i]));
+
+ debug('* BlobBuilder.append(file) - multiple files');
+ runHybridBlobTest([ F('nonexistent'),
+ F('empty.txt')]);
+ runHybridBlobTest([ F('empty.txt'),
+ F('file-for-drag-to-send.txt') ]);
+ runHybridBlobTest([ F('empty.txt'),
+ F('file-for-drag-to-send.txt'),
+ F('file-for-drag-to-send2.txt') ]);
+ runHybridBlobTest([ F('file-for-drag-to-send2.txt'),
+ F('file-for-drag-to-send2.txt') ]);
+
+ debug('* BlobBuilder.append(mixed)');
+ runHybridBlobTest([ [ F('empty.txt') ] ]);
+ runHybridBlobTest([ [ F('empty.txt'),
+ F('file-for-drag-to-send.txt') ],
+ F('file-for-drag-to-send2.txt') ]);
+ runHybridBlobTest([ D('abcde'),
+ F('file-for-drag-to-send2.txt'),
+ D('|123|456|') ]);
+ runHybridBlobTest([ F('empty.txt'),
+ D('13579'),
+ [ F('file-for-drag-to-send2.txt'),
+ F('file-for-drag-to-send.txt') ],
+ F('file-for-drag-to-send.txt'),
+ D('A_B_C_D_E')]);
+
+ debug('* BlobBuilder.append(mixed) - with Blob.slice()');
+ runHybridBlobTest([ F('file-for-drag-to-send.txt') ],
+ { 'start': 5, 'length': 10 });
+ runHybridBlobTest([ [ F('file-for-drag-to-send2.txt') ] ],
+ { 'start': 3, 'length': 17 });
+ runHybridBlobTest([ F('file-for-drag-to-send.txt'),
+ F('file-for-drag-to-send2.txt') ],
+ { 'start': 3, 'length': 17 });
+ runHybridBlobTest([ F('file-for-drag-to-send2.txt'),
+ D('abcde'),
+ F('file-for-drag-to-send2.txt') ],
+ { 'start': 3, 'length': 17 });
+ runHybridBlobTest([ F('file-for-drag-to-send2.txt'),
+ D('abcde'),
+ F('file-for-drag-to-send2.txt') ],
+ { 'start': 33, 'length': 90 });
+ runHybridBlobTest([ F('file-for-drag-to-send2.txt'),
+ F('file-for-drag-to-send.txt'),
+ F('file-for-drag-to-send2.txt') ],
+ { 'start': 33, 'length': 42 });
+ runHybridBlobTest([ F('empty.txt'),
+ F('file-for-drag-to-send.txt'),
+ F('file-for-drag-to-send2.txt'),
+ F('abe.png') ],
+ { 'start': 20, 'length': 3000 });
+
+ finishJSTest();
+}
+
+if (window.testRunner) {
+ jsTestIsAsync = true;
+ util.runTests();
+} else
+ testFailed("This test is not interactive, please run using a test harness.");
+
+var successfullyParsed = true;
Added: trunk/LayoutTests/http/tests/local/blob/send-hybrid-blob-using-open-panel-expected.txt (0 => 213042)
--- trunk/LayoutTests/http/tests/local/blob/send-hybrid-blob-using-open-panel-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/local/blob/send-hybrid-blob-using-open-panel-expected.txt 2017-02-27 09:49:29 UTC (rev 213042)
@@ -0,0 +1,35 @@
+OPEN FILE PANEL
+
+Test for building blobs with multiple files combined by BlobBuilder and sending them via XMLHttpRequest.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+* BlobBuilder.append(file) - single file
+PASS Expected response data received: OK
+PASS Expected response data received: OK
+PASS Expected response data received: OK
+PASS Expected response data received: OK
+PASS Expected response data received: OK
+* BlobBuilder.append(file) - multiple files
+PASS Expected response data received: OK
+PASS Expected response data received: OK
+PASS Expected response data received: OK
+PASS Expected response data received: OK
+* BlobBuilder.append(mixed)
+PASS Expected response data received: OK
+PASS Expected response data received: OK
+PASS Expected response data received: OK
+PASS Expected response data received: OK
+* BlobBuilder.append(mixed) - with Blob.slice()
+PASS Expected response data received: OK
+PASS Expected response data received: OK
+PASS Expected response data received: OK
+PASS Expected response data received: OK
+PASS Expected response data received: OK
+PASS Expected response data received: OK
+PASS Expected response data received: OK
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/http/tests/local/blob/send-hybrid-blob-using-open-panel.html (0 => 213042)
--- trunk/LayoutTests/http/tests/local/blob/send-hybrid-blob-using-open-panel.html (rev 0)
+++ trunk/LayoutTests/http/tests/local/blob/send-hybrid-blob-using-open-panel.html 2017-02-27 09:49:29 UTC (rev 213042)
@@ -0,0 +1,14 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src=""
+<script src=""
+<script src=""
+</body>
+</html>
Added: trunk/LayoutTests/http/tests/local/fileapi/file-last-modified-after-delete-using-open-panel-expected.txt (0 => 213042)
--- trunk/LayoutTests/http/tests/local/fileapi/file-last-modified-after-delete-using-open-panel-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/local/fileapi/file-last-modified-after-delete-using-open-panel-expected.txt 2017-02-27 09:49:29 UTC (rev 213042)
@@ -0,0 +1,14 @@
+OPEN FILE PANEL
+Test File.lastModifiedDate returns null if the information is not available.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS event.target.files contains a File object.
+PASS lastModified is not null
+PASS lastModified is >= testStartTime.getTime()
+PASS (new Date()).getTime() is >= lastModified
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/http/tests/local/fileapi/file-last-modified-after-delete-using-open-panel.html (0 => 213042)
--- trunk/LayoutTests/http/tests/local/fileapi/file-last-modified-after-delete-using-open-panel.html (rev 0)
+++ trunk/LayoutTests/http/tests/local/fileapi/file-last-modified-after-delete-using-open-panel.html 2017-02-27 09:49:29 UTC (rev 213042)
@@ -0,0 +1,15 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src=""
+<script src=""
+<script src=""
+<script src=""
+</body>
+</html>
Copied: trunk/LayoutTests/http/tests/local/fileapi/file-last-modified-using-open-panel-expected.txt (from rev 213041, trunk/LayoutTests/platform/wk2/accessibility/file-upload-button-with-axpress-expected.txt) (0 => 213042)
--- trunk/LayoutTests/http/tests/local/fileapi/file-last-modified-using-open-panel-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/local/fileapi/file-last-modified-using-open-panel-expected.txt 2017-02-27 09:49:29 UTC (rev 213042)
@@ -0,0 +1,12 @@
+OPEN FILE PANEL
+Test File.lastModifiedDate.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS event.target.files contains a File object.
+PASS file.lastModified verified
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/http/tests/local/fileapi/file-last-modified-using-open-panel.html (0 => 213042)
--- trunk/LayoutTests/http/tests/local/fileapi/file-last-modified-using-open-panel.html (rev 0)
+++ trunk/LayoutTests/http/tests/local/fileapi/file-last-modified-using-open-panel.html 2017-02-27 09:49:29 UTC (rev 213042)
@@ -0,0 +1,14 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src=""
+<script src=""
+<script src=""
+</body>
+</html>
Modified: trunk/LayoutTests/http/tests/local/fileapi/resources/setup-file-input-element-for-drag.js (213041 => 213042)
--- trunk/LayoutTests/http/tests/local/fileapi/resources/setup-file-input-element-for-drag.js 2017-02-27 09:45:10 UTC (rev 213041)
+++ trunk/LayoutTests/http/tests/local/fileapi/resources/setup-file-input-element-for-drag.js 2017-02-27 09:49:29 UTC (rev 213042)
@@ -28,11 +28,27 @@
event.preventDefault();
}, false);
+var fileInputChangeCallback = null;
+fileInput.addEventListener("change", function() {
+ if (event.target.files.length == 1)
+ testPassed("event.target.files contains a File object.");
+ else
+ testPassed("event.target.files does not contain a File object.");
+
+ if (fileInputChangeCallback)
+ fileInputChangeCallback(event.target.files[0]);
+}, false);
+
function setFileInputDropCallback(fileInputDropCallbackFunc)
{
fileInputDropCallback = fileInputDropCallbackFunc;
}
+function setFileInputChangeCallback(fileInputChangeCallbackFunc)
+{
+ fileInputChangeCallback = fileInputChangeCallbackFunc;
+}
+
function moveMouseToCenterOfElement(element)
{
var centerX = element.offsetLeft + element.offsetWidth / 2;
Added: trunk/LayoutTests/http/tests/local/fileapi/script-tests/file-last-modified-after-delete-using-open-panel.js (0 => 213042)
--- trunk/LayoutTests/http/tests/local/fileapi/script-tests/file-last-modified-after-delete-using-open-panel.js (rev 0)
+++ trunk/LayoutTests/http/tests/local/fileapi/script-tests/file-last-modified-after-delete-using-open-panel.js 2017-02-27 09:49:29 UTC (rev 213042)
@@ -0,0 +1,48 @@
+description("Test File.lastModifiedDate returns null if the information is not available.");
+
+jsTestIsAsync = true;
+
+var tempFileContent = "1234567890";
+var tempFileName = "file-last-modified-after-delete.tmp";
+var testStartTime = new Date();
+var lastModified;
+
+function onFileChange(file)
+{
+ // Remove the temp file.
+ removeTempFile(tempFileName);
+
+ // This synchronosly queries the file's lastModified (which should fail) until/unless we start capturing the file metadata at File construction time.
+ lastModified = file.lastModified;
+
+ // The returned value should be equal to the current date/time since the file's modified date/time is not available.
+ shouldNotBe('lastModified', 'null');
+ shouldBeGreaterThanOrEqual('lastModified', 'testStartTime.getTime()');
+ shouldBeGreaterThanOrEqual('(new Date()).getTime()', 'lastModified');
+
+ // Clean up after ourselves
+ removeFileInputElement();
+
+ finishJSTest();
+}
+
+function runTest()
+{
+ var tempFilePath = createTempFile(tempFileName, tempFileContent);
+ if (tempFilePath.length == 0)
+ return;
+
+ setFileInputChangeCallback(onFileChange);
+ testRunner.setOpenPanelFiles([tempFilePath]);
+
+ var centerX = fileInput.offsetLeft + fileInput.offsetWidth / 2;
+ var centerY = fileInput.offsetTop + fileInput.offsetHeight / 2;
+ UIHelper.activateAt(centerX, centerY);
+}
+
+if (window.testRunner)
+ runTest();
+else
+ testFailed("This test is not interactive, please run using a test harness.");
+
+var successfullyParsed = true;
Added: trunk/LayoutTests/http/tests/local/fileapi/script-tests/file-last-modified-using-open-panel.js (0 => 213042)
--- trunk/LayoutTests/http/tests/local/fileapi/script-tests/file-last-modified-using-open-panel.js (rev 0)
+++ trunk/LayoutTests/http/tests/local/fileapi/script-tests/file-last-modified-using-open-panel.js 2017-02-27 09:49:29 UTC (rev 213042)
@@ -0,0 +1,39 @@
+description("Test File.lastModifiedDate.");
+
+jsTestIsAsync = true;
+
+function onFileChange(file, filePath)
+{
+ var xhr = new XMLHttpRequest();
+ xhr.open("GET", "http://127.0.0.1:8000/resources/file-last-modified.php?path=../local/fileapi/" + filePath, false);
+ xhr.send();
+ var expectedDate = new Date(parseInt(xhr.responseText) * 1000);
+ var actualDate = file.lastModified;
+ if (expectedDate.getTime() == actualDate)
+ testPassed("file.lastModified verified");
+ else
+ testFailed("file.lastModified incorrect");
+
+ // Clean up after ourselves
+ removeFileInputElement();
+
+ finishJSTest();
+}
+
+function runTest()
+{
+ var testFilePath = "../resources/file-for-drag-to-send.txt";
+ setFileInputChangeCallback(function(file) { onFileChange(file, testFilePath); });
+ testRunner.setOpenPanelFiles([testFilePath]);
+
+ var centerX = fileInput.offsetLeft + fileInput.offsetWidth / 2;
+ var centerY = fileInput.offsetTop + fileInput.offsetHeight / 2;
+ UIHelper.activateAt(centerX, centerY);
+}
+
+if (window.testRunner)
+ runTest();
+else
+ testFailed("This test is not interactive, please run using a test harness");
+
+var successfullyParsed = true;
Added: trunk/LayoutTests/http/tests/local/fileapi/upload-zip-bundle-as-blob-using-open-panel-expected.txt (0 => 213042)
--- trunk/LayoutTests/http/tests/local/fileapi/upload-zip-bundle-as-blob-using-open-panel-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/local/fileapi/upload-zip-bundle-as-blob-using-open-panel-expected.txt 2017-02-27 09:49:29 UTC (rev 213042)
@@ -0,0 +1,11 @@
+OPEN FILE PANEL
+Test that bundles are automatically zipped when uploaded with XMLHttpRequest. To test manually, please select a file bundle in the "Choose File" input below.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS String.fromCharCode(responseArray[0], responseArray[1]) is 'PK'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/http/tests/local/fileapi/upload-zip-bundle-as-blob-using-open-panel.html (0 => 213042)
--- trunk/LayoutTests/http/tests/local/fileapi/upload-zip-bundle-as-blob-using-open-panel.html (rev 0)
+++ trunk/LayoutTests/http/tests/local/fileapi/upload-zip-bundle-as-blob-using-open-panel.html 2017-02-27 09:49:29 UTC (rev 213042)
@@ -0,0 +1,50 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<script src=""
+<script src=""
+</head>
+<body>
+<div id=description></div>
+<input type=file id=fileInput></div>
+<div id=console></div>
+<script>
+if (window.testRunner)
+ testRunner.dumpAsText();
+
+description("Test that bundles are automatically zipped when uploaded with XMLHttpRequest. To test manually, please select a file bundle in the \"Choose File\" input below.");
+jsTestIsAsync = true;
+
+window._onload_ = function()
+{
+ var fileInput = document.getElementById("fileInput");
+
+ fileInput.addEventListener("change", onchange, true);
+
+ if (!window.testRunner)
+ return;
+
+ var centerX = fileInput.offsetLeft + fileInput.offsetWidth / 2;
+ var centerY = fileInput.offsetTop + fileInput.offsetHeight / 2;
+ testRunner.setOpenPanelFiles(["resources/document.rtfd"]);
+ UIHelper.activateAt(centerX, centerY);
+}
+
+function onchange(event)
+{
+ var file = event.target.files.item(0);
+ var xhr = new XMLHttpRequest;
+ xhr.open("POST", "http://127.0.0.1:8000/xmlhttprequest/resources/post-echo.cgi", true);
+ xhr.responseType = "arraybuffer";
+ xhr.send(file);
+ xhr._onloadend_ = function() {
+ responseArray = new Uint8Array(xhr.response);
+ shouldBe("String.fromCharCode(responseArray[0], responseArray[1])", "'PK'");
+ finishJSTest();
+ }
+}
+</script>
+<script src=""
+</body>
+</html>
Added: trunk/LayoutTests/http/tests/local/formdata/send-form-data-constructed-from-form-using-open-panel-expected.txt (0 => 213042)
--- trunk/LayoutTests/http/tests/local/formdata/send-form-data-constructed-from-form-using-open-panel-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/local/formdata/send-form-data-constructed-from-form-using-open-panel-expected.txt 2017-02-27 09:49:29 UTC (rev 213042)
@@ -0,0 +1,7 @@
+OPEN FILE PANEL
+
+
+Test that FormData constructor takes a HTML Form element.
+Response: submitted=true&checkbox=value2&radio=value3&text=value4&file=test.txt:text/plain:Hello
+DONE
+
Added: trunk/LayoutTests/http/tests/local/formdata/send-form-data-constructed-from-form-using-open-panel.html (0 => 213042)
--- trunk/LayoutTests/http/tests/local/formdata/send-form-data-constructed-from-form-using-open-panel.html (rev 0)
+++ trunk/LayoutTests/http/tests/local/formdata/send-form-data-constructed-from-form-using-open-panel.html 2017-02-27 09:49:29 UTC (rev 213042)
@@ -0,0 +1,54 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<body>
+<form id=f>
+<input type=hidden name="submitted" value="true">
+<input type=button name="button" value="value1">
+<input type=checkbox name="checkbox" value="value2" checked>
+<input type=radio name="radio" value="value3" checked>
+<input type=text name="text" value="value4">
+<input type=text name="text2" value="value5" disabled><br>
+<input type=file id="file" name="file" _onchange_="onInputFileChange()">
+<input type=submit>
+</form>
+<pre id='console'></pre>
+<script src=''></script>
+<script>
+function log(message)
+{
+ document.getElementById('console').appendChild(document.createTextNode(message + "\n"));
+}
+
+function onInputFileChange()
+{
+ log("Test that FormData constructor takes a HTML Form element.");
+
+ var file = document.getElementById("file").files[0];
+ var xhr = new XMLHttpRequest();
+ xhr.open("POST", "http://127.0.0.1:8000/xmlhttprequest/resources/multipart-post-echo.php", false);
+ xhr.send(new FormData(document.getElementById("f")));
+ log("Response: " + xhr.responseText);
+
+ log("DONE");
+ if (testRunner.notifyDone)
+ testRunner.notifyDone();
+}
+
+function runTests()
+{
+ testRunner.setOpenPanelFiles(['resources/test.txt']);
+
+ var element = document.getElementById("file")
+ var centerX = element.offsetLeft + element.offsetWidth / 2;
+ var centerY = element.offsetTop + element.offsetHeight / 2;
+ UIHelper.activateAt(centerX, centerY);
+}
+
+if (window.testRunner) {
+ testRunner.dumpAsText();
+ testRunner.waitUntilDone();
+ window._onload_ = runTests;
+}
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/http/tests/local/formdata/send-form-data-with-empty-file-filename-using-open-panel-expected.txt (0 => 213042)
--- trunk/LayoutTests/http/tests/local/formdata/send-form-data-with-empty-file-filename-using-open-panel-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/local/formdata/send-form-data-with-empty-file-filename-using-open-panel-expected.txt 2017-02-27 09:49:29 UTC (rev 213042)
@@ -0,0 +1,12 @@
+OPEN FILE PANEL
+Test that filename passed to FormData.append() takes precedence over filename in File, even if empty.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Sending FormData containing one file with custom empty filename:
+PASS filename is ''
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/http/tests/local/formdata/send-form-data-with-empty-file-filename-using-open-panel.html (0 => 213042)
--- trunk/LayoutTests/http/tests/local/formdata/send-form-data-with-empty-file-filename-using-open-panel.html (rev 0)
+++ trunk/LayoutTests/http/tests/local/formdata/send-form-data-with-empty-file-filename-using-open-panel.html 2017-02-27 09:49:29 UTC (rev 213042)
@@ -0,0 +1,59 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src=""
+<script>
+description("Test that filename passed to FormData.append() takes precedence over filename in File, even if empty.");
+
+self.jsTestIsAsync = true;
+
+function onChange(event)
+{
+ var formData = new FormData;
+ formData.append("file", event.target.files[0], "");
+ var xhr = new XMLHttpRequest();
+ xhr.open("POST", "http://127.0.0.1:8000/xmlhttprequest/resources/multipart-post-echo-filenames.php", true);
+ xhr._onload_ = function() {
+ filename = xhr.responseText;
+ shouldBe("filename", "''");
+ formDataTestingCleanup();
+ finishJSTest();
+ }
+
+ xhr.send(formData);
+}
+
+function runTest()
+{
+ debug("Sending FormData containing one file with custom empty filename:");
+
+ var input = document.getElementsByTagName("input")[0];
+ input._onchange_ = onChange;
+ if (window.testRunner) {
+ testRunner.setOpenPanelFiles(['../resources/file-for-drag-to-send.txt']);
+
+ var centerX = input.offsetLeft + input.offsetWidth / 2;
+ var centerY = input.offsetTop + input.offsetHeight / 2;
+ UIHelper.activateAt(centerX, centerY);
+ }
+}
+
+if (window.testRunner)
+ runTest();
+else {
+ debug("To run this test manually, please drag a file onto file input above");
+ document.getElementsByTagName("input")[0]._onchange_ = onChange;
+}
+
+var successfullyParsed = true;
+</script>
+<script src=""
+</body>
+</html>
+
Added: trunk/LayoutTests/media/video-src-blob-using-open-panel-expected.txt (0 => 213042)
--- trunk/LayoutTests/media/video-src-blob-using-open-panel-expected.txt (rev 0)
+++ trunk/LayoutTests/media/video-src-blob-using-open-panel-expected.txt 2017-02-27 09:49:29 UTC (rev 213042)
@@ -0,0 +1,7 @@
+OPEN FILE PANEL
+This tests the ability of the <video> element to load blob URLs. In the browser, select a video file:
+
+EVENT(change)
+EVENT(loadedmetadata)
+END OF TEST
+
Added: trunk/LayoutTests/media/video-src-blob-using-open-panel.html (0 => 213042)
--- trunk/LayoutTests/media/video-src-blob-using-open-panel.html (rev 0)
+++ trunk/LayoutTests/media/video-src-blob-using-open-panel.html 2017-02-27 09:49:29 UTC (rev 213042)
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <script src=""
+ <script src=""
+ <script src=''></script>
+ <script>
+ function inputFileChanged(e) {
+ findMediaElement();
+ var file = e.target.files[0];
+ waitForEventAndEnd('loadedmetadata');
+ waitForEventAndFail('error');
+ video.src = ""
+ }
+
+ function runTest() {
+ var inputFile = document.getElementById('file');
+ var centerX = inputFile.offsetLeft + inputFile.offsetWidth / 2;
+ var centerY = inputFile.offsetTop + inputFile.offsetHeight / 2;
+ waitForEvent('change', inputFileChanged, false, false, inputFile);
+
+ if (window.testRunner) {
+ testRunner.setOpenPanelFiles([findMediaFile("video", "content/test")]);
+ UIHelper.activateAt(centerX, centerY);
+ }
+ }
+ </script>
+ </head>
+ <body _onload_="runTest()">
+ <div>
+ This tests the ability of the <video> element to load blob URLs. In the browser, select a video file:
+ <input type="file" name="file" id="file">
+ </div>
+ <video></video>
+ </body>
+</html>
Modified: trunk/LayoutTests/platform/ios-simulator/TestExpectations (213041 => 213042)
--- trunk/LayoutTests/platform/ios-simulator/TestExpectations 2017-02-27 09:45:10 UTC (rev 213041)
+++ trunk/LayoutTests/platform/ios-simulator/TestExpectations 2017-02-27 09:49:29 UTC (rev 213042)
@@ -2887,3 +2887,7 @@
[ Debug ] fast/frames/exponential-frames.html [ Skip ]
webkit.org/b/168053 pageoverlay/overlay-remove-reinsert-view.html [ Pass Failure ]
+
+# Bundle upload is not supported on iOS
+fast/files/filereader-zip-bundle-using-open-panel.html [ Skip ]
+http/tests/local/fileapi/upload-zip-bundle-as-blob-using-open-panel.html [ Skip ]
Modified: trunk/Tools/ChangeLog (213041 => 213042)
--- trunk/Tools/ChangeLog 2017-02-27 09:45:10 UTC (rev 213041)
+++ trunk/Tools/ChangeLog 2017-02-27 09:49:29 UTC (rev 213042)
@@ -1,3 +1,57 @@
+2017-02-27 Andy Estes <[email protected]>
+
+ Add a way to test file input without relying on drag and drop
+ https://bugs.webkit.org/show_bug.cgi?id=168848
+ <rdar://problem/22258242>
+
+ Reviewed by Tim Horton.
+
+ Existing layout tests relied on drag and drop support in EventSender to configure a file
+ input element for testing. This had several problems:
+
+ 1. WebKitTestRunner has no support for beginDragWithFiles(), and DumpRenderTree doesn't
+ support it on iOS.
+ 2. We have no test coverage for selecting files via the runOpenPanel UI delegate, leading to
+ bugs like webkit.org/b/159686.
+
+ Even if we fixed (1), we'd still have a test coverage gap due to (2), so this patch
+ introduces a way for a test to specify the list of files that should be selected by the
+ runOpenPanel UI delegate: TestRunner.setOpenPanelFiles(). It also creates versions of a
+ number of existing file input tests using TestRunner.setOpenPanelFiles() instead of
+ EventSender.beginDragWithFiles().
+
+ * DumpRenderTree/ios/DumpRenderTreeBrowserView.mm:
+ (-[DumpRenderTreeBrowserView webView:runOpenPanelForFileButtonWithResultListener:configuration:]):
+ Overrode to call the corresponding method on UIDelegate.
+ * DumpRenderTree/TestRunner.cpp:
+ (setOpenPanelFilesCallback): Added to call TestRunner::setOpenPanelFiles().
+ (TestRunner::staticFunctions): Registered setOpenPanelFiles.
+ (TestRunner::setOpenPanelFiles): Added. Converts the _javascript_ array of file paths to a
+ std::vector of std::strings.
+ * DumpRenderTree/TestRunner.h:
+ (TestRunner::openPanelFiles):
+ * DumpRenderTree/mac/UIDelegate.mm:
+ (-[UIDelegate webView:runOpenPanelForFileButtonWithResultListener:allowMultipleFiles:]):
+ Added. Converts the array of file paths to an NSArray of NSURLs, resolving the file paths
+ relative to the current test URL. Returns either the first item or all items depending on
+ the value of allowMultipleFiles.
+ * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl: Defined setOpenPanelFiles.
+ * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
+ (WTR::TestRunner::setOpenPanelFiles): Added. Converts the _javascript_ array of file paths to
+ a WKArray of WKURLs, resolving the file paths relative to the current test URL, and sends
+ the WKArray to the UI process with the "SetOpenPanelFileURLs" message.
+ * WebKitTestRunner/InjectedBundle/TestRunner.h:
+ * WebKitTestRunner/TestController.cpp:
+ (WTR::runOpenPanel): Calls the WKOpenPanelResultListener with either the first item or all
+ items, depending on the value of WKOpenPanelParametersGetAllowsMultipleFiles().
+ (WTR::TestController::resetStateToConsistentValues): Clear m_openPanelFileURLs.
+ * WebKitTestRunner/TestController.h:
+ (WTR::TestController::openPanelFileURLs):
+ (WTR::TestController::setOpenPanelFileURLs):
+ * WebKitTestRunner/TestInvocation.cpp:
+ (WTR::TestInvocation::didReceiveMessageFromInjectedBundle): Added code to handle the
+ "SetOpenPanelFileURLs" message.
+
2017-02-26 Wenson Hsieh <[email protected]>
REGRESSION (r211312): Double-clicking a word selects it along with the space that follows it
Modified: trunk/Tools/DumpRenderTree/TestRunner.cpp (213041 => 213042)
--- trunk/Tools/DumpRenderTree/TestRunner.cpp 2017-02-27 09:45:10 UTC (rev 213041)
+++ trunk/Tools/DumpRenderTree/TestRunner.cpp 2017-02-27 09:49:29 UTC (rev 213042)
@@ -1795,6 +1795,13 @@
return JSValueMakeUndefined(context);
}
+static JSValueRef setOpenPanelFilesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+ if (argumentCount == 1)
+ static_cast<TestRunner*>(JSObjectGetPrivate(thisObject))->setOpenPanelFiles(context, arguments[0]);
+ return JSValueMakeUndefined(context);
+}
+
// Static Values
static JSValueRef getTimeoutCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
@@ -2242,6 +2249,7 @@
{ "runUIScript", runUIScriptCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "imageCountInGeneralPasteboard", imageCountInGeneralPasteboardCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "setSpellCheckerLoggingEnabled", setSpellCheckerLoggingEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+ { "setOpenPanelFiles", setOpenPanelFilesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ 0, 0, 0 }
};
@@ -2440,6 +2448,33 @@
WebCoreTestSupport::setAllowsAnySSLCertificate(allowsAnySSLCertificate);
}
+void TestRunner::setOpenPanelFiles(JSContextRef context, JSValueRef filesValue)
+{
+ if (!JSValueIsArray(context, filesValue))
+ return;
+
+ JSObjectRef files = JSValueToObject(context, filesValue, nullptr);
+ static auto lengthProperty = JSRetainPtr<JSStringRef>(Adopt, JSStringCreateWithUTF8CString("length"));
+ JSValueRef filesLengthValue = JSObjectGetProperty(context, files, lengthProperty.get(), nullptr);
+ if (!JSValueIsNumber(context, filesLengthValue))
+ return;
+
+ m_openPanelFiles.clear();
+ auto filesLength = static_cast<size_t>(JSValueToNumber(context, filesLengthValue, nullptr));
+ for (size_t i = 0; i < filesLength; ++i) {
+ JSValueRef fileValue = JSObjectGetPropertyAtIndex(context, files, i, nullptr);
+ if (!JSValueIsString(context, fileValue))
+ continue;
+
+ auto file = JSRetainPtr<JSStringRef>(Adopt, JSValueToStringCopy(context, fileValue, nullptr));
+ size_t fileBufferSize = JSStringGetMaximumUTF8CStringSize(file.get()) + 1;
+ auto fileBuffer = std::make_unique<char[]>(fileBufferSize);
+ JSStringGetUTF8CString(file.get(), fileBuffer.get(), fileBufferSize);
+
+ m_openPanelFiles.push_back(fileBuffer.get());
+ }
+}
+
void TestRunner::cleanup()
{
clearTestRunnerCallbacks();
Modified: trunk/Tools/DumpRenderTree/TestRunner.h (213041 => 213042)
--- trunk/Tools/DumpRenderTree/TestRunner.h 2017-02-27 09:45:10 UTC (rev 213041)
+++ trunk/Tools/DumpRenderTree/TestRunner.h 2017-02-27 09:49:29 UTC (rev 213042)
@@ -377,6 +377,9 @@
void setSpellCheckerLoggingEnabled(bool);
+ const std::vector<std::string>& openPanelFiles() const { return m_openPanelFiles; }
+ void setOpenPanelFiles(JSContextRef, JSValueRef);
+
private:
TestRunner(const std::string& testURL, const std::string& expectedPixelHash);
@@ -467,6 +470,8 @@
std::unique_ptr<WTR::UIScriptContext> m_UIScriptContext;
UIScriptInvocationData* m_pendingUIScriptInvocationData { nullptr };
+ std::vector<std::string> m_openPanelFiles;
+
static JSClassRef getJSClass();
static JSStaticValue* staticValues();
static JSStaticFunction* staticFunctions();
Modified: trunk/Tools/DumpRenderTree/ios/DumpRenderTreeBrowserView.mm (213041 => 213042)
--- trunk/Tools/DumpRenderTree/ios/DumpRenderTreeBrowserView.mm 2017-02-27 09:45:10 UTC (rev 213041)
+++ trunk/Tools/DumpRenderTree/ios/DumpRenderTreeBrowserView.mm 2017-02-27 09:49:29 UTC (rev 213042)
@@ -30,6 +30,8 @@
#import <WebCore/WebCoreThreadRun.h>
#import <WebKit/WebCoreThread.h>
+#import <WebKit/WebUIDelegate.h>
+#import <WebKit/WebUIKitDelegate.h>
#import <WebKit/WebView.h>
@interface UIWebBrowserView (WebUIKitDelegate)
@@ -78,6 +80,13 @@
[uiDelegate webView:sender addMessageToConsole:dictionary withSource:source];
}
+- (void)webView:(WebView *)webView runOpenPanelForFileButtonWithResultListener:(id <WebOpenPanelResultListener>)resultListener configuration:(NSDictionary *)configuration
+{
+ WebThreadLock();
+ BOOL allowMultipleFiles = [configuration[WebOpenPanelConfigurationAllowMultipleFilesKey] boolValue];
+ [webView.UIDelegate webView:webView runOpenPanelForFileButtonWithResultListener:resultListener allowMultipleFiles:allowMultipleFiles];
+}
+
@end
@implementation DumpRenderTreeBrowserView (DRTTesting)
Modified: trunk/Tools/DumpRenderTree/mac/UIDelegate.mm (213041 => 213042)
--- trunk/Tools/DumpRenderTree/mac/UIDelegate.mm 2017-02-27 09:45:10 UTC (rev 213041)
+++ trunk/Tools/DumpRenderTree/mac/UIDelegate.mm 2017-02-27 09:49:29 UTC (rev 213042)
@@ -363,6 +363,31 @@
return [NSData dataWithBytes:"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" length:16];
}
+- (void)webView:(WebView *)sender runOpenPanelForFileButtonWithResultListener:(id<WebOpenPanelResultListener>)resultListener allowMultipleFiles:(BOOL)allowMultipleFiles
+{
+ printf("OPEN FILE PANEL\n");
+
+ auto& openPanelFiles = gTestRunner->openPanelFiles();
+ if (openPanelFiles.empty()) {
+ [resultListener cancel];
+ return;
+ }
+
+ NSURL *baseURL = [NSURL URLWithString:[NSString stringWithUTF8String:gTestRunner->testURL().c_str()]];
+ auto filePaths = adoptNS([[NSMutableArray alloc] initWithCapacity:openPanelFiles.size()]);
+ for (auto& filePath : openPanelFiles) {
+ NSURL *fileURL = [NSURL fileURLWithPath:[NSString stringWithUTF8String:filePath.c_str()] relativeToURL:baseURL];
+ [filePaths addObject:fileURL.path];
+ }
+
+ if (allowMultipleFiles) {
+ [resultListener chooseFilenames:filePaths.get()];
+ return;
+ }
+
+ [resultListener chooseFilename:[filePaths firstObject]];
+}
+
- (void)dealloc
{
#if !PLATFORM(IOS)
Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl (213041 => 213042)
--- trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl 2017-02-27 09:45:10 UTC (rev 213041)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl 2017-02-27 09:49:29 UTC (rev 213042)
@@ -262,4 +262,7 @@
void setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(boolean value);
void setStatisticsMinimumTimeBetweeenDataRecordsRemoval(double seconds);
void statisticsResetToConsistentState();
+
+ // Open panel
+ void setOpenPanelFiles(object filesArray);
};
Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp (213041 => 213042)
--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp 2017-02-27 09:45:10 UTC (rev 213041)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp 2017-02-27 09:49:29 UTC (rev 213042)
@@ -1479,4 +1479,37 @@
}
#endif // PLATFORM(MAC)
+void TestRunner::setOpenPanelFiles(JSValueRef filesValue)
+{
+ WKBundlePageRef page = InjectedBundle::singleton().page()->page();
+ JSContextRef context = WKBundleFrameGetJavaScriptContext(WKBundlePageGetMainFrame(page));
+
+ if (!JSValueIsArray(context, filesValue))
+ return;
+
+ JSObjectRef files = JSValueToObject(context, filesValue, nullptr);
+ static auto lengthProperty = JSRetainPtr<JSStringRef>(Adopt, JSStringCreateWithUTF8CString("length"));
+ JSValueRef filesLengthValue = JSObjectGetProperty(context, files, lengthProperty.get(), nullptr);
+ if (!JSValueIsNumber(context, filesLengthValue))
+ return;
+
+ auto fileURLs = adoptWK(WKMutableArrayCreate());
+ auto filesLength = static_cast<size_t>(JSValueToNumber(context, filesLengthValue, nullptr));
+ for (size_t i = 0; i < filesLength; ++i) {
+ JSValueRef fileValue = JSObjectGetPropertyAtIndex(context, files, i, nullptr);
+ if (!JSValueIsString(context, fileValue))
+ continue;
+
+ auto file = JSRetainPtr<JSStringRef>(Adopt, JSValueToStringCopy(context, fileValue, nullptr));
+ size_t fileBufferSize = JSStringGetMaximumUTF8CStringSize(file.get()) + 1;
+ auto fileBuffer = std::make_unique<char[]>(fileBufferSize);
+ JSStringGetUTF8CString(file.get(), fileBuffer.get(), fileBufferSize);
+
+ WKArrayAppendItem(fileURLs.get(), adoptWK(WKURLCreateWithBaseURL(m_testURL.get(), fileBuffer.get())).get());
+ }
+
+ static auto messageName = adoptWK(WKStringCreateWithUTF8CString("SetOpenPanelFileURLs"));
+ WKBundlePagePostMessage(page, messageName.get(), fileURLs.get());
+}
+
} // namespace WTR
Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h (213041 => 213042)
--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h 2017-02-27 09:45:10 UTC (rev 213041)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h 2017-02-27 09:49:29 UTC (rev 213042)
@@ -363,6 +363,9 @@
void setStatisticsMinimumTimeBetweeenDataRecordsRemoval(double);
void statisticsResetToConsistentState();
+ // Open panel
+ void setOpenPanelFiles(JSValueRef);
+
private:
TestRunner();
Modified: trunk/Tools/WebKitTestRunner/TestController.cpp (213041 => 213042)
--- trunk/Tools/WebKitTestRunner/TestController.cpp 2017-02-27 09:45:10 UTC (rev 213041)
+++ trunk/Tools/WebKitTestRunner/TestController.cpp 2017-02-27 09:49:29 UTC (rev 213042)
@@ -152,7 +152,19 @@
static void runOpenPanel(WKPageRef page, WKFrameRef frame, WKOpenPanelParametersRef parameters, WKOpenPanelResultListenerRef resultListenerRef, const void*)
{
printf("OPEN FILE PANEL\n");
- WKOpenPanelResultListenerCancel(resultListenerRef);
+ WKArrayRef fileURLs = TestController::singleton().openPanelFileURLs();
+ if (!fileURLs || !WKArrayGetSize(fileURLs)) {
+ WKOpenPanelResultListenerCancel(resultListenerRef);
+ return;
+ }
+
+ if (WKOpenPanelParametersGetAllowsMultipleFiles(parameters)) {
+ WKOpenPanelResultListenerChooseFiles(resultListenerRef, fileURLs);
+ return;
+ }
+
+ WKTypeRef firstItem = WKArrayGetItemAtIndex(fileURLs, 0);
+ WKOpenPanelResultListenerChooseFiles(resultListenerRef, adoptWK(WKArrayCreate(&firstItem, 1)).get());
}
void TestController::runModal(WKPageRef page, const void* clientInfo)
@@ -823,6 +835,8 @@
setIgnoresViewportScaleLimits(options.ignoresViewportScaleLimits);
+ m_openPanelFileURLs = nullptr;
+
WKPageLoadURL(m_mainWebView->page(), blankURL());
runUntil(m_doneResetting, m_currentInvocation->shortTimeout());
return m_doneResetting;
Modified: trunk/Tools/WebKitTestRunner/TestController.h (213041 => 213042)
--- trunk/Tools/WebKitTestRunner/TestController.h 2017-02-27 09:45:10 UTC (rev 213041)
+++ trunk/Tools/WebKitTestRunner/TestController.h 2017-02-27 09:49:29 UTC (rev 213042)
@@ -162,6 +162,9 @@
void setStatisticsMinimumTimeBetweeenDataRecordsRemoval(double);
void statisticsResetToConsistentState();
+ WKArrayRef openPanelFileURLs() const { return m_openPanelFileURLs.get(); }
+ void setOpenPanelFileURLs(WKArrayRef fileURLs) { m_openPanelFileURLs = fileURLs; }
+
private:
WKRetainPtr<WKPageConfigurationRef> generatePageConfiguration(WKContextConfigurationRef);
WKRetainPtr<WKContextConfigurationRef> generateContextConfiguration() const;
@@ -363,6 +366,8 @@
bool m_shouldDecideNavigationPolicyAfterDelay { false };
+ WKRetainPtr<WKArrayRef> m_openPanelFileURLs;
+
std::unique_ptr<EventSenderProxy> m_eventSenderProxy;
WorkQueueManager m_workQueueManager;
Modified: trunk/Tools/WebKitTestRunner/TestInvocation.cpp (213041 => 213042)
--- trunk/Tools/WebKitTestRunner/TestInvocation.cpp 2017-02-27 09:45:10 UTC (rev 213041)
+++ trunk/Tools/WebKitTestRunner/TestInvocation.cpp 2017-02-27 09:49:29 UTC (rev 213042)
@@ -733,6 +733,11 @@
return;
}
+ if (WKStringIsEqualToUTF8CString(messageName, "SetOpenPanelFileURLs")) {
+ TestController::singleton().setOpenPanelFileURLs(static_cast<WKArrayRef>(messageBody));
+ return;
+ }
+
ASSERT_NOT_REACHED();
}