File: runtime.go

package info (click to toggle)
golang-github-chromedp-cdproto 0.0~git20230109.6b041c6-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 4,584 kB
  • sloc: makefile: 2
file content (1098 lines) | stat: -rw-r--r-- 47,454 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
// Package runtime provides the Chrome DevTools Protocol
// commands, types, and events for the Runtime domain.
//
// Runtime domain exposes JavaScript runtime by means of remote evaluation
// and mirror objects. Evaluation results are returned as mirror object that
// expose object type, string representation and unique identifier that can be
// used for further object reference. Original objects are maintained in memory
// unless they are either explicitly released or are released along with the
// other objects in their object group.
//
// Generated by the cdproto-gen command.
package runtime

// Code generated by cdproto-gen. DO NOT EDIT.

import (
	"context"

	"github.com/chromedp/cdproto/cdp"
)

// AwaitPromiseParams add handler to promise with given promise object id.
type AwaitPromiseParams struct {
	PromiseObjectID RemoteObjectID `json:"promiseObjectId"`           // Identifier of the promise.
	ReturnByValue   bool           `json:"returnByValue,omitempty"`   // Whether the result is expected to be a JSON object that should be sent by value.
	GeneratePreview bool           `json:"generatePreview,omitempty"` // Whether preview should be generated for the result.
}

// AwaitPromise add handler to promise with given promise object id.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Runtime#method-awaitPromise
//
// parameters:
//
//	promiseObjectID - Identifier of the promise.
func AwaitPromise(promiseObjectID RemoteObjectID) *AwaitPromiseParams {
	return &AwaitPromiseParams{
		PromiseObjectID: promiseObjectID,
	}
}

// WithReturnByValue whether the result is expected to be a JSON object that
// should be sent by value.
func (p AwaitPromiseParams) WithReturnByValue(returnByValue bool) *AwaitPromiseParams {
	p.ReturnByValue = returnByValue
	return &p
}

// WithGeneratePreview whether preview should be generated for the result.
func (p AwaitPromiseParams) WithGeneratePreview(generatePreview bool) *AwaitPromiseParams {
	p.GeneratePreview = generatePreview
	return &p
}

// AwaitPromiseReturns return values.
type AwaitPromiseReturns struct {
	Result           *RemoteObject     `json:"result,omitempty"`           // Promise result. Will contain rejected value if promise was rejected.
	ExceptionDetails *ExceptionDetails `json:"exceptionDetails,omitempty"` // Exception details if stack strace is available.
}

// Do executes Runtime.awaitPromise against the provided context.
//
// returns:
//
//	result - Promise result. Will contain rejected value if promise was rejected.
//	exceptionDetails - Exception details if stack strace is available.
func (p *AwaitPromiseParams) Do(ctx context.Context) (result *RemoteObject, exceptionDetails *ExceptionDetails, err error) {
	// execute
	var res AwaitPromiseReturns
	err = cdp.Execute(ctx, CommandAwaitPromise, p, &res)
	if err != nil {
		return nil, nil, err
	}

	return res.Result, res.ExceptionDetails, nil
}

// CallFunctionOnParams calls function with given declaration on the given
// object. Object group of the result is inherited from the target object.
type CallFunctionOnParams struct {
	FunctionDeclaration    string             `json:"functionDeclaration"`              // Declaration of the function to call.
	ObjectID               RemoteObjectID     `json:"objectId,omitempty"`               // Identifier of the object to call function on. Either objectId or executionContextId should be specified.
	Arguments              []*CallArgument    `json:"arguments,omitempty"`              // Call arguments. All call arguments must belong to the same JavaScript world as the target object.
	Silent                 bool               `json:"silent,omitempty"`                 // In silent mode exceptions thrown during evaluation are not reported and do not pause execution. Overrides setPauseOnException state.
	ReturnByValue          bool               `json:"returnByValue,omitempty"`          // Whether the result is expected to be a JSON object which should be sent by value.
	GeneratePreview        bool               `json:"generatePreview,omitempty"`        // Whether preview should be generated for the result.
	UserGesture            bool               `json:"userGesture,omitempty"`            // Whether execution should be treated as initiated by user in the UI.
	AwaitPromise           bool               `json:"awaitPromise,omitempty"`           // Whether execution should await for resulting value and return once awaited promise is resolved.
	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.
	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.
	ThrowOnSideEffect      bool               `json:"throwOnSideEffect,omitempty"`      // Whether to throw an exception if side effect cannot be ruled out during evaluation.
	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.
	GenerateWebDriverValue bool               `json:"generateWebDriverValue,omitempty"` // Whether the result should contain webDriverValue, serialized according to https://w3c.github.io/webdriver-bidi. This is mutually exclusive with returnByValue, but resulting objectId is still provided.
}

// CallFunctionOn calls function with given declaration on the given object.
// Object group of the result is inherited from the target object.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Runtime#method-callFunctionOn
//
// parameters:
//
//	functionDeclaration - Declaration of the function to call.
func CallFunctionOn(functionDeclaration string) *CallFunctionOnParams {
	return &CallFunctionOnParams{
		FunctionDeclaration: functionDeclaration,
	}
}

// WithObjectID identifier of the object to call function on. Either objectId
// or executionContextId should be specified.
func (p CallFunctionOnParams) WithObjectID(objectID RemoteObjectID) *CallFunctionOnParams {
	p.ObjectID = objectID
	return &p
}

// WithArguments call arguments. All call arguments must belong to the same
// JavaScript world as the target object.
func (p CallFunctionOnParams) WithArguments(arguments []*CallArgument) *CallFunctionOnParams {
	p.Arguments = arguments
	return &p
}

// WithSilent in silent mode exceptions thrown during evaluation are not
// reported and do not pause execution. Overrides setPauseOnException state.
func (p CallFunctionOnParams) WithSilent(silent bool) *CallFunctionOnParams {
	p.Silent = silent
	return &p
}

// WithReturnByValue whether the result is expected to be a JSON object which
// should be sent by value.
func (p CallFunctionOnParams) WithReturnByValue(returnByValue bool) *CallFunctionOnParams {
	p.ReturnByValue = returnByValue
	return &p
}

// WithGeneratePreview whether preview should be generated for the result.
func (p CallFunctionOnParams) WithGeneratePreview(generatePreview bool) *CallFunctionOnParams {
	p.GeneratePreview = generatePreview
	return &p
}

// WithUserGesture whether execution should be treated as initiated by user
// in the UI.
func (p CallFunctionOnParams) WithUserGesture(userGesture bool) *CallFunctionOnParams {
	p.UserGesture = userGesture
	return &p
}

// WithAwaitPromise whether execution should await for resulting value and
// return once awaited promise is resolved.
func (p CallFunctionOnParams) WithAwaitPromise(awaitPromise bool) *CallFunctionOnParams {
	p.AwaitPromise = awaitPromise
	return &p
}

// WithExecutionContextID specifies execution context which global object
// will be used to call function on. Either executionContextId or objectId
// should be specified.
func (p CallFunctionOnParams) WithExecutionContextID(executionContextID ExecutionContextID) *CallFunctionOnParams {
	p.ExecutionContextID = executionContextID
	return &p
}

// WithObjectGroup 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.
func (p CallFunctionOnParams) WithObjectGroup(objectGroup string) *CallFunctionOnParams {
	p.ObjectGroup = objectGroup
	return &p
}

// WithThrowOnSideEffect whether to throw an exception if side effect cannot
// be ruled out during evaluation.
func (p CallFunctionOnParams) WithThrowOnSideEffect(throwOnSideEffect bool) *CallFunctionOnParams {
	p.ThrowOnSideEffect = throwOnSideEffect
	return &p
}

// WithUniqueContextID 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.
func (p CallFunctionOnParams) WithUniqueContextID(uniqueContextID string) *CallFunctionOnParams {
	p.UniqueContextID = uniqueContextID
	return &p
}

// WithGenerateWebDriverValue whether the result should contain
// webDriverValue, serialized according to https://w3c.github.io/webdriver-bidi.
// This is mutually exclusive with returnByValue, but resulting objectId is
// still provided.
func (p CallFunctionOnParams) WithGenerateWebDriverValue(generateWebDriverValue bool) *CallFunctionOnParams {
	p.GenerateWebDriverValue = generateWebDriverValue
	return &p
}

// CallFunctionOnReturns return values.
type CallFunctionOnReturns struct {
	Result           *RemoteObject     `json:"result,omitempty"`           // Call result.
	ExceptionDetails *ExceptionDetails `json:"exceptionDetails,omitempty"` // Exception details.
}

// Do executes Runtime.callFunctionOn against the provided context.
//
// returns:
//
//	result - Call result.
//	exceptionDetails - Exception details.
func (p *CallFunctionOnParams) Do(ctx context.Context) (result *RemoteObject, exceptionDetails *ExceptionDetails, err error) {
	// execute
	var res CallFunctionOnReturns
	err = cdp.Execute(ctx, CommandCallFunctionOn, p, &res)
	if err != nil {
		return nil, nil, err
	}

	return res.Result, res.ExceptionDetails, nil
}

// CompileScriptParams compiles expression.
type CompileScriptParams struct {
	Expression         string             `json:"expression"`                   // Expression to compile.
	SourceURL          string             `json:"sourceURL"`                    // Source url to be set for the script.
	PersistScript      bool               `json:"persistScript"`                // Specifies whether the compiled script should be persisted.
	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.
}

// CompileScript compiles expression.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Runtime#method-compileScript
//
// parameters:
//
//	expression - Expression to compile.
//	sourceURL - Source url to be set for the script.
//	persistScript - Specifies whether the compiled script should be persisted.
func CompileScript(expression string, sourceURL string, persistScript bool) *CompileScriptParams {
	return &CompileScriptParams{
		Expression:    expression,
		SourceURL:     sourceURL,
		PersistScript: persistScript,
	}
}

// WithExecutionContextID 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.
func (p CompileScriptParams) WithExecutionContextID(executionContextID ExecutionContextID) *CompileScriptParams {
	p.ExecutionContextID = executionContextID
	return &p
}

// CompileScriptReturns return values.
type CompileScriptReturns struct {
	ScriptID         ScriptID          `json:"scriptId,omitempty"`         // Id of the script.
	ExceptionDetails *ExceptionDetails `json:"exceptionDetails,omitempty"` // Exception details.
}

// Do executes Runtime.compileScript against the provided context.
//
// returns:
//
//	scriptID - Id of the script.
//	exceptionDetails - Exception details.
func (p *CompileScriptParams) Do(ctx context.Context) (scriptID ScriptID, exceptionDetails *ExceptionDetails, err error) {
	// execute
	var res CompileScriptReturns
	err = cdp.Execute(ctx, CommandCompileScript, p, &res)
	if err != nil {
		return "", nil, err
	}

	return res.ScriptID, res.ExceptionDetails, nil
}

// DisableParams disables reporting of execution contexts creation.
type DisableParams struct{}

// Disable disables reporting of execution contexts creation.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Runtime#method-disable
func Disable() *DisableParams {
	return &DisableParams{}
}

// Do executes Runtime.disable against the provided context.
func (p *DisableParams) Do(ctx context.Context) (err error) {
	return cdp.Execute(ctx, CommandDisable, nil, nil)
}

// DiscardConsoleEntriesParams discards collected exceptions and console API
// calls.
type DiscardConsoleEntriesParams struct{}

// DiscardConsoleEntries discards collected exceptions and console API calls.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Runtime#method-discardConsoleEntries
func DiscardConsoleEntries() *DiscardConsoleEntriesParams {
	return &DiscardConsoleEntriesParams{}
}

// Do executes Runtime.discardConsoleEntries against the provided context.
func (p *DiscardConsoleEntriesParams) Do(ctx context.Context) (err error) {
	return cdp.Execute(ctx, CommandDiscardConsoleEntries, nil, nil)
}

// EnableParams enables reporting of execution contexts creation by means of
// executionContextCreated event. When the reporting gets enabled the event will
// be sent immediately for each existing execution context.
type EnableParams struct{}

// Enable enables reporting of execution contexts creation by means of
// executionContextCreated event. When the reporting gets enabled the event will
// be sent immediately for each existing execution context.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Runtime#method-enable
func Enable() *EnableParams {
	return &EnableParams{}
}

// Do executes Runtime.enable against the provided context.
func (p *EnableParams) Do(ctx context.Context) (err error) {
	return cdp.Execute(ctx, CommandEnable, nil, nil)
}

// EvaluateParams evaluates expression on global object.
type EvaluateParams struct {
	Expression                  string             `json:"expression"`                            // Expression to evaluate.
	ObjectGroup                 string             `json:"objectGroup,omitempty"`                 // Symbolic group name that can be used to release multiple objects.
	IncludeCommandLineAPI       bool               `json:"includeCommandLineAPI,omitempty"`       // Determines whether Command Line API should be available during the evaluation.
	Silent                      bool               `json:"silent,omitempty"`                      // In silent mode exceptions thrown during evaluation are not reported and do not pause execution. Overrides setPauseOnException state.
	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.
	ReturnByValue               bool               `json:"returnByValue,omitempty"`               // Whether the result is expected to be a JSON object that should be sent by value.
	GeneratePreview             bool               `json:"generatePreview,omitempty"`             // Whether preview should be generated for the result.
	UserGesture                 bool               `json:"userGesture,omitempty"`                 // Whether execution should be treated as initiated by user in the UI.
	AwaitPromise                bool               `json:"awaitPromise,omitempty"`                // Whether execution should await for resulting value and return once awaited promise is resolved.
	ThrowOnSideEffect           bool               `json:"throwOnSideEffect,omitempty"`           // Whether to throw an exception if side effect cannot be ruled out during evaluation. This implies disableBreaks below.
	Timeout                     TimeDelta          `json:"timeout,omitempty"`                     // Terminate execution after timing out (number of milliseconds).
	DisableBreaks               bool               `json:"disableBreaks,omitempty"`               // Disable breakpoints during execution.
	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.
	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.
	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.
	GenerateWebDriverValue      bool               `json:"generateWebDriverValue,omitempty"`      // Whether the result should be serialized according to https://w3c.github.io/webdriver-bidi.
}

// Evaluate evaluates expression on global object.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Runtime#method-evaluate
//
// parameters:
//
//	expression - Expression to evaluate.
func Evaluate(expression string) *EvaluateParams {
	return &EvaluateParams{
		Expression: expression,
	}
}

// WithObjectGroup symbolic group name that can be used to release multiple
// objects.
func (p EvaluateParams) WithObjectGroup(objectGroup string) *EvaluateParams {
	p.ObjectGroup = objectGroup
	return &p
}

// WithIncludeCommandLineAPI determines whether Command Line API should be
// available during the evaluation.
func (p EvaluateParams) WithIncludeCommandLineAPI(includeCommandLineAPI bool) *EvaluateParams {
	p.IncludeCommandLineAPI = includeCommandLineAPI
	return &p
}

// WithSilent in silent mode exceptions thrown during evaluation are not
// reported and do not pause execution. Overrides setPauseOnException state.
func (p EvaluateParams) WithSilent(silent bool) *EvaluateParams {
	p.Silent = silent
	return &p
}

// WithContextID 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.
func (p EvaluateParams) WithContextID(contextID ExecutionContextID) *EvaluateParams {
	p.ContextID = contextID
	return &p
}

// WithReturnByValue whether the result is expected to be a JSON object that
// should be sent by value.
func (p EvaluateParams) WithReturnByValue(returnByValue bool) *EvaluateParams {
	p.ReturnByValue = returnByValue
	return &p
}

// WithGeneratePreview whether preview should be generated for the result.
func (p EvaluateParams) WithGeneratePreview(generatePreview bool) *EvaluateParams {
	p.GeneratePreview = generatePreview
	return &p
}

// WithUserGesture whether execution should be treated as initiated by user
// in the UI.
func (p EvaluateParams) WithUserGesture(userGesture bool) *EvaluateParams {
	p.UserGesture = userGesture
	return &p
}

// WithAwaitPromise whether execution should await for resulting value and
// return once awaited promise is resolved.
func (p EvaluateParams) WithAwaitPromise(awaitPromise bool) *EvaluateParams {
	p.AwaitPromise = awaitPromise
	return &p
}

// WithThrowOnSideEffect whether to throw an exception if side effect cannot
// be ruled out during evaluation. This implies disableBreaks below.
func (p EvaluateParams) WithThrowOnSideEffect(throwOnSideEffect bool) *EvaluateParams {
	p.ThrowOnSideEffect = throwOnSideEffect
	return &p
}

// WithTimeout terminate execution after timing out (number of milliseconds).
func (p EvaluateParams) WithTimeout(timeout TimeDelta) *EvaluateParams {
	p.Timeout = timeout
	return &p
}

// WithDisableBreaks disable breakpoints during execution.
func (p EvaluateParams) WithDisableBreaks(disableBreaks bool) *EvaluateParams {
	p.DisableBreaks = disableBreaks
	return &p
}

// WithReplMode 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.
func (p EvaluateParams) WithReplMode(replMode bool) *EvaluateParams {
	p.ReplMode = replMode
	return &p
}

// WithAllowUnsafeEvalBlockedByCSP 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.
func (p EvaluateParams) WithAllowUnsafeEvalBlockedByCSP(allowUnsafeEvalBlockedByCSP bool) *EvaluateParams {
	p.AllowUnsafeEvalBlockedByCSP = allowUnsafeEvalBlockedByCSP
	return &p
}

// WithUniqueContextID 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.
func (p EvaluateParams) WithUniqueContextID(uniqueContextID string) *EvaluateParams {
	p.UniqueContextID = uniqueContextID
	return &p
}

// WithGenerateWebDriverValue whether the result should be serialized
// according to https://w3c.github.io/webdriver-bidi.
func (p EvaluateParams) WithGenerateWebDriverValue(generateWebDriverValue bool) *EvaluateParams {
	p.GenerateWebDriverValue = generateWebDriverValue
	return &p
}

// EvaluateReturns return values.
type EvaluateReturns struct {
	Result           *RemoteObject     `json:"result,omitempty"`           // Evaluation result.
	ExceptionDetails *ExceptionDetails `json:"exceptionDetails,omitempty"` // Exception details.
}

// Do executes Runtime.evaluate against the provided context.
//
// returns:
//
//	result - Evaluation result.
//	exceptionDetails - Exception details.
func (p *EvaluateParams) Do(ctx context.Context) (result *RemoteObject, exceptionDetails *ExceptionDetails, err error) {
	// execute
	var res EvaluateReturns
	err = cdp.Execute(ctx, CommandEvaluate, p, &res)
	if err != nil {
		return nil, nil, err
	}

	return res.Result, res.ExceptionDetails, nil
}

// GetIsolateIDParams returns the isolate id.
type GetIsolateIDParams struct{}

// GetIsolateID returns the isolate id.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Runtime#method-getIsolateId
func GetIsolateID() *GetIsolateIDParams {
	return &GetIsolateIDParams{}
}

// GetIsolateIDReturns return values.
type GetIsolateIDReturns struct {
	ID string `json:"id,omitempty"` // The isolate id.
}

// Do executes Runtime.getIsolateId against the provided context.
//
// returns:
//
//	id - The isolate id.
func (p *GetIsolateIDParams) Do(ctx context.Context) (id string, err error) {
	// execute
	var res GetIsolateIDReturns
	err = cdp.Execute(ctx, CommandGetIsolateID, nil, &res)
	if err != nil {
		return "", err
	}

	return res.ID, nil
}

// GetHeapUsageParams returns the JavaScript heap usage. It is the total
// usage of the corresponding isolate not scoped to a particular Runtime.
type GetHeapUsageParams struct{}

// GetHeapUsage returns the JavaScript heap usage. It is the total usage of
// the corresponding isolate not scoped to a particular Runtime.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Runtime#method-getHeapUsage
func GetHeapUsage() *GetHeapUsageParams {
	return &GetHeapUsageParams{}
}

// GetHeapUsageReturns return values.
type GetHeapUsageReturns struct {
	UsedSize  float64 `json:"usedSize,omitempty"`  // Used heap size in bytes.
	TotalSize float64 `json:"totalSize,omitempty"` // Allocated heap size in bytes.
}

// Do executes Runtime.getHeapUsage against the provided context.
//
// returns:
//
//	usedSize - Used heap size in bytes.
//	totalSize - Allocated heap size in bytes.
func (p *GetHeapUsageParams) Do(ctx context.Context) (usedSize float64, totalSize float64, err error) {
	// execute
	var res GetHeapUsageReturns
	err = cdp.Execute(ctx, CommandGetHeapUsage, nil, &res)
	if err != nil {
		return 0, 0, err
	}

	return res.UsedSize, res.TotalSize, nil
}

// GetPropertiesParams returns properties of a given object. Object group of
// the result is inherited from the target object.
type GetPropertiesParams struct {
	ObjectID                 RemoteObjectID `json:"objectId"`                           // Identifier of the object to return properties for.
	OwnProperties            bool           `json:"ownProperties,omitempty"`            // If true, returns properties belonging only to the element itself, not to its prototype chain.
	AccessorPropertiesOnly   bool           `json:"accessorPropertiesOnly,omitempty"`   // If true, returns accessor properties (with getter/setter) only; internal properties are not returned either.
	GeneratePreview          bool           `json:"generatePreview,omitempty"`          // Whether preview should be generated for the results.
	NonIndexedPropertiesOnly bool           `json:"nonIndexedPropertiesOnly,omitempty"` // If true, returns non-indexed properties only.
}

// GetProperties returns properties of a given object. Object group of the
// result is inherited from the target object.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Runtime#method-getProperties
//
// parameters:
//
//	objectID - Identifier of the object to return properties for.
func GetProperties(objectID RemoteObjectID) *GetPropertiesParams {
	return &GetPropertiesParams{
		ObjectID: objectID,
	}
}

// WithOwnProperties if true, returns properties belonging only to the
// element itself, not to its prototype chain.
func (p GetPropertiesParams) WithOwnProperties(ownProperties bool) *GetPropertiesParams {
	p.OwnProperties = ownProperties
	return &p
}

// WithAccessorPropertiesOnly if true, returns accessor properties (with
// getter/setter) only; internal properties are not returned either.
func (p GetPropertiesParams) WithAccessorPropertiesOnly(accessorPropertiesOnly bool) *GetPropertiesParams {
	p.AccessorPropertiesOnly = accessorPropertiesOnly
	return &p
}

// WithGeneratePreview whether preview should be generated for the results.
func (p GetPropertiesParams) WithGeneratePreview(generatePreview bool) *GetPropertiesParams {
	p.GeneratePreview = generatePreview
	return &p
}

// WithNonIndexedPropertiesOnly if true, returns non-indexed properties only.
func (p GetPropertiesParams) WithNonIndexedPropertiesOnly(nonIndexedPropertiesOnly bool) *GetPropertiesParams {
	p.NonIndexedPropertiesOnly = nonIndexedPropertiesOnly
	return &p
}

// GetPropertiesReturns return values.
type GetPropertiesReturns struct {
	Result             []*PropertyDescriptor         `json:"result,omitempty"`             // Object properties.
	InternalProperties []*InternalPropertyDescriptor `json:"internalProperties,omitempty"` // Internal object properties (only of the element itself).
	PrivateProperties  []*PrivatePropertyDescriptor  `json:"privateProperties,omitempty"`  // Object private properties.
	ExceptionDetails   *ExceptionDetails             `json:"exceptionDetails,omitempty"`   // Exception details.
}

// Do executes Runtime.getProperties against the provided context.
//
// returns:
//
//	result - Object properties.
//	internalProperties - Internal object properties (only of the element itself).
//	privateProperties - Object private properties.
//	exceptionDetails - Exception details.
func (p *GetPropertiesParams) Do(ctx context.Context) (result []*PropertyDescriptor, internalProperties []*InternalPropertyDescriptor, privateProperties []*PrivatePropertyDescriptor, exceptionDetails *ExceptionDetails, err error) {
	// execute
	var res GetPropertiesReturns
	err = cdp.Execute(ctx, CommandGetProperties, p, &res)
	if err != nil {
		return nil, nil, nil, nil, err
	}

	return res.Result, res.InternalProperties, res.PrivateProperties, res.ExceptionDetails, nil
}

// GlobalLexicalScopeNamesParams returns all let, const and class variables
// from global scope.
type GlobalLexicalScopeNamesParams struct {
	ExecutionContextID ExecutionContextID `json:"executionContextId,omitempty"` // Specifies in which execution context to lookup global scope variables.
}

// GlobalLexicalScopeNames returns all let, const and class variables from
// global scope.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Runtime#method-globalLexicalScopeNames
//
// parameters:
func GlobalLexicalScopeNames() *GlobalLexicalScopeNamesParams {
	return &GlobalLexicalScopeNamesParams{}
}

// WithExecutionContextID specifies in which execution context to lookup
// global scope variables.
func (p GlobalLexicalScopeNamesParams) WithExecutionContextID(executionContextID ExecutionContextID) *GlobalLexicalScopeNamesParams {
	p.ExecutionContextID = executionContextID
	return &p
}

// GlobalLexicalScopeNamesReturns return values.
type GlobalLexicalScopeNamesReturns struct {
	Names []string `json:"names,omitempty"`
}

// Do executes Runtime.globalLexicalScopeNames against the provided context.
//
// returns:
//
//	names
func (p *GlobalLexicalScopeNamesParams) Do(ctx context.Context) (names []string, err error) {
	// execute
	var res GlobalLexicalScopeNamesReturns
	err = cdp.Execute(ctx, CommandGlobalLexicalScopeNames, p, &res)
	if err != nil {
		return nil, err
	}

	return res.Names, nil
}

// QueryObjectsParams [no description].
type QueryObjectsParams struct {
	PrototypeObjectID RemoteObjectID `json:"prototypeObjectId"`     // Identifier of the prototype to return objects for.
	ObjectGroup       string         `json:"objectGroup,omitempty"` // Symbolic group name that can be used to release the results.
}

// QueryObjects [no description].
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Runtime#method-queryObjects
//
// parameters:
//
//	prototypeObjectID - Identifier of the prototype to return objects for.
func QueryObjects(prototypeObjectID RemoteObjectID) *QueryObjectsParams {
	return &QueryObjectsParams{
		PrototypeObjectID: prototypeObjectID,
	}
}

// WithObjectGroup symbolic group name that can be used to release the
// results.
func (p QueryObjectsParams) WithObjectGroup(objectGroup string) *QueryObjectsParams {
	p.ObjectGroup = objectGroup
	return &p
}

// QueryObjectsReturns return values.
type QueryObjectsReturns struct {
	Objects *RemoteObject `json:"objects,omitempty"` // Array with objects.
}

// Do executes Runtime.queryObjects against the provided context.
//
// returns:
//
//	objects - Array with objects.
func (p *QueryObjectsParams) Do(ctx context.Context) (objects *RemoteObject, err error) {
	// execute
	var res QueryObjectsReturns
	err = cdp.Execute(ctx, CommandQueryObjects, p, &res)
	if err != nil {
		return nil, err
	}

	return res.Objects, nil
}

// ReleaseObjectParams releases remote object with given id.
type ReleaseObjectParams struct {
	ObjectID RemoteObjectID `json:"objectId"` // Identifier of the object to release.
}

// ReleaseObject releases remote object with given id.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Runtime#method-releaseObject
//
// parameters:
//
//	objectID - Identifier of the object to release.
func ReleaseObject(objectID RemoteObjectID) *ReleaseObjectParams {
	return &ReleaseObjectParams{
		ObjectID: objectID,
	}
}

// Do executes Runtime.releaseObject against the provided context.
func (p *ReleaseObjectParams) Do(ctx context.Context) (err error) {
	return cdp.Execute(ctx, CommandReleaseObject, p, nil)
}

// ReleaseObjectGroupParams releases all remote objects that belong to a
// given group.
type ReleaseObjectGroupParams struct {
	ObjectGroup string `json:"objectGroup"` // Symbolic object group name.
}

// ReleaseObjectGroup releases all remote objects that belong to a given
// group.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Runtime#method-releaseObjectGroup
//
// parameters:
//
//	objectGroup - Symbolic object group name.
func ReleaseObjectGroup(objectGroup string) *ReleaseObjectGroupParams {
	return &ReleaseObjectGroupParams{
		ObjectGroup: objectGroup,
	}
}

// Do executes Runtime.releaseObjectGroup against the provided context.
func (p *ReleaseObjectGroupParams) Do(ctx context.Context) (err error) {
	return cdp.Execute(ctx, CommandReleaseObjectGroup, p, nil)
}

// RunIfWaitingForDebuggerParams tells inspected instance to run if it was
// waiting for debugger to attach.
type RunIfWaitingForDebuggerParams struct{}

// RunIfWaitingForDebugger tells inspected instance to run if it was waiting
// for debugger to attach.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Runtime#method-runIfWaitingForDebugger
func RunIfWaitingForDebugger() *RunIfWaitingForDebuggerParams {
	return &RunIfWaitingForDebuggerParams{}
}

// Do executes Runtime.runIfWaitingForDebugger against the provided context.
func (p *RunIfWaitingForDebuggerParams) Do(ctx context.Context) (err error) {
	return cdp.Execute(ctx, CommandRunIfWaitingForDebugger, nil, nil)
}

// RunScriptParams runs script with given id in a given context.
type RunScriptParams struct {
	ScriptID              ScriptID           `json:"scriptId"`                        // Id of the script to run.
	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.
	ObjectGroup           string             `json:"objectGroup,omitempty"`           // Symbolic group name that can be used to release multiple objects.
	Silent                bool               `json:"silent,omitempty"`                // In silent mode exceptions thrown during evaluation are not reported and do not pause execution. Overrides setPauseOnException state.
	IncludeCommandLineAPI bool               `json:"includeCommandLineAPI,omitempty"` // Determines whether Command Line API should be available during the evaluation.
	ReturnByValue         bool               `json:"returnByValue,omitempty"`         // Whether the result is expected to be a JSON object which should be sent by value.
	GeneratePreview       bool               `json:"generatePreview,omitempty"`       // Whether preview should be generated for the result.
	AwaitPromise          bool               `json:"awaitPromise,omitempty"`          // Whether execution should await for resulting value and return once awaited promise is resolved.
}

// RunScript runs script with given id in a given context.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Runtime#method-runScript
//
// parameters:
//
//	scriptID - Id of the script to run.
func RunScript(scriptID ScriptID) *RunScriptParams {
	return &RunScriptParams{
		ScriptID: scriptID,
	}
}

// WithExecutionContextID 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.
func (p RunScriptParams) WithExecutionContextID(executionContextID ExecutionContextID) *RunScriptParams {
	p.ExecutionContextID = executionContextID
	return &p
}

// WithObjectGroup symbolic group name that can be used to release multiple
// objects.
func (p RunScriptParams) WithObjectGroup(objectGroup string) *RunScriptParams {
	p.ObjectGroup = objectGroup
	return &p
}

// WithSilent in silent mode exceptions thrown during evaluation are not
// reported and do not pause execution. Overrides setPauseOnException state.
func (p RunScriptParams) WithSilent(silent bool) *RunScriptParams {
	p.Silent = silent
	return &p
}

// WithIncludeCommandLineAPI determines whether Command Line API should be
// available during the evaluation.
func (p RunScriptParams) WithIncludeCommandLineAPI(includeCommandLineAPI bool) *RunScriptParams {
	p.IncludeCommandLineAPI = includeCommandLineAPI
	return &p
}

// WithReturnByValue whether the result is expected to be a JSON object which
// should be sent by value.
func (p RunScriptParams) WithReturnByValue(returnByValue bool) *RunScriptParams {
	p.ReturnByValue = returnByValue
	return &p
}

// WithGeneratePreview whether preview should be generated for the result.
func (p RunScriptParams) WithGeneratePreview(generatePreview bool) *RunScriptParams {
	p.GeneratePreview = generatePreview
	return &p
}

// WithAwaitPromise whether execution should await for resulting value and
// return once awaited promise is resolved.
func (p RunScriptParams) WithAwaitPromise(awaitPromise bool) *RunScriptParams {
	p.AwaitPromise = awaitPromise
	return &p
}

// RunScriptReturns return values.
type RunScriptReturns struct {
	Result           *RemoteObject     `json:"result,omitempty"`           // Run result.
	ExceptionDetails *ExceptionDetails `json:"exceptionDetails,omitempty"` // Exception details.
}

// Do executes Runtime.runScript against the provided context.
//
// returns:
//
//	result - Run result.
//	exceptionDetails - Exception details.
func (p *RunScriptParams) Do(ctx context.Context) (result *RemoteObject, exceptionDetails *ExceptionDetails, err error) {
	// execute
	var res RunScriptReturns
	err = cdp.Execute(ctx, CommandRunScript, p, &res)
	if err != nil {
		return nil, nil, err
	}

	return res.Result, res.ExceptionDetails, nil
}

// SetCustomObjectFormatterEnabledParams [no description].
type SetCustomObjectFormatterEnabledParams struct {
	Enabled bool `json:"enabled"`
}

// SetCustomObjectFormatterEnabled [no description].
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Runtime#method-setCustomObjectFormatterEnabled
//
// parameters:
//
//	enabled
func SetCustomObjectFormatterEnabled(enabled bool) *SetCustomObjectFormatterEnabledParams {
	return &SetCustomObjectFormatterEnabledParams{
		Enabled: enabled,
	}
}

// Do executes Runtime.setCustomObjectFormatterEnabled against the provided context.
func (p *SetCustomObjectFormatterEnabledParams) Do(ctx context.Context) (err error) {
	return cdp.Execute(ctx, CommandSetCustomObjectFormatterEnabled, p, nil)
}

// SetMaxCallStackSizeToCaptureParams [no description].
type SetMaxCallStackSizeToCaptureParams struct {
	Size int64 `json:"size"`
}

// SetMaxCallStackSizeToCapture [no description].
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Runtime#method-setMaxCallStackSizeToCapture
//
// parameters:
//
//	size
func SetMaxCallStackSizeToCapture(size int64) *SetMaxCallStackSizeToCaptureParams {
	return &SetMaxCallStackSizeToCaptureParams{
		Size: size,
	}
}

// Do executes Runtime.setMaxCallStackSizeToCapture against the provided context.
func (p *SetMaxCallStackSizeToCaptureParams) Do(ctx context.Context) (err error) {
	return cdp.Execute(ctx, CommandSetMaxCallStackSizeToCapture, p, nil)
}

// TerminateExecutionParams terminate current or next JavaScript execution.
// Will cancel the termination when the outer-most script execution ends.
type TerminateExecutionParams struct{}

// TerminateExecution terminate current or next JavaScript execution. Will
// cancel the termination when the outer-most script execution ends.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Runtime#method-terminateExecution
func TerminateExecution() *TerminateExecutionParams {
	return &TerminateExecutionParams{}
}

// Do executes Runtime.terminateExecution against the provided context.
func (p *TerminateExecutionParams) Do(ctx context.Context) (err error) {
	return cdp.Execute(ctx, CommandTerminateExecution, nil, nil)
}

// AddBindingParams if executionContextId is empty, adds binding with the
// given name on the global objects of all inspected contexts, including those
// created later, bindings survive reloads. Binding function takes exactly one
// argument, this argument should be string, in case of any other input,
// function throws an exception. Each binding function call produces
// Runtime.bindingCalled notification.
type AddBindingParams struct {
	Name                 string `json:"name"`
	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.
}

// AddBinding if executionContextId is empty, adds binding with the given
// name on the global objects of all inspected contexts, including those created
// later, bindings survive reloads. Binding function takes exactly one argument,
// this argument should be string, in case of any other input, function throws
// an exception. Each binding function call produces Runtime.bindingCalled
// notification.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Runtime#method-addBinding
//
// parameters:
//
//	name
func AddBinding(name string) *AddBindingParams {
	return &AddBindingParams{
		Name: name,
	}
}

// WithExecutionContextName 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.
func (p AddBindingParams) WithExecutionContextName(executionContextName string) *AddBindingParams {
	p.ExecutionContextName = executionContextName
	return &p
}

// Do executes Runtime.addBinding against the provided context.
func (p *AddBindingParams) Do(ctx context.Context) (err error) {
	return cdp.Execute(ctx, CommandAddBinding, p, nil)
}

// RemoveBindingParams this method does not remove binding function from
// global object but unsubscribes current runtime agent from
// Runtime.bindingCalled notifications.
type RemoveBindingParams struct {
	Name string `json:"name"`
}

// RemoveBinding this method does not remove binding function from global
// object but unsubscribes current runtime agent from Runtime.bindingCalled
// notifications.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Runtime#method-removeBinding
//
// parameters:
//
//	name
func RemoveBinding(name string) *RemoveBindingParams {
	return &RemoveBindingParams{
		Name: name,
	}
}

// Do executes Runtime.removeBinding against the provided context.
func (p *RemoveBindingParams) Do(ctx context.Context) (err error) {
	return cdp.Execute(ctx, CommandRemoveBinding, p, nil)
}

// GetExceptionDetailsParams this method tries to lookup and populate
// exception details for a JavaScript Error object. Note that the stackTrace
// portion of the resulting exceptionDetails will only be populated if the
// Runtime domain was enabled at the time when the Error was thrown.
type GetExceptionDetailsParams struct {
	ErrorObjectID RemoteObjectID `json:"errorObjectId"` // The error object for which to resolve the exception details.
}

// GetExceptionDetails this method tries to lookup and populate exception
// details for a JavaScript Error object. Note that the stackTrace portion of
// the resulting exceptionDetails will only be populated if the Runtime domain
// was enabled at the time when the Error was thrown.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Runtime#method-getExceptionDetails
//
// parameters:
//
//	errorObjectID - The error object for which to resolve the exception details.
func GetExceptionDetails(errorObjectID RemoteObjectID) *GetExceptionDetailsParams {
	return &GetExceptionDetailsParams{
		ErrorObjectID: errorObjectID,
	}
}

// GetExceptionDetailsReturns return values.
type GetExceptionDetailsReturns struct {
	ExceptionDetails *ExceptionDetails `json:"exceptionDetails,omitempty"`
}

// Do executes Runtime.getExceptionDetails against the provided context.
//
// returns:
//
//	exceptionDetails
func (p *GetExceptionDetailsParams) Do(ctx context.Context) (exceptionDetails *ExceptionDetails, err error) {
	// execute
	var res GetExceptionDetailsReturns
	err = cdp.Execute(ctx, CommandGetExceptionDetails, p, &res)
	if err != nil {
		return nil, err
	}

	return res.ExceptionDetails, nil
}

// Command names.
const (
	CommandAwaitPromise                    = "Runtime.awaitPromise"
	CommandCallFunctionOn                  = "Runtime.callFunctionOn"
	CommandCompileScript                   = "Runtime.compileScript"
	CommandDisable                         = "Runtime.disable"
	CommandDiscardConsoleEntries           = "Runtime.discardConsoleEntries"
	CommandEnable                          = "Runtime.enable"
	CommandEvaluate                        = "Runtime.evaluate"
	CommandGetIsolateID                    = "Runtime.getIsolateId"
	CommandGetHeapUsage                    = "Runtime.getHeapUsage"
	CommandGetProperties                   = "Runtime.getProperties"
	CommandGlobalLexicalScopeNames         = "Runtime.globalLexicalScopeNames"
	CommandQueryObjects                    = "Runtime.queryObjects"
	CommandReleaseObject                   = "Runtime.releaseObject"
	CommandReleaseObjectGroup              = "Runtime.releaseObjectGroup"
	CommandRunIfWaitingForDebugger         = "Runtime.runIfWaitingForDebugger"
	CommandRunScript                       = "Runtime.runScript"
	CommandSetCustomObjectFormatterEnabled = "Runtime.setCustomObjectFormatterEnabled"
	CommandSetMaxCallStackSizeToCapture    = "Runtime.setMaxCallStackSizeToCapture"
	CommandTerminateExecution              = "Runtime.terminateExecution"
	CommandAddBinding                      = "Runtime.addBinding"
	CommandRemoveBinding                   = "Runtime.removeBinding"
	CommandGetExceptionDetails             = "Runtime.getExceptionDetails"
)