No bug - tagging b4d3227540c9ebc43d64aac6168fdca7019c22d8 with FIREFOX_BETA_126_BASE...
[gecko.git] / devtools / shared / specs / source.js
blobb2cd2d977a3a2a64efaa73aca1a9067612fde393
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";
6 const {
7   Arg,
8   RetVal,
9   generateActorSpec,
10   types,
11 } = require("resource://devtools/shared/protocol.js");
13 const longstringType = types.getType("longstring");
14 const arraybufferType = types.getType("arraybuffer");
15 // The sourcedata type needs some custom marshalling, because it is sometimes
16 // returned as an arraybuffer and sometimes as a longstring.
17 types.addType("sourcedata", {
18   write: (value, context, detail) => {
19     if (value.typeName === "arraybuffer") {
20       return arraybufferType.write(value, context, detail);
21     }
22     return longstringType.write(value, context, detail);
23   },
24   read: (value, context, detail) => {
25     if (value.typeName === "arraybuffer") {
26       return arraybufferType.read(value, context, detail);
27     }
28     return longstringType.read(value, context, detail);
29   },
30 });
32 types.addDictType("sourceposition", {
33   line: "number",
34   column: "number",
35 });
36 types.addDictType("nullablesourceposition", {
37   line: "nullable:number",
38   column: "nullable:number",
39 });
40 types.addDictType("breakpointquery", {
41   start: "nullable:nullablesourceposition",
42   end: "nullable:nullablesourceposition",
43 });
45 types.addDictType("source.onsource", {
46   contentType: "nullable:string",
47   source: "nullable:sourcedata",
48 });
50 const sourceSpec = generateActorSpec({
51   typeName: "source",
53   methods: {
54     getBreakpointPositionsCompressed: {
55       request: {
56         query: Arg(0, "nullable:breakpointquery"),
57       },
58       response: {
59         positions: RetVal("json"),
60       },
61     },
62     getBreakableLines: {
63       request: {},
64       response: {
65         lines: RetVal("json"),
66       },
67     },
68     source: {
69       request: {},
70       response: RetVal("source.onsource"),
71     },
72     setPausePoints: {
73       request: {
74         pausePoints: Arg(0, "json"),
75       },
76     },
77     blackbox: {
78       request: { range: Arg(0, "nullable:json") },
79       response: { pausedInSource: RetVal("boolean") },
80     },
81     unblackbox: {
82       request: { range: Arg(0, "nullable:json") },
83     },
84   },
85 });
87 exports.sourceSpec = sourceSpec;