Commit 4144fea8 authored by levin@chromium.org's avatar levin@chromium.org

[chromium] FileSystem bridge needs threadsafe fixes and other clean-up.

https://bugs.webkit.org/show_bug.cgi?id=74666

Reviewed by Dmitry Titov.

Tests for all of the fixes done in bugs related to 74666.

* http/tests/workers/resources/open-database-sync.js: Removed.
* http/tests/workers/resources/sync-operations.js: Added.
(removeAllInDirectorySync):
(onmessage):
* http/tests/workers/terminate-during-sync-operation-expected.txt: Added.
* http/tests/workers/terminate-during-sync-operation.html: Renamed from LayoutTests/http/tests/workers/interrupt-database-sync-open-crash.html-skipped.
* platform/chromium/test_expectations.txt:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@104113 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 38e29bc0
2012-01-04 David Levin <levin@chromium.org>
[chromium] FileSystem bridge needs threadsafe fixes and other clean-up.
https://bugs.webkit.org/show_bug.cgi?id=74666
Reviewed by Dmitry Titov.
Tests for all of the fixes done in bugs related to 74666.
* http/tests/workers/resources/open-database-sync.js: Removed.
* http/tests/workers/resources/sync-operations.js: Added.
(removeAllInDirectorySync):
(onmessage):
* http/tests/workers/terminate-during-sync-operation-expected.txt: Added.
* http/tests/workers/terminate-during-sync-operation.html: Renamed from LayoutTests/http/tests/workers/interrupt-database-sync-open-crash.html-skipped.
* platform/chromium/test_expectations.txt:
2012-01-04 Kenneth Russell <kbr@google.com>
Fix semantics of WEBKIT_WEBGL_lose_context
postMessage('started');
onmessage = function(evt)
{
if (evt.data == 'openDatabaseSync')
openDatabaseSync('', '', '', 1);
}
function removeAllInDirectorySync(directory)
{
if (!directory)
return;
var reader = directory.createReader();
do {
var entries = reader.readEntries();
for (var i = 0; i < entries.length; ++i) {
if (entries[i].isDirectory)
entries[i].removeRecursively();
else
entries[i].remove();
}
} while (entries.length);
}
onmessage = function(evt)
{
try {
// Increase the change of getting caught doing a sync operation
// by repeating the opration multiple times.
for (var i = 0; i < 10; ++i) {
if (evt.data == 'openDatabaseSync')
openDatabaseSync('', '', '', 1);
else if (evt.data == 'requestFileSystemSync') {
if (!this.webkitRequestFileSystemSync)
return;
webkitRequestFileSystemSync(this.TEMPORARY, 100);
} else if (evt.data == 'fileSyncOperations') {
if (!this.webkitRequestFileSystemSync)
return;
// Do many different sync filesystem operations. If this starts crashing,
// then a simple investigation would be to isolate these commands.
var fileSystem = webkitRequestFileSystemSync(this.TEMPORARY, 100);
removeAllInDirectorySync(fileSystem.root);
// Stage 1 (prepare)
var a = fileSystem.root.getFile('a', {create:true});
var b = fileSystem.root.getDirectory('b', {create:true});
var c = fileSystem.root.getDirectory('c', {create:true});
var d = fileSystem.root.getFile('d', {create:true});
// Stage 2 (test)
var a_copy = a.copyTo(b, 'tmp');
var metadata = a.getMetadata();
var b_parent = b.getParent();
var c_copy = c.copyTo(fileSystem.root, 'f');
var d_new = d.moveTo(fileSystem.root, 'd2');
var e = fileSystem.root.getFile('e', {create:true});
// Verify
var reader = fileSystem.root.createReader();
var dirsCount = 0;
var paths = [];
do {
var entries = reader.readEntries();
for (var i = 0; i < entries.length; ++i) {
paths.push(entries[i].fullPath);
if (entries[i].isDirectory)
dirsCount++;
}
} while (entries.length);
removeAllInDirectorySync(fileSystem.root);
}
}
} catch (e) {
// Purposely ignore any exceptions. Since the whole purpose of this test is to try
// to interrupt the synchronous operations, they will naturally throw exceptions,
// but which ones throw exception isn't determinant and we don't want random output
// showing up as a console message.
}
}
postMessage('started');
Test that terminating the worker while it is performing synchronous file or database operations will not cause any crashes, asserts, etc.
Starting test run.
Waiting for all workers to exit.
Testing interrupting: openDatabaseSync
Starting workers.
Started worker count: 1
Started worker count: 2
Started worker count: 3
Started worker count: 4
Started worker count: 5
Started worker count: 6
Started worker count: 7
Started worker count: 8
Started worker count: 9
Started worker count: 10
Started worker count: 11
Started worker count: 12
Started worker count: 13
Started worker count: 14
Started worker count: 15
Started worker count: 16
Started worker count: 17
Started worker count: 18
Started worker count: 19
Started worker count: 20
Started worker count: 21
Started worker count: 22
Started worker count: 23
Started worker count: 24
Started worker count: 25
Started worker count: 26
Started worker count: 27
Started worker count: 28
Started worker count: 29
Started worker count: 30
Running operation.
Closed worker count: 1
Closed worker count: 2
Closed worker count: 3
Closed worker count: 4
Closed worker count: 5
Closed worker count: 6
Closed worker count: 7
Closed worker count: 8
Closed worker count: 9
Closed worker count: 10
Closed worker count: 11
Closed worker count: 12
Closed worker count: 13
Closed worker count: 14
Closed worker count: 15
Closed worker count: 16
Closed worker count: 17
Closed worker count: 18
Closed worker count: 19
Closed worker count: 20
Closed worker count: 21
Closed worker count: 22
Closed worker count: 23
Closed worker count: 24
Closed worker count: 25
Closed worker count: 26
Closed worker count: 27
Closed worker count: 28
Closed worker count: 29
Closed worker count: 30
Waiting for all workers to exit.
Testing interrupting: requestFileSystemSync
Starting workers.
Started worker count: 1
Started worker count: 2
Started worker count: 3
Started worker count: 4
Started worker count: 5
Started worker count: 6
Started worker count: 7
Started worker count: 8
Started worker count: 9
Started worker count: 10
Started worker count: 11
Started worker count: 12
Started worker count: 13
Started worker count: 14
Started worker count: 15
Started worker count: 16
Started worker count: 17
Started worker count: 18
Started worker count: 19
Started worker count: 20
Started worker count: 21
Started worker count: 22
Started worker count: 23
Started worker count: 24
Started worker count: 25
Started worker count: 26
Started worker count: 27
Started worker count: 28
Started worker count: 29
Started worker count: 30
Running operation.
Closed worker count: 1
Closed worker count: 2
Closed worker count: 3
Closed worker count: 4
Closed worker count: 5
Closed worker count: 6
Closed worker count: 7
Closed worker count: 8
Closed worker count: 9
Closed worker count: 10
Closed worker count: 11
Closed worker count: 12
Closed worker count: 13
Closed worker count: 14
Closed worker count: 15
Closed worker count: 16
Closed worker count: 17
Closed worker count: 18
Closed worker count: 19
Closed worker count: 20
Closed worker count: 21
Closed worker count: 22
Closed worker count: 23
Closed worker count: 24
Closed worker count: 25
Closed worker count: 26
Closed worker count: 27
Closed worker count: 28
Closed worker count: 29
Closed worker count: 30
Waiting for all workers to exit.
Testing interrupting: fileSyncOperations
Starting workers.
Started worker count: 1
Started worker count: 2
Started worker count: 3
Started worker count: 4
Started worker count: 5
Started worker count: 6
Started worker count: 7
Started worker count: 8
Started worker count: 9
Started worker count: 10
Started worker count: 11
Started worker count: 12
Started worker count: 13
Started worker count: 14
Started worker count: 15
Started worker count: 16
Started worker count: 17
Started worker count: 18
Started worker count: 19
Started worker count: 20
Started worker count: 21
Started worker count: 22
Started worker count: 23
Started worker count: 24
Started worker count: 25
Started worker count: 26
Started worker count: 27
Started worker count: 28
Started worker count: 29
Started worker count: 30
Running operation.
Closed worker count: 1
Closed worker count: 2
Closed worker count: 3
Closed worker count: 4
Closed worker count: 5
Closed worker count: 6
Closed worker count: 7
Closed worker count: 8
Closed worker count: 9
Closed worker count: 10
Closed worker count: 11
Closed worker count: 12
Closed worker count: 13
Closed worker count: 14
Closed worker count: 15
Closed worker count: 16
Closed worker count: 17
Closed worker count: 18
Closed worker count: 19
Closed worker count: 20
Closed worker count: 21
Closed worker count: 22
Closed worker count: 23
Closed worker count: 24
Closed worker count: 25
Closed worker count: 26
Closed worker count: 27
Closed worker count: 28
Closed worker count: 29
Closed worker count: 30
Waiting for all workers to exit.
DONE
......@@ -5,46 +5,49 @@
var workersStarted;
var workersClosed;
// Do the test 10 times because the crash didn't happen every time, but
// it happen with a high degree of confidence in 10 iterations.
var remainingIterations = 10;
var testNumber = -1;
var syncOperationTests = new Array('openDatabaseSync', 'requestFileSystemSync', 'fileSyncOperations');
// 30 workers seemed to cause the crash to happen frequently.
var workers = new Array(30);
function nextIteration()
function startNextTest()
{
log('Remaining iterations: ' + remainingIterations);
testNumber++;
log('Waiting for all workers to exit.');
if (testNumber >= syncOperationTests.length) {
waitUntilWorkerThreadsExit(done)
return;
}
waitUntilWorkerThreadsExit(startWorkers)
}
function startWorkers()
{
if (!remainingIterations) {
done();
return;
}
remainingIterations--;
log('Testing interrupting: ' + syncOperationTests[testNumber]);
log('Starting workers.');
workersStarted = 0;
workersClosed = 0;
for (var i = 0; i < workers.length; ++i) {
workers[i] = new Worker('resources/open-database-sync.js?arg=' + i)
workers[i].onmessage = waitForAllWorkersToStart;
workers[i] = new Worker('resources/sync-operations.js?arg=' + i)
workers[i].onmessage = onWorkerStarted;
}
}
// Do our best to try to interrupt the databse open
// Do our best to try to interrupt the database open
// call by waiting for the worker to start and then
// telling it to do the open database call (and
// then terminate the worker).
function waitForAllWorkersToStart()
function onWorkerStarted()
{
workersStarted++;
log('Started worker count: ' + workersStarted);
if (workersStarted < workers.length)
return;
log('Running operation.');
for (var i = 0; i < workers.length; ++i)
workers[i].postMessage('openDatabaseSync');
workers[i].postMessage(syncOperationTests[testNumber]);
setTimeout('closeWorker()', 0);
}
......@@ -53,23 +56,26 @@ function closeWorker()
{
workers[workersClosed].terminate();
workersClosed++;
log('Closed worker count: ' + workersClosed);
if (workersClosed < workers.length)
setTimeout('closeWorker()', 3);
else
nextIteration();
startNextTest();
}
function runTest()
{
log('Starting test run.');
if (window.layoutTestController) {
layoutTestController.dumpAsText();
layoutTestController.waitUntilDone();
}
nextIteration();
startNextTest();
}
</script>
</head>
<body onload='runTest()'>
<p>Test that terminating the worker while it is performing synchronous file or database operations will not cause any crashes, asserts, etc.</p>
<div id='result'>
</div>
</body>
......
......@@ -189,7 +189,7 @@ BUGWK74466 : fast/workers/worker-script-error.html = PASS TIMEOUT FAIL
// Tests timing out because layoutTestController.workerThreadCount is not implemented in DRT
BUGWK74653 SKIP : http/tests/xmlhttprequest/workers/abort-exception-assert.html = TIMEOUT
//BUGWK74653 SKIP : http/tests/workers/interrupt-database-sync-open-crash.html = TIMEOUT
BUGWK74653 SKIP : http/tests/workers/terminate-during-sync-operation.html = TIMEOUT
BUGWK74653 SKIP : fast/workers/storage/interrupt-database.html = TIMEOUT
BUGWK71968 : fast/files/workers/worker-apply-blob-url-to-xhr.html = TEXT
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment