Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(273)

Unified Diff: LayoutTests/http/tests/xmlhttprequest/post-formdata.html

Issue 57483002: Implement File constructor. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Answered feedback, part 2. Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: LayoutTests/http/tests/xmlhttprequest/post-formdata.html
diff --git a/LayoutTests/http/tests/xmlhttprequest/post-formdata.html b/LayoutTests/http/tests/xmlhttprequest/post-formdata.html
new file mode 100644
index 0000000000000000000000000000000000000000..a73e11ac5379fcaad5b699bee80224623bd2e853
--- /dev/null
+++ b/LayoutTests/http/tests/xmlhttprequest/post-formdata.html
@@ -0,0 +1,96 @@
+<!DOCTYPE html>
+<html>
+<head>
esprehn 2013/11/04 19:28:08 We often omit the html, head and body elements.
pwnall-personal 2013/11/04 23:01:21 Done. Also did this in the scripts around that I u
+ <script src="/js-test-resources/js-test-pre.js"></script>
+</head>
+<body>
+ <script type="text/javascript">
esprehn 2013/11/04 19:28:08 remove type attr
pwnall-personal 2013/11/04 23:01:21 Done.
+ description("Test verifies that FormData is sent correctly when using " +
+ "<a href='http://www.w3.org/TR/XMLHttpRequest/#the-send-method'>XMLHttpRequest asynchronously.</a>");
+
+ var xhrFormDataTestUrl = '/xmlhttprequest/resources/multipart-post-echo.php';
+ var xhrFormDataTestCases = [{
+ data: { string: 'string value' },
+ result: "string=string value"
+ }, {
+ data: { bareBlob: new Blob(['blob-value']) },
+ result: 'bareBlob=blob:application/octet-stream:blob-value'
+ }, {
+ data: { mimeBlob: new Blob(['blob-value'], { type: 'text/html' }) },
+ result: 'mimeBlob=blob:text/html:blob-value'
+ }, {
+ data: {
+ namedBlob: {
+ value: new Blob(['blob-value']),
+ fileName: 'blob-file.txt'
+ }
+ },
+ result: 'namedBlob=blob-file.txt:application/octet-stream:blob-value'
+ }, {
+ data: { bareFile: new File(['file-value'], 'file-name.txt') },
+ result: 'bareFile=file-name.txt:application/octet-stream:file-value'
+ }, {
+ data: {
+ mimeFile: new File(['file-value'], 'file-name.html', { type: 'text/html' })
+ },
+ result: 'mimeFile=file-name.html:text/html:file-value'
+ }, {
+ data: {
+ renamedFile: {
+ value: new File(['file-value'], 'file-name.html', { type: 'text/html' }),
+ fileName: 'file-name-override.html'
+ }
+ },
+ result: 'bareFile=file-name-override.html:text/html:file-value'
+ }];
+
+ var xhr;
+ var expectedMimeType;
+ window.jsTestIsAsync = true;
+ var asyncTestCase = 0;
+
+ function runNextAsyncTest() {
+ asyncTestCase++;
+ runAsyncTests();
+ }
+
+ function reportResult(e) {
+ var testCase = xhrFormDataTestCases[asyncTestCase];
+ if (xhr.status === 200) {
+ echoResult = xhr.response;
+ shouldBeEqualToString("echoResult", testCase.result);
+ } else {
+ testFailed("Unknown error");
+ }
+
+ runNextAsyncTest();
+ }
+
+ function runAsyncTests() {
+ if (asyncTestCase >= xhrFormDataTestCases.length) {
+ finishJSTest();
+ return;
+ } else {
+ var testCase = xhrFormDataTestCases[asyncTestCase];
+ var formData = new FormData();
+ for (var fieldName in testCase.data) {
+ fieldValue = testCase.data[fieldName];
+ if (fieldValue.constructor === Object) {
+ formData.append(fieldName, fieldValue.value, fieldValue.fileName);
+ } else {
+ formData.append(fieldName, fieldValue);
+ }
+ }
+
+ xhr = new XMLHttpRequest();
+ xhr.onloadend = reportResult;
+ xhr.open("POST", xhrFormDataTestUrl, true);
+ xhr.send(formData);
+ }
+ }
+
+ runAsyncTests();
+
+ </script>
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698