Bug 837572 - Cannot access any property by the manifest of app object. r=fabrice

This commit is contained in:
Gene Lian 2013-02-05 13:57:36 +08:00
parent 6046a91976
commit 3f35df4217

View File

@ -318,24 +318,33 @@ let manifestCache = {
_cache: { },
// Gets an entry from the cache, and populates the cache if needed.
get : function mcache_get(aManifestURL, aManifest, aWindow) {
get: function mcache_get(aManifestURL, aManifest, aWindow, aInnerWindowID) {
if (!(aManifestURL in this._cache)) {
this._cache[aManifestURL] = ObjectWrapper.wrap(aManifest, aWindow);
this._cache[aManifestURL] = { };
}
return this._cache[aManifestURL];
let winObjs = this._cache[aManifestURL];
if (!(aInnerWindowID in winObjs)) {
winObjs[aInnerWindowID] = ObjectWrapper.wrap(aManifest, aWindow);
}
return winObjs[aInnerWindowID];
},
// Invalidates an entry in the cache.
evict: function mcache_evict(aManifestURL) {
evict: function mcache_evict(aManifestURL, aInnerWindowID) {
if (aManifestURL in this._cache) {
delete this._cache[aManifestURL];
}
},
let winObjs = this._cache[aManifestURL];
if (aInnerWindowID in winObjs) {
delete winObjs[aInnerWindowID];
}
clear: function mcache_clear() {
this._cache = { };
if (Object.keys(winObjs).length == 0) {
delete this._cache[aManifestURL];
}
}
}
}
};
function createApplicationObject(aWindow, aApp) {
let app = Cc["@mozilla.org/webapps/application;1"].createInstance(Ci.mozIDOMApplication);
@ -391,7 +400,10 @@ WebappsApplication.prototype = {
},
get manifest() {
return manifestCache.get(this.manifestURL, this._manifest, this._window);
return manifestCache.get(this.manifestURL,
this._manifest,
this._window,
this.innerWindowID);
},
get updateManifest() {
@ -487,7 +499,8 @@ WebappsApplication.prototype = {
["Webapps:OfflineCache",
"Webapps:PackageEvent",
"Webapps:CheckForUpdate:Return:OK"]);
manifestCache.clear();
manifestCache.evict(this.manifestURL, this.innerWindowID);
},
_fireEvent: function(aName, aHandler) {
@ -577,7 +590,7 @@ WebappsApplication.prototype = {
this._fireEvent("downloadprogress", this._onprogress);
break;
case "installed":
manifestCache.evict(this.manifestURL);
manifestCache.evict(this.manifestURL, this.innerWindowID);
this._manifest = msg.manifest;
this._fireEvent("downloadsuccess", this._ondownloadsuccess);
this._fireEvent("downloadapplied", this._ondownloadapplied);
@ -586,13 +599,13 @@ WebappsApplication.prototype = {
// We don't update the packaged apps manifests until they
// are installed or until the update is unstaged.
if (msg.manifest) {
manifestCache.evict(this.manifestURL);
manifestCache.evict(this.manifestURL, this.innerWindowID);
this._manifest = msg.manifest;
}
this._fireEvent("downloadsuccess", this._ondownloadsuccess);
break;
case "applied":
manifestCache.evict(this.manifestURL);
manifestCache.evict(this.manifestURL, this.innerWindowID);
this._manifest = msg.manifest;
this._fireEvent("downloadapplied", this._ondownloadapplied);
break;