Bug 506437 - The titlebar of a tear off window is not updated correctly after having detached a tab with private browsing mode; r=mconnor

This commit is contained in:
Ehsan Akhgari 2009-08-08 21:37:33 +04:30
Родитель 80760f19c8
Коммит fe6e4f9a29
2 изменённых файлов: 61 добавлений и 64 удалений

Просмотреть файл

@ -6976,6 +6976,7 @@ let gPrivateBrowsingUI = {
docElement.setAttribute("titlemodifier",
docElement.getAttribute("titlemodifier_privatebrowsing"));
docElement.setAttribute("browsingmode", "private");
gBrowser.updateTitlebar();
}
setTimeout(function () {

Просмотреть файл

@ -54,87 +54,83 @@ function test() {
let test_title = "Test title";
let app_name = document.documentElement.getAttribute("title");
const isOSX = ("nsILocalFileMac" in Ci);
var page_with_title;
var page_without_title;
var pb_page_with_title;
var pb_page_without_title;
var about_pb_title;
let page_with_title;
let page_without_title;
let about_pb_title;
let pb_page_with_title;
let pb_page_without_title;
let pb_about_pb_title;
if (isOSX) {
page_with_title = test_title;
page_without_title = app_name;
about_pb_title = "Would you like to start Private Browsing?";
pb_page_with_title = test_title + " - (Private Browsing)";
pb_page_without_title = app_name + " - (Private Browsing)";
about_pb_title = pb_page_without_title;
pb_about_pb_title = pb_page_without_title;
}
else {
page_with_title = test_title + " - " + app_name;
page_without_title = app_name;
about_pb_title = "Would you like to start Private Browsing?" + " - " + app_name;
pb_page_with_title = test_title + " - " + app_name + " (Private Browsing)";
pb_page_without_title = app_name + " (Private Browsing)";
about_pb_title = "Private Browsing - " + app_name + " (Private Browsing)";
pb_about_pb_title = "Private Browsing - " + app_name + " (Private Browsing)";
}
// check the window title for a page without a title
let blankTab = gBrowser.addTab();
gBrowser.selectedTab = blankTab;
is(document.title, page_without_title, "The window title for a page without a title matches " +
"(outside private browsing mode)");
gBrowser.removeTab(blankTab);
function testTabTitle(url, insidePB, expected_title, funcNext) {
pb.privateBrowsingEnabled = insidePB;
let pageTab = gBrowser.addTab();
gBrowser.selectedTab = pageTab;
let pageBrowser = gBrowser.getBrowserForTab(pageTab);
pageBrowser.addEventListener("load", function () {
pageBrowser.removeEventListener("load", arguments.callee, true);
let tab = gBrowser.addTab();
gBrowser.selectedTab = tab;
let browser = gBrowser.getBrowserForTab(tab);
browser.addEventListener("load", function() {
browser.removeEventListener("load", arguments.callee, true);
// check the window title for a page with a title
is(document.title, page_with_title, "The window title for a page with a title matches " +
"(outside private browsing mode)");
// ensure that the test is run after the page onload event
setTimeout(function() {
setTimeout(function() {
is(document.title, expected_title, "The window title for " + url +
" is correct (" + (insidePB ? "inside" : "outside") +
" private browsing mode)");
gBrowser.removeTab(pageTab);
let win = gBrowser.replaceTabWithWindow(tab);
win.addEventListener("load", function() {
win.removeEventListener("load", arguments.callee, false);
// enter the private browsing mode
pb.privateBrowsingEnabled = true;
// ensure that the test is run after delayedStartup
setTimeout(function() {
setTimeout(function() {
is(win.document.title, expected_title, "The window title for " + url +
" detahced tab is correct (" + (insidePB ? "inside" : "outside") +
" private browsing mode)");
win.close();
// check the window title for a page without a title
blankTab = gBrowser.addTab();
gBrowser.selectedTab = blankTab;
is(document.title, pb_page_without_title, "The window title for a page without a title matches " +
"(inside private browsing mode)");
gBrowser.removeTab(blankTab);
pageTab = gBrowser.addTab();
gBrowser.selectedTab = pageTab;
pageBrowser = gBrowser.getBrowserForTab(pageTab);
pageBrowser.addEventListener("load", function () {
pageBrowser.removeEventListener("load", arguments.callee, true);
// check the window title for a page with a title
is(document.title, pb_page_with_title, "The window title for a page with a title matches " +
"(inside private browsing mode)");
gBrowser.removeTab(pageTab);
let aboutPBTab = gBrowser.addTab();
gBrowser.selectedTab = aboutPBTab;
let aboutPBBrowser = gBrowser.getBrowserForTab(aboutPBTab);
aboutPBBrowser.addEventListener("load", function() {
aboutPBBrowser.removeEventListener("load", arguments.callee, true);
// check the window title for about:privatebrowsing
is(document.title, about_pb_title, "The window title for about:privatebrowsing matches " +
"(inside private browsing mode)");
gBrowser.removeTab(aboutPBTab);
// cleanup
pb.privateBrowsingEnabled = false;
prefBranch.clearUserPref("browser.privatebrowsing.keep_current_session");
finish();
}, true);
aboutPBBrowser.contentWindow.location = "about:privatebrowsing";
funcNext();
}, 0);
}, 0);
}, false);
}, 0);
}, 0);
}, true);
pageBrowser.contentWindow.location = testPageURL;
}, true);
pageBrowser.contentWindow.location = testPageURL;
browser.loadURI(url);
}
function cleanup() {
pb.privateBrowsingEnabled = false;
prefBranch.clearUserPref("browser.privatebrowsing.keep_current_session");
finish();
}
testTabTitle("about:blank", false, page_without_title, function() {
testTabTitle(testPageURL, false, page_with_title, function() {
testTabTitle("about:privatebrowsing", false, about_pb_title, function() {
testTabTitle("about:blank", true, pb_page_without_title, function() {
testTabTitle(testPageURL, true, pb_page_with_title, function() {
testTabTitle("about:privatebrowsing", true, pb_about_pb_title, cleanup);
});
});
});
});
});
return;
}