Skip to content
Permalink
Browse files
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.

Canonical link: https://commits.webkit.org/129987@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@144974 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
pwnall authored and webkit-commit-queue committed Mar 6, 2013
1 parent a8adca1 commit 865101833fc1f878f0fb0dc9829b117f29d5a743
Showing 6 changed files with 50 additions and 18 deletions.
@@ -1,3 +1,17 @@
2013-03-06 Victor Costan <costan@gmail.com>

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 <rniwa@webkit.org>

Add a flaky crash test expectation to platform/mac/fast/speechsynthesis/speech-synthesis-cancel.html
@@ -28,10 +28,10 @@ function sendFormData(formDataList, fileSliced, sendAsAsync, addEventHandlers)
{
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 @@ function testSendingFormData(dataList, sendAsAsync, addEventHandlers)
{
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 @@ function testSendingFormData(dataList, sendAsAsync, addEventHandlers)
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);
@@ -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".

@@ -8,7 +8,7 @@
<div id="console"></div>
<script src="resources/send-form-data-common.js"></script>
<script>
description("Test for sending FormData via XMLHttpRequest.");
description("Test that filename passed to FormData.append() takes precedence over filename in File.");

function runTest()
{
@@ -1,3 +1,16 @@
2013-03-06 Victor Costan <costan@gmail.com>

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 <tonyg@chromium.org>

Threaded HTML parser should use 8 bit strings for attributes
@@ -59,9 +59,9 @@ static void appendQuotedString(Vector<char>& buffer, const CString& string)
// 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:

0 comments on commit 8651018

Please sign in to comment.