promises.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. const {
  6. Arg,
  7. RetVal,
  8. generateActorSpec,
  9. types
  10. } = require("devtools/shared/protocol");
  11. // Teach protocol.js how to deal with legacy actor types
  12. types.addType("ObjectActor", {
  13. write: actor => actor.grip(),
  14. read: grip => grip
  15. });
  16. const promisesSpec = generateActorSpec({
  17. typeName: "promises",
  18. events: {
  19. // Event emitted for new promises allocated in debuggee and bufferred by
  20. // sending the list of promise objects in a batch.
  21. "new-promises": {
  22. type: "new-promises",
  23. data: Arg(0, "array:ObjectActor"),
  24. },
  25. // Event emitted for promise settlements.
  26. "promises-settled": {
  27. type: "promises-settled",
  28. data: Arg(0, "array:ObjectActor")
  29. }
  30. },
  31. methods: {
  32. attach: {
  33. request: {},
  34. response: {},
  35. },
  36. detach: {
  37. request: {},
  38. response: {},
  39. },
  40. listPromises: {
  41. request: {},
  42. response: {
  43. promises: RetVal("array:ObjectActor"),
  44. },
  45. }
  46. }
  47. });
  48. exports.promisesSpec = promisesSpec;