runtime.go 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096
  1. // Package runtime provides the Chrome DevTools Protocol
  2. // commands, types, and events for the Runtime domain.
  3. //
  4. // Runtime domain exposes JavaScript runtime by means of remote evaluation
  5. // and mirror objects. Evaluation results are returned as mirror object that
  6. // expose object type, string representation and unique identifier that can be
  7. // used for further object reference. Original objects are maintained in memory
  8. // unless they are either explicitly released or are released along with the
  9. // other objects in their object group.
  10. //
  11. // Generated by the cdproto-gen command.
  12. package runtime
  13. // Code generated by cdproto-gen. DO NOT EDIT.
  14. import (
  15. "context"
  16. "github.com/chromedp/cdproto/cdp"
  17. )
  18. // AwaitPromiseParams add handler to promise with given promise object id.
  19. type AwaitPromiseParams struct {
  20. PromiseObjectID RemoteObjectID `json:"promiseObjectId"` // Identifier of the promise.
  21. ReturnByValue bool `json:"returnByValue,omitempty"` // Whether the result is expected to be a JSON object that should be sent by value.
  22. GeneratePreview bool `json:"generatePreview,omitempty"` // Whether preview should be generated for the result.
  23. }
  24. // AwaitPromise add handler to promise with given promise object id.
  25. //
  26. // See: https://chromedevtools.github.io/devtools-protocol/tot/Runtime#method-awaitPromise
  27. //
  28. // parameters:
  29. //
  30. // promiseObjectID - Identifier of the promise.
  31. func AwaitPromise(promiseObjectID RemoteObjectID) *AwaitPromiseParams {
  32. return &AwaitPromiseParams{
  33. PromiseObjectID: promiseObjectID,
  34. }
  35. }
  36. // WithReturnByValue whether the result is expected to be a JSON object that
  37. // should be sent by value.
  38. func (p AwaitPromiseParams) WithReturnByValue(returnByValue bool) *AwaitPromiseParams {
  39. p.ReturnByValue = returnByValue
  40. return &p
  41. }
  42. // WithGeneratePreview whether preview should be generated for the result.
  43. func (p AwaitPromiseParams) WithGeneratePreview(generatePreview bool) *AwaitPromiseParams {
  44. p.GeneratePreview = generatePreview
  45. return &p
  46. }
  47. // AwaitPromiseReturns return values.
  48. type AwaitPromiseReturns struct {
  49. Result *RemoteObject `json:"result,omitempty"` // Promise result. Will contain rejected value if promise was rejected.
  50. ExceptionDetails *ExceptionDetails `json:"exceptionDetails,omitempty"` // Exception details if stack strace is available.
  51. }
  52. // Do executes Runtime.awaitPromise against the provided context.
  53. //
  54. // returns:
  55. //
  56. // result - Promise result. Will contain rejected value if promise was rejected.
  57. // exceptionDetails - Exception details if stack strace is available.
  58. func (p *AwaitPromiseParams) Do(ctx context.Context) (result *RemoteObject, exceptionDetails *ExceptionDetails, err error) {
  59. // execute
  60. var res AwaitPromiseReturns
  61. err = cdp.Execute(ctx, CommandAwaitPromise, p, &res)
  62. if err != nil {
  63. return nil, nil, err
  64. }
  65. return res.Result, res.ExceptionDetails, nil
  66. }
  67. // CallFunctionOnParams calls function with given declaration on the given
  68. // object. Object group of the result is inherited from the target object.
  69. type CallFunctionOnParams struct {
  70. FunctionDeclaration string `json:"functionDeclaration"` // Declaration of the function to call.
  71. ObjectID RemoteObjectID `json:"objectId,omitempty"` // Identifier of the object to call function on. Either objectId or executionContextId should be specified.
  72. Arguments []*CallArgument `json:"arguments,omitempty"` // Call arguments. All call arguments must belong to the same JavaScript world as the target object.
  73. Silent bool `json:"silent,omitempty"` // In silent mode exceptions thrown during evaluation are not reported and do not pause execution. Overrides setPauseOnException state.
  74. ReturnByValue bool `json:"returnByValue,omitempty"` // Whether the result is expected to be a JSON object which should be sent by value. Can be overridden by serializationOptions.
  75. GeneratePreview bool `json:"generatePreview,omitempty"` // Whether preview should be generated for the result.
  76. UserGesture bool `json:"userGesture,omitempty"` // Whether execution should be treated as initiated by user in the UI.
  77. AwaitPromise bool `json:"awaitPromise,omitempty"` // Whether execution should await for resulting value and return once awaited promise is resolved.
  78. ExecutionContextID ExecutionContextID `json:"executionContextId,omitempty"` // Specifies execution context which global object will be used to call function on. Either executionContextId or objectId should be specified.
  79. ObjectGroup string `json:"objectGroup,omitempty"` // Symbolic group name that can be used to release multiple objects. If objectGroup is not specified and objectId is, objectGroup will be inherited from object.
  80. ThrowOnSideEffect bool `json:"throwOnSideEffect,omitempty"` // Whether to throw an exception if side effect cannot be ruled out during evaluation.
  81. UniqueContextID string `json:"uniqueContextId,omitempty"` // An alternative way to specify the execution context to call function on. Compared to contextId that may be reused across processes, this is guaranteed to be system-unique, so it can be used to prevent accidental function call in context different than intended (e.g. as a result of navigation across process boundaries). This is mutually exclusive with executionContextId.
  82. SerializationOptions *SerializationOptions `json:"serializationOptions,omitempty"` // Specifies the result serialization. If provided, overrides generatePreview and returnByValue.
  83. }
  84. // CallFunctionOn calls function with given declaration on the given object.
  85. // Object group of the result is inherited from the target object.
  86. //
  87. // See: https://chromedevtools.github.io/devtools-protocol/tot/Runtime#method-callFunctionOn
  88. //
  89. // parameters:
  90. //
  91. // functionDeclaration - Declaration of the function to call.
  92. func CallFunctionOn(functionDeclaration string) *CallFunctionOnParams {
  93. return &CallFunctionOnParams{
  94. FunctionDeclaration: functionDeclaration,
  95. }
  96. }
  97. // WithObjectID identifier of the object to call function on. Either objectId
  98. // or executionContextId should be specified.
  99. func (p CallFunctionOnParams) WithObjectID(objectID RemoteObjectID) *CallFunctionOnParams {
  100. p.ObjectID = objectID
  101. return &p
  102. }
  103. // WithArguments call arguments. All call arguments must belong to the same
  104. // JavaScript world as the target object.
  105. func (p CallFunctionOnParams) WithArguments(arguments []*CallArgument) *CallFunctionOnParams {
  106. p.Arguments = arguments
  107. return &p
  108. }
  109. // WithSilent in silent mode exceptions thrown during evaluation are not
  110. // reported and do not pause execution. Overrides setPauseOnException state.
  111. func (p CallFunctionOnParams) WithSilent(silent bool) *CallFunctionOnParams {
  112. p.Silent = silent
  113. return &p
  114. }
  115. // WithReturnByValue whether the result is expected to be a JSON object which
  116. // should be sent by value. Can be overridden by serializationOptions.
  117. func (p CallFunctionOnParams) WithReturnByValue(returnByValue bool) *CallFunctionOnParams {
  118. p.ReturnByValue = returnByValue
  119. return &p
  120. }
  121. // WithGeneratePreview whether preview should be generated for the result.
  122. func (p CallFunctionOnParams) WithGeneratePreview(generatePreview bool) *CallFunctionOnParams {
  123. p.GeneratePreview = generatePreview
  124. return &p
  125. }
  126. // WithUserGesture whether execution should be treated as initiated by user
  127. // in the UI.
  128. func (p CallFunctionOnParams) WithUserGesture(userGesture bool) *CallFunctionOnParams {
  129. p.UserGesture = userGesture
  130. return &p
  131. }
  132. // WithAwaitPromise whether execution should await for resulting value and
  133. // return once awaited promise is resolved.
  134. func (p CallFunctionOnParams) WithAwaitPromise(awaitPromise bool) *CallFunctionOnParams {
  135. p.AwaitPromise = awaitPromise
  136. return &p
  137. }
  138. // WithExecutionContextID specifies execution context which global object
  139. // will be used to call function on. Either executionContextId or objectId
  140. // should be specified.
  141. func (p CallFunctionOnParams) WithExecutionContextID(executionContextID ExecutionContextID) *CallFunctionOnParams {
  142. p.ExecutionContextID = executionContextID
  143. return &p
  144. }
  145. // WithObjectGroup symbolic group name that can be used to release multiple
  146. // objects. If objectGroup is not specified and objectId is, objectGroup will be
  147. // inherited from object.
  148. func (p CallFunctionOnParams) WithObjectGroup(objectGroup string) *CallFunctionOnParams {
  149. p.ObjectGroup = objectGroup
  150. return &p
  151. }
  152. // WithThrowOnSideEffect whether to throw an exception if side effect cannot
  153. // be ruled out during evaluation.
  154. func (p CallFunctionOnParams) WithThrowOnSideEffect(throwOnSideEffect bool) *CallFunctionOnParams {
  155. p.ThrowOnSideEffect = throwOnSideEffect
  156. return &p
  157. }
  158. // WithUniqueContextID an alternative way to specify the execution context to
  159. // call function on. Compared to contextId that may be reused across processes,
  160. // this is guaranteed to be system-unique, so it can be used to prevent
  161. // accidental function call in context different than intended (e.g. as a result
  162. // of navigation across process boundaries). This is mutually exclusive with
  163. // executionContextId.
  164. func (p CallFunctionOnParams) WithUniqueContextID(uniqueContextID string) *CallFunctionOnParams {
  165. p.UniqueContextID = uniqueContextID
  166. return &p
  167. }
  168. // WithSerializationOptions specifies the result serialization. If provided,
  169. // overrides generatePreview and returnByValue.
  170. func (p CallFunctionOnParams) WithSerializationOptions(serializationOptions *SerializationOptions) *CallFunctionOnParams {
  171. p.SerializationOptions = serializationOptions
  172. return &p
  173. }
  174. // CallFunctionOnReturns return values.
  175. type CallFunctionOnReturns struct {
  176. Result *RemoteObject `json:"result,omitempty"` // Call result.
  177. ExceptionDetails *ExceptionDetails `json:"exceptionDetails,omitempty"` // Exception details.
  178. }
  179. // Do executes Runtime.callFunctionOn against the provided context.
  180. //
  181. // returns:
  182. //
  183. // result - Call result.
  184. // exceptionDetails - Exception details.
  185. func (p *CallFunctionOnParams) Do(ctx context.Context) (result *RemoteObject, exceptionDetails *ExceptionDetails, err error) {
  186. // execute
  187. var res CallFunctionOnReturns
  188. err = cdp.Execute(ctx, CommandCallFunctionOn, p, &res)
  189. if err != nil {
  190. return nil, nil, err
  191. }
  192. return res.Result, res.ExceptionDetails, nil
  193. }
  194. // CompileScriptParams compiles expression.
  195. type CompileScriptParams struct {
  196. Expression string `json:"expression"` // Expression to compile.
  197. SourceURL string `json:"sourceURL"` // Source url to be set for the script.
  198. PersistScript bool `json:"persistScript"` // Specifies whether the compiled script should be persisted.
  199. ExecutionContextID ExecutionContextID `json:"executionContextId,omitempty"` // Specifies in which execution context to perform script run. If the parameter is omitted the evaluation will be performed in the context of the inspected page.
  200. }
  201. // CompileScript compiles expression.
  202. //
  203. // See: https://chromedevtools.github.io/devtools-protocol/tot/Runtime#method-compileScript
  204. //
  205. // parameters:
  206. //
  207. // expression - Expression to compile.
  208. // sourceURL - Source url to be set for the script.
  209. // persistScript - Specifies whether the compiled script should be persisted.
  210. func CompileScript(expression string, sourceURL string, persistScript bool) *CompileScriptParams {
  211. return &CompileScriptParams{
  212. Expression: expression,
  213. SourceURL: sourceURL,
  214. PersistScript: persistScript,
  215. }
  216. }
  217. // WithExecutionContextID specifies in which execution context to perform
  218. // script run. If the parameter is omitted the evaluation will be performed in
  219. // the context of the inspected page.
  220. func (p CompileScriptParams) WithExecutionContextID(executionContextID ExecutionContextID) *CompileScriptParams {
  221. p.ExecutionContextID = executionContextID
  222. return &p
  223. }
  224. // CompileScriptReturns return values.
  225. type CompileScriptReturns struct {
  226. ScriptID ScriptID `json:"scriptId,omitempty"` // Id of the script.
  227. ExceptionDetails *ExceptionDetails `json:"exceptionDetails,omitempty"` // Exception details.
  228. }
  229. // Do executes Runtime.compileScript against the provided context.
  230. //
  231. // returns:
  232. //
  233. // scriptID - Id of the script.
  234. // exceptionDetails - Exception details.
  235. func (p *CompileScriptParams) Do(ctx context.Context) (scriptID ScriptID, exceptionDetails *ExceptionDetails, err error) {
  236. // execute
  237. var res CompileScriptReturns
  238. err = cdp.Execute(ctx, CommandCompileScript, p, &res)
  239. if err != nil {
  240. return "", nil, err
  241. }
  242. return res.ScriptID, res.ExceptionDetails, nil
  243. }
  244. // DisableParams disables reporting of execution contexts creation.
  245. type DisableParams struct{}
  246. // Disable disables reporting of execution contexts creation.
  247. //
  248. // See: https://chromedevtools.github.io/devtools-protocol/tot/Runtime#method-disable
  249. func Disable() *DisableParams {
  250. return &DisableParams{}
  251. }
  252. // Do executes Runtime.disable against the provided context.
  253. func (p *DisableParams) Do(ctx context.Context) (err error) {
  254. return cdp.Execute(ctx, CommandDisable, nil, nil)
  255. }
  256. // DiscardConsoleEntriesParams discards collected exceptions and console API
  257. // calls.
  258. type DiscardConsoleEntriesParams struct{}
  259. // DiscardConsoleEntries discards collected exceptions and console API calls.
  260. //
  261. // See: https://chromedevtools.github.io/devtools-protocol/tot/Runtime#method-discardConsoleEntries
  262. func DiscardConsoleEntries() *DiscardConsoleEntriesParams {
  263. return &DiscardConsoleEntriesParams{}
  264. }
  265. // Do executes Runtime.discardConsoleEntries against the provided context.
  266. func (p *DiscardConsoleEntriesParams) Do(ctx context.Context) (err error) {
  267. return cdp.Execute(ctx, CommandDiscardConsoleEntries, nil, nil)
  268. }
  269. // EnableParams enables reporting of execution contexts creation by means of
  270. // executionContextCreated event. When the reporting gets enabled the event will
  271. // be sent immediately for each existing execution context.
  272. type EnableParams struct{}
  273. // Enable enables reporting of execution contexts creation by means of
  274. // executionContextCreated event. When the reporting gets enabled the event will
  275. // be sent immediately for each existing execution context.
  276. //
  277. // See: https://chromedevtools.github.io/devtools-protocol/tot/Runtime#method-enable
  278. func Enable() *EnableParams {
  279. return &EnableParams{}
  280. }
  281. // Do executes Runtime.enable against the provided context.
  282. func (p *EnableParams) Do(ctx context.Context) (err error) {
  283. return cdp.Execute(ctx, CommandEnable, nil, nil)
  284. }
  285. // EvaluateParams evaluates expression on global object.
  286. type EvaluateParams struct {
  287. Expression string `json:"expression"` // Expression to evaluate.
  288. ObjectGroup string `json:"objectGroup,omitempty"` // Symbolic group name that can be used to release multiple objects.
  289. IncludeCommandLineAPI bool `json:"includeCommandLineAPI,omitempty"` // Determines whether Command Line API should be available during the evaluation.
  290. Silent bool `json:"silent,omitempty"` // In silent mode exceptions thrown during evaluation are not reported and do not pause execution. Overrides setPauseOnException state.
  291. ContextID ExecutionContextID `json:"contextId,omitempty"` // Specifies in which execution context to perform evaluation. If the parameter is omitted the evaluation will be performed in the context of the inspected page. This is mutually exclusive with uniqueContextId, which offers an alternative way to identify the execution context that is more reliable in a multi-process environment.
  292. ReturnByValue bool `json:"returnByValue,omitempty"` // Whether the result is expected to be a JSON object that should be sent by value.
  293. GeneratePreview bool `json:"generatePreview,omitempty"` // Whether preview should be generated for the result.
  294. UserGesture bool `json:"userGesture,omitempty"` // Whether execution should be treated as initiated by user in the UI.
  295. AwaitPromise bool `json:"awaitPromise,omitempty"` // Whether execution should await for resulting value and return once awaited promise is resolved.
  296. ThrowOnSideEffect bool `json:"throwOnSideEffect,omitempty"` // Whether to throw an exception if side effect cannot be ruled out during evaluation. This implies disableBreaks below.
  297. Timeout TimeDelta `json:"timeout,omitempty"` // Terminate execution after timing out (number of milliseconds).
  298. DisableBreaks bool `json:"disableBreaks,omitempty"` // Disable breakpoints during execution.
  299. ReplMode bool `json:"replMode,omitempty"` // Setting this flag to true enables let re-declaration and top-level await. Note that let variables can only be re-declared if they originate from replMode themselves.
  300. AllowUnsafeEvalBlockedByCSP bool `json:"allowUnsafeEvalBlockedByCSP,omitempty"` // The Content Security Policy (CSP) for the target might block 'unsafe-eval' which includes eval(), Function(), setTimeout() and setInterval() when called with non-callable arguments. This flag bypasses CSP for this evaluation and allows unsafe-eval. Defaults to true.
  301. UniqueContextID string `json:"uniqueContextId,omitempty"` // An alternative way to specify the execution context to evaluate in. Compared to contextId that may be reused across processes, this is guaranteed to be system-unique, so it can be used to prevent accidental evaluation of the expression in context different than intended (e.g. as a result of navigation across process boundaries). This is mutually exclusive with contextId.
  302. SerializationOptions *SerializationOptions `json:"serializationOptions,omitempty"` // Specifies the result serialization. If provided, overrides generatePreview and returnByValue.
  303. }
  304. // Evaluate evaluates expression on global object.
  305. //
  306. // See: https://chromedevtools.github.io/devtools-protocol/tot/Runtime#method-evaluate
  307. //
  308. // parameters:
  309. //
  310. // expression - Expression to evaluate.
  311. func Evaluate(expression string) *EvaluateParams {
  312. return &EvaluateParams{
  313. Expression: expression,
  314. }
  315. }
  316. // WithObjectGroup symbolic group name that can be used to release multiple
  317. // objects.
  318. func (p EvaluateParams) WithObjectGroup(objectGroup string) *EvaluateParams {
  319. p.ObjectGroup = objectGroup
  320. return &p
  321. }
  322. // WithIncludeCommandLineAPI determines whether Command Line API should be
  323. // available during the evaluation.
  324. func (p EvaluateParams) WithIncludeCommandLineAPI(includeCommandLineAPI bool) *EvaluateParams {
  325. p.IncludeCommandLineAPI = includeCommandLineAPI
  326. return &p
  327. }
  328. // WithSilent in silent mode exceptions thrown during evaluation are not
  329. // reported and do not pause execution. Overrides setPauseOnException state.
  330. func (p EvaluateParams) WithSilent(silent bool) *EvaluateParams {
  331. p.Silent = silent
  332. return &p
  333. }
  334. // WithContextID specifies in which execution context to perform evaluation.
  335. // If the parameter is omitted the evaluation will be performed in the context
  336. // of the inspected page. This is mutually exclusive with uniqueContextId, which
  337. // offers an alternative way to identify the execution context that is more
  338. // reliable in a multi-process environment.
  339. func (p EvaluateParams) WithContextID(contextID ExecutionContextID) *EvaluateParams {
  340. p.ContextID = contextID
  341. return &p
  342. }
  343. // WithReturnByValue whether the result is expected to be a JSON object that
  344. // should be sent by value.
  345. func (p EvaluateParams) WithReturnByValue(returnByValue bool) *EvaluateParams {
  346. p.ReturnByValue = returnByValue
  347. return &p
  348. }
  349. // WithGeneratePreview whether preview should be generated for the result.
  350. func (p EvaluateParams) WithGeneratePreview(generatePreview bool) *EvaluateParams {
  351. p.GeneratePreview = generatePreview
  352. return &p
  353. }
  354. // WithUserGesture whether execution should be treated as initiated by user
  355. // in the UI.
  356. func (p EvaluateParams) WithUserGesture(userGesture bool) *EvaluateParams {
  357. p.UserGesture = userGesture
  358. return &p
  359. }
  360. // WithAwaitPromise whether execution should await for resulting value and
  361. // return once awaited promise is resolved.
  362. func (p EvaluateParams) WithAwaitPromise(awaitPromise bool) *EvaluateParams {
  363. p.AwaitPromise = awaitPromise
  364. return &p
  365. }
  366. // WithThrowOnSideEffect whether to throw an exception if side effect cannot
  367. // be ruled out during evaluation. This implies disableBreaks below.
  368. func (p EvaluateParams) WithThrowOnSideEffect(throwOnSideEffect bool) *EvaluateParams {
  369. p.ThrowOnSideEffect = throwOnSideEffect
  370. return &p
  371. }
  372. // WithTimeout terminate execution after timing out (number of milliseconds).
  373. func (p EvaluateParams) WithTimeout(timeout TimeDelta) *EvaluateParams {
  374. p.Timeout = timeout
  375. return &p
  376. }
  377. // WithDisableBreaks disable breakpoints during execution.
  378. func (p EvaluateParams) WithDisableBreaks(disableBreaks bool) *EvaluateParams {
  379. p.DisableBreaks = disableBreaks
  380. return &p
  381. }
  382. // WithReplMode setting this flag to true enables let re-declaration and
  383. // top-level await. Note that let variables can only be re-declared if they
  384. // originate from replMode themselves.
  385. func (p EvaluateParams) WithReplMode(replMode bool) *EvaluateParams {
  386. p.ReplMode = replMode
  387. return &p
  388. }
  389. // WithAllowUnsafeEvalBlockedByCSP the Content Security Policy (CSP) for the
  390. // target might block 'unsafe-eval' which includes eval(), Function(),
  391. // setTimeout() and setInterval() when called with non-callable arguments. This
  392. // flag bypasses CSP for this evaluation and allows unsafe-eval. Defaults to
  393. // true.
  394. func (p EvaluateParams) WithAllowUnsafeEvalBlockedByCSP(allowUnsafeEvalBlockedByCSP bool) *EvaluateParams {
  395. p.AllowUnsafeEvalBlockedByCSP = allowUnsafeEvalBlockedByCSP
  396. return &p
  397. }
  398. // WithUniqueContextID an alternative way to specify the execution context to
  399. // evaluate in. Compared to contextId that may be reused across processes, this
  400. // is guaranteed to be system-unique, so it can be used to prevent accidental
  401. // evaluation of the expression in context different than intended (e.g. as a
  402. // result of navigation across process boundaries). This is mutually exclusive
  403. // with contextId.
  404. func (p EvaluateParams) WithUniqueContextID(uniqueContextID string) *EvaluateParams {
  405. p.UniqueContextID = uniqueContextID
  406. return &p
  407. }
  408. // WithSerializationOptions specifies the result serialization. If provided,
  409. // overrides generatePreview and returnByValue.
  410. func (p EvaluateParams) WithSerializationOptions(serializationOptions *SerializationOptions) *EvaluateParams {
  411. p.SerializationOptions = serializationOptions
  412. return &p
  413. }
  414. // EvaluateReturns return values.
  415. type EvaluateReturns struct {
  416. Result *RemoteObject `json:"result,omitempty"` // Evaluation result.
  417. ExceptionDetails *ExceptionDetails `json:"exceptionDetails,omitempty"` // Exception details.
  418. }
  419. // Do executes Runtime.evaluate against the provided context.
  420. //
  421. // returns:
  422. //
  423. // result - Evaluation result.
  424. // exceptionDetails - Exception details.
  425. func (p *EvaluateParams) Do(ctx context.Context) (result *RemoteObject, exceptionDetails *ExceptionDetails, err error) {
  426. // execute
  427. var res EvaluateReturns
  428. err = cdp.Execute(ctx, CommandEvaluate, p, &res)
  429. if err != nil {
  430. return nil, nil, err
  431. }
  432. return res.Result, res.ExceptionDetails, nil
  433. }
  434. // GetIsolateIDParams returns the isolate id.
  435. type GetIsolateIDParams struct{}
  436. // GetIsolateID returns the isolate id.
  437. //
  438. // See: https://chromedevtools.github.io/devtools-protocol/tot/Runtime#method-getIsolateId
  439. func GetIsolateID() *GetIsolateIDParams {
  440. return &GetIsolateIDParams{}
  441. }
  442. // GetIsolateIDReturns return values.
  443. type GetIsolateIDReturns struct {
  444. ID string `json:"id,omitempty"` // The isolate id.
  445. }
  446. // Do executes Runtime.getIsolateId against the provided context.
  447. //
  448. // returns:
  449. //
  450. // id - The isolate id.
  451. func (p *GetIsolateIDParams) Do(ctx context.Context) (id string, err error) {
  452. // execute
  453. var res GetIsolateIDReturns
  454. err = cdp.Execute(ctx, CommandGetIsolateID, nil, &res)
  455. if err != nil {
  456. return "", err
  457. }
  458. return res.ID, nil
  459. }
  460. // GetHeapUsageParams returns the JavaScript heap usage. It is the total
  461. // usage of the corresponding isolate not scoped to a particular Runtime.
  462. type GetHeapUsageParams struct{}
  463. // GetHeapUsage returns the JavaScript heap usage. It is the total usage of
  464. // the corresponding isolate not scoped to a particular Runtime.
  465. //
  466. // See: https://chromedevtools.github.io/devtools-protocol/tot/Runtime#method-getHeapUsage
  467. func GetHeapUsage() *GetHeapUsageParams {
  468. return &GetHeapUsageParams{}
  469. }
  470. // GetHeapUsageReturns return values.
  471. type GetHeapUsageReturns struct {
  472. UsedSize float64 `json:"usedSize,omitempty"` // Used heap size in bytes.
  473. TotalSize float64 `json:"totalSize,omitempty"` // Allocated heap size in bytes.
  474. }
  475. // Do executes Runtime.getHeapUsage against the provided context.
  476. //
  477. // returns:
  478. //
  479. // usedSize - Used heap size in bytes.
  480. // totalSize - Allocated heap size in bytes.
  481. func (p *GetHeapUsageParams) Do(ctx context.Context) (usedSize float64, totalSize float64, err error) {
  482. // execute
  483. var res GetHeapUsageReturns
  484. err = cdp.Execute(ctx, CommandGetHeapUsage, nil, &res)
  485. if err != nil {
  486. return 0, 0, err
  487. }
  488. return res.UsedSize, res.TotalSize, nil
  489. }
  490. // GetPropertiesParams returns properties of a given object. Object group of
  491. // the result is inherited from the target object.
  492. type GetPropertiesParams struct {
  493. ObjectID RemoteObjectID `json:"objectId"` // Identifier of the object to return properties for.
  494. OwnProperties bool `json:"ownProperties,omitempty"` // If true, returns properties belonging only to the element itself, not to its prototype chain.
  495. AccessorPropertiesOnly bool `json:"accessorPropertiesOnly,omitempty"` // If true, returns accessor properties (with getter/setter) only; internal properties are not returned either.
  496. GeneratePreview bool `json:"generatePreview,omitempty"` // Whether preview should be generated for the results.
  497. NonIndexedPropertiesOnly bool `json:"nonIndexedPropertiesOnly,omitempty"` // If true, returns non-indexed properties only.
  498. }
  499. // GetProperties returns properties of a given object. Object group of the
  500. // result is inherited from the target object.
  501. //
  502. // See: https://chromedevtools.github.io/devtools-protocol/tot/Runtime#method-getProperties
  503. //
  504. // parameters:
  505. //
  506. // objectID - Identifier of the object to return properties for.
  507. func GetProperties(objectID RemoteObjectID) *GetPropertiesParams {
  508. return &GetPropertiesParams{
  509. ObjectID: objectID,
  510. }
  511. }
  512. // WithOwnProperties if true, returns properties belonging only to the
  513. // element itself, not to its prototype chain.
  514. func (p GetPropertiesParams) WithOwnProperties(ownProperties bool) *GetPropertiesParams {
  515. p.OwnProperties = ownProperties
  516. return &p
  517. }
  518. // WithAccessorPropertiesOnly if true, returns accessor properties (with
  519. // getter/setter) only; internal properties are not returned either.
  520. func (p GetPropertiesParams) WithAccessorPropertiesOnly(accessorPropertiesOnly bool) *GetPropertiesParams {
  521. p.AccessorPropertiesOnly = accessorPropertiesOnly
  522. return &p
  523. }
  524. // WithGeneratePreview whether preview should be generated for the results.
  525. func (p GetPropertiesParams) WithGeneratePreview(generatePreview bool) *GetPropertiesParams {
  526. p.GeneratePreview = generatePreview
  527. return &p
  528. }
  529. // WithNonIndexedPropertiesOnly if true, returns non-indexed properties only.
  530. func (p GetPropertiesParams) WithNonIndexedPropertiesOnly(nonIndexedPropertiesOnly bool) *GetPropertiesParams {
  531. p.NonIndexedPropertiesOnly = nonIndexedPropertiesOnly
  532. return &p
  533. }
  534. // GetPropertiesReturns return values.
  535. type GetPropertiesReturns struct {
  536. Result []*PropertyDescriptor `json:"result,omitempty"` // Object properties.
  537. InternalProperties []*InternalPropertyDescriptor `json:"internalProperties,omitempty"` // Internal object properties (only of the element itself).
  538. PrivateProperties []*PrivatePropertyDescriptor `json:"privateProperties,omitempty"` // Object private properties.
  539. ExceptionDetails *ExceptionDetails `json:"exceptionDetails,omitempty"` // Exception details.
  540. }
  541. // Do executes Runtime.getProperties against the provided context.
  542. //
  543. // returns:
  544. //
  545. // result - Object properties.
  546. // internalProperties - Internal object properties (only of the element itself).
  547. // privateProperties - Object private properties.
  548. // exceptionDetails - Exception details.
  549. func (p *GetPropertiesParams) Do(ctx context.Context) (result []*PropertyDescriptor, internalProperties []*InternalPropertyDescriptor, privateProperties []*PrivatePropertyDescriptor, exceptionDetails *ExceptionDetails, err error) {
  550. // execute
  551. var res GetPropertiesReturns
  552. err = cdp.Execute(ctx, CommandGetProperties, p, &res)
  553. if err != nil {
  554. return nil, nil, nil, nil, err
  555. }
  556. return res.Result, res.InternalProperties, res.PrivateProperties, res.ExceptionDetails, nil
  557. }
  558. // GlobalLexicalScopeNamesParams returns all let, const and class variables
  559. // from global scope.
  560. type GlobalLexicalScopeNamesParams struct {
  561. ExecutionContextID ExecutionContextID `json:"executionContextId,omitempty"` // Specifies in which execution context to lookup global scope variables.
  562. }
  563. // GlobalLexicalScopeNames returns all let, const and class variables from
  564. // global scope.
  565. //
  566. // See: https://chromedevtools.github.io/devtools-protocol/tot/Runtime#method-globalLexicalScopeNames
  567. //
  568. // parameters:
  569. func GlobalLexicalScopeNames() *GlobalLexicalScopeNamesParams {
  570. return &GlobalLexicalScopeNamesParams{}
  571. }
  572. // WithExecutionContextID specifies in which execution context to lookup
  573. // global scope variables.
  574. func (p GlobalLexicalScopeNamesParams) WithExecutionContextID(executionContextID ExecutionContextID) *GlobalLexicalScopeNamesParams {
  575. p.ExecutionContextID = executionContextID
  576. return &p
  577. }
  578. // GlobalLexicalScopeNamesReturns return values.
  579. type GlobalLexicalScopeNamesReturns struct {
  580. Names []string `json:"names,omitempty"`
  581. }
  582. // Do executes Runtime.globalLexicalScopeNames against the provided context.
  583. //
  584. // returns:
  585. //
  586. // names
  587. func (p *GlobalLexicalScopeNamesParams) Do(ctx context.Context) (names []string, err error) {
  588. // execute
  589. var res GlobalLexicalScopeNamesReturns
  590. err = cdp.Execute(ctx, CommandGlobalLexicalScopeNames, p, &res)
  591. if err != nil {
  592. return nil, err
  593. }
  594. return res.Names, nil
  595. }
  596. // QueryObjectsParams [no description].
  597. type QueryObjectsParams struct {
  598. PrototypeObjectID RemoteObjectID `json:"prototypeObjectId"` // Identifier of the prototype to return objects for.
  599. ObjectGroup string `json:"objectGroup,omitempty"` // Symbolic group name that can be used to release the results.
  600. }
  601. // QueryObjects [no description].
  602. //
  603. // See: https://chromedevtools.github.io/devtools-protocol/tot/Runtime#method-queryObjects
  604. //
  605. // parameters:
  606. //
  607. // prototypeObjectID - Identifier of the prototype to return objects for.
  608. func QueryObjects(prototypeObjectID RemoteObjectID) *QueryObjectsParams {
  609. return &QueryObjectsParams{
  610. PrototypeObjectID: prototypeObjectID,
  611. }
  612. }
  613. // WithObjectGroup symbolic group name that can be used to release the
  614. // results.
  615. func (p QueryObjectsParams) WithObjectGroup(objectGroup string) *QueryObjectsParams {
  616. p.ObjectGroup = objectGroup
  617. return &p
  618. }
  619. // QueryObjectsReturns return values.
  620. type QueryObjectsReturns struct {
  621. Objects *RemoteObject `json:"objects,omitempty"` // Array with objects.
  622. }
  623. // Do executes Runtime.queryObjects against the provided context.
  624. //
  625. // returns:
  626. //
  627. // objects - Array with objects.
  628. func (p *QueryObjectsParams) Do(ctx context.Context) (objects *RemoteObject, err error) {
  629. // execute
  630. var res QueryObjectsReturns
  631. err = cdp.Execute(ctx, CommandQueryObjects, p, &res)
  632. if err != nil {
  633. return nil, err
  634. }
  635. return res.Objects, nil
  636. }
  637. // ReleaseObjectParams releases remote object with given id.
  638. type ReleaseObjectParams struct {
  639. ObjectID RemoteObjectID `json:"objectId"` // Identifier of the object to release.
  640. }
  641. // ReleaseObject releases remote object with given id.
  642. //
  643. // See: https://chromedevtools.github.io/devtools-protocol/tot/Runtime#method-releaseObject
  644. //
  645. // parameters:
  646. //
  647. // objectID - Identifier of the object to release.
  648. func ReleaseObject(objectID RemoteObjectID) *ReleaseObjectParams {
  649. return &ReleaseObjectParams{
  650. ObjectID: objectID,
  651. }
  652. }
  653. // Do executes Runtime.releaseObject against the provided context.
  654. func (p *ReleaseObjectParams) Do(ctx context.Context) (err error) {
  655. return cdp.Execute(ctx, CommandReleaseObject, p, nil)
  656. }
  657. // ReleaseObjectGroupParams releases all remote objects that belong to a
  658. // given group.
  659. type ReleaseObjectGroupParams struct {
  660. ObjectGroup string `json:"objectGroup"` // Symbolic object group name.
  661. }
  662. // ReleaseObjectGroup releases all remote objects that belong to a given
  663. // group.
  664. //
  665. // See: https://chromedevtools.github.io/devtools-protocol/tot/Runtime#method-releaseObjectGroup
  666. //
  667. // parameters:
  668. //
  669. // objectGroup - Symbolic object group name.
  670. func ReleaseObjectGroup(objectGroup string) *ReleaseObjectGroupParams {
  671. return &ReleaseObjectGroupParams{
  672. ObjectGroup: objectGroup,
  673. }
  674. }
  675. // Do executes Runtime.releaseObjectGroup against the provided context.
  676. func (p *ReleaseObjectGroupParams) Do(ctx context.Context) (err error) {
  677. return cdp.Execute(ctx, CommandReleaseObjectGroup, p, nil)
  678. }
  679. // RunIfWaitingForDebuggerParams tells inspected instance to run if it was
  680. // waiting for debugger to attach.
  681. type RunIfWaitingForDebuggerParams struct{}
  682. // RunIfWaitingForDebugger tells inspected instance to run if it was waiting
  683. // for debugger to attach.
  684. //
  685. // See: https://chromedevtools.github.io/devtools-protocol/tot/Runtime#method-runIfWaitingForDebugger
  686. func RunIfWaitingForDebugger() *RunIfWaitingForDebuggerParams {
  687. return &RunIfWaitingForDebuggerParams{}
  688. }
  689. // Do executes Runtime.runIfWaitingForDebugger against the provided context.
  690. func (p *RunIfWaitingForDebuggerParams) Do(ctx context.Context) (err error) {
  691. return cdp.Execute(ctx, CommandRunIfWaitingForDebugger, nil, nil)
  692. }
  693. // RunScriptParams runs script with given id in a given context.
  694. type RunScriptParams struct {
  695. ScriptID ScriptID `json:"scriptId"` // Id of the script to run.
  696. ExecutionContextID ExecutionContextID `json:"executionContextId,omitempty"` // Specifies in which execution context to perform script run. If the parameter is omitted the evaluation will be performed in the context of the inspected page.
  697. ObjectGroup string `json:"objectGroup,omitempty"` // Symbolic group name that can be used to release multiple objects.
  698. Silent bool `json:"silent,omitempty"` // In silent mode exceptions thrown during evaluation are not reported and do not pause execution. Overrides setPauseOnException state.
  699. IncludeCommandLineAPI bool `json:"includeCommandLineAPI,omitempty"` // Determines whether Command Line API should be available during the evaluation.
  700. ReturnByValue bool `json:"returnByValue,omitempty"` // Whether the result is expected to be a JSON object which should be sent by value.
  701. GeneratePreview bool `json:"generatePreview,omitempty"` // Whether preview should be generated for the result.
  702. AwaitPromise bool `json:"awaitPromise,omitempty"` // Whether execution should await for resulting value and return once awaited promise is resolved.
  703. }
  704. // RunScript runs script with given id in a given context.
  705. //
  706. // See: https://chromedevtools.github.io/devtools-protocol/tot/Runtime#method-runScript
  707. //
  708. // parameters:
  709. //
  710. // scriptID - Id of the script to run.
  711. func RunScript(scriptID ScriptID) *RunScriptParams {
  712. return &RunScriptParams{
  713. ScriptID: scriptID,
  714. }
  715. }
  716. // WithExecutionContextID specifies in which execution context to perform
  717. // script run. If the parameter is omitted the evaluation will be performed in
  718. // the context of the inspected page.
  719. func (p RunScriptParams) WithExecutionContextID(executionContextID ExecutionContextID) *RunScriptParams {
  720. p.ExecutionContextID = executionContextID
  721. return &p
  722. }
  723. // WithObjectGroup symbolic group name that can be used to release multiple
  724. // objects.
  725. func (p RunScriptParams) WithObjectGroup(objectGroup string) *RunScriptParams {
  726. p.ObjectGroup = objectGroup
  727. return &p
  728. }
  729. // WithSilent in silent mode exceptions thrown during evaluation are not
  730. // reported and do not pause execution. Overrides setPauseOnException state.
  731. func (p RunScriptParams) WithSilent(silent bool) *RunScriptParams {
  732. p.Silent = silent
  733. return &p
  734. }
  735. // WithIncludeCommandLineAPI determines whether Command Line API should be
  736. // available during the evaluation.
  737. func (p RunScriptParams) WithIncludeCommandLineAPI(includeCommandLineAPI bool) *RunScriptParams {
  738. p.IncludeCommandLineAPI = includeCommandLineAPI
  739. return &p
  740. }
  741. // WithReturnByValue whether the result is expected to be a JSON object which
  742. // should be sent by value.
  743. func (p RunScriptParams) WithReturnByValue(returnByValue bool) *RunScriptParams {
  744. p.ReturnByValue = returnByValue
  745. return &p
  746. }
  747. // WithGeneratePreview whether preview should be generated for the result.
  748. func (p RunScriptParams) WithGeneratePreview(generatePreview bool) *RunScriptParams {
  749. p.GeneratePreview = generatePreview
  750. return &p
  751. }
  752. // WithAwaitPromise whether execution should await for resulting value and
  753. // return once awaited promise is resolved.
  754. func (p RunScriptParams) WithAwaitPromise(awaitPromise bool) *RunScriptParams {
  755. p.AwaitPromise = awaitPromise
  756. return &p
  757. }
  758. // RunScriptReturns return values.
  759. type RunScriptReturns struct {
  760. Result *RemoteObject `json:"result,omitempty"` // Run result.
  761. ExceptionDetails *ExceptionDetails `json:"exceptionDetails,omitempty"` // Exception details.
  762. }
  763. // Do executes Runtime.runScript against the provided context.
  764. //
  765. // returns:
  766. //
  767. // result - Run result.
  768. // exceptionDetails - Exception details.
  769. func (p *RunScriptParams) Do(ctx context.Context) (result *RemoteObject, exceptionDetails *ExceptionDetails, err error) {
  770. // execute
  771. var res RunScriptReturns
  772. err = cdp.Execute(ctx, CommandRunScript, p, &res)
  773. if err != nil {
  774. return nil, nil, err
  775. }
  776. return res.Result, res.ExceptionDetails, nil
  777. }
  778. // SetCustomObjectFormatterEnabledParams [no description].
  779. type SetCustomObjectFormatterEnabledParams struct {
  780. Enabled bool `json:"enabled"`
  781. }
  782. // SetCustomObjectFormatterEnabled [no description].
  783. //
  784. // See: https://chromedevtools.github.io/devtools-protocol/tot/Runtime#method-setCustomObjectFormatterEnabled
  785. //
  786. // parameters:
  787. //
  788. // enabled
  789. func SetCustomObjectFormatterEnabled(enabled bool) *SetCustomObjectFormatterEnabledParams {
  790. return &SetCustomObjectFormatterEnabledParams{
  791. Enabled: enabled,
  792. }
  793. }
  794. // Do executes Runtime.setCustomObjectFormatterEnabled against the provided context.
  795. func (p *SetCustomObjectFormatterEnabledParams) Do(ctx context.Context) (err error) {
  796. return cdp.Execute(ctx, CommandSetCustomObjectFormatterEnabled, p, nil)
  797. }
  798. // SetMaxCallStackSizeToCaptureParams [no description].
  799. type SetMaxCallStackSizeToCaptureParams struct {
  800. Size int64 `json:"size"`
  801. }
  802. // SetMaxCallStackSizeToCapture [no description].
  803. //
  804. // See: https://chromedevtools.github.io/devtools-protocol/tot/Runtime#method-setMaxCallStackSizeToCapture
  805. //
  806. // parameters:
  807. //
  808. // size
  809. func SetMaxCallStackSizeToCapture(size int64) *SetMaxCallStackSizeToCaptureParams {
  810. return &SetMaxCallStackSizeToCaptureParams{
  811. Size: size,
  812. }
  813. }
  814. // Do executes Runtime.setMaxCallStackSizeToCapture against the provided context.
  815. func (p *SetMaxCallStackSizeToCaptureParams) Do(ctx context.Context) (err error) {
  816. return cdp.Execute(ctx, CommandSetMaxCallStackSizeToCapture, p, nil)
  817. }
  818. // TerminateExecutionParams terminate current or next JavaScript execution.
  819. // Will cancel the termination when the outer-most script execution ends.
  820. type TerminateExecutionParams struct{}
  821. // TerminateExecution terminate current or next JavaScript execution. Will
  822. // cancel the termination when the outer-most script execution ends.
  823. //
  824. // See: https://chromedevtools.github.io/devtools-protocol/tot/Runtime#method-terminateExecution
  825. func TerminateExecution() *TerminateExecutionParams {
  826. return &TerminateExecutionParams{}
  827. }
  828. // Do executes Runtime.terminateExecution against the provided context.
  829. func (p *TerminateExecutionParams) Do(ctx context.Context) (err error) {
  830. return cdp.Execute(ctx, CommandTerminateExecution, nil, nil)
  831. }
  832. // AddBindingParams if executionContextId is empty, adds binding with the
  833. // given name on the global objects of all inspected contexts, including those
  834. // created later, bindings survive reloads. Binding function takes exactly one
  835. // argument, this argument should be string, in case of any other input,
  836. // function throws an exception. Each binding function call produces
  837. // Runtime.bindingCalled notification.
  838. type AddBindingParams struct {
  839. Name string `json:"name"`
  840. ExecutionContextName string `json:"executionContextName,omitempty"` // If specified, the binding is exposed to the executionContext with matching name, even for contexts created after the binding is added. See also ExecutionContext.name and worldName parameter to Page.addScriptToEvaluateOnNewDocument. This parameter is mutually exclusive with executionContextId.
  841. }
  842. // AddBinding if executionContextId is empty, adds binding with the given
  843. // name on the global objects of all inspected contexts, including those created
  844. // later, bindings survive reloads. Binding function takes exactly one argument,
  845. // this argument should be string, in case of any other input, function throws
  846. // an exception. Each binding function call produces Runtime.bindingCalled
  847. // notification.
  848. //
  849. // See: https://chromedevtools.github.io/devtools-protocol/tot/Runtime#method-addBinding
  850. //
  851. // parameters:
  852. //
  853. // name
  854. func AddBinding(name string) *AddBindingParams {
  855. return &AddBindingParams{
  856. Name: name,
  857. }
  858. }
  859. // WithExecutionContextName if specified, the binding is exposed to the
  860. // executionContext with matching name, even for contexts created after the
  861. // binding is added. See also ExecutionContext.name and worldName parameter to
  862. // Page.addScriptToEvaluateOnNewDocument. This parameter is mutually exclusive
  863. // with executionContextId.
  864. func (p AddBindingParams) WithExecutionContextName(executionContextName string) *AddBindingParams {
  865. p.ExecutionContextName = executionContextName
  866. return &p
  867. }
  868. // Do executes Runtime.addBinding against the provided context.
  869. func (p *AddBindingParams) Do(ctx context.Context) (err error) {
  870. return cdp.Execute(ctx, CommandAddBinding, p, nil)
  871. }
  872. // RemoveBindingParams this method does not remove binding function from
  873. // global object but unsubscribes current runtime agent from
  874. // Runtime.bindingCalled notifications.
  875. type RemoveBindingParams struct {
  876. Name string `json:"name"`
  877. }
  878. // RemoveBinding this method does not remove binding function from global
  879. // object but unsubscribes current runtime agent from Runtime.bindingCalled
  880. // notifications.
  881. //
  882. // See: https://chromedevtools.github.io/devtools-protocol/tot/Runtime#method-removeBinding
  883. //
  884. // parameters:
  885. //
  886. // name
  887. func RemoveBinding(name string) *RemoveBindingParams {
  888. return &RemoveBindingParams{
  889. Name: name,
  890. }
  891. }
  892. // Do executes Runtime.removeBinding against the provided context.
  893. func (p *RemoveBindingParams) Do(ctx context.Context) (err error) {
  894. return cdp.Execute(ctx, CommandRemoveBinding, p, nil)
  895. }
  896. // GetExceptionDetailsParams this method tries to lookup and populate
  897. // exception details for a JavaScript Error object. Note that the stackTrace
  898. // portion of the resulting exceptionDetails will only be populated if the
  899. // Runtime domain was enabled at the time when the Error was thrown.
  900. type GetExceptionDetailsParams struct {
  901. ErrorObjectID RemoteObjectID `json:"errorObjectId"` // The error object for which to resolve the exception details.
  902. }
  903. // GetExceptionDetails this method tries to lookup and populate exception
  904. // details for a JavaScript Error object. Note that the stackTrace portion of
  905. // the resulting exceptionDetails will only be populated if the Runtime domain
  906. // was enabled at the time when the Error was thrown.
  907. //
  908. // See: https://chromedevtools.github.io/devtools-protocol/tot/Runtime#method-getExceptionDetails
  909. //
  910. // parameters:
  911. //
  912. // errorObjectID - The error object for which to resolve the exception details.
  913. func GetExceptionDetails(errorObjectID RemoteObjectID) *GetExceptionDetailsParams {
  914. return &GetExceptionDetailsParams{
  915. ErrorObjectID: errorObjectID,
  916. }
  917. }
  918. // GetExceptionDetailsReturns return values.
  919. type GetExceptionDetailsReturns struct {
  920. ExceptionDetails *ExceptionDetails `json:"exceptionDetails,omitempty"`
  921. }
  922. // Do executes Runtime.getExceptionDetails against the provided context.
  923. //
  924. // returns:
  925. //
  926. // exceptionDetails
  927. func (p *GetExceptionDetailsParams) Do(ctx context.Context) (exceptionDetails *ExceptionDetails, err error) {
  928. // execute
  929. var res GetExceptionDetailsReturns
  930. err = cdp.Execute(ctx, CommandGetExceptionDetails, p, &res)
  931. if err != nil {
  932. return nil, err
  933. }
  934. return res.ExceptionDetails, nil
  935. }
  936. // Command names.
  937. const (
  938. CommandAwaitPromise = "Runtime.awaitPromise"
  939. CommandCallFunctionOn = "Runtime.callFunctionOn"
  940. CommandCompileScript = "Runtime.compileScript"
  941. CommandDisable = "Runtime.disable"
  942. CommandDiscardConsoleEntries = "Runtime.discardConsoleEntries"
  943. CommandEnable = "Runtime.enable"
  944. CommandEvaluate = "Runtime.evaluate"
  945. CommandGetIsolateID = "Runtime.getIsolateId"
  946. CommandGetHeapUsage = "Runtime.getHeapUsage"
  947. CommandGetProperties = "Runtime.getProperties"
  948. CommandGlobalLexicalScopeNames = "Runtime.globalLexicalScopeNames"
  949. CommandQueryObjects = "Runtime.queryObjects"
  950. CommandReleaseObject = "Runtime.releaseObject"
  951. CommandReleaseObjectGroup = "Runtime.releaseObjectGroup"
  952. CommandRunIfWaitingForDebugger = "Runtime.runIfWaitingForDebugger"
  953. CommandRunScript = "Runtime.runScript"
  954. CommandSetCustomObjectFormatterEnabled = "Runtime.setCustomObjectFormatterEnabled"
  955. CommandSetMaxCallStackSizeToCapture = "Runtime.setMaxCallStackSizeToCapture"
  956. CommandTerminateExecution = "Runtime.terminateExecution"
  957. CommandAddBinding = "Runtime.addBinding"
  958. CommandRemoveBinding = "Runtime.removeBinding"
  959. CommandGetExceptionDetails = "Runtime.getExceptionDetails"
  960. )