Bug 1341159 - Use commonLibRequire trick to reuse already loaded libraries r=Honza

MozReview-Commit-ID: 5OHpu6fqF6J

--HG--
extra : rebase_source : 8dd462dac95345a1ff35b08ca04a44c3bdeac006
This commit is contained in:
Ricky Chien 2017-02-21 10:54:30 +08:00
Родитель c280c97f5a
Коммит 6e4a52bd8a
4 изменённых файлов: 16 добавлений и 22 удалений

Просмотреть файл

@ -5,7 +5,6 @@
"use strict";
const Services = require("Services");
const EventEmitter = require("devtools/shared/event-emitter");
const { TimelineFront } = require("devtools/shared/fronts/timeline");
const { CurlUtils } = require("devtools/client/shared/curl");
const { ACTIVITY_TYPE, EVENTS } = require("./constants");
@ -892,14 +891,6 @@ NetworkEventsHandler.prototype = {
}
};
/**
* Convenient way of emitting events from the panel window.
*/
EventEmitter.decorate(window);
/**
* Preliminary setup for the NetMonitorController object.
*/
NetMonitorController.TargetEventsHandler = new TargetEventsHandler();
NetMonitorController.NetworkEventsHandler = new NetworkEventsHandler();
window.gNetwork = NetMonitorController.NetworkEventsHandler;

Просмотреть файл

@ -4,7 +4,19 @@
"use strict";
const { BrowserLoader } = Components.utils.import("resource://devtools/client/shared/browser-loader.js", {});
function Netmonitor(toolbox) {
const require = window.windowRequire = BrowserLoader({
baseURI: "resource://devtools/client/netmonitor/",
window,
commonLibRequire: toolbox.browserRequire,
}).require;
// Inject EventEmitter into netmonitor window.
const EventEmitter = require("devtools/shared/event-emitter");
EventEmitter.decorate(window);
window.NetMonitorController = require("./netmonitor-controller").NetMonitorController;
window.NetMonitorController._toolbox = toolbox;
window.NetMonitorController._target = toolbox.target;

Просмотреть файл

@ -8,19 +8,7 @@
<link rel="stylesheet" href="chrome://devtools/content/shared/widgets/widgets.css"/>
<link rel="stylesheet" href="chrome://devtools/skin/widgets.css"/>
<link rel="stylesheet" href="chrome://devtools/skin/netmonitor.css"/>
<script src="chrome://devtools/content/shared/theme-switching.js"/>
<script>
"use strict";
const { BrowserLoader } = Components.utils.import(
"resource://devtools/client/shared/browser-loader.js", {});
const { require } = BrowserLoader({
baseURI: "resource://devtools/client/netmonitor/",
window,
});
window.windowRequire = require;
</script>
</head>
<body class="theme-sidebar" role="application">
<div class="root"></div>

5
devtools/client/shared/vendor/react-dom.js поставляемый
Просмотреть файл

@ -150,8 +150,11 @@
let doc = node.ownerDocument;
const inspectorUrl = "chrome://devtools/content/inspector/inspector.xhtml";
const netMonitorUrl = "chrome://devtools/content/netmonitor/netmonitor.xhtml";
while (doc instanceof XULDocument || doc.location.href === inspectorUrl) {
while (doc instanceof XULDocument ||
doc.location.href === inspectorUrl ||
doc.location.href === netMonitorUrl) {
const {frameElement} = doc.defaultView;
if (!frameElement) {