summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/filesystem/resources/file-from-file-entry.js
blob: 09cd5f7937613ca623a150c4686bbd187565e2bd (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
if (this.importScripts) {
    importScripts('fs-worker-common.js');
    importScripts('../../../resources/js-test.js');
    importScripts('fs-test-util.js');
}

description("Obtaining File from FileEntry.");

var fileSystem = null;
var testFileName = '/testFileEntry.txt';
var testFileEntry = null;
var testFile = null;

function errorCallback(error) {
    testFailed("Error occured:" + error.name);
    finishJSTest();
}

function fileCallback(file) {
    testFile = file;
    shouldBe("testFile.name", "testFileEntry.name");
    shouldBe("testFile.type", "'text/plain'");
    shouldBe("testFile.size", "0");
    finishJSTest();
}

function getFileFromEntry(entry) {
    testFileEntry = entry;
    entry.file(fileCallback, errorCallback);
}

function createTestFile() {
    fileSystem.root.getFile(testFileName, {create:true}, getFileFromEntry, errorCallback);
}

function fileSystemCallback(fs) {
    fileSystem = fs;
    removeAllInDirectory(fileSystem.root, createTestFile, errorCallback);
}

var jsTestIsAsync = true;
webkitRequestFileSystem(TEMPORARY, 100, fileSystemCallback, errorCallback);