dbg-actors.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 file,
  3. * You can obtain one at http://mozilla.org/MPL/2.0/. */
  4. 'use strict';
  5. const { Promise } = Cu.import("resource://gre/modules/Promise.jsm", {});
  6. var { Services } = Cu.import("resource://gre/modules/Services.jsm", {});
  7. const { devtools } = Cu.import("resource://devtools/shared/Loader.jsm", {});
  8. const { RootActor } = devtools.require("devtools/server/actors/root");
  9. const { BrowserTabList } = devtools.require("devtools/server/actors/webbrowser");
  10. /**
  11. * xpcshell-test (XPCST) specific actors.
  12. *
  13. */
  14. /**
  15. * Construct a root actor appropriate for use in a server running xpcshell
  16. * tests. <snip boilerplate> :)
  17. */
  18. function createRootActor(connection)
  19. {
  20. let parameters = {
  21. tabList: new XPCSTTabList(connection),
  22. globalActorFactories: DebuggerServer.globalActorFactories,
  23. onShutdown() {
  24. // If the user never switches to the "debugger" tab we might get a
  25. // shutdown before we've attached.
  26. Services.obs.notifyObservers(null, "xpcshell-test-devtools-shutdown", null);
  27. }
  28. };
  29. return new RootActor(connection, parameters);
  30. }
  31. /**
  32. * A "stub" TabList implementation that provides no tabs.
  33. */
  34. function XPCSTTabList(connection)
  35. {
  36. BrowserTabList.call(this, connection);
  37. }
  38. XPCSTTabList.prototype = Object.create(BrowserTabList.prototype);
  39. XPCSTTabList.prototype.constructor = XPCSTTabList;
  40. XPCSTTabList.prototype.getList = function() {
  41. return Promise.resolve([]);
  42. };