Simulator.jsm 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. Components.utils.import("resource://devtools/shared/event-emitter.js");
  6. /**
  7. * TODO (Bug 1132453) The `Simulator` module is deprecated, and should be
  8. * removed once all simulator addons stop using it (see bug 1132452).
  9. *
  10. * If you want to register, unregister, or otherwise deal with installed
  11. * simulators, please use the `Simulators` module defined in:
  12. *
  13. * devtools/client/webide/modules/simulators.js
  14. */
  15. this.EXPORTED_SYMBOLS = ["Simulator"];
  16. let Simulator = this.Simulator = {
  17. _simulators: {},
  18. register: function (name, simulator) {
  19. // simulators register themselves as "Firefox OS X.Y"
  20. this._simulators[name] = simulator;
  21. this.emit("register", name);
  22. },
  23. unregister: function (name) {
  24. delete this._simulators[name];
  25. this.emit("unregister", name);
  26. },
  27. availableNames: function () {
  28. return Object.keys(this._simulators).sort();
  29. },
  30. getByName: function (name) {
  31. return this._simulators[name];
  32. },
  33. };
  34. EventEmitter.decorate(Simulator);