summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/filesystem/simple-readonly-file-object.html
blob: 961ff9b81135d094bab1f558e335a1df6e1e9e2d (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<!DOCTYPE html>
<html>
<head>
<script src="resources/fs-test-util.js"></script>
<script src="../../resources/js-test.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script>
description("Test readonly attributes of File.");

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

function setReadonlyProperty(property, value)
{
    oldValue = eval(property);
    debug("trying to set readonly property " + property);
    evalAndLog(property + " = " + value);
    newValue = eval(property);
    if (oldValue == newValue) {
        testPassed(property + " is still " + oldValue);
    } else {
        testFailed(property + " value was changed");
    }
}

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

function fileCallback(file) {
    testFile = file;
    setReadonlyProperty("testFile.size", "1");
    setReadonlyProperty("testFile.type", "'application/octet-stream'");
    setReadonlyProperty("testFile.name", "'bar'");
    finishJSTest();
}

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

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

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

var jsTestIsAsync = true;
evalAndLog("webkitRequestFileSystem(TEMPORARY, 100, fileSystemCallback, errorCallback);");
</script>
</body>
</html>