mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 806694 - Port browser_privatebrowsing_popupblocker.js to the new per-window PB APIs; r=ehsan
--HG-- rename : browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_popupblocker.js => browser/components/privatebrowsing/test/browser/perwindow/browser_privatebrowsing_popupblocker.js rename : browser/components/privatebrowsing/test/browser/global/popup.html => browser/components/privatebrowsing/test/browser/perwindow/popup.html extra : rebase_source : 637f2cc15fb5dd31a960b40bd9683b7ae7017853
This commit is contained in:
parent
04d165e18c
commit
d3e82fbd75
@ -29,8 +29,10 @@ MOCHITEST_BROWSER_FILES = \
|
||||
browser_privatebrowsing_localStorage_page2.html \
|
||||
browser_privatebrowsing_opendir.js \
|
||||
browser_privatebrowsing_openlocation.js \
|
||||
browser_privatebrowsing_popupblocker.js \
|
||||
browser_privatebrowsing_theming.js \
|
||||
browser_privatebrowsing_zoomrestore.js \
|
||||
popup.html \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
@ -0,0 +1,86 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// This test makes sure that private browsing mode disables the remember option
|
||||
// for the popup blocker menu.
|
||||
function test() {
|
||||
// initialization
|
||||
waitForExplicitFinish();
|
||||
|
||||
let testURI = "http://mochi.test:8888/browser/browser/components/privatebrowsing/test/browser/perwindow/popup.html";
|
||||
let windowsToClose = [];
|
||||
let oldPopupPolicy = gPrefService.getBoolPref("dom.disable_open_during_load");
|
||||
gPrefService.setBoolPref("dom.disable_open_during_load", true);
|
||||
|
||||
function testPopupBlockerMenuItem(aExpectedDisabled, aWindow, aCallback) {
|
||||
|
||||
aWindow.gBrowser.addEventListener("DOMUpdatePageReport", function() {
|
||||
aWindow.gBrowser.removeEventListener("DOMUpdatePageReport", arguments.callee, false);
|
||||
|
||||
executeSoon(function() {
|
||||
let notification = aWindow.gBrowser.getNotificationBox().getNotificationWithValue("popup-blocked");
|
||||
ok(notification, "The notification box should be displayed");
|
||||
|
||||
function checkMenuItem(callback) {
|
||||
dump("CMI: in\n");
|
||||
aWindow.document.addEventListener("popupshown", function(event) {
|
||||
dump("CMI: popupshown\n");
|
||||
aWindow.document.removeEventListener("popupshown", arguments.callee, false);
|
||||
|
||||
if (aExpectedDisabled)
|
||||
is(aWindow.document.getElementById("blockedPopupAllowSite").getAttribute("disabled"), "true",
|
||||
"The allow popups menu item should be disabled");
|
||||
|
||||
event.originalTarget.hidePopup();
|
||||
dump("CMI: calling back\n");
|
||||
callback();
|
||||
dump("CMI: called back\n");
|
||||
}, false);
|
||||
dump("CMI: out\n");
|
||||
}
|
||||
|
||||
checkMenuItem(function() {
|
||||
aCallback();
|
||||
});
|
||||
notification.querySelector("button").doCommand();
|
||||
});
|
||||
|
||||
}, false);
|
||||
|
||||
aWindow.gBrowser.selectedBrowser.loadURI(testURI);
|
||||
}
|
||||
|
||||
function finishTest() {
|
||||
// cleanup
|
||||
gPrefService.setBoolPref("dom.disable_open_during_load", oldPopupPolicy);
|
||||
finish();
|
||||
};
|
||||
|
||||
function testOnWindow(options, callback) {
|
||||
let win = OpenBrowserWindow(options);
|
||||
win.addEventListener("load", function onLoad() {
|
||||
win.removeEventListener("load", onLoad, false);
|
||||
windowsToClose.push(win);
|
||||
executeSoon(function() callback(win));
|
||||
}, false);
|
||||
};
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
windowsToClose.forEach(function(win) {
|
||||
win.close();
|
||||
});
|
||||
});
|
||||
|
||||
testOnWindow({}, function(win) {
|
||||
testPopupBlockerMenuItem(false, win,
|
||||
testOnWindow({private: true}, function(win) {
|
||||
testPopupBlockerMenuItem(true, win,
|
||||
testOnWindow({}, function(win) {
|
||||
testPopupBlockerMenuItem(false, win, finishTest);
|
||||
})
|
||||
);
|
||||
})
|
||||
);
|
||||
});
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>Page creating a popup</title>
|
||||
</head>
|
||||
<body>
|
||||
<script type="text/javascript">
|
||||
window.open("data:text/plain,test", "testwin");
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user