Changeset 144974 in webkit


Ignore:
Timestamp:
Mar 6, 2013 1:25:35 PM (11 years ago)
Author:
commit-queue@webkit.org
Message:

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

Patch by Victor Costan <costan@gmail.com> 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 <costan@gmail.com> 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.
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r144965 r144974  
     12013-03-06  Victor Costan  <costan@gmail.com>
     2
     3        Cleanup in multipart FormData tests.
     4        https://bugs.webkit.org/show_bug.cgi?id=111603
     5
     6        Reviewed by Alexey Proskuryakov.
     7
     8        * http/tests/local/formdata/resources/send-form-data-common.js:
     9        (sendFormData): JavaScript style cleanup.
     10        (testSendingFormData): JavaScript style, bugfix in checking if
     11        eventSender.beginDragWithFiles needs to be called.
     12        * http/tests/local/formdata/send-form-data-with-filename-expected.txt: Better test description.
     13        * http/tests/local/formdata/send-form-data-with-filename.html: Better test description.
     14
    1152013-03-06  Ryosuke Niwa  <rniwa@webkit.org>
    216
  • trunk/LayoutTests/http/tests/local/formdata/resources/send-form-data-common.js

    r120165 r144974  
    2929    var formData = new FormData();
    3030    for (var i = 0; i < formDataList.length; i++) {
    31         if (formDataList[i]['filename'] != undefined)
    32             formData.append(formDataList[i]['name'], formDataList[i]['value'], formDataList[i]['filename']);
     31        if (formDataList[i].filename !== undefined)
     32            formData.append(formDataList[i].name, formDataList[i].value, formDataList[i].filename);
    3333        else
    34             formData.append(formDataList[i]['name'], formDataList[i]['value']);
     34            formData.append(formDataList[i].name, formDataList[i].value);
    3535    }
    3636
     
    5050    var filesToDrag = [];
    5151    for (var i = 0; i < dataList.length; i++) {
    52         if (dataList[i]['type'] == 'file')
    53             filesToDrag.push(dataList[i]['value']);
     52        if (dataList[i].type === 'file')
     53            filesToDrag.push(dataList[i].value);
    5454    }
    5555
    56     if (filesToDrag) {
     56    if (filesToDrag.length !== 0) {
    5757        eventSender.beginDragWithFiles(filesToDrag);
    5858        moveMouseToCenterOfElement(fileInput);
     
    6464    var fileSliced = false;
    6565    for (var i = 0; i < dataList.length; i++) {
    66         if (dataList[i]['type'] == 'file') {
    67             var fileName = getFileName(dataList[i]['value']);
     66        var field = {name: dataList[i].name};
     67        if (dataList[i].type === 'file') {
     68            var fileName = getFileName(dataList[i].value);
    6869            for (var j = 0; j < files.length; j++) {
    6970                if (fileName == files[j].name) {
    7071                    var file = files[j];
    71                     if (dataList[i]['start'] && dataList[i]['length']) {
     72                    if ('start' in dataList[i] && 'length' in dataList[i]) {
    7273                        fileSliced = true;
    73                         file = file.slice(dataList[i]['start'], dataList[i]['start'] + dataList[i]['length']);
     74                        file = file.slice(dataList[i].start, dataList[i].start + dataList[i].length);
    7475                    }
    75                     formDataList.push({'name': dataList[i]['name'], 'value': file, 'filename': dataList[i]['filename']});
     76                    field.value = file;
    7677                    break;
    7778                }
    7879            }
    79         } else {
    80             formDataList.push({'name': dataList[i]['name'], 'value': dataList[i]['value']});
    8180        }
     81        else
     82            field.value = dataList[i].value;
     83        if (dataList[i]['filename'])
     84            field.filename = dataList[i].filename;
     85
     86        formDataList.push(field);
    8287    }
    8388
  • trunk/LayoutTests/http/tests/local/formdata/send-form-data-with-filename-expected.txt

    r144677 r144974  
    1 Test for sending FormData via XMLHttpRequest.
     1Test that filename passed to FormData.append() takes precedence over filename in File.
    22
    33On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
  • trunk/LayoutTests/http/tests/local/formdata/send-form-data-with-filename.html

    r144677 r144974  
    99<script src="resources/send-form-data-common.js"></script>
    1010<script>
    11 description("Test for sending FormData via XMLHttpRequest.");
     11description("Test that filename passed to FormData.append() takes precedence over filename in File.");
    1212
    1313function runTest()
  • trunk/Source/WebCore/ChangeLog

    r144972 r144974  
     12013-03-06  Victor Costan <costan@gmail.com>
     2
     3        Cleanup in multipart FormData sending code.
     4        https://bugs.webkit.org/show_bug.cgi?id=111603
     5
     6        Reviewed by Alexey Proskuryakov.
     7
     8        No new tests. This is cleanup.
     9
     10        * platform/network/FormDataBuilder.cpp:
     11        (WebCore::appendQuotedString): use proper types (e.g, size_t instead of
     12        unsigned long)
     13
    1142013-03-06  Tony Gentilcore  <tonyg@chromium.org>
    215
  • trunk/Source/WebCore/platform/network/FormDataBuilder.cpp

    r98896 r144974  
    6060    // FIXME: Is it correct to use percent escaping here? Other browsers do not encode these characters yet,
    6161    // so we should test popular servers to find out if there is an encoding form they can handle.
    62     unsigned length = string.length();
    63     for (unsigned i = 0; i < length; ++i) {
    64         unsigned char c = string.data()[i];
     62    size_t length = string.length();
     63    for (size_t i = 0; i < length; ++i) {
     64        char c = string.data()[i];
    6565
    6666        switch (c) {
Note: See TracChangeset for help on using the changeset viewer.