mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-13 18:27:35 +00:00
Bug 826311 - Extend the browser_privatebrowsing_cookieacceptdialog.js to check if the cookies modal dialog appears; r=ehsan
This commit is contained in:
parent
1afab8e729
commit
51da5f0549
@ -16,6 +16,7 @@ MOCHITEST_BROWSER_FILES = \
|
||||
browser_privatebrowsing_concurrent.js \
|
||||
browser_privatebrowsing_concurrent_page.html \
|
||||
browser_privatebrowsing_cookieacceptdialog.js \
|
||||
browser_privatebrowsing_cookieacceptdialog.html \
|
||||
browser_privatebrowsing_crh.js \
|
||||
browser_privatebrowsing_downloadLastDir.js \
|
||||
browser_privatebrowsing_downloadLastDir_c.js \
|
||||
|
@ -0,0 +1,11 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>browser_privatebrowsing_cookieacceptdialog.html</title>
|
||||
<script type="application/javascript">
|
||||
document.cookie = "foo=bar";
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
@ -7,6 +7,9 @@
|
||||
|
||||
function test() {
|
||||
// initialization
|
||||
const TEST_URL = "http://mochi.test:8888/browser/browser/components/" +
|
||||
"privatebrowsing/test/browser/perwindow/" +
|
||||
"browser_privatebrowsing_cookieacceptdialog.html";
|
||||
let cp = Cc["@mozilla.org/embedcomp/cookieprompt-service;1"].
|
||||
getService(Ci.nsICookiePromptService);
|
||||
|
||||
@ -69,6 +72,39 @@ function test() {
|
||||
cp.cookieDialog(aWindow, cookie, "mozilla.org", 10, false, remember);
|
||||
}
|
||||
|
||||
function checkSettingDialog(aIsPrivateWindow, aWindow, aCallback) {
|
||||
aWindow.gBrowser.selectedTab = aWindow.gBrowser.addTab();
|
||||
let selectedBrowser = aWindow.gBrowser.selectedBrowser;
|
||||
|
||||
function onLoad() {
|
||||
selectedBrowser.removeEventListener("load", onLoad, true);
|
||||
Services.ww.unregisterNotification(observer);
|
||||
|
||||
ok(aIsPrivateWindow, "Confirm setting dialog is not displayed for private window");
|
||||
|
||||
executeSoon(aCallback);
|
||||
}
|
||||
selectedBrowser.addEventListener("load", onLoad, true);
|
||||
|
||||
function observer(aSubject, aTopic, aData) {
|
||||
if (aTopic != "domwindowopened")
|
||||
return;
|
||||
selectedBrowser.removeEventListener("load", onLoad, true);
|
||||
Services.ww.unregisterNotification(observer);
|
||||
|
||||
ok(!aIsPrivateWindow, "Confirm setting dialog is displayed for normal window");
|
||||
|
||||
let win = aSubject.QueryInterface(Ci.nsIDOMWindow);
|
||||
executeSoon(function () {
|
||||
win.close();
|
||||
executeSoon(aCallback);
|
||||
});
|
||||
}
|
||||
Services.ww.registerNotification(observer);
|
||||
|
||||
selectedBrowser.loadURI(TEST_URL);
|
||||
}
|
||||
|
||||
var windowsToClose = [];
|
||||
function testOnWindow(options, callback) {
|
||||
var win = OpenBrowserWindow(options);
|
||||
@ -81,14 +117,22 @@ function test() {
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
windowsToClose.forEach(function(win) {
|
||||
Services.prefs.clearUserPref("network.cookie.lifetimePolicy");
|
||||
win.close();
|
||||
});
|
||||
});
|
||||
|
||||
testOnWindow({private: true}, function(win) {
|
||||
checkRememberOption(true, win, function() {
|
||||
testOnWindow(undefined, function(win) {
|
||||
checkRememberOption(false, win, finish);
|
||||
// ask all cookies
|
||||
Services.prefs.setIntPref("network.cookie.lifetimePolicy", 1);
|
||||
|
||||
testOnWindow({private: true}, function(aPrivWin) {
|
||||
checkRememberOption(true, aPrivWin, function() {
|
||||
checkSettingDialog(true, aPrivWin, function() {
|
||||
testOnWindow(undefined, function(aWin) {
|
||||
checkRememberOption(false, aWin, function() {
|
||||
checkSettingDialog(false, aWin, finish);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user