You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ia...@apache.org on 2013/12/16 06:26:50 UTC
spec commit: CB-5403: Test backwards compatibility with file:// urls
in file plugin
Updated Branches:
refs/heads/master 8043a2783 -> db0707997
CB-5403: Test backwards compatibility with file:// urls in file plugin
Project: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/commit/db070799
Tree: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/tree/db070799
Diff: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/diff/db070799
Branch: refs/heads/master
Commit: db0707997443053c348f54c11570aed0fffccc2f
Parents: 8043a27
Author: Ian Clelland <ic...@chromium.org>
Authored: Sun Dec 15 23:36:43 2013 -0500
Committer: Ian Clelland <ic...@chromium.org>
Committed: Mon Dec 16 00:26:24 2013 -0500
----------------------------------------------------------------------
autotest/tests/file.tests.js | 47 +++++++++++++++++++++++++++++++++++++++
1 file changed, 47 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/db070799/autotest/tests/file.tests.js
----------------------------------------------------------------------
diff --git a/autotest/tests/file.tests.js b/autotest/tests/file.tests.js
index aeba723..959fa80 100644
--- a/autotest/tests/file.tests.js
+++ b/autotest/tests/file.tests.js
@@ -3880,4 +3880,51 @@ describe('File API', function() {
});
});
});
+ describe('Backwards compatibility', function() {
+ /* These specs exist to test that the File plugin can still recognize file:///
+ * URLs, and can resolve them to FileEntry and DirectoryEntry objects.
+ * They rely on an undocumented interface to File which provides absolute file
+ * paths, which are not used internally anymore.
+ * If that interface is not present, then these tests will silently succeed.
+ */
+ it("file.spec.109 should be able to resolve a file:/// URL", function() {
+ var localFilename = 'file.txt';
+ var localURL = dirPath = joinURL(root.toURL(), 'file.txt');
+ var originalEntry;
+
+ var unsupportedOperation = jasmine.createSpy("Operation not supported");
+
+ var resolveWin = jasmine.createSpy("resolveWin").andCallFake(function(fileEntry) {
+ expect(fileEntry.toURL()).toEqual(originalEntry.toURL());
+ // cleanup
+ deleteFile(fileName);
+ });
+ var resolveFail = createDoNotCallSpy('resolveFail');
+ var getFail = createDoNotCallSpy('getFail');
+
+ runs(function() {
+ root.getFile(localFilename, {create: true}, function(entry) {
+ originalEntry = entry;
+ /* This is an undocumented interface to File which exists only for testing
+ * backwards compatibilty. By obtaining the raw filesystem path of the download
+ * location, we can pass that to ft.download() to make sure that previously-stored
+ * paths are still valid.
+ */
+ cordova.exec(function(localPath) {
+ window.resolveLocalFileSystemURI("file://" + localPath, resolveWin, resolveFail);
+ }, unsupportedOperation, 'File', '_getLocalFilesystemPath', [entry.toURL()]);
+ }, getFail);
+ });
+
+ waitsForAny(resolveWin, resolveFail, getFail, unsupportedOperation);
+
+ runs(function() {
+ if (!unsupportedOperation.wasCalled) {
+ expect(resolveWin).toHaveBeenCalled();
+ expect(resolveFail).not.toHaveBeenCalled();
+ }
+ });
+
+ });
+ });
});