event-emitter.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  4. "use strict";
  5. /**
  6. * This file only exists to support add-ons which import this module at a
  7. * specific path.
  8. */
  9. (function (factory) { // Module boilerplate
  10. if (this.module && module.id.indexOf("event-emitter") >= 0) { // require
  11. factory.call(this, require, exports, module);
  12. } else { // Cu.import
  13. const Cu = Components.utils;
  14. const { require } =
  15. Cu.import("resource://devtools/shared/Loader.jsm", {});
  16. this.isWorker = false;
  17. this.promise = Cu.import("resource://gre/modules/Promise.jsm", {}).Promise;
  18. factory.call(this, require, this, { exports: this });
  19. this.EXPORTED_SYMBOLS = ["EventEmitter"];
  20. }
  21. }).call(this, function (require, exports, module) {
  22. const { Cu } = require("chrome");
  23. const Services = require("Services");
  24. const WARNING_PREF = "devtools.migration.warnings";
  25. // Cu and Services aren't accessible from workers
  26. if (Cu && Services && Services.prefs &&
  27. Services.prefs.getBoolPref(WARNING_PREF)) {
  28. const { Deprecated } =
  29. Cu.import("resource://gre/modules/Deprecated.jsm", {});
  30. Deprecated.warning("This path to event-emitter.js is deprecated. Please " +
  31. "use require(\"devtools/shared/event-emitter\") to " +
  32. "load this module.",
  33. "https://bugzil.la/912121");
  34. }
  35. const EventEmitter = require("devtools/shared/event-emitter");
  36. this.EventEmitter = EventEmitter;
  37. module.exports = EventEmitter;
  38. });