Bug 917610 - Fix backgroundPageThumbsContent.js's use of nsIDOMWindowUtils.preventFurtherDialogs. r=markh

This commit is contained in:
Drew Willcoxon 2013-09-20 21:40:37 -07:00
parent 122bb761d8
commit bc73d515b4

View File

@ -13,12 +13,7 @@ Cu.import("resource://gre/modules/Services.jsm");
const backgroundPageThumbsContent = {
init: function () {
// Arrange to prevent (most) popup dialogs for this window - popups done
// in the parent (eg, auth) aren't prevented, but alert() etc are.
let dwu = content.
QueryInterface(Ci.nsIInterfaceRequestor).
getInterface(Ci.nsIDOMWindowUtils);
dwu.preventFurtherDialogs();
Services.obs.addObserver(this, "document-element-inserted", true);
// We want a low network priority for this service - lower than b/g tabs
// etc - so set it to the lowest priority available.
@ -43,6 +38,19 @@ const backgroundPageThumbsContent = {
addProgressListener(this, Ci.nsIWebProgress.NOTIFY_STATE_WINDOW);
},
observe: function (subj, topic, data) {
// Arrange to prevent (most) popup dialogs for this window - popups done
// in the parent (eg, auth) aren't prevented, but alert() etc are.
// preventFurtherDialogs only works on the current inner window, so it has
// to be called every page load, but before scripts run.
if (subj == content.document) {
content.
QueryInterface(Ci.nsIInterfaceRequestor).
getInterface(Ci.nsIDOMWindowUtils).
preventFurtherDialogs();
}
},
get _webNav() {
return docShell.QueryInterface(Ci.nsIWebNavigation);
},
@ -102,6 +110,7 @@ const backgroundPageThumbsContent = {
QueryInterface: XPCOMUtils.generateQI([
Ci.nsIWebProgressListener,
Ci.nsISupportsWeakReference,
Ci.nsIObserver,
]),
};