| OLD | NEW |
| 1 if (this.importScripts) { | 1 if (this.importScripts) { |
| 2 importScripts('../../resources/fs-worker-common.js'); | 2 importScripts('../../resources/fs-worker-common.js'); |
| 3 importScripts('../../resources/fs-test-util.js'); | 3 importScripts('../../resources/fs-test-util.js'); |
| 4 } | 4 } |
| 5 | 5 |
| 6 description("Tests using webkitResolveLocalFileSystemSyncURL to obtain an Entry
from a URL"); | 6 description("Tests using webkitResolveLocalFileSystemSyncURL to obtain an Entry
from a URL"); |
| 7 | 7 |
| 8 var testFileName = '/testFile'; | 8 var testFileName = '/testFile'; |
| 9 var fileSystem = null; | 9 var fileSystem = null; |
| 10 | 10 |
| 11 var expectedPath = null; | 11 var expectedPath = null; |
| 12 var actualPath = null; | 12 var actualPath = null; |
| 13 var errorCode = null; | 13 var errorCode = null; |
| 14 | 14 |
| 15 function createTestFile() { | 15 function createTestFile() { |
| 16 return fileSystem.root.getFile(testFileName, {create:true}); | 16 return fileSystem.root.getFile(testFileName, {create:true}); |
| 17 } | 17 } |
| 18 | 18 |
| 19 function assertEncodingErr(code) { | 19 var error; |
| 20 errorCode = code; | 20 |
| 21 shouldBe("FileException.ENCODING_ERR", "errorCode"); | 21 function assertEncodingErr(e) { |
| 22 error = e; |
| 23 shouldBe("error.name", "'EncodingError'"); |
| 22 } | 24 } |
| 23 | 25 |
| 24 function assertSecurityErr(code) { | 26 function assertSecurityErr(e) { |
| 25 errorCode = code; | 27 error = e; |
| 26 shouldBe("FileException.SECURITY_ERR", "errorCode"); | 28 shouldBe("error.name", "'SecurityError'"); |
| 27 } | 29 } |
| 28 | 30 |
| 29 function assertPathsMatch(expected, actual) { | 31 function assertPathsMatch(expected, actual) { |
| 30 expectedPath = expected; | 32 expectedPath = expected; |
| 31 actualPath = actual; | 33 actualPath = actual; |
| 32 shouldBe("expectedPath", "actualPath"); | 34 shouldBe("expectedPath", "actualPath"); |
| 33 } | 35 } |
| 34 | 36 |
| 35 var isDirectory = false; | 37 var isDirectory = false; |
| 36 function assertIsDirectory(entry) { | 38 function assertIsDirectory(entry) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 61 assertPathsMatch(testFileName, e.fullPath); | 63 assertPathsMatch(testFileName, e.fullPath); |
| 62 assertIsFile(e); | 64 assertIsFile(e); |
| 63 } | 65 } |
| 64 | 66 |
| 65 function runWrongDomain() { | 67 function runWrongDomain() { |
| 66 debug("* Resolving a URL with the wrong security origin (domain)"); | 68 debug("* Resolving a URL with the wrong security origin (domain)"); |
| 67 try { | 69 try { |
| 68 webkitResolveLocalFileSystemSyncURL("filesystem:http://localhost:8000/te
mporary/foo"); | 70 webkitResolveLocalFileSystemSyncURL("filesystem:http://localhost:8000/te
mporary/foo"); |
| 69 testFailed(); | 71 testFailed(); |
| 70 } catch (e) { | 72 } catch (e) { |
| 71 assertSecurityErr(e.code); | 73 assertSecurityErr(e); |
| 72 } | 74 } |
| 73 } | 75 } |
| 74 | 76 |
| 75 function runWrongPort() { | 77 function runWrongPort() { |
| 76 debug("* Resolving a URL with the wrong security origin (port)"); | 78 debug("* Resolving a URL with the wrong security origin (port)"); |
| 77 try { | 79 try { |
| 78 webkitResolveLocalFileSystemSyncURL("filesystem:http://127.0.0.1:8080/te
mporary/foo"); | 80 webkitResolveLocalFileSystemSyncURL("filesystem:http://127.0.0.1:8080/te
mporary/foo"); |
| 79 testFailed(); | 81 testFailed(); |
| 80 } catch (e) { | 82 } catch (e) { |
| 81 assertSecurityErr(e.code); | 83 assertSecurityErr(e); |
| 82 } | 84 } |
| 83 } | 85 } |
| 84 | 86 |
| 85 function runWrongScheme() { | 87 function runWrongScheme() { |
| 86 debug("* Resolving a URL with the wrong security origin (scheme)"); | 88 debug("* Resolving a URL with the wrong security origin (scheme)"); |
| 87 try { | 89 try { |
| 88 webkitResolveLocalFileSystemSyncURL("filesystem:https://127.0.0.1:8000/t
emporary/foo"); | 90 webkitResolveLocalFileSystemSyncURL("filesystem:https://127.0.0.1:8000/t
emporary/foo"); |
| 89 testFailed(); | 91 testFailed(); |
| 90 } catch (e) { | 92 } catch (e) { |
| 91 assertSecurityErr(e.code); | 93 assertSecurityErr(e); |
| 92 } | 94 } |
| 93 } | 95 } |
| 94 | 96 |
| 95 function runBogusURL() { | 97 function runBogusURL() { |
| 96 debug("* Resolving a completely bogus URL."); | 98 debug("* Resolving a completely bogus URL."); |
| 97 try { | 99 try { |
| 98 webkitResolveLocalFileSystemSyncURL("foo"); | 100 webkitResolveLocalFileSystemSyncURL("foo"); |
| 99 testFailed(); | 101 testFailed(); |
| 100 } catch (e) { | 102 } catch (e) { |
| 101 assertEncodingErr(e.code); | 103 assertEncodingErr(e); |
| 102 } | 104 } |
| 103 } | 105 } |
| 104 | 106 |
| 105 function runWrongProtocol() { | 107 function runWrongProtocol() { |
| 106 debug("* Resolving a URL with the wrong protocol"); | 108 debug("* Resolving a URL with the wrong protocol"); |
| 107 try { | 109 try { |
| 108 webkitResolveLocalFileSystemSyncURL("http://127.0.0.1:8000/foo/bar/baz")
; | 110 webkitResolveLocalFileSystemSyncURL("http://127.0.0.1:8000/foo/bar/baz")
; |
| 109 testFailed(); | 111 testFailed(); |
| 110 } catch (e) { | 112 } catch (e) { |
| 111 assertEncodingErr(e.code); | 113 assertEncodingErr(e); |
| 112 } | 114 } |
| 113 } | 115 } |
| 114 | 116 |
| 115 function runNotEnoughSlashes() { | 117 function runNotEnoughSlashes() { |
| 116 debug("* Resolving a URL with no slash between type and file"); | 118 debug("* Resolving a URL with no slash between type and file"); |
| 117 entry = createTestFile(); | 119 entry = createTestFile(); |
| 118 try { | 120 try { |
| 119 webkitResolveLocalFileSystemSyncURL("filesystem:http://127.0.0.1:8000/te
mporarytestFile"); | 121 webkitResolveLocalFileSystemSyncURL("filesystem:http://127.0.0.1:8000/te
mporarytestFile"); |
| 120 testFailed(); | 122 testFailed(); |
| 121 } catch (e) { | 123 } catch (e) { |
| 122 assertEncodingErr(e.code); | 124 assertEncodingErr(e); |
| 123 } | 125 } |
| 124 } | 126 } |
| 125 | 127 |
| 126 function runNotEnoughSlashes2() { | 128 function runNotEnoughSlashes2() { |
| 127 debug("* Resolving a URL with no slash between protocol and type (bogus port
)"); | 129 debug("* Resolving a URL with no slash between protocol and type (bogus port
)"); |
| 128 entry = createTestFile(); | 130 entry = createTestFile(); |
| 129 try { | 131 try { |
| 130 webkitResolveLocalFileSystemSyncURL("filesystem:http://127.0.0.1:8000tem
porary/testFile"); | 132 webkitResolveLocalFileSystemSyncURL("filesystem:http://127.0.0.1:8000tem
porary/testFile"); |
| 131 } catch (e) { | 133 } catch (e) { |
| 132 assertSecurityErr(e.code); | 134 assertSecurityErr(e); |
| 133 } | 135 } |
| 134 } | 136 } |
| 135 | 137 |
| 136 function runUseBackSlashes() { | 138 function runUseBackSlashes() { |
| 137 debug("* Resolve a path using backslashes"); | 139 debug("* Resolve a path using backslashes"); |
| 138 entry = fileSystem.root.getDirectory("foo", {create:true}).getFile("testFile
", {create:true}); | 140 entry = fileSystem.root.getDirectory("foo", {create:true}).getFile("testFile
", {create:true}); |
| 139 var e = webkitResolveLocalFileSystemSyncURL("filesystem:http://127.0.0.1:800
0/temporary/foo\\testFile"); | 141 var e = webkitResolveLocalFileSystemSyncURL("filesystem:http://127.0.0.1:800
0/temporary/foo\\testFile"); |
| 140 assertPathsMatch("/foo/testFile", e.fullPath); | 142 assertPathsMatch("/foo/testFile", e.fullPath); |
| 141 assertIsFile(e); | 143 assertIsFile(e); |
| 142 } | 144 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 testsList[i](); | 192 testsList[i](); |
| 191 removeAllInDirectorySync(fileSystem.root); | 193 removeAllInDirectorySync(fileSystem.root); |
| 192 entry = null; | 194 entry = null; |
| 193 } | 195 } |
| 194 debug("Finished running tests."); | 196 debug("Finished running tests."); |
| 195 finishJSTest(); | 197 finishJSTest(); |
| 196 } else | 198 } else |
| 197 debug("This test requires FileSystem API support."); | 199 debug("This test requires FileSystem API support."); |
| 198 | 200 |
| 199 var successfullyParsed = true; | 201 var successfullyParsed = true; |
| OLD | NEW |