зеркало из https://github.com/mozilla/gecko-dev.git
Bug 461625 - Hide the UI for saving permission manager entries in Private Browsing mode (test); r=mconnor
This commit is contained in:
Родитель
d331d3d51c
Коммит
63ad68e798
|
@ -62,6 +62,7 @@ _BROWSER_TEST_FILES = \
|
|||
browser_privatebrowsing_openlocation.js \
|
||||
browser_privatebrowsing_pageinfo.js \
|
||||
browser_privatebrowsing_placestitle.js \
|
||||
browser_privatebrowsing_popupblocker.js \
|
||||
browser_privatebrowsing_popupmode.js \
|
||||
browser_privatebrowsing_searchbar.js \
|
||||
browser_privatebrowsing_sslsite_transition.js \
|
||||
|
@ -74,6 +75,9 @@ _BROWSER_TEST_FILES = \
|
|||
browser_privatebrowsing_windowtitle_page.html \
|
||||
browser_privatebrowsing_zoom.js \
|
||||
browser_privatebrowsing_zoomrestore.js \
|
||||
ctxmenu.html \
|
||||
ctxmenu-image.png \
|
||||
popup.html \
|
||||
staller.sjs \
|
||||
title.sjs \
|
||||
$(NULL)
|
||||
|
|
|
@ -0,0 +1,89 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Private Browsing Tests.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ehsan Akhgari.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2009
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Ehsan Akhgari <ehsan.akhgari@gmail.com> (Original Author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
// This test makes sure that private browsing mode disables the Block Image
|
||||
// context menu item.
|
||||
|
||||
function test() {
|
||||
// initialization
|
||||
let pb = Cc["@mozilla.org/privatebrowsing;1"].
|
||||
getService(Ci.nsIPrivateBrowsingService);
|
||||
|
||||
const TEST_URI = "http://localhost:8888/browser/browser/components/privatebrowsing/test/browser/ctxmenu.html";
|
||||
|
||||
waitForExplicitFinish();
|
||||
|
||||
function checkBlockImageMenuItem(expectedHidden, callback) {
|
||||
let tab = gBrowser.addTab();
|
||||
gBrowser.selectedTab = tab;
|
||||
let browser = gBrowser.getBrowserForTab(tab);
|
||||
browser.addEventListener("load", function() {
|
||||
browser.removeEventListener("load", arguments.callee, true);
|
||||
|
||||
executeSoon(function() {
|
||||
let contextMenu = document.getElementById("contentAreaContextMenu");
|
||||
let blockImage = document.getElementById("context-blockimage");
|
||||
let image = browser.contentDocument.getElementsByTagName("img")[0];
|
||||
ok(image, "The content image should be accessible");
|
||||
|
||||
contextMenu.addEventListener("popupshown", function() {
|
||||
contextMenu.removeEventListener("popupshown", arguments.callee, false);
|
||||
|
||||
is(blockImage.hidden, expectedHidden,
|
||||
"The Block Image menu item should " + (expectedHidden ? "" : "not ") + "be hidden");
|
||||
contextMenu.hidePopup();
|
||||
gBrowser.removeTab(tab);
|
||||
callback();
|
||||
}, false);
|
||||
|
||||
document.popupNode = image;
|
||||
EventUtils.synthesizeMouse(image, 2, 2,
|
||||
{type: "contextmenu", button: 2},
|
||||
browser.contentWindow);
|
||||
});
|
||||
}, true);
|
||||
browser.loadURI(TEST_URI);
|
||||
}
|
||||
|
||||
checkBlockImageMenuItem(false, function() {
|
||||
pb.privateBrowsingEnabled = true;
|
||||
checkBlockImageMenuItem(true, function() {
|
||||
pb.privateBrowsingEnabled = false;
|
||||
checkBlockImageMenuItem(false, finish);
|
||||
});
|
||||
});
|
||||
}
|
|
@ -0,0 +1,117 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Private Browsing Tests.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ehsan Akhgari.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2009
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Ehsan Akhgari <ehsan.akhgari@gmail.com> (Original Author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
// This test makes sure that private browsing mode disables the "remember"
|
||||
// option in the cookie accept dialog.
|
||||
|
||||
function test() {
|
||||
// initialization
|
||||
let pb = Cc["@mozilla.org/privatebrowsing;1"].
|
||||
getService(Ci.nsIPrivateBrowsingService);
|
||||
let ww = Cc["@mozilla.org/embedcomp/window-watcher;1"].
|
||||
getService(Ci.nsIWindowWatcher);
|
||||
let cp = Cc["@mozilla.org/embedcomp/cookieprompt-service;1"].
|
||||
getService(Ci.nsICookiePromptService);
|
||||
|
||||
waitForExplicitFinish();
|
||||
|
||||
function checkRememberOption(expectedDisabled, callback) {
|
||||
let observer = {
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
if (aTopic === "domwindowopened") {
|
||||
ww.unregisterNotification(this);
|
||||
let win = aSubject.QueryInterface(Ci.nsIDOMWindow);
|
||||
win.addEventListener("load", function onLoad(event) {
|
||||
win.removeEventListener("load", onLoad, false);
|
||||
|
||||
executeSoon(function() {
|
||||
let doc = win.document;
|
||||
let remember = doc.getElementById("persistDomainAcceptance");
|
||||
ok(remember, "The remember checkbox should exist");
|
||||
|
||||
if (expectedDisabled)
|
||||
is(remember.getAttribute("disabled"), "true",
|
||||
"The checkbox should be disabled");
|
||||
else
|
||||
ok(!remember.hasAttribute("disabled"),
|
||||
"The checkbox should not be disabled");
|
||||
|
||||
win.close();
|
||||
callback();
|
||||
});
|
||||
}, false);
|
||||
}
|
||||
}
|
||||
};
|
||||
ww.registerNotification(observer);
|
||||
|
||||
let remember = {};
|
||||
const time = (new Date("Jan 1, 2030")).getTime() / 1000;
|
||||
let cookie = {
|
||||
name: "foo",
|
||||
value: "bar",
|
||||
isDomain: true,
|
||||
host: "mozilla.org",
|
||||
path: "/baz",
|
||||
isSecure: false,
|
||||
expires: time,
|
||||
status: 0,
|
||||
policy: 0,
|
||||
isSession: false,
|
||||
expiry: time,
|
||||
isHttpOnly: true,
|
||||
QueryInterface: function(iid) {
|
||||
const validIIDs = [Components.interfaces.nsISupports,
|
||||
Components.interfaces.nsICookie,
|
||||
Components.interfaces.nsICookie2];
|
||||
for (var i = 0; i < validIIDs.length; ++i)
|
||||
if (iid == validIIDs[i])
|
||||
return this;
|
||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
};
|
||||
cp.cookieDialog(window, cookie, "mozilla.org", 10, false, remember);
|
||||
}
|
||||
|
||||
checkRememberOption(false, function() {
|
||||
pb.privateBrowsingEnabled = true;
|
||||
checkRememberOption(true, function() {
|
||||
pb.privateBrowsingEnabled = false;
|
||||
checkRememberOption(false, finish);
|
||||
});
|
||||
});
|
||||
}
|
|
@ -0,0 +1,97 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Private Browsing Tests.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ehsan Akhgari.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2009
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Ehsan Akhgari <ehsan.akhgari@gmail.com> (Original Author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
// This test makes sure that private browsing mode disables the remember option
|
||||
// for the popup blocker menu.
|
||||
|
||||
function test() {
|
||||
// initialization
|
||||
let pb = Cc["@mozilla.org/privatebrowsing;1"].
|
||||
getService(Ci.nsIPrivateBrowsingService);
|
||||
|
||||
let oldPopupPolicy = gPrefService.getBoolPref("dom.disable_open_during_load");
|
||||
gPrefService.setBoolPref("dom.disable_open_during_load", true);
|
||||
|
||||
const TEST_URI = "http://localhost:8888/browser/browser/components/privatebrowsing/test/browser/popup.html";
|
||||
|
||||
waitForExplicitFinish();
|
||||
|
||||
function testPopupBlockerMenuItem(expectedDisabled, callback) {
|
||||
gBrowser.addEventListener("DOMUpdatePageReport", function() {
|
||||
gBrowser.removeEventListener("DOMUpdatePageReport", arguments.callee, false);
|
||||
executeSoon(function() {
|
||||
let pageReportButton = document.getElementById("page-report-button");
|
||||
let notification = gBrowser.getNotificationBox().getNotificationWithValue("popup-blocked");
|
||||
|
||||
ok(!pageReportButton.hidden, "The page report button should not be hidden");
|
||||
ok(notification, "The notification box should be displayed");
|
||||
|
||||
function checkMenuItem(callback) {
|
||||
document.addEventListener("popupshown", function(event) {
|
||||
document.removeEventListener("popupshown", arguments.callee, false);
|
||||
|
||||
if (expectedDisabled)
|
||||
is(document.getElementById("blockedPopupAllowSite").getAttribute("disabled"), "true",
|
||||
"The allow popups menu item should be disabled");
|
||||
|
||||
event.originalTarget.hidePopup();
|
||||
callback();
|
||||
}, false);
|
||||
}
|
||||
|
||||
checkMenuItem(function() {
|
||||
checkMenuItem(function() {
|
||||
gBrowser.removeTab(tab);
|
||||
callback();
|
||||
});
|
||||
notification.querySelector("button").doCommand();
|
||||
});
|
||||
EventUtils.synthesizeMouse(document.getElementById("page-report-button"), 1, 1, {});
|
||||
});
|
||||
}, false);
|
||||
|
||||
let tab = gBrowser.addTab(TEST_URI);
|
||||
gBrowser.selectedTab = tab;
|
||||
}
|
||||
|
||||
pb.privateBrowsingEnabled = true;
|
||||
testPopupBlockerMenuItem(true, function() {
|
||||
pb.privateBrowsingEnabled = false;
|
||||
gPrefService.setBoolPref("dom.disable_open_during_load", oldPopupPolicy);
|
||||
finish();
|
||||
});
|
||||
}
|
|
@ -60,13 +60,19 @@ function test() {
|
|||
|
||||
// test the gPrivateBrowsingUI object
|
||||
ok(gPrivateBrowsingUI, "The gPrivateBrowsingUI object exists");
|
||||
is(pb.privateBrowsingEnabled, false, "The private browsing mode should not be started initially");
|
||||
is(gPrivateBrowsingUI.privateBrowsingEnabled, false, "gPrivateBrowsingUI should expose the correct private browsing status");
|
||||
ok(pbMenuItem, "The Private Browsing menu item exists");
|
||||
is(pbMenuItem.getAttribute("label"), pbMenuItem.getAttribute("startlabel"), "The Private Browsing menu item should read \"Start Private Browsing\"");
|
||||
gPrivateBrowsingUI.toggleMode();
|
||||
is(pb.privateBrowsingEnabled, true, "The private browsing mode should be started");
|
||||
is(gPrivateBrowsingUI.privateBrowsingEnabled, true, "gPrivateBrowsingUI should expose the correct private browsing status");
|
||||
// check to see if the Private Browsing mode was activated successfully
|
||||
is(observer.data, "enter", "Private Browsing mode was activated using the gPrivateBrowsingUI object");
|
||||
is(pbMenuItem.getAttribute("label"), pbMenuItem.getAttribute("stoplabel"), "The Private Browsing menu item should read \"Stop Private Browsing\"");
|
||||
gPrivateBrowsingUI.toggleMode()
|
||||
is(pb.privateBrowsingEnabled, false, "The private browsing mode should not be started");
|
||||
is(gPrivateBrowsingUI.privateBrowsingEnabled, false, "gPrivateBrowsingUI should expose the correct private browsing status");
|
||||
// check to see if the Private Browsing mode was deactivated successfully
|
||||
is(observer.data, "exit", "Private Browsing mode was deactivated using the gPrivateBrowsingUI object");
|
||||
is(pbMenuItem.getAttribute("label"), pbMenuItem.getAttribute("startlabel"), "The Private Browsing menu item should read \"Start Private Browsing\"");
|
||||
|
|
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 5.3 KiB |
|
@ -0,0 +1,9 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>Page containing an image</title>
|
||||
</head>
|
||||
<body>
|
||||
<img src="ctxmenu-image.png">
|
||||
</body>
|
||||
</html>
|
|
@ -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>
|
Загрузка…
Ссылка в новой задаче