From 68cd4da8c3d5bd36e424681ade9e3363fd7cc871 Mon Sep 17 00:00:00 2001 From: Gijs Kruitbosch Date: Tue, 14 May 2013 20:20:45 +0200 Subject: [PATCH] Bug 752434 - Stop hiding toolbars for about:addons & co, r=dao --- browser/base/content/browser.js | 29 +-- browser/base/content/test/Makefile.in | 2 - .../content/test/browser_disablechrome.js | 216 ------------------ browser/base/content/test/disablechrome.html | 4 - .../components/customizableui/content/jar.mn | 8 - .../customizableui/content/panelUIOverlay.js | 9 - .../customizableui/content/panelUIOverlay.xul | 26 --- toolkit/themes/linux/global/inContentUI.css | 4 +- toolkit/themes/windows/global/inContentUI.css | 12 +- 9 files changed, 14 insertions(+), 296 deletions(-) delete mode 100644 browser/base/content/test/browser_disablechrome.js delete mode 100644 browser/base/content/test/disablechrome.html delete mode 100644 browser/components/customizableui/content/panelUIOverlay.js delete mode 100644 browser/components/customizableui/content/panelUIOverlay.xul diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index 9ea1012a5b0a..0fdace231dbd 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -3457,11 +3457,8 @@ var XULBrowserWindow = { startTime: 0, statusText: "", isBusy: false, - // The pages in this array should be kept in sync with what pages that - // panelUIOverlay.xul is set to overlay in - // browser/components/customizableui/content/jar.mn - inContentWhitelist: ["about:addons", "about:downloads", "about:permissions", - "about:sync-progress", "about:preferences"], + // Left here for add-on compatibility, see bug 752434 + inContentWhitelist: [], QueryInterface: function (aIID) { if (aIID.equals(Ci.nsIWebProgressListener) || @@ -3751,16 +3748,12 @@ var XULBrowserWindow = { SocialShare.update(); } - // Show or hide browser chrome based on the whitelist - if (this.hideChromeForLocation(location)) { + // Show or hide browser chrome for apps + let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore); + if (ss.getTabValue(gBrowser.selectedTab, "appOrigin")) document.documentElement.setAttribute("disablechrome", "true"); - } else { - let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore); - if (ss.getTabValue(gBrowser.selectedTab, "appOrigin")) - document.documentElement.setAttribute("disablechrome", "true"); - else - document.documentElement.removeAttribute("disablechrome"); - } + else + document.documentElement.removeAttribute("disablechrome"); // Utility functions for disabling find var shouldDisableFind = function shouldDisableFind(aDocument) { @@ -3838,12 +3831,8 @@ var XULBrowserWindow = { FeedHandler.updateFeeds(); }, - hideChromeForLocation: function(aLocation) { - aLocation = aLocation.toLowerCase(); - return this.inContentWhitelist.some(function(aSpec) { - return aSpec == aLocation; - }); - }, + // Left here for add-on compatibility, see bug 752434 + hideChromeForLocation: function() {}, onStatusChange: function (aWebProgress, aRequest, aStatus, aMessage) { this.status = aMessage; diff --git a/browser/base/content/test/Makefile.in b/browser/base/content/test/Makefile.in index 860f11a92df6..f1695f348ed8 100644 --- a/browser/base/content/test/Makefile.in +++ b/browser/base/content/test/Makefile.in @@ -171,7 +171,6 @@ _BROWSER_FILES = \ browser_contextSearchTabPosition.js \ browser_ctrlTab.js \ browser_customize_popupNotification.js \ - browser_disablechrome.js \ browser_discovery.js \ browser_duplicateIDs.js \ browser_fullscreen-window-open.js \ @@ -238,7 +237,6 @@ _BROWSER_FILES = \ browser_visibleTabs_bookmarkAllTabs.js \ browser_visibleTabs_tabPreview.js \ bug592338.html \ - disablechrome.html \ discovery.html \ domplate_test.js \ file_bug822367_1.html \ diff --git a/browser/base/content/test/browser_disablechrome.js b/browser/base/content/test/browser_disablechrome.js deleted file mode 100644 index 24b3f4811935..000000000000 --- a/browser/base/content/test/browser_disablechrome.js +++ /dev/null @@ -1,216 +0,0 @@ -/* 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, aCanHide, aCallback) { - gNewBrowser.addEventListener("pageshow", function() { - // Filter out about:blank loads - if (gNewBrowser.currentURI.spec != aURL) - return; - - gNewBrowser.removeEventListener("pageshow", arguments.callee, false); - - if (aCanHide) - is_chrome_hidden(); - else - is_chrome_visible(); - - if (aURL == "about:addons") { - function check_after_init() { - if (aCanHide) - is_chrome_hidden(); - else - is_chrome_visible(); - - aCallback(); - } - - if (gNewBrowser.contentWindow.gIsInitializing) { - gNewBrowser.contentDocument.addEventListener("Initialized", function() { - gNewBrowser.contentDocument.removeEventListener("Initialized", arguments.callee, false); - - check_after_init(); - }, false); - } - else { - check_after_init(); - } - } - else { - executeSoon(aCallback); - } - }, false); - gNewBrowser.loadURI(aURL); -} - -var gOldTab; -var gNewTab; -var gNewBrowser; - -function test() { - // Opening the add-ons manager and waiting for it to load the discovery pane - // takes more time in windows debug builds - requestLongerTimeout(2); - - 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, aCanHide, function() { - 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, false, function() { - info("Switch back"); - gBrowser.selectedTab = gNewTab; - if (aCanHide) - is_chrome_hidden(); - else - is_chrome_visible(); - - load_page("about:blank", false, 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, run_http_test3); -} - -function run_http_test3() { - info("HTTP tests"); - test_url(HTTPSRC + "disablechrome.html", false, run_chrome_about_test_3); -} - -// Should not hide the chrome -function run_chrome_about_test_3() { - info("Chrome about: tests"); - test_url("about:Addons", true, function(){ - info("Tabs on top"); - TabsOnTop.enabled = true; - run_http_test4(); - }); -} - -function run_http_test4() { - info("HTTP tests"); - test_url(HTTPSRC + "disablechrome.html", false, run_chrome_about_test_4); -} - -function run_chrome_about_test_4() { - info("Chrome about: tests"); - test_url("about:Addons", true, run_http_test5); - } - -function run_http_test5() { - info("HTTP tests"); - test_url(HTTPSRC + "disablechrome.html", false, run_chrome_about_test_5); -} - -// Should hide the chrome -function run_chrome_about_test_5() { - info("Chrome about: tests"); - test_url("about:preferences", true, function(){ - info("Tabs on bottom"); - TabsOnTop.enabled = false; - run_http_test6(); - }); -} - -function run_http_test6() { - info("HTTP tests"); - test_url(HTTPSRC + "disablechrome.html", false, run_chrome_about_test_6); -} - -function run_chrome_about_test_6() { - info("Chrome about: tests"); - test_url("about:preferences", true, end_test); -} \ No newline at end of file diff --git a/browser/base/content/test/disablechrome.html b/browser/base/content/test/disablechrome.html deleted file mode 100644 index 7879e1ce9fd7..000000000000 --- a/browser/base/content/test/disablechrome.html +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/browser/components/customizableui/content/jar.mn b/browser/components/customizableui/content/jar.mn index f254bef3b772..43f68f4c3dea 100644 --- a/browser/components/customizableui/content/jar.mn +++ b/browser/components/customizableui/content/jar.mn @@ -7,13 +7,5 @@ browser.jar: content/browser/customizableui/panelUI.css content/browser/customizableui/panelUI.js content/browser/customizableui/panelUI.xml - content/browser/customizableui/panelUIOverlay.xul - content/browser/customizableui/panelUIOverlay.js content/browser/customizableui/toolbar.xml -# These overlays should be kept in sync with what pages are in -# XULBrowserWindow.inContentWhitelist in browser.js -% overlay about:addons chrome://browser/content/customizableui/panelUIOverlay.xul -% overlay about:preferences chrome://browser/content/customizableui/panelUIOverlay.xul -% overlay about:permissions chrome://browser/content/customizableui/panelUIOverlay.xul -% overlay about:sync-progress chrome://browser/content/customizableui/panelUIOverlay.xul diff --git a/browser/components/customizableui/content/panelUIOverlay.js b/browser/components/customizableui/content/panelUIOverlay.js deleted file mode 100644 index 0fdad43ab058..000000000000 --- a/browser/components/customizableui/content/panelUIOverlay.js +++ /dev/null @@ -1,9 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -if (typeof XPCOMUtils == "undefined") - Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); - -XPCOMUtils.defineLazyModuleGetter(this, "CustomizableUI", - "resource:///modules/CustomizableUI.jsm"); diff --git a/browser/components/customizableui/content/panelUIOverlay.xul b/browser/components/customizableui/content/panelUIOverlay.xul deleted file mode 100644 index 8f49fa9b0818..000000000000 --- a/browser/components/customizableui/content/panelUIOverlay.xul +++ /dev/null @@ -1,26 +0,0 @@ - - - - - %brandDTD; - - %browserDTD; -]> - - - - -