Bug 571970: Main browser chrome should be hidden when viewing in-content UI. r=gavin, a=blocks-betaN

This commit is contained in:
Dave Townsend 2010-12-06 10:05:55 -08:00
parent 25aad5e898
commit ae11537481
6 changed files with 170 additions and 2 deletions

View File

@ -100,6 +100,10 @@ toolbarpaletteitem[place="palette"] > toolbaritem > hbox[type="places"] {
display: none;
}
#main-window[disablechrome] #navigator-toolbox[tabsontop="true"] > toolbar:not(#toolbar-menubar):not(#TabsToolbar) {
visibility: collapse;
}
#wrapper-urlbar-container #urlbar-container > #urlbar > toolbarbutton,
#urlbar-container:not([combined]) > #urlbar > toolbarbutton,
#urlbar-container[combined] + #reload-button + #stop-button,

View File

@ -3901,6 +3901,7 @@ var XULBrowserWindow = {
startTime: 0,
statusText: "",
isBusy: false,
inContentWhitelist: ["about:addons"],
QueryInterface: function (aIID) {
if (aIID.equals(Ci.nsIWebProgressListener) ||
@ -4139,6 +4140,16 @@ var XULBrowserWindow = {
}
}
// Show or hide browser chrome based on the whitelist
var disableChrome = this.inContentWhitelist.some(function(aSpec) {
return aSpec == location;
});
if (disableChrome)
document.documentElement.setAttribute("disablechrome", "true");
else
document.documentElement.removeAttribute("disablechrome");
// This code here does not compare uris exactly when determining
// whether or not the message should be hidden since the message
// may be prematurely hidden when an install is invoked by a click

View File

@ -166,6 +166,7 @@ _BROWSER_FILES = \
browser_bug609700.js \
browser_contextSearchTabPosition.js \
browser_ctrlTab.js \
browser_disablechrome.js \
browser_discovery.js \
browser_duplicateIDs.js \
browser_gestureSupport.js \
@ -207,6 +208,7 @@ _BROWSER_FILES = \
browser_visibleTabs_bookmarkAllTabs.js \
browser_visibleTabs_tabPreview.js \
bug592338.html \
disablechrome.html \
discovery.html \
domplate_test.js \
moz.png \

View File

@ -0,0 +1,141 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// Tests that the disablechrome attribute gets propogated to the main UI
const HTTPSRC = "http://example.com/browser/browser/base/content/test/";
function is_element_hidden(aElement) {
var style = window.getComputedStyle(document.getElementById("nav-bar"), "");
if (style.visibility != "visible" || style.display == "none")
return true;
if (aElement.ownerDocument != aElement.parentNode)
return is_element_hidden(aElement.parentNode);
return false;
}
function is_chrome_hidden() {
is(document.documentElement.getAttribute("disablechrome"), "true", "Attribute should be set");
if (TabsOnTop.enabled)
ok(is_element_hidden(document.getElementById("nav-bar")), "Toolbar should be hidden");
else
ok(!is_element_hidden(document.getElementById("nav-bar")), "Toolbar should not be hidden");
}
function is_chrome_visible() {
isnot(document.getElementById("main-window").getAttribute("disablechrome"), "true", "Attribute should not be set");
ok(!is_element_hidden(document.getElementById("nav-bar")), "Toolbar should not be hidden");
}
function load_page(aURL, aCallback) {
gNewBrowser.addEventListener("pageshow", function() {
// Filter out about:blank loads
if (gNewBrowser.currentURI.spec != aURL)
return;
gNewBrowser.removeEventListener("pageshow", arguments.callee, false);
executeSoon(aCallback);
}, false);
gNewBrowser.loadURI(aURL);
}
var gOldTab;
var gNewTab;
var gNewBrowser;
function test() {
var gOldTabsOnTop = TabsOnTop.enabled;
registerCleanupFunction(function() {
TabsOnTop.enabled = gOldTabsOnTop;
});
waitForExplicitFinish();
gOldTab = gBrowser.selectedTab;
gNewTab = gBrowser.selectedTab = gBrowser.addTab("about:blank");
gNewBrowser = gBrowser.selectedBrowser;
info("Tabs on top");
TabsOnTop.enabled = true;
run_http_test_1();
}
function end_test() {
gBrowser.removeTab(gNewTab);
finish();
}
function test_url(aURL, aCanHide, aNextTest) {
is_chrome_visible();
info("Page load");
load_page(aURL, function() {
if (aCanHide)
is_chrome_hidden();
else
is_chrome_visible();
info("Switch away");
gBrowser.selectedTab = gOldTab;
is_chrome_visible();
info("Switch back");
gBrowser.selectedTab = gNewTab;
if (aCanHide)
is_chrome_hidden();
else
is_chrome_visible();
gBrowser.removeTab(gNewTab);
gNewTab = gBrowser.selectedTab = gBrowser.addTab("about:blank");
gNewBrowser = gBrowser.selectedBrowser;
gBrowser.selectedTab = gOldTab;
info("Background load");
load_page(aURL, function() {
is_chrome_visible();
info("Switch back");
gBrowser.selectedTab = gNewTab;
if (aCanHide)
is_chrome_hidden();
else
is_chrome_visible();
load_page("about:blank", aNextTest);
});
});
}
// Should never hide the chrome
function run_http_test_1() {
info("HTTP tests");
test_url(HTTPSRC + "disablechrome.html", false, run_chrome_about_test);
}
// Should hide the chrome
function run_chrome_about_test() {
info("Chrome about: tests");
test_url("about:addons", true, function() {
info("Tabs on bottom");
TabsOnTop.enabled = false;
run_http_test_2();
});
}
// Should never hide the chrome
function run_http_test_2() {
info("HTTP tests");
test_url(HTTPSRC + "disablechrome.html", false, run_chrome_about_test_2);
}
// Should not hide the chrome
function run_chrome_about_test_2() {
info("Chrome about: tests");
test_url("about:addons", true, end_test);
}

View File

@ -0,0 +1,4 @@
<html>
<body>
</body>
</html>

View File

@ -564,8 +564,14 @@ add_test(function() {
var doc = aManager.document;
if (gUseInContentUI) {
is_element_hidden(doc.getElementById("back-btn"), "Back button should be hidden");
is_element_hidden(doc.getElementById("forward-btn"), "Forward button should be hidden");
var btn = document.getElementById("back-button");
if (!btn || is_hidden(btn)) {
is_element_visible(doc.getElementById("back-btn"), "Back button should not be hidden");
is_element_visible(doc.getElementById("forward-btn"), "Forward button should not be hidden");
} else {
is_element_hidden(doc.getElementById("back-btn"), "Back button should be hidden");
is_element_hidden(doc.getElementById("forward-btn"), "Forward button should be hidden");
}
} else {
is_element_visible(doc.getElementById("back-btn"), "Back button should not be hidden");
is_element_visible(doc.getElementById("forward-btn"), "Forward button should not be hidden");