Backed out changeset e9429bd59114 (bug 873567) for mochitest-2 failures.

CLOSED TREE
This commit is contained in:
Ryan VanderMeulen 2013-08-01 21:43:53 -04:00
parent 595cbc9fd5
commit e51ba7c524
2 changed files with 52 additions and 65 deletions

View File

@ -1920,70 +1920,17 @@ this.DOMApplicationRegistry = {
// content side. This let the webpage the opportunity to set event handlers // content side. This let the webpage the opportunity to set event handlers
// on the app before we start firing progress events. // on the app before we start firing progress events.
queuedDownload: {}, queuedDownload: {},
queuedPackageDownload: {},
onInstallSuccessAck: function onInstallSuccessAck(aManifestURL) { onInstallSuccessAck: function onInstallSuccessAck(aManifestURL) {
let cacheDownload = this.queuedDownload[aManifestURL]; let download = this.queuedDownload[aManifestURL];
if (cacheDownload) { if (!download) {
this.startOfflineCacheDownload(cacheDownload.manifest,
cacheDownload.app,
cacheDownload.profileDir,
cacheDownload.offlineCacheObserver);
delete this.queuedDownload[aManifestURL];
return; return;
} }
this.startOfflineCacheDownload(download.manifest,
let packageDownload = this.queuedPackageDownload[aManifestURL]; download.app,
if (packageDownload) { download.profileDir,
let manifest = packageDownload.manifest; download.offlineCacheObserver);
let appObject = packageDownload.app; delete this.queuedDownload[aManifestURL];
let installSuccessCallback = packageDownload.callback;
delete this.queuedPackageDownload[aManifestURL];
this.downloadPackage(manifest, appObject, false, (function(aId, aManifest) {
// Move the zip out of TmpD.
let app = DOMApplicationRegistry.webapps[aId];
let zipFile = FileUtils.getFile("TmpD", ["webapps", aId, "application.zip"], true);
let dir = this._getAppDir(aId);
zipFile.moveTo(dir, "application.zip");
let tmpDir = FileUtils.getDir("TmpD", ["webapps", aId], true, true);
try {
tmpDir.remove(true);
} catch(e) { }
// Save the manifest
let manFile = dir.clone();
manFile.append("manifest.webapp");
this._writeFile(manFile, JSON.stringify(aManifest), function() { });
// Set state and fire events.
app.installState = "installed";
app.downloading = false;
app.downloadAvailable = false;
this._saveApps((function() {
this.updateAppHandlers(null, aManifest, appObject);
this.broadcastMessage("Webapps:AddApp", { id: aId, app: appObject });
if (supportUseCurrentProfile()) {
// Update the permissions for this app.
PermissionsInstaller.installPermissions({ manifest: aManifest,
origin: appObject.origin,
manifestURL: appObject.manifestURL },
true);
}
debug("About to fire Webapps:PackageEvent 'installed'");
this.broadcastMessage("Webapps:PackageEvent",
{ type: "installed",
manifestURL: appObject.manifestURL,
app: app,
manifest: aManifest });
if (installSuccessCallback) {
installSuccessCallback(aManifest);
}
}).bind(this));
}).bind(this));
}
}, },
confirmInstall: function(aData, aFromSync, aProfileDir, confirmInstall: function(aData, aFromSync, aProfileDir,
@ -2121,12 +2068,47 @@ this.DOMApplicationRegistry = {
// origin for install apps is meaningless here, since it's app:// and this // origin for install apps is meaningless here, since it's app:// and this
// can't be used to resolve package paths. // can't be used to resolve package paths.
manifest = new ManifestHelper(jsonManifest, app.manifestURL); manifest = new ManifestHelper(jsonManifest, app.manifestURL);
this.downloadPackage(manifest, appObject, false, (function(aId, aManifest) {
// Success! Move the zip out of TmpD.
let app = DOMApplicationRegistry.webapps[aId];
let zipFile = FileUtils.getFile("TmpD", ["webapps", aId, "application.zip"], true);
let dir = this._getAppDir(id);
zipFile.moveTo(dir, "application.zip");
let tmpDir = FileUtils.getDir("TmpD", ["webapps", aId], true, true);
try {
tmpDir.remove(true);
} catch(e) { }
this.queuedPackageDownload[app.manifestURL] = { // Save the manifest
manifest: manifest, let manFile = dir.clone();
app: appObject, manFile.append("manifest.webapp");
callback: aInstallSuccessCallback this._writeFile(manFile, JSON.stringify(aManifest), function() { });
} // Set state and fire events.
app.installState = "installed";
app.downloading = false;
app.downloadAvailable = false;
this._saveApps((function() {
this.updateAppHandlers(null, aManifest, appObject);
this.broadcastMessage("Webapps:AddApp", { id: aId, app: appObject });
if (supportUseCurrentProfile()) {
// Update the permissions for this app.
PermissionsInstaller.installPermissions({ manifest: aManifest,
origin: appObject.origin,
manifestURL: appObject.manifestURL },
true);
}
debug("About to fire Webapps:PackageEvent 'installed'");
this.broadcastMessage("Webapps:PackageEvent",
{ type: "installed",
manifestURL: appObject.manifestURL,
app: app,
manifest: aManifest });
if (aInstallSuccessCallback) {
aInstallSuccessCallback(aManifest);
}
}).bind(this));
}).bind(this));
} }
}, },

View File

@ -18,11 +18,16 @@ MOCHITEST_FILES = \
file_cached_app.template.appcache \ file_cached_app.template.appcache \
file_hosted_app.template.webapp \ file_hosted_app.template.webapp \
test_app_update.html \ test_app_update.html \
$(NULL)
ifdef MOZ_B2G
MOCHITEST_FILES += \
file_packaged_app.sjs \ file_packaged_app.sjs \
file_packaged_app.template.webapp \ file_packaged_app.template.webapp \
file_packaged_app.template.html \ file_packaged_app.template.html \
test_packaged_app_install.html \ test_packaged_app_install.html \
$(NULL) $(NULL)
endif
MOCHITEST_CHROME_FILES = \ MOCHITEST_CHROME_FILES = \
test_apps_service.xul \ test_apps_service.xul \