Return-Path: X-Original-To: apmail-cordova-commits-archive@www.apache.org Delivered-To: apmail-cordova-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id DEFB610939 for ; Fri, 28 Feb 2014 19:54:29 +0000 (UTC) Received: (qmail 62659 invoked by uid 500); 28 Feb 2014 19:54:22 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 62596 invoked by uid 500); 28 Feb 2014 19:54:21 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cordova.apache.org Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 62508 invoked by uid 99); 28 Feb 2014 19:54:20 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 28 Feb 2014 19:54:20 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 2610693130A; Fri, 28 Feb 2014 19:54:20 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: ian@apache.org To: commits@cordova.apache.org Message-Id: <2064fa66cf234ca7b6b674c97f1b4ec5@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: spec commit: CB-6116: Test handling of resolveLocalFileSystemURL on file://localhost/ URLs Date: Fri, 28 Feb 2014 19:54:20 +0000 (UTC) Repository: cordova-mobile-spec Updated Branches: refs/heads/master dcef9fb7c -> 74de382ad CB-6116: Test handling of resolveLocalFileSystemURL on file://localhost/ URLs 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/74de382a Tree: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/tree/74de382a Diff: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/diff/74de382a Branch: refs/heads/master Commit: 74de382ade125bf58a68c0434d9f70268291d94c Parents: dcef9fb Author: Ian Clelland Authored: Fri Feb 28 14:53:59 2014 -0500 Committer: Ian Clelland Committed: Fri Feb 28 14:53:59 2014 -0500 ---------------------------------------------------------------------- autotest/tests/file.tests.js | 154 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 154 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/74de382a/autotest/tests/file.tests.js ---------------------------------------------------------------------- diff --git a/autotest/tests/file.tests.js b/autotest/tests/file.tests.js index 14c32a5..f6d517e 100644 --- a/autotest/tests/file.tests.js +++ b/autotest/tests/file.tests.js @@ -4156,6 +4156,160 @@ describe('File API', function() { waitsFor(function() { return checkEntry.wasCalled; }, "checkEntry callback never called", Tests.TEST_TIMEOUT); }); + }); + describe('resolveLocalFileSystemURL on file://', function() { + /* These specs verify that window.resolveLocalFileSystemURL works correctly on file:// URLs + */ + it("file.spec.117 should not resolve native URLs outside of FS roots", function() { + var fail = jasmine.createSpy().andCallFake(function(error) { + expect(error).toBeDefined(); + }), + win = createWin('window.resolveLocalFileSystemURI'); + + // lookup file system entry + runs(function() { + window.resolveLocalFileSystemURL("file:///this.is.an.invalid.url", win, fail); + }); + + waitsFor(function() { return fail.wasCalled; }, "error callback never called", Tests.TEST_TIMEOUT); + + runs(function() { + expect(fail).toHaveBeenCalled(); + expect(win).not.toHaveBeenCalled(); + }); + }); + it("file.spec.118 should not resolve native URLs outside of FS roots", function() { + var fail = jasmine.createSpy().andCallFake(function(error) { + expect(error).toBeDefined(); + }), + win = createWin('window.resolveLocalFileSystemURI'); + + // lookup file system entry + runs(function() { + window.resolveLocalFileSystemURL("file://localhost/this.is.an.invalid.url", win, fail); + }); + + waitsFor(function() { return fail.wasCalled; }, "error callback never called", Tests.TEST_TIMEOUT); + + runs(function() { + expect(fail).toHaveBeenCalled(); + expect(win).not.toHaveBeenCalled(); + }); + }); + it("file.spec.119 should not resolve invalid native URLs", function() { + var fail = jasmine.createSpy().andCallFake(function(error) { + expect(error).toBeDefined(); + }), + win = createWin('window.resolveLocalFileSystemURI'); + + // lookup file system entry + runs(function() { + window.resolveLocalFileSystemURL("file://localhost", win, fail); + }); + + waitsFor(function() { return fail.wasCalled; }, "error callback never called", Tests.TEST_TIMEOUT); + + runs(function() { + expect(fail).toHaveBeenCalled(); + expect(win).not.toHaveBeenCalled(); + }); + }); + it("file.spec.120 should not resolve invalid native URLs with query strings", function() { + var fail = jasmine.createSpy().andCallFake(function(error) { + expect(error).toBeDefined(); + }), + win = createWin('window.resolveLocalFileSystemURI'); + + // lookup file system entry + runs(function() { + window.resolveLocalFileSystemURL("file://localhost?test/test", win, fail); + }); + + waitsFor(function() { return fail.wasCalled; }, "error callback never called", Tests.TEST_TIMEOUT); + + runs(function() { + expect(fail).toHaveBeenCalled(); + expect(win).not.toHaveBeenCalled(); + }); + }); + it("file.spec.121 should resolve native URLs returned by API", function() { + var fileName = "native.resolve.uri1", + fail = createFail('window.resolveLocalFileSystemURI'), + checkEntry = jasmine.createSpy().andCallFake(function(entry) { + expect(entry.fullPath).toEqual("/" + fileName); + // cleanup + deleteEntry(fileName); + }); + + // create a new file entry + runs(function() { + createFile(fileName, function(entry) { + resolveLocalFileSystemURL(entry.toNativeURL(), checkEntry, fail); + }, fail); + }); + + waitsFor(function() { return checkEntry.wasCalled; }, "checkEntry callback never called", Tests.TEST_TIMEOUT); + }); + it("file.spec.122 should resolve native URLs returned by API with localhost", function() { + var fileName = "native.resolve.uri2", + fail = createFail('window.resolveLocalFileSystemURI'), + checkEntry = jasmine.createSpy().andCallFake(function(entry) { + expect(entry.fullPath).toEqual("/" + fileName); + // cleanup + deleteEntry(fileName); + }); + + // create a new file entry + runs(function() { + createFile(fileName, function(entry) { + var url = entry.toNativeURL(); + url = url.replace("///","//localhost/"); + resolveLocalFileSystemURL(url, checkEntry, fail); + }, fail); + }); + + waitsFor(function() { return checkEntry.wasCalled; }, "checkEntry callback never called", Tests.TEST_TIMEOUT); + }); + it("file.spec.123 should resolve native URLs returned by API with query string", function() { + var fileName = "native.resolve.uri3", + fail = createFail('window.resolveLocalFileSystemURI'), + checkEntry = jasmine.createSpy().andCallFake(function(entry) { + expect(entry.fullPath).toEqual("/" + fileName); + // cleanup + deleteEntry(fileName); + }); + + // create a new file entry + runs(function() { + createFile(fileName, function(entry) { + var url = entry.toNativeURL(); + url = url + "?test/test"; + resolveLocalFileSystemURL(url, checkEntry, fail); + }, fail); + }); + + waitsFor(function() { return checkEntry.wasCalled; }, "checkEntry callback never called", Tests.TEST_TIMEOUT); + }); + it("file.spec.124 should resolve native URLs returned by API with localhost and query string", function() { + var fileName = "native.resolve.uri4", + fail = createFail('window.resolveLocalFileSystemURI'), + checkEntry = jasmine.createSpy().andCallFake(function(entry) { + expect(entry.fullPath).toEqual("/" + fileName); + // cleanup + deleteEntry(fileName); + }); + + // create a new file entry + runs(function() { + createFile(fileName, function(entry) { + var url = entry.toNativeURL(); + url = url.replace("///","//localhost/") + "?test/test"; + resolveLocalFileSystemURL(url, checkEntry, fail); + }, fail); + }); + + waitsFor(function() { return checkEntry.wasCalled; }, "checkEntry callback never called", Tests.TEST_TIMEOUT); + }); }); });