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