Bug 778076 mochitest-plain 1852 TEST-UNEXPECTED-FAIL | /tests/suite/browser/test/test_contextmenu.html | checking item #0 (popupwindow-reject) name - got popupwindow-allow, expected popupwindow-reject r=Neil.

This commit is contained in:
Philip Chee 2012-08-01 02:55:19 +08:00
Родитель 5dab9fbc99
Коммит feb2858bb1
1 изменённых файлов: 18 добавлений и 21 удалений

Просмотреть файл

@ -45,7 +45,7 @@ nsContextMenu.prototype = {
this.isTextSelected = this.isTextSelection();
this.isContentSelected = this.isContentSelection();
this.initPopupURL();
this.initPopupPrincipal();
// Initialize (disable/remove) menu items.
this.initItems();
@ -253,18 +253,18 @@ nsContextMenu.prototype = {
this.autoDownload ? "valueSave" : "valueSaveAs");
var blocking = true;
if (this.popupURL)
if (this.popupPrincipal)
try {
const PM = Components.classes["@mozilla.org/PopupWindowManager;1"]
.getService(Components.interfaces.nsIPopupWindowManager);
blocking = PM.testPermission(this.popupURL) ==
Components.interfaces.nsIPopupWindowManager.DENY_POPUP;
blocking = PM.testPermission(this.popupPrincipal) == PM.DENY_POPUP;
} catch (e) {
Components.utils.reportError(e);
}
this.showItem("popupwindow-reject", this.popupURL && !blocking);
this.showItem("popupwindow-allow", this.popupURL && blocking);
this.showItem("context-sep-popup", this.popupURL);
this.showItem("popupwindow-reject", this.popupPrincipal && !blocking);
this.showItem("popupwindow-allow", this.popupPrincipal && blocking);
this.showItem("context-sep-popup", this.popupPrincipal);
// BiDi UI
this.showItem("context-sep-bidi", gShowBiDi);
@ -436,7 +436,7 @@ nsContextMenu.prototype = {
this.inSyntheticDoc = false;
this.hasBGImage = false;
this.bgImageURL = "";
this.popupURL = null;
this.popupPrincipal = null;
this.autoDownload = false;
this.isTextSelected = false;
this.isContentSelected = false;
@ -658,7 +658,7 @@ nsContextMenu.prototype = {
}
},
initPopupURL: function() {
initPopupPrincipal: function() {
// quick check: if no opener, it can't be a popup
if (!window.content.opener)
return;
@ -676,13 +676,11 @@ nsContextMenu.prototype = {
if (xulwin.contextFlags &
CI.nsIWindowCreator2.PARENT_IS_LOADING_OR_RUNNING_TIMEOUT) {
// do the pref settings allow site-by-site popup management?
const PB = Components.classes["@mozilla.org/preferences-service;1"]
.getService(CI.nsIPrefBranch);
show = !PB.getBoolPref("dom.disable_open_during_load");
show = !Services.prefs.getBoolPref("dom.disable_open_during_load");
}
if (show) {
// initialize popupURL
this.popupURL = Services.io.newURI(window.content.opener.location.href, null, null);
// initialize popupPrincipal
this.popupPrincipal = window.content.opener.document.nodePrincipal;
}
} catch(e) {
}
@ -717,18 +715,17 @@ nsContextMenu.prototype = {
// Block popup windows
rejectPopupWindows: function(aAndClose) {
const PM = Components.classes["@mozilla.org/PopupWindowManager;1"]
.getService(Components.interfaces.nsIPopupWindowManager);
PM.add(this.popupURL, false);
Services.perms.addFromPrincipal(this.popupPrincipal, "popup",
Services.perms.DENY_ACTION);
if (aAndClose)
Services.obs.notifyObservers(window, "popup-perm-close", this.popupURL.spec);
Services.obs.notifyObservers(window, "popup-perm-close",
this.popupPrincipal.URI.spec);
},
// Unblock popup windows
allowPopupWindows: function() {
const PM = Components.classes["@mozilla.org/PopupWindowManager;1"]
.getService(Components.interfaces.nsIPopupWindowManager);
PM.add(this.popupURL, true);
Services.perms.addFromPrincipal(this.popupPrincipal, "popup",
Services.perms.ALLOW_ACTION);
},
// Block/Unblock image from loading in the future.