1 description("Passing Flags parameter tests. This test checks if passing Flags parameters to DirectoryEntry.getFile does not crash and works as expected.");
3 var testFileName = '/non_existent_file';
5 var expectedCallbacksCount = 0;
6 var unexpectedCallbacksCount = 0;
7 var expected = function(e) { expectedCallbacksCount++; };
8 var unexpected = function(e) { unexpectedCallbacksCount++; };
14 runJSONTestWithExclusive,
20 function runNextTest(v) {
21 if (testCounter == testsList.length) {
22 debug("Finished running tests.");
23 shouldBe('expectedCallbacksCount', '1');
24 shouldBe('unexpectedCallbacksCount', '0');
27 (testsList[testCounter++])();
30 function errorCallback(error) {
31 debug("Error occured during requesting Temporary FileSystem:" + error.name);
35 // Test body functions ----------------------------------------------------
36 function runNullTest(v) {
37 debug("* Passing null as a flags parameter.");
39 // This should be ok and we treat it as {false, false} Flags.
40 fileSystem.root.getFile(testFileName, null, runNextTest, errorCallback);
43 function runNonObjectTest(v) {
44 debug("* Passing a number as a flags parameter.");
47 // This should be not be ok because 7 is not an object.
48 fileSystem.root.getFile(testFileName, 7, errorCallback, errorCallback);
50 debug("Caught exception: " + ex);
55 function runObjectTest(v) {
56 // WebKitFlags no longer has a visible constructor.
57 if (window.WebKitFlags)
58 throw "There should be no constructor for WebKitFlags!";
62 function runJSONTest(v) {
63 debug("* Passing JSON Flags object.");
65 fileSystem.root.getFile(testFileName, {create:false}, unexpected, expected);
66 fileSystem.root.getFile(testFileName, {create:true}, runNextTest, errorCallback);
69 function runJSONTestWithExclusive(v) {
70 debug("* Passing JSON Flags object (with exclusive=true).");
73 fileSystem.root.getFile(testFileName, {create:true, exclusive:true}, errorCallback, runNextTest);
76 // End of test body functions ---------------------------------------------
78 function cleanupAndRunNext(v) {
79 fileSystem.root.getFile(testFileName, {create:false}, function(entry) {
80 // Remove the entry before start testing.
81 entry.remove(runNextTest, errorCallback);
85 function fileSystemCallback(fs) {
90 if (window.webkitRequestFileSystem) {
91 window.jsTestIsAsync = true;
92 webkitRequestFileSystem(window.TEMPORARY, 100, fileSystemCallback, errorCallback);
94 debug("This test requires FileSystem API support.");