forked from web-platform-tests/wpt-actions-test
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WPT: Add form-based file upload coverage
Tests multipart form POSTs with file inputs where the selected "file" was constructed using the `File` constructor and added to a `DataTransferItemList` (this avoids the user gesture requirement which otherwise would consign this to manual testing.) For the non-ASCII filenames with non-UTF-8 accept-charsets this also verifies fallback encoding/replacement of unrepresentable characters using numeric character references. whatwg/html#2861 Coverage for fallback encoding is still tentative because filename fallback encoding is not yet standardized. whatwg/html#3223 Bug: 661819 Change-Id: Ic646f76b0c8a0792d1214a7848d2238bcc3a76e7 Reviewed-on: https://chromium-review.googlesource.com/811625 Reviewed-by: Victor Costan <[email protected]> Reviewed-by: Joshua Bell <[email protected]> Commit-Queue: Benjamin Wiley Sittler <[email protected]> Cr-Commit-Position: refs/heads/master@{#522197}
- Loading branch information
1 parent
7c29597
commit cbe8c8e
Showing
6 changed files
with
546 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>Upload files in ISO-2022-JP form (tentative)</title> | ||
<!-- | ||
NOTE: This test is tentative because encoding for filename | ||
characters unrepresentable in the form charset is not yet | ||
standardized. | ||
--> | ||
<link rel="help" | ||
href="https://github.com/whatwg/html/issues/3223"> | ||
<link rel="help" | ||
href="https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#multipart-form-data"> | ||
<link rel="help" | ||
href="https://html.spec.whatwg.org/multipage/dnd.html#datatransferitemlist"> | ||
<link rel="help" | ||
href="https://w3c.github.io/FileAPI/#file-constructor"> | ||
<link rel="author" title="Benjamin C. Wiley Sittler" | ||
href="mailto:[email protected]"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="../support/send-file-form-helper.js"></script> | ||
<script> | ||
'use strict'; | ||
|
||
formPostFileUploadTest({ | ||
fileNameSource: 'ASCII', | ||
fileBaseName: 'file-for-upload-in-form.txt', | ||
formEncoding: 'ISO-2022-JP', | ||
expectedEncodedBaseName: 'file-for-upload-in-form.txt', | ||
}); | ||
|
||
formPostFileUploadTest({ | ||
fileNameSource: 'x-user-defined', | ||
fileBaseName: 'file-for-upload-in-form-\uF7F0\uF793\uF783\uF7A0.txt', | ||
formEncoding: 'ISO-2022-JP', | ||
expectedEncodedBaseName: ( | ||
'file-for-upload-in-form-.txt'), | ||
}); | ||
|
||
formPostFileUploadTest({ | ||
fileNameSource: 'windows-1252', | ||
fileBaseName: 'file-for-upload-in-form-☺😂.txt', | ||
formEncoding: 'ISO-2022-JP', | ||
expectedEncodedBaseName: ( | ||
'file-for-upload-in-form-☺😂.txt'), | ||
}); | ||
|
||
formPostFileUploadTest({ | ||
fileNameSource: 'JIS X 0201 and JIS X 0208', | ||
fileBaseName: 'file-for-upload-in-form-★星★.txt', | ||
formEncoding: 'ISO-2022-JP', | ||
expectedEncodedBaseName: 'file-for-upload-in-form-\x1B$B!z@1!z\x1B(B.txt', | ||
}); | ||
|
||
formPostFileUploadTest({ | ||
fileNameSource: 'Unicode', | ||
fileBaseName: 'file-for-upload-in-form-☺😂.txt', | ||
formEncoding: 'ISO-2022-JP', | ||
expectedEncodedBaseName: 'file-for-upload-in-form-☺😂.txt', | ||
}); | ||
|
||
formPostFileUploadTest({ | ||
fileNameSource: 'Unicode', | ||
fileBaseName: `file-for-upload-in-form-${kTestChars}.txt`, | ||
formEncoding: 'ISO-2022-JP', | ||
expectedEncodedBaseName: `file-for-upload-in-form-${ | ||
kTestFallbackIso2022jp | ||
}.txt`, | ||
}); | ||
|
||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>Upload files in UTF-8 form</title> | ||
<link rel="help" | ||
href="https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#multipart-form-data"> | ||
<link rel="help" | ||
href="https://html.spec.whatwg.org/multipage/dnd.html#datatransferitemlist"> | ||
<link rel="help" | ||
href="https://w3c.github.io/FileAPI/#file-constructor"> | ||
<link rel="author" title="Benjamin C. Wiley Sittler" | ||
href="mailto:[email protected]"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="../support/send-file-form-helper.js"></script> | ||
<script> | ||
'use strict'; | ||
|
||
formPostFileUploadTest({ | ||
fileNameSource: 'ASCII', | ||
fileBaseName: 'file-for-upload-in-form.txt', | ||
formEncoding: 'UTF-8', | ||
expectedEncodedBaseName: 'file-for-upload-in-form.txt', | ||
}); | ||
|
||
formPostFileUploadTest({ | ||
fileNameSource: 'x-user-defined', | ||
fileBaseName: 'file-for-upload-in-form-\uF7F0\uF793\uF783\uF7A0.txt', | ||
formEncoding: 'UTF-8', | ||
expectedEncodedBaseName: ( | ||
'file-for-upload-in-form-\uF7F0\uF793\uF783\uF7A0.txt'), | ||
}); | ||
|
||
formPostFileUploadTest({ | ||
fileNameSource: 'windows-1252', | ||
fileBaseName: 'file-for-upload-in-form-☺😂.txt', | ||
formEncoding: 'UTF-8', | ||
expectedEncodedBaseName: 'file-for-upload-in-form-☺😂.txt', | ||
}); | ||
|
||
formPostFileUploadTest({ | ||
fileNameSource: 'JIS X 0201 and JIS X 0208', | ||
fileBaseName: 'file-for-upload-in-form-★星★.txt', | ||
formEncoding: 'UTF-8', | ||
expectedEncodedBaseName: 'file-for-upload-in-form-★星★.txt', | ||
}); | ||
|
||
formPostFileUploadTest({ | ||
fileNameSource: 'Unicode', | ||
fileBaseName: 'file-for-upload-in-form-☺😂.txt', | ||
formEncoding: 'UTF-8', | ||
expectedEncodedBaseName: 'file-for-upload-in-form-☺😂.txt', | ||
}); | ||
|
||
formPostFileUploadTest({ | ||
fileNameSource: 'Unicode', | ||
fileBaseName: `file-for-upload-in-form-${kTestChars}.txt`, | ||
formEncoding: 'UTF-8', | ||
expectedEncodedBaseName: `file-for-upload-in-form-${kTestChars}.txt`, | ||
}); | ||
|
||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>Upload files in Windows-1252 form (tentative)</title> | ||
<!-- | ||
NOTE: This test is tentative because encoding for filename | ||
characters unrepresentable in the form charset is not yet | ||
standardized. | ||
--> | ||
<link rel="help" | ||
href="https://github.com/whatwg/html/issues/3223"> | ||
<link rel="help" | ||
href="https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#multipart-form-data"> | ||
<link rel="help" | ||
href="https://html.spec.whatwg.org/multipage/dnd.html#datatransferitemlist"> | ||
<link rel="help" | ||
href="https://w3c.github.io/FileAPI/#file-constructor"> | ||
<link rel="author" title="Benjamin C. Wiley Sittler" | ||
href="mailto:[email protected]"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="../support/send-file-form-helper.js"></script> | ||
<script> | ||
'use strict'; | ||
|
||
formPostFileUploadTest({ | ||
fileNameSource: 'ASCII', | ||
fileBaseName: 'file-for-upload-in-form.txt', | ||
formEncoding: 'windows-1252', | ||
expectedEncodedBaseName: 'file-for-upload-in-form.txt', | ||
}); | ||
|
||
formPostFileUploadTest({ | ||
fileNameSource: 'x-user-defined', | ||
fileBaseName: 'file-for-upload-in-form-\uF7F0\uF793\uF783\uF7A0.txt', | ||
formEncoding: 'windows-1252', | ||
expectedEncodedBaseName: ( | ||
'file-for-upload-in-form-.txt'), | ||
}); | ||
|
||
formPostFileUploadTest({ | ||
fileNameSource: 'windows-1252', | ||
fileBaseName: 'file-for-upload-in-form-☺😂.txt', | ||
formEncoding: 'windows-1252', | ||
expectedEncodedBaseName: 'file-for-upload-in-form-☺😂.txt', | ||
}); | ||
|
||
formPostFileUploadTest({ | ||
fileNameSource: 'JIS X 0201 and JIS X 0208', | ||
fileBaseName: 'file-for-upload-in-form-★星★.txt', | ||
formEncoding: 'windows-1252', | ||
expectedEncodedBaseName: 'file-for-upload-in-form-★星★.txt', | ||
}); | ||
|
||
formPostFileUploadTest({ | ||
fileNameSource: 'Unicode', | ||
fileBaseName: 'file-for-upload-in-form-☺😂.txt', | ||
formEncoding: 'windows-1252', | ||
expectedEncodedBaseName: 'file-for-upload-in-form-☺😂.txt', | ||
}); | ||
|
||
formPostFileUploadTest({ | ||
fileNameSource: 'Unicode', | ||
fileBaseName: `file-for-upload-in-form-${kTestChars}.txt`, | ||
formEncoding: 'windows-1252', | ||
expectedEncodedBaseName: `file-for-upload-in-form-${ | ||
kTestFallbackWindows1252 | ||
}.txt`, | ||
}); | ||
|
||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>Upload files in x-user-defined form (tentative)</title> | ||
<!-- | ||
NOTE: This test is tentative because encoding for filename | ||
characters unrepresentable in the form charset is not yet | ||
standardized. | ||
--> | ||
<link rel="help" | ||
href="https://github.com/whatwg/html/issues/3223"> | ||
<link rel="help" | ||
href="https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#multipart-form-data"> | ||
<link rel="help" | ||
href="https://html.spec.whatwg.org/multipage/dnd.html#datatransferitemlist"> | ||
<link rel="help" | ||
href="https://w3c.github.io/FileAPI/#file-constructor"> | ||
<link rel="author" title="Benjamin C. Wiley Sittler" | ||
href="mailto:[email protected]"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="../support/send-file-form-helper.js"></script> | ||
<script> | ||
'use strict'; | ||
|
||
formPostFileUploadTest({ | ||
fileNameSource: 'ASCII', | ||
fileBaseName: 'file-for-upload-in-form.txt', | ||
formEncoding: 'x-user-defined', | ||
expectedEncodedBaseName: 'file-for-upload-in-form.txt', | ||
}); | ||
|
||
formPostFileUploadTest({ | ||
fileNameSource: 'x-user-defined', | ||
fileBaseName: 'file-for-upload-in-form-\uF7F0\uF793\uF783\uF7A0.txt', | ||
formEncoding: 'x-user-defined', | ||
expectedEncodedBaseName: 'file-for-upload-in-form-𓃠.txt', | ||
}); | ||
|
||
formPostFileUploadTest({ | ||
fileNameSource: 'windows-1252', | ||
fileBaseName: 'file-for-upload-in-form-☺😂.txt', | ||
formEncoding: 'x-user-defined', | ||
expectedEncodedBaseName: ('file-for-upload-in-form-' + | ||
'☺😂.txt'), | ||
}); | ||
|
||
formPostFileUploadTest({ | ||
fileNameSource: 'JIS X 0201 and JIS X 0208', | ||
fileBaseName: 'file-for-upload-in-form-★星★.txt', | ||
formEncoding: 'x-user-defined', | ||
expectedEncodedBaseName: 'file-for-upload-in-form-★星★.txt', | ||
}); | ||
|
||
formPostFileUploadTest({ | ||
fileNameSource: 'Unicode', | ||
fileBaseName: 'file-for-upload-in-form-☺😂.txt', | ||
formEncoding: 'x-user-defined', | ||
expectedEncodedBaseName: 'file-for-upload-in-form-☺😂.txt', | ||
}); | ||
|
||
formPostFileUploadTest({ | ||
fileNameSource: 'Unicode', | ||
fileBaseName: `file-for-upload-in-form-${kTestChars}.txt`, | ||
formEncoding: 'x-user-defined', | ||
expectedEncodedBaseName: `file-for-upload-in-form-${ | ||
kTestFallbackXUserDefined | ||
}.txt`, | ||
}); | ||
|
||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>Upload ASCII-named file in UTF-8 form</title> | ||
<link rel="help" | ||
href="https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#multipart-form-data"> | ||
<link rel="help" | ||
href="https://html.spec.whatwg.org/multipage/dnd.html#datatransferitemlist"> | ||
<link rel="help" | ||
href="https://w3c.github.io/FileAPI/#file-constructor"> | ||
<link rel="author" title="Benjamin C. Wiley Sittler" | ||
href="mailto:[email protected]"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="../support/send-file-form-helper.js"></script> | ||
<script> | ||
'use strict'; | ||
|
||
formPostFileUploadTest({ | ||
fileNameSource: 'ASCII', | ||
fileBaseName: 'file-for-upload-in-form.txt', | ||
formEncoding: 'UTF-8', | ||
expectedEncodedBaseName: 'file-for-upload-in-form.txt', | ||
}); | ||
|
||
</script> |
Oops, something went wrong.