diff --git a/accessible/tests/mochitest/events/docload/test_docload_root.html b/accessible/tests/mochitest/events/docload/test_docload_root.html index 91ce3a10ee8e..330949f2ac94 100644 --- a/accessible/tests/mochitest/events/docload/test_docload_root.html +++ b/accessible/tests/mochitest/events/docload/test_docload_root.html @@ -90,13 +90,15 @@ // Do tests function doTests() { - // Front end stuff sometimes likes to stuff things in the hidden window(s) - // in which case we should repress all accessibles for those. + if (Services.appShell.hasHiddenWindow) { + // Front end stuff sometimes likes to stuff things in the hidden window(s) + // in which case we should repress all accessibles for those. - // Try to create an accessible for the hidden window's document. - let doc = Services.appShell.hiddenDOMWindow.document; - let hiddenDocAcc = gAccService.getAccessibleFor(doc); - ok(!hiddenDocAcc, "hiddenDOMWindow should not have an accessible."); + // Try to create an accessible for the hidden window's document. + let doc = Services.appShell.hiddenDOMWindow.document; + let hiddenDocAcc = gAccService.getAccessibleFor(doc); + ok(!hiddenDocAcc, "hiddenDOMWindow should not have an accessible."); + } const gQueue = new eventQueue(); gQueue.push(new openDialogWnd("about:about")); diff --git a/accessible/tests/mochitest/events/docload/test_docload_shutdown.html b/accessible/tests/mochitest/events/docload/test_docload_shutdown.html index a111d9e43b12..6c98a6826156 100644 --- a/accessible/tests/mochitest/events/docload/test_docload_shutdown.html +++ b/accessible/tests/mochitest/events/docload/test_docload_shutdown.html @@ -107,13 +107,15 @@ // Do tests function doTests() { - // Front end stuff sometimes likes to stuff things in the hidden window(s) - // in which case we should repress all accessibles for those. + if (Services.appShell.hasHiddenWindow) { + // Front end stuff sometimes likes to stuff things in the hidden window(s) + // in which case we should repress all accessibles for those. - // Try to create an accessible for the hidden window's document. - let doc = Services.appShell.hiddenDOMWindow.document; - let hiddenDocAcc = gAccService.getAccessibleFor(doc); - ok(!hiddenDocAcc, "hiddenDOMWindow should not have an accessible."); + // Try to create an accessible for the hidden window's document. + let doc = Services.appShell.hiddenDOMWindow.document; + let hiddenDocAcc = gAccService.getAccessibleFor(doc); + ok(!hiddenDocAcc, "hiddenDOMWindow should not have an accessible."); + } const gQueue = new eventQueue(); gQueue.push(new openWndShutdownDoc("../../events/docload/docload_wnd.html")); diff --git a/browser/base/content/browser-init.js b/browser/base/content/browser-init.js index e976d57b4330..a3c3f46dff09 100644 --- a/browser/base/content/browser-init.js +++ b/browser/base/content/browser-init.js @@ -335,10 +335,6 @@ var gBrowserInit = { this._cancelDelayedStartup(); - // Bug 1531854 - The hidden window is force-created here - // until all of its dependencies are handled. - Services.appShell.hiddenDOMWindow; - gBrowser.addEventListener( "PermissionStateChange", function () { diff --git a/browser/base/content/test/performance/browser.toml b/browser/base/content/test/performance/browser.toml index 2dd7029ddd85..213a9e7d7183 100644 --- a/browser/base/content/test/performance/browser.toml +++ b/browser/base/content/test/performance/browser.toml @@ -35,6 +35,8 @@ skip-if = [ ["browser_hidden_browser_vsync.js"] +["browser_hiddenwindow_existence.js"] + ["browser_panel_vsync.js"] support-files = ["!/browser/components/downloads/test/browser/head.js"] @@ -64,12 +66,6 @@ run-if = [ "nightly_build", # Requires StartupRecorder.sys.mjs, which isn't shipped everywhere by default ] -["browser_startup_hiddenwindow.js"] -run-if = [ - "os == 'linux'", - "os == 'win'", -] - ["browser_tabclose.js"] skip-if = [ "os == 'linux' && devedition", # Bug 1737131 diff --git a/browser/base/content/test/performance/browser_hiddenwindow_existence.js b/browser/base/content/test/performance/browser_hiddenwindow_existence.js new file mode 100644 index 000000000000..cbd327d88c8e --- /dev/null +++ b/browser/base/content/test/performance/browser_hiddenwindow_existence.js @@ -0,0 +1,18 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +add_task(async function test_hiddenwindow_existence() { + switch (AppConstants.platform) { + case "macosx": + is(Services.appShell.hasHiddenWindow, true, "Hidden window exists"); + break; + default: + is( + Services.appShell.hasHiddenWindow, + false, + "Hidden window does not exist" + ); + } +}); diff --git a/browser/base/content/test/performance/browser_startup_hiddenwindow.js b/browser/base/content/test/performance/browser_startup_hiddenwindow.js deleted file mode 100644 index 27ff837dc4a3..000000000000 --- a/browser/base/content/test/performance/browser_startup_hiddenwindow.js +++ /dev/null @@ -1,47 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -"use strict"; - -add_task(async function () { - if ( - !AppConstants.NIGHTLY_BUILD && - !AppConstants.MOZ_DEV_EDITION && - !AppConstants.DEBUG - ) { - ok( - !("@mozilla.org/test/startuprecorder;1" in Cc), - "the startup recorder component shouldn't exist in this non-nightly/non-devedition/" + - "non-debug build." - ); - return; - } - - let startupRecorder = - Cc["@mozilla.org/test/startuprecorder;1"].getService().wrappedJSObject; - await startupRecorder.done; - - let extras = Cu.cloneInto(startupRecorder.data.extras, {}); - - let phasesExpectations = { - "before profile selection": false, - "before opening first browser window": false, - "before first paint": AppConstants.platform === "macosx", - // Bug 1531854 - "before handling user events": true, - "before becoming idle": true, - }; - - for (let phase in extras) { - if (!(phase in phasesExpectations)) { - ok(false, `Startup phase '${phase}' should be specified.`); - continue; - } - - is( - extras[phase].hiddenWindowLoaded, - phasesExpectations[phase], - `Hidden window loaded at '${phase}': ${phasesExpectations[phase]}` - ); - } -}); diff --git a/browser/base/jar.mn b/browser/base/jar.mn index d743e7c1b5fa..9ba15b559993 100644 --- a/browser/base/jar.mn +++ b/browser/base/jar.mn @@ -87,7 +87,6 @@ browser.jar: content/browser/nsContextMenu.sys.mjs (content/nsContextMenu.sys.mjs) content/browser/contentTheme.js (content/contentTheme.js) #ifdef XP_MACOSX -# XXX: We should exclude this one as well (bug 71895) * content/browser/hiddenWindowMac.xhtml (content/hiddenWindowMac.xhtml) content/browser/nonbrowser-mac.js (content/nonbrowser-mac.js) #endif diff --git a/browser/components/BrowserGlue.sys.mjs b/browser/components/BrowserGlue.sys.mjs index 268cc51a2ff6..c42584264153 100644 --- a/browser/components/BrowserGlue.sys.mjs +++ b/browser/components/BrowserGlue.sys.mjs @@ -4868,7 +4868,7 @@ BrowserGlue.prototype = { return; } - if (Services.appShell.hiddenDOMWindow.openPreferences) { + if (AppConstants.platform == "macosx") { Services.appShell.hiddenDOMWindow.openPreferences(...args); } }, diff --git a/browser/components/StartupRecorder.sys.mjs b/browser/components/StartupRecorder.sys.mjs index bdc08ee6ddbd..cb3e54c1b19b 100644 --- a/browser/components/StartupRecorder.sys.mjs +++ b/browser/components/StartupRecorder.sys.mjs @@ -80,7 +80,6 @@ export function StartupRecorder() { "image-loading": new Set(), }, code: {}, - extras: {}, prefStats: {}, }; this.done = new Promise(resolve => { @@ -103,9 +102,6 @@ StartupRecorder.prototype = { } }), }; - this.data.extras[name] = { - hiddenWindowLoaded: Services.appShell.hasHiddenWindow, - }; }, observe(subject, topic, data) { diff --git a/dom/base/nsWindowMemoryReporter.h b/dom/base/nsWindowMemoryReporter.h index a91d60cddeac..c2a61d63acac 100644 --- a/dom/base/nsWindowMemoryReporter.h +++ b/dom/base/nsWindowMemoryReporter.h @@ -80,8 +80,8 @@ class nsGlobalWindowInner; * its own sub-tree, even if multiple tabs are showing the same URI. * * - is the URI of the top window. Excepting special windows (such - * as browser.xhtml or hiddenWindow.html) it's what the address bar shows for - * the tab. + * as browser.xhtml or hiddenWindowMac.xhtml) it's what the address bar shows + * for the tab. * */ class nsWindowMemoryReporter final : public nsIMemoryReporter, diff --git a/dom/jar.mn b/dom/jar.mn deleted file mode 100644 index 0b3661cd1603..000000000000 --- a/dom/jar.mn +++ /dev/null @@ -1,6 +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/. - -toolkit.jar: - res/hiddenWindow.html (res/hiddenWindow.html) diff --git a/dom/moz.build b/dom/moz.build index 97c26c96bc29..d3cb669153cb 100644 --- a/dom/moz.build +++ b/dom/moz.build @@ -8,8 +8,6 @@ with Files("**"): BUG_COMPONENT = ("Core", "DOM: Core & HTML") -JAR_MANIFESTS += ["jar.mn"] - interfaces = [ "base", "events", diff --git a/dom/res/hiddenWindow.html b/dom/res/hiddenWindow.html deleted file mode 100644 index cb440d34a3b5..000000000000 --- a/dom/res/hiddenWindow.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - diff --git a/testing/mochitest/leaks.py b/testing/mochitest/leaks.py index 08ed649a0c2a..036fcd56edf6 100644 --- a/testing/mochitest/leaks.py +++ b/testing/mochitest/leaks.py @@ -277,10 +277,7 @@ class ShutdownLeaks(object): return sorted(counts, key=itemgetter(1), reverse=True) def _isHiddenWindowURL(self, url): - return ( - url == "resource://gre-resources/hiddenWindow.html" - or url == "chrome://browser/content/hiddenWindowMac.xhtml" # Win / Linux - ) # Mac + return url == "resource://gre-resources/hiddenWindowMac.xhtml" class LSANLeaks(object): diff --git a/toolkit/components/places/tests/history/test_async_history_api.js b/toolkit/components/places/tests/history/test_async_history_api.js index cc645baaec7b..9ecaee7f445f 100644 --- a/toolkit/components/places/tests/history/test_async_history_api.js +++ b/toolkit/components/places/tests/history/test_async_history_api.js @@ -361,7 +361,7 @@ add_task(async function test_non_addable_uri_errors() { "cached-favicon:http://mozilla.org/made-up-favicon", "view-source:http://mozilla.org", "chrome://browser/content/browser.xhtml", - "resource://gre-resources/hiddenWindow.html", + "resource://gre-resources/hiddenWindowMac.html", "data:,Hello%2C%20World!", "javascript:alert('hello wolrd!');", "blob:foo", diff --git a/toolkit/components/places/tests/unit/test_isvisited.js b/toolkit/components/places/tests/unit/test_isvisited.js index 7271ef7903d6..7ba9354b6d1e 100644 --- a/toolkit/components/places/tests/unit/test_isvisited.js +++ b/toolkit/components/places/tests/unit/test_isvisited.js @@ -40,7 +40,7 @@ add_task(async function test_execute() { "cached-favicon:http://mozilla.org/made-up-favicon", "view-source:http://mozilla.org", "chrome://browser/content/browser.xhtml", - "resource://gre-resources/hiddenWindow.html", + "resource://gre-resources/hiddenWindowMac.xhtml", "data:,Hello%2C%20World!", "javascript:alert('hello wolrd!');", "http://localhost/" + "a".repeat(1984), diff --git a/toolkit/components/startup/nsAppStartup.cpp b/toolkit/components/startup/nsAppStartup.cpp index 724bbcfeca7e..76d85f007ba2 100644 --- a/toolkit/components/startup/nsAppStartup.cpp +++ b/toolkit/components/startup/nsAppStartup.cpp @@ -346,17 +346,12 @@ nsAppStartup::Quit(uint32_t aMode, int aExitCode, bool* aUserAllowedQuit) { } #ifdef XP_MACOSX else if (mConsiderQuitStopper == suspiciousCount) { - // ... or there is only a hiddenWindow left, and it's useless: - // Failure shouldn't be fatal, but will abort quit attempt: if (!appShell) return NS_OK; - - bool usefulHiddenWindow; - appShell->GetApplicationProvidedHiddenWindow(&usefulHiddenWindow); - nsCOMPtr hiddenWindow; - appShell->GetHiddenWindow(getter_AddRefs(hiddenWindow)); - // If the remaining windows are useful, we won't quit: - if (!hiddenWindow || usefulHiddenWindow) { + bool hasHiddenWindow = false; + appShell->GetHasHiddenWindow(&hasHiddenWindow); + // If there's a hidden window, we won't quit: + if (hasHiddenWindow) { return NS_OK; } diff --git a/toolkit/components/startup/public/nsIAppStartup.idl b/toolkit/components/startup/public/nsIAppStartup.idl index 6d9f5d8cfea8..b8eca35f78b3 100644 --- a/toolkit/components/startup/public/nsIAppStartup.idl +++ b/toolkit/components/startup/public/nsIAppStartup.idl @@ -13,12 +13,14 @@ interface nsIAppStartup : nsISupports /** * Create the hidden window. */ + [noscript] void createHiddenWindow(); /** * Destroys the hidden window. This will have no effect if the hidden window * has not yet been created. */ + [noscript] void destroyHiddenWindow(); /** diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp index 06a9aaa84871..318ee7e293b9 100644 --- a/toolkit/xre/nsAppRunner.cpp +++ b/toolkit/xre/nsAppRunner.cpp @@ -5639,25 +5639,12 @@ nsresult XREMain::XRE_mainRun() { SaveToEnv("XRE_RESTARTED_BY_PROFILE_MANAGER="); if (!AppShutdown::IsInOrBeyond(ShutdownPhase::AppShutdownConfirmed)) { - // Don't create the hidden window during startup on - // platforms that don't always need it. #ifdef XP_MACOSX - bool lazyHiddenWindow = false; -#else - bool lazyHiddenWindow = true; -#endif - -#ifdef MOZ_BACKGROUNDTASKS - if (BackgroundTasks::IsBackgroundTaskMode()) { - // Background tasks aren't going to load a chrome XUL document. - lazyHiddenWindow = true; - } -#endif - - if (!lazyHiddenWindow) { + if (!BackgroundTasks::IsBackgroundTaskMode()) { rv = appStartup->CreateHiddenWindow(); NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE); } +#endif #ifdef XP_WIN Preferences::RegisterCallbackAndCall( diff --git a/xpfe/appshell/nsAppShellService.cpp b/xpfe/appshell/nsAppShellService.cpp index a68e24e6ad24..8475ce5b896e 100644 --- a/xpfe/appshell/nsAppShellService.cpp +++ b/xpfe/appshell/nsAppShellService.cpp @@ -50,16 +50,12 @@ using namespace mozilla; using mozilla::dom::BrowsingContext; using mozilla::intl::LocaleService; -// Default URL for the hidden window, can be overridden by a pref on Mac -#define DEFAULT_HIDDENWINDOW_URL "resource://gre-resources/hiddenWindow.html" - class nsIAppShell; nsAppShellService::nsAppShellService() : mXPCOMWillShutDown(false), mXPCOMShuttingDown(false), mModalWindowCount(0), - mApplicationProvidedHiddenWindow(false), mScreenId(0) { nsCOMPtr obs = services::GetObserverService(); @@ -82,14 +78,9 @@ nsAppShellService::SetScreenId(uint32_t aScreenId) { return NS_OK; } -void nsAppShellService::EnsureHiddenWindow() { - if (!mHiddenWindow) { - (void)CreateHiddenWindow(); - } -} - NS_IMETHODIMP nsAppShellService::CreateHiddenWindow() { +#if defined(XP_MACOSX) if (!XRE_IsParentProcess()) { return NS_ERROR_NOT_IMPLEMENTED; } @@ -113,17 +104,13 @@ nsAppShellService::CreateHiddenWindow() { nsresult rv; int32_t initialHeight = 100, initialWidth = 100; -#ifdef XP_MACOSX uint32_t chromeMask = 0; nsAutoCString prefVal; rv = Preferences::GetCString("browser.hiddenWindowChromeURL", prefVal); - const char* hiddenWindowURL = - NS_SUCCEEDED(rv) ? prefVal.get() : DEFAULT_HIDDENWINDOW_URL; - mApplicationProvidedHiddenWindow = prefVal.get() ? true : false; -#else - static const char hiddenWindowURL[] = DEFAULT_HIDDENWINDOW_URL; - uint32_t chromeMask = nsIWebBrowserChrome::CHROME_ALL; -#endif + if (NS_FAILED(rv)) { + return NS_OK; + } + const char* hiddenWindowURL = prefVal.get(); nsCOMPtr url; rv = NS_NewURI(getter_AddRefs(url), hiddenWindowURL); @@ -142,6 +129,7 @@ nsAppShellService::CreateHiddenWindow() { } mHiddenWindow.swap(newWindow); +#endif return NS_OK; } @@ -677,8 +665,6 @@ NS_IMETHODIMP nsAppShellService::GetHiddenWindow(nsIAppWindow** aWindow) { NS_ENSURE_ARG_POINTER(aWindow); - EnsureHiddenWindow(); - *aWindow = mHiddenWindow; NS_IF_ADDREF(*aWindow); return *aWindow ? NS_OK : NS_ERROR_FAILURE; @@ -688,8 +674,6 @@ NS_IMETHODIMP nsAppShellService::GetHiddenDOMWindow(mozIDOMWindowProxy** aWindow) { NS_ENSURE_ARG_POINTER(aWindow); - EnsureHiddenWindow(); - nsresult rv; nsCOMPtr docShell; NS_ENSURE_TRUE(mHiddenWindow, NS_ERROR_FAILURE); @@ -711,12 +695,6 @@ nsAppShellService::GetHasHiddenWindow(bool* aHasHiddenWindow) { return NS_OK; } -NS_IMETHODIMP -nsAppShellService::GetApplicationProvidedHiddenWindow(bool* aAPHW) { - *aAPHW = mApplicationProvidedHiddenWindow; - return NS_OK; -} - /* * Register a new top level window (created elsewhere) */ diff --git a/xpfe/appshell/nsAppShellService.h b/xpfe/appshell/nsAppShellService.h index 8e85958897af..a960111f5d8c 100644 --- a/xpfe/appshell/nsAppShellService.h +++ b/xpfe/appshell/nsAppShellService.h @@ -34,8 +34,6 @@ class nsAppShellService final : public nsIAppShellService, public nsIObserver { protected: ~nsAppShellService(); - void EnsureHiddenWindow(); - nsresult JustCreateTopWindow(nsIAppWindow* aParent, nsIURI* aUrl, uint32_t aChromeMask, int32_t aInitialWidth, int32_t aInitialHeight, bool aIsHiddenWindow, @@ -46,7 +44,6 @@ class nsAppShellService final : public nsIAppShellService, public nsIObserver { bool mXPCOMWillShutDown; bool mXPCOMShuttingDown; uint16_t mModalWindowCount; - bool mApplicationProvidedHiddenWindow; uint32_t mScreenId; }; diff --git a/xpfe/appshell/nsIAppShellService.idl b/xpfe/appshell/nsIAppShellService.idl index 93d4e4f9cf89..3b1173935baf 100644 --- a/xpfe/appshell/nsIAppShellService.idl +++ b/xpfe/appshell/nsIAppShellService.idl @@ -58,6 +58,7 @@ interface nsIAppShellService : nsISupports [noscript] void createHiddenWindow(); + [noscript] void destroyHiddenWindow(); /** @@ -86,13 +87,6 @@ interface nsIAppShellService : nsISupports */ readonly attribute mozIDOMWindowProxy hiddenDOMWindow; - /** - * Return true if the application hidden window was provided by the - * application. If it wasn't, the default hidden window was used. This will - * usually be false on all non-mac platforms. - */ - readonly attribute boolean applicationProvidedHiddenWindow; - /** * Add a window to the application's registry of windows. These windows * are generally shown in the Windows taskbar, and the application @@ -112,7 +106,8 @@ interface nsIAppShellService : nsISupports void unregisterTopLevelWindow(in nsIAppWindow aWindow); /** - * Whether the hidden window has been lazily created. + * Whether the hidden window exists. + * This will be false on all non-mac platforms. */ readonly attribute boolean hasHiddenWindow; };