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.*;
013import Torello.Java.JSON.*;
014
015import static Torello.Java.JSON.JFlag.*;
016
017import Torello.Java.StrCmpr;
018import Torello.JavaDoc.StaticFunctional;
019import Torello.JavaDoc.JDHeaderBackgroundImg;
020import Torello.JavaDoc.Excuse;
021
022/**
023 * <SPAN CLASS=COPIEDJDK><B>This domain emulates different environments for the page.</B></SPAN>
024 * 
025 * <EMBED CLASS='external-html' DATA-FILE-ID=CODE_GEN_NOTE>
026 */
027@StaticFunctional(Excused={"counter"}, Excuses={Excuse.CONFIGURATION})
028@JDHeaderBackgroundImg(EmbedTagFileID="WOOD_PLANK_NOTE")
029public class Emulation
030{
031    // ********************************************************************************************
032    // ********************************************************************************************
033    // Class Header Stuff
034    // ********************************************************************************************
035    // ********************************************************************************************
036
037
038    // No Pubic Constructors
039    private Emulation () { }
040
041    // These two Vector's are used by all the "Methods" exported by this class.  java.lang.reflect
042    // is used to generate the JSON String's.  It saves thousands of lines of Auto-Generated Code.
043    private static final Map<String, Vector<String>>    parameterNames = new HashMap<>();
044    private static final Map<String, Vector<Class<?>>>  parameterTypes = new HashMap<>();
045
046    // Some Methods do not take any parameters - for instance all the "enable()" and "disable()"
047    // I simply could not get ride of RAW-TYPES and UNCHECKED warnings... so there are now,
048    // offically, two empty-vectors.  One for String's, and the other for Classes.
049
050    private static final Vector<String>     EMPTY_VEC_STR = new Vector<>();
051    private static final Vector<Class<?>>   EMPTY_VEC_CLASS = new Vector<>();
052
053    static
054    {
055        for (Method m : Emulation.class.getMethods())
056        {
057            // This doesn't work!  The parameter names are all "arg0" ... "argN"
058            // It works for java.lang.reflect.Field, BUT NOT java.lang.reflect.Parameter!
059            //
060            // Vector<String> parameterNamesList = new Vector<>(); -- NOPE!
061
062            Vector<Class<?>> parameterTypesList = new Vector<>();
063        
064            for (Parameter p : m.getParameters()) parameterTypesList.add(p.getType());
065
066            parameterTypes.put(
067                m.getName(),
068                (parameterTypesList.size() > 0) ? parameterTypesList : EMPTY_VEC_CLASS
069            );
070        }
071    }
072
073    static
074    {
075        Vector<String> v = null;
076
077        parameterNames.put("canEmulate", EMPTY_VEC_STR);
078
079        parameterNames.put("clearDeviceMetricsOverride", EMPTY_VEC_STR);
080
081        parameterNames.put("clearGeolocationOverride", EMPTY_VEC_STR);
082
083        parameterNames.put("resetPageScaleFactor", EMPTY_VEC_STR);
084
085        v = new Vector<String>(1);
086        parameterNames.put("setFocusEmulationEnabled", v);
087        Collections.addAll(v, new String[]
088        { "enabled", });
089
090        v = new Vector<String>(1);
091        parameterNames.put("setAutoDarkModeOverride", v);
092        Collections.addAll(v, new String[]
093        { "enabled", });
094
095        v = new Vector<String>(1);
096        parameterNames.put("setCPUThrottlingRate", v);
097        Collections.addAll(v, new String[]
098        { "rate", });
099
100        v = new Vector<String>(1);
101        parameterNames.put("setDefaultBackgroundColorOverride", v);
102        Collections.addAll(v, new String[]
103        { "color", });
104
105        v = new Vector<String>(13);
106        parameterNames.put("setDeviceMetricsOverride", v);
107        Collections.addAll(v, new String[]
108        { "width", "height", "deviceScaleFactor", "mobile", "scale", "screenWidth", "screenHeight", "positionX", "positionY", "dontSetVisibleSize", "screenOrientation", "viewport", "displayFeature", });
109
110        v = new Vector<String>(1);
111        parameterNames.put("setScrollbarsHidden", v);
112        Collections.addAll(v, new String[]
113        { "hidden", });
114
115        v = new Vector<String>(1);
116        parameterNames.put("setDocumentCookieDisabled", v);
117        Collections.addAll(v, new String[]
118        { "disabled", });
119
120        v = new Vector<String>(2);
121        parameterNames.put("setEmitTouchEventsForMouse", v);
122        Collections.addAll(v, new String[]
123        { "enabled", "configuration", });
124
125        v = new Vector<String>(2);
126        parameterNames.put("setEmulatedMedia", v);
127        Collections.addAll(v, new String[]
128        { "media", "features", });
129
130        v = new Vector<String>(1);
131        parameterNames.put("setEmulatedVisionDeficiency", v);
132        Collections.addAll(v, new String[]
133        { "type", });
134
135        v = new Vector<String>(3);
136        parameterNames.put("setGeolocationOverride", v);
137        Collections.addAll(v, new String[]
138        { "latitude", "longitude", "accuracy", });
139
140        v = new Vector<String>(2);
141        parameterNames.put("setIdleOverride", v);
142        Collections.addAll(v, new String[]
143        { "isUserActive", "isScreenUnlocked", });
144
145        parameterNames.put("clearIdleOverride", EMPTY_VEC_STR);
146
147        v = new Vector<String>(1);
148        parameterNames.put("setNavigatorOverrides", v);
149        Collections.addAll(v, new String[]
150        { "platform", });
151
152        v = new Vector<String>(1);
153        parameterNames.put("setPageScaleFactor", v);
154        Collections.addAll(v, new String[]
155        { "pageScaleFactor", });
156
157        v = new Vector<String>(1);
158        parameterNames.put("setScriptExecutionDisabled", v);
159        Collections.addAll(v, new String[]
160        { "value", });
161
162        v = new Vector<String>(2);
163        parameterNames.put("setTouchEmulationEnabled", v);
164        Collections.addAll(v, new String[]
165        { "enabled", "maxTouchPoints", });
166
167        v = new Vector<String>(5);
168        parameterNames.put("setVirtualTimePolicy", v);
169        Collections.addAll(v, new String[]
170        { "policy", "budget", "maxVirtualTimeTaskStarvationCount", "waitForNavigation", "initialVirtualTime", });
171
172        v = new Vector<String>(1);
173        parameterNames.put("setLocaleOverride", v);
174        Collections.addAll(v, new String[]
175        { "locale", });
176
177        v = new Vector<String>(1);
178        parameterNames.put("setTimezoneOverride", v);
179        Collections.addAll(v, new String[]
180        { "timezoneId", });
181
182        v = new Vector<String>(2);
183        parameterNames.put("setVisibleSize", v);
184        Collections.addAll(v, new String[]
185        { "width", "height", });
186
187        v = new Vector<String>(1);
188        parameterNames.put("setDisabledImageTypes", v);
189        Collections.addAll(v, new String[]
190        { "imageTypes", });
191
192        v = new Vector<String>(4);
193        parameterNames.put("setUserAgentOverride", v);
194        Collections.addAll(v, new String[]
195        { "userAgent", "acceptLanguage", "platform", "userAgentMetadata", });
196    }
197
198
199    // ********************************************************************************************
200    // ********************************************************************************************
201    // Types - Static Inner Classes
202    // ********************************************************************************************
203    // ********************************************************************************************
204
205    /**
206     * advance: If the scheduler runs out of immediate work, the virtual time base may fast forward to
207     * allow the next delayed task (if any) to run; pause: The virtual time base may not advance;
208     * pauseIfNetworkFetchesPending: The virtual time base may not advance if there are any pending
209     * resource fetches.
210     * <BR />
211     * <BR /><B>EXPERIMENTAL</B>
212     */
213    public static final String[] VirtualTimePolicy =
214    { "advance", "pause", "pauseIfNetworkFetchesPending", };
215    
216    /**
217     * Enum of image types that can be disabled.
218     * <BR />
219     * <BR /><B>EXPERIMENTAL</B>
220     */
221    public static final String[] DisabledImageType =
222    { "avif", "jxl", "webp", };
223    
224    /** Screen orientation. */
225    public static class ScreenOrientation
226        extends BaseType
227        implements java.io.Serializable
228    {
229        /** For Object Serialization.  java.io.Serializable */
230        protected static final long serialVersionUID = 1;
231        
232        public boolean[] optionals()
233        { return new boolean[] { false, false, }; }
234        
235        /** Orientation type. */
236        public final String type;
237        
238        /** Orientation angle. */
239        public final int angle;
240        
241        /**
242         * Constructor
243         *
244         * @param type Orientation type.
245         * <BR />Acceptable Values: ["portraitPrimary", "portraitSecondary", "landscapePrimary", "landscapeSecondary"]
246         * 
247         * @param angle Orientation angle.
248         */
249        public ScreenOrientation(String type, int angle)
250        {
251            // Exception-Check(s) to ensure that if any parameters which are not declared as
252            // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
253            
254            if (type == null) BRDPC.throwNPE("type");
255            
256            // Exception-Check(s) to ensure that if any parameters which must adhere to a
257            // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw.
258            
259            BRDPC.checkIAE(
260                "type", type,
261                "portraitPrimary", "portraitSecondary", "landscapePrimary", "landscapeSecondary"
262            );
263            
264            this.type   = type;
265            this.angle  = angle;
266        }
267        
268        /**
269         * JSON Object Constructor
270         * @param jo A Json-Object having data about an instance of {@code 'ScreenOrientation'}.
271         */
272        public ScreenOrientation (JsonObject jo)
273        {
274            this.type   = ReadJSON.getString(jo, "type", false, true);
275            this.angle  = ReadPrimJSON.getInt(jo, "angle");
276        }
277        
278        
279        /** Checks whether {@code 'this'} equals an input Java-{@code Object} */
280        public boolean equals(Object other)
281        {
282            if (other == null)                       return false;
283            if (other.getClass() != this.getClass()) return false;
284        
285            ScreenOrientation o = (ScreenOrientation) other;
286        
287            return
288                    Objects.equals(this.type, o.type)
289                &&  (this.angle == o.angle);
290        }
291        
292        /** Generates a Hash-Code for {@code 'this'} instance */
293        public int hashCode()
294        {
295            return
296                    Objects.hashCode(this.type)
297                +   this.angle;
298        }
299    }
300    
301    /** <CODE>[No Description Provided by Google]</CODE> */
302    public static class DisplayFeature
303        extends BaseType
304        implements java.io.Serializable
305    {
306        /** For Object Serialization.  java.io.Serializable */
307        protected static final long serialVersionUID = 1;
308        
309        public boolean[] optionals()
310        { return new boolean[] { false, false, false, }; }
311        
312        /** Orientation of a display feature in relation to screen */
313        public final String orientation;
314        
315        /**
316         * The offset from the screen origin in either the x (for vertical
317         * orientation) or y (for horizontal orientation) direction.
318         */
319        public final int offset;
320        
321        /**
322         * A display feature may mask content such that it is not physically
323         * displayed - this length along with the offset describes this area.
324         * A display feature that only splits content will have a 0 mask_length.
325         */
326        public final int maskLength;
327        
328        /**
329         * Constructor
330         *
331         * @param orientation Orientation of a display feature in relation to screen
332         * <BR />Acceptable Values: ["vertical", "horizontal"]
333         * 
334         * @param offset 
335         * The offset from the screen origin in either the x (for vertical
336         * orientation) or y (for horizontal orientation) direction.
337         * 
338         * @param maskLength 
339         * A display feature may mask content such that it is not physically
340         * displayed - this length along with the offset describes this area.
341         * A display feature that only splits content will have a 0 mask_length.
342         */
343        public DisplayFeature(String orientation, int offset, int maskLength)
344        {
345            // Exception-Check(s) to ensure that if any parameters which are not declared as
346            // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
347            
348            if (orientation == null) BRDPC.throwNPE("orientation");
349            
350            // Exception-Check(s) to ensure that if any parameters which must adhere to a
351            // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw.
352            
353            BRDPC.checkIAE(
354                "orientation", orientation,
355                "vertical", "horizontal"
356            );
357            
358            this.orientation  = orientation;
359            this.offset       = offset;
360            this.maskLength   = maskLength;
361        }
362        
363        /**
364         * JSON Object Constructor
365         * @param jo A Json-Object having data about an instance of {@code 'DisplayFeature'}.
366         */
367        public DisplayFeature (JsonObject jo)
368        {
369            this.orientation  = ReadJSON.getString(jo, "orientation", false, true);
370            this.offset       = ReadPrimJSON.getInt(jo, "offset");
371            this.maskLength   = ReadPrimJSON.getInt(jo, "maskLength");
372        }
373        
374        
375        /** Checks whether {@code 'this'} equals an input Java-{@code Object} */
376        public boolean equals(Object other)
377        {
378            if (other == null)                       return false;
379            if (other.getClass() != this.getClass()) return false;
380        
381            DisplayFeature o = (DisplayFeature) other;
382        
383            return
384                    Objects.equals(this.orientation, o.orientation)
385                &&  (this.offset == o.offset)
386                &&  (this.maskLength == o.maskLength);
387        }
388        
389        /** Generates a Hash-Code for {@code 'this'} instance */
390        public int hashCode()
391        {
392            return
393                    Objects.hashCode(this.orientation)
394                +   this.offset
395                +   this.maskLength;
396        }
397    }
398    
399    /** <CODE>[No Description Provided by Google]</CODE> */
400    public static class MediaFeature
401        extends BaseType
402        implements java.io.Serializable
403    {
404        /** For Object Serialization.  java.io.Serializable */
405        protected static final long serialVersionUID = 1;
406        
407        public boolean[] optionals()
408        { return new boolean[] { false, false, }; }
409        
410        /** <CODE>[No Description Provided by Google]</CODE> */
411        public final String name;
412        
413        /** <CODE>[No Description Provided by Google]</CODE> */
414        public final String value;
415        
416        /**
417         * Constructor
418         *
419         * @param name -
420         * 
421         * @param value -
422         */
423        public MediaFeature(String name, String value)
424        {
425            // Exception-Check(s) to ensure that if any parameters which are not declared as
426            // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
427            
428            if (name == null)  BRDPC.throwNPE("name");
429            if (value == null) BRDPC.throwNPE("value");
430            
431            this.name   = name;
432            this.value  = value;
433        }
434        
435        /**
436         * JSON Object Constructor
437         * @param jo A Json-Object having data about an instance of {@code 'MediaFeature'}.
438         */
439        public MediaFeature (JsonObject jo)
440        {
441            this.name   = ReadJSON.getString(jo, "name", false, true);
442            this.value  = ReadJSON.getString(jo, "value", false, true);
443        }
444        
445        
446        /** Checks whether {@code 'this'} equals an input Java-{@code Object} */
447        public boolean equals(Object other)
448        {
449            if (other == null)                       return false;
450            if (other.getClass() != this.getClass()) return false;
451        
452            MediaFeature o = (MediaFeature) other;
453        
454            return
455                    Objects.equals(this.name, o.name)
456                &&  Objects.equals(this.value, o.value);
457        }
458        
459        /** Generates a Hash-Code for {@code 'this'} instance */
460        public int hashCode()
461        {
462            return
463                    Objects.hashCode(this.name)
464                +   Objects.hashCode(this.value);
465        }
466    }
467    
468    /**
469     * Used to specify User Agent Cient Hints to emulate. See https://wicg.github.io/ua-client-hints
470     * <BR />
471     * <BR /><B>EXPERIMENTAL</B>
472     */
473    public static class UserAgentBrandVersion
474        extends BaseType
475        implements java.io.Serializable
476    {
477        /** For Object Serialization.  java.io.Serializable */
478        protected static final long serialVersionUID = 1;
479        
480        public boolean[] optionals()
481        { return new boolean[] { false, false, }; }
482        
483        /** <CODE>[No Description Provided by Google]</CODE> */
484        public final String brand;
485        
486        /** <CODE>[No Description Provided by Google]</CODE> */
487        public final String version;
488        
489        /**
490         * Constructor
491         *
492         * @param brand -
493         * 
494         * @param version -
495         */
496        public UserAgentBrandVersion(String brand, String version)
497        {
498            // Exception-Check(s) to ensure that if any parameters which are not declared as
499            // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
500            
501            if (brand == null)   BRDPC.throwNPE("brand");
502            if (version == null) BRDPC.throwNPE("version");
503            
504            this.brand    = brand;
505            this.version  = version;
506        }
507        
508        /**
509         * JSON Object Constructor
510         * @param jo A Json-Object having data about an instance of {@code 'UserAgentBrandVersion'}.
511         */
512        public UserAgentBrandVersion (JsonObject jo)
513        {
514            this.brand    = ReadJSON.getString(jo, "brand", false, true);
515            this.version  = ReadJSON.getString(jo, "version", false, true);
516        }
517        
518        
519        /** Checks whether {@code 'this'} equals an input Java-{@code Object} */
520        public boolean equals(Object other)
521        {
522            if (other == null)                       return false;
523            if (other.getClass() != this.getClass()) return false;
524        
525            UserAgentBrandVersion o = (UserAgentBrandVersion) other;
526        
527            return
528                    Objects.equals(this.brand, o.brand)
529                &&  Objects.equals(this.version, o.version);
530        }
531        
532        /** Generates a Hash-Code for {@code 'this'} instance */
533        public int hashCode()
534        {
535            return
536                    Objects.hashCode(this.brand)
537                +   Objects.hashCode(this.version);
538        }
539    }
540    
541    /**
542     * Used to specify User Agent Cient Hints to emulate. See https://wicg.github.io/ua-client-hints
543     * Missing optional values will be filled in by the target with what it would normally use.
544     * <BR />
545     * <BR /><B>EXPERIMENTAL</B>
546     */
547    public static class UserAgentMetadata
548        extends BaseType
549        implements java.io.Serializable
550    {
551        /** For Object Serialization.  java.io.Serializable */
552        protected static final long serialVersionUID = 1;
553        
554        public boolean[] optionals()
555        { return new boolean[] { true, true, false, false, false, false, false, }; }
556        
557        /**
558         * <CODE>[No Description Provided by Google]</CODE>
559         * <BR />
560         * <BR /><B>OPTIONAL</B>
561         */
562        public final Emulation.UserAgentBrandVersion[] brands;
563        
564        /**
565         * <CODE>[No Description Provided by Google]</CODE>
566         * <BR />
567         * <BR /><B>OPTIONAL</B>
568         */
569        public final String fullVersion;
570        
571        /** <CODE>[No Description Provided by Google]</CODE> */
572        public final String platform;
573        
574        /** <CODE>[No Description Provided by Google]</CODE> */
575        public final String platformVersion;
576        
577        /** <CODE>[No Description Provided by Google]</CODE> */
578        public final String architecture;
579        
580        /** <CODE>[No Description Provided by Google]</CODE> */
581        public final String model;
582        
583        /** <CODE>[No Description Provided by Google]</CODE> */
584        public final boolean mobile;
585        
586        /**
587         * Constructor
588         *
589         * @param brands -
590         * <BR /><B>OPTIONAL</B>
591         * 
592         * @param fullVersion -
593         * <BR /><B>OPTIONAL</B>
594         * 
595         * @param platform -
596         * 
597         * @param platformVersion -
598         * 
599         * @param architecture -
600         * 
601         * @param model -
602         * 
603         * @param mobile -
604         */
605        public UserAgentMetadata(
606                Emulation.UserAgentBrandVersion[] brands, String fullVersion, String platform, 
607                String platformVersion, String architecture, String model, boolean mobile
608            )
609        {
610            // Exception-Check(s) to ensure that if any parameters which are not declared as
611            // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
612            
613            if (platform == null)        BRDPC.throwNPE("platform");
614            if (platformVersion == null) BRDPC.throwNPE("platformVersion");
615            if (architecture == null)    BRDPC.throwNPE("architecture");
616            if (model == null)           BRDPC.throwNPE("model");
617            
618            this.brands           = brands;
619            this.fullVersion      = fullVersion;
620            this.platform         = platform;
621            this.platformVersion  = platformVersion;
622            this.architecture     = architecture;
623            this.model            = model;
624            this.mobile           = mobile;
625        }
626        
627        /**
628         * JSON Object Constructor
629         * @param jo A Json-Object having data about an instance of {@code 'UserAgentMetadata'}.
630         */
631        public UserAgentMetadata (JsonObject jo)
632        {
633            this.brands = (jo.getJsonArray("brands") == null)
634                ? null
635                : ReadArrJSON.DimN.objArr(jo.getJsonArray("brands"), null, 0, Emulation.UserAgentBrandVersion[].class);
636        
637            this.fullVersion      = ReadJSON.getString(jo, "fullVersion", true, false);
638            this.platform         = ReadJSON.getString(jo, "platform", false, true);
639            this.platformVersion  = ReadJSON.getString(jo, "platformVersion", false, true);
640            this.architecture     = ReadJSON.getString(jo, "architecture", false, true);
641            this.model            = ReadJSON.getString(jo, "model", false, true);
642            this.mobile           = ReadPrimJSON.getBoolean(jo, "mobile");
643        }
644        
645        
646        /** Checks whether {@code 'this'} equals an input Java-{@code Object} */
647        public boolean equals(Object other)
648        {
649            if (other == null)                       return false;
650            if (other.getClass() != this.getClass()) return false;
651        
652            UserAgentMetadata o = (UserAgentMetadata) other;
653        
654            return
655                    Arrays.deepEquals(this.brands, o.brands)
656                &&  Objects.equals(this.fullVersion, o.fullVersion)
657                &&  Objects.equals(this.platform, o.platform)
658                &&  Objects.equals(this.platformVersion, o.platformVersion)
659                &&  Objects.equals(this.architecture, o.architecture)
660                &&  Objects.equals(this.model, o.model)
661                &&  (this.mobile == o.mobile);
662        }
663        
664        /** Generates a Hash-Code for {@code 'this'} instance */
665        public int hashCode()
666        {
667            return
668                    Arrays.deepHashCode(this.brands)
669                +   Objects.hashCode(this.fullVersion)
670                +   Objects.hashCode(this.platform)
671                +   Objects.hashCode(this.platformVersion)
672                +   Objects.hashCode(this.architecture)
673                +   Objects.hashCode(this.model)
674                +   (this.mobile ? 1 : 0);
675        }
676    }
677    
678    /**
679     * Notification sent after the virtual time budget for the current VirtualTimePolicy has run out.
680     * <BR />
681     * <BR /><B>EXPERIMENTAL</B>
682     *
683     * <BR /><BR />This is Marker-Event.  Marker-Event's are Events that do not posses
684     * any data, fields or state.  When they are fired, only the event name is supplied.
685     */
686    public static class virtualTimeBudgetExpired
687        extends BrowserEvent
688        implements java.io.Serializable
689    {
690        /** For Object Serialization.  java.io.Serializable */
691        protected static final long serialVersionUID = 1;
692    
693        public boolean[] optionals() { return new boolean[0]; }
694    
695        /** JSON Object Constructor */
696        public virtualTimeBudgetExpired(JsonObject jo)
697        { super("Emulation", "virtualTimeBudgetExpired", 0); }
698    
699        @Override
700        public String toString() { return "Emulation.virtualTimeBudgetExpired Marker Event\n"; }
701    }
702    
703    
704    // Counter for keeping the WebSocket Request ID's distinct.
705    private static int counter = 1;
706    
707    /**
708     * Tells whether emulation is supported.
709     * 
710     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
711     * Boolean&gt;</CODE>
712     * 
713     * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using
714     * {@link Script#exec()}, and afterwards, a {@link Promise}<CODE>&lt;JsonObject,
715     * Boolean&gt;</CODE> will be returned.
716     *
717     * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>,
718     * using {@link Promise#await()}, <I>and the returned result of this Browser Function may
719      * may be retrieved.</I>
720     *
721     * <BR /><BR />This Browser Function <B STYLE='color: red'>returns</B>
722     * <BR /><BR /><UL CLASS=JDUL>
723     * <LI><CODE>Boolean (<B>result</B></CODE>)
724     *     <BR />True if emulation is supported.
725     * </LI>
726     * </UL> */
727    public static Script<String, JsonObject, Boolean> canEmulate()
728    {
729        final int          webSocketID = 21000000 + counter++;
730        final boolean[]    optionals   = new boolean[0];
731        
732        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
733        String requestJSON = WriteJSON.get(
734            parameterTypes.get("canEmulate"),
735            parameterNames.get("canEmulate"),
736            optionals, webSocketID,
737            "Emulation.canEmulate"
738        );
739        
740        // 'JSON Binding' ... Converts Browser Response-JSON to 'Boolean'
741        Function<JsonObject, Boolean> responseProcessor = (JsonObject jo) ->
742            ReadPrimJSON.getBoolean(jo, "result");
743        
744        // Pass the 'defaultSender' to Script-Constructor
745        // The sender that is used can be changed before executing script.
746        return new Script<>(BRDPC.defaultSender, webSocketID, requestJSON, responseProcessor);
747    }
748    
749    /**
750     * Clears the overridden device metrics.
751     * 
752     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
753     * {@link Ret0}&gt;</CODE>
754     *
755     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
756     * browser receives the invocation-request.
757     *
758     * <BR /><BR />This Browser-Function <I>does not have</I> a return-value.  You may choose to
759     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0}
760     * {@code >} to ensure the Browser Function has run to completion.
761     */
762    public static Script<String, JsonObject, Ret0> clearDeviceMetricsOverride()
763    {
764        final int          webSocketID = 21001000 + counter++;
765        final boolean[]    optionals   = new boolean[0];
766        
767        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
768        String requestJSON = WriteJSON.get(
769            parameterTypes.get("clearDeviceMetricsOverride"),
770            parameterNames.get("clearDeviceMetricsOverride"),
771            optionals, webSocketID,
772            "Emulation.clearDeviceMetricsOverride"
773        );
774        
775        // This Remote Command does not have a Return-Value.
776        return new Script<>
777            (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues);
778    }
779    
780    /**
781     * Clears the overridden Geolocation Position and Error.
782     * 
783     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
784     * {@link Ret0}&gt;</CODE>
785     *
786     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
787     * browser receives the invocation-request.
788     *
789     * <BR /><BR />This Browser-Function <I>does not have</I> a return-value.  You may choose to
790     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0}
791     * {@code >} to ensure the Browser Function has run to completion.
792     */
793    public static Script<String, JsonObject, Ret0> clearGeolocationOverride()
794    {
795        final int          webSocketID = 21002000 + counter++;
796        final boolean[]    optionals   = new boolean[0];
797        
798        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
799        String requestJSON = WriteJSON.get(
800            parameterTypes.get("clearGeolocationOverride"),
801            parameterNames.get("clearGeolocationOverride"),
802            optionals, webSocketID,
803            "Emulation.clearGeolocationOverride"
804        );
805        
806        // This Remote Command does not have a Return-Value.
807        return new Script<>
808            (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues);
809    }
810    
811    /**
812     * Requests that page scale factor is reset to initial values.
813     * <BR /><B>EXPERIMENTAL</B>
814     * 
815     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
816     * {@link Ret0}&gt;</CODE>
817     *
818     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
819     * browser receives the invocation-request.
820     *
821     * <BR /><BR />This Browser-Function <I>does not have</I> a return-value.  You may choose to
822     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0}
823     * {@code >} to ensure the Browser Function has run to completion.
824     */
825    public static Script<String, JsonObject, Ret0> resetPageScaleFactor()
826    {
827        final int          webSocketID = 21003000 + counter++;
828        final boolean[]    optionals   = new boolean[0];
829        
830        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
831        String requestJSON = WriteJSON.get(
832            parameterTypes.get("resetPageScaleFactor"),
833            parameterNames.get("resetPageScaleFactor"),
834            optionals, webSocketID,
835            "Emulation.resetPageScaleFactor"
836        );
837        
838        // This Remote Command does not have a Return-Value.
839        return new Script<>
840            (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues);
841    }
842    
843    /**
844     * Enables or disables simulating a focused and active page.
845     * <BR /><B>EXPERIMENTAL</B>
846     * 
847     * @param enabled Whether to enable to disable focus emulation.
848     * 
849     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
850     * {@link Ret0}&gt;</CODE>
851     *
852     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
853     * browser receives the invocation-request.
854     *
855     * <BR /><BR />This Browser-Function <I>does not have</I> a return-value.  You may choose to
856     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0}
857     * {@code >} to ensure the Browser Function has run to completion.
858     */
859    public static Script<String, JsonObject, Ret0> setFocusEmulationEnabled(boolean enabled)
860    {
861        final int       webSocketID = 21004000 + counter++;
862        final boolean[] optionals   = { false, };
863        
864        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
865        String requestJSON = WriteJSON.get(
866            parameterTypes.get("setFocusEmulationEnabled"),
867            parameterNames.get("setFocusEmulationEnabled"),
868            optionals, webSocketID,
869            "Emulation.setFocusEmulationEnabled",
870            enabled
871        );
872        
873        // This Remote Command does not have a Return-Value.
874        return new Script<>
875            (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues);
876    }
877    
878    /**
879     * Automatically render all web contents using a dark theme.
880     * <BR /><B>EXPERIMENTAL</B>
881     * 
882     * @param enabled 
883     * Whether to enable or disable automatic dark mode.
884     * If not specified, any existing override will be cleared.
885     * <BR /><B>OPTIONAL</B>
886     * 
887     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
888     * {@link Ret0}&gt;</CODE>
889     *
890     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
891     * browser receives the invocation-request.
892     *
893     * <BR /><BR />This Browser-Function <I>does not have</I> a return-value.  You may choose to
894     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0}
895     * {@code >} to ensure the Browser Function has run to completion.
896     */
897    public static Script<String, JsonObject, Ret0> setAutoDarkModeOverride(Boolean enabled)
898    {
899        final int       webSocketID = 21005000 + counter++;
900        final boolean[] optionals   = { true, };
901        
902        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
903        String requestJSON = WriteJSON.get(
904            parameterTypes.get("setAutoDarkModeOverride"),
905            parameterNames.get("setAutoDarkModeOverride"),
906            optionals, webSocketID,
907            "Emulation.setAutoDarkModeOverride",
908            enabled
909        );
910        
911        // This Remote Command does not have a Return-Value.
912        return new Script<>
913            (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues);
914    }
915    
916    /**
917     * Enables CPU throttling to emulate slow CPUs.
918     * <BR /><B>EXPERIMENTAL</B>
919     * 
920     * @param rate Throttling rate as a slowdown factor (1 is no throttle, 2 is 2x slowdown, etc).
921     * 
922     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
923     * {@link Ret0}&gt;</CODE>
924     *
925     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
926     * browser receives the invocation-request.
927     *
928     * <BR /><BR />This Browser-Function <I>does not have</I> a return-value.  You may choose to
929     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0}
930     * {@code >} to ensure the Browser Function has run to completion.
931     */
932    public static Script<String, JsonObject, Ret0> setCPUThrottlingRate(Number rate)
933    {
934        // Exception-Check(s) to ensure that if any parameters which are not declared as
935        // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
936        
937        if (rate == null) BRDPC.throwNPE("rate");
938        
939        final int       webSocketID = 21006000 + counter++;
940        final boolean[] optionals   = { false, };
941        
942        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
943        String requestJSON = WriteJSON.get(
944            parameterTypes.get("setCPUThrottlingRate"),
945            parameterNames.get("setCPUThrottlingRate"),
946            optionals, webSocketID,
947            "Emulation.setCPUThrottlingRate",
948            rate
949        );
950        
951        // This Remote Command does not have a Return-Value.
952        return new Script<>
953            (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues);
954    }
955    
956    /**
957     * Sets or clears an override of the default background color of the frame. This override is used
958     * if the content does not specify one.
959     * 
960     * @param color 
961     * RGBA of the default background color. If not specified, any existing override will be
962     * cleared.
963     * <BR /><B>OPTIONAL</B>
964     * 
965     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
966     * {@link Ret0}&gt;</CODE>
967     *
968     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
969     * browser receives the invocation-request.
970     *
971     * <BR /><BR />This Browser-Function <I>does not have</I> a return-value.  You may choose to
972     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0}
973     * {@code >} to ensure the Browser Function has run to completion.
974     */
975    public static Script<String, JsonObject, Ret0> setDefaultBackgroundColorOverride
976        (DOM.RGBA color)
977    {
978        final int       webSocketID = 21007000 + counter++;
979        final boolean[] optionals   = { true, };
980        
981        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
982        String requestJSON = WriteJSON.get(
983            parameterTypes.get("setDefaultBackgroundColorOverride"),
984            parameterNames.get("setDefaultBackgroundColorOverride"),
985            optionals, webSocketID,
986            "Emulation.setDefaultBackgroundColorOverride",
987            color
988        );
989        
990        // This Remote Command does not have a Return-Value.
991        return new Script<>
992            (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues);
993    }
994    
995    /**
996     * Overrides the values of device screen dimensions (window.screen.width, window.screen.height,
997     * window.innerWidth, window.innerHeight, and "device-width"/"device-height"-related CSS media
998     * query results).
999     * 
1000     * @param width Overriding width value in pixels (minimum 0, maximum 10000000). 0 disables the override.
1001     * 
1002     * @param height Overriding height value in pixels (minimum 0, maximum 10000000). 0 disables the override.
1003     * 
1004     * @param deviceScaleFactor Overriding device scale factor value. 0 disables the override.
1005     * 
1006     * @param mobile 
1007     * Whether to emulate mobile device. This includes viewport meta tag, overlay scrollbars, text
1008     * autosizing and more.
1009     * 
1010     * @param scale Scale to apply to resulting view image.
1011     * <BR /><B>OPTIONAL</B>
1012     * <BR /><B>EXPERIMENTAL</B>
1013     * 
1014     * @param screenWidth Overriding screen width value in pixels (minimum 0, maximum 10000000).
1015     * <BR /><B>OPTIONAL</B>
1016     * <BR /><B>EXPERIMENTAL</B>
1017     * 
1018     * @param screenHeight Overriding screen height value in pixels (minimum 0, maximum 10000000).
1019     * <BR /><B>OPTIONAL</B>
1020     * <BR /><B>EXPERIMENTAL</B>
1021     * 
1022     * @param positionX Overriding view X position on screen in pixels (minimum 0, maximum 10000000).
1023     * <BR /><B>OPTIONAL</B>
1024     * <BR /><B>EXPERIMENTAL</B>
1025     * 
1026     * @param positionY Overriding view Y position on screen in pixels (minimum 0, maximum 10000000).
1027     * <BR /><B>OPTIONAL</B>
1028     * <BR /><B>EXPERIMENTAL</B>
1029     * 
1030     * @param dontSetVisibleSize Do not set visible view size, rely upon explicit setVisibleSize call.
1031     * <BR /><B>OPTIONAL</B>
1032     * <BR /><B>EXPERIMENTAL</B>
1033     * 
1034     * @param screenOrientation Screen orientation override.
1035     * <BR /><B>OPTIONAL</B>
1036     * 
1037     * @param viewport 
1038     * If set, the visible area of the page will be overridden to this viewport. This viewport
1039     * change is not observed by the page, e.g. viewport-relative elements do not change positions.
1040     * <BR /><B>OPTIONAL</B>
1041     * <BR /><B>EXPERIMENTAL</B>
1042     * 
1043     * @param displayFeature 
1044     * If set, the display feature of a multi-segment screen. If not set, multi-segment support
1045     * is turned-off.
1046     * <BR /><B>OPTIONAL</B>
1047     * <BR /><B>EXPERIMENTAL</B>
1048     * 
1049     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
1050     * {@link Ret0}&gt;</CODE>
1051     *
1052     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
1053     * browser receives the invocation-request.
1054     *
1055     * <BR /><BR />This Browser-Function <I>does not have</I> a return-value.  You may choose to
1056     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0}
1057     * {@code >} to ensure the Browser Function has run to completion.
1058     */
1059    public static Script<String, JsonObject, Ret0> setDeviceMetricsOverride(
1060            int width, int height, Number deviceScaleFactor, boolean mobile, Number scale, 
1061            Integer screenWidth, Integer screenHeight, Integer positionX, Integer positionY, 
1062            Boolean dontSetVisibleSize, Emulation.ScreenOrientation screenOrientation, 
1063            Page.Viewport viewport, Emulation.DisplayFeature displayFeature
1064        )
1065    {
1066        // Exception-Check(s) to ensure that if any parameters which are not declared as
1067        // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
1068        
1069        if (deviceScaleFactor == null) BRDPC.throwNPE("deviceScaleFactor");
1070        
1071        final int       webSocketID = 21008000 + counter++;
1072        final boolean[] optionals   = { false, false, false, false, true, true, true, true, true, true, true, true, true, };
1073        
1074        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
1075        String requestJSON = WriteJSON.get(
1076            parameterTypes.get("setDeviceMetricsOverride"),
1077            parameterNames.get("setDeviceMetricsOverride"),
1078            optionals, webSocketID,
1079            "Emulation.setDeviceMetricsOverride",
1080            width, height, deviceScaleFactor, mobile, scale, screenWidth, screenHeight, positionX,
1081            positionY, dontSetVisibleSize, screenOrientation, viewport, displayFeature
1082        );
1083        
1084        // This Remote Command does not have a Return-Value.
1085        return new Script<>
1086            (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues);
1087    }
1088    
1089    /**
1090     * <CODE>[No Description Provided by Google]</CODE>
1091     * <BR /><B>EXPERIMENTAL</B>
1092     * 
1093     * @param hidden Whether scrollbars should be always hidden.
1094     * 
1095     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
1096     * {@link Ret0}&gt;</CODE>
1097     *
1098     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
1099     * browser receives the invocation-request.
1100     *
1101     * <BR /><BR />This Browser-Function <I>does not have</I> a return-value.  You may choose to
1102     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0}
1103     * {@code >} to ensure the Browser Function has run to completion.
1104     */
1105    public static Script<String, JsonObject, Ret0> setScrollbarsHidden(boolean hidden)
1106    {
1107        final int       webSocketID = 21009000 + counter++;
1108        final boolean[] optionals   = { false, };
1109        
1110        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
1111        String requestJSON = WriteJSON.get(
1112            parameterTypes.get("setScrollbarsHidden"),
1113            parameterNames.get("setScrollbarsHidden"),
1114            optionals, webSocketID,
1115            "Emulation.setScrollbarsHidden",
1116            hidden
1117        );
1118        
1119        // This Remote Command does not have a Return-Value.
1120        return new Script<>
1121            (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues);
1122    }
1123    
1124    /**
1125     * <CODE>[No Description Provided by Google]</CODE>
1126     * <BR /><B>EXPERIMENTAL</B>
1127     * 
1128     * @param disabled Whether document.coookie API should be disabled.
1129     * 
1130     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
1131     * {@link Ret0}&gt;</CODE>
1132     *
1133     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
1134     * browser receives the invocation-request.
1135     *
1136     * <BR /><BR />This Browser-Function <I>does not have</I> a return-value.  You may choose to
1137     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0}
1138     * {@code >} to ensure the Browser Function has run to completion.
1139     */
1140    public static Script<String, JsonObject, Ret0> setDocumentCookieDisabled(boolean disabled)
1141    {
1142        final int       webSocketID = 21010000 + counter++;
1143        final boolean[] optionals   = { false, };
1144        
1145        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
1146        String requestJSON = WriteJSON.get(
1147            parameterTypes.get("setDocumentCookieDisabled"),
1148            parameterNames.get("setDocumentCookieDisabled"),
1149            optionals, webSocketID,
1150            "Emulation.setDocumentCookieDisabled",
1151            disabled
1152        );
1153        
1154        // This Remote Command does not have a Return-Value.
1155        return new Script<>
1156            (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues);
1157    }
1158    
1159    /**
1160     * <CODE>[No Description Provided by Google]</CODE>
1161     * <BR /><B>EXPERIMENTAL</B>
1162     * 
1163     * @param enabled Whether touch emulation based on mouse input should be enabled.
1164     * 
1165     * @param configuration Touch/gesture events configuration. Default: current platform.
1166     * <BR />Acceptable Values: ["mobile", "desktop"]
1167     * <BR /><B>OPTIONAL</B>
1168     * 
1169     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
1170     * {@link Ret0}&gt;</CODE>
1171     *
1172     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
1173     * browser receives the invocation-request.
1174     *
1175     * <BR /><BR />This Browser-Function <I>does not have</I> a return-value.  You may choose to
1176     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0}
1177     * {@code >} to ensure the Browser Function has run to completion.
1178     */
1179    public static Script<String, JsonObject, Ret0> setEmitTouchEventsForMouse
1180        (boolean enabled, String configuration)
1181    {
1182        // Exception-Check(s) to ensure that if any parameters which must adhere to a
1183        // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw.
1184        
1185        BRDPC.checkIAE(
1186            "configuration", configuration,
1187            "mobile", "desktop"
1188        );
1189        
1190        final int       webSocketID = 21011000 + counter++;
1191        final boolean[] optionals   = { false, true, };
1192        
1193        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
1194        String requestJSON = WriteJSON.get(
1195            parameterTypes.get("setEmitTouchEventsForMouse"),
1196            parameterNames.get("setEmitTouchEventsForMouse"),
1197            optionals, webSocketID,
1198            "Emulation.setEmitTouchEventsForMouse",
1199            enabled, configuration
1200        );
1201        
1202        // This Remote Command does not have a Return-Value.
1203        return new Script<>
1204            (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues);
1205    }
1206    
1207    /**
1208     * Emulates the given media type or media feature for CSS media queries.
1209     * 
1210     * @param media Media type to emulate. Empty string disables the override.
1211     * <BR /><B>OPTIONAL</B>
1212     * 
1213     * @param features Media features to emulate.
1214     * <BR /><B>OPTIONAL</B>
1215     * 
1216     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
1217     * {@link Ret0}&gt;</CODE>
1218     *
1219     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
1220     * browser receives the invocation-request.
1221     *
1222     * <BR /><BR />This Browser-Function <I>does not have</I> a return-value.  You may choose to
1223     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0}
1224     * {@code >} to ensure the Browser Function has run to completion.
1225     */
1226    public static Script<String, JsonObject, Ret0> setEmulatedMedia
1227        (String media, Emulation.MediaFeature[] features)
1228    {
1229        final int       webSocketID = 21012000 + counter++;
1230        final boolean[] optionals   = { true, true, };
1231        
1232        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
1233        String requestJSON = WriteJSON.get(
1234            parameterTypes.get("setEmulatedMedia"),
1235            parameterNames.get("setEmulatedMedia"),
1236            optionals, webSocketID,
1237            "Emulation.setEmulatedMedia",
1238            media, features
1239        );
1240        
1241        // This Remote Command does not have a Return-Value.
1242        return new Script<>
1243            (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues);
1244    }
1245    
1246    /**
1247     * Emulates the given vision deficiency.
1248     * <BR /><B>EXPERIMENTAL</B>
1249     * 
1250     * @param type Vision deficiency to emulate.
1251     * <BR />Acceptable Values: ["none", "achromatopsia", "blurredVision", "deuteranopia", "protanopia", "tritanopia"]
1252     * 
1253     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
1254     * {@link Ret0}&gt;</CODE>
1255     *
1256     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
1257     * browser receives the invocation-request.
1258     *
1259     * <BR /><BR />This Browser-Function <I>does not have</I> a return-value.  You may choose to
1260     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0}
1261     * {@code >} to ensure the Browser Function has run to completion.
1262     */
1263    public static Script<String, JsonObject, Ret0> setEmulatedVisionDeficiency(String type)
1264    {
1265        // Exception-Check(s) to ensure that if any parameters which are not declared as
1266        // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
1267        
1268        if (type == null) BRDPC.throwNPE("type");
1269        
1270        // Exception-Check(s) to ensure that if any parameters which must adhere to a
1271        // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw.
1272        
1273        BRDPC.checkIAE(
1274            "type", type,
1275            "none", "achromatopsia", "blurredVision", "deuteranopia", "protanopia", "tritanopia"
1276        );
1277        
1278        final int       webSocketID = 21013000 + counter++;
1279        final boolean[] optionals   = { false, };
1280        
1281        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
1282        String requestJSON = WriteJSON.get(
1283            parameterTypes.get("setEmulatedVisionDeficiency"),
1284            parameterNames.get("setEmulatedVisionDeficiency"),
1285            optionals, webSocketID,
1286            "Emulation.setEmulatedVisionDeficiency",
1287            type
1288        );
1289        
1290        // This Remote Command does not have a Return-Value.
1291        return new Script<>
1292            (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues);
1293    }
1294    
1295    /**
1296     * Overrides the Geolocation Position or Error. Omitting any of the parameters emulates position
1297     * unavailable.
1298     * 
1299     * @param latitude Mock latitude
1300     * <BR /><B>OPTIONAL</B>
1301     * 
1302     * @param longitude Mock longitude
1303     * <BR /><B>OPTIONAL</B>
1304     * 
1305     * @param accuracy Mock accuracy
1306     * <BR /><B>OPTIONAL</B>
1307     * 
1308     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
1309     * {@link Ret0}&gt;</CODE>
1310     *
1311     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
1312     * browser receives the invocation-request.
1313     *
1314     * <BR /><BR />This Browser-Function <I>does not have</I> a return-value.  You may choose to
1315     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0}
1316     * {@code >} to ensure the Browser Function has run to completion.
1317     */
1318    public static Script<String, JsonObject, Ret0> setGeolocationOverride
1319        (Number latitude, Number longitude, Number accuracy)
1320    {
1321        final int       webSocketID = 21014000 + counter++;
1322        final boolean[] optionals   = { true, true, true, };
1323        
1324        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
1325        String requestJSON = WriteJSON.get(
1326            parameterTypes.get("setGeolocationOverride"),
1327            parameterNames.get("setGeolocationOverride"),
1328            optionals, webSocketID,
1329            "Emulation.setGeolocationOverride",
1330            latitude, longitude, accuracy
1331        );
1332        
1333        // This Remote Command does not have a Return-Value.
1334        return new Script<>
1335            (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues);
1336    }
1337    
1338    /**
1339     * Overrides the Idle state.
1340     * <BR /><B>EXPERIMENTAL</B>
1341     * 
1342     * @param isUserActive Mock isUserActive
1343     * 
1344     * @param isScreenUnlocked Mock isScreenUnlocked
1345     * 
1346     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
1347     * {@link Ret0}&gt;</CODE>
1348     *
1349     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
1350     * browser receives the invocation-request.
1351     *
1352     * <BR /><BR />This Browser-Function <I>does not have</I> a return-value.  You may choose to
1353     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0}
1354     * {@code >} to ensure the Browser Function has run to completion.
1355     */
1356    public static Script<String, JsonObject, Ret0> setIdleOverride
1357        (boolean isUserActive, boolean isScreenUnlocked)
1358    {
1359        final int       webSocketID = 21015000 + counter++;
1360        final boolean[] optionals   = { false, false, };
1361        
1362        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
1363        String requestJSON = WriteJSON.get(
1364            parameterTypes.get("setIdleOverride"),
1365            parameterNames.get("setIdleOverride"),
1366            optionals, webSocketID,
1367            "Emulation.setIdleOverride",
1368            isUserActive, isScreenUnlocked
1369        );
1370        
1371        // This Remote Command does not have a Return-Value.
1372        return new Script<>
1373            (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues);
1374    }
1375    
1376    /**
1377     * Clears Idle state overrides.
1378     * <BR /><B>EXPERIMENTAL</B>
1379     * 
1380     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
1381     * {@link Ret0}&gt;</CODE>
1382     *
1383     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
1384     * browser receives the invocation-request.
1385     *
1386     * <BR /><BR />This Browser-Function <I>does not have</I> a return-value.  You may choose to
1387     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0}
1388     * {@code >} to ensure the Browser Function has run to completion.
1389     */
1390    public static Script<String, JsonObject, Ret0> clearIdleOverride()
1391    {
1392        final int          webSocketID = 21016000 + counter++;
1393        final boolean[]    optionals   = new boolean[0];
1394        
1395        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
1396        String requestJSON = WriteJSON.get(
1397            parameterTypes.get("clearIdleOverride"),
1398            parameterNames.get("clearIdleOverride"),
1399            optionals, webSocketID,
1400            "Emulation.clearIdleOverride"
1401        );
1402        
1403        // This Remote Command does not have a Return-Value.
1404        return new Script<>
1405            (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues);
1406    }
1407    
1408    /**
1409     * Overrides value returned by the javascript navigator object.
1410     * <BR /><B>EXPERIMENTAL</B>
1411     * <BR /><B>DEPRECATED</B>
1412     * 
1413     * @param platform The platform navigator.platform should return.
1414     * 
1415     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
1416     * {@link Ret0}&gt;</CODE>
1417     *
1418     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
1419     * browser receives the invocation-request.
1420     *
1421     * <BR /><BR />This Browser-Function <I>does not have</I> a return-value.  You may choose to
1422     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0}
1423     * {@code >} to ensure the Browser Function has run to completion.
1424     */
1425    public static Script<String, JsonObject, Ret0> setNavigatorOverrides(String platform)
1426    {
1427        // Exception-Check(s) to ensure that if any parameters which are not declared as
1428        // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
1429        
1430        if (platform == null) BRDPC.throwNPE("platform");
1431        
1432        final int       webSocketID = 21017000 + counter++;
1433        final boolean[] optionals   = { false, };
1434        
1435        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
1436        String requestJSON = WriteJSON.get(
1437            parameterTypes.get("setNavigatorOverrides"),
1438            parameterNames.get("setNavigatorOverrides"),
1439            optionals, webSocketID,
1440            "Emulation.setNavigatorOverrides",
1441            platform
1442        );
1443        
1444        // This Remote Command does not have a Return-Value.
1445        return new Script<>
1446            (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues);
1447    }
1448    
1449    /**
1450     * Sets a specified page scale factor.
1451     * <BR /><B>EXPERIMENTAL</B>
1452     * 
1453     * @param pageScaleFactor Page scale factor.
1454     * 
1455     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
1456     * {@link Ret0}&gt;</CODE>
1457     *
1458     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
1459     * browser receives the invocation-request.
1460     *
1461     * <BR /><BR />This Browser-Function <I>does not have</I> a return-value.  You may choose to
1462     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0}
1463     * {@code >} to ensure the Browser Function has run to completion.
1464     */
1465    public static Script<String, JsonObject, Ret0> setPageScaleFactor(Number pageScaleFactor)
1466    {
1467        // Exception-Check(s) to ensure that if any parameters which are not declared as
1468        // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
1469        
1470        if (pageScaleFactor == null) BRDPC.throwNPE("pageScaleFactor");
1471        
1472        final int       webSocketID = 21018000 + counter++;
1473        final boolean[] optionals   = { false, };
1474        
1475        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
1476        String requestJSON = WriteJSON.get(
1477            parameterTypes.get("setPageScaleFactor"),
1478            parameterNames.get("setPageScaleFactor"),
1479            optionals, webSocketID,
1480            "Emulation.setPageScaleFactor",
1481            pageScaleFactor
1482        );
1483        
1484        // This Remote Command does not have a Return-Value.
1485        return new Script<>
1486            (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues);
1487    }
1488    
1489    /**
1490     * Switches script execution in the page.
1491     * 
1492     * @param value Whether script execution should be disabled in the page.
1493     * 
1494     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
1495     * {@link Ret0}&gt;</CODE>
1496     *
1497     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
1498     * browser receives the invocation-request.
1499     *
1500     * <BR /><BR />This Browser-Function <I>does not have</I> a return-value.  You may choose to
1501     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0}
1502     * {@code >} to ensure the Browser Function has run to completion.
1503     */
1504    public static Script<String, JsonObject, Ret0> setScriptExecutionDisabled(boolean value)
1505    {
1506        final int       webSocketID = 21019000 + counter++;
1507        final boolean[] optionals   = { false, };
1508        
1509        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
1510        String requestJSON = WriteJSON.get(
1511            parameterTypes.get("setScriptExecutionDisabled"),
1512            parameterNames.get("setScriptExecutionDisabled"),
1513            optionals, webSocketID,
1514            "Emulation.setScriptExecutionDisabled",
1515            value
1516        );
1517        
1518        // This Remote Command does not have a Return-Value.
1519        return new Script<>
1520            (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues);
1521    }
1522    
1523    /**
1524     * Enables touch on platforms which do not support them.
1525     * 
1526     * @param enabled Whether the touch event emulation should be enabled.
1527     * 
1528     * @param maxTouchPoints Maximum touch points supported. Defaults to one.
1529     * <BR /><B>OPTIONAL</B>
1530     * 
1531     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
1532     * {@link Ret0}&gt;</CODE>
1533     *
1534     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
1535     * browser receives the invocation-request.
1536     *
1537     * <BR /><BR />This Browser-Function <I>does not have</I> a return-value.  You may choose to
1538     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0}
1539     * {@code >} to ensure the Browser Function has run to completion.
1540     */
1541    public static Script<String, JsonObject, Ret0> setTouchEmulationEnabled
1542        (boolean enabled, Integer maxTouchPoints)
1543    {
1544        final int       webSocketID = 21020000 + counter++;
1545        final boolean[] optionals   = { false, true, };
1546        
1547        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
1548        String requestJSON = WriteJSON.get(
1549            parameterTypes.get("setTouchEmulationEnabled"),
1550            parameterNames.get("setTouchEmulationEnabled"),
1551            optionals, webSocketID,
1552            "Emulation.setTouchEmulationEnabled",
1553            enabled, maxTouchPoints
1554        );
1555        
1556        // This Remote Command does not have a Return-Value.
1557        return new Script<>
1558            (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues);
1559    }
1560    
1561    /**
1562     * Turns on virtual time for all frames (replacing real-time with a synthetic time source) and sets
1563     * the current virtual time policy.  Note this supersedes any previous time budget.
1564     * <BR /><B>EXPERIMENTAL</B>
1565     * 
1566     * @param policy -
1567     * 
1568     * @param budget 
1569     * If set, after this many virtual milliseconds have elapsed virtual time will be paused and a
1570     * virtualTimeBudgetExpired event is sent.
1571     * <BR /><B>OPTIONAL</B>
1572     * 
1573     * @param maxVirtualTimeTaskStarvationCount 
1574     * If set this specifies the maximum number of tasks that can be run before virtual is forced
1575     * forwards to prevent deadlock.
1576     * <BR /><B>OPTIONAL</B>
1577     * 
1578     * @param waitForNavigation 
1579     * If set the virtual time policy change should be deferred until any frame starts navigating.
1580     * Note any previous deferred policy change is superseded.
1581     * <BR /><B>OPTIONAL</B>
1582     * 
1583     * @param initialVirtualTime If set, base::Time::Now will be overridden to initially return this value.
1584     * <BR /><B>OPTIONAL</B>
1585     * 
1586     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
1587     * Number&gt;</CODE>
1588     * 
1589     * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using
1590     * {@link Script#exec()}, and afterwards, a {@link Promise}<CODE>&lt;JsonObject,
1591     * Number&gt;</CODE> will be returned.
1592     *
1593     * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>,
1594     * using {@link Promise#await()}, <I>and the returned result of this Browser Function may
1595      * may be retrieved.</I>
1596     *
1597     * <BR /><BR />This Browser Function <B STYLE='color: red'>returns</B>
1598     * <BR /><BR /><UL CLASS=JDUL>
1599     * <LI><CODE>Number (<B>virtualTimeTicksBase</B></CODE>)
1600     *     <BR />Absolute timestamp at which virtual time was first enabled (up time in milliseconds).
1601     * </LI>
1602     * </UL> */
1603    public static Script<String, JsonObject, Number> setVirtualTimePolicy(
1604            String policy, Number budget, Integer maxVirtualTimeTaskStarvationCount, 
1605            Boolean waitForNavigation, Number initialVirtualTime
1606        )
1607    {
1608        // Exception-Check(s) to ensure that if any parameters which are not declared as
1609        // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
1610        
1611        if (policy == null) BRDPC.throwNPE("policy");
1612        
1613        // Exception-Check(s) to ensure that if any parameters which must adhere to a
1614        // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw.
1615        
1616        BRDPC.checkIAE("policy", policy, "Emulation.VirtualTimePolicy", Emulation.VirtualTimePolicy);
1617        
1618        final int       webSocketID = 21021000 + counter++;
1619        final boolean[] optionals   = { false, true, true, true, true, };
1620        
1621        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
1622        String requestJSON = WriteJSON.get(
1623            parameterTypes.get("setVirtualTimePolicy"),
1624            parameterNames.get("setVirtualTimePolicy"),
1625            optionals, webSocketID,
1626            "Emulation.setVirtualTimePolicy",
1627            policy, budget, maxVirtualTimeTaskStarvationCount, waitForNavigation, initialVirtualTime
1628        );
1629        
1630        // 'JSON Binding' ... Converts Browser Response-JSON to 'Number'
1631        Function<JsonObject, Number> responseProcessor = (JsonObject jo) ->
1632            ReadNumberJSON.get(jo, "virtualTimeTicksBase", false, true);
1633        
1634        // Pass the 'defaultSender' to Script-Constructor
1635        // The sender that is used can be changed before executing script.
1636        return new Script<>(BRDPC.defaultSender, webSocketID, requestJSON, responseProcessor);
1637    }
1638    
1639    /**
1640     * Overrides default host system locale with the specified one.
1641     * <BR /><B>EXPERIMENTAL</B>
1642     * 
1643     * @param locale 
1644     * ICU style C locale (e.g. "en_US"). If not specified or empty, disables the override and
1645     * restores default host system locale.
1646     * <BR /><B>OPTIONAL</B>
1647     * 
1648     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
1649     * {@link Ret0}&gt;</CODE>
1650     *
1651     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
1652     * browser receives the invocation-request.
1653     *
1654     * <BR /><BR />This Browser-Function <I>does not have</I> a return-value.  You may choose to
1655     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0}
1656     * {@code >} to ensure the Browser Function has run to completion.
1657     */
1658    public static Script<String, JsonObject, Ret0> setLocaleOverride(String locale)
1659    {
1660        final int       webSocketID = 21022000 + counter++;
1661        final boolean[] optionals   = { true, };
1662        
1663        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
1664        String requestJSON = WriteJSON.get(
1665            parameterTypes.get("setLocaleOverride"),
1666            parameterNames.get("setLocaleOverride"),
1667            optionals, webSocketID,
1668            "Emulation.setLocaleOverride",
1669            locale
1670        );
1671        
1672        // This Remote Command does not have a Return-Value.
1673        return new Script<>
1674            (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues);
1675    }
1676    
1677    /**
1678     * Overrides default host system timezone with the specified one.
1679     * <BR /><B>EXPERIMENTAL</B>
1680     * 
1681     * @param timezoneId 
1682     * The timezone identifier. If empty, disables the override and
1683     * restores default host system timezone.
1684     * 
1685     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
1686     * {@link Ret0}&gt;</CODE>
1687     *
1688     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
1689     * browser receives the invocation-request.
1690     *
1691     * <BR /><BR />This Browser-Function <I>does not have</I> a return-value.  You may choose to
1692     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0}
1693     * {@code >} to ensure the Browser Function has run to completion.
1694     */
1695    public static Script<String, JsonObject, Ret0> setTimezoneOverride(String timezoneId)
1696    {
1697        // Exception-Check(s) to ensure that if any parameters which are not declared as
1698        // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
1699        
1700        if (timezoneId == null) BRDPC.throwNPE("timezoneId");
1701        
1702        final int       webSocketID = 21023000 + counter++;
1703        final boolean[] optionals   = { false, };
1704        
1705        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
1706        String requestJSON = WriteJSON.get(
1707            parameterTypes.get("setTimezoneOverride"),
1708            parameterNames.get("setTimezoneOverride"),
1709            optionals, webSocketID,
1710            "Emulation.setTimezoneOverride",
1711            timezoneId
1712        );
1713        
1714        // This Remote Command does not have a Return-Value.
1715        return new Script<>
1716            (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues);
1717    }
1718    
1719    /**
1720     * Resizes the frame/viewport of the page. Note that this does not affect the frame's container
1721     * (e.g. browser window). Can be used to produce screenshots of the specified size. Not supported
1722     * on Android.
1723     * <BR /><B>EXPERIMENTAL</B>
1724     * <BR /><B>DEPRECATED</B>
1725     * 
1726     * @param width Frame width (DIP).
1727     * 
1728     * @param height Frame height (DIP).
1729     * 
1730     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
1731     * {@link Ret0}&gt;</CODE>
1732     *
1733     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
1734     * browser receives the invocation-request.
1735     *
1736     * <BR /><BR />This Browser-Function <I>does not have</I> a return-value.  You may choose to
1737     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0}
1738     * {@code >} to ensure the Browser Function has run to completion.
1739     */
1740    public static Script<String, JsonObject, Ret0> setVisibleSize(int width, int height)
1741    {
1742        final int       webSocketID = 21024000 + counter++;
1743        final boolean[] optionals   = { false, false, };
1744        
1745        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
1746        String requestJSON = WriteJSON.get(
1747            parameterTypes.get("setVisibleSize"),
1748            parameterNames.get("setVisibleSize"),
1749            optionals, webSocketID,
1750            "Emulation.setVisibleSize",
1751            width, height
1752        );
1753        
1754        // This Remote Command does not have a Return-Value.
1755        return new Script<>
1756            (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues);
1757    }
1758    
1759    /**
1760     * <CODE>[No Description Provided by Google]</CODE>
1761     * <BR /><B>EXPERIMENTAL</B>
1762     * 
1763     * @param imageTypes Image types to disable.
1764     * 
1765     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
1766     * {@link Ret0}&gt;</CODE>
1767     *
1768     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
1769     * browser receives the invocation-request.
1770     *
1771     * <BR /><BR />This Browser-Function <I>does not have</I> a return-value.  You may choose to
1772     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0}
1773     * {@code >} to ensure the Browser Function has run to completion.
1774     */
1775    public static Script<String, JsonObject, Ret0> setDisabledImageTypes(String[] imageTypes)
1776    {
1777        // Exception-Check(s) to ensure that if any parameters which are not declared as
1778        // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
1779        
1780        if (imageTypes == null) BRDPC.throwNPE("imageTypes");
1781        
1782        final int       webSocketID = 21025000 + counter++;
1783        final boolean[] optionals   = { false, };
1784        
1785        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
1786        String requestJSON = WriteJSON.get(
1787            parameterTypes.get("setDisabledImageTypes"),
1788            parameterNames.get("setDisabledImageTypes"),
1789            optionals, webSocketID,
1790            "Emulation.setDisabledImageTypes",
1791            (Object) imageTypes
1792        );
1793        
1794        // This Remote Command does not have a Return-Value.
1795        return new Script<>
1796            (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues);
1797    }
1798    
1799    /**
1800     * Allows overriding user agent with the given string.
1801     * 
1802     * @param userAgent User agent to use.
1803     * 
1804     * @param acceptLanguage Browser langugage to emulate.
1805     * <BR /><B>OPTIONAL</B>
1806     * 
1807     * @param platform The platform navigator.platform should return.
1808     * <BR /><B>OPTIONAL</B>
1809     * 
1810     * @param userAgentMetadata To be sent in Sec-CH-UA-* headers and returned in navigator.userAgentData
1811     * <BR /><B>OPTIONAL</B>
1812     * <BR /><B>EXPERIMENTAL</B>
1813     * 
1814     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
1815     * {@link Ret0}&gt;</CODE>
1816     *
1817     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
1818     * browser receives the invocation-request.
1819     *
1820     * <BR /><BR />This Browser-Function <I>does not have</I> a return-value.  You may choose to
1821     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0}
1822     * {@code >} to ensure the Browser Function has run to completion.
1823     */
1824    public static Script<String, JsonObject, Ret0> setUserAgentOverride(
1825            String userAgent, String acceptLanguage, String platform, 
1826            Emulation.UserAgentMetadata userAgentMetadata
1827        )
1828    {
1829        // Exception-Check(s) to ensure that if any parameters which are not declared as
1830        // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
1831        
1832        if (userAgent == null) BRDPC.throwNPE("userAgent");
1833        
1834        final int       webSocketID = 21026000 + counter++;
1835        final boolean[] optionals   = { false, true, true, true, };
1836        
1837        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
1838        String requestJSON = WriteJSON.get(
1839            parameterTypes.get("setUserAgentOverride"),
1840            parameterNames.get("setUserAgentOverride"),
1841            optionals, webSocketID,
1842            "Emulation.setUserAgentOverride",
1843            userAgent, acceptLanguage, platform, userAgentMetadata
1844        );
1845        
1846        // This Remote Command does not have a Return-Value.
1847        return new Script<>
1848            (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues);
1849    }
1850    
1851}