Backout 2865d46e472d (bug 778079) for xpcshell failures on a CLOSED TREE. r=IfYoureGoingToUseTryLookAtTheResultsBeforePushingToInbound

This commit is contained in:
Ryan VanderMeulen 2012-08-29 18:58:31 -04:00
parent 9f725f39e3
commit 29b9becedd
6 changed files with 54 additions and 95 deletions

View File

@ -23,19 +23,14 @@ DirectoryProvider.prototype = {
getFile: function dp_getFile(prop, persistent) {
#ifdef MOZ_WIDGET_GONK
let localProps = ["cachePDir", "webappsDir", "PrefD", "indexedDBPDir",
"permissionDBPDir", "UpdRootD"];
"permissionDBPDir", "UpdRootD"];
if (localProps.indexOf(prop) != -1) {
prop.persistent = true;
let file = Cc["@mozilla.org/file/local;1"]
.createInstance(Ci.nsILocalFile)
file.initWithPath(LOCAL_DIR);
persistent.value = true;
return file;
} else if (prop == "coreAppsDir") {
let file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile)
file.initWithPath("/system/b2g");
persistent.value = true;
return file;
}
}
#endif
return null;

View File

@ -30,7 +30,6 @@ let AppsUtils = {
installTime: aApp.installTime,
manifestURL: aApp.manifestURL,
appStatus: aApp.appStatus,
removable: aApp.removable,
localId: aApp.localId,
progress: aApp.progress || 0.0,
status: aApp.status || "installed"

View File

@ -20,7 +20,8 @@ function convertAppsArray(aApps, aWindow) {
let apps = Cu.createArrayIn(aWindow);
for (let i = 0; i < aApps.length; i++) {
let app = aApps[i];
apps.push(createApplicationObject(aWindow, app));
apps.push(createApplicationObject(aWindow, app.origin, app.manifest, app.manifestURL,
app.receipts, app.installOrigin, app.installTime));
}
return apps;
@ -72,7 +73,8 @@ WebappsRegistry.prototype = {
let app = msg.app;
switch (aMessage.name) {
case "Webapps:Install:Return:OK":
Services.DOMRequest.fireSuccess(req, createApplicationObject(this._window, app));
Services.DOMRequest.fireSuccess(req, createApplicationObject(this._window, app.origin, app.manifest, app.manifestURL, app.receipts,
app.installOrigin, app.installTime));
break;
case "Webapps:Install:Return:KO":
Services.DOMRequest.fireError(req, msg.error || "DENIED");
@ -80,7 +82,8 @@ WebappsRegistry.prototype = {
case "Webapps:GetSelf:Return:OK":
if (msg.apps.length) {
app = msg.apps[0];
Services.DOMRequest.fireSuccess(req, createApplicationObject(this._window, app));
Services.DOMRequest.fireSuccess(req, createApplicationObject(this._window, app.origin, app.manifest, app.manifestURL, app.receipts,
app.installOrigin, app.installTime));
} else {
Services.DOMRequest.fireSuccess(req, null);
}
@ -220,9 +223,9 @@ WebappsRegistry.prototype = {
* mozIDOMApplication object
*/
function createApplicationObject(aWindow, aApp) {
function createApplicationObject(aWindow, aOrigin, aManifest, aManifestURL, aReceipts, aInstallOrigin, aInstallTime) {
let app = Cc["@mozilla.org/webapps/application;1"].createInstance(Ci.mozIDOMApplication);
app.wrappedJSObject.init(aWindow, aApp);
app.wrappedJSObject.init(aWindow, aOrigin, aManifest, aManifestURL, aReceipts, aInstallOrigin, aInstallTime);
return app;
}
@ -243,24 +246,20 @@ WebappsApplication.prototype = {
onprogress: 'rw',
launch: 'r',
receipts: 'r',
removable: 'r',
uninstall: 'r'
},
init: function(aWindow, aApp) {
this.origin = aApp.origin;
this.manifest = ObjectWrapper.wrap(aApp.manifest, aWindow);
this.manifestURL = aApp.manifestURL;
this.receipts = aApp.receipts;
this.installOrigin = aApp.installOrigin;
this.installTime = aApp.installTime;
init: function(aWindow, aOrigin, aManifest, aManifestURL, aReceipts, aInstallOrigin, aInstallTime) {
this.origin = aOrigin;
this.manifest = ObjectWrapper.wrap(aManifest, aWindow);
this.manifestURL = aManifestURL;
this.receipts = aReceipts;
this.installOrigin = aInstallOrigin;
this.installTime = aInstallTime;
this.status = "installed";
this.removable = aApp.removable;
this.progress = NaN;
this._onprogress = null;
this.initHelper(aWindow, ["Webapps:Uninstall:Return:OK",
"Webapps:Uninstall:Return:KO",
"Webapps:OfflineCache"]);
this.initHelper(aWindow, ["Webapps:Uninstall:Return:OK", "Webapps:Uninstall:Return:KO", "Webapps:OfflineCache"]);
},
set onprogress(aCallback) {
@ -423,14 +422,15 @@ WebappsApplicationMgmt.prototype = {
if (this._oninstall) {
let app = msg.app;
let event = new this._window.MozApplicationEvent("applicationinstall",
{ application : createApplicationObject(this._window, app) });
{ application : createApplicationObject(this._window, app.origin, app.manifest, app.manifestURL, app.receipts,
app.installOrigin, app.installTime) });
this._oninstall.handleEvent(event);
}
break;
case "Webapps:Uninstall:Return:OK":
if (this._onuninstall) {
let event = new this._window.MozApplicationEvent("applicationuninstall",
{ application : createApplicationObject(this._window, { origin: msg.origin }) });
{ application : createApplicationObject(this._window, msg.origin, null, null, null, null, 0) });
this._onuninstall.handleEvent(event);
}
break;

View File

@ -71,41 +71,24 @@ let DOMApplicationRegistry = {
this.appsFile = FileUtils.getFile(DIRECTORY_NAME,
["webapps", "webapps.json"], true);
let dirList = [DIRECTORY_NAME];
#ifdef MOZ_WIDGET_GONK
dirList.push("coreAppsDir");
#endif
let currentId = 1;
dirList.forEach((function(dir) {
let curFile = FileUtils.getFile(dir, ["webapps", "webapps.json"], true);
if (curFile.exists()) {
let appDir = FileUtils.getDir(dir, ["webapps"]);
this._loadJSONAsync(curFile, (function(aData) {
if (!aData) {
return;
}
// Add new apps to the merged list.
for (let id in aData) {
this.webapps[id] = aData[id];
this.webapps[id].basePath = appDir.path;
this.webapps[id].removable = (dir == DIRECTORY_NAME);
if (this.appsFile.exists()) {
this._loadJSONAsync(this.appsFile, (function(aData) {
this.webapps = aData;
for (let id in this.webapps) {
#ifdef MOZ_SYS_MSG
this._processManifestForId(id);
this._processManifestForId(id);
#endif
// local ids must be stable between restarts.
// We partition the ids in two buckets:
// - 1 to 1000 for the core apps.
// - 1001 to Inf for installed apps.
// This way, a gecko update with new core apps will not lead to
// changes for installed apps ids.
if (!this.webapps[id].removable) {
this.webapps[id].localId = currentId++;
}
};
}).bind(this));
}
}).bind(this));
if (!this.webapps[id].localId) {
this.webapps[id].localId = this._nextLocalId();
}
// Default to a non privileged status.
if (this.webapps[id].appStatus === undefined) {
this.webapps[id].appStatus = Ci.nsIPrincipal.APP_STATUS_INSTALLED;
}
};
}).bind(this));
}
try {
let hosts = Services.prefs.getCharPref("dom.mozApps.whitelist");
@ -271,7 +254,7 @@ let DOMApplicationRegistry = {
this.installPackage(msg);
break;
case "Webapps:GetBasePath":
return this.webapps[msg.id].basePath;
return FileUtils.getFile(DIRECTORY_NAME, ["webapps"], true).path;
break;
case "Webapps:GetList":
this.children.push(aMessage.target);
@ -279,11 +262,6 @@ let DOMApplicationRegistry = {
}
},
_getAppDir: function(aId) {
FileUtils.getDir(this.webapps[aId].removable ? DIRECTORY_NAME : "coreAppsDir",
["webapps", aId], true, true);
},
_writeFile: function ss_writeFile(aFile, aData, aCallbak) {
// Initialize the file output stream.
let ostream = FileUtils.openSafeFileOutputStream(aFile);
@ -316,13 +294,12 @@ let DOMApplicationRegistry = {
confirmInstall: function(aData, aFromSync, aProfileDir, aOfflineCacheObserver) {
let app = aData.app;
app.removable = true;
let id = app.syncId || this._appId(app.origin);
let localId = this.getAppLocalIdByManifestURL(app.manifestURL);
// Installing an application again is considered as an update.
if (id) {
let dir = this._getAppDir(id);
let dir = FileUtils.getDir(DIRECTORY_NAME, ["webapps", id], true, true);
try {
dir.remove(true);
} catch(e) {
@ -398,8 +375,7 @@ let DOMApplicationRegistry = {
},
_nextLocalId: function() {
// All installed apps have a localId > 1000.
let maxLocalId = 1000;
let maxLocalId = Ci.nsIScriptSecurityManager.NO_APP_ID;
for (let id in this.webapps) {
if (this.webapps[id].localId > maxLocalId) {
@ -443,10 +419,9 @@ let DOMApplicationRegistry = {
let id = aData[index].id;
// the manifest file used to be named manifest.json, so fallback on this.
let baseDir = (this.webapps[id].removable ? DIRECTORY_NAME : "coreAppsDir");
let file = FileUtils.getFile(baseDir, ["webapps", id, "manifest.webapp"], true);
let file = FileUtils.getFile(DIRECTORY_NAME, ["webapps", id, "manifest.webapp"], true);
if (!file.exists()) {
file = FileUtils.getFile(baseDir, ["webapps", id, "manifest.json"], true);
file = FileUtils.getFile(DIRECTORY_NAME, ["webapps", id, "manifest.json"], true);
}
this._loadJSONAsync(file, (function(aJSON) {
@ -623,9 +598,6 @@ let DOMApplicationRegistry = {
continue;
}
if (!this.webapps[id].removable)
return;
found = true;
let appNote = JSON.stringify(AppsUtils.cloneAppObject(app));
appNote.id = id;
@ -636,7 +608,7 @@ let DOMApplicationRegistry = {
#endif
}).bind(this));
let dir = this._getAppDir(id);
let dir = FileUtils.getDir(DIRECTORY_NAME, ["webapps", id], true, true);
try {
dir.remove(true);
} catch (e) {}
@ -789,11 +761,11 @@ let DOMApplicationRegistry = {
for (let i = 0; i < aRecords.length; i++) {
let record = aRecords[i];
if (record.hidden) {
if (!this.webapps[record.id] || !this.webapps[record.id].removable)
if (!this.webapps[record.id])
continue;
let origin = this.webapps[record.id].origin;
delete this.webapps[record.id];
let dir = this._getAppDir(record.id);
let dir = FileUtils.getDir(DIRECTORY_NAME, ["webapps", record.id], true, true);
try {
dir.remove(true);
} catch (e) {
@ -826,12 +798,8 @@ let DOMApplicationRegistry = {
wipe: function(aCallback) {
let ids = this.getAllIDs();
for (let id in ids) {
if (!this.webapps[id].removable) {
continue;
}
delete this.webapps[id];
let dir = this._getAppDir(id);
let dir = FileUtils.getDir(DIRECTORY_NAME, ["webapps", id], true, true);
try {
dir.remove(true);
} catch (e) {

View File

@ -8,7 +8,7 @@
interface nsIDOMDOMRequest;
interface nsIArray;
[scriptable, uuid(e3649c1d-c950-495e-b0ed-6ce40be9743b)]
[scriptable, uuid(9583b825-46b1-4e8f-bb48-9fed660a95e6)]
interface mozIDOMApplication : nsISupports
{
readonly attribute jsval manifest;
@ -17,7 +17,6 @@ interface mozIDOMApplication : nsISupports
readonly attribute DOMString origin;
readonly attribute DOMString installOrigin;
readonly attribute unsigned long long installTime;
readonly attribute boolean removable;
/*
* The current progress when downloading an offline cache.

View File

@ -16,7 +16,7 @@ XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
"nsISyncMessageSender");
function AppProtocolHandler() {
this._basePath = [];
this._basePath = null;
}
AppProtocolHandler.prototype = {
@ -30,14 +30,12 @@ AppProtocolHandler.prototype = {
Ci.nsIProtocolHandler.URI_NOAUTH |
Ci.nsIProtocolHandler.URI_LOADABLE_BY_ANYONE,
getBasePath: function app_phGetBasePath(aId) {
if (!this._basePath[aId]) {
this._basePath[aId] = cpmm.sendSyncMessage("Webapps:GetBasePath",
{ id: aId })[0] + "/";
get basePath() {
if (!this._basePath) {
this._basePath = cpmm.sendSyncMessage("Webapps:GetBasePath", { })[0] + "/";
}
return this._basePath[aId];
return this._basePath;
},
newURI: function app_phNewURI(aSpec, aOriginCharset, aBaseURI) {
@ -62,7 +60,7 @@ AppProtocolHandler.prototype = {
}
// Build a jar channel and masquerade as an app:// URI.
let uri = "jar:file://" + this.getBasePath(appId) + appId + "/application.zip!" + fileSpec;
let uri = "jar:file://" + this.basePath + appId + "/application.zip!" + fileSpec;
let channel = Services.io.newChannel(uri, null, null);
channel.QueryInterface(Ci.nsIJARChannel).setAppURI(aURI);
channel.QueryInterface(Ci.nsIChannel).originalURI = aURI;