1 function removeAllInDirectorySync(directory
)
5 var reader
= directory
.createReader();
7 var entries
= reader
.readEntries();
8 for (var i
= 0; i
< entries
.length
; ++i
) {
9 if (entries
[i
].isDirectory
)
10 entries
[i
].removeRecursively();
14 } while (entries
.length
);
17 onmessage = function(evt
)
20 // Increase the change of getting caught doing a sync operation
21 // by repeating the opration multiple times.
22 for (var i
= 0; i
< 10; ++i
) {
23 if (evt
.data
== 'requestFileSystemSync') {
24 if (!this.webkitRequestFileSystemSync
)
26 webkitRequestFileSystemSync(this.TEMPORARY
, 100);
27 } else if (evt
.data
== 'fileSyncOperations') {
28 if (!this.webkitRequestFileSystemSync
)
30 // Do many different sync filesystem operations. If this starts crashing,
31 // then a simple investigation would be to isolate these commands.
32 var fileSystem
= webkitRequestFileSystemSync(this.TEMPORARY
, 100);
34 removeAllInDirectorySync(fileSystem
.root
);
37 var a
= fileSystem
.root
.getFile('a', {create
:true});
38 var b
= fileSystem
.root
.getDirectory('b', {create
:true});
39 var c
= fileSystem
.root
.getDirectory('c', {create
:true});
40 var d
= fileSystem
.root
.getFile('d', {create
:true});
43 var a_copy
= a
.copyTo(b
, 'tmp');
44 var metadata
= a
.getMetadata();
45 var b_parent
= b
.getParent();
46 var c_copy
= c
.copyTo(fileSystem
.root
, 'f');
47 var d_new
= d
.moveTo(fileSystem
.root
, 'd2');
48 var e
= fileSystem
.root
.getFile('e', {create
:true});
51 var reader
= fileSystem
.root
.createReader();
55 var entries
= reader
.readEntries();
56 for (var i
= 0; i
< entries
.length
; ++i
) {
57 paths
.push(entries
[i
].fullPath
);
58 if (entries
[i
].isDirectory
)
61 } while (entries
.length
);
63 removeAllInDirectorySync(fileSystem
.root
);
67 // Purposely ignore any exceptions. Since the whole purpose of this test is to try
68 // to interrupt the synchronous operations, they will naturally throw exceptions,
69 // but which ones throw exception isn't determinant and we don't want random output
70 // showing up as a console message.
74 postMessage('started');