Bug 588655 - Part 1: Add a privatebrowsingmode="permanent" attribute to browser.xul's document element for permanent private browsing sessions; r=dao a=blocking-final+

This commit is contained in:
Ehsan Akhgari 2010-09-22 17:22:41 -04:00
parent 0212f693d8
commit 30f9cfbf68
2 changed files with 12 additions and 10 deletions

View File

@ -7486,6 +7486,7 @@ let gPrivateBrowsingUI = {
// temporary fix until bug 463607 is fixed
document.getElementById("Tools:Sanitize").setAttribute("disabled", "true");
let docElement = document.documentElement;
if (this._privateBrowsingService.autoStarted) {
// Disable the menu item in auto-start mode
document.getElementById("privateBrowsingItem")
@ -7496,15 +7497,16 @@ let gPrivateBrowsingUI = {
#endif
document.getElementById("Tools:PrivateBrowsing")
.setAttribute("disabled", "true");
if (window.location.href == getBrowserURL())
docElement.setAttribute("privatebrowsingmode", "permanent");
}
else if (window.location.href == getBrowserURL()) {
// Adjust the window's title
let docElement = document.documentElement;
docElement.setAttribute("title",
docElement.getAttribute("title_privatebrowsing"));
docElement.setAttribute("titlemodifier",
docElement.getAttribute("titlemodifier_privatebrowsing"));
docElement.setAttribute("browsingmode", "private");
docElement.setAttribute("privatebrowsingmode", "temporary");
gBrowser.updateTitlebar();
}
@ -7551,7 +7553,7 @@ let gPrivateBrowsingUI = {
docElement.getAttribute("title_normal"));
docElement.setAttribute("titlemodifier",
docElement.getAttribute("titlemodifier_normal"));
docElement.setAttribute("browsingmode", "normal");
docElement.removeAttribute("privatebrowsingmode");
}
// Enable the menu item in after exiting the auto-start mode

View File

@ -35,7 +35,7 @@
*
* ***** END LICENSE BLOCK ***** */
// This test makes sure that browsingmode attribute of the window is correctly
// This test makes sure that privatebrowsingmode attribute of the window is correctly
// switched with private browsing mode changes.
function test() {
@ -45,20 +45,20 @@ function test() {
getService(Ci.nsIPrivateBrowsingService);
let docRoot = document.documentElement;
is(docRoot.getAttribute("browsingmode"), "normal",
"browsingmode should be \"normal\" initially");
ok(!docRoot.hasAttribute("privatebrowsingmode"),
"privatebrowsingmode should not be present in normal mode");
// enter private browsing mode
pb.privateBrowsingEnabled = true;
is(docRoot.getAttribute("browsingmode"), "private",
"browsingmode should be \"private\" inside the private browsing mode");
is(docRoot.getAttribute("privatebrowsingmode"), "temporary",
"privatebrowsingmode should be \"temporary\" inside the private browsing mode");
// leave private browsing mode
pb.privateBrowsingEnabled = false;
is(docRoot.getAttribute("browsingmode"), "normal",
"browsingmode should be \"normal\" outside the private browsing mode");
ok(!docRoot.hasAttribute("privatebrowsingmode"),
"privatebrowsingmode should not be present in normal mode");
// cleanup
gPrefService.clearUserPref("browser.privatebrowsing.keep_current_session");