[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.22-985-g3c00f00
jianli at chromium.org
jianli at chromium.org
Wed Mar 17 18:34:59 UTC 2010
The following commit has been merged in the webkit-1.1 branch:
commit 339598a52683c16ce2ed312f213e71defdff3ea9
Author: jianli at chromium.org <jianli at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Fri Mar 12 02:15:46 2010 +0000
Add more test cases for Blob.slice.
https://bugs.webkit.org/show_bug.cgi?id=36038
Reviewed by Dmitry Titov.
* http/tests/local/resources/abe.png: Copied from LayoutTests/editing/resources/abe.png.
* http/tests/local/resources/empty.txt: Copied from LayoutTests/http/tests/appcache/resources/empty.txt.
* http/tests/local/resources/send-sliced-dragged-file.js:
* http/tests/local/send-sliced-dragged-file-expected.txt:
* http/tests/resources/post-and-verify.cgi: Added.
* http/tests/resources/write-temp-file.php:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@55873 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 22a2be9..69049fd 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,5 +1,19 @@
2010-03-11 Jian Li <jianli at chromium.org>
+ Reviewed by Dmitry Titov.
+
+ Add more test cases for Blob.slice.
+ https://bugs.webkit.org/show_bug.cgi?id=36038
+
+ * http/tests/local/resources/abe.png: Copied from LayoutTests/editing/resources/abe.png.
+ * http/tests/local/resources/empty.txt: Copied from LayoutTests/http/tests/appcache/resources/empty.txt.
+ * http/tests/local/resources/send-sliced-dragged-file.js:
+ * http/tests/local/send-sliced-dragged-file-expected.txt:
+ * http/tests/resources/post-and-verify.cgi: Added.
+ * http/tests/resources/write-temp-file.php:
+
+2010-03-11 Jian Li <jianli at chromium.org>
+
Unreviewed. Added the test that time out on Tiger bot to mac-tiger/Skipped.
* platform/mac-tiger/Skipped:
diff --git a/LayoutTests/editing/resources/abe.png b/LayoutTests/http/tests/local/resources/abe.png
similarity index 100%
copy from LayoutTests/editing/resources/abe.png
copy to LayoutTests/http/tests/local/resources/abe.png
diff --git a/LayoutTests/http/tests/appcache/resources/empty.txt b/LayoutTests/http/tests/local/resources/empty.txt
similarity index 100%
copy from LayoutTests/http/tests/appcache/resources/empty.txt
copy to LayoutTests/http/tests/local/resources/empty.txt
diff --git a/LayoutTests/http/tests/local/resources/send-sliced-dragged-file.js b/LayoutTests/http/tests/local/resources/send-sliced-dragged-file.js
index c2289a8..4252962 100644
--- a/LayoutTests/http/tests/local/resources/send-sliced-dragged-file.js
+++ b/LayoutTests/http/tests/local/resources/send-sliced-dragged-file.js
@@ -1,14 +1,13 @@
description("Test for slicing a dragged file and sending it via XMLHttpRequest.");
-var originalText = "1234567890";
+var tempFileContent = "1234567890";
var tempFileName = "send-slice-dragged-file.tmp";
-var tempFileOriginalModificationTime;
var subfile;
-function uploadFile(file, expectedText, expectedException)
+function uploadFile(file, filePath, start, length, expectedException)
{
var xhr = new XMLHttpRequest();
- xhr.open("POST", "http://127.0.0.1:8000/xmlhttprequest/resources/post-echo.cgi", false);
+ xhr.open("POST", "http://127.0.0.1:8000/resources/post-and-verify.cgi?path=" + filePath + "&start=" + start + "&length=" + length, false);
var passed;
var message;
@@ -18,12 +17,12 @@ function uploadFile(file, expectedText, expectedException)
passed = false;
message = "Unexpected response data received: " + xhr.responseText + ". Expecting exception thrown";
} else {
- if (xhr.responseText == expectedText) {
+ if (xhr.responseText == "OK") {
passed = true;
message = "Expected response data received: " + xhr.responseText;
} else {
passed = false;
- message = "Unexpected response data received: " + xhr.responseText + ". Expecting: " + expectedText;
+ message = "Unexpected response data received: " + xhr.responseText;
}
}
} catch (ex) {
@@ -53,12 +52,12 @@ function createTempFile(fileData)
}
var values = xhr.responseText.split('\n');
- if (values.length < 2) {
+ if (xhr.responseText.indexOf("FAIL") == 0) {
testFailed("Unexpected response text received: " + xhr.responseText);
return;
}
- return values;
+ return xhr.responseText;
}
function touchTempFile()
@@ -75,40 +74,50 @@ function removeTempFile()
xhr.send();
}
-function onStableFileDrop(file, start, length)
+function computeExpectedLength(fileLength, start, length)
+{
+ var expectedLength = length;
+ if (start + length > fileLength) {
+ if (start >= fileLength)
+ expectedLength = 0;
+ else
+ expectedLength = fileLength - start;
+ }
+ return expectedLength;
+}
+
+function onStableFileDrop(file, filePath, fileLength, start, length)
{
// Slice the file.
subfile = file.slice(start, length);
- var expectedText = originalText.substring(start, start + length);
- shouldEvaluateTo("subfile.size", expectedText.length);
+ shouldEvaluateTo("subfile.size", computeExpectedLength(fileLength, start, length));
// Upload the sliced file.
- uploadFile(subfile, expectedText, false);
+ uploadFile(subfile, filePath, start, length, false);
}
-function dragAndSliceStableFile(start, length)
+function dragAndSliceStableFile(filePath, fileLength, start, length)
{
- setFileInputDropCallback(function(file) { onStableFileDrop(file, start, length); });
- eventSender.beginDragWithFiles(["resources/file-for-drag-to-send.txt"]);
+ setFileInputDropCallback(function(file) { onStableFileDrop(file, "../local/" + filePath, fileLength, start, length); });
+ eventSender.beginDragWithFiles([filePath]);
moveMouseToCenterOfElement(fileInput);
eventSender.mouseUp();
}
-function onUnstableFileDrop(file, start, length)
+function onUnstableFileDrop(file, filePath, fileLength, start, length)
{
// Slice the file.
subfile = file.slice(start, length);
- var expectedText = originalText.substring(start, start + length);
- shouldEvaluateTo("subfile.size", expectedText.length);
+ shouldEvaluateTo("subfile.size", computeExpectedLength(fileLength, start, length));
// Upload the sliced file.
- uploadFile(subfile, expectedText, false);
+ uploadFile(subfile, filePath, start, length, false);
// Touch the underlying temp file.
touchTempFile();
// Upload the sliced file. We should receive an exception since the file has been changed.
- uploadFile(subfile, null, true);
+ uploadFile(subfile, filePath, start, length, true);
// Remove the temp file.
removeTempFile();
@@ -116,15 +125,11 @@ function onUnstableFileDrop(file, start, length)
function dragAndSliceUnstableFile(start, length)
{
- var tempFileInfo = createTempFile(originalText);
- if (tempFileInfo.length < 2) {
- done();
+ var tempFilePath = createTempFile(tempFileContent);
+ if (tempFilePath.length == 0)
return;
- }
- var tempFilePath = tempFileInfo[0];
- tempFileOriginalModificationTime = tempFileInfo[1];
- setFileInputDropCallback(function(file) { onUnstableFileDrop(file, start, length); });
+ setFileInputDropCallback(function(file) { onUnstableFileDrop(file, tempFilePath, tempFileContent.length, start, length); });
eventSender.beginDragWithFiles([tempFilePath]);
moveMouseToCenterOfElement(fileInput);
eventSender.mouseUp();
@@ -132,10 +137,21 @@ function dragAndSliceUnstableFile(start, length)
function runTest()
{
- dragAndSliceStableFile(2, 4);
- dragAndSliceStableFile(2, 20);
- dragAndSliceStableFile(15, 20);
+ debug("Test slicing and sending an empty file.");
+ dragAndSliceStableFile("resources/empty.txt", 0, 0, 10);
+
+ debug("Test slicing and sending a small file.");
+ dragAndSliceStableFile("resources/file-for-drag-to-send.txt", 10, 2, 4);
+ dragAndSliceStableFile("resources/file-for-drag-to-send.txt", 10, 2, 20);
+ dragAndSliceStableFile("resources/file-for-drag-to-send.txt", 10, 15, 20);
+
+ // This is to test a file that exceeds the read buffer limit (2K in Mac).
+ debug("Test slicing and sending a big file.");
+ dragAndSliceStableFile("resources/abe.png", 12242, 10, 40);
+ dragAndSliceStableFile("resources/abe.png", 12242, 10, 3000);
+ dragAndSliceStableFile("resources/abe.png", 12242, 3000, 15000);
+ debug("Test slicing and sending a file that has been changed right before sending.");
dragAndSliceUnstableFile(3, 5);
}
diff --git a/LayoutTests/http/tests/local/send-sliced-dragged-file-expected.txt b/LayoutTests/http/tests/local/send-sliced-dragged-file-expected.txt
index b460791..2015a3d 100644
--- a/LayoutTests/http/tests/local/send-sliced-dragged-file-expected.txt
+++ b/LayoutTests/http/tests/local/send-sliced-dragged-file-expected.txt
@@ -3,18 +3,34 @@ Test for slicing a dragged file and sending it via XMLHttpRequest.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+Test slicing and sending an empty file.
+PASS event.dataTransfer contains a File object on drop.
+PASS subfile.size is 0
+PASS Expected response data received: OK
+Test slicing and sending a small file.
PASS event.dataTransfer contains a File object on drop.
PASS subfile.size is 4
-PASS Expected response data received: 3456
+PASS Expected response data received: OK
PASS event.dataTransfer contains a File object on drop.
PASS subfile.size is 8
-PASS Expected response data received: 34567890
+PASS Expected response data received: OK
PASS event.dataTransfer contains a File object on drop.
PASS subfile.size is 0
-PASS Expected response data received:
+PASS Expected response data received: OK
+Test slicing and sending a big file.
+PASS event.dataTransfer contains a File object on drop.
+PASS subfile.size is 40
+PASS Expected response data received: OK
+PASS event.dataTransfer contains a File object on drop.
+PASS subfile.size is 3000
+PASS Expected response data received: OK
+PASS event.dataTransfer contains a File object on drop.
+PASS subfile.size is 9242
+PASS Expected response data received: OK
+Test slicing and sending a file that has been changed right before sending.
PASS event.dataTransfer contains a File object on drop.
PASS subfile.size is 5
-PASS Expected response data received: 45678
+PASS Expected response data received: OK
PASS Expected exception thrown: Error: NETWORK_ERR: XMLHttpRequest Exception 101
PASS successfullyParsed is true
diff --git a/LayoutTests/http/tests/resources/post-and-verify.cgi b/LayoutTests/http/tests/resources/post-and-verify.cgi
new file mode 100755
index 0000000..2c7aa62
--- /dev/null
+++ b/LayoutTests/http/tests/resources/post-and-verify.cgi
@@ -0,0 +1,30 @@
+#!/usr/bin/perl -w
+
+print "Content-type: text/plain\n\n";
+
+if ($ENV{'REQUEST_METHOD'} eq "POST") {
+ if ($ENV{'CONTENT_LENGTH'}) {
+ read(STDIN, $postData, $ENV{'CONTENT_LENGTH'}) || die "Could not get post data\n";
+ } else {
+ $postData = "";
+ }
+
+ @list = split(/&/, $ENV{'QUERY_STRING'});
+ foreach $element (@list) {
+ ($key, $value) = split(/=/, $element);
+ $values{$key} = $value;
+ }
+
+ open FILE, $values{'path'} || die("Could not open file\n");
+ seek FILE, $values{'start'}, 0;
+ read FILE, $expectedData, $values{'length'};
+ close(FILE);
+
+ if ($postData eq $expectedData) {
+ print "OK";
+ } else {
+ print "FAILED";
+ }
+} else {
+ print "Wrong method: " . $ENV{'REQUEST_METHOD'} . "\n";
+}
diff --git a/LayoutTests/http/tests/resources/write-temp-file.php b/LayoutTests/http/tests/resources/write-temp-file.php
index ffe2c8c..7abe358 100644
--- a/LayoutTests/http/tests/resources/write-temp-file.php
+++ b/LayoutTests/http/tests/resources/write-temp-file.php
@@ -13,8 +13,5 @@ if (!file_put_contents($tmpFile, $_GET['data'])) {
exit();
}
-$stat = stat($tmpFile);
-
-echo $tmpFile . "\n";
-echo $stat['mtime'];
+echo $tmpFile;
?>
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list