Bug 1341420 - don't load main.js from webconsole.xul; r?nchevobbe
MozReview-Commit-ID: JMHIEWooNf2
--- a/devtools/client/webconsole/net/.eslintrc.js
+++ b/devtools/client/webconsole/net/.eslintrc.js
@@ -1,13 +1,12 @@
"use strict";
module.exports = {
"globals": {
- "Locale": true,
"Document": true,
"document": true,
"Node": true,
"Element": true,
"MessageEvent": true,
"BrowserLoader": true,
"addEventListener": true,
"DOMParser": true,
--- a/devtools/client/webconsole/net/components/cookies-tab.js
+++ b/devtools/client/webconsole/net/components/cookies-tab.js
@@ -1,14 +1,16 @@
/* 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/. */
"use strict";
const React = require("devtools/client/shared/vendor/react");
+const {Locale} = require("devtools/client/webconsole/net/main");
+
const NetInfoGroupList = React.createFactory(require("./net-info-group-list"));
const Spinner = React.createFactory(require("./spinner"));
// Shortcuts
const DOM = React.DOM;
const PropTypes = React.PropTypes;
/**
--- a/devtools/client/webconsole/net/components/headers-tab.js
+++ b/devtools/client/webconsole/net/components/headers-tab.js
@@ -1,14 +1,16 @@
/* 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/. */
"use strict";
const React = require("devtools/client/shared/vendor/react");
+const {Locale} = require("devtools/client/webconsole/net/main");
+
const NetInfoGroupList = React.createFactory(require("./net-info-group-list"));
const Spinner = React.createFactory(require("./spinner"));
// Shortcuts
const DOM = React.DOM;
const PropTypes = React.PropTypes;
/**
--- a/devtools/client/webconsole/net/components/post-tab.js
+++ b/devtools/client/webconsole/net/components/post-tab.js
@@ -1,14 +1,15 @@
/* 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/. */
"use strict";
const React = require("devtools/client/shared/vendor/react");
+const {Locale} = require("devtools/client/webconsole/net/main");
const TreeView = React.createFactory(require("devtools/client/shared/components/tree/tree-view"));
const { REPS, MODE, parseURLEncodedText } = require("devtools/client/shared/components/reps/reps");
const Rep = React.createFactory(REPS.Rep);
// Network
const NetInfoParams = React.createFactory(require("./net-info-params"));
--- a/devtools/client/webconsole/net/components/response-tab.js
+++ b/devtools/client/webconsole/net/components/response-tab.js
@@ -1,14 +1,15 @@
/* 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/. */
"use strict";
const React = require("devtools/client/shared/vendor/react");
+const {Locale} = require("devtools/client/webconsole/net/main");
// Reps
const TreeView = React.createFactory(require("devtools/client/shared/components/tree/tree-view"));
const { REPS, MODE } = require("devtools/client/shared/components/reps/reps");
const Rep = React.createFactory(REPS.Rep);
// Network
const SizeLimit = React.createFactory(require("./size-limit"));
--- a/devtools/client/webconsole/net/main.js
+++ b/devtools/client/webconsole/net/main.js
@@ -1,25 +1,13 @@
/* 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/. */
"use strict";
-/* global BrowserLoader */
-
-var { utils: Cu } = Components;
-
-// Initialize module loader and load all modules of the new inline
-// preview feature. The entire code-base doesn't need any extra
-// privileges and runs entirely in content scope.
-const rootUrl = "resource://devtools/client/webconsole/net/";
-const require = BrowserLoader({
- baseURI: rootUrl,
- window}).require;
-
const NetRequest = require("./net-request");
const { loadSheet } = require("sdk/stylesheet/utils");
// Localization
const {LocalizationHelper} = require("devtools/shared/l10n");
const L10N = new LocalizationHelper("devtools/client/locales/netmonitor.properties");
// Stylesheets
@@ -34,29 +22,31 @@ var styleSheets = [
"resource://devtools/client/webconsole/net/components/net-info-params.css",
"resource://devtools/client/webconsole/net/components/response-tab.css"
];
// Load theme stylesheets into the Console frame. This should be
// done automatically by UI Components as soon as we have consensus
// on the right CSS strategy FIXME.
// It would also be nice to include them using @import.
-styleSheets.forEach(url => {
- loadSheet(this, url, "author");
-});
+function loadStyleSheets(window) {
+ styleSheets.forEach(url => {
+ loadSheet(window, url, "author");
+ });
+}
// Localization API used by React components
// accessing strings from *.properties file.
// Example:
// let localizedString = Locale.$STR('string-key');
//
// Resources:
// http://l20n.org/
// https://github.com/yahoo/react-intl
-this.Locale = {
+var Locale = {
$STR: key => {
try {
return L10N.getStr(key);
} catch (err) {
console.error(key + ": " + err);
}
}
};
@@ -87,12 +77,13 @@ function onNetworkEvent(log) {
if (log.update) {
netRequest.updateBody(response);
}
return;
}
-// Make the 'onNetworkEvent' accessible from chrome (see webconsole.js)
-this.NetRequest = {
- onNetworkEvent: onNetworkEvent
+module.exports = {
+ onNetworkEvent,
+ Locale,
+ loadStyleSheets,
};
--- a/devtools/client/webconsole/webconsole.js
+++ b/devtools/client/webconsole/webconsole.js
@@ -575,16 +575,26 @@ WebConsoleFrame.prototype = {
// in JSTerm is still necessary.
this.newConsoleOutput = new this.window.NewConsoleOutput(
this.experimentalOutputNode, this.jsterm, toolbox, this.owner, this.document);
let filterToolbar = this.document.querySelector(".hud-console-filter-toolbar");
filterToolbar.hidden = true;
} else {
+ const rootUrl = "resource://devtools/client/webconsole/net/";
+ let {require} = BrowserLoaderModule.BrowserLoader({
+ window: this.window,
+ baseURI: rootUrl
+ });
+
+ let {onNetworkEvent, loadStyleSheets} = require("devtools/client/webconsole/net/main");
+ this.onNetworkEvent = onNetworkEvent;
+ loadStyleSheets(this.window);
+
// Register the controller to handle "select all" properly.
this._commandController = new CommandController(this);
this.window.controllers.insertControllerAt(0, this._commandController);
this._contextMenuHandler = new ConsoleContextMenu(this);
this._initDefaultFilterPrefs();
this.filterBox = this.document.querySelector(".hud-filter-box");
@@ -1666,18 +1676,18 @@ WebConsoleFrame.prototype = {
this._addMessageLinkCallback(urlNode, onClick);
this._addMessageLinkCallback(statusNode, onClick);
networkInfo.node = messageNode;
this._updateNetMessage(actorId);
- if (this.window.NetRequest) {
- this.window.NetRequest.onNetworkEvent({
+ if (this.onNetworkEvent) {
+ this.onNetworkEvent({
consoleFrame: this,
response: networkInfo,
node: messageNode,
update: false
});
}
return messageNode;
@@ -1836,18 +1846,18 @@ WebConsoleFrame.prototype = {
*
* @param object networkInfo
* The network request information.
* @param object packet
* Update details.
*/
handleNetworkEventUpdate: function (networkInfo, packet) {
if (networkInfo.node && this._updateNetMessage(packet.from)) {
- if (this.window.NetRequest) {
- this.window.NetRequest.onNetworkEvent({
+ if (this.onNetworkEvent) {
+ this.onNetworkEvent({
client: this.webConsoleClient,
response: packet,
node: networkInfo.node,
update: true
});
}
this.emit("new-messages", new Set([{
--- a/devtools/client/webconsole/webconsole.xul
+++ b/devtools/client/webconsole/webconsole.xul
@@ -24,17 +24,16 @@
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>
<commandset id="editMenuCommands"/>