зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1386299 - Stop importing event-emitter as a JSM. r=jdescottes
MozReview-Commit-ID: FnIRJbILIxj --HG-- extra : rebase_source : e34b781a628a8085bdeb8eba090d5d8102d50c76
This commit is contained in:
Родитель
edb829b798
Коммит
dbebe3ebb7
|
@ -7,13 +7,12 @@
|
|||
|
||||
const { interfaces: Ci, utils: Cu } = Components;
|
||||
|
||||
const { require } = Cu.import("resource://devtools/shared/Loader.jsm", {});
|
||||
const { require, loader } = Cu.import("resource://devtools/shared/Loader.jsm", {});
|
||||
const { XPCOMUtils } = require("resource://gre/modules/XPCOMUtils.jsm");
|
||||
const { ViewHelpers } = require("devtools/client/shared/widgets/view-helpers");
|
||||
const { KeyCodes } = require("devtools/client/shared/keycodes");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "EventEmitter",
|
||||
"resource://devtools/shared/event-emitter.js");
|
||||
loader.lazyRequireGetter(this, "EventEmitter", "devtools/shared/event-emitter");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "console",
|
||||
"resource://gre/modules/Console.jsm");
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
Components.utils.import("resource://devtools/shared/event-emitter.js");
|
||||
const { require } = Components.utils.import("resource://devtools/shared/Loader.jsm", {});
|
||||
const EventEmitter = require("devtools/shared/event-emitter");
|
||||
|
||||
/* exported EXPORTED_SYMBOLS */
|
||||
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
Components.utils.import("resource://devtools/shared/event-emitter.js");
|
||||
const { require } = Components.utils.import("resource://devtools/shared/Loader.jsm", {});
|
||||
const EventEmitter = require("devtools/shared/event-emitter");
|
||||
|
||||
/**
|
||||
* TODO (Bug 1132453) The `Simulator` module is deprecated, and should be
|
||||
|
|
|
@ -4,66 +4,6 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
(function (factory) {
|
||||
// This file can be loaded in several different ways. It can be
|
||||
// require()d, either from the main thread or from a worker thread;
|
||||
// or it can be imported via Cu.import. These different forms
|
||||
// explain some of the hairiness of this code.
|
||||
//
|
||||
// It's important for the devtools-as-html project that a require()
|
||||
// on the main thread not use any chrome privileged APIs. Instead,
|
||||
// the body of the main function can only require() (not Cu.import)
|
||||
// modules that are available in the devtools content mode. This,
|
||||
// plus the lack of |console| in workers, results in some gyrations
|
||||
// in the definition of |console|.
|
||||
if (this.module && module.id.indexOf("event-emitter") >= 0) {
|
||||
let console;
|
||||
if (isWorker) {
|
||||
console = {
|
||||
error: () => {}
|
||||
};
|
||||
} else {
|
||||
console = this.console;
|
||||
}
|
||||
// require
|
||||
factory.call(this, require, exports, module, console);
|
||||
} else {
|
||||
// Cu.import. This snippet implements a sort of miniature loader,
|
||||
// which is responsible for appropriately translating require()
|
||||
// requests from the client function. This code can use
|
||||
// Cu.import, because it is never run in the devtools-in-content
|
||||
// mode.
|
||||
this.isWorker = false;
|
||||
const Cu = Components.utils;
|
||||
let console = Cu.import("resource://gre/modules/Console.jsm", {}).console;
|
||||
// Bug 1259045: This module is loaded early in firefox startup as a JSM,
|
||||
// but it doesn't depends on any real module. We can save a few cycles
|
||||
// and bytes by not loading Loader.jsm.
|
||||
let require = function (module) {
|
||||
switch (module) {
|
||||
case "devtools/shared/defer":
|
||||
return Cu.import("resource://gre/modules/Promise.jsm", {}).Promise.defer;
|
||||
case "Services":
|
||||
return Cu.import("resource://gre/modules/Services.jsm", {}).Services;
|
||||
case "devtools/shared/platform/stack": {
|
||||
let obj = {};
|
||||
Cu.import("resource://devtools/shared/platform/chrome/stack.js", obj);
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
factory.call(this, require, this, { exports: this }, console);
|
||||
this.EXPORTED_SYMBOLS = ["EventEmitter"];
|
||||
}
|
||||
}).call(this, function (require, exports, module, console) {
|
||||
// ⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠
|
||||
// After this point the code may not use Cu.import, and should only
|
||||
// require() modules that are "clean-for-content".
|
||||
let EventEmitter = this.EventEmitter = function () {};
|
||||
module.exports = EventEmitter;
|
||||
|
||||
// See comment in JSM module boilerplate when adding a new dependency.
|
||||
const Services = require("Services");
|
||||
const defer = require("devtools/shared/defer");
|
||||
const { describeNthCaller } = require("devtools/shared/platform/stack");
|
||||
|
@ -78,6 +18,9 @@
|
|||
});
|
||||
}
|
||||
|
||||
let EventEmitter = this.EventEmitter = function () {};
|
||||
module.exports = EventEmitter;
|
||||
|
||||
/**
|
||||
* Decorate an object with event emitter functionality.
|
||||
*
|
||||
|
@ -250,4 +193,3 @@
|
|||
dump(out);
|
||||
},
|
||||
};
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче