Bug 1092447 - Ignore non top-level documents when enabling/disabling Report Site Menu. r=margaret

This commit is contained in:
Mike Taylor 2014-11-03 12:39:00 +01:00
parent 6d26261829
commit bc63d7486c

View File

@ -13,12 +13,15 @@ var WebcompatReporter = {
menuItemEnabled: null,
init: function() {
Services.obs.addObserver(this, "DesktopMode:Change", false);
Services.obs.addObserver(this, "content-page-shown", false);
Services.obs.addObserver(this, "chrome-document-global-created", false);
Services.obs.addObserver(this, "content-document-global-created", false);
this.addMenuItem();
},
uninit: function() {
Services.obs.removeObserver(this, "DesktopMode:Change");
Services.obs.removeObserver(this, "chrome-document-global-created");
Services.obs.removeObserver(this, "content-document-global-created");
if (this.menuItem) {
NativeWindow.menu.remove(this.menuItem);
@ -27,8 +30,15 @@ var WebcompatReporter = {
},
observe: function(subject, topic, data) {
if (topic === "content-page-shown") {
let currentURI = subject.documentURI;
if (topic == "content-document-global-created" || topic == "chrome-document-global-created") {
let win = subject;
let currentURI = win.document.documentURI;
// Ignore non top-level documents
if (currentURI !== win.top.location.href) {
return;
}
if (!this.menuItemEnabled && this.isReportableUrl(currentURI)) {
NativeWindow.menu.update(this.menuItem, {enabled: true});
this.menuItemEnabled = true;