001package Torello.Browser;
002
003import java.util.*;
004import javax.json.*;
005import javax.json.stream.*;
006import java.io.*;
007
008import java.lang.reflect.Method;
009import java.lang.reflect.Parameter;
010import java.util.function.Function;
011
012import Torello.Java.Additional.*;
013
014import static Torello.Java.Additional.JFlag.*;
015
016import Torello.Java.StrCmpr;
017import Torello.JavaDoc.StaticFunctional;
018import Torello.JavaDoc.JDHeaderBackgroundImg;
019import Torello.JavaDoc.Excuse;
020
021/**
022 * <SPAN CLASS=CopiedJDK><B>RunTime domain exposes JavaScript runtime by means of remote evaluation and mirror objects.
023 * Evaluation results are returned as mirror object that expose object type, string representation
024 * and unique identifier that can be used for further object reference. Original objects are
025 * maintained in memory unless they are either explicitly released or are released along with the
026 * other objects in their object group.</B></SPAN>
027 * 
028 * <EMBED CLASS='external-html' DATA-FILE-ID=CODE_GEN_NOTE>
029 */
030@StaticFunctional(Excused={"counter"}, Excuses={Excuse.CONFIGURATION})
031@JDHeaderBackgroundImg(EmbedTagFileID="WOOD_PLANK_NOTE")
032public class RunTime
033{
034    // ********************************************************************************************
035    // ********************************************************************************************
036    // Class Header Stuff
037    // ********************************************************************************************
038    // ********************************************************************************************
039
040
041    // No Pubic Constructors
042    private RunTime () { }
043
044    // These two Vector's are used by all the "Methods" exported by this class.  java.lang.reflect
045    // is used to generate the JSON String's.  It saves thousands of lines of Auto-Generated Code.
046    private static final Map<String, Vector<String>>    parameterNames = new HashMap<>();
047    private static final Map<String, Vector<Class<?>>>  parameterTypes = new HashMap<>();
048
049    // Some Methods do not take any parameters - for instance all the "enable()" and "disable()"
050    // I simply could not get ride of RAW-TYPES and UNCHECKED warnings... so there are now,
051    // offically, two empty-vectors.  One for String's, and the other for Classes.
052
053    private static final Vector<String>     EMPTY_VEC_STR = new Vector<>();
054    private static final Vector<Class<?>>   EMPTY_VEC_CLASS = new Vector<>();
055
056    static
057    {
058        for (Method m : RunTime.class.getMethods())
059        {
060            // This doesn't work!  The parameter names are all "arg0" ... "argN"
061            // It works for java.lang.reflect.Field, BUT NOT java.lang.reflect.Parameter!
062            //
063            // Vector<String> parameterNamesList = new Vector<>(); -- NOPE!
064
065            Vector<Class<?>> parameterTypesList = new Vector<>();
066        
067            for (Parameter p : m.getParameters()) parameterTypesList.add(p.getType());
068
069            parameterTypes.put(
070                m.getName(),
071                (parameterTypesList.size() > 0) ? parameterTypesList : EMPTY_VEC_CLASS
072            );
073        }
074    }
075
076    static
077    {
078        Vector<String> v = null;
079
080        v = new Vector<String>(3);
081        parameterNames.put("awaitPromise", v);
082        Collections.addAll(v, new String[]
083        { "promiseObjectId", "returnByValue", "generatePreview", });
084
085        v = new Vector<String>(11);
086        parameterNames.put("callFunctionOn", v);
087        Collections.addAll(v, new String[]
088        { "functionDeclaration", "objectId", "arguments", "silent", "returnByValue", "generatePreview", "userGesture", "awaitPromise", "executionContextId", "objectGroup", "throwOnSideEffect", });
089
090        v = new Vector<String>(4);
091        parameterNames.put("compileScript", v);
092        Collections.addAll(v, new String[]
093        { "expression", "sourceURL", "persistScript", "executionContextId", });
094
095        parameterNames.put("disable", EMPTY_VEC_STR);
096
097        parameterNames.put("discardConsoleEntries", EMPTY_VEC_STR);
098
099        parameterNames.put("enable", EMPTY_VEC_STR);
100
101        v = new Vector<String>(15);
102        parameterNames.put("evaluate", v);
103        Collections.addAll(v, new String[]
104        { "expression", "objectGroup", "includeCommandLineAPI", "silent", "contextId", "returnByValue", "generatePreview", "userGesture", "awaitPromise", "throwOnSideEffect", "timeout", "disableBreaks", "replMode", "allowUnsafeEvalBlockedByCSP", "uniqueContextId", });
105
106        parameterNames.put("getIsolateId", EMPTY_VEC_STR);
107
108        parameterNames.put("getHeapUsage", EMPTY_VEC_STR);
109
110        v = new Vector<String>(5);
111        parameterNames.put("getProperties", v);
112        Collections.addAll(v, new String[]
113        { "objectId", "ownProperties", "accessorPropertiesOnly", "generatePreview", "nonIndexedPropertiesOnly", });
114
115        v = new Vector<String>(1);
116        parameterNames.put("globalLexicalScopeNames", v);
117        Collections.addAll(v, new String[]
118        { "executionContextId", });
119
120        v = new Vector<String>(2);
121        parameterNames.put("queryObjects", v);
122        Collections.addAll(v, new String[]
123        { "prototypeObjectId", "objectGroup", });
124
125        v = new Vector<String>(1);
126        parameterNames.put("releaseObject", v);
127        Collections.addAll(v, new String[]
128        { "objectId", });
129
130        v = new Vector<String>(1);
131        parameterNames.put("releaseObjectGroup", v);
132        Collections.addAll(v, new String[]
133        { "objectGroup", });
134
135        parameterNames.put("runIfWaitingForDebugger", EMPTY_VEC_STR);
136
137        v = new Vector<String>(8);
138        parameterNames.put("runScript", v);
139        Collections.addAll(v, new String[]
140        { "scriptId", "executionContextId", "objectGroup", "silent", "includeCommandLineAPI", "returnByValue", "generatePreview", "awaitPromise", });
141
142        v = new Vector<String>(1);
143        parameterNames.put("setAsyncCallStackDepth", v);
144        Collections.addAll(v, new String[]
145        { "maxDepth", });
146
147        v = new Vector<String>(1);
148        parameterNames.put("setCustomObjectFormatterEnabled", v);
149        Collections.addAll(v, new String[]
150        { "enabled", });
151
152        v = new Vector<String>(1);
153        parameterNames.put("setMaxCallStackSizeToCapture", v);
154        Collections.addAll(v, new String[]
155        { "size", });
156
157        parameterNames.put("terminateExecution", EMPTY_VEC_STR);
158
159        v = new Vector<String>(3);
160        parameterNames.put("addBinding", v);
161        Collections.addAll(v, new String[]
162        { "name", "executionContextId", "executionContextName", });
163
164        v = new Vector<String>(1);
165        parameterNames.put("removeBinding", v);
166        Collections.addAll(v, new String[]
167        { "name", });
168    }
169
170
171    // ********************************************************************************************
172    // ********************************************************************************************
173    // Types - Static Inner Classes
174    // ********************************************************************************************
175    // ********************************************************************************************
176
177    // public static class ScriptId => String
178    
179    // public static class RemoteObjectId => String
180    
181    // public static class UnserializableValue => String
182    
183    // public static class ExecutionContextId => Integer
184    
185    // public static class Timestamp => Number
186    
187    // public static class TimeDelta => Number
188    
189    // public static class UniqueDebuggerId => String
190    
191    /** Mirror object referencing original JavaScript object. */
192    public static class RemoteObject extends BaseType
193    {
194        /** For Object Serialization.  java.io.Serializable */
195        protected static final long serialVersionUID = 1;
196        
197        public boolean[] optionals()
198        { return new boolean[] { false, true, true, true, true, true, true, true, true, }; }
199        
200        /** Object type. */
201        public final String type;
202        
203        /**
204         * Object subtype hint. Specified for <CODE>object</CODE> type values only.
205         * NOTE: If you change anything here, make sure to also update
206         * <CODE>subtype</CODE> in <CODE>ObjectPreview</CODE> and <CODE>PropertyPreview</CODE> below.
207         * <BR />
208         * <BR /><B>OPTIONAL</B>
209         */
210        public final String subtype;
211        
212        /**
213         * Object class (constructor) name. Specified for <CODE>object</CODE> type values only.
214         * <BR />
215         * <BR /><B>OPTIONAL</B>
216         */
217        public final String className;
218        
219        /**
220         * Remote object value in case of primitive values or JSON values (if it was requested).
221         * <BR />
222         * <BR /><B>OPTIONAL</B>
223         */
224        public final JsonValue value;
225        
226        /**
227         * Primitive value which can not be JSON-stringified does not have <CODE>value</CODE>, but gets this
228         * property.
229         * <BR />
230         * <BR /><B>OPTIONAL</B>
231         */
232        public final String unserializableValue;
233        
234        /**
235         * String representation of the object.
236         * <BR />
237         * <BR /><B>OPTIONAL</B>
238         */
239        public final String description;
240        
241        /**
242         * Unique object identifier (for non-primitive values).
243         * <BR />
244         * <BR /><B>OPTIONAL</B>
245         */
246        public final String objectId;
247        
248        /**
249         * Preview containing abbreviated property values. Specified for <CODE>object</CODE> type values only.
250         * <BR />
251         * <BR /><B>OPTIONAL</B>
252         * <BR /><B>EXPERIMENTAL</B>
253         */
254        public final RunTime.ObjectPreview preview;
255        
256        /**
257         * <CODE>[No Description Provided by Google]</CODE>
258         * <BR />
259         * <BR /><B>OPTIONAL</B>
260         * <BR /><B>EXPERIMENTAL</B>
261         */
262        public final RunTime.CustomPreview customPreview;
263        
264        /**
265         * Constructor
266         *
267         * @param type Object type.
268         * <BR />Acceptable Values: ["object", "function", "undefined", "string", "number", "boolean", "symbol", "bigint"]
269         * 
270         * @param subtype 
271         * Object subtype hint. Specified for <CODE>object</CODE> type values only.
272         * NOTE: If you change anything here, make sure to also update
273         * <CODE>subtype</CODE> in <CODE>ObjectPreview</CODE> and <CODE>PropertyPreview</CODE> below.
274         * <BR />Acceptable Values: ["array", "null", "node", "regexp", "date", "map", "set", "weakmap", "weakset", "iterator", "generator", "error", "proxy", "promise", "typedarray", "arraybuffer", "dataview", "webassemblymemory", "wasmvalue"]
275         * <BR /><B>OPTIONAL</B>
276         * 
277         * @param className Object class (constructor) name. Specified for <CODE>object</CODE> type values only.
278         * <BR /><B>OPTIONAL</B>
279         * 
280         * @param value Remote object value in case of primitive values or JSON values (if it was requested).
281         * <BR /><B>OPTIONAL</B>
282         * 
283         * @param unserializableValue 
284         * Primitive value which can not be JSON-stringified does not have <CODE>value</CODE>, but gets this
285         * property.
286         * <BR /><B>OPTIONAL</B>
287         * 
288         * @param description String representation of the object.
289         * <BR /><B>OPTIONAL</B>
290         * 
291         * @param objectId Unique object identifier (for non-primitive values).
292         * <BR /><B>OPTIONAL</B>
293         * 
294         * @param preview Preview containing abbreviated property values. Specified for <CODE>object</CODE> type values only.
295         * <BR /><B>OPTIONAL</B>
296         * <BR /><B>EXPERIMENTAL</B>
297         * 
298         * @param customPreview -
299         * <BR /><B>OPTIONAL</B>
300         * <BR /><B>EXPERIMENTAL</B>
301         */
302        public RemoteObject(
303                String type, String subtype, String className, JsonValue value, 
304                String unserializableValue, String description, String objectId, 
305                RunTime.ObjectPreview preview, RunTime.CustomPreview customPreview
306            )
307        {
308            // Exception-Check(s) to ensure that if any parameters which are not declared as
309            // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
310            
311            if (type == null) BRDPC.throwNPE("type");
312            
313            // Exception-Check(s) to ensure that if any parameters which must adhere to a
314            // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw.
315            
316            BRDPC.checkIAE(
317                "type", type,
318                "object", "function", "undefined", "string", "number", "boolean", "symbol", "bigint"
319            );
320            BRDPC.checkIAE(
321                "subtype", subtype,
322                "array", "null", "node", "regexp", "date", "map", "set", "weakmap", "weakset", "iterator", "generator", "error", "proxy", "promise", "typedarray", "arraybuffer", "dataview", "webassemblymemory", "wasmvalue"
323            );
324            
325            this.type                 = type;
326            this.subtype              = subtype;
327            this.className            = className;
328            this.value                = value;
329            this.unserializableValue  = unserializableValue;
330            this.description          = description;
331            this.objectId             = objectId;
332            this.preview              = preview;
333            this.customPreview        = customPreview;
334        }
335        
336        /**
337         * JSON Object Constructor
338         * @param jo A Json-Object having data about an instance of {@code 'RemoteObject'}.
339         */
340        public RemoteObject (JsonObject jo)
341        {
342            this.type                 = ReadJSON.getString(jo, "type", false, true);
343            this.subtype              = ReadJSON.getString(jo, "subtype", true, false);
344            this.className            = ReadJSON.getString(jo, "className", true, false);
345            this.value                = jo.get("value");
346            this.unserializableValue  = ReadJSON.getString(jo, "unserializableValue", true, false);
347            this.description          = ReadJSON.getString(jo, "description", true, false);
348            this.objectId             = ReadJSON.getString(jo, "objectId", true, false);
349            this.preview              = ReadJSON.XL.getObject(jo, "preview", RunTime.ObjectPreview.class, true, false);
350            this.customPreview        = ReadJSON.XL.getObject(jo, "customPreview", RunTime.CustomPreview.class, true, false);
351        }
352        
353    }
354    
355    /**
356     * <CODE>[No Description Provided by Google]</CODE>
357     * <BR />
358     * <BR /><B>EXPERIMENTAL</B>
359     */
360    public static class CustomPreview extends BaseType
361    {
362        /** For Object Serialization.  java.io.Serializable */
363        protected static final long serialVersionUID = 1;
364        
365        public boolean[] optionals()
366        { return new boolean[] { false, true, }; }
367        
368        /**
369         * The JSON-stringified result of formatter.header(object, config) call.
370         * It contains json ML array that represents RemoteObject.
371         */
372        public final String header;
373        
374        /**
375         * If formatter returns true as a result of formatter.hasBody call then bodyGetterId will
376         * contain RemoteObjectId for the function that returns result of formatter.body(object, config) call.
377         * The result value is json ML array.
378         * <BR />
379         * <BR /><B>OPTIONAL</B>
380         */
381        public final String bodyGetterId;
382        
383        /**
384         * Constructor
385         *
386         * @param header 
387         * The JSON-stringified result of formatter.header(object, config) call.
388         * It contains json ML array that represents RemoteObject.
389         * 
390         * @param bodyGetterId 
391         * If formatter returns true as a result of formatter.hasBody call then bodyGetterId will
392         * contain RemoteObjectId for the function that returns result of formatter.body(object, config) call.
393         * The result value is json ML array.
394         * <BR /><B>OPTIONAL</B>
395         */
396        public CustomPreview(String header, String bodyGetterId)
397        {
398            // Exception-Check(s) to ensure that if any parameters which are not declared as
399            // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
400            
401            if (header == null) BRDPC.throwNPE("header");
402            
403            this.header        = header;
404            this.bodyGetterId  = bodyGetterId;
405        }
406        
407        /**
408         * JSON Object Constructor
409         * @param jo A Json-Object having data about an instance of {@code 'CustomPreview'}.
410         */
411        public CustomPreview (JsonObject jo)
412        {
413            this.header        = ReadJSON.getString(jo, "header", false, true);
414            this.bodyGetterId  = ReadJSON.getString(jo, "bodyGetterId", true, false);
415        }
416        
417    }
418    
419    /**
420     * Object containing abbreviated remote object value.
421     * <BR />
422     * <BR /><B>EXPERIMENTAL</B>
423     */
424    public static class ObjectPreview extends BaseType
425    {
426        /** For Object Serialization.  java.io.Serializable */
427        protected static final long serialVersionUID = 1;
428        
429        public boolean[] optionals()
430        { return new boolean[] { false, true, true, false, false, true, }; }
431        
432        /** Object type. */
433        public final String type;
434        
435        /**
436         * Object subtype hint. Specified for <CODE>object</CODE> type values only.
437         * <BR />
438         * <BR /><B>OPTIONAL</B>
439         */
440        public final String subtype;
441        
442        /**
443         * String representation of the object.
444         * <BR />
445         * <BR /><B>OPTIONAL</B>
446         */
447        public final String description;
448        
449        /** True iff some of the properties or entries of the original object did not fit. */
450        public final boolean overflow;
451        
452        /** List of the properties. */
453        public final RunTime.PropertyPreview[] properties;
454        
455        /**
456         * List of the entries. Specified for <CODE>map</CODE> and <CODE>set</CODE> subtype values only.
457         * <BR />
458         * <BR /><B>OPTIONAL</B>
459         */
460        public final RunTime.EntryPreview[] entries;
461        
462        /**
463         * Constructor
464         *
465         * @param type Object type.
466         * <BR />Acceptable Values: ["object", "function", "undefined", "string", "number", "boolean", "symbol", "bigint"]
467         * 
468         * @param subtype Object subtype hint. Specified for <CODE>object</CODE> type values only.
469         * <BR />Acceptable Values: ["array", "null", "node", "regexp", "date", "map", "set", "weakmap", "weakset", "iterator", "generator", "error", "proxy", "promise", "typedarray", "arraybuffer", "dataview", "webassemblymemory", "wasmvalue"]
470         * <BR /><B>OPTIONAL</B>
471         * 
472         * @param description String representation of the object.
473         * <BR /><B>OPTIONAL</B>
474         * 
475         * @param overflow True iff some of the properties or entries of the original object did not fit.
476         * 
477         * @param properties List of the properties.
478         * 
479         * @param entries List of the entries. Specified for <CODE>map</CODE> and <CODE>set</CODE> subtype values only.
480         * <BR /><B>OPTIONAL</B>
481         */
482        public ObjectPreview(
483                String type, String subtype, String description, boolean overflow, 
484                RunTime.PropertyPreview[] properties, RunTime.EntryPreview[] entries
485            )
486        {
487            // Exception-Check(s) to ensure that if any parameters which are not declared as
488            // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
489            
490            if (type == null)       BRDPC.throwNPE("type");
491            if (properties == null) BRDPC.throwNPE("properties");
492            
493            // Exception-Check(s) to ensure that if any parameters which must adhere to a
494            // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw.
495            
496            BRDPC.checkIAE(
497                "type", type,
498                "object", "function", "undefined", "string", "number", "boolean", "symbol", "bigint"
499            );
500            BRDPC.checkIAE(
501                "subtype", subtype,
502                "array", "null", "node", "regexp", "date", "map", "set", "weakmap", "weakset", "iterator", "generator", "error", "proxy", "promise", "typedarray", "arraybuffer", "dataview", "webassemblymemory", "wasmvalue"
503            );
504            
505            this.type         = type;
506            this.subtype      = subtype;
507            this.description  = description;
508            this.overflow     = overflow;
509            this.properties   = properties;
510            this.entries      = entries;
511        }
512        
513        /**
514         * JSON Object Constructor
515         * @param jo A Json-Object having data about an instance of {@code 'ObjectPreview'}.
516         */
517        public ObjectPreview (JsonObject jo)
518        {
519            this.type         = ReadJSON.getString(jo, "type", false, true);
520            this.subtype      = ReadJSON.getString(jo, "subtype", true, false);
521            this.description  = ReadJSON.getString(jo, "description", true, false);
522            this.overflow     = ReadJSON.getBoolean(jo, "overflow");
523            this.properties   = (jo.getJsonArray("properties") == null)
524            ? null
525            : ReadArrJSON.DimN.objArr(jo.getJsonArray("properties"), null, 0, RunTime.PropertyPreview[].class);
526            this.entries      = (jo.getJsonArray("entries") == null)
527            ? null
528            : ReadArrJSON.DimN.objArr(jo.getJsonArray("entries"), null, 0, RunTime.EntryPreview[].class);
529        }
530        
531    }
532    
533    /**
534     * <CODE>[No Description Provided by Google]</CODE>
535     * <BR />
536     * <BR /><B>EXPERIMENTAL</B>
537     */
538    public static class PropertyPreview extends BaseType
539    {
540        /** For Object Serialization.  java.io.Serializable */
541        protected static final long serialVersionUID = 1;
542        
543        public boolean[] optionals()
544        { return new boolean[] { false, false, true, true, true, }; }
545        
546        /** Property name. */
547        public final String name;
548        
549        /** Object type. Accessor means that the property itself is an accessor property. */
550        public final String type;
551        
552        /**
553         * User-friendly property value string.
554         * <BR />
555         * <BR /><B>OPTIONAL</B>
556         */
557        public final String value;
558        
559        /**
560         * Nested value preview.
561         * <BR />
562         * <BR /><B>OPTIONAL</B>
563         */
564        public final RunTime.ObjectPreview valuePreview;
565        
566        /**
567         * Object subtype hint. Specified for <CODE>object</CODE> type values only.
568         * <BR />
569         * <BR /><B>OPTIONAL</B>
570         */
571        public final String subtype;
572        
573        /**
574         * Constructor
575         *
576         * @param name Property name.
577         * 
578         * @param type Object type. Accessor means that the property itself is an accessor property.
579         * <BR />Acceptable Values: ["object", "function", "undefined", "string", "number", "boolean", "symbol", "accessor", "bigint"]
580         * 
581         * @param value User-friendly property value string.
582         * <BR /><B>OPTIONAL</B>
583         * 
584         * @param valuePreview Nested value preview.
585         * <BR /><B>OPTIONAL</B>
586         * 
587         * @param subtype Object subtype hint. Specified for <CODE>object</CODE> type values only.
588         * <BR />Acceptable Values: ["array", "null", "node", "regexp", "date", "map", "set", "weakmap", "weakset", "iterator", "generator", "error", "proxy", "promise", "typedarray", "arraybuffer", "dataview", "webassemblymemory", "wasmvalue"]
589         * <BR /><B>OPTIONAL</B>
590         */
591        public PropertyPreview(
592                String name, String type, String value, RunTime.ObjectPreview valuePreview, 
593                String subtype
594            )
595        {
596            // Exception-Check(s) to ensure that if any parameters which are not declared as
597            // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
598            
599            if (name == null) BRDPC.throwNPE("name");
600            if (type == null) BRDPC.throwNPE("type");
601            
602            // Exception-Check(s) to ensure that if any parameters which must adhere to a
603            // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw.
604            
605            BRDPC.checkIAE(
606                "type", type,
607                "object", "function", "undefined", "string", "number", "boolean", "symbol", "accessor", "bigint"
608            );
609            BRDPC.checkIAE(
610                "subtype", subtype,
611                "array", "null", "node", "regexp", "date", "map", "set", "weakmap", "weakset", "iterator", "generator", "error", "proxy", "promise", "typedarray", "arraybuffer", "dataview", "webassemblymemory", "wasmvalue"
612            );
613            
614            this.name          = name;
615            this.type          = type;
616            this.value         = value;
617            this.valuePreview  = valuePreview;
618            this.subtype       = subtype;
619        }
620        
621        /**
622         * JSON Object Constructor
623         * @param jo A Json-Object having data about an instance of {@code 'PropertyPreview'}.
624         */
625        public PropertyPreview (JsonObject jo)
626        {
627            this.name          = ReadJSON.getString(jo, "name", false, true);
628            this.type          = ReadJSON.getString(jo, "type", false, true);
629            this.value         = ReadJSON.getString(jo, "value", true, false);
630            this.valuePreview  = ReadJSON.XL.getObject(jo, "valuePreview", RunTime.ObjectPreview.class, true, false);
631            this.subtype       = ReadJSON.getString(jo, "subtype", true, false);
632        }
633        
634    }
635    
636    /**
637     * <CODE>[No Description Provided by Google]</CODE>
638     * <BR />
639     * <BR /><B>EXPERIMENTAL</B>
640     */
641    public static class EntryPreview extends BaseType
642    {
643        /** For Object Serialization.  java.io.Serializable */
644        protected static final long serialVersionUID = 1;
645        
646        public boolean[] optionals()
647        { return new boolean[] { true, false, }; }
648        
649        /**
650         * Preview of the key. Specified for map-like collection entries.
651         * <BR />
652         * <BR /><B>OPTIONAL</B>
653         */
654        public final RunTime.ObjectPreview key;
655        
656        /** Preview of the value. */
657        public final RunTime.ObjectPreview value;
658        
659        /**
660         * Constructor
661         *
662         * @param key Preview of the key. Specified for map-like collection entries.
663         * <BR /><B>OPTIONAL</B>
664         * 
665         * @param value Preview of the value.
666         */
667        public EntryPreview(RunTime.ObjectPreview key, RunTime.ObjectPreview value)
668        {
669            // Exception-Check(s) to ensure that if any parameters which are not declared as
670            // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
671            
672            if (value == null) BRDPC.throwNPE("value");
673            
674            this.key    = key;
675            this.value  = value;
676        }
677        
678        /**
679         * JSON Object Constructor
680         * @param jo A Json-Object having data about an instance of {@code 'EntryPreview'}.
681         */
682        public EntryPreview (JsonObject jo)
683        {
684            this.key    = ReadJSON.XL.getObject(jo, "key", RunTime.ObjectPreview.class, true, false);
685            this.value  = ReadJSON.XL.getObject(jo, "value", RunTime.ObjectPreview.class, false, true);
686        }
687        
688    }
689    
690    /** Object property descriptor. */
691    public static class PropertyDescriptor extends BaseType
692    {
693        /** For Object Serialization.  java.io.Serializable */
694        protected static final long serialVersionUID = 1;
695        
696        public boolean[] optionals()
697        { return new boolean[] { false, true, true, true, true, false, false, true, true, true, }; }
698        
699        /** Property name or symbol description. */
700        public final String name;
701        
702        /**
703         * The value associated with the property.
704         * <BR />
705         * <BR /><B>OPTIONAL</B>
706         */
707        public final RunTime.RemoteObject value;
708        
709        /**
710         * True if the value associated with the property may be changed (data descriptors only).
711         * <BR />
712         * <BR /><B>OPTIONAL</B>
713         */
714        public final Boolean writable;
715        
716        /**
717         * A function which serves as a getter for the property, or <CODE>undefined</CODE> if there is no getter
718         * (accessor descriptors only).
719         * <BR />
720         * <BR /><B>OPTIONAL</B>
721         */
722        public final RunTime.RemoteObject get;
723        
724        /**
725         * A function which serves as a setter for the property, or <CODE>undefined</CODE> if there is no setter
726         * (accessor descriptors only).
727         * <BR />
728         * <BR /><B>OPTIONAL</B>
729         */
730        public final RunTime.RemoteObject set;
731        
732        /**
733         * True if the type of this property descriptor may be changed and if the property may be
734         * deleted from the corresponding object.
735         */
736        public final boolean configurable;
737        
738        /**
739         * True if this property shows up during enumeration of the properties on the corresponding
740         * object.
741         */
742        public final boolean enumerable;
743        
744        /**
745         * True if the result was thrown during the evaluation.
746         * <BR />
747         * <BR /><B>OPTIONAL</B>
748         */
749        public final Boolean wasThrown;
750        
751        /**
752         * True if the property is owned for the object.
753         * <BR />
754         * <BR /><B>OPTIONAL</B>
755         */
756        public final Boolean isOwn;
757        
758        /**
759         * Property symbol object, if the property is of the <CODE>symbol</CODE> type.
760         * <BR />
761         * <BR /><B>OPTIONAL</B>
762         */
763        public final RunTime.RemoteObject symbol;
764        
765        /**
766         * Constructor
767         *
768         * @param name Property name or symbol description.
769         * 
770         * @param value The value associated with the property.
771         * <BR /><B>OPTIONAL</B>
772         * 
773         * @param writable True if the value associated with the property may be changed (data descriptors only).
774         * <BR /><B>OPTIONAL</B>
775         * 
776         * @param get 
777         * A function which serves as a getter for the property, or <CODE>undefined</CODE> if there is no getter
778         * (accessor descriptors only).
779         * <BR /><B>OPTIONAL</B>
780         * 
781         * @param set 
782         * A function which serves as a setter for the property, or <CODE>undefined</CODE> if there is no setter
783         * (accessor descriptors only).
784         * <BR /><B>OPTIONAL</B>
785         * 
786         * @param configurable 
787         * True if the type of this property descriptor may be changed and if the property may be
788         * deleted from the corresponding object.
789         * 
790         * @param enumerable 
791         * True if this property shows up during enumeration of the properties on the corresponding
792         * object.
793         * 
794         * @param wasThrown True if the result was thrown during the evaluation.
795         * <BR /><B>OPTIONAL</B>
796         * 
797         * @param isOwn True if the property is owned for the object.
798         * <BR /><B>OPTIONAL</B>
799         * 
800         * @param symbol Property symbol object, if the property is of the <CODE>symbol</CODE> type.
801         * <BR /><B>OPTIONAL</B>
802         */
803        public PropertyDescriptor(
804                String name, RunTime.RemoteObject value, Boolean writable, RunTime.RemoteObject get, 
805                RunTime.RemoteObject set, boolean configurable, boolean enumerable, 
806                Boolean wasThrown, Boolean isOwn, RunTime.RemoteObject symbol
807            )
808        {
809            // Exception-Check(s) to ensure that if any parameters which are not declared as
810            // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
811            
812            if (name == null) BRDPC.throwNPE("name");
813            
814            this.name          = name;
815            this.value         = value;
816            this.writable      = writable;
817            this.get           = get;
818            this.set           = set;
819            this.configurable  = configurable;
820            this.enumerable    = enumerable;
821            this.wasThrown     = wasThrown;
822            this.isOwn         = isOwn;
823            this.symbol        = symbol;
824        }
825        
826        /**
827         * JSON Object Constructor
828         * @param jo A Json-Object having data about an instance of {@code 'PropertyDescriptor'}.
829         */
830        public PropertyDescriptor (JsonObject jo)
831        {
832            this.name          = ReadJSON.getString(jo, "name", false, true);
833            this.value         = ReadJSON.XL.getObject(jo, "value", RunTime.RemoteObject.class, true, false);
834            this.writable      = ReadJSON.getBOOLEAN(jo, "writable", true);
835            this.get           = ReadJSON.XL.getObject(jo, "get", RunTime.RemoteObject.class, true, false);
836            this.set           = ReadJSON.XL.getObject(jo, "set", RunTime.RemoteObject.class, true, false);
837            this.configurable  = ReadJSON.getBoolean(jo, "configurable");
838            this.enumerable    = ReadJSON.getBoolean(jo, "enumerable");
839            this.wasThrown     = ReadJSON.getBOOLEAN(jo, "wasThrown", true);
840            this.isOwn         = ReadJSON.getBOOLEAN(jo, "isOwn", true);
841            this.symbol        = ReadJSON.XL.getObject(jo, "symbol", RunTime.RemoteObject.class, true, false);
842        }
843        
844    }
845    
846    /** Object internal property descriptor. This property isn't normally visible in JavaScript code. */
847    public static class InternalPropertyDescriptor extends BaseType
848    {
849        /** For Object Serialization.  java.io.Serializable */
850        protected static final long serialVersionUID = 1;
851        
852        public boolean[] optionals()
853        { return new boolean[] { false, true, }; }
854        
855        /** Conventional property name. */
856        public final String name;
857        
858        /**
859         * The value associated with the property.
860         * <BR />
861         * <BR /><B>OPTIONAL</B>
862         */
863        public final RunTime.RemoteObject value;
864        
865        /**
866         * Constructor
867         *
868         * @param name Conventional property name.
869         * 
870         * @param value The value associated with the property.
871         * <BR /><B>OPTIONAL</B>
872         */
873        public InternalPropertyDescriptor(String name, RunTime.RemoteObject value)
874        {
875            // Exception-Check(s) to ensure that if any parameters which are not declared as
876            // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
877            
878            if (name == null) BRDPC.throwNPE("name");
879            
880            this.name   = name;
881            this.value  = value;
882        }
883        
884        /**
885         * JSON Object Constructor
886         * @param jo A Json-Object having data about an instance of {@code 'InternalPropertyDescriptor'}.
887         */
888        public InternalPropertyDescriptor (JsonObject jo)
889        {
890            this.name   = ReadJSON.getString(jo, "name", false, true);
891            this.value  = ReadJSON.XL.getObject(jo, "value", RunTime.RemoteObject.class, true, false);
892        }
893        
894    }
895    
896    /**
897     * Object private field descriptor.
898     * <BR />
899     * <BR /><B>EXPERIMENTAL</B>
900     */
901    public static class PrivatePropertyDescriptor extends BaseType
902    {
903        /** For Object Serialization.  java.io.Serializable */
904        protected static final long serialVersionUID = 1;
905        
906        public boolean[] optionals()
907        { return new boolean[] { false, true, true, true, }; }
908        
909        /** Private property name. */
910        public final String name;
911        
912        /**
913         * The value associated with the private property.
914         * <BR />
915         * <BR /><B>OPTIONAL</B>
916         */
917        public final RunTime.RemoteObject value;
918        
919        /**
920         * A function which serves as a getter for the private property,
921         * or <CODE>undefined</CODE> if there is no getter (accessor descriptors only).
922         * <BR />
923         * <BR /><B>OPTIONAL</B>
924         */
925        public final RunTime.RemoteObject get;
926        
927        /**
928         * A function which serves as a setter for the private property,
929         * or <CODE>undefined</CODE> if there is no setter (accessor descriptors only).
930         * <BR />
931         * <BR /><B>OPTIONAL</B>
932         */
933        public final RunTime.RemoteObject set;
934        
935        /**
936         * Constructor
937         *
938         * @param name Private property name.
939         * 
940         * @param value The value associated with the private property.
941         * <BR /><B>OPTIONAL</B>
942         * 
943         * @param get 
944         * A function which serves as a getter for the private property,
945         * or <CODE>undefined</CODE> if there is no getter (accessor descriptors only).
946         * <BR /><B>OPTIONAL</B>
947         * 
948         * @param set 
949         * A function which serves as a setter for the private property,
950         * or <CODE>undefined</CODE> if there is no setter (accessor descriptors only).
951         * <BR /><B>OPTIONAL</B>
952         */
953        public PrivatePropertyDescriptor(
954                String name, RunTime.RemoteObject value, RunTime.RemoteObject get, 
955                RunTime.RemoteObject set
956            )
957        {
958            // Exception-Check(s) to ensure that if any parameters which are not declared as
959            // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
960            
961            if (name == null) BRDPC.throwNPE("name");
962            
963            this.name   = name;
964            this.value  = value;
965            this.get    = get;
966            this.set    = set;
967        }
968        
969        /**
970         * JSON Object Constructor
971         * @param jo A Json-Object having data about an instance of {@code 'PrivatePropertyDescriptor'}.
972         */
973        public PrivatePropertyDescriptor (JsonObject jo)
974        {
975            this.name   = ReadJSON.getString(jo, "name", false, true);
976            this.value  = ReadJSON.XL.getObject(jo, "value", RunTime.RemoteObject.class, true, false);
977            this.get    = ReadJSON.XL.getObject(jo, "get", RunTime.RemoteObject.class, true, false);
978            this.set    = ReadJSON.XL.getObject(jo, "set", RunTime.RemoteObject.class, true, false);
979        }
980        
981    }
982    
983    /**
984     * Represents function call argument. Either remote object id <CODE>objectId</CODE>, primitive <CODE>value</CODE>,
985     * unserializable primitive value or neither of (for undefined) them should be specified.
986     */
987    public static class CallArgument extends BaseType
988    {
989        /** For Object Serialization.  java.io.Serializable */
990        protected static final long serialVersionUID = 1;
991        
992        public boolean[] optionals()
993        { return new boolean[] { true, true, true, }; }
994        
995        /**
996         * Primitive value or serializable javascript object.
997         * <BR />
998         * <BR /><B>OPTIONAL</B>
999         */
1000        public final JsonValue value;
1001        
1002        /**
1003         * Primitive value which can not be JSON-stringified.
1004         * <BR />
1005         * <BR /><B>OPTIONAL</B>
1006         */
1007        public final String unserializableValue;
1008        
1009        /**
1010         * Remote object handle.
1011         * <BR />
1012         * <BR /><B>OPTIONAL</B>
1013         */
1014        public final String objectId;
1015        
1016        /**
1017         * Constructor
1018         *
1019         * @param value Primitive value or serializable javascript object.
1020         * <BR /><B>OPTIONAL</B>
1021         * 
1022         * @param unserializableValue Primitive value which can not be JSON-stringified.
1023         * <BR /><B>OPTIONAL</B>
1024         * 
1025         * @param objectId Remote object handle.
1026         * <BR /><B>OPTIONAL</B>
1027         */
1028        public CallArgument(JsonValue value, String unserializableValue, String objectId)
1029        {
1030            this.value                = value;
1031            this.unserializableValue  = unserializableValue;
1032            this.objectId             = objectId;
1033        }
1034        
1035        /**
1036         * JSON Object Constructor
1037         * @param jo A Json-Object having data about an instance of {@code 'CallArgument'}.
1038         */
1039        public CallArgument (JsonObject jo)
1040        {
1041            this.value                = jo.get("value");
1042            this.unserializableValue  = ReadJSON.getString(jo, "unserializableValue", true, false);
1043            this.objectId             = ReadJSON.getString(jo, "objectId", true, false);
1044        }
1045        
1046    }
1047    
1048    /** Description of an isolated world. */
1049    public static class ExecutionContextDescription extends BaseType
1050    {
1051        /** For Object Serialization.  java.io.Serializable */
1052        protected static final long serialVersionUID = 1;
1053        
1054        public boolean[] optionals()
1055        { return new boolean[] { false, false, false, false, true, }; }
1056        
1057        /**
1058         * Unique id of the execution context. It can be used to specify in which execution context
1059         * script evaluation should be performed.
1060         */
1061        public final int id;
1062        
1063        /** Execution context origin. */
1064        public final String origin;
1065        
1066        /** Human readable name describing given context. */
1067        public final String name;
1068        
1069        /**
1070         * A system-unique execution context identifier. Unlike the id, this is unique across
1071         * multiple processes, so can be reliably used to identify specific context while backend
1072         * performs a cross-process navigation.
1073         * <BR />
1074         * <BR /><B>EXPERIMENTAL</B>
1075         */
1076        public final String uniqueId;
1077        
1078        /**
1079         * Embedder-specific auxiliary data.
1080         * <BR />
1081         * <BR /><B>OPTIONAL</B>
1082         */
1083        public final JsonObject auxData;
1084        
1085        /**
1086         * Constructor
1087         *
1088         * @param id 
1089         * Unique id of the execution context. It can be used to specify in which execution context
1090         * script evaluation should be performed.
1091         * 
1092         * @param origin Execution context origin.
1093         * 
1094         * @param name Human readable name describing given context.
1095         * 
1096         * @param uniqueId 
1097         * A system-unique execution context identifier. Unlike the id, this is unique across
1098         * multiple processes, so can be reliably used to identify specific context while backend
1099         * performs a cross-process navigation.
1100         * <BR /><B>EXPERIMENTAL</B>
1101         * 
1102         * @param auxData Embedder-specific auxiliary data.
1103         * <BR /><B>OPTIONAL</B>
1104         */
1105        public ExecutionContextDescription
1106            (int id, String origin, String name, String uniqueId, JsonObject auxData)
1107        {
1108            // Exception-Check(s) to ensure that if any parameters which are not declared as
1109            // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
1110            
1111            if (origin == null)   BRDPC.throwNPE("origin");
1112            if (name == null)     BRDPC.throwNPE("name");
1113            if (uniqueId == null) BRDPC.throwNPE("uniqueId");
1114            
1115            this.id        = id;
1116            this.origin    = origin;
1117            this.name      = name;
1118            this.uniqueId  = uniqueId;
1119            this.auxData   = auxData;
1120        }
1121        
1122        /**
1123         * JSON Object Constructor
1124         * @param jo A Json-Object having data about an instance of {@code 'ExecutionContextDescription'}.
1125         */
1126        public ExecutionContextDescription (JsonObject jo)
1127        {
1128            this.id        = ReadJSON.getInt(jo, "id");
1129            this.origin    = ReadJSON.getString(jo, "origin", false, true);
1130            this.name      = ReadJSON.getString(jo, "name", false, true);
1131            this.uniqueId  = ReadJSON.getString(jo, "uniqueId", false, true);
1132            this.auxData   = jo.getJsonObject("auxData");
1133        }
1134        
1135    }
1136    
1137    /**
1138     * Detailed information about exception (or error) that was thrown during script compilation or
1139     * execution.
1140     */
1141    public static class ExceptionDetails extends BaseType
1142    {
1143        /** For Object Serialization.  java.io.Serializable */
1144        protected static final long serialVersionUID = 1;
1145        
1146        public boolean[] optionals()
1147        { return new boolean[] { false, false, false, false, true, true, true, true, true, true, }; }
1148        
1149        /** Exception id. */
1150        public final int exceptionId;
1151        
1152        /** Exception text, which should be used together with exception object when available. */
1153        public final String text;
1154        
1155        /** Line number of the exception location (0-based). */
1156        public final int lineNumber;
1157        
1158        /** Column number of the exception location (0-based). */
1159        public final int columnNumber;
1160        
1161        /**
1162         * Script ID of the exception location.
1163         * <BR />
1164         * <BR /><B>OPTIONAL</B>
1165         */
1166        public final String scriptId;
1167        
1168        /**
1169         * URL of the exception location, to be used when the script was not reported.
1170         * <BR />
1171         * <BR /><B>OPTIONAL</B>
1172         */
1173        public final String url;
1174        
1175        /**
1176         * JavaScript stack trace if available.
1177         * <BR />
1178         * <BR /><B>OPTIONAL</B>
1179         */
1180        public final RunTime.StackTrace stackTrace;
1181        
1182        /**
1183         * Exception object if available.
1184         * <BR />
1185         * <BR /><B>OPTIONAL</B>
1186         */
1187        public final RunTime.RemoteObject exception;
1188        
1189        /**
1190         * Identifier of the context where exception happened.
1191         * <BR />
1192         * <BR /><B>OPTIONAL</B>
1193         */
1194        public final Integer executionContextId;
1195        
1196        /**
1197         * Dictionary with entries of meta data that the client associated
1198         * with this exception, such as information about associated network
1199         * requests, etc.
1200         * <BR />
1201         * <BR /><B>OPTIONAL</B>
1202         * <BR /><B>EXPERIMENTAL</B>
1203         */
1204        public final JsonObject exceptionMetaData;
1205        
1206        /**
1207         * Constructor
1208         *
1209         * @param exceptionId Exception id.
1210         * 
1211         * @param text Exception text, which should be used together with exception object when available.
1212         * 
1213         * @param lineNumber Line number of the exception location (0-based).
1214         * 
1215         * @param columnNumber Column number of the exception location (0-based).
1216         * 
1217         * @param scriptId Script ID of the exception location.
1218         * <BR /><B>OPTIONAL</B>
1219         * 
1220         * @param url URL of the exception location, to be used when the script was not reported.
1221         * <BR /><B>OPTIONAL</B>
1222         * 
1223         * @param stackTrace JavaScript stack trace if available.
1224         * <BR /><B>OPTIONAL</B>
1225         * 
1226         * @param exception Exception object if available.
1227         * <BR /><B>OPTIONAL</B>
1228         * 
1229         * @param executionContextId Identifier of the context where exception happened.
1230         * <BR /><B>OPTIONAL</B>
1231         * 
1232         * @param exceptionMetaData 
1233         * Dictionary with entries of meta data that the client associated
1234         * with this exception, such as information about associated network
1235         * requests, etc.
1236         * <BR /><B>OPTIONAL</B>
1237         * <BR /><B>EXPERIMENTAL</B>
1238         */
1239        public ExceptionDetails(
1240                int exceptionId, String text, int lineNumber, int columnNumber, String scriptId, 
1241                String url, RunTime.StackTrace stackTrace, RunTime.RemoteObject exception, 
1242                Integer executionContextId, JsonObject exceptionMetaData
1243            )
1244        {
1245            // Exception-Check(s) to ensure that if any parameters which are not declared as
1246            // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
1247            
1248            if (text == null) BRDPC.throwNPE("text");
1249            
1250            this.exceptionId         = exceptionId;
1251            this.text                = text;
1252            this.lineNumber          = lineNumber;
1253            this.columnNumber        = columnNumber;
1254            this.scriptId            = scriptId;
1255            this.url                 = url;
1256            this.stackTrace          = stackTrace;
1257            this.exception           = exception;
1258            this.executionContextId  = executionContextId;
1259            this.exceptionMetaData   = exceptionMetaData;
1260        }
1261        
1262        /**
1263         * JSON Object Constructor
1264         * @param jo A Json-Object having data about an instance of {@code 'ExceptionDetails'}.
1265         */
1266        public ExceptionDetails (JsonObject jo)
1267        {
1268            this.exceptionId         = ReadJSON.getInt(jo, "exceptionId");
1269            this.text                = ReadJSON.getString(jo, "text", false, true);
1270            this.lineNumber          = ReadJSON.getInt(jo, "lineNumber");
1271            this.columnNumber        = ReadJSON.getInt(jo, "columnNumber");
1272            this.scriptId            = ReadJSON.getString(jo, "scriptId", true, false);
1273            this.url                 = ReadJSON.getString(jo, "url", true, false);
1274            this.stackTrace          = ReadJSON.XL.getObject(jo, "stackTrace", RunTime.StackTrace.class, true, false);
1275            this.exception           = ReadJSON.XL.getObject(jo, "exception", RunTime.RemoteObject.class, true, false);
1276            this.executionContextId  = ReadJSON.getINTEGER(jo, "executionContextId", true);
1277            this.exceptionMetaData   = jo.getJsonObject("exceptionMetaData");
1278        }
1279        
1280    }
1281    
1282    /** Stack entry for runtime errors and assertions. */
1283    public static class CallFrame extends BaseType
1284    {
1285        /** For Object Serialization.  java.io.Serializable */
1286        protected static final long serialVersionUID = 1;
1287        
1288        public boolean[] optionals()
1289        { return new boolean[] { false, false, false, false, false, }; }
1290        
1291        /** JavaScript function name. */
1292        public final String functionName;
1293        
1294        /** JavaScript script id. */
1295        public final String scriptId;
1296        
1297        /** JavaScript script name or url. */
1298        public final String url;
1299        
1300        /** JavaScript script line number (0-based). */
1301        public final int lineNumber;
1302        
1303        /** JavaScript script column number (0-based). */
1304        public final int columnNumber;
1305        
1306        /**
1307         * Constructor
1308         *
1309         * @param functionName JavaScript function name.
1310         * 
1311         * @param scriptId JavaScript script id.
1312         * 
1313         * @param url JavaScript script name or url.
1314         * 
1315         * @param lineNumber JavaScript script line number (0-based).
1316         * 
1317         * @param columnNumber JavaScript script column number (0-based).
1318         */
1319        public CallFrame
1320            (String functionName, String scriptId, String url, int lineNumber, int columnNumber)
1321        {
1322            // Exception-Check(s) to ensure that if any parameters which are not declared as
1323            // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
1324            
1325            if (functionName == null) BRDPC.throwNPE("functionName");
1326            if (scriptId == null)     BRDPC.throwNPE("scriptId");
1327            if (url == null)          BRDPC.throwNPE("url");
1328            
1329            this.functionName  = functionName;
1330            this.scriptId      = scriptId;
1331            this.url           = url;
1332            this.lineNumber    = lineNumber;
1333            this.columnNumber  = columnNumber;
1334        }
1335        
1336        /**
1337         * JSON Object Constructor
1338         * @param jo A Json-Object having data about an instance of {@code 'CallFrame'}.
1339         */
1340        public CallFrame (JsonObject jo)
1341        {
1342            this.functionName  = ReadJSON.getString(jo, "functionName", false, true);
1343            this.scriptId      = ReadJSON.getString(jo, "scriptId", false, true);
1344            this.url           = ReadJSON.getString(jo, "url", false, true);
1345            this.lineNumber    = ReadJSON.getInt(jo, "lineNumber");
1346            this.columnNumber  = ReadJSON.getInt(jo, "columnNumber");
1347        }
1348        
1349    }
1350    
1351    /** Call frames for assertions or error messages. */
1352    public static class StackTrace extends BaseType
1353    {
1354        /** For Object Serialization.  java.io.Serializable */
1355        protected static final long serialVersionUID = 1;
1356        
1357        public boolean[] optionals()
1358        { return new boolean[] { true, false, true, true, }; }
1359        
1360        /**
1361         * String label of this stack trace. For async traces this may be a name of the function that
1362         * initiated the async call.
1363         * <BR />
1364         * <BR /><B>OPTIONAL</B>
1365         */
1366        public final String description;
1367        
1368        /** JavaScript function name. */
1369        public final RunTime.CallFrame[] callFrames;
1370        
1371        /**
1372         * Asynchronous JavaScript stack trace that preceded this stack, if available.
1373         * <BR />
1374         * <BR /><B>OPTIONAL</B>
1375         */
1376        public final RunTime.StackTrace parent;
1377        
1378        /**
1379         * Asynchronous JavaScript stack trace that preceded this stack, if available.
1380         * <BR />
1381         * <BR /><B>OPTIONAL</B>
1382         * <BR /><B>EXPERIMENTAL</B>
1383         */
1384        public final RunTime.StackTraceId parentId;
1385        
1386        /**
1387         * Constructor
1388         *
1389         * @param description 
1390         * String label of this stack trace. For async traces this may be a name of the function that
1391         * initiated the async call.
1392         * <BR /><B>OPTIONAL</B>
1393         * 
1394         * @param callFrames JavaScript function name.
1395         * 
1396         * @param parent Asynchronous JavaScript stack trace that preceded this stack, if available.
1397         * <BR /><B>OPTIONAL</B>
1398         * 
1399         * @param parentId Asynchronous JavaScript stack trace that preceded this stack, if available.
1400         * <BR /><B>OPTIONAL</B>
1401         * <BR /><B>EXPERIMENTAL</B>
1402         */
1403        public StackTrace(
1404                String description, RunTime.CallFrame[] callFrames, RunTime.StackTrace parent, 
1405                RunTime.StackTraceId parentId
1406            )
1407        {
1408            // Exception-Check(s) to ensure that if any parameters which are not declared as
1409            // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
1410            
1411            if (callFrames == null) BRDPC.throwNPE("callFrames");
1412            
1413            this.description  = description;
1414            this.callFrames   = callFrames;
1415            this.parent       = parent;
1416            this.parentId     = parentId;
1417        }
1418        
1419        /**
1420         * JSON Object Constructor
1421         * @param jo A Json-Object having data about an instance of {@code 'StackTrace'}.
1422         */
1423        public StackTrace (JsonObject jo)
1424        {
1425            this.description  = ReadJSON.getString(jo, "description", true, false);
1426            this.callFrames   = (jo.getJsonArray("callFrames") == null)
1427            ? null
1428            : ReadArrJSON.DimN.objArr(jo.getJsonArray("callFrames"), null, 0, RunTime.CallFrame[].class);
1429            this.parent       = ReadJSON.XL.getObject(jo, "parent", RunTime.StackTrace.class, true, false);
1430            this.parentId     = ReadJSON.XL.getObject(jo, "parentId", RunTime.StackTraceId.class, true, false);
1431        }
1432        
1433    }
1434    
1435    /**
1436     * If <CODE>debuggerId</CODE> is set stack trace comes from another debugger and can be resolved there. This
1437     * allows to track cross-debugger calls. See <CODE>RunTime.StackTrace</CODE> and <CODE>Debugger.paused</CODE> for usages.
1438     * <BR />
1439     * <BR /><B>EXPERIMENTAL</B>
1440     */
1441    public static class StackTraceId extends BaseType
1442    {
1443        /** For Object Serialization.  java.io.Serializable */
1444        protected static final long serialVersionUID = 1;
1445        
1446        public boolean[] optionals()
1447        { return new boolean[] { false, true, }; }
1448        
1449        /** <CODE>[No Description Provided by Google]</CODE> */
1450        public final String id;
1451        
1452        /**
1453         * <CODE>[No Description Provided by Google]</CODE>
1454         * <BR />
1455         * <BR /><B>OPTIONAL</B>
1456         */
1457        public final String debuggerId;
1458        
1459        /**
1460         * Constructor
1461         *
1462         * @param id -
1463         * 
1464         * @param debuggerId -
1465         * <BR /><B>OPTIONAL</B>
1466         */
1467        public StackTraceId(String id, String debuggerId)
1468        {
1469            // Exception-Check(s) to ensure that if any parameters which are not declared as
1470            // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
1471            
1472            if (id == null) BRDPC.throwNPE("id");
1473            
1474            this.id          = id;
1475            this.debuggerId  = debuggerId;
1476        }
1477        
1478        /**
1479         * JSON Object Constructor
1480         * @param jo A Json-Object having data about an instance of {@code 'StackTraceId'}.
1481         */
1482        public StackTraceId (JsonObject jo)
1483        {
1484            this.id          = ReadJSON.getString(jo, "id", false, true);
1485            this.debuggerId  = ReadJSON.getString(jo, "debuggerId", true, false);
1486        }
1487        
1488    }
1489    
1490    /**
1491     * Issued when all executionContexts were cleared in browser
1492     *
1493     * <BR /><BR />This is Marker-Event.  Marker-Event's are Events that do not posses
1494     * any data, fields or state.  When they are fired, only the event name is supplied.
1495     */
1496    public static class executionContextsCleared extends BrowserEvent
1497    {
1498        /** For Object Serialization.  java.io.Serializable */
1499        protected static final long serialVersionUID = 1;
1500    
1501        public boolean[] optionals() { return new boolean[0]; }
1502    
1503        /** JSON Object Constructor */
1504        public executionContextsCleared(JsonObject jo)
1505        { super("RunTime", "executionContextsCleared", 0); }
1506    
1507        @Override
1508        public String toString() { return "RunTime.executionContextsCleared Marker Event\n"; }
1509    }
1510    
1511    /**
1512     * Notification is issued every time when binding is called.
1513     * <BR />
1514     * <BR /><B>EXPERIMENTAL</B>
1515     */
1516    public static class bindingCalled extends BrowserEvent
1517    {
1518        /** For Object Serialization.  java.io.Serializable */
1519        protected static final long serialVersionUID = 1;
1520        
1521        public boolean[] optionals()
1522        { return new boolean[] { false, false, false, }; }
1523        
1524        /** <CODE>[No Description Provided by Google]</CODE> */
1525        public final String name;
1526        
1527        /** <CODE>[No Description Provided by Google]</CODE> */
1528        public final String payload;
1529        
1530        /** Identifier of the context where the call was made. */
1531        public final int executionContextId;
1532        
1533        /**
1534         * Constructor
1535         *
1536         * @param name -
1537         * 
1538         * @param payload -
1539         * 
1540         * @param executionContextId Identifier of the context where the call was made.
1541         */
1542        public bindingCalled(String name, String payload, int executionContextId)
1543        {
1544            super("RunTime", "bindingCalled", 3);
1545            
1546            // Exception-Check(s) to ensure that if any parameters which are not declared as
1547            // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
1548            
1549            if (name == null)    BRDPC.throwNPE("name");
1550            if (payload == null) BRDPC.throwNPE("payload");
1551            
1552            this.name                = name;
1553            this.payload             = payload;
1554            this.executionContextId  = executionContextId;
1555        }
1556        
1557        /**
1558         * JSON Object Constructor
1559         * @param jo A Json-Object having data about an instance of {@code 'bindingCalled'}.
1560         */
1561        public bindingCalled (JsonObject jo)
1562        {
1563            super("RunTime", "bindingCalled", 3);
1564        
1565            this.name                = ReadJSON.getString(jo, "name", false, true);
1566            this.payload             = ReadJSON.getString(jo, "payload", false, true);
1567            this.executionContextId  = ReadJSON.getInt(jo, "executionContextId");
1568        }
1569        
1570    }
1571    
1572    /** Issued when console API was called. */
1573    public static class consoleAPICalled extends BrowserEvent
1574    {
1575        /** For Object Serialization.  java.io.Serializable */
1576        protected static final long serialVersionUID = 1;
1577        
1578        public boolean[] optionals()
1579        { return new boolean[] { false, false, false, false, true, true, }; }
1580        
1581        /** Type of the call. */
1582        public final String type;
1583        
1584        /** Call arguments. */
1585        public final RunTime.RemoteObject[] args;
1586        
1587        /** Identifier of the context where the call was made. */
1588        public final int executionContextId;
1589        
1590        /** Call timestamp. */
1591        public final Number timestamp;
1592        
1593        /**
1594         * Stack trace captured when the call was made. The async stack chain is automatically reported for
1595         * the following call types: <CODE>assert</CODE>, <CODE>error</CODE>, <CODE>trace</CODE>, <CODE>warning</CODE>. For other types the async call
1596         * chain can be retrieved using <CODE>Debugger.getStackTrace</CODE> and <CODE>stackTrace.parentId</CODE> field.
1597         * <BR />
1598         * <BR /><B>OPTIONAL</B>
1599         */
1600        public final RunTime.StackTrace stackTrace;
1601        
1602        /**
1603         * Console context descriptor for calls on non-default console context (not console.*):
1604         * 'anonymous#unique-logger-id' for call on unnamed context, 'name#unique-logger-id' for call
1605         * on named context.
1606         * <BR />
1607         * <BR /><B>OPTIONAL</B>
1608         * <BR /><B>EXPERIMENTAL</B>
1609         */
1610        public final String context;
1611        
1612        /**
1613         * Constructor
1614         *
1615         * @param type Type of the call.
1616         * <BR />Acceptable Values: ["log", "debug", "info", "error", "warning", "dir", "dirxml", "table", "trace", "clear", "startGroup", "startGroupCollapsed", "endGroup", "assert", "profile", "profileEnd", "count", "timeEnd"]
1617         * 
1618         * @param args Call arguments.
1619         * 
1620         * @param executionContextId Identifier of the context where the call was made.
1621         * 
1622         * @param timestamp Call timestamp.
1623         * 
1624         * @param stackTrace 
1625         * Stack trace captured when the call was made. The async stack chain is automatically reported for
1626         * the following call types: <CODE>assert</CODE>, <CODE>error</CODE>, <CODE>trace</CODE>, <CODE>warning</CODE>. For other types the async call
1627         * chain can be retrieved using <CODE>Debugger.getStackTrace</CODE> and <CODE>stackTrace.parentId</CODE> field.
1628         * <BR /><B>OPTIONAL</B>
1629         * 
1630         * @param context 
1631         * Console context descriptor for calls on non-default console context (not console.*):
1632         * 'anonymous#unique-logger-id' for call on unnamed context, 'name#unique-logger-id' for call
1633         * on named context.
1634         * <BR /><B>OPTIONAL</B>
1635         * <BR /><B>EXPERIMENTAL</B>
1636         */
1637        public consoleAPICalled(
1638                String type, RunTime.RemoteObject[] args, int executionContextId, Number timestamp, 
1639                RunTime.StackTrace stackTrace, String context
1640            )
1641        {
1642            super("RunTime", "consoleAPICalled", 6);
1643            
1644            // Exception-Check(s) to ensure that if any parameters which are not declared as
1645            // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
1646            
1647            if (type == null)      BRDPC.throwNPE("type");
1648            if (args == null)      BRDPC.throwNPE("args");
1649            if (timestamp == null) BRDPC.throwNPE("timestamp");
1650            
1651            // Exception-Check(s) to ensure that if any parameters which must adhere to a
1652            // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw.
1653            
1654            BRDPC.checkIAE(
1655                "type", type,
1656                "log", "debug", "info", "error", "warning", "dir", "dirxml", "table", "trace", "clear", "startGroup", "startGroupCollapsed", "endGroup", "assert", "profile", "profileEnd", "count", "timeEnd"
1657            );
1658            
1659            this.type                = type;
1660            this.args                = args;
1661            this.executionContextId  = executionContextId;
1662            this.timestamp           = timestamp;
1663            this.stackTrace          = stackTrace;
1664            this.context             = context;
1665        }
1666        
1667        /**
1668         * JSON Object Constructor
1669         * @param jo A Json-Object having data about an instance of {@code 'consoleAPICalled'}.
1670         */
1671        public consoleAPICalled (JsonObject jo)
1672        {
1673            super("RunTime", "consoleAPICalled", 6);
1674        
1675            this.type                = ReadJSON.getString(jo, "type", false, true);
1676            this.args                = (jo.getJsonArray("args") == null)
1677            ? null
1678            : ReadArrJSON.DimN.objArr(jo.getJsonArray("args"), null, 0, RunTime.RemoteObject[].class);
1679            this.executionContextId  = ReadJSON.getInt(jo, "executionContextId");
1680            this.timestamp           = ReadJSON.getNUMBER(jo, "timestamp", false, true);
1681            this.stackTrace          = ReadJSON.XL.getObject(jo, "stackTrace", RunTime.StackTrace.class, true, false);
1682            this.context             = ReadJSON.getString(jo, "context", true, false);
1683        }
1684        
1685    }
1686    
1687    /** Issued when unhandled exception was revoked. */
1688    public static class exceptionRevoked extends BrowserEvent
1689    {
1690        /** For Object Serialization.  java.io.Serializable */
1691        protected static final long serialVersionUID = 1;
1692        
1693        public boolean[] optionals()
1694        { return new boolean[] { false, false, }; }
1695        
1696        /** Reason describing why exception was revoked. */
1697        public final String reason;
1698        
1699        /** The id of revoked exception, as reported in <CODE>exceptionThrown</CODE>. */
1700        public final int exceptionId;
1701        
1702        /**
1703         * Constructor
1704         *
1705         * @param reason Reason describing why exception was revoked.
1706         * 
1707         * @param exceptionId The id of revoked exception, as reported in <CODE>exceptionThrown</CODE>.
1708         */
1709        public exceptionRevoked(String reason, int exceptionId)
1710        {
1711            super("RunTime", "exceptionRevoked", 2);
1712            
1713            // Exception-Check(s) to ensure that if any parameters which are not declared as
1714            // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
1715            
1716            if (reason == null) BRDPC.throwNPE("reason");
1717            
1718            this.reason       = reason;
1719            this.exceptionId  = exceptionId;
1720        }
1721        
1722        /**
1723         * JSON Object Constructor
1724         * @param jo A Json-Object having data about an instance of {@code 'exceptionRevoked'}.
1725         */
1726        public exceptionRevoked (JsonObject jo)
1727        {
1728            super("RunTime", "exceptionRevoked", 2);
1729        
1730            this.reason       = ReadJSON.getString(jo, "reason", false, true);
1731            this.exceptionId  = ReadJSON.getInt(jo, "exceptionId");
1732        }
1733        
1734    }
1735    
1736    /** Issued when exception was thrown and unhandled. */
1737    public static class exceptionThrown extends BrowserEvent
1738    {
1739        /** For Object Serialization.  java.io.Serializable */
1740        protected static final long serialVersionUID = 1;
1741        
1742        public boolean[] optionals()
1743        { return new boolean[] { false, false, }; }
1744        
1745        /** Timestamp of the exception. */
1746        public final Number timestamp;
1747        
1748        /** <CODE>[No Description Provided by Google]</CODE> */
1749        public final RunTime.ExceptionDetails exceptionDetails;
1750        
1751        /**
1752         * Constructor
1753         *
1754         * @param timestamp Timestamp of the exception.
1755         * 
1756         * @param exceptionDetails -
1757         */
1758        public exceptionThrown(Number timestamp, RunTime.ExceptionDetails exceptionDetails)
1759        {
1760            super("RunTime", "exceptionThrown", 2);
1761            
1762            // Exception-Check(s) to ensure that if any parameters which are not declared as
1763            // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
1764            
1765            if (timestamp == null)        BRDPC.throwNPE("timestamp");
1766            if (exceptionDetails == null) BRDPC.throwNPE("exceptionDetails");
1767            
1768            this.timestamp         = timestamp;
1769            this.exceptionDetails  = exceptionDetails;
1770        }
1771        
1772        /**
1773         * JSON Object Constructor
1774         * @param jo A Json-Object having data about an instance of {@code 'exceptionThrown'}.
1775         */
1776        public exceptionThrown (JsonObject jo)
1777        {
1778            super("RunTime", "exceptionThrown", 2);
1779        
1780            this.timestamp         = ReadJSON.getNUMBER(jo, "timestamp", false, true);
1781            this.exceptionDetails  = ReadJSON.XL.getObject(jo, "exceptionDetails", RunTime.ExceptionDetails.class, false, true);
1782        }
1783        
1784    }
1785    
1786    /** Issued when new execution context is created. */
1787    public static class executionContextCreated extends BrowserEvent
1788    {
1789        /** For Object Serialization.  java.io.Serializable */
1790        protected static final long serialVersionUID = 1;
1791        
1792        public boolean[] optionals()
1793        { return new boolean[] { false, }; }
1794        
1795        /** A newly created execution context. */
1796        public final RunTime.ExecutionContextDescription context;
1797        
1798        /**
1799         * Constructor
1800         *
1801         * @param context A newly created execution context.
1802         */
1803        public executionContextCreated(RunTime.ExecutionContextDescription context)
1804        {
1805            super("RunTime", "executionContextCreated", 1);
1806            
1807            // Exception-Check(s) to ensure that if any parameters which are not declared as
1808            // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
1809            
1810            if (context == null) BRDPC.throwNPE("context");
1811            
1812            this.context  = context;
1813        }
1814        
1815        /**
1816         * JSON Object Constructor
1817         * @param jo A Json-Object having data about an instance of {@code 'executionContextCreated'}.
1818         */
1819        public executionContextCreated (JsonObject jo)
1820        {
1821            super("RunTime", "executionContextCreated", 1);
1822        
1823            this.context  = ReadJSON.XL.getObject(jo, "context", RunTime.ExecutionContextDescription.class, false, true);
1824        }
1825        
1826    }
1827    
1828    /** Issued when execution context is destroyed. */
1829    public static class executionContextDestroyed extends BrowserEvent
1830    {
1831        /** For Object Serialization.  java.io.Serializable */
1832        protected static final long serialVersionUID = 1;
1833        
1834        public boolean[] optionals()
1835        { return new boolean[] { false, }; }
1836        
1837        /** Id of the destroyed context */
1838        public final int executionContextId;
1839        
1840        /**
1841         * Constructor
1842         *
1843         * @param executionContextId Id of the destroyed context
1844         */
1845        public executionContextDestroyed(int executionContextId)
1846        {
1847            super("RunTime", "executionContextDestroyed", 1);
1848            
1849            this.executionContextId  = executionContextId;
1850        }
1851        
1852        /**
1853         * JSON Object Constructor
1854         * @param jo A Json-Object having data about an instance of {@code 'executionContextDestroyed'}.
1855         */
1856        public executionContextDestroyed (JsonObject jo)
1857        {
1858            super("RunTime", "executionContextDestroyed", 1);
1859        
1860            this.executionContextId  = ReadJSON.getInt(jo, "executionContextId");
1861        }
1862        
1863    }
1864    
1865    /**
1866     * Issued when object should be inspected (for example, as a result of inspect() command line API
1867     * call).
1868     */
1869    public static class inspectRequested extends BrowserEvent
1870    {
1871        /** For Object Serialization.  java.io.Serializable */
1872        protected static final long serialVersionUID = 1;
1873        
1874        public boolean[] optionals()
1875        { return new boolean[] { false, false, true, }; }
1876        
1877        /** <CODE>[No Description Provided by Google]</CODE> */
1878        public final RunTime.RemoteObject object;
1879        
1880        /** <CODE>[No Description Provided by Google]</CODE> */
1881        public final JsonObject hints;
1882        
1883        /**
1884         * Identifier of the context where the call was made.
1885         * <BR />
1886         * <BR /><B>OPTIONAL</B>
1887         * <BR /><B>EXPERIMENTAL</B>
1888         */
1889        public final Integer executionContextId;
1890        
1891        /**
1892         * Constructor
1893         *
1894         * @param object -
1895         * 
1896         * @param hints -
1897         * 
1898         * @param executionContextId Identifier of the context where the call was made.
1899         * <BR /><B>OPTIONAL</B>
1900         * <BR /><B>EXPERIMENTAL</B>
1901         */
1902        public inspectRequested
1903            (RunTime.RemoteObject object, JsonObject hints, Integer executionContextId)
1904        {
1905            super("RunTime", "inspectRequested", 3);
1906            
1907            // Exception-Check(s) to ensure that if any parameters which are not declared as
1908            // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
1909            
1910            if (object == null) BRDPC.throwNPE("object");
1911            if (hints == null)  BRDPC.throwNPE("hints");
1912            
1913            this.object              = object;
1914            this.hints               = hints;
1915            this.executionContextId  = executionContextId;
1916        }
1917        
1918        /**
1919         * JSON Object Constructor
1920         * @param jo A Json-Object having data about an instance of {@code 'inspectRequested'}.
1921         */
1922        public inspectRequested (JsonObject jo)
1923        {
1924            super("RunTime", "inspectRequested", 3);
1925        
1926            this.object              = ReadJSON.XL.getObject(jo, "object", RunTime.RemoteObject.class, false, true);
1927            this.hints               = jo.getJsonObject("hints");
1928            this.executionContextId  = ReadJSON.getINTEGER(jo, "executionContextId", true);
1929        }
1930        
1931    }
1932    
1933    
1934    // Counter for keeping the WebSocket Request ID's distinct.
1935    private static int counter = 1;
1936    
1937    /**
1938     * Add handler to promise with given promise object id.
1939     * 
1940     * @param promiseObjectId Identifier of the promise.
1941     * 
1942     * @param returnByValue Whether the result is expected to be a JSON object that should be sent by value.
1943     * <BR /><B>OPTIONAL</B>
1944     * 
1945     * @param generatePreview Whether preview should be generated for the result.
1946     * <BR /><B>OPTIONAL</B>
1947     * 
1948     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
1949     * {@link Ret2}&gt;</CODE>
1950     *
1951     * <BR /><BR />This {@link Script} may be <B STYLE='color:red'>executed</B> (using 
1952     * {@link Script#exec()}), and a {@link Promise} returned.
1953     *
1954     * <BR /><BR />When the {@code Promise} is <B STYLE='color: red'>awaited</B>
1955     * (using {@link Promise#await()}), the {@code Ret2} will subsequently
1956     * be returned from that call.
1957     * 
1958     * <BR /><BR />The <B STYLE='color: red'>returned</B> values are encapsulated
1959     * in an instance of <B>{@link Ret2}</B>
1960     *
1961     * <BR /><BR /><UL CLASS=JDUL>
1962     * <LI><CODE><B>Ret2.a:</B> {@link RunTime.RemoteObject} (<B>result</B>)</CODE>
1963     *     <BR />Promise result. Will contain rejected value if promise was rejected.
1964     *     <BR /><BR /></LI>
1965     * <LI><CODE><B>Ret2.b:</B> {@link RunTime.ExceptionDetails} (<B>exceptionDetails</B>)</CODE>
1966     *     <BR />Exception details if stack strace is available.
1967     *     </LI>
1968     * </UL>
1969     */
1970    public static Script<String, JsonObject, Ret2<RunTime.RemoteObject, RunTime.ExceptionDetails>> awaitPromise
1971        (String promiseObjectId, Boolean returnByValue, Boolean generatePreview)
1972    {
1973        // Exception-Check(s) to ensure that if any parameters which are not declared as
1974        // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
1975        
1976        if (promiseObjectId == null) BRDPC.throwNPE("promiseObjectId");
1977        
1978        final int       webSocketID = 5000000 + counter++;
1979        final boolean[] optionals   = { false, true, true, };
1980        
1981        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
1982        String requestJSON = WriteJSON.get(
1983            parameterTypes.get("awaitPromise"),
1984            parameterNames.get("awaitPromise"),
1985            optionals, webSocketID,
1986            "RunTime.awaitPromise",
1987            promiseObjectId, returnByValue, generatePreview
1988        );
1989        
1990        // 'JSON Binding' ... Converts Browser Response-JSON into Java-Type 'Ret2'
1991        Function<JsonObject, Ret2<RunTime.RemoteObject, RunTime.ExceptionDetails>> 
1992            responseProcessor = (JsonObject jo) -> new Ret2<>(
1993                ReadJSON.XL.getObject(jo, "result", RunTime.RemoteObject.class, false, true),
1994                ReadJSON.XL.getObject(jo, "exceptionDetails", RunTime.ExceptionDetails.class, true, false)
1995            );
1996        
1997        // Pass the 'defaultSender' to Script-Constructor
1998        // The sender that is used can be changed before executing script.
1999        return new Script<>(BRDPC.defaultSender, webSocketID, requestJSON, responseProcessor);
2000    }
2001    
2002    /**
2003     * Calls function with given declaration on the given object. Object group of the result is
2004     * inherited from the target object.
2005     * 
2006     * @param functionDeclaration Declaration of the function to call.
2007     * 
2008     * @param objectId 
2009     * Identifier of the object to call function on. Either objectId or executionContextId should
2010     * be specified.
2011     * <BR /><B>OPTIONAL</B>
2012     * 
2013     * @param arguments 
2014     * Call arguments. All call arguments must belong to the same JavaScript world as the target
2015     * object.
2016     * <BR /><B>OPTIONAL</B>
2017     * 
2018     * @param silent 
2019     * In silent mode exceptions thrown during evaluation are not reported and do not pause
2020     * execution. Overrides <CODE>setPauseOnException</CODE> state.
2021     * <BR /><B>OPTIONAL</B>
2022     * 
2023     * @param returnByValue Whether the result is expected to be a JSON object which should be sent by value.
2024     * <BR /><B>OPTIONAL</B>
2025     * 
2026     * @param generatePreview Whether preview should be generated for the result.
2027     * <BR /><B>OPTIONAL</B>
2028     * <BR /><B>EXPERIMENTAL</B>
2029     * 
2030     * @param userGesture Whether execution should be treated as initiated by user in the UI.
2031     * <BR /><B>OPTIONAL</B>
2032     * 
2033     * @param awaitPromise 
2034     * Whether execution should <CODE>await</CODE> for resulting value and return once awaited promise is
2035     * resolved.
2036     * <BR /><B>OPTIONAL</B>
2037     * 
2038     * @param executionContextId 
2039     * Specifies execution context which global object will be used to call function on. Either
2040     * executionContextId or objectId should be specified.
2041     * <BR /><B>OPTIONAL</B>
2042     * 
2043     * @param objectGroup 
2044     * Symbolic group name that can be used to release multiple objects. If objectGroup is not
2045     * specified and objectId is, objectGroup will be inherited from object.
2046     * <BR /><B>OPTIONAL</B>
2047     * 
2048     * @param throwOnSideEffect Whether to throw an exception if side effect cannot be ruled out during evaluation.
2049     * <BR /><B>OPTIONAL</B>
2050     * <BR /><B>EXPERIMENTAL</B>
2051     * 
2052     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
2053     * {@link Ret2}&gt;</CODE>
2054     *
2055     * <BR /><BR />This {@link Script} may be <B STYLE='color:red'>executed</B> (using 
2056     * {@link Script#exec()}), and a {@link Promise} returned.
2057     *
2058     * <BR /><BR />When the {@code Promise} is <B STYLE='color: red'>awaited</B>
2059     * (using {@link Promise#await()}), the {@code Ret2} will subsequently
2060     * be returned from that call.
2061     * 
2062     * <BR /><BR />The <B STYLE='color: red'>returned</B> values are encapsulated
2063     * in an instance of <B>{@link Ret2}</B>
2064     *
2065     * <BR /><BR /><UL CLASS=JDUL>
2066     * <LI><CODE><B>Ret2.a:</B> {@link RunTime.RemoteObject} (<B>result</B>)</CODE>
2067     *     <BR />Call result.
2068     *     <BR /><BR /></LI>
2069     * <LI><CODE><B>Ret2.b:</B> {@link RunTime.ExceptionDetails} (<B>exceptionDetails</B>)</CODE>
2070     *     <BR />Exception details.
2071     *     </LI>
2072     * </UL>
2073     */
2074    public static Script<String, JsonObject, Ret2<RunTime.RemoteObject, RunTime.ExceptionDetails>> callFunctionOn(
2075            String functionDeclaration, String objectId, RunTime.CallArgument[] arguments, 
2076            Boolean silent, Boolean returnByValue, Boolean generatePreview, Boolean userGesture, 
2077            Boolean awaitPromise, Integer executionContextId, String objectGroup, 
2078            Boolean throwOnSideEffect
2079        )
2080    {
2081        // Exception-Check(s) to ensure that if any parameters which are not declared as
2082        // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
2083        
2084        if (functionDeclaration == null) BRDPC.throwNPE("functionDeclaration");
2085        
2086        final int       webSocketID = 5001000 + counter++;
2087        final boolean[] optionals   = { false, true, true, true, true, true, true, true, true, true, true, };
2088        
2089        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
2090        String requestJSON = WriteJSON.get(
2091            parameterTypes.get("callFunctionOn"),
2092            parameterNames.get("callFunctionOn"),
2093            optionals, webSocketID,
2094            "RunTime.callFunctionOn",
2095            functionDeclaration, objectId, arguments, silent, returnByValue, generatePreview,
2096            userGesture, awaitPromise, executionContextId, objectGroup, throwOnSideEffect
2097        );
2098        
2099        // 'JSON Binding' ... Converts Browser Response-JSON into Java-Type 'Ret2'
2100        Function<JsonObject, Ret2<RunTime.RemoteObject, RunTime.ExceptionDetails>> 
2101            responseProcessor = (JsonObject jo) -> new Ret2<>(
2102                ReadJSON.XL.getObject(jo, "result", RunTime.RemoteObject.class, false, true),
2103                ReadJSON.XL.getObject(jo, "exceptionDetails", RunTime.ExceptionDetails.class, true, false)
2104            );
2105        
2106        // Pass the 'defaultSender' to Script-Constructor
2107        // The sender that is used can be changed before executing script.
2108        return new Script<>(BRDPC.defaultSender, webSocketID, requestJSON, responseProcessor);
2109    }
2110    
2111    /**
2112     * Compiles expression.
2113     * 
2114     * @param expression Expression to compile.
2115     * 
2116     * @param sourceURL Source url to be set for the script.
2117     * 
2118     * @param persistScript Specifies whether the compiled script should be persisted.
2119     * 
2120     * @param executionContextId 
2121     * Specifies in which execution context to perform script run. If the parameter is omitted the
2122     * evaluation will be performed in the context of the inspected page.
2123     * <BR /><B>OPTIONAL</B>
2124     * 
2125     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
2126     * {@link Ret2}&gt;</CODE>
2127     *
2128     * <BR /><BR />This {@link Script} may be <B STYLE='color:red'>executed</B> (using 
2129     * {@link Script#exec()}), and a {@link Promise} returned.
2130     *
2131     * <BR /><BR />When the {@code Promise} is <B STYLE='color: red'>awaited</B>
2132     * (using {@link Promise#await()}), the {@code Ret2} will subsequently
2133     * be returned from that call.
2134     * 
2135     * <BR /><BR />The <B STYLE='color: red'>returned</B> values are encapsulated
2136     * in an instance of <B>{@link Ret2}</B>
2137     *
2138     * <BR /><BR /><UL CLASS=JDUL>
2139     * <LI><CODE><B>Ret2.a:</B> String (<B>scriptId</B>)</CODE>
2140     *     <BR />Id of the script.
2141     *     <BR /><BR /></LI>
2142     * <LI><CODE><B>Ret2.b:</B> {@link RunTime.ExceptionDetails} (<B>exceptionDetails</B>)</CODE>
2143     *     <BR />Exception details.
2144     *     </LI>
2145     * </UL>
2146     */
2147    public static Script<String, JsonObject, Ret2<String, RunTime.ExceptionDetails>> compileScript
2148        (String expression, String sourceURL, boolean persistScript, Integer executionContextId)
2149    {
2150        // Exception-Check(s) to ensure that if any parameters which are not declared as
2151        // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
2152        
2153        if (expression == null) BRDPC.throwNPE("expression");
2154        if (sourceURL == null)  BRDPC.throwNPE("sourceURL");
2155        
2156        final int       webSocketID = 5002000 + counter++;
2157        final boolean[] optionals   = { false, false, false, true, };
2158        
2159        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
2160        String requestJSON = WriteJSON.get(
2161            parameterTypes.get("compileScript"),
2162            parameterNames.get("compileScript"),
2163            optionals, webSocketID,
2164            "RunTime.compileScript",
2165            expression, sourceURL, persistScript, executionContextId
2166        );
2167        
2168        // 'JSON Binding' ... Converts Browser Response-JSON into Java-Type 'Ret2'
2169        Function<JsonObject, Ret2<String, RunTime.ExceptionDetails>> 
2170            responseProcessor = (JsonObject jo) -> new Ret2<>(
2171                ReadJSON.getString(jo, "scriptId", true, false),
2172                ReadJSON.XL.getObject(jo, "exceptionDetails", RunTime.ExceptionDetails.class, true, false)
2173            );
2174        
2175        // Pass the 'defaultSender' to Script-Constructor
2176        // The sender that is used can be changed before executing script.
2177        return new Script<>(BRDPC.defaultSender, webSocketID, requestJSON, responseProcessor);
2178    }
2179    
2180    /**
2181     * Disables reporting of execution contexts creation.
2182     * 
2183     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
2184     * {@link Ret0}&gt;</CODE>
2185     *
2186     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
2187     * browser receives the invocation-request.
2188     *
2189     * <BR /><BR />This Browser-Function <I>does not have</I> a return-value.  You may choose to
2190     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0}
2191     * {@code >} to ensure the Browser Function has run to completion.
2192     */
2193    public static Script<String, JsonObject, Ret0> disable()
2194    {
2195        final int          webSocketID = 5003000 + counter++;
2196        final boolean[]    optionals   = new boolean[0];
2197        
2198        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
2199        String requestJSON = WriteJSON.get(
2200            parameterTypes.get("disable"),
2201            parameterNames.get("disable"),
2202            optionals, webSocketID,
2203            "RunTime.disable"
2204        );
2205        
2206        // This Remote Command does not have a Return-Value.
2207        return new Script<>
2208            (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues);
2209    }
2210    
2211    /**
2212     * Discards collected exceptions and console API calls.
2213     * 
2214     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
2215     * {@link Ret0}&gt;</CODE>
2216     *
2217     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
2218     * browser receives the invocation-request.
2219     *
2220     * <BR /><BR />This Browser-Function <I>does not have</I> a return-value.  You may choose to
2221     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0}
2222     * {@code >} to ensure the Browser Function has run to completion.
2223     */
2224    public static Script<String, JsonObject, Ret0> discardConsoleEntries()
2225    {
2226        final int          webSocketID = 5004000 + counter++;
2227        final boolean[]    optionals   = new boolean[0];
2228        
2229        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
2230        String requestJSON = WriteJSON.get(
2231            parameterTypes.get("discardConsoleEntries"),
2232            parameterNames.get("discardConsoleEntries"),
2233            optionals, webSocketID,
2234            "RunTime.discardConsoleEntries"
2235        );
2236        
2237        // This Remote Command does not have a Return-Value.
2238        return new Script<>
2239            (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues);
2240    }
2241    
2242    /**
2243     * Enables reporting of execution contexts creation by means of <CODE>executionContextCreated</CODE> event.
2244     * When the reporting gets enabled the event will be sent immediately for each existing execution
2245     * context.
2246     * 
2247     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
2248     * {@link Ret0}&gt;</CODE>
2249     *
2250     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
2251     * browser receives the invocation-request.
2252     *
2253     * <BR /><BR />This Browser-Function <I>does not have</I> a return-value.  You may choose to
2254     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0}
2255     * {@code >} to ensure the Browser Function has run to completion.
2256     */
2257    public static Script<String, JsonObject, Ret0> enable()
2258    {
2259        final int          webSocketID = 5005000 + counter++;
2260        final boolean[]    optionals   = new boolean[0];
2261        
2262        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
2263        String requestJSON = WriteJSON.get(
2264            parameterTypes.get("enable"),
2265            parameterNames.get("enable"),
2266            optionals, webSocketID,
2267            "RunTime.enable"
2268        );
2269        
2270        // This Remote Command does not have a Return-Value.
2271        return new Script<>
2272            (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues);
2273    }
2274    
2275    /**
2276     * Evaluates expression on global object.
2277     * 
2278     * @param expression Expression to evaluate.
2279     * 
2280     * @param objectGroup Symbolic group name that can be used to release multiple objects.
2281     * <BR /><B>OPTIONAL</B>
2282     * 
2283     * @param includeCommandLineAPI Determines whether Command Line API should be available during the evaluation.
2284     * <BR /><B>OPTIONAL</B>
2285     * 
2286     * @param silent 
2287     * In silent mode exceptions thrown during evaluation are not reported and do not pause
2288     * execution. Overrides <CODE>setPauseOnException</CODE> state.
2289     * <BR /><B>OPTIONAL</B>
2290     * 
2291     * @param contextId 
2292     * Specifies in which execution context to perform evaluation. If the parameter is omitted the
2293     * evaluation will be performed in the context of the inspected page.
2294     * This is mutually exclusive with <CODE>uniqueContextId</CODE>, which offers an
2295     * alternative way to identify the execution context that is more reliable
2296     * in a multi-process environment.
2297     * <BR /><B>OPTIONAL</B>
2298     * 
2299     * @param returnByValue Whether the result is expected to be a JSON object that should be sent by value.
2300     * <BR /><B>OPTIONAL</B>
2301     * 
2302     * @param generatePreview Whether preview should be generated for the result.
2303     * <BR /><B>OPTIONAL</B>
2304     * <BR /><B>EXPERIMENTAL</B>
2305     * 
2306     * @param userGesture Whether execution should be treated as initiated by user in the UI.
2307     * <BR /><B>OPTIONAL</B>
2308     * 
2309     * @param awaitPromise 
2310     * Whether execution should <CODE>await</CODE> for resulting value and return once awaited promise is
2311     * resolved.
2312     * <BR /><B>OPTIONAL</B>
2313     * 
2314     * @param throwOnSideEffect 
2315     * Whether to throw an exception if side effect cannot be ruled out during evaluation.
2316     * This implies <CODE>disableBreaks</CODE> below.
2317     * <BR /><B>OPTIONAL</B>
2318     * <BR /><B>EXPERIMENTAL</B>
2319     * 
2320     * @param timeout Terminate execution after timing out (number of milliseconds).
2321     * <BR /><B>OPTIONAL</B>
2322     * <BR /><B>EXPERIMENTAL</B>
2323     * 
2324     * @param disableBreaks Disable breakpoints during execution.
2325     * <BR /><B>OPTIONAL</B>
2326     * <BR /><B>EXPERIMENTAL</B>
2327     * 
2328     * @param replMode 
2329     * Setting this flag to true enables <CODE>let</CODE> re-declaration and top-level <CODE>await</CODE>.
2330     * Note that <CODE>let</CODE> variables can only be re-declared if they originate from
2331     * <CODE>replMode</CODE> themselves.
2332     * <BR /><B>OPTIONAL</B>
2333     * <BR /><B>EXPERIMENTAL</B>
2334     * 
2335     * @param allowUnsafeEvalBlockedByCSP 
2336     * The Content Security Policy (CSP) for the target might block 'unsafe-eval'
2337     * which includes eval(), Function(), setTimeout() and setInterval()
2338     * when called with non-callable arguments. This flag bypasses CSP for this
2339     * evaluation and allows unsafe-eval. Defaults to true.
2340     * <BR /><B>OPTIONAL</B>
2341     * <BR /><B>EXPERIMENTAL</B>
2342     * 
2343     * @param uniqueContextId 
2344     * An alternative way to specify the execution context to evaluate in.
2345     * Compared to contextId that may be reused across processes, this is guaranteed to be
2346     * system-unique, so it can be used to prevent accidental evaluation of the expression
2347     * in context different than intended (e.g. as a result of navigation across process
2348     * boundaries).
2349     * This is mutually exclusive with <CODE>contextId</CODE>.
2350     * <BR /><B>OPTIONAL</B>
2351     * <BR /><B>EXPERIMENTAL</B>
2352     * 
2353     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
2354     * {@link Ret2}&gt;</CODE>
2355     *
2356     * <BR /><BR />This {@link Script} may be <B STYLE='color:red'>executed</B> (using 
2357     * {@link Script#exec()}), and a {@link Promise} returned.
2358     *
2359     * <BR /><BR />When the {@code Promise} is <B STYLE='color: red'>awaited</B>
2360     * (using {@link Promise#await()}), the {@code Ret2} will subsequently
2361     * be returned from that call.
2362     * 
2363     * <BR /><BR />The <B STYLE='color: red'>returned</B> values are encapsulated
2364     * in an instance of <B>{@link Ret2}</B>
2365     *
2366     * <BR /><BR /><UL CLASS=JDUL>
2367     * <LI><CODE><B>Ret2.a:</B> {@link RunTime.RemoteObject} (<B>result</B>)</CODE>
2368     *     <BR />Evaluation result.
2369     *     <BR /><BR /></LI>
2370     * <LI><CODE><B>Ret2.b:</B> {@link RunTime.ExceptionDetails} (<B>exceptionDetails</B>)</CODE>
2371     *     <BR />Exception details.
2372     *     </LI>
2373     * </UL>
2374     */
2375    public static Script<String, JsonObject, Ret2<RunTime.RemoteObject, RunTime.ExceptionDetails>> evaluate(
2376            String expression, String objectGroup, Boolean includeCommandLineAPI, Boolean silent, 
2377            Integer contextId, Boolean returnByValue, Boolean generatePreview, Boolean userGesture, 
2378            Boolean awaitPromise, Boolean throwOnSideEffect, Number timeout, Boolean disableBreaks, 
2379            Boolean replMode, Boolean allowUnsafeEvalBlockedByCSP, String uniqueContextId
2380        )
2381    {
2382        // Exception-Check(s) to ensure that if any parameters which are not declared as
2383        // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
2384        
2385        if (expression == null) BRDPC.throwNPE("expression");
2386        
2387        final int       webSocketID = 5006000 + counter++;
2388        final boolean[] optionals   = { false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, };
2389        
2390        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
2391        String requestJSON = WriteJSON.get(
2392            parameterTypes.get("evaluate"),
2393            parameterNames.get("evaluate"),
2394            optionals, webSocketID,
2395            "RunTime.evaluate",
2396            expression, objectGroup, includeCommandLineAPI, silent, contextId, returnByValue,
2397            generatePreview, userGesture, awaitPromise, throwOnSideEffect, timeout, disableBreaks,
2398            replMode, allowUnsafeEvalBlockedByCSP, uniqueContextId
2399        );
2400        
2401        // 'JSON Binding' ... Converts Browser Response-JSON into Java-Type 'Ret2'
2402        Function<JsonObject, Ret2<RunTime.RemoteObject, RunTime.ExceptionDetails>> 
2403            responseProcessor = (JsonObject jo) -> new Ret2<>(
2404                ReadJSON.XL.getObject(jo, "result", RunTime.RemoteObject.class, false, true),
2405                ReadJSON.XL.getObject(jo, "exceptionDetails", RunTime.ExceptionDetails.class, true, false)
2406            );
2407        
2408        // Pass the 'defaultSender' to Script-Constructor
2409        // The sender that is used can be changed before executing script.
2410        return new Script<>(BRDPC.defaultSender, webSocketID, requestJSON, responseProcessor);
2411    }
2412    
2413    /**
2414     * Returns the isolate id.
2415     * <BR /><B>EXPERIMENTAL</B>
2416     * 
2417     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
2418     * String&gt;</CODE>
2419     * 
2420     * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using
2421     * {@link Script#exec()}, and afterwards, a {@link Promise}<CODE>&lt;JsonObject,
2422     * String&gt;</CODE> will be returned.
2423     *
2424     * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>,
2425     * using {@link Promise#await()}, <I>and the returned result of this Browser Function may
2426      * may be retrieved.</I>
2427     *
2428     * <BR /><BR />This Browser Function <B STYLE='color: red'>returns</B>
2429     * <BR /><BR /><UL CLASS=JDUL>
2430     * <LI><CODE>String (<B>id</B></CODE>)
2431     *     <BR />The isolate id.
2432     * </LI>
2433     * </UL> */
2434    public static Script<String, JsonObject, String> getIsolateId()
2435    {
2436        final int          webSocketID = 5007000 + counter++;
2437        final boolean[]    optionals   = new boolean[0];
2438        
2439        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
2440        String requestJSON = WriteJSON.get(
2441            parameterTypes.get("getIsolateId"),
2442            parameterNames.get("getIsolateId"),
2443            optionals, webSocketID,
2444            "RunTime.getIsolateId"
2445        );
2446        
2447        // 'JSON Binding' ... Converts Browser Response-JSON to 'String'
2448        Function<JsonObject, String> responseProcessor = (JsonObject jo) ->
2449            ReadJSON.getString(jo, "id", false, true);
2450        
2451        // Pass the 'defaultSender' to Script-Constructor
2452        // The sender that is used can be changed before executing script.
2453        return new Script<>(BRDPC.defaultSender, webSocketID, requestJSON, responseProcessor);
2454    }
2455    
2456    /**
2457     * Returns the JavaScript heap usage.
2458     * It is the total usage of the corresponding isolate not scoped to a particular RunTime.
2459     * <BR /><B>EXPERIMENTAL</B>
2460     * 
2461     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
2462     * {@link Ret2}&gt;</CODE>
2463     *
2464     * <BR /><BR />This {@link Script} may be <B STYLE='color:red'>executed</B> (using 
2465     * {@link Script#exec()}), and a {@link Promise} returned.
2466     *
2467     * <BR /><BR />When the {@code Promise} is <B STYLE='color: red'>awaited</B>
2468     * (using {@link Promise#await()}), the {@code Ret2} will subsequently
2469     * be returned from that call.
2470     * 
2471     * <BR /><BR />The <B STYLE='color: red'>returned</B> values are encapsulated
2472     * in an instance of <B>{@link Ret2}</B>
2473     *
2474     * <BR /><BR /><UL CLASS=JDUL>
2475     * <LI><CODE><B>Ret2.a:</B> Number (<B>usedSize</B>)</CODE>
2476     *     <BR />Used heap size in bytes.
2477     *     <BR /><BR /></LI>
2478     * <LI><CODE><B>Ret2.b:</B> Number (<B>totalSize</B>)</CODE>
2479     *     <BR />Allocated heap size in bytes.
2480     *     </LI>
2481     * </UL>
2482     */
2483    public static Script<String, JsonObject, Ret2<Number, Number>> getHeapUsage()
2484    {
2485        final int          webSocketID = 5008000 + counter++;
2486        final boolean[]    optionals   = new boolean[0];
2487        
2488        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
2489        String requestJSON = WriteJSON.get(
2490            parameterTypes.get("getHeapUsage"),
2491            parameterNames.get("getHeapUsage"),
2492            optionals, webSocketID,
2493            "RunTime.getHeapUsage"
2494        );
2495        
2496        // 'JSON Binding' ... Converts Browser Response-JSON into Java-Type 'Ret2'
2497        Function<JsonObject, Ret2<Number, Number>> 
2498            responseProcessor = (JsonObject jo) -> new Ret2<>(
2499                ReadJSON.getNUMBER(jo, "usedSize", false, true),
2500                ReadJSON.getNUMBER(jo, "totalSize", false, true)
2501            );
2502        
2503        // Pass the 'defaultSender' to Script-Constructor
2504        // The sender that is used can be changed before executing script.
2505        return new Script<>(BRDPC.defaultSender, webSocketID, requestJSON, responseProcessor);
2506    }
2507    
2508    /**
2509     * Returns properties of a given object. Object group of the result is inherited from the target
2510     * object.
2511     * 
2512     * @param objectId Identifier of the object to return properties for.
2513     * 
2514     * @param ownProperties 
2515     * If true, returns properties belonging only to the element itself, not to its prototype
2516     * chain.
2517     * <BR /><B>OPTIONAL</B>
2518     * 
2519     * @param accessorPropertiesOnly 
2520     * If true, returns accessor properties (with getter/setter) only; internal properties are not
2521     * returned either.
2522     * <BR /><B>OPTIONAL</B>
2523     * <BR /><B>EXPERIMENTAL</B>
2524     * 
2525     * @param generatePreview Whether preview should be generated for the results.
2526     * <BR /><B>OPTIONAL</B>
2527     * <BR /><B>EXPERIMENTAL</B>
2528     * 
2529     * @param nonIndexedPropertiesOnly If true, returns non-indexed properties only.
2530     * <BR /><B>OPTIONAL</B>
2531     * <BR /><B>EXPERIMENTAL</B>
2532     * 
2533     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
2534     * {@link Ret4}&gt;</CODE>
2535     *
2536     * <BR /><BR />This {@link Script} may be <B STYLE='color:red'>executed</B> (using 
2537     * {@link Script#exec()}), and a {@link Promise} returned.
2538     *
2539     * <BR /><BR />When the {@code Promise} is <B STYLE='color: red'>awaited</B>
2540     * (using {@link Promise#await()}), the {@code Ret4} will subsequently
2541     * be returned from that call.
2542     * 
2543     * <BR /><BR />The <B STYLE='color: red'>returned</B> values are encapsulated
2544     * in an instance of <B>{@link Ret4}</B>
2545     *
2546     * <BR /><BR /><UL CLASS=JDUL>
2547     * <LI><CODE><B>Ret4.a:</B> {@link RunTime.PropertyDescriptor}[] (<B>result</B>)</CODE>
2548     *     <BR />Object properties.
2549     *     <BR /><BR /></LI>
2550     * <LI><CODE><B>Ret4.b:</B> {@link RunTime.InternalPropertyDescriptor}[] (<B>internalProperties</B>)</CODE>
2551     *     <BR />Internal object properties (only of the element itself).
2552     *     <BR /><BR /></LI>
2553     * <LI><CODE><B>Ret4.c:</B> {@link RunTime.PrivatePropertyDescriptor}[] (<B>privateProperties</B>)</CODE>
2554     *     <BR />Object private properties.
2555     *     <BR /><BR /></LI>
2556     * <LI><CODE><B>Ret4.d:</B> {@link RunTime.ExceptionDetails} (<B>exceptionDetails</B>)</CODE>
2557     *     <BR />Exception details.
2558     *     </LI>
2559     * </UL>
2560     */
2561    public static Script<String, JsonObject, Ret4<RunTime.PropertyDescriptor[], RunTime.InternalPropertyDescriptor[], RunTime.PrivatePropertyDescriptor[], RunTime.ExceptionDetails>> 
2562        getProperties(
2563            String objectId, Boolean ownProperties, Boolean accessorPropertiesOnly, 
2564            Boolean generatePreview, Boolean nonIndexedPropertiesOnly
2565        )
2566    {
2567        // Exception-Check(s) to ensure that if any parameters which are not declared as
2568        // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
2569        
2570        if (objectId == null) BRDPC.throwNPE("objectId");
2571        
2572        final int       webSocketID = 5009000 + counter++;
2573        final boolean[] optionals   = { false, true, true, true, true, };
2574        
2575        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
2576        String requestJSON = WriteJSON.get(
2577            parameterTypes.get("getProperties"),
2578            parameterNames.get("getProperties"),
2579            optionals, webSocketID,
2580            "RunTime.getProperties",
2581            objectId, ownProperties, accessorPropertiesOnly, generatePreview,
2582            nonIndexedPropertiesOnly
2583        );
2584        
2585        // 'JSON Binding' ... Converts Browser Response-JSON into Java-Type 'Ret4'
2586        Function<JsonObject, Ret4<RunTime.PropertyDescriptor[], RunTime.InternalPropertyDescriptor[], RunTime.PrivatePropertyDescriptor[], RunTime.ExceptionDetails>> 
2587            responseProcessor = (JsonObject jo) -> new Ret4<>(
2588                (jo.getJsonArray("result") == null)
2589                    ? null
2590                    : ReadArrJSON.DimN.objArr(jo.getJsonArray("result"), null, 0, RunTime.PropertyDescriptor[].class),
2591                (jo.getJsonArray("internalProperties") == null)
2592                    ? null
2593                    : ReadArrJSON.DimN.objArr(jo.getJsonArray("internalProperties"), null, 0, RunTime.InternalPropertyDescriptor[].class),
2594                (jo.getJsonArray("privateProperties") == null)
2595                    ? null
2596                    : ReadArrJSON.DimN.objArr(jo.getJsonArray("privateProperties"), null, 0, RunTime.PrivatePropertyDescriptor[].class),
2597                ReadJSON.XL.getObject(jo, "exceptionDetails", RunTime.ExceptionDetails.class, true, false)
2598            );
2599        
2600        // Pass the 'defaultSender' to Script-Constructor
2601        // The sender that is used can be changed before executing script.
2602        return new Script<>(BRDPC.defaultSender, webSocketID, requestJSON, responseProcessor);
2603    }
2604    
2605    /**
2606     * Returns all let, const and class variables from global scope.
2607     * 
2608     * @param executionContextId Specifies in which execution context to lookup global scope variables.
2609     * <BR /><B>OPTIONAL</B>
2610     * 
2611     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
2612     * String[]&gt;</CODE>
2613     * 
2614     * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using
2615     * {@link Script#exec()}, and afterwards, a {@link Promise}<CODE>&lt;JsonObject,
2616     * String[]&gt;</CODE> will be returned.
2617     *
2618     * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>,
2619     * using {@link Promise#await()}, <I>and the returned result of this Browser Function may
2620      * may be retrieved.</I>
2621     *
2622     * <BR /><BR />This Browser Function <B STYLE='color: red'>returns</B>
2623     * <BR /><BR /><UL CLASS=JDUL>
2624     * <LI><CODE>String[] (<B>names</B></CODE>)
2625     *     <BR />-
2626     * </LI>
2627     * </UL> */
2628    public static Script<String, JsonObject, String[]> globalLexicalScopeNames
2629        (Integer executionContextId)
2630    {
2631        final int       webSocketID = 5010000 + counter++;
2632        final boolean[] optionals   = { true, };
2633        
2634        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
2635        String requestJSON = WriteJSON.get(
2636            parameterTypes.get("globalLexicalScopeNames"),
2637            parameterNames.get("globalLexicalScopeNames"),
2638            optionals, webSocketID,
2639            "RunTime.globalLexicalScopeNames",
2640            executionContextId
2641        );
2642        
2643        // 'JSON Binding' ... Converts Browser Response-JSON to 'String[]'
2644        Function<JsonObject, String[]> responseProcessor = (JsonObject jo) ->
2645            (jo.getJsonArray("names") == null)
2646                ? null
2647                : ReadArrJSON.DimN.strArr(jo.getJsonArray("names"), null, 0, String[].class);
2648        
2649        // Pass the 'defaultSender' to Script-Constructor
2650        // The sender that is used can be changed before executing script.
2651        return new Script<>(BRDPC.defaultSender, webSocketID, requestJSON, responseProcessor);
2652    }
2653    
2654    /**
2655     * <CODE>[No Description Provided by Google]</CODE>
2656     * 
2657     * @param prototypeObjectId Identifier of the prototype to return objects for.
2658     * 
2659     * @param objectGroup Symbolic group name that can be used to release the results.
2660     * <BR /><B>OPTIONAL</B>
2661     * 
2662     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
2663     * {@link RunTime.RemoteObject}&gt;</CODE>
2664     * 
2665     * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using
2666     * {@link Script#exec()}, and afterwards, a {@link Promise}<CODE>&lt;JsonObject,
2667     * {@link RunTime.RemoteObject}&gt;</CODE> will be returned.
2668     *
2669     * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>,
2670     * using {@link Promise#await()}, <I>and the returned result of this Browser Function may
2671      * may be retrieved.</I>
2672     *
2673     * <BR /><BR />This Browser Function <B STYLE='color: red'>returns</B>
2674     * <BR /><BR /><UL CLASS=JDUL>
2675     * <LI><CODE>{@link RunTime.RemoteObject} (<B>objects</B></CODE>)
2676     *     <BR />Array with objects.
2677     * </LI>
2678     * </UL> */
2679    public static Script<String, JsonObject, RunTime.RemoteObject> queryObjects
2680        (String prototypeObjectId, String objectGroup)
2681    {
2682        // Exception-Check(s) to ensure that if any parameters which are not declared as
2683        // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
2684        
2685        if (prototypeObjectId == null) BRDPC.throwNPE("prototypeObjectId");
2686        
2687        final int       webSocketID = 5011000 + counter++;
2688        final boolean[] optionals   = { false, true, };
2689        
2690        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
2691        String requestJSON = WriteJSON.get(
2692            parameterTypes.get("queryObjects"),
2693            parameterNames.get("queryObjects"),
2694            optionals, webSocketID,
2695            "RunTime.queryObjects",
2696            prototypeObjectId, objectGroup
2697        );
2698        
2699        // 'JSON Binding' ... Converts Browser Response-JSON to 'RunTime.RemoteObject'
2700        Function<JsonObject, RunTime.RemoteObject> responseProcessor = (JsonObject jo) ->
2701            ReadJSON.XL.getObject(jo, "objects", RunTime.RemoteObject.class, false, true);
2702        
2703        // Pass the 'defaultSender' to Script-Constructor
2704        // The sender that is used can be changed before executing script.
2705        return new Script<>(BRDPC.defaultSender, webSocketID, requestJSON, responseProcessor);
2706    }
2707    
2708    /**
2709     * Releases remote object with given id.
2710     * 
2711     * @param objectId Identifier of the object to release.
2712     * 
2713     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
2714     * {@link Ret0}&gt;</CODE>
2715     *
2716     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
2717     * browser receives the invocation-request.
2718     *
2719     * <BR /><BR />This Browser-Function <I>does not have</I> a return-value.  You may choose to
2720     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0}
2721     * {@code >} to ensure the Browser Function has run to completion.
2722     */
2723    public static Script<String, JsonObject, Ret0> releaseObject(String objectId)
2724    {
2725        // Exception-Check(s) to ensure that if any parameters which are not declared as
2726        // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
2727        
2728        if (objectId == null) BRDPC.throwNPE("objectId");
2729        
2730        final int       webSocketID = 5012000 + counter++;
2731        final boolean[] optionals   = { false, };
2732        
2733        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
2734        String requestJSON = WriteJSON.get(
2735            parameterTypes.get("releaseObject"),
2736            parameterNames.get("releaseObject"),
2737            optionals, webSocketID,
2738            "RunTime.releaseObject",
2739            objectId
2740        );
2741        
2742        // This Remote Command does not have a Return-Value.
2743        return new Script<>
2744            (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues);
2745    }
2746    
2747    /**
2748     * Releases all remote objects that belong to a given group.
2749     * 
2750     * @param objectGroup Symbolic object group name.
2751     * 
2752     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
2753     * {@link Ret0}&gt;</CODE>
2754     *
2755     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
2756     * browser receives the invocation-request.
2757     *
2758     * <BR /><BR />This Browser-Function <I>does not have</I> a return-value.  You may choose to
2759     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0}
2760     * {@code >} to ensure the Browser Function has run to completion.
2761     */
2762    public static Script<String, JsonObject, Ret0> releaseObjectGroup(String objectGroup)
2763    {
2764        // Exception-Check(s) to ensure that if any parameters which are not declared as
2765        // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
2766        
2767        if (objectGroup == null) BRDPC.throwNPE("objectGroup");
2768        
2769        final int       webSocketID = 5013000 + counter++;
2770        final boolean[] optionals   = { false, };
2771        
2772        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
2773        String requestJSON = WriteJSON.get(
2774            parameterTypes.get("releaseObjectGroup"),
2775            parameterNames.get("releaseObjectGroup"),
2776            optionals, webSocketID,
2777            "RunTime.releaseObjectGroup",
2778            objectGroup
2779        );
2780        
2781        // This Remote Command does not have a Return-Value.
2782        return new Script<>
2783            (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues);
2784    }
2785    
2786    /**
2787     * Tells inspected instance to run if it was waiting for debugger to attach.
2788     * 
2789     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
2790     * {@link Ret0}&gt;</CODE>
2791     *
2792     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
2793     * browser receives the invocation-request.
2794     *
2795     * <BR /><BR />This Browser-Function <I>does not have</I> a return-value.  You may choose to
2796     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0}
2797     * {@code >} to ensure the Browser Function has run to completion.
2798     */
2799    public static Script<String, JsonObject, Ret0> runIfWaitingForDebugger()
2800    {
2801        final int          webSocketID = 5014000 + counter++;
2802        final boolean[]    optionals   = new boolean[0];
2803        
2804        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
2805        String requestJSON = WriteJSON.get(
2806            parameterTypes.get("runIfWaitingForDebugger"),
2807            parameterNames.get("runIfWaitingForDebugger"),
2808            optionals, webSocketID,
2809            "RunTime.runIfWaitingForDebugger"
2810        );
2811        
2812        // This Remote Command does not have a Return-Value.
2813        return new Script<>
2814            (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues);
2815    }
2816    
2817    /**
2818     * Runs script with given id in a given context.
2819     * 
2820     * @param scriptId Id of the script to run.
2821     * 
2822     * @param executionContextId 
2823     * Specifies in which execution context to perform script run. If the parameter is omitted the
2824     * evaluation will be performed in the context of the inspected page.
2825     * <BR /><B>OPTIONAL</B>
2826     * 
2827     * @param objectGroup Symbolic group name that can be used to release multiple objects.
2828     * <BR /><B>OPTIONAL</B>
2829     * 
2830     * @param silent 
2831     * In silent mode exceptions thrown during evaluation are not reported and do not pause
2832     * execution. Overrides <CODE>setPauseOnException</CODE> state.
2833     * <BR /><B>OPTIONAL</B>
2834     * 
2835     * @param includeCommandLineAPI Determines whether Command Line API should be available during the evaluation.
2836     * <BR /><B>OPTIONAL</B>
2837     * 
2838     * @param returnByValue Whether the result is expected to be a JSON object which should be sent by value.
2839     * <BR /><B>OPTIONAL</B>
2840     * 
2841     * @param generatePreview Whether preview should be generated for the result.
2842     * <BR /><B>OPTIONAL</B>
2843     * 
2844     * @param awaitPromise 
2845     * Whether execution should <CODE>await</CODE> for resulting value and return once awaited promise is
2846     * resolved.
2847     * <BR /><B>OPTIONAL</B>
2848     * 
2849     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
2850     * {@link Ret2}&gt;</CODE>
2851     *
2852     * <BR /><BR />This {@link Script} may be <B STYLE='color:red'>executed</B> (using 
2853     * {@link Script#exec()}), and a {@link Promise} returned.
2854     *
2855     * <BR /><BR />When the {@code Promise} is <B STYLE='color: red'>awaited</B>
2856     * (using {@link Promise#await()}), the {@code Ret2} will subsequently
2857     * be returned from that call.
2858     * 
2859     * <BR /><BR />The <B STYLE='color: red'>returned</B> values are encapsulated
2860     * in an instance of <B>{@link Ret2}</B>
2861     *
2862     * <BR /><BR /><UL CLASS=JDUL>
2863     * <LI><CODE><B>Ret2.a:</B> {@link RunTime.RemoteObject} (<B>result</B>)</CODE>
2864     *     <BR />Run result.
2865     *     <BR /><BR /></LI>
2866     * <LI><CODE><B>Ret2.b:</B> {@link RunTime.ExceptionDetails} (<B>exceptionDetails</B>)</CODE>
2867     *     <BR />Exception details.
2868     *     </LI>
2869     * </UL>
2870     */
2871    public static Script<String, JsonObject, Ret2<RunTime.RemoteObject, RunTime.ExceptionDetails>> runScript(
2872            String scriptId, Integer executionContextId, String objectGroup, Boolean silent, 
2873            Boolean includeCommandLineAPI, Boolean returnByValue, Boolean generatePreview, 
2874            Boolean awaitPromise
2875        )
2876    {
2877        // Exception-Check(s) to ensure that if any parameters which are not declared as
2878        // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
2879        
2880        if (scriptId == null) BRDPC.throwNPE("scriptId");
2881        
2882        final int       webSocketID = 5015000 + counter++;
2883        final boolean[] optionals   = { false, true, true, true, true, true, true, true, };
2884        
2885        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
2886        String requestJSON = WriteJSON.get(
2887            parameterTypes.get("runScript"),
2888            parameterNames.get("runScript"),
2889            optionals, webSocketID,
2890            "RunTime.runScript",
2891            scriptId, executionContextId, objectGroup, silent, includeCommandLineAPI, returnByValue,
2892            generatePreview, awaitPromise
2893        );
2894        
2895        // 'JSON Binding' ... Converts Browser Response-JSON into Java-Type 'Ret2'
2896        Function<JsonObject, Ret2<RunTime.RemoteObject, RunTime.ExceptionDetails>> 
2897            responseProcessor = (JsonObject jo) -> new Ret2<>(
2898                ReadJSON.XL.getObject(jo, "result", RunTime.RemoteObject.class, false, true),
2899                ReadJSON.XL.getObject(jo, "exceptionDetails", RunTime.ExceptionDetails.class, true, false)
2900            );
2901        
2902        // Pass the 'defaultSender' to Script-Constructor
2903        // The sender that is used can be changed before executing script.
2904        return new Script<>(BRDPC.defaultSender, webSocketID, requestJSON, responseProcessor);
2905    }
2906    
2907    /**
2908     * Enables or disables async call stacks tracking.
2909     * 
2910     * @param maxDepth 
2911     * Maximum depth of async call stacks. Setting to <CODE>0</CODE> will effectively disable collecting async
2912     * call stacks (default).
2913     * 
2914     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
2915     * {@link Ret0}&gt;</CODE>
2916     *
2917     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
2918     * browser receives the invocation-request.
2919     *
2920     * <BR /><BR />This Browser-Function <I>does not have</I> a return-value.  You may choose to
2921     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0}
2922     * {@code >} to ensure the Browser Function has run to completion.
2923     */
2924    public static Script<String, JsonObject, Ret0> setAsyncCallStackDepth(int maxDepth)
2925    {
2926        final int       webSocketID = 5016000 + counter++;
2927        final boolean[] optionals   = { false, };
2928        
2929        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
2930        String requestJSON = WriteJSON.get(
2931            parameterTypes.get("setAsyncCallStackDepth"),
2932            parameterNames.get("setAsyncCallStackDepth"),
2933            optionals, webSocketID,
2934            "RunTime.setAsyncCallStackDepth",
2935            maxDepth
2936        );
2937        
2938        // This Remote Command does not have a Return-Value.
2939        return new Script<>
2940            (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues);
2941    }
2942    
2943    /**
2944     * <CODE>[No Description Provided by Google]</CODE>
2945     * <BR /><B>EXPERIMENTAL</B>
2946     * 
2947     * @param enabled -
2948     * 
2949     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
2950     * {@link Ret0}&gt;</CODE>
2951     *
2952     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
2953     * browser receives the invocation-request.
2954     *
2955     * <BR /><BR />This Browser-Function <I>does not have</I> a return-value.  You may choose to
2956     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0}
2957     * {@code >} to ensure the Browser Function has run to completion.
2958     */
2959    public static Script<String, JsonObject, Ret0> setCustomObjectFormatterEnabled
2960        (boolean enabled)
2961    {
2962        final int       webSocketID = 5017000 + counter++;
2963        final boolean[] optionals   = { false, };
2964        
2965        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
2966        String requestJSON = WriteJSON.get(
2967            parameterTypes.get("setCustomObjectFormatterEnabled"),
2968            parameterNames.get("setCustomObjectFormatterEnabled"),
2969            optionals, webSocketID,
2970            "RunTime.setCustomObjectFormatterEnabled",
2971            enabled
2972        );
2973        
2974        // This Remote Command does not have a Return-Value.
2975        return new Script<>
2976            (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues);
2977    }
2978    
2979    /**
2980     * <CODE>[No Description Provided by Google]</CODE>
2981     * <BR /><B>EXPERIMENTAL</B>
2982     * 
2983     * @param size -
2984     * 
2985     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
2986     * {@link Ret0}&gt;</CODE>
2987     *
2988     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
2989     * browser receives the invocation-request.
2990     *
2991     * <BR /><BR />This Browser-Function <I>does not have</I> a return-value.  You may choose to
2992     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0}
2993     * {@code >} to ensure the Browser Function has run to completion.
2994     */
2995    public static Script<String, JsonObject, Ret0> setMaxCallStackSizeToCapture(int size)
2996    {
2997        final int       webSocketID = 5018000 + counter++;
2998        final boolean[] optionals   = { false, };
2999        
3000        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
3001        String requestJSON = WriteJSON.get(
3002            parameterTypes.get("setMaxCallStackSizeToCapture"),
3003            parameterNames.get("setMaxCallStackSizeToCapture"),
3004            optionals, webSocketID,
3005            "RunTime.setMaxCallStackSizeToCapture",
3006            size
3007        );
3008        
3009        // This Remote Command does not have a Return-Value.
3010        return new Script<>
3011            (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues);
3012    }
3013    
3014    /**
3015     * Terminate current or next JavaScript execution.
3016     * Will cancel the termination when the outer-most script execution ends.
3017     * <BR /><B>EXPERIMENTAL</B>
3018     * 
3019     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
3020     * {@link Ret0}&gt;</CODE>
3021     *
3022     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
3023     * browser receives the invocation-request.
3024     *
3025     * <BR /><BR />This Browser-Function <I>does not have</I> a return-value.  You may choose to
3026     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0}
3027     * {@code >} to ensure the Browser Function has run to completion.
3028     */
3029    public static Script<String, JsonObject, Ret0> terminateExecution()
3030    {
3031        final int          webSocketID = 5019000 + counter++;
3032        final boolean[]    optionals   = new boolean[0];
3033        
3034        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
3035        String requestJSON = WriteJSON.get(
3036            parameterTypes.get("terminateExecution"),
3037            parameterNames.get("terminateExecution"),
3038            optionals, webSocketID,
3039            "RunTime.terminateExecution"
3040        );
3041        
3042        // This Remote Command does not have a Return-Value.
3043        return new Script<>
3044            (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues);
3045    }
3046    
3047    /**
3048     * If executionContextId is empty, adds binding with the given name on the
3049     * global objects of all inspected contexts, including those created later,
3050     * bindings survive reloads.
3051     * Binding function takes exactly one argument, this argument should be string,
3052     * in case of any other input, function throws an exception.
3053     * Each binding function call produces RunTime.bindingCalled notification.
3054     * <BR /><B>EXPERIMENTAL</B>
3055     * 
3056     * @param name -
3057     * 
3058     * @param executionContextId 
3059     * If specified, the binding would only be exposed to the specified
3060     * execution context. If omitted and <CODE>executionContextName</CODE> is not set,
3061     * the binding is exposed to all execution contexts of the target.
3062     * This parameter is mutually exclusive with <CODE>executionContextName</CODE>.
3063     * Deprecated in favor of <CODE>executionContextName</CODE> due to an unclear use case
3064     * and bugs in implementation (crbug.com/1169639). <CODE>executionContextId</CODE> will be
3065     * removed in the future.
3066     * <BR /><B>OPTIONAL</B>
3067     * <BR /><B>DEPRECATED</B>
3068     * 
3069     * @param executionContextName 
3070     * If specified, the binding is exposed to the executionContext with
3071     * matching name, even for contexts created after the binding is added.
3072     * See also <CODE>ExecutionContext.name</CODE> and <CODE>worldName</CODE> parameter to
3073     * <CODE>Page.addScriptToEvaluateOnNewDocument</CODE>.
3074     * This parameter is mutually exclusive with <CODE>executionContextId</CODE>.
3075     * <BR /><B>OPTIONAL</B>
3076     * <BR /><B>EXPERIMENTAL</B>
3077     * 
3078     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
3079     * {@link Ret0}&gt;</CODE>
3080     *
3081     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
3082     * browser receives the invocation-request.
3083     *
3084     * <BR /><BR />This Browser-Function <I>does not have</I> a return-value.  You may choose to
3085     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0}
3086     * {@code >} to ensure the Browser Function has run to completion.
3087     */
3088    public static Script<String, JsonObject, Ret0> addBinding
3089        (String name, Integer executionContextId, String executionContextName)
3090    {
3091        // Exception-Check(s) to ensure that if any parameters which are not declared as
3092        // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
3093        
3094        if (name == null) BRDPC.throwNPE("name");
3095        
3096        final int       webSocketID = 5020000 + counter++;
3097        final boolean[] optionals   = { false, true, true, };
3098        
3099        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
3100        String requestJSON = WriteJSON.get(
3101            parameterTypes.get("addBinding"),
3102            parameterNames.get("addBinding"),
3103            optionals, webSocketID,
3104            "RunTime.addBinding",
3105            name, executionContextId, executionContextName
3106        );
3107        
3108        // This Remote Command does not have a Return-Value.
3109        return new Script<>
3110            (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues);
3111    }
3112    
3113    /**
3114     * This method does not remove binding function from global object but
3115     * unsubscribes current runtime agent from RunTime.bindingCalled notifications.
3116     * <BR /><B>EXPERIMENTAL</B>
3117     * 
3118     * @param name -
3119     * 
3120     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
3121     * {@link Ret0}&gt;</CODE>
3122     *
3123     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
3124     * browser receives the invocation-request.
3125     *
3126     * <BR /><BR />This Browser-Function <I>does not have</I> a return-value.  You may choose to
3127     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0}
3128     * {@code >} to ensure the Browser Function has run to completion.
3129     */
3130    public static Script<String, JsonObject, Ret0> removeBinding(String name)
3131    {
3132        // Exception-Check(s) to ensure that if any parameters which are not declared as
3133        // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
3134        
3135        if (name == null) BRDPC.throwNPE("name");
3136        
3137        final int       webSocketID = 5021000 + counter++;
3138        final boolean[] optionals   = { false, };
3139        
3140        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
3141        String requestJSON = WriteJSON.get(
3142            parameterTypes.get("removeBinding"),
3143            parameterNames.get("removeBinding"),
3144            optionals, webSocketID,
3145            "RunTime.removeBinding",
3146            name
3147        );
3148        
3149        // This Remote Command does not have a Return-Value.
3150        return new Script<>
3151            (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues);
3152    }
3153    
3154}