call-watcher.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 protocol = require("devtools/shared/protocol");
  6. const { Arg, RetVal, Option, generateActorSpec } = protocol;
  7. /**
  8. * Type describing a single function call in a stack trace.
  9. */
  10. protocol.types.addDictType("call-stack-item", {
  11. name: "string",
  12. file: "string",
  13. line: "number"
  14. });
  15. /**
  16. * Type describing an overview of a function call.
  17. */
  18. protocol.types.addDictType("call-details", {
  19. type: "number",
  20. name: "string",
  21. stack: "array:call-stack-item"
  22. });
  23. const functionCallSpec = generateActorSpec({
  24. typeName: "function-call",
  25. methods: {
  26. getDetails: {
  27. response: { info: RetVal("call-details") }
  28. },
  29. },
  30. });
  31. exports.functionCallSpec = functionCallSpec;
  32. const callWatcherSpec = generateActorSpec({
  33. typeName: "call-watcher",
  34. events: {
  35. /**
  36. * Events emitted when the `onCall` function isn't provided.
  37. */
  38. "call": {
  39. type: "call",
  40. function: Arg(0, "function-call")
  41. }
  42. },
  43. methods: {
  44. setup: {
  45. request: {
  46. tracedGlobals: Option(0, "nullable:array:string"),
  47. tracedFunctions: Option(0, "nullable:array:string"),
  48. startRecording: Option(0, "boolean"),
  49. performReload: Option(0, "boolean"),
  50. holdWeak: Option(0, "boolean"),
  51. storeCalls: Option(0, "boolean")
  52. },
  53. oneway: true
  54. },
  55. finalize: {
  56. oneway: true
  57. },
  58. isRecording: {
  59. response: RetVal("boolean")
  60. },
  61. initTimestampEpoch: {},
  62. resumeRecording: {},
  63. pauseRecording: {
  64. response: { calls: RetVal("array:function-call") }
  65. },
  66. eraseRecording: {},
  67. }
  68. });
  69. exports.callWatcherSpec = callWatcherSpec;