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.setAttribute("titlemodifier",
docElement.getAttribute("titlemodifier_privatebrowsing")); docElement.getAttribute("titlemodifier_privatebrowsing"));
docElement.setAttribute("browsingmode", "private"); docElement.setAttribute("browsingmode", "private");
gBrowser.updateTitlebar();
} }
setTimeout(function () { setTimeout(function () {

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

@ -54,87 +54,83 @@ function test() {
let test_title = "Test title"; let test_title = "Test title";
let app_name = document.documentElement.getAttribute("title"); let app_name = document.documentElement.getAttribute("title");
const isOSX = ("nsILocalFileMac" in Ci); const isOSX = ("nsILocalFileMac" in Ci);
var page_with_title; let page_with_title;
var page_without_title; let page_without_title;
var pb_page_with_title; let about_pb_title;
var pb_page_without_title; let pb_page_with_title;
var about_pb_title; let pb_page_without_title;
let pb_about_pb_title;
if (isOSX) { if (isOSX) {
page_with_title = test_title; page_with_title = test_title;
page_without_title = app_name; 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_with_title = test_title + " - (Private Browsing)";
pb_page_without_title = app_name + " - (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 { else {
page_with_title = test_title + " - " + app_name; page_with_title = test_title + " - " + app_name;
page_without_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_with_title = test_title + " - " + app_name + " (Private Browsing)";
pb_page_without_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 function testTabTitle(url, insidePB, expected_title, funcNext) {
let blankTab = gBrowser.addTab(); pb.privateBrowsingEnabled = insidePB;
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);
let pageTab = gBrowser.addTab(); let tab = gBrowser.addTab();
gBrowser.selectedTab = pageTab; gBrowser.selectedTab = tab;
let pageBrowser = gBrowser.getBrowserForTab(pageTab); let browser = gBrowser.getBrowserForTab(tab);
pageBrowser.addEventListener("load", function () { browser.addEventListener("load", function() {
pageBrowser.removeEventListener("load", arguments.callee, true); browser.removeEventListener("load", arguments.callee, true);
// check the window title for a page with a title // ensure that the test is run after the page onload event
is(document.title, page_with_title, "The window title for a page with a title matches " + setTimeout(function() {
"(outside private browsing mode)"); 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 // ensure that the test is run after delayedStartup
pb.privateBrowsingEnabled = true; 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 funcNext();
blankTab = gBrowser.addTab(); }, 0);
gBrowser.selectedTab = blankTab; }, 0);
is(document.title, pb_page_without_title, "The window title for a page without a title matches " + }, false);
"(inside private browsing mode)"); }, 0);
gBrowser.removeTab(blankTab); }, 0);
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";
}, true); }, true);
pageBrowser.contentWindow.location = testPageURL; browser.loadURI(url);
}, true); }
pageBrowser.contentWindow.location = testPageURL;
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;
} }