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