You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2013/01/15 03:52:43 UTC

spec commit: Add autotest for fetching file:/// with FileTransfer.

Updated Branches:
  refs/heads/master f9ae3788b -> 1f8bd78ff


Add autotest for fetching file:/// with FileTransfer.

https://issues.apache.org/jira/browse/CB-2183


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/1f8bd78f
Tree: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/tree/1f8bd78f
Diff: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/diff/1f8bd78f

Branch: refs/heads/master
Commit: 1f8bd78ffc57c8e63a991bfbe393300ad38d7901
Parents: f9ae378
Author: Andrew Grieve <ag...@chromium.org>
Authored: Mon Jan 14 21:51:59 2013 -0500
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Mon Jan 14 21:51:59 2013 -0500

----------------------------------------------------------------------
 autotest/tests/filetransfer.tests.js |   28 ++++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/1f8bd78f/autotest/tests/filetransfer.tests.js
----------------------------------------------------------------------
diff --git a/autotest/tests/filetransfer.tests.js b/autotest/tests/filetransfer.tests.js
index 8c1cd35..843a662 100644
--- a/autotest/tests/filetransfer.tests.js
+++ b/autotest/tests/filetransfer.tests.js
@@ -136,6 +136,34 @@ describe('FileTransfer', function() {
 
             waitsForAny(downloadWin, fail);
         });
+        it("should be able to download a file using file:// (when hosted from file://)", function() {
+            var fail = createDoNotCallSpy('downloadFail');
+            var remoteFile = window.location.href;
+            var localFileName = remoteFile.substring(remoteFile.lastIndexOf('/')+1);
+            var lastProgressEvent = null;
+
+            if (!/^file/.exec(remoteFile)) {
+                expect(remoteFile).toMatch(/^file:/);
+                return;
+            }
+
+            var downloadWin = jasmine.createSpy().andCallFake(function(entry) {
+                expect(entry.name).toBe(localFileName);
+                expect(lastProgressEvent.loaded).toBeGreaterThan(1);
+            });
+
+            this.after(function() {
+                deleteFile(localFileName);
+            });
+
+            var ft = new FileTransfer();
+            ft.onprogress = function(e) {
+                lastProgressEvent = e;
+            };
+            ft.download(remoteFile, root.fullPath + "/" + localFileName, downloadWin, fail);
+
+            waitsForAny(downloadWin, fail);
+        });
         it("should be able to download a file using https", function() {
             var remoteFile = "https://www.apache.org/licenses/";
             var localFileName = 'httpstest.html';