mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Add form submission for file type input and related fixings
This commit is contained in:
parent
2553bb7af4
commit
ef091179f5
15 changed files with 243 additions and 113 deletions
|
@ -5806,16 +5806,16 @@
|
|||
"url": "/_mozilla/css/word_break_a.html"
|
||||
}
|
||||
],
|
||||
"mozilla/blob_url_upload.html": [
|
||||
"mozilla/FileAPI/blob_url_upload.html": [
|
||||
{
|
||||
"path": "mozilla/blob_url_upload.html",
|
||||
"path": "mozilla/FileAPI/blob_url_upload.html",
|
||||
"references": [
|
||||
[
|
||||
"/_mozilla/mozilla/blob_url_upload_ref.html",
|
||||
"/_mozilla/mozilla/FileAPI/blob_url_upload_ref.html",
|
||||
"=="
|
||||
]
|
||||
],
|
||||
"url": "/_mozilla/mozilla/blob_url_upload.html"
|
||||
"url": "/_mozilla/mozilla/FileAPI/blob_url_upload.html"
|
||||
}
|
||||
],
|
||||
"mozilla/canvas/drawimage_html_image_1.html": [
|
||||
|
@ -6234,6 +6234,24 @@
|
|||
"url": "/_mozilla/mozilla/Event.html"
|
||||
}
|
||||
],
|
||||
"mozilla/FileAPI/blob.html": [
|
||||
{
|
||||
"path": "mozilla/FileAPI/blob.html",
|
||||
"url": "/_mozilla/mozilla/FileAPI/blob.html"
|
||||
}
|
||||
],
|
||||
"mozilla/FileAPI/file-select.html": [
|
||||
{
|
||||
"path": "mozilla/FileAPI/file-select.html",
|
||||
"url": "/_mozilla/mozilla/FileAPI/file-select.html"
|
||||
}
|
||||
],
|
||||
"mozilla/FileAPI/file-upload.html": [
|
||||
{
|
||||
"path": "mozilla/FileAPI/file-upload.html",
|
||||
"url": "/_mozilla/mozilla/FileAPI/file-upload.html"
|
||||
}
|
||||
],
|
||||
"mozilla/FocusEvent.html": [
|
||||
{
|
||||
"path": "mozilla/FocusEvent.html",
|
||||
|
@ -6258,12 +6276,6 @@
|
|||
"url": "/_mozilla/mozilla/binding_keyword.html"
|
||||
}
|
||||
],
|
||||
"mozilla/blob.html": [
|
||||
{
|
||||
"path": "mozilla/blob.html",
|
||||
"url": "/_mozilla/mozilla/blob.html"
|
||||
}
|
||||
],
|
||||
"mozilla/body_listener.html": [
|
||||
{
|
||||
"path": "mozilla/body_listener.html",
|
||||
|
@ -6540,12 +6552,6 @@
|
|||
"url": "/_mozilla/mozilla/event_listener.html"
|
||||
}
|
||||
],
|
||||
"mozilla/file_upload.html": [
|
||||
{
|
||||
"path": "mozilla/file_upload.html",
|
||||
"url": "/_mozilla/mozilla/file_upload.html"
|
||||
}
|
||||
],
|
||||
"mozilla/focus_blur.html": [
|
||||
{
|
||||
"path": "mozilla/focus_blur.html",
|
||||
|
@ -14936,16 +14942,16 @@
|
|||
"url": "/_mozilla/css/word_break_a.html"
|
||||
}
|
||||
],
|
||||
"mozilla/blob_url_upload.html": [
|
||||
"mozilla/FileAPI/blob_url_upload.html": [
|
||||
{
|
||||
"path": "mozilla/blob_url_upload.html",
|
||||
"path": "mozilla/FileAPI/blob_url_upload.html",
|
||||
"references": [
|
||||
[
|
||||
"/_mozilla/mozilla/blob_url_upload_ref.html",
|
||||
"/_mozilla/mozilla/FileAPI/blob_url_upload_ref.html",
|
||||
"=="
|
||||
]
|
||||
],
|
||||
"url": "/_mozilla/mozilla/blob_url_upload.html"
|
||||
"url": "/_mozilla/mozilla/FileAPI/blob_url_upload.html"
|
||||
}
|
||||
],
|
||||
"mozilla/canvas/drawimage_html_image_1.html": [
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
[file_upload.html]
|
||||
[file-select.html]
|
||||
type: testharness
|
||||
prefs: [dom.testing.htmlinputelement.select_files.enabled:true]
|
|
@ -0,0 +1,3 @@
|
|||
[file-upload.html]
|
||||
type: testharness
|
||||
prefs: [dom.testing.htmlinputelement.select_files.enabled:true]
|
|
@ -2,6 +2,6 @@
|
|||
<meta charset="utf-8">
|
||||
<title>Reference: Blob URL with File Upload</title>
|
||||
<body>
|
||||
<img src="test.jpg" id="image">
|
||||
<img src="../test.jpg" id="image">
|
||||
<input type="file" id="file-input"">
|
||||
</body>
|
|
@ -1,6 +1,6 @@
|
|||
<!doctype html>
|
||||
<meta charset="utf-8">
|
||||
<title>Test of uploading a file through input element</title>
|
||||
<title>Test of selecting a file through input element</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
<form id="testform" enctype="multipart/form-data" action="resource/file-submission.py" method="post">
|
||||
<input type="file" name="file-input" id="file-input" />
|
||||
</form>
|
||||
|
||||
<script type="text/javascript">
|
||||
var e = document.getElementById("file-input");
|
||||
e.selectFiles(["./tests/wpt/mozilla/tests/mozilla/FileAPI/resource/upload.txt"]);
|
||||
</script>
|
23
tests/wpt/mozilla/tests/mozilla/FileAPI/file-upload.html
Normal file
23
tests/wpt/mozilla/tests/mozilla/FileAPI/file-upload.html
Normal file
|
@ -0,0 +1,23 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
|
||||
function run_test() {
|
||||
var t = async_test("form submission of uploaded file");
|
||||
|
||||
var testframe = document.getElementById("testframe");
|
||||
var testdocument = testframe.contentWindow.document;
|
||||
|
||||
testframe.onload = function() {
|
||||
t.step(function () {
|
||||
var response = testframe.contentDocument.documentElement.textContent;
|
||||
assert_equals(response, "OK");
|
||||
});
|
||||
t.done();
|
||||
};
|
||||
testdocument.getElementById("testform").submit();
|
||||
}
|
||||
</script>
|
||||
<iframe id=testframe src="file-upload-frame.html" onload="run_test();"></iframe>
|
|
@ -0,0 +1,29 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
|
||||
def fail(msg):
|
||||
return ([("Content-Type", "text/plain")], "FAIL: " + msg)
|
||||
|
||||
|
||||
def main(request, response):
|
||||
content_type = request.headers.get('Content-Type').split("; ")
|
||||
|
||||
if len(content_type) != 2:
|
||||
return fail("content type length is incorrect")
|
||||
|
||||
if content_type[0] != 'multipart/form-data':
|
||||
return fail("content type first field is incorrect")
|
||||
|
||||
boundary = content_type[1].strip("boundary=")
|
||||
|
||||
body = "--" + boundary + "\r\nContent-Disposition: form-data; name=\"file-input\"; filename=\"upload.txt\""
|
||||
body += "\r\n" + "text/plain\r\n\r\nHello\r\n--" + boundary + "--"
|
||||
|
||||
if body != request.body:
|
||||
return fail("request body doesn't match: " + body + "+++++++" + request.body)
|
||||
|
||||
return ([("Content-Type", "text/plain")], "OK")
|
|
@ -0,0 +1 @@
|
|||
Hello
|
Loading…
Add table
Add a link
Reference in a new issue