Bug 1442006 - Rename globalOverlay.js to chromeGlobals.js and load it in all chrome documents;r=florian
This uses the chrome-document-global-created notification to load the script in all chrome documents
in the parent process. The only exception is if the associated window location is about:blank, since
we don't want to de extra work in the initial blank window
MozReview-Commit-ID: 5HKbkSMrnC4
--- a/browser/base/content/pageinfo/pageInfo.js
+++ b/browser/base/content/pageinfo/pageInfo.js
@@ -1,15 +1,14 @@
/* 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/. */
ChromeUtils.import("resource://gre/modules/Services.jsm");
-/* import-globals-from ../../../../toolkit/content/globalOverlay.js */
/* import-globals-from ../../../../toolkit/content/contentAreaUtils.js */
/* import-globals-from ../../../../toolkit/content/treeUtils.js */
/* import-globals-from feeds.js */
/* import-globals-from permissions.js */
/* import-globals-from security.js */
// define a js object to implement nsITreeView
function pageInfoTreeView(treeid, copycol) {
--- a/browser/base/content/pageinfo/pageInfo.xul
+++ b/browser/base/content/pageinfo/pageInfo.xul
@@ -24,17 +24,16 @@
windowtype="Browser:page-info"
onload="onLoadPageInfo()"
onunload="onUnloadPageInfo()"
align="stretch"
screenX="10" screenY="10"
width="&pageInfoWindow.width;" height="&pageInfoWindow.height;"
persist="screenX screenY width height sizemode">
- <script type="application/javascript" src="chrome://global/content/globalOverlay.js"/>
<script type="application/javascript" src="chrome://global/content/contentAreaUtils.js"/>
<script type="application/javascript" src="chrome://global/content/treeUtils.js"/>
<script type="application/javascript" src="chrome://browser/content/pageinfo/pageInfo.js"/>
<script type="application/javascript" src="chrome://browser/content/pageinfo/feeds.js"/>
<script type="application/javascript" src="chrome://browser/content/pageinfo/permissions.js"/>
<script type="application/javascript" src="chrome://browser/content/pageinfo/security.js"/>
<script type="application/javascript" src="chrome://browser/content/utilityOverlay.js"/>
--- a/browser/components/downloads/content/allDownloadsViewOverlay.xul
+++ b/browser/components/downloads/content/allDownloadsViewOverlay.xul
@@ -18,18 +18,17 @@
managing the downloads list. In order to use this view:
1. Apply this overlay to your window.
2. Insert in all the overlay entry-points, namely:
<richlistbox id="downloadsRichListBox"/>
<commandset id="downloadCommands"/>
<menupopup id="downloadsContextMenu"/>
3. Make sure your window has the editMenuOverlay overlay applied,
because the view implements cmd_copy and cmd_delete.
- 4. Make sure your window has the globalOverlay.js script loaded.
- 5. To initialize the view
+ 4. To initialize the view
let view = new DownloadsPlacesView(document.getElementById("downloadsRichListBox"));
// This is what the Places Library uses. It could be tweaked a bit as long as the
// transition-type is set correctly
view.place = "place:transition=7&sort=4";
-->
<overlay id="downloadsViewOverlay"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
--- a/browser/components/downloads/content/contentAreaDownloadsView.xul
+++ b/browser/components/downloads/content/contentAreaDownloadsView.xul
@@ -18,18 +18,16 @@
]>
<window id="contentAreaDownloadsView"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="&downloads.title;"
onload="ContentAreaDownloadsView.init();">
<script type="application/javascript"
- src="chrome://global/content/globalOverlay.js"/>
- <script type="application/javascript"
src="chrome://browser/content/downloads/contentAreaDownloadsView.js"/>
#include ../../../../toolkit/content/editMenuCommands.inc.xul
#include ../../../../toolkit/content/editMenuKeys.inc.xul
#ifdef XP_MACOSX
<keyset id="editMenuKeysExtra">
<key id="key_delete2" keycode="VK_BACK" command="cmd_delete"/>
--- a/browser/components/places/content/placesOverlay.xul
+++ b/browser/components/places/content/placesOverlay.xul
@@ -9,18 +9,16 @@
%editMenuOverlayDTD;
]>
<overlay id="placesOverlay"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript"
- src="chrome://global/content/globalOverlay.js"/>
- <script type="application/javascript"
src="chrome://browser/content/utilityOverlay.js"/>
<script type="application/javascript"><![CDATA[
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
ChromeUtils.defineModuleGetter(window,
"PlacesUtils", "resource://gre/modules/PlacesUtils.jsm");
ChromeUtils.defineModuleGetter(window,
"PlacesUIUtils", "resource:///modules/PlacesUIUtils.jsm");
ChromeUtils.defineModuleGetter(window,
--- a/devtools/client/debugger/debugger.xul
+++ b/devtools/client/debugger/debugger.xul
@@ -19,17 +19,16 @@
macanimationtype="document"
fullscreenbutton="true"
screenX="4" screenY="4"
width="960" height="480"
persist="screenX screenY width height sizemode">
<script type="application/javascript"
src="chrome://devtools/content/shared/theme-switching.js"/>
- <script type="text/javascript" src="chrome://global/content/globalOverlay.js"/>
<script type="text/javascript" src="debugger-controller.js"/>
<script type="text/javascript" src="debugger-view.js"/>
<script type="text/javascript" src="utils.js"/>
<script type="text/javascript" src="views/workers-view.js"/>
<script type="text/javascript" src="views/variable-bubble-view.js"/>
<script type="text/javascript" src="views/watch-expressions-view.js"/>
<script type="text/javascript" src="views/global-search-view.js"/>
<script type="text/javascript" src="views/toolbar-view.js"/>
--- a/devtools/client/framework/toolbox-process-window.xul
+++ b/devtools/client/framework/toolbox-process-window.xul
@@ -12,17 +12,16 @@
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
id="devtools-toolbox-window"
macanimationtype="document"
fullscreenbutton="true"
windowtype="devtools:toolbox"
width="900" height="600"
persist="screenX screenY width height sizemode">
- <script type="text/javascript" src="chrome://global/content/globalOverlay.js"/>
<script type="text/javascript" src="toolbox-process-window.js"/>
<script type="text/javascript" src="chrome://global/content/viewSourceUtils.js"/>
<script type="text/javascript" src="chrome://browser/content/utilityOverlay.js"/>
<commandset id="toolbox-commandset">
<command id="toolbox-cmd-close"/>
</commandset>
--- a/devtools/client/framework/toolbox.js
+++ b/devtools/client/framework/toolbox.js
@@ -2869,17 +2869,17 @@ Toolbox.prototype = {
// Do not display in browser toolbox
if (this.target.chrome) {
return;
}
showDoorhanger({ window: this.win, type: "deveditionpromo" });
},
/**
- * Enable / disable necessary textbox menu items using globalOverlay.js.
+ * Enable / disable necessary textbox menu items using chromeGlobals.js.
*/
_updateTextBoxMenuItems: function() {
let window = this.win;
["cmd_undo", "cmd_delete", "cmd_cut",
"cmd_copy", "cmd_paste", "cmd_selectAll"].forEach(window.goUpdateCommand);
},
/**
--- a/devtools/client/framework/toolbox.xul
+++ b/devtools/client/framework/toolbox.xul
@@ -18,17 +18,16 @@
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml">
<script type="application/javascript"
src="chrome://devtools/content/shared/theme-switching.js"/>
<script type="application/javascript"
src="chrome://global/content/viewSourceUtils.js"/>
- <script type="application/javascript" src="chrome://global/content/globalOverlay.js"/>
<script type="application/javascript"
src="chrome://devtools/content/framework/toolbox-init.js"/>
#include ../../../toolkit/content/editMenuCommands.inc.xul
#include ../../../toolkit/content/editMenuKeys.inc.xul
<popupset>
<menupopup id="toolbox-textbox-context-popup">
--- a/devtools/client/scratchpad/scratchpad.xul
+++ b/devtools/client/scratchpad/scratchpad.xul
@@ -23,17 +23,16 @@
macanimationtype="document"
fullscreenbutton="true"
screenX="4" screenY="4"
width="640" height="480"
persist="screenX screenY width height sizemode">
<script type="application/javascript"
src="chrome://devtools/content/shared/theme-switching.js"/>
-<script type="application/javascript" src="chrome://global/content/globalOverlay.js"/>
<script type="application/javascript" src="chrome://devtools/content/scratchpad/scratchpad.js"/>
#include ../../../toolkit/content/editMenuCommands.inc.xul
<commandset id="sourceEditorCommands">
<command id="cmd_find" oncommand=";"/>
<command id="cmd_findAgain" oncommand=";"/>
<command id="cmd_gotoLine" oncommand=";"/>
--- a/devtools/client/storage/storage.xul
+++ b/devtools/client/storage/storage.xul
@@ -12,17 +12,16 @@
<!ENTITY % storageDTD SYSTEM "chrome://devtools/locale/storage.dtd">
%storageDTD;
]>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript"
src="chrome://devtools/content/shared/theme-switching.js"/>
- <script type="text/javascript" src="chrome://global/content/globalOverlay.js"/>
#include ../../../toolkit/content/editMenuCommands.inc.xul
<popupset id="storagePopupSet">
<menupopup id="storage-tree-popup">
<menuitem id="storage-tree-popup-delete-all"
label="&storage.popupMenu.deleteAllLabel;"/>
<menuitem id="storage-tree-popup-delete-all-session-cookies"
--- a/devtools/client/styleeditor/styleeditor.xul
+++ b/devtools/client/styleeditor/styleeditor.xul
@@ -22,17 +22,16 @@
<?xml-stylesheet href="chrome://devtools/skin/styleeditor.css" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
id="style-editor-chrome-window">
<script type="application/javascript"
src="chrome://devtools/content/shared/theme-switching.js"/>
- <script type="application/javascript" src="chrome://global/content/globalOverlay.js"/>
<script type="application/javascript" src="chrome://browser/content/utilityOverlay.js"/>
<script type="application/javascript">
function goUpdateSourceEditorMenuItems() {
goUpdateGlobalEditMenuItems();
['cmd_undo', 'cmd_redo', 'cmd_cut', 'cmd_paste',
'cmd_delete', 'cmd_find', 'cmd_findAgain'].forEach(goUpdateCommand);
}
--- a/devtools/client/webconsole/webconsole.xul
+++ b/devtools/client/webconsole/webconsole.xul
@@ -22,17 +22,16 @@
title="&window.title;"
windowtype="devtools:webconsole"
width="900" height="350"
persist="screenX screenY width height sizemode">
<script type="application/javascript"
src="chrome://devtools/content/shared/theme-switching.js"/>
<script type="application/javascript"
src="resource://devtools/client/webconsole/new-console-output/main.js"/>
- <script type="text/javascript" src="chrome://global/content/globalOverlay.js"/>
<script type="text/javascript" src="resource://devtools/client/webconsole/net/main.js"/>
<script type="text/javascript"><![CDATA[
function goUpdateConsoleCommands() {
goUpdateCommand("consoleCmd_openURL");
goUpdateCommand("consoleCmd_copyURL");
}
// ]]></script>
--- a/devtools/client/webide/content/webide.xul
+++ b/devtools/client/webide/content/webide.xul
@@ -19,17 +19,16 @@
title="&windowTitle;"
windowtype="devtools:webide"
macanimationtype="document"
fullscreenbutton="true"
screenX="4" screenY="4"
width="800" height="600"
persist="screenX screenY width height sizemode">
- <script type="application/javascript" src="chrome://global/content/globalOverlay.js"></script>
<script type="application/javascript" src="project-panel.js"></script>
<script type="application/javascript" src="runtime-panel.js"></script>
<script type="application/javascript" src="webide.js"></script>
#include ../../../../toolkit/content/editMenuCommands.inc.xul
<commandset id="mainCommandSet">
<commandset id="webideCommands">
--- a/testing/talos/talos/pageloader/chrome/pageloader.xul
+++ b/testing/talos/talos/pageloader/chrome/pageloader.xul
@@ -39,18 +39,16 @@
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="pageloader"
screenX="0" screenY="0"
onload="plInit()">
- <script type="application/x-javascript"
- src="chrome://global/content/globalOverlay.js"/>
<script type="application/x-javascript" src="chrome://talos-powers-content/content/TalosParentProfiler.js"></script>
<script type="application/x-javascript" src="MozillaFileLogger.js"></script>
<script type="application/x-javascript" src="report.js"></script>
<script type="application/x-javascript" src="pageloader.js"></script>
<script type="application/x-javascript" src="quit.js"></script>
<browser id="contentPageloader" src="about:blank"
type="content" flex="1"/>
--- a/toolkit/components/processsingleton/MainProcessSingleton.js
+++ b/toolkit/components/processsingleton/MainProcessSingleton.js
@@ -55,26 +55,35 @@ MainProcessSingleton.prototype = {
Services.search.addEngine(engineURL.spec, null, iconURL ? iconURL.spec : null, true);
});
},
observe(subject, topic, data) {
switch (topic) {
case "app-startup": {
Services.obs.addObserver(this, "xpcom-shutdown");
+ Services.obs.addObserver(this, "chrome-document-global-created");
// Load this script early so that console.* is initialized
// before other frame scripts.
Services.mm.loadFrameScript("chrome://global/content/browser-content.js", true);
Services.ppmm.loadProcessScript("chrome://global/content/process-content.js", true);
Services.mm.addMessageListener("Search:AddEngine", this.addSearchEngine);
Services.ppmm.loadProcessScript("resource:///modules/ContentObservers.js", true);
break;
}
+ case "chrome-document-global-created":
+ if (subject.location.toString() !== "about:blank") {
+ Services.scriptloader.loadSubScript("chrome://global/content/chromeGlobals.js",
+ subject.QueryInterface(Ci.nsIDOMWindow));
+ }
+ break;
+
case "xpcom-shutdown":
Services.mm.removeMessageListener("Search:AddEngine", this.addSearchEngine);
+ Services.obs.removeObserver(this, "chrome-document-global-created");
break;
}
},
};
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([MainProcessSingleton]);
--- a/toolkit/components/prompts/content/commonDialog.xul
+++ b/toolkit/components/prompts/content/commonDialog.xul
@@ -16,17 +16,16 @@
onunload="commonDialogOnUnload();"
ondialogaccept="Dialog.onButton0(); return true;"
ondialogcancel="Dialog.onButton1(); return true;"
ondialogextra1="Dialog.onButton2(); window.close();"
ondialogextra2="Dialog.onButton3(); window.close();"
buttonpack="center">
<script type="application/javascript" src="chrome://global/content/commonDialog.js"/>
- <script type="application/javascript" src="chrome://global/content/globalOverlay.js"/>
<script type="application/javascript">
document.addEventListener("DOMContentLoaded", function() {
commonDialogOnLoad();
});
</script>
<commandset id="selectEditMenuItems">
<command id="cmd_copy" oncommand="goDoCommand('cmd_copy')" disabled="true"/>
rename from toolkit/content/globalOverlay.js
rename to toolkit/content/chromeGlobals.js
--- a/toolkit/content/jar.mn
+++ b/toolkit/content/jar.mn
@@ -42,17 +42,17 @@ toolkit.jar:
* content/global/buildconfig.html
content/global/buildconfig.css
content/global/contentAreaUtils.js
content/global/datepicker.xhtml
#ifndef MOZ_FENNEC
content/global/editMenuOverlay.js
#endif
content/global/filepicker.properties
- content/global/globalOverlay.js
+ content/global/chromeGlobals.js
content/global/mozilla.xhtml
content/global/aboutMozilla.css
content/global/preferencesBindings.js
content/global/process-content.js
content/global/resetProfile.css
content/global/resetProfile.js
content/global/resetProfile.xul
content/global/resetProfileProgress.xul
--- a/toolkit/content/tests/chrome/bug366992_window.xul
+++ b/toolkit/content/tests/chrome/bug366992_window.xul
@@ -26,18 +26,16 @@
<command id="cmd_copy" oncommand="goDoCommand('cmd_copy')"/>
<command id="cmd_paste" oncommand="goDoCommand('cmd_paste')"/>
<command id="cmd_delete" oncommand="goDoCommand('cmd_delete')"/>
<command id="cmd_selectAll" oncommand="goDoCommand('cmd_selectAll')"/>
<command id="cmd_switchTextDirection" oncommand="goDoCommand('cmd_switchTextDirection');"/>
</commandset>
<script type="application/javascript"
- src="chrome://global/content/globalOverlay.js"/>
- <script type="application/javascript"
src="chrome://global/content/editMenuOverlay.js"/>
<script type="application/javascript"><![CDATA[
// Without the fix for bug 366992, the delete command would be enabled
// for the textbox even though the textbox's controller for this command
// disables it.
var gShouldNotBeReachedController = {
supportsCommand: function(aCommand) {
return aCommand == "cmd_delete";
--- a/toolkit/content/tests/chrome/test_autocomplete_delayOnPaste.xul
+++ b/toolkit/content/tests/chrome/test_autocomplete_delayOnPaste.xul
@@ -5,18 +5,16 @@
<window title="Autocomplete Widget Test 4"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="runTest();">
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
- <script type="application/javascript"
- src="chrome://global/content/globalOverlay.js"/>
<textbox id="autocomplete"
type="autocomplete"
completedefaultindex="true"
onsearchcomplete="searchComplete();"
timeout="0"
autocompletesearch="simple"/>
--- a/toolkit/content/tests/chrome/test_autocomplete_placehold_last_complete.xul
+++ b/toolkit/content/tests/chrome/test_autocomplete_placehold_last_complete.xul
@@ -5,18 +5,16 @@
<window title="Autocomplete Widget Test"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="runTest();">
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
- <script type="application/javascript"
- src="chrome://global/content/globalOverlay.js"/>
<textbox id="autocomplete"
type="autocomplete"
completedefaultindex="true"
timeout="0"
autocompletesearch="simple"/>
<script class="testbody" type="application/javascript">
--- a/toolkit/mozapps/extensions/content/blocklist.xul
+++ b/toolkit/mozapps/extensions/content/blocklist.xul
@@ -18,17 +18,16 @@
<dialog windowtype="Addons:Blocklist" title="&blocklist.title;" align="stretch"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="init();" ondialogaccept="return finish(true)"
ondialogcancel="return finish(false)"
buttons="accept,cancel" style="&blocklist.style;"
buttonlabelaccept="&blocklist.accept.label;"
buttonaccesskeyaccept="&blocklist.accept.accesskey;">
- <script type="application/javascript" src="chrome://global/content/globalOverlay.js"/>
<script type="application/javascript" src="chrome://mozapps/content/extensions/blocklist.js"/>
<hbox align="stretch" flex="1">
<vbox pack="start">
<image class="error-icon"/>
</vbox>
<vbox flex="1">
<label>&blocklist.summary;</label>
--- a/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/browser-window.js
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/browser-window.js
@@ -24,19 +24,18 @@ const rootDir = helpers.rootDir;
// These are scripts not included in global-scripts.inc, but which are loaded
// via overlays.
const EXTRA_SCRIPTS = [
"browser/base/content/nsContextMenu.js",
"toolkit/content/contentAreaUtils.js",
"browser/components/places/content/editBookmarkOverlay.js",
"browser/components/downloads/content/downloads.js",
"browser/components/downloads/content/indicator.js",
- // This gets loaded into the same scopes as browser.js via browser.xul and
- // placesOverlay.xul.
- "toolkit/content/globalOverlay.js",
+ // This gets loaded into all chrome documents
+ "toolkit/content/chromeGlobals.js",
// Via editMenuCommands.inc.xul
"toolkit/content/editMenuOverlay.js",
// Via baseMenuOverlay.xul
"browser/base/content/utilityOverlay.js"
];
// Some files in global-scripts.inc need mapping to specific locations.
const MAPPINGS = {
--- a/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/places-overlay.js
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/places-overlay.js
@@ -13,17 +13,16 @@
// -----------------------------------------------------------------------------
// Rule Definition
// -----------------------------------------------------------------------------
var path = require("path");
var helpers = require("../helpers");
var globals = require("../globals");
const placesOverlayFiles = [
- "toolkit/content/globalOverlay.js",
"browser/base/content/utilityOverlay.js"
];
const extraPlacesDefinitions = [
// Via Components.utils, defineModuleGetter, defineLazyModuleGetters or
// defineLazyScriptGetter (and map to
// single) variable.
{name: "XPCOMUtils", writable: false},