summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/filesystem/resources/sync-operations.js
blob: 1a8a870c40b40c28842b11ef088d4816e35d7682 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
if (this.importScripts) {
    importScripts('../resources/fs-worker-common.js');
    importScripts('../../../resources/js-test.js');
    importScripts('../resources/fs-test-util.js');
}

description("Test making multiple synchronous FileSystem operations.");

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 = [];
var entries;
do {
    entries = reader.readEntries();
    shouldBe('entries.__proto__', 'Array.prototype');
    for (var i = 0; i < entries.length; ++i) {
        paths.push(entries[i].fullPath);
        if (entries[i].isDirectory)
            dirsCount++;
    }
} while (entries.length);

paths.sort();
shouldBe('"' + paths.join(',') + '"', '"/a,/b,/c,/d2,/e,/f"');
shouldBe("dirsCount", "3");
removeAllInDirectorySync(fileSystem.root);
finishJSTest();