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 2014/05/27 03:10:53 UTC

[2/2] git commit: Delete explicit toNativeURL() since file: is now the default

Delete explicit toNativeURL() since file: is now the default


Project: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/commit/a8c23d63
Tree: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/tree/a8c23d63
Diff: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/diff/a8c23d63

Branch: refs/heads/master
Commit: a8c23d6325e82f4d4a4793fbe43bad546b07e35f
Parents: 10e6be0
Author: Andrew Grieve <ag...@chromium.org>
Authored: Mon May 26 21:10:21 2014 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Mon May 26 21:10:21 2014 -0400

----------------------------------------------------------------------
 www/cdvah/js/DirectoryManager.js |  1 +
 www/cdvah/js/Installer.js        | 53 +++++++++++++++++------------------
 www/cdvah/js/ResourcesLoader.js  |  4 ---
 3 files changed, 27 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/a8c23d63/www/cdvah/js/DirectoryManager.js
----------------------------------------------------------------------
diff --git a/www/cdvah/js/DirectoryManager.js b/www/cdvah/js/DirectoryManager.js
index 3ff0ef5..9f0c737 100644
--- a/www/cdvah/js/DirectoryManager.js
+++ b/www/cdvah/js/DirectoryManager.js
@@ -61,6 +61,7 @@
             if (this._assetManifest.hasOwnProperty(relativePath)) {
                 return this._assetManifest[relativePath];
             }
+            return '';
         };
 
         DirectoryManager.prototype.getAssetManifestEtag = function() {

http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/a8c23d63/www/cdvah/js/Installer.js
----------------------------------------------------------------------
diff --git a/www/cdvah/js/Installer.js b/www/cdvah/js/Installer.js
index 49a6d92..1363c31 100644
--- a/www/cdvah/js/Installer.js
+++ b/www/cdvah/js/Installer.js
@@ -80,7 +80,7 @@
 
         Installer.prototype.updateCordovaPluginsFile = function(etag) {
             var self = this;
-            return self.getPluginMetadata()
+            return $q.when(self.getPluginMetadata())
             .then(function(metadata) {
                 self.plugins = PluginMetadata.process(metadata);
                 var pluginIds = Object.keys(metadata);
@@ -120,33 +120,32 @@
                 var urlutil = cordova.require('cordova/urlutil');
                 var harnessUrl = urlutil.makeAbsolute(location.pathname);
                 var harnessDir = harnessUrl.replace(/\/[^\/]*\/[^\/]*$/, '');
-                var installUrl = self.directoryManager.rootURL;
+                var realWwwUrl = self.directoryManager.rootURL + 'www';
                 var startLocation = urlutil.makeAbsolute(self.startPage).replace('/cdvah/', '/');
-                var useNativeStartLocation = platformId == 'ios';
-
-                // Use toNativeURL() so that scheme is file:/ instead of cdvfile:/ (file: has special access).
-                return ResourcesLoader.toNativeURL(installUrl)
-                .then(function(nativeInstallUrl) {
-                    nativeInstallUrl = nativeInstallUrl.replace(/\/$/, '');
-                    // Point right at the dest. location on iOS.
-                    if (useNativeStartLocation) {
-                        startLocation = startLocation.replace(harnessDir, nativeInstallUrl + '/www');
-                    }
-
-                    // Override cordova.js, and www/plugins to point at bundled plugins.
-                    UrlRemap.aliasUri('^(?!app-harness://).*/www/cordova\\.js.*', '.+', 'app-harness:///cordova.js', false /* redirect */, true /* allowFurtherRemapping */);
-                    UrlRemap.aliasUri('^(?!app-harness://).*/www/plugins/.*', '^.*?/www/plugins/' , 'app-harness:///plugins/', false /* redirect */, true /* allowFurtherRemapping */);
-
-                    // Make any references to www/ point to the app's install location.
-                    var harnessPrefixPattern = '^' + harnessDir.replace('file:///', 'file://.*?/');
-                    UrlRemap.aliasUri(harnessPrefixPattern, harnessPrefixPattern, nativeInstallUrl + '/www', false /* redirect */, true /* allowFurtherRemapping */);
-
-                    // Set-up app-harness: scheme to point at the harness.
-                    UrlRemap.aliasUri('^app-harness:///cdvah/index.html', '^app-harness://', harnessDir, true, false);
-                    return UrlRemap.aliasUri('^app-harness:', '^app-harness://', harnessDir, false, false)
-                    .then(function() {
-                        return startLocation;
-                    });
+                var realStartLocation = startLocation.replace(harnessDir, realWwwUrl);
+
+                // Point right at the dest. location on iOS.
+                if (platformId == 'ios') {
+                    startLocation = realStartLocation;
+                }
+
+                if (!/^file:/.exec(startLocation)) {
+                    throw new Error('Expected to start with file: ' + startLocation);
+                }
+
+                // Override cordova.js, and www/plugins to point at bundled plugins.
+                UrlRemap.aliasUri('^(?!app-harness://).*/www/cordova\\.js.*', '.+', 'app-harness:///cordova.js', false /* redirect */, true /* allowFurtherRemapping */);
+                UrlRemap.aliasUri('^(?!app-harness://).*/www/plugins/.*', '^.*?/www/plugins/' , 'app-harness:///plugins/', false /* redirect */, true /* allowFurtherRemapping */);
+
+                // Make any references to www/ point to the app's install location.
+                var harnessPrefixPattern = '^' + harnessDir.replace('file:///', 'file://.*?/');
+                UrlRemap.aliasUri(harnessPrefixPattern, harnessPrefixPattern, realWwwUrl, false /* redirect */, true /* allowFurtherRemapping */);
+
+                // Set-up app-harness: scheme to point at the harness.
+                UrlRemap.aliasUri('^app-harness:///cdvah/index.html', '^app-harness://', harnessDir, true, false);
+                return UrlRemap.aliasUri('^app-harness:', '^app-harness://', harnessDir, false, false)
+                .then(function() {
+                    return startLocation;
                 });
             });
         };

http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/a8c23d63/www/cdvah/js/ResourcesLoader.js
----------------------------------------------------------------------
diff --git a/www/cdvah/js/ResourcesLoader.js b/www/cdvah/js/ResourcesLoader.js
index f8a0434..557275d 100644
--- a/www/cdvah/js/ResourcesLoader.js
+++ b/www/cdvah/js/ResourcesLoader.js
@@ -130,10 +130,6 @@
                 return resolveURL(url).then(function() { return true; }, function() { return false; });
             },
 
-            toNativeURL: function(url){
-                return resolveURL(url).then(function(e) { return e.toNativeURL(); });
-            },
-
             // returns a promise with a full path to the downloaded file
             downloadFromUrl: function(from, to) {
                 return ensureDirectoryExists(dirName(to))