Title: [144974] trunk
Revision
144974
Author
[email protected]
Date
2013-03-06 13:25:35 -0800 (Wed, 06 Mar 2013)

Log Message

Source/WebCore: Cleanup in multipart FormData sending code.
https://bugs.webkit.org/show_bug.cgi?id=111603

Patch by Victor Costan <[email protected]> on 2013-03-06
Reviewed by Alexey Proskuryakov.

No new tests. This is cleanup.

* platform/network/FormDataBuilder.cpp:
(WebCore::appendQuotedString): use proper types (e.g, size_t instead of
unsigned long)

LayoutTests: Cleanup in multipart FormData tests.
https://bugs.webkit.org/show_bug.cgi?id=111603

Patch by Victor Costan <[email protected]> on 2013-03-06
Reviewed by Alexey Proskuryakov.

* http/tests/local/formdata/resources/send-form-data-common.js:
(sendFormData): _javascript_ style cleanup.
(testSendingFormData): _javascript_ style, bugfix in checking if
eventSender.beginDragWithFiles needs to be called.
* http/tests/local/formdata/send-form-data-with-filename-expected.txt: Better test description.
* http/tests/local/formdata/send-form-data-with-filename.html: Better test description.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (144973 => 144974)


--- trunk/LayoutTests/ChangeLog	2013-03-06 21:23:39 UTC (rev 144973)
+++ trunk/LayoutTests/ChangeLog	2013-03-06 21:25:35 UTC (rev 144974)
@@ -1,3 +1,17 @@
+2013-03-06  Victor Costan  <[email protected]>
+
+        Cleanup in multipart FormData tests.
+        https://bugs.webkit.org/show_bug.cgi?id=111603
+
+        Reviewed by Alexey Proskuryakov.
+
+        * http/tests/local/formdata/resources/send-form-data-common.js:
+        (sendFormData): _javascript_ style cleanup.
+        (testSendingFormData): _javascript_ style, bugfix in checking if
+        eventSender.beginDragWithFiles needs to be called.
+        * http/tests/local/formdata/send-form-data-with-filename-expected.txt: Better test description.
+        * http/tests/local/formdata/send-form-data-with-filename.html: Better test description.
+
 2013-03-06  Ryosuke Niwa  <[email protected]>
 
         Add a flaky crash test expectation to platform/mac/fast/speechsynthesis/speech-synthesis-cancel.html

Modified: trunk/LayoutTests/http/tests/local/formdata/resources/send-form-data-common.js (144973 => 144974)


--- trunk/LayoutTests/http/tests/local/formdata/resources/send-form-data-common.js	2013-03-06 21:23:39 UTC (rev 144973)
+++ trunk/LayoutTests/http/tests/local/formdata/resources/send-form-data-common.js	2013-03-06 21:25:35 UTC (rev 144974)
@@ -28,10 +28,10 @@
 {
     var formData = new FormData();
     for (var i = 0; i < formDataList.length; i++) {
-        if (formDataList[i]['filename'] != undefined)
-            formData.append(formDataList[i]['name'], formDataList[i]['value'], formDataList[i]['filename']);
+        if (formDataList[i].filename !== undefined)
+            formData.append(formDataList[i].name, formDataList[i].value, formDataList[i].filename);
         else
-            formData.append(formDataList[i]['name'], formDataList[i]['value']);
+            formData.append(formDataList[i].name, formDataList[i].value);
     }
 
     var xhr = new XMLHttpRequest();
@@ -49,11 +49,11 @@
 {
     var filesToDrag = [];
     for (var i = 0; i < dataList.length; i++) {
-        if (dataList[i]['type'] == 'file')
-            filesToDrag.push(dataList[i]['value']);
+        if (dataList[i].type === 'file')
+            filesToDrag.push(dataList[i].value);
     }
 
-    if (filesToDrag) {
+    if (filesToDrag.length !== 0) {
         eventSender.beginDragWithFiles(filesToDrag);
         moveMouseToCenterOfElement(fileInput);
         eventSender.mouseUp();
@@ -63,22 +63,27 @@
     var formDataList = [];
     var fileSliced = false;
     for (var i = 0; i < dataList.length; i++) {
-        if (dataList[i]['type'] == 'file') {
-            var fileName = getFileName(dataList[i]['value']);
+        var field = {name: dataList[i].name};
+        if (dataList[i].type === 'file') {
+            var fileName = getFileName(dataList[i].value);
             for (var j = 0; j < files.length; j++) {
                 if (fileName == files[j].name) {
                     var file = files[j];
-                    if (dataList[i]['start'] && dataList[i]['length']) {
+                    if ('start' in dataList[i] && 'length' in dataList[i]) {
                         fileSliced = true;
-                        file = file.slice(dataList[i]['start'], dataList[i]['start'] + dataList[i]['length']);
+                        file = file.slice(dataList[i].start, dataList[i].start + dataList[i].length);
                     }
-                    formDataList.push({'name': dataList[i]['name'], 'value': file, 'filename': dataList[i]['filename']});
+                    field.value = file;
                     break;
                 }
             }
-        } else {
-            formDataList.push({'name': dataList[i]['name'], 'value': dataList[i]['value']});
         }
+        else
+            field.value = dataList[i].value;
+        if (dataList[i]['filename'])
+            field.filename = dataList[i].filename;
+
+        formDataList.push(field);
     }
 
     sendFormData(formDataList, fileSliced, sendAsAsync, addEventHandlers);

Modified: trunk/LayoutTests/http/tests/local/formdata/send-form-data-with-filename-expected.txt (144973 => 144974)


--- trunk/LayoutTests/http/tests/local/formdata/send-form-data-with-filename-expected.txt	2013-03-06 21:23:39 UTC (rev 144973)
+++ trunk/LayoutTests/http/tests/local/formdata/send-form-data-with-filename-expected.txt	2013-03-06 21:25:35 UTC (rev 144974)
@@ -1,4 +1,4 @@
-Test for sending FormData via XMLHttpRequest.
+Test that filename passed to FormData.append() takes precedence over filename in File.
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 

Modified: trunk/LayoutTests/http/tests/local/formdata/send-form-data-with-filename.html (144973 => 144974)


--- trunk/LayoutTests/http/tests/local/formdata/send-form-data-with-filename.html	2013-03-06 21:23:39 UTC (rev 144973)
+++ trunk/LayoutTests/http/tests/local/formdata/send-form-data-with-filename.html	2013-03-06 21:25:35 UTC (rev 144974)
@@ -8,7 +8,7 @@
 <div id="console"></div>
 <script src=""
 <script>
-description("Test for sending FormData via XMLHttpRequest.");
+description("Test that filename passed to FormData.append() takes precedence over filename in File.");
 
 function runTest()
 {

Modified: trunk/Source/WebCore/ChangeLog (144973 => 144974)


--- trunk/Source/WebCore/ChangeLog	2013-03-06 21:23:39 UTC (rev 144973)
+++ trunk/Source/WebCore/ChangeLog	2013-03-06 21:25:35 UTC (rev 144974)
@@ -1,3 +1,16 @@
+2013-03-06  Victor Costan <[email protected]>
+
+        Cleanup in multipart FormData sending code.
+        https://bugs.webkit.org/show_bug.cgi?id=111603
+
+        Reviewed by Alexey Proskuryakov.
+
+        No new tests. This is cleanup.
+
+        * platform/network/FormDataBuilder.cpp:
+        (WebCore::appendQuotedString): use proper types (e.g, size_t instead of
+        unsigned long)
+
 2013-03-06  Tony Gentilcore  <[email protected]>
 
         Threaded HTML parser should use 8 bit strings for attributes

Modified: trunk/Source/WebCore/platform/network/FormDataBuilder.cpp (144973 => 144974)


--- trunk/Source/WebCore/platform/network/FormDataBuilder.cpp	2013-03-06 21:23:39 UTC (rev 144973)
+++ trunk/Source/WebCore/platform/network/FormDataBuilder.cpp	2013-03-06 21:25:35 UTC (rev 144974)
@@ -59,9 +59,9 @@
     // Append a string as a quoted value, escaping quotes and line breaks.
     // FIXME: Is it correct to use percent escaping here? Other browsers do not encode these characters yet,
     // so we should test popular servers to find out if there is an encoding form they can handle.
-    unsigned length = string.length();
-    for (unsigned i = 0; i < length; ++i) {
-        unsigned char c = string.data()[i];
+    size_t length = string.length();
+    for (size_t i = 0; i < length; ++i) {
+        char c = string.data()[i];
 
         switch (c) {
         case  0x0a:
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to