Bug 827023 r=vingtetun

This commit is contained in:
Fabrice Desré 2013-01-08 09:02:17 -08:00
parent 248890f607
commit 1da28e32f7

View File

@ -82,13 +82,38 @@ WebappsRegistry.prototype = {
}
},
// Checks that we run as a foreground page, and fire an error on the
// DOM Request if we aren't.
_ensureForeground: function(aRequest) {
let docShell = this._window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIDocShell);
if (docShell.isActive) {
return true;
}
let runnable = {
run: function run() {
Services.DOMRequest.fireError(aRequest, "BACKGROUND_APP");
}
}
Services.tm.currentThread.dispatch(runnable,
Ci.nsIThread.DISPATCH_NORMAL);
return false;
},
// mozIDOMApplicationRegistry implementation
install: function(aURL, aParams) {
let request = this.createRequest();
if (!this._ensureForeground(request)) {
return request;
}
this._validateScheme(aURL);
let installURL = this._window.location.href;
let request = this.createRequest();
let requestID = this.getRequestId(request);
let receipts = (aParams && aParams.receipts &&
Array.isArray(aParams.receipts)) ? aParams.receipts
@ -159,10 +184,15 @@ WebappsRegistry.prototype = {
// mozIDOMApplicationRegistry2 implementation
installPackage: function(aURL, aParams) {
let request = this.createRequest();
if (!this._ensureForeground(request)) {
return request;
}
this._validateScheme(aURL);
let installURL = this._window.location.href;
let request = this.createRequest();
let requestID = this.getRequestId(request);
let receipts = (aParams && aParams.receipts &&
Array.isArray(aParams.receipts)) ? aParams.receipts