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