001package Torello.Browser.BrowserAPI; 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.Browser.BrowserEvent; 013import Torello.Browser.JavaScriptAPI.*; 014import Torello.Browser.helper.*; 015 016import Torello.Java.Additional.*; 017import Torello.Java.JSON.*; 018 019import static Torello.Java.JSON.JFlag.*; 020 021import Torello.Java.StrCmpr; 022import Torello.JavaDoc.StaticFunctional; 023import Torello.JavaDoc.JDHeaderBackgroundImg; 024import Torello.JavaDoc.Excuse; 025 026/** 027 * <SPAN CLASS=COPIEDJDK><B>This domain emulates different environments for the page.</B></SPAN> 028 * 029 * <EMBED CLASS='external-html' DATA-FILE-ID=CODE_GEN_NOTE> 030 */ 031@StaticFunctional(Excused={"counter"}, Excuses={Excuse.CONFIGURATION}) 032@JDHeaderBackgroundImg(EmbedTagFileID="WOOD_PLANK_NOTE") 033public class Emulation 034{ 035 // ******************************************************************************************** 036 // ******************************************************************************************** 037 // Class Header Stuff 038 // ******************************************************************************************** 039 // ******************************************************************************************** 040 041 042 // No Pubic Constructors 043 private Emulation () { } 044 045 // These two Vector's are used by all the "Methods" exported by this class. java.lang.reflect 046 // is used to generate the JSON String's. It saves thousands of lines of Auto-Generated Code. 047 private static final Map<String, Vector<String>> parameterNames = new HashMap<>(); 048 private static final Map<String, Vector<Class<?>>> parameterTypes = new HashMap<>(); 049 050 // Some Methods do not take any parameters - for instance all the "enable()" and "disable()" 051 // I simply could not get ride of RAW-TYPES and UNCHECKED warnings... so there are now, 052 // offically, two empty-vectors. One for String's, and the other for Classes. 053 054 private static final Vector<String> EMPTY_VEC_STR = new Vector<>(); 055 private static final Vector<Class<?>> EMPTY_VEC_CLASS = new Vector<>(); 056 057 static 058 { 059 for (Method m : Emulation.class.getMethods()) 060 { 061 // This doesn't work! The parameter names are all "arg0" ... "argN" 062 // It works for java.lang.reflect.Field, BUT NOT java.lang.reflect.Parameter! 063 // 064 // Vector<String> parameterNamesList = new Vector<>(); -- NOPE! 065 066 Vector<Class<?>> parameterTypesList = new Vector<>(); 067 068 for (Parameter p : m.getParameters()) parameterTypesList.add(p.getType()); 069 070 parameterTypes.put( 071 m.getName(), 072 (parameterTypesList.size() > 0) ? parameterTypesList : EMPTY_VEC_CLASS 073 ); 074 } 075 } 076 077 static 078 { 079 Vector<String> v = null; 080 081 parameterNames.put("canEmulate", EMPTY_VEC_STR); 082 083 parameterNames.put("clearDeviceMetricsOverride", EMPTY_VEC_STR); 084 085 parameterNames.put("clearGeolocationOverride", EMPTY_VEC_STR); 086 087 parameterNames.put("resetPageScaleFactor", EMPTY_VEC_STR); 088 089 v = new Vector<String>(1); 090 parameterNames.put("setFocusEmulationEnabled", v); 091 Collections.addAll(v, new String[] 092 { "enabled", }); 093 094 v = new Vector<String>(1); 095 parameterNames.put("setAutoDarkModeOverride", v); 096 Collections.addAll(v, new String[] 097 { "enabled", }); 098 099 v = new Vector<String>(1); 100 parameterNames.put("setCPUThrottlingRate", v); 101 Collections.addAll(v, new String[] 102 { "rate", }); 103 104 v = new Vector<String>(1); 105 parameterNames.put("setDefaultBackgroundColorOverride", v); 106 Collections.addAll(v, new String[] 107 { "color", }); 108 109 v = new Vector<String>(1); 110 parameterNames.put("setSafeAreaInsetsOverride", v); 111 Collections.addAll(v, new String[] 112 { "insets", }); 113 114 v = new Vector<String>(14); 115 parameterNames.put("setDeviceMetricsOverride", v); 116 Collections.addAll(v, new String[] 117 { "width", "height", "deviceScaleFactor", "mobile", "scale", "screenWidth", "screenHeight", "positionX", "positionY", "dontSetVisibleSize", "screenOrientation", "viewport", "displayFeature", "devicePosture", }); 118 119 v = new Vector<String>(1); 120 parameterNames.put("setDevicePostureOverride", v); 121 Collections.addAll(v, new String[] 122 { "posture", }); 123 124 parameterNames.put("clearDevicePostureOverride", EMPTY_VEC_STR); 125 126 v = new Vector<String>(1); 127 parameterNames.put("setDisplayFeaturesOverride", v); 128 Collections.addAll(v, new String[] 129 { "features", }); 130 131 parameterNames.put("clearDisplayFeaturesOverride", EMPTY_VEC_STR); 132 133 v = new Vector<String>(1); 134 parameterNames.put("setScrollbarsHidden", v); 135 Collections.addAll(v, new String[] 136 { "hidden", }); 137 138 v = new Vector<String>(1); 139 parameterNames.put("setDocumentCookieDisabled", v); 140 Collections.addAll(v, new String[] 141 { "disabled", }); 142 143 v = new Vector<String>(2); 144 parameterNames.put("setEmitTouchEventsForMouse", v); 145 Collections.addAll(v, new String[] 146 { "enabled", "configuration", }); 147 148 v = new Vector<String>(2); 149 parameterNames.put("setEmulatedMedia", v); 150 Collections.addAll(v, new String[] 151 { "media", "features", }); 152 153 v = new Vector<String>(1); 154 parameterNames.put("setEmulatedVisionDeficiency", v); 155 Collections.addAll(v, new String[] 156 { "type", }); 157 158 v = new Vector<String>(1); 159 parameterNames.put("setEmulatedOSTextScale", v); 160 Collections.addAll(v, new String[] 161 { "scale", }); 162 163 v = new Vector<String>(7); 164 parameterNames.put("setGeolocationOverride", v); 165 Collections.addAll(v, new String[] 166 { "latitude", "longitude", "accuracy", "altitude", "altitudeAccuracy", "heading", "speed", }); 167 168 v = new Vector<String>(1); 169 parameterNames.put("getOverriddenSensorInformation", v); 170 Collections.addAll(v, new String[] 171 { "type", }); 172 173 v = new Vector<String>(3); 174 parameterNames.put("setSensorOverrideEnabled", v); 175 Collections.addAll(v, new String[] 176 { "enabled", "type", "metadata", }); 177 178 v = new Vector<String>(2); 179 parameterNames.put("setSensorOverrideReadings", v); 180 Collections.addAll(v, new String[] 181 { "type", "reading", }); 182 183 v = new Vector<String>(3); 184 parameterNames.put("setPressureSourceOverrideEnabled", v); 185 Collections.addAll(v, new String[] 186 { "enabled", "source", "metadata", }); 187 188 v = new Vector<String>(2); 189 parameterNames.put("setPressureStateOverride", v); 190 Collections.addAll(v, new String[] 191 { "source", "state", }); 192 193 v = new Vector<String>(3); 194 parameterNames.put("setPressureDataOverride", v); 195 Collections.addAll(v, new String[] 196 { "source", "state", "ownContributionEstimate", }); 197 198 v = new Vector<String>(2); 199 parameterNames.put("setIdleOverride", v); 200 Collections.addAll(v, new String[] 201 { "isUserActive", "isScreenUnlocked", }); 202 203 parameterNames.put("clearIdleOverride", EMPTY_VEC_STR); 204 205 v = new Vector<String>(1); 206 parameterNames.put("setNavigatorOverrides", v); 207 Collections.addAll(v, new String[] 208 { "platform", }); 209 210 v = new Vector<String>(1); 211 parameterNames.put("setPageScaleFactor", v); 212 Collections.addAll(v, new String[] 213 { "pageScaleFactor", }); 214 215 v = new Vector<String>(1); 216 parameterNames.put("setScriptExecutionDisabled", v); 217 Collections.addAll(v, new String[] 218 { "value", }); 219 220 v = new Vector<String>(2); 221 parameterNames.put("setTouchEmulationEnabled", v); 222 Collections.addAll(v, new String[] 223 { "enabled", "maxTouchPoints", }); 224 225 v = new Vector<String>(4); 226 parameterNames.put("setVirtualTimePolicy", v); 227 Collections.addAll(v, new String[] 228 { "policy", "budget", "maxVirtualTimeTaskStarvationCount", "initialVirtualTime", }); 229 230 v = new Vector<String>(1); 231 parameterNames.put("setLocaleOverride", v); 232 Collections.addAll(v, new String[] 233 { "locale", }); 234 235 v = new Vector<String>(1); 236 parameterNames.put("setTimezoneOverride", v); 237 Collections.addAll(v, new String[] 238 { "timezoneId", }); 239 240 v = new Vector<String>(2); 241 parameterNames.put("setVisibleSize", v); 242 Collections.addAll(v, new String[] 243 { "width", "height", }); 244 245 v = new Vector<String>(1); 246 parameterNames.put("setDisabledImageTypes", v); 247 Collections.addAll(v, new String[] 248 { "imageTypes", }); 249 250 v = new Vector<String>(1); 251 parameterNames.put("setDataSaverOverride", v); 252 Collections.addAll(v, new String[] 253 { "dataSaverEnabled", }); 254 255 v = new Vector<String>(1); 256 parameterNames.put("setHardwareConcurrencyOverride", v); 257 Collections.addAll(v, new String[] 258 { "hardwareConcurrency", }); 259 260 v = new Vector<String>(4); 261 parameterNames.put("setUserAgentOverride", v); 262 Collections.addAll(v, new String[] 263 { "userAgent", "acceptLanguage", "platform", "userAgentMetadata", }); 264 265 v = new Vector<String>(1); 266 parameterNames.put("setAutomationOverride", v); 267 Collections.addAll(v, new String[] 268 { "enabled", }); 269 270 v = new Vector<String>(1); 271 parameterNames.put("setSmallViewportHeightDifferenceOverride", v); 272 Collections.addAll(v, new String[] 273 { "difference", }); 274 } 275 276 277 // ******************************************************************************************** 278 // ******************************************************************************************** 279 // Types - Static Inner Classes 280 // ******************************************************************************************** 281 // ******************************************************************************************** 282 283 /** 284 * advance: If the scheduler runs out of immediate work, the virtual time base may fast forward to 285 * allow the next delayed task (if any) to run; pause: The virtual time base may not advance; 286 * pauseIfNetworkFetchesPending: The virtual time base may not advance if there are any pending 287 * resource fetches. 288 * <BR /><B CLASS=Exp>EXPERIMENTAL</B> 289 */ 290 public static final String[] VirtualTimePolicy = 291 { "advance", "pause", "pauseIfNetworkFetchesPending", }; 292 293 /** 294 * Used to specify sensor types to emulate. 295 * See https://w3c.github.io/sensors/#automation for more information. 296 * <BR /><B CLASS=Exp>EXPERIMENTAL</B> 297 */ 298 public static final String[] SensorType = 299 { 300 "absolute-orientation", "accelerometer", "ambient-light", "gravity", "gyroscope", 301 "linear-acceleration", "magnetometer", "relative-orientation", 302 }; 303 304 /** 305 * <CODE>[No Description Provided by Google]</CODE> 306 * <BR /><B CLASS=Exp>EXPERIMENTAL</B> 307 */ 308 public static final String[] PressureSource = 309 { "cpu", }; 310 311 /** 312 * <CODE>[No Description Provided by Google]</CODE> 313 * <BR /><B CLASS=Exp>EXPERIMENTAL</B> 314 */ 315 public static final String[] PressureState = 316 { "nominal", "fair", "serious", "critical", }; 317 318 /** 319 * Enum of image types that can be disabled. 320 * <BR /><B CLASS=Exp>EXPERIMENTAL</B> 321 */ 322 public static final String[] DisabledImageType = 323 { "avif", "webp", }; 324 325 /** 326 * <CODE>[No Description Provided by Google]</CODE> 327 * <BR /><B CLASS=Exp>EXPERIMENTAL</B> 328 */ 329 public static class SafeAreaInsets 330 extends BaseType 331 implements java.io.Serializable 332 { 333 /** For Object Serialization. java.io.Serializable */ 334 protected static final long serialVersionUID = 1; 335 336 public boolean[] optionals() 337 { return new boolean[] { true, true, true, true, true, true, true, true, }; } 338 339 /** 340 * Overrides safe-area-inset-top. 341 * <BR /><B CLASS=Opt>OPTIONAL</B> 342 */ 343 public final Integer top; 344 345 /** 346 * Overrides safe-area-max-inset-top. 347 * <BR /><B CLASS=Opt>OPTIONAL</B> 348 */ 349 public final Integer topMax; 350 351 /** 352 * Overrides safe-area-inset-left. 353 * <BR /><B CLASS=Opt>OPTIONAL</B> 354 */ 355 public final Integer left; 356 357 /** 358 * Overrides safe-area-max-inset-left. 359 * <BR /><B CLASS=Opt>OPTIONAL</B> 360 */ 361 public final Integer leftMax; 362 363 /** 364 * Overrides safe-area-inset-bottom. 365 * <BR /><B CLASS=Opt>OPTIONAL</B> 366 */ 367 public final Integer bottom; 368 369 /** 370 * Overrides safe-area-max-inset-bottom. 371 * <BR /><B CLASS=Opt>OPTIONAL</B> 372 */ 373 public final Integer bottomMax; 374 375 /** 376 * Overrides safe-area-inset-right. 377 * <BR /><B CLASS=Opt>OPTIONAL</B> 378 */ 379 public final Integer right; 380 381 /** 382 * Overrides safe-area-max-inset-right. 383 * <BR /><B CLASS=Opt>OPTIONAL</B> 384 */ 385 public final Integer rightMax; 386 387 /** 388 * Constructor 389 * 390 * @param top Overrides safe-area-inset-top. 391 * <BR /><B CLASS=Opt>OPTIONAL</B> 392 * 393 * @param topMax Overrides safe-area-max-inset-top. 394 * <BR /><B CLASS=Opt>OPTIONAL</B> 395 * 396 * @param left Overrides safe-area-inset-left. 397 * <BR /><B CLASS=Opt>OPTIONAL</B> 398 * 399 * @param leftMax Overrides safe-area-max-inset-left. 400 * <BR /><B CLASS=Opt>OPTIONAL</B> 401 * 402 * @param bottom Overrides safe-area-inset-bottom. 403 * <BR /><B CLASS=Opt>OPTIONAL</B> 404 * 405 * @param bottomMax Overrides safe-area-max-inset-bottom. 406 * <BR /><B CLASS=Opt>OPTIONAL</B> 407 * 408 * @param right Overrides safe-area-inset-right. 409 * <BR /><B CLASS=Opt>OPTIONAL</B> 410 * 411 * @param rightMax Overrides safe-area-max-inset-right. 412 * <BR /><B CLASS=Opt>OPTIONAL</B> 413 */ 414 public SafeAreaInsets( 415 Integer top, Integer topMax, Integer left, Integer leftMax, Integer bottom, 416 Integer bottomMax, Integer right, Integer rightMax 417 ) 418 { 419 this.top = top; 420 this.topMax = topMax; 421 this.left = left; 422 this.leftMax = leftMax; 423 this.bottom = bottom; 424 this.bottomMax = bottomMax; 425 this.right = right; 426 this.rightMax = rightMax; 427 } 428 429 /** 430 * JSON Object Constructor 431 * @param jo A Json-Object having data about an instance of {@code 'SafeAreaInsets'}. 432 */ 433 public SafeAreaInsets (JsonObject jo) 434 { 435 this.top = ReadBoxedJSON.getInteger(jo, "top", true); 436 this.topMax = ReadBoxedJSON.getInteger(jo, "topMax", true); 437 this.left = ReadBoxedJSON.getInteger(jo, "left", true); 438 this.leftMax = ReadBoxedJSON.getInteger(jo, "leftMax", true); 439 this.bottom = ReadBoxedJSON.getInteger(jo, "bottom", true); 440 this.bottomMax = ReadBoxedJSON.getInteger(jo, "bottomMax", true); 441 this.right = ReadBoxedJSON.getInteger(jo, "right", true); 442 this.rightMax = ReadBoxedJSON.getInteger(jo, "rightMax", true); 443 } 444 445 446 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 447 public boolean equals(Object other) 448 { 449 if (this == other) return true; 450 if (other == null) return false; 451 if (other.getClass() != this.getClass()) return false; 452 453 SafeAreaInsets o = (SafeAreaInsets) other; 454 455 return 456 Objects.equals(this.top, o.top) 457 && Objects.equals(this.topMax, o.topMax) 458 && Objects.equals(this.left, o.left) 459 && Objects.equals(this.leftMax, o.leftMax) 460 && Objects.equals(this.bottom, o.bottom) 461 && Objects.equals(this.bottomMax, o.bottomMax) 462 && Objects.equals(this.right, o.right) 463 && Objects.equals(this.rightMax, o.rightMax); 464 } 465 466 /** Generates a Hash-Code for {@code 'this'} instance */ 467 public int hashCode() 468 { 469 return 470 Objects.hashCode(this.top) 471 + Objects.hashCode(this.topMax) 472 + Objects.hashCode(this.left) 473 + Objects.hashCode(this.leftMax) 474 + Objects.hashCode(this.bottom) 475 + Objects.hashCode(this.bottomMax) 476 + Objects.hashCode(this.right) 477 + Objects.hashCode(this.rightMax); 478 } 479 } 480 481 /** Screen orientation. */ 482 public static class ScreenOrientation 483 extends BaseType 484 implements java.io.Serializable 485 { 486 /** For Object Serialization. java.io.Serializable */ 487 protected static final long serialVersionUID = 1; 488 489 public boolean[] optionals() 490 { return new boolean[] { false, false, }; } 491 492 /** Orientation type. */ 493 public final String type; 494 495 /** Orientation angle. */ 496 public final int angle; 497 498 /** 499 * Constructor 500 * 501 * @param type Orientation type. 502 * <BR />Acceptable Values: ["portraitPrimary", "portraitSecondary", "landscapePrimary", "landscapeSecondary"] 503 * 504 * @param angle Orientation angle. 505 */ 506 public ScreenOrientation(String type, int angle) 507 { 508 // Exception-Check(s) to ensure that if any parameters which are not declared as 509 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 510 511 if (type == null) THROWS.throwNPE("type"); 512 513 // Exception-Check(s) to ensure that if any parameters which must adhere to a 514 // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw. 515 516 THROWS.checkIAE( 517 "type", type, 518 "portraitPrimary", "portraitSecondary", "landscapePrimary", "landscapeSecondary" 519 ); 520 521 this.type = type; 522 this.angle = angle; 523 } 524 525 /** 526 * JSON Object Constructor 527 * @param jo A Json-Object having data about an instance of {@code 'ScreenOrientation'}. 528 */ 529 public ScreenOrientation (JsonObject jo) 530 { 531 this.type = ReadJSON.getString(jo, "type", false, true); 532 this.angle = ReadPrimJSON.getInt(jo, "angle"); 533 } 534 535 536 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 537 public boolean equals(Object other) 538 { 539 if (this == other) return true; 540 if (other == null) return false; 541 if (other.getClass() != this.getClass()) return false; 542 543 ScreenOrientation o = (ScreenOrientation) other; 544 545 return 546 Objects.equals(this.type, o.type) 547 && (this.angle == o.angle); 548 } 549 550 /** Generates a Hash-Code for {@code 'this'} instance */ 551 public int hashCode() 552 { 553 return 554 Objects.hashCode(this.type) 555 + this.angle; 556 } 557 } 558 559 /** <CODE>[No Description Provided by Google]</CODE> */ 560 public static class DisplayFeature 561 extends BaseType 562 implements java.io.Serializable 563 { 564 /** For Object Serialization. java.io.Serializable */ 565 protected static final long serialVersionUID = 1; 566 567 public boolean[] optionals() 568 { return new boolean[] { false, false, false, }; } 569 570 /** Orientation of a display feature in relation to screen */ 571 public final String orientation; 572 573 /** 574 * The offset from the screen origin in either the x (for vertical 575 * orientation) or y (for horizontal orientation) direction. 576 */ 577 public final int offset; 578 579 /** 580 * A display feature may mask content such that it is not physically 581 * displayed - this length along with the offset describes this area. 582 * A display feature that only splits content will have a 0 mask_length. 583 */ 584 public final int maskLength; 585 586 /** 587 * Constructor 588 * 589 * @param orientation Orientation of a display feature in relation to screen 590 * <BR />Acceptable Values: ["vertical", "horizontal"] 591 * 592 * @param offset 593 * The offset from the screen origin in either the x (for vertical 594 * orientation) or y (for horizontal orientation) direction. 595 * 596 * @param maskLength 597 * A display feature may mask content such that it is not physically 598 * displayed - this length along with the offset describes this area. 599 * A display feature that only splits content will have a 0 mask_length. 600 */ 601 public DisplayFeature(String orientation, int offset, int maskLength) 602 { 603 // Exception-Check(s) to ensure that if any parameters which are not declared as 604 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 605 606 if (orientation == null) THROWS.throwNPE("orientation"); 607 608 // Exception-Check(s) to ensure that if any parameters which must adhere to a 609 // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw. 610 611 THROWS.checkIAE( 612 "orientation", orientation, 613 "vertical", "horizontal" 614 ); 615 616 this.orientation = orientation; 617 this.offset = offset; 618 this.maskLength = maskLength; 619 } 620 621 /** 622 * JSON Object Constructor 623 * @param jo A Json-Object having data about an instance of {@code 'DisplayFeature'}. 624 */ 625 public DisplayFeature (JsonObject jo) 626 { 627 this.orientation = ReadJSON.getString(jo, "orientation", false, true); 628 this.offset = ReadPrimJSON.getInt(jo, "offset"); 629 this.maskLength = ReadPrimJSON.getInt(jo, "maskLength"); 630 } 631 632 633 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 634 public boolean equals(Object other) 635 { 636 if (this == other) return true; 637 if (other == null) return false; 638 if (other.getClass() != this.getClass()) return false; 639 640 DisplayFeature o = (DisplayFeature) other; 641 642 return 643 Objects.equals(this.orientation, o.orientation) 644 && (this.offset == o.offset) 645 && (this.maskLength == o.maskLength); 646 } 647 648 /** Generates a Hash-Code for {@code 'this'} instance */ 649 public int hashCode() 650 { 651 return 652 Objects.hashCode(this.orientation) 653 + this.offset 654 + this.maskLength; 655 } 656 } 657 658 /** <CODE>[No Description Provided by Google]</CODE> */ 659 public static class DevicePosture 660 extends BaseType 661 implements java.io.Serializable 662 { 663 /** For Object Serialization. java.io.Serializable */ 664 protected static final long serialVersionUID = 1; 665 666 public boolean[] optionals() 667 { return new boolean[] { false, }; } 668 669 /** Current posture of the device */ 670 public final String type; 671 672 /** 673 * Constructor 674 * 675 * @param type Current posture of the device 676 * <BR />Acceptable Values: ["continuous", "folded"] 677 */ 678 public DevicePosture(String type) 679 { 680 // Exception-Check(s) to ensure that if any parameters which are not declared as 681 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 682 683 if (type == null) THROWS.throwNPE("type"); 684 685 // Exception-Check(s) to ensure that if any parameters which must adhere to a 686 // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw. 687 688 THROWS.checkIAE( 689 "type", type, 690 "continuous", "folded" 691 ); 692 693 this.type = type; 694 } 695 696 /** 697 * JSON Object Constructor 698 * @param jo A Json-Object having data about an instance of {@code 'DevicePosture'}. 699 */ 700 public DevicePosture (JsonObject jo) 701 { 702 this.type = ReadJSON.getString(jo, "type", false, true); 703 } 704 705 706 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 707 public boolean equals(Object other) 708 { 709 if (this == other) return true; 710 if (other == null) return false; 711 if (other.getClass() != this.getClass()) return false; 712 713 DevicePosture o = (DevicePosture) other; 714 715 return 716 Objects.equals(this.type, o.type); 717 } 718 719 /** Generates a Hash-Code for {@code 'this'} instance */ 720 public int hashCode() 721 { 722 return 723 Objects.hashCode(this.type); 724 } 725 } 726 727 /** <CODE>[No Description Provided by Google]</CODE> */ 728 public static class MediaFeature 729 extends BaseType 730 implements java.io.Serializable 731 { 732 /** For Object Serialization. java.io.Serializable */ 733 protected static final long serialVersionUID = 1; 734 735 public boolean[] optionals() 736 { return new boolean[] { false, false, }; } 737 738 /** <CODE>[No Description Provided by Google]</CODE> */ 739 public final String name; 740 741 /** <CODE>[No Description Provided by Google]</CODE> */ 742 public final String value; 743 744 /** 745 * Constructor 746 * 747 * @param name - 748 * 749 * @param value - 750 */ 751 public MediaFeature(String name, String value) 752 { 753 // Exception-Check(s) to ensure that if any parameters which are not declared as 754 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 755 756 if (name == null) THROWS.throwNPE("name"); 757 if (value == null) THROWS.throwNPE("value"); 758 759 this.name = name; 760 this.value = value; 761 } 762 763 /** 764 * JSON Object Constructor 765 * @param jo A Json-Object having data about an instance of {@code 'MediaFeature'}. 766 */ 767 public MediaFeature (JsonObject jo) 768 { 769 this.name = ReadJSON.getString(jo, "name", false, true); 770 this.value = ReadJSON.getString(jo, "value", false, true); 771 } 772 773 774 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 775 public boolean equals(Object other) 776 { 777 if (this == other) return true; 778 if (other == null) return false; 779 if (other.getClass() != this.getClass()) return false; 780 781 MediaFeature o = (MediaFeature) other; 782 783 return 784 Objects.equals(this.name, o.name) 785 && Objects.equals(this.value, o.value); 786 } 787 788 /** Generates a Hash-Code for {@code 'this'} instance */ 789 public int hashCode() 790 { 791 return 792 Objects.hashCode(this.name) 793 + Objects.hashCode(this.value); 794 } 795 } 796 797 /** 798 * Used to specify User Agent Client Hints to emulate. See https://wicg.github.io/ua-client-hints 799 * <BR /><B CLASS=Exp>EXPERIMENTAL</B> 800 */ 801 public static class UserAgentBrandVersion 802 extends BaseType 803 implements java.io.Serializable 804 { 805 /** For Object Serialization. java.io.Serializable */ 806 protected static final long serialVersionUID = 1; 807 808 public boolean[] optionals() 809 { return new boolean[] { false, false, }; } 810 811 /** <CODE>[No Description Provided by Google]</CODE> */ 812 public final String brand; 813 814 /** <CODE>[No Description Provided by Google]</CODE> */ 815 public final String version; 816 817 /** 818 * Constructor 819 * 820 * @param brand - 821 * 822 * @param version - 823 */ 824 public UserAgentBrandVersion(String brand, String version) 825 { 826 // Exception-Check(s) to ensure that if any parameters which are not declared as 827 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 828 829 if (brand == null) THROWS.throwNPE("brand"); 830 if (version == null) THROWS.throwNPE("version"); 831 832 this.brand = brand; 833 this.version = version; 834 } 835 836 /** 837 * JSON Object Constructor 838 * @param jo A Json-Object having data about an instance of {@code 'UserAgentBrandVersion'}. 839 */ 840 public UserAgentBrandVersion (JsonObject jo) 841 { 842 this.brand = ReadJSON.getString(jo, "brand", false, true); 843 this.version = ReadJSON.getString(jo, "version", false, true); 844 } 845 846 847 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 848 public boolean equals(Object other) 849 { 850 if (this == other) return true; 851 if (other == null) return false; 852 if (other.getClass() != this.getClass()) return false; 853 854 UserAgentBrandVersion o = (UserAgentBrandVersion) other; 855 856 return 857 Objects.equals(this.brand, o.brand) 858 && Objects.equals(this.version, o.version); 859 } 860 861 /** Generates a Hash-Code for {@code 'this'} instance */ 862 public int hashCode() 863 { 864 return 865 Objects.hashCode(this.brand) 866 + Objects.hashCode(this.version); 867 } 868 } 869 870 /** 871 * Used to specify User Agent Client Hints to emulate. See https://wicg.github.io/ua-client-hints 872 * Missing optional values will be filled in by the target with what it would normally use. 873 * <BR /><B CLASS=Exp>EXPERIMENTAL</B> 874 */ 875 public static class UserAgentMetadata 876 extends BaseType 877 implements java.io.Serializable 878 { 879 /** For Object Serialization. java.io.Serializable */ 880 protected static final long serialVersionUID = 1; 881 882 public boolean[] optionals() 883 { return new boolean[] { true, true, true, false, false, false, false, false, true, true, true, }; } 884 885 /** 886 * Brands appearing in Sec-CH-UA. 887 * <BR /><B CLASS=Opt>OPTIONAL</B> 888 */ 889 public final Emulation.UserAgentBrandVersion[] brands; 890 891 /** 892 * Brands appearing in Sec-CH-UA-Full-Version-List. 893 * <BR /><B CLASS=Opt>OPTIONAL</B> 894 */ 895 public final Emulation.UserAgentBrandVersion[] fullVersionList; 896 897 /** 898 * <CODE>[No Description Provided by Google]</CODE> 899 * <BR /><B CLASS=Opt>OPTIONAL</B> 900 <B CLASS=Dep>DEPRECATED</B> 901 */ 902 public final String fullVersion; 903 904 /** <CODE>[No Description Provided by Google]</CODE> */ 905 public final String platform; 906 907 /** <CODE>[No Description Provided by Google]</CODE> */ 908 public final String platformVersion; 909 910 /** <CODE>[No Description Provided by Google]</CODE> */ 911 public final String architecture; 912 913 /** <CODE>[No Description Provided by Google]</CODE> */ 914 public final String model; 915 916 /** <CODE>[No Description Provided by Google]</CODE> */ 917 public final boolean mobile; 918 919 /** 920 * <CODE>[No Description Provided by Google]</CODE> 921 * <BR /><B CLASS=Opt>OPTIONAL</B> 922 */ 923 public final String bitness; 924 925 /** 926 * <CODE>[No Description Provided by Google]</CODE> 927 * <BR /><B CLASS=Opt>OPTIONAL</B> 928 */ 929 public final Boolean wow64; 930 931 /** 932 * Used to specify User Agent form-factor values. 933 * See https://wicg.github.io/ua-client-hints/#sec-ch-ua-form-factors 934 * <BR /><B CLASS=Opt>OPTIONAL</B> 935 */ 936 public final String[] formFactors; 937 938 /** 939 * Constructor 940 * 941 * @param brands Brands appearing in Sec-CH-UA. 942 * <BR /><B CLASS=Opt>OPTIONAL</B> 943 * 944 * @param fullVersionList Brands appearing in Sec-CH-UA-Full-Version-List. 945 * <BR /><B CLASS=Opt>OPTIONAL</B> 946 * 947 * @param fullVersion - 948 * <BR /><B CLASS=Opt>OPTIONAL</B><B CLASS=Dep>DEPRECATED</B> 949 * 950 * @param platform - 951 * 952 * @param platformVersion - 953 * 954 * @param architecture - 955 * 956 * @param model - 957 * 958 * @param mobile - 959 * 960 * @param bitness - 961 * <BR /><B CLASS=Opt>OPTIONAL</B> 962 * 963 * @param wow64 - 964 * <BR /><B CLASS=Opt>OPTIONAL</B> 965 * 966 * @param formFactors 967 * Used to specify User Agent form-factor values. 968 * See https://wicg.github.io/ua-client-hints/#sec-ch-ua-form-factors 969 * <BR /><B CLASS=Opt>OPTIONAL</B> 970 */ 971 public UserAgentMetadata( 972 Emulation.UserAgentBrandVersion[] brands, 973 Emulation.UserAgentBrandVersion[] fullVersionList, String fullVersion, 974 String platform, String platformVersion, String architecture, String model, 975 boolean mobile, String bitness, Boolean wow64, String[] formFactors 976 ) 977 { 978 // Exception-Check(s) to ensure that if any parameters which are not declared as 979 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 980 981 if (platform == null) THROWS.throwNPE("platform"); 982 if (platformVersion == null) THROWS.throwNPE("platformVersion"); 983 if (architecture == null) THROWS.throwNPE("architecture"); 984 if (model == null) THROWS.throwNPE("model"); 985 986 this.brands = brands; 987 this.fullVersionList = fullVersionList; 988 this.fullVersion = fullVersion; 989 this.platform = platform; 990 this.platformVersion = platformVersion; 991 this.architecture = architecture; 992 this.model = model; 993 this.mobile = mobile; 994 this.bitness = bitness; 995 this.wow64 = wow64; 996 this.formFactors = formFactors; 997 } 998 999 /** 1000 * JSON Object Constructor 1001 * @param jo A Json-Object having data about an instance of {@code 'UserAgentMetadata'}. 1002 */ 1003 public UserAgentMetadata (JsonObject jo) 1004 { 1005 this.brands = (jo.getJsonArray("brands") == null) 1006 ? null 1007 : RJArrIntoStream.objArr(jo.getJsonArray("brands"), null, 0, Emulation.UserAgentBrandVersion.class).toArray(Emulation.UserAgentBrandVersion[]::new); 1008 1009 this.fullVersionList = (jo.getJsonArray("fullVersionList") == null) 1010 ? null 1011 : RJArrIntoStream.objArr(jo.getJsonArray("fullVersionList"), null, 0, Emulation.UserAgentBrandVersion.class).toArray(Emulation.UserAgentBrandVersion[]::new); 1012 1013 this.fullVersion = ReadJSON.getString(jo, "fullVersion", true, false); 1014 this.platform = ReadJSON.getString(jo, "platform", false, true); 1015 this.platformVersion = ReadJSON.getString(jo, "platformVersion", false, true); 1016 this.architecture = ReadJSON.getString(jo, "architecture", false, true); 1017 this.model = ReadJSON.getString(jo, "model", false, true); 1018 this.mobile = ReadPrimJSON.getBoolean(jo, "mobile"); 1019 this.bitness = ReadJSON.getString(jo, "bitness", true, false); 1020 this.wow64 = ReadBoxedJSON.getBoolean(jo, "wow64", true); 1021 this.formFactors = (jo.getJsonArray("formFactors") == null) 1022 ? null 1023 : RJArrIntoStream.strArr(jo.getJsonArray("formFactors"), null, 0).toArray(String[]::new); 1024 1025 } 1026 1027 1028 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 1029 public boolean equals(Object other) 1030 { 1031 if (this == other) return true; 1032 if (other == null) return false; 1033 if (other.getClass() != this.getClass()) return false; 1034 1035 UserAgentMetadata o = (UserAgentMetadata) other; 1036 1037 return 1038 Arrays.deepEquals(this.brands, o.brands) 1039 && Arrays.deepEquals(this.fullVersionList, o.fullVersionList) 1040 && Objects.equals(this.fullVersion, o.fullVersion) 1041 && Objects.equals(this.platform, o.platform) 1042 && Objects.equals(this.platformVersion, o.platformVersion) 1043 && Objects.equals(this.architecture, o.architecture) 1044 && Objects.equals(this.model, o.model) 1045 && (this.mobile == o.mobile) 1046 && Objects.equals(this.bitness, o.bitness) 1047 && Objects.equals(this.wow64, o.wow64) 1048 && Arrays.deepEquals(this.formFactors, o.formFactors); 1049 } 1050 1051 /** Generates a Hash-Code for {@code 'this'} instance */ 1052 public int hashCode() 1053 { 1054 return 1055 Arrays.deepHashCode(this.brands) 1056 + Arrays.deepHashCode(this.fullVersionList) 1057 + Objects.hashCode(this.fullVersion) 1058 + Objects.hashCode(this.platform) 1059 + Objects.hashCode(this.platformVersion) 1060 + Objects.hashCode(this.architecture) 1061 + Objects.hashCode(this.model) 1062 + (this.mobile ? 1 : 0) 1063 + Objects.hashCode(this.bitness) 1064 + Objects.hashCode(this.wow64) 1065 + Arrays.deepHashCode(this.formFactors); 1066 } 1067 } 1068 1069 /** 1070 * <CODE>[No Description Provided by Google]</CODE> 1071 * <BR /><B CLASS=Exp>EXPERIMENTAL</B> 1072 */ 1073 public static class SensorMetadata 1074 extends BaseType 1075 implements java.io.Serializable 1076 { 1077 /** For Object Serialization. java.io.Serializable */ 1078 protected static final long serialVersionUID = 1; 1079 1080 public boolean[] optionals() 1081 { return new boolean[] { true, true, true, }; } 1082 1083 /** 1084 * <CODE>[No Description Provided by Google]</CODE> 1085 * <BR /><B CLASS=Opt>OPTIONAL</B> 1086 */ 1087 public final Boolean available; 1088 1089 /** 1090 * <CODE>[No Description Provided by Google]</CODE> 1091 * <BR /><B CLASS=Opt>OPTIONAL</B> 1092 */ 1093 public final Number minimumFrequency; 1094 1095 /** 1096 * <CODE>[No Description Provided by Google]</CODE> 1097 * <BR /><B CLASS=Opt>OPTIONAL</B> 1098 */ 1099 public final Number maximumFrequency; 1100 1101 /** 1102 * Constructor 1103 * 1104 * @param available - 1105 * <BR /><B CLASS=Opt>OPTIONAL</B> 1106 * 1107 * @param minimumFrequency - 1108 * <BR /><B CLASS=Opt>OPTIONAL</B> 1109 * 1110 * @param maximumFrequency - 1111 * <BR /><B CLASS=Opt>OPTIONAL</B> 1112 */ 1113 public SensorMetadata 1114 (Boolean available, Number minimumFrequency, Number maximumFrequency) 1115 { 1116 this.available = available; 1117 this.minimumFrequency = minimumFrequency; 1118 this.maximumFrequency = maximumFrequency; 1119 } 1120 1121 /** 1122 * JSON Object Constructor 1123 * @param jo A Json-Object having data about an instance of {@code 'SensorMetadata'}. 1124 */ 1125 public SensorMetadata (JsonObject jo) 1126 { 1127 this.available = ReadBoxedJSON.getBoolean(jo, "available", true); 1128 this.minimumFrequency = ReadNumberJSON.get(jo, "minimumFrequency", true, false); 1129 this.maximumFrequency = ReadNumberJSON.get(jo, "maximumFrequency", true, false); 1130 } 1131 1132 1133 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 1134 public boolean equals(Object other) 1135 { 1136 if (this == other) return true; 1137 if (other == null) return false; 1138 if (other.getClass() != this.getClass()) return false; 1139 1140 SensorMetadata o = (SensorMetadata) other; 1141 1142 return 1143 Objects.equals(this.available, o.available) 1144 && Objects.equals(this.minimumFrequency, o.minimumFrequency) 1145 && Objects.equals(this.maximumFrequency, o.maximumFrequency); 1146 } 1147 1148 /** Generates a Hash-Code for {@code 'this'} instance */ 1149 public int hashCode() 1150 { 1151 return 1152 Objects.hashCode(this.available) 1153 + Objects.hashCode(this.minimumFrequency) 1154 + Objects.hashCode(this.maximumFrequency); 1155 } 1156 } 1157 1158 /** 1159 * <CODE>[No Description Provided by Google]</CODE> 1160 * <BR /><B CLASS=Exp>EXPERIMENTAL</B> 1161 */ 1162 public static class SensorReadingSingle 1163 extends BaseType 1164 implements java.io.Serializable 1165 { 1166 /** For Object Serialization. java.io.Serializable */ 1167 protected static final long serialVersionUID = 1; 1168 1169 public boolean[] optionals() 1170 { return new boolean[] { false, }; } 1171 1172 /** <CODE>[No Description Provided by Google]</CODE> */ 1173 public final Number value; 1174 1175 /** 1176 * Constructor 1177 * 1178 * @param value - 1179 */ 1180 public SensorReadingSingle(Number value) 1181 { 1182 // Exception-Check(s) to ensure that if any parameters which are not declared as 1183 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 1184 1185 if (value == null) THROWS.throwNPE("value"); 1186 1187 this.value = value; 1188 } 1189 1190 /** 1191 * JSON Object Constructor 1192 * @param jo A Json-Object having data about an instance of {@code 'SensorReadingSingle'}. 1193 */ 1194 public SensorReadingSingle (JsonObject jo) 1195 { 1196 this.value = ReadNumberJSON.get(jo, "value", false, true); 1197 } 1198 1199 1200 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 1201 public boolean equals(Object other) 1202 { 1203 if (this == other) return true; 1204 if (other == null) return false; 1205 if (other.getClass() != this.getClass()) return false; 1206 1207 SensorReadingSingle o = (SensorReadingSingle) other; 1208 1209 return 1210 Objects.equals(this.value, o.value); 1211 } 1212 1213 /** Generates a Hash-Code for {@code 'this'} instance */ 1214 public int hashCode() 1215 { 1216 return 1217 Objects.hashCode(this.value); 1218 } 1219 } 1220 1221 /** 1222 * <CODE>[No Description Provided by Google]</CODE> 1223 * <BR /><B CLASS=Exp>EXPERIMENTAL</B> 1224 */ 1225 public static class SensorReadingXYZ 1226 extends BaseType 1227 implements java.io.Serializable 1228 { 1229 /** For Object Serialization. java.io.Serializable */ 1230 protected static final long serialVersionUID = 1; 1231 1232 public boolean[] optionals() 1233 { return new boolean[] { false, false, false, }; } 1234 1235 /** <CODE>[No Description Provided by Google]</CODE> */ 1236 public final Number x; 1237 1238 /** <CODE>[No Description Provided by Google]</CODE> */ 1239 public final Number y; 1240 1241 /** <CODE>[No Description Provided by Google]</CODE> */ 1242 public final Number z; 1243 1244 /** 1245 * Constructor 1246 * 1247 * @param x - 1248 * 1249 * @param y - 1250 * 1251 * @param z - 1252 */ 1253 public SensorReadingXYZ(Number x, Number y, Number z) 1254 { 1255 // Exception-Check(s) to ensure that if any parameters which are not declared as 1256 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 1257 1258 if (x == null) THROWS.throwNPE("x"); 1259 if (y == null) THROWS.throwNPE("y"); 1260 if (z == null) THROWS.throwNPE("z"); 1261 1262 this.x = x; 1263 this.y = y; 1264 this.z = z; 1265 } 1266 1267 /** 1268 * JSON Object Constructor 1269 * @param jo A Json-Object having data about an instance of {@code 'SensorReadingXYZ'}. 1270 */ 1271 public SensorReadingXYZ (JsonObject jo) 1272 { 1273 this.x = ReadNumberJSON.get(jo, "x", false, true); 1274 this.y = ReadNumberJSON.get(jo, "y", false, true); 1275 this.z = ReadNumberJSON.get(jo, "z", false, true); 1276 } 1277 1278 1279 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 1280 public boolean equals(Object other) 1281 { 1282 if (this == other) return true; 1283 if (other == null) return false; 1284 if (other.getClass() != this.getClass()) return false; 1285 1286 SensorReadingXYZ o = (SensorReadingXYZ) other; 1287 1288 return 1289 Objects.equals(this.x, o.x) 1290 && Objects.equals(this.y, o.y) 1291 && Objects.equals(this.z, o.z); 1292 } 1293 1294 /** Generates a Hash-Code for {@code 'this'} instance */ 1295 public int hashCode() 1296 { 1297 return 1298 Objects.hashCode(this.x) 1299 + Objects.hashCode(this.y) 1300 + Objects.hashCode(this.z); 1301 } 1302 } 1303 1304 /** 1305 * <CODE>[No Description Provided by Google]</CODE> 1306 * <BR /><B CLASS=Exp>EXPERIMENTAL</B> 1307 */ 1308 public static class SensorReadingQuaternion 1309 extends BaseType 1310 implements java.io.Serializable 1311 { 1312 /** For Object Serialization. java.io.Serializable */ 1313 protected static final long serialVersionUID = 1; 1314 1315 public boolean[] optionals() 1316 { return new boolean[] { false, false, false, false, }; } 1317 1318 /** <CODE>[No Description Provided by Google]</CODE> */ 1319 public final Number x; 1320 1321 /** <CODE>[No Description Provided by Google]</CODE> */ 1322 public final Number y; 1323 1324 /** <CODE>[No Description Provided by Google]</CODE> */ 1325 public final Number z; 1326 1327 /** <CODE>[No Description Provided by Google]</CODE> */ 1328 public final Number w; 1329 1330 /** 1331 * Constructor 1332 * 1333 * @param x - 1334 * 1335 * @param y - 1336 * 1337 * @param z - 1338 * 1339 * @param w - 1340 */ 1341 public SensorReadingQuaternion(Number x, Number y, Number z, Number w) 1342 { 1343 // Exception-Check(s) to ensure that if any parameters which are not declared as 1344 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 1345 1346 if (x == null) THROWS.throwNPE("x"); 1347 if (y == null) THROWS.throwNPE("y"); 1348 if (z == null) THROWS.throwNPE("z"); 1349 if (w == null) THROWS.throwNPE("w"); 1350 1351 this.x = x; 1352 this.y = y; 1353 this.z = z; 1354 this.w = w; 1355 } 1356 1357 /** 1358 * JSON Object Constructor 1359 * @param jo A Json-Object having data about an instance of {@code 'SensorReadingQuaternion'}. 1360 */ 1361 public SensorReadingQuaternion (JsonObject jo) 1362 { 1363 this.x = ReadNumberJSON.get(jo, "x", false, true); 1364 this.y = ReadNumberJSON.get(jo, "y", false, true); 1365 this.z = ReadNumberJSON.get(jo, "z", false, true); 1366 this.w = ReadNumberJSON.get(jo, "w", false, true); 1367 } 1368 1369 1370 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 1371 public boolean equals(Object other) 1372 { 1373 if (this == other) return true; 1374 if (other == null) return false; 1375 if (other.getClass() != this.getClass()) return false; 1376 1377 SensorReadingQuaternion o = (SensorReadingQuaternion) other; 1378 1379 return 1380 Objects.equals(this.x, o.x) 1381 && Objects.equals(this.y, o.y) 1382 && Objects.equals(this.z, o.z) 1383 && Objects.equals(this.w, o.w); 1384 } 1385 1386 /** Generates a Hash-Code for {@code 'this'} instance */ 1387 public int hashCode() 1388 { 1389 return 1390 Objects.hashCode(this.x) 1391 + Objects.hashCode(this.y) 1392 + Objects.hashCode(this.z) 1393 + Objects.hashCode(this.w); 1394 } 1395 } 1396 1397 /** 1398 * <CODE>[No Description Provided by Google]</CODE> 1399 * <BR /><B CLASS=Exp>EXPERIMENTAL</B> 1400 */ 1401 public static class SensorReading 1402 extends BaseType 1403 implements java.io.Serializable 1404 { 1405 /** For Object Serialization. java.io.Serializable */ 1406 protected static final long serialVersionUID = 1; 1407 1408 public boolean[] optionals() 1409 { return new boolean[] { true, true, true, }; } 1410 1411 /** 1412 * <CODE>[No Description Provided by Google]</CODE> 1413 * <BR /><B CLASS=Opt>OPTIONAL</B> 1414 */ 1415 public final Emulation.SensorReadingSingle single; 1416 1417 /** 1418 * <CODE>[No Description Provided by Google]</CODE> 1419 * <BR /><B CLASS=Opt>OPTIONAL</B> 1420 */ 1421 public final Emulation.SensorReadingXYZ xyz; 1422 1423 /** 1424 * <CODE>[No Description Provided by Google]</CODE> 1425 * <BR /><B CLASS=Opt>OPTIONAL</B> 1426 */ 1427 public final Emulation.SensorReadingQuaternion quaternion; 1428 1429 /** 1430 * Constructor 1431 * 1432 * @param single - 1433 * <BR /><B CLASS=Opt>OPTIONAL</B> 1434 * 1435 * @param xyz - 1436 * <BR /><B CLASS=Opt>OPTIONAL</B> 1437 * 1438 * @param quaternion - 1439 * <BR /><B CLASS=Opt>OPTIONAL</B> 1440 */ 1441 public SensorReading( 1442 Emulation.SensorReadingSingle single, Emulation.SensorReadingXYZ xyz, 1443 Emulation.SensorReadingQuaternion quaternion 1444 ) 1445 { 1446 this.single = single; 1447 this.xyz = xyz; 1448 this.quaternion = quaternion; 1449 } 1450 1451 /** 1452 * JSON Object Constructor 1453 * @param jo A Json-Object having data about an instance of {@code 'SensorReading'}. 1454 */ 1455 public SensorReading (JsonObject jo) 1456 { 1457 this.single = ReadJSON.getObject(jo, "single", Emulation.SensorReadingSingle.class, true, false); 1458 this.xyz = ReadJSON.getObject(jo, "xyz", Emulation.SensorReadingXYZ.class, true, false); 1459 this.quaternion = ReadJSON.getObject(jo, "quaternion", Emulation.SensorReadingQuaternion.class, true, false); 1460 } 1461 1462 1463 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 1464 public boolean equals(Object other) 1465 { 1466 if (this == other) return true; 1467 if (other == null) return false; 1468 if (other.getClass() != this.getClass()) return false; 1469 1470 SensorReading o = (SensorReading) other; 1471 1472 return 1473 Objects.equals(this.single, o.single) 1474 && Objects.equals(this.xyz, o.xyz) 1475 && Objects.equals(this.quaternion, o.quaternion); 1476 } 1477 1478 /** Generates a Hash-Code for {@code 'this'} instance */ 1479 public int hashCode() 1480 { 1481 return 1482 this.single.hashCode() 1483 + this.xyz.hashCode() 1484 + this.quaternion.hashCode(); 1485 } 1486 } 1487 1488 /** 1489 * <CODE>[No Description Provided by Google]</CODE> 1490 * <BR /><B CLASS=Exp>EXPERIMENTAL</B> 1491 */ 1492 public static class PressureMetadata 1493 extends BaseType 1494 implements java.io.Serializable 1495 { 1496 /** For Object Serialization. java.io.Serializable */ 1497 protected static final long serialVersionUID = 1; 1498 1499 public boolean[] optionals() 1500 { return new boolean[] { true, }; } 1501 1502 /** 1503 * <CODE>[No Description Provided by Google]</CODE> 1504 * <BR /><B CLASS=Opt>OPTIONAL</B> 1505 */ 1506 public final Boolean available; 1507 1508 /** 1509 * Constructor 1510 * 1511 * @param available - 1512 * <BR /><B CLASS=Opt>OPTIONAL</B> 1513 */ 1514 public PressureMetadata(Boolean available) 1515 { 1516 this.available = available; 1517 } 1518 1519 /** 1520 * JSON Object Constructor 1521 * @param jo A Json-Object having data about an instance of {@code 'PressureMetadata'}. 1522 */ 1523 public PressureMetadata (JsonObject jo) 1524 { 1525 this.available = ReadBoxedJSON.getBoolean(jo, "available", true); 1526 } 1527 1528 1529 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 1530 public boolean equals(Object other) 1531 { 1532 if (this == other) return true; 1533 if (other == null) return false; 1534 if (other.getClass() != this.getClass()) return false; 1535 1536 PressureMetadata o = (PressureMetadata) other; 1537 1538 return 1539 Objects.equals(this.available, o.available); 1540 } 1541 1542 /** Generates a Hash-Code for {@code 'this'} instance */ 1543 public int hashCode() 1544 { 1545 return 1546 Objects.hashCode(this.available); 1547 } 1548 } 1549 1550 /** 1551 * Notification sent after the virtual time budget for the current VirtualTimePolicy has run out. 1552 * <BR /> 1553 * <BR /><B>EXPERIMENTAL</B> 1554 * 1555 * <BR /><BR />This is Marker-Event. Marker-Event's are Events that do not posses 1556 * any data, fields or state. When they are fired, only the event name is supplied. 1557 */ 1558 public static class virtualTimeBudgetExpired 1559 extends BrowserEvent 1560 implements java.io.Serializable 1561 { 1562 /** For Object Serialization. java.io.Serializable */ 1563 protected static final long serialVersionUID = 1; 1564 1565 public boolean[] optionals() { return new boolean[0]; } 1566 1567 /** JSON Object Constructor */ 1568 public virtualTimeBudgetExpired(JsonObject jo) 1569 { super("Emulation", "virtualTimeBudgetExpired", 0); } 1570 1571 @Override 1572 public String toString() { return "Emulation.virtualTimeBudgetExpired Marker Event\n"; } 1573 } 1574 1575 1576 // Counter for keeping the WebSocket Request ID's distinct. 1577 private static int counter = 1; 1578 1579 /** 1580 * Tells whether emulation is supported. 1581 * <BR /><B CLASS=Dep-Top>DEPRECATED</B> 1582 * 1583 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 1584 * Boolean></CODE> 1585 * 1586 * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using 1587 * {@link Script#exec()}, and afterwards, a {@link Promise}<CODE><JsonObject, 1588 * Boolean></CODE> will be returned. 1589 * 1590 * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>, 1591 * using {@link Promise#await()}, <I>and the returned result of this Browser Function may 1592 * may be retrieved.</I> 1593 * 1594 * <BR /><BR />This Browser Function <B STYLE='color: red'>returns</B> 1595 * <BR /><BR /><UL CLASS=JDUL> 1596 * <LI><CODE>Boolean (<B>result</B></CODE>) 1597 * <BR />True if emulation is supported. 1598 * </LI> 1599 * </UL> */ 1600 public static Script<String, JsonObject, Boolean> canEmulate() 1601 { 1602 final int webSocketID = 23000000 + counter++; 1603 final boolean[] optionals = new boolean[0]; 1604 1605 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 1606 String requestJSON = WriteJSON.get( 1607 parameterTypes.get("canEmulate"), 1608 parameterNames.get("canEmulate"), 1609 optionals, webSocketID, 1610 "Emulation.canEmulate" 1611 ); 1612 1613 // 'JSON Binding' ... Converts Browser Response-JSON to 'Boolean' 1614 Function<JsonObject, Boolean> responseProcessor = (JsonObject jo) -> 1615 ReadPrimJSON.getBoolean(jo, "result"); 1616 1617 return new Script<>(webSocketID, requestJSON, responseProcessor); 1618 } 1619 1620 /** 1621 * Clears the overridden device metrics. 1622 * 1623 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 1624 * {@link Ret0}></CODE> 1625 * 1626 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 1627 * browser receives the invocation-request. 1628 * 1629 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 1630 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 1631 * {@code >} to ensure the Browser Function has run to completion. 1632 */ 1633 public static Script<String, JsonObject, Ret0> clearDeviceMetricsOverride() 1634 { 1635 final int webSocketID = 23001000 + counter++; 1636 final boolean[] optionals = new boolean[0]; 1637 1638 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 1639 String requestJSON = WriteJSON.get( 1640 parameterTypes.get("clearDeviceMetricsOverride"), 1641 parameterNames.get("clearDeviceMetricsOverride"), 1642 optionals, webSocketID, 1643 "Emulation.clearDeviceMetricsOverride" 1644 ); 1645 1646 // This Remote Command does not have a Return-Value. 1647 return new Script<> 1648 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 1649 } 1650 1651 /** 1652 * Clears the overridden Geolocation Position and Error. 1653 * 1654 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 1655 * {@link Ret0}></CODE> 1656 * 1657 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 1658 * browser receives the invocation-request. 1659 * 1660 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 1661 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 1662 * {@code >} to ensure the Browser Function has run to completion. 1663 */ 1664 public static Script<String, JsonObject, Ret0> clearGeolocationOverride() 1665 { 1666 final int webSocketID = 23002000 + counter++; 1667 final boolean[] optionals = new boolean[0]; 1668 1669 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 1670 String requestJSON = WriteJSON.get( 1671 parameterTypes.get("clearGeolocationOverride"), 1672 parameterNames.get("clearGeolocationOverride"), 1673 optionals, webSocketID, 1674 "Emulation.clearGeolocationOverride" 1675 ); 1676 1677 // This Remote Command does not have a Return-Value. 1678 return new Script<> 1679 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 1680 } 1681 1682 /** 1683 * Requests that page scale factor is reset to initial values. 1684 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 1685 * 1686 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 1687 * {@link Ret0}></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> resetPageScaleFactor() 1697 { 1698 final int webSocketID = 23003000 + counter++; 1699 final boolean[] optionals = new boolean[0]; 1700 1701 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 1702 String requestJSON = WriteJSON.get( 1703 parameterTypes.get("resetPageScaleFactor"), 1704 parameterNames.get("resetPageScaleFactor"), 1705 optionals, webSocketID, 1706 "Emulation.resetPageScaleFactor" 1707 ); 1708 1709 // This Remote Command does not have a Return-Value. 1710 return new Script<> 1711 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 1712 } 1713 1714 /** 1715 * Enables or disables simulating a focused and active page. 1716 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 1717 * 1718 * @param enabled Whether to enable to disable focus emulation. 1719 * 1720 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 1721 * {@link Ret0}></CODE> 1722 * 1723 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 1724 * browser receives the invocation-request. 1725 * 1726 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 1727 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 1728 * {@code >} to ensure the Browser Function has run to completion. 1729 */ 1730 public static Script<String, JsonObject, Ret0> setFocusEmulationEnabled(boolean enabled) 1731 { 1732 final int webSocketID = 23004000 + counter++; 1733 final boolean[] optionals = { false, }; 1734 1735 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 1736 String requestJSON = WriteJSON.get( 1737 parameterTypes.get("setFocusEmulationEnabled"), 1738 parameterNames.get("setFocusEmulationEnabled"), 1739 optionals, webSocketID, 1740 "Emulation.setFocusEmulationEnabled", 1741 enabled 1742 ); 1743 1744 // This Remote Command does not have a Return-Value. 1745 return new Script<> 1746 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 1747 } 1748 1749 /** 1750 * Automatically render all web contents using a dark theme. 1751 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 1752 * 1753 * @param enabled 1754 * Whether to enable or disable automatic dark mode. 1755 * If not specified, any existing override will be cleared. 1756 * <BR /><B CLASS=Opt>OPTIONAL</B> 1757 * 1758 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 1759 * {@link Ret0}></CODE> 1760 * 1761 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 1762 * browser receives the invocation-request. 1763 * 1764 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 1765 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 1766 * {@code >} to ensure the Browser Function has run to completion. 1767 */ 1768 public static Script<String, JsonObject, Ret0> setAutoDarkModeOverride(Boolean enabled) 1769 { 1770 final int webSocketID = 23005000 + counter++; 1771 final boolean[] optionals = { true, }; 1772 1773 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 1774 String requestJSON = WriteJSON.get( 1775 parameterTypes.get("setAutoDarkModeOverride"), 1776 parameterNames.get("setAutoDarkModeOverride"), 1777 optionals, webSocketID, 1778 "Emulation.setAutoDarkModeOverride", 1779 enabled 1780 ); 1781 1782 // This Remote Command does not have a Return-Value. 1783 return new Script<> 1784 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 1785 } 1786 1787 /** 1788 * Enables CPU throttling to emulate slow CPUs. 1789 * 1790 * @param rate Throttling rate as a slowdown factor (1 is no throttle, 2 is 2x slowdown, etc). 1791 * 1792 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 1793 * {@link Ret0}></CODE> 1794 * 1795 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 1796 * browser receives the invocation-request. 1797 * 1798 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 1799 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 1800 * {@code >} to ensure the Browser Function has run to completion. 1801 */ 1802 public static Script<String, JsonObject, Ret0> setCPUThrottlingRate(Number rate) 1803 { 1804 // Exception-Check(s) to ensure that if any parameters which are not declared as 1805 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 1806 1807 if (rate == null) THROWS.throwNPE("rate"); 1808 1809 final int webSocketID = 23006000 + counter++; 1810 final boolean[] optionals = { false, }; 1811 1812 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 1813 String requestJSON = WriteJSON.get( 1814 parameterTypes.get("setCPUThrottlingRate"), 1815 parameterNames.get("setCPUThrottlingRate"), 1816 optionals, webSocketID, 1817 "Emulation.setCPUThrottlingRate", 1818 rate 1819 ); 1820 1821 // This Remote Command does not have a Return-Value. 1822 return new Script<> 1823 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 1824 } 1825 1826 /** 1827 * Sets or clears an override of the default background color of the frame. This override is used 1828 * if the content does not specify one. 1829 * 1830 * @param color 1831 * RGBA of the default background color. If not specified, any existing override will be 1832 * cleared. 1833 * <BR /><B CLASS=Opt>OPTIONAL</B> 1834 * 1835 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 1836 * {@link Ret0}></CODE> 1837 * 1838 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 1839 * browser receives the invocation-request. 1840 * 1841 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 1842 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 1843 * {@code >} to ensure the Browser Function has run to completion. 1844 */ 1845 public static Script<String, JsonObject, Ret0> setDefaultBackgroundColorOverride 1846 (DOM.RGBA color) 1847 { 1848 final int webSocketID = 23007000 + counter++; 1849 final boolean[] optionals = { true, }; 1850 1851 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 1852 String requestJSON = WriteJSON.get( 1853 parameterTypes.get("setDefaultBackgroundColorOverride"), 1854 parameterNames.get("setDefaultBackgroundColorOverride"), 1855 optionals, webSocketID, 1856 "Emulation.setDefaultBackgroundColorOverride", 1857 color 1858 ); 1859 1860 // This Remote Command does not have a Return-Value. 1861 return new Script<> 1862 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 1863 } 1864 1865 /** 1866 * Overrides the values for env(safe-area-inset-*) and env(safe-area-max-inset-*). Unset values will cause the 1867 * respective variables to be undefined, even if previously overridden. 1868 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 1869 * 1870 * @param insets - 1871 * 1872 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 1873 * {@link Ret0}></CODE> 1874 * 1875 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 1876 * browser receives the invocation-request. 1877 * 1878 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 1879 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 1880 * {@code >} to ensure the Browser Function has run to completion. 1881 */ 1882 public static Script<String, JsonObject, Ret0> setSafeAreaInsetsOverride 1883 (Emulation.SafeAreaInsets insets) 1884 { 1885 // Exception-Check(s) to ensure that if any parameters which are not declared as 1886 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 1887 1888 if (insets == null) THROWS.throwNPE("insets"); 1889 1890 final int webSocketID = 23008000 + counter++; 1891 final boolean[] optionals = { false, }; 1892 1893 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 1894 String requestJSON = WriteJSON.get( 1895 parameterTypes.get("setSafeAreaInsetsOverride"), 1896 parameterNames.get("setSafeAreaInsetsOverride"), 1897 optionals, webSocketID, 1898 "Emulation.setSafeAreaInsetsOverride", 1899 insets 1900 ); 1901 1902 // This Remote Command does not have a Return-Value. 1903 return new Script<> 1904 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 1905 } 1906 1907 /** 1908 * Overrides the values of device screen dimensions (window.screen.width, window.screen.height, 1909 * window.innerWidth, window.innerHeight, and "device-width"/"device-height"-related CSS media 1910 * query results). 1911 * 1912 * @param width Overriding width value in pixels (minimum 0, maximum 10000000). 0 disables the override. 1913 * 1914 * @param height Overriding height value in pixels (minimum 0, maximum 10000000). 0 disables the override. 1915 * 1916 * @param deviceScaleFactor Overriding device scale factor value. 0 disables the override. 1917 * 1918 * @param mobile 1919 * Whether to emulate mobile device. This includes viewport meta tag, overlay scrollbars, text 1920 * autosizing and more. 1921 * 1922 * @param scale Scale to apply to resulting view image. 1923 * <BR /><B CLASS=Opt>OPTIONAL</B><B CLASS=Exp>EXPERIMENTAL</B> 1924 * 1925 * @param screenWidth Overriding screen width value in pixels (minimum 0, maximum 10000000). 1926 * <BR /><B CLASS=Opt>OPTIONAL</B><B CLASS=Exp>EXPERIMENTAL</B> 1927 * 1928 * @param screenHeight Overriding screen height value in pixels (minimum 0, maximum 10000000). 1929 * <BR /><B CLASS=Opt>OPTIONAL</B><B CLASS=Exp>EXPERIMENTAL</B> 1930 * 1931 * @param positionX Overriding view X position on screen in pixels (minimum 0, maximum 10000000). 1932 * <BR /><B CLASS=Opt>OPTIONAL</B><B CLASS=Exp>EXPERIMENTAL</B> 1933 * 1934 * @param positionY Overriding view Y position on screen in pixels (minimum 0, maximum 10000000). 1935 * <BR /><B CLASS=Opt>OPTIONAL</B><B CLASS=Exp>EXPERIMENTAL</B> 1936 * 1937 * @param dontSetVisibleSize Do not set visible view size, rely upon explicit setVisibleSize call. 1938 * <BR /><B CLASS=Opt>OPTIONAL</B><B CLASS=Exp>EXPERIMENTAL</B> 1939 * 1940 * @param screenOrientation Screen orientation override. 1941 * <BR /><B CLASS=Opt>OPTIONAL</B> 1942 * 1943 * @param viewport 1944 * If set, the visible area of the page will be overridden to this viewport. This viewport 1945 * change is not observed by the page, e.g. viewport-relative elements do not change positions. 1946 * <BR /><B CLASS=Opt>OPTIONAL</B><B CLASS=Exp>EXPERIMENTAL</B> 1947 * 1948 * @param displayFeature 1949 * If set, the display feature of a multi-segment screen. If not set, multi-segment support 1950 * is turned-off. 1951 * Deprecated, use Emulation.setDisplayFeaturesOverride. 1952 * <BR /><B CLASS=Opt>OPTIONAL</B><B CLASS=Exp>EXPERIMENTAL</B><B CLASS=Dep>DEPRECATED</B> 1953 * 1954 * @param devicePosture 1955 * If set, the posture of a foldable device. If not set the posture is set 1956 * to continuous. 1957 * Deprecated, use Emulation.setDevicePostureOverride. 1958 * <BR /><B CLASS=Opt>OPTIONAL</B><B CLASS=Exp>EXPERIMENTAL</B><B CLASS=Dep>DEPRECATED</B> 1959 * 1960 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 1961 * {@link Ret0}></CODE> 1962 * 1963 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 1964 * browser receives the invocation-request. 1965 * 1966 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 1967 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 1968 * {@code >} to ensure the Browser Function has run to completion. 1969 */ 1970 public static Script<String, JsonObject, Ret0> setDeviceMetricsOverride( 1971 int width, int height, Number deviceScaleFactor, boolean mobile, Number scale, 1972 Integer screenWidth, Integer screenHeight, Integer positionX, Integer positionY, 1973 Boolean dontSetVisibleSize, Emulation.ScreenOrientation screenOrientation, 1974 Page.Viewport viewport, Emulation.DisplayFeature displayFeature, 1975 Emulation.DevicePosture devicePosture 1976 ) 1977 { 1978 // Exception-Check(s) to ensure that if any parameters which are not declared as 1979 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 1980 1981 if (deviceScaleFactor == null) THROWS.throwNPE("deviceScaleFactor"); 1982 1983 final int webSocketID = 23009000 + counter++; 1984 final boolean[] optionals = { false, false, false, false, true, true, true, true, true, true, true, true, true, true, }; 1985 1986 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 1987 String requestJSON = WriteJSON.get( 1988 parameterTypes.get("setDeviceMetricsOverride"), 1989 parameterNames.get("setDeviceMetricsOverride"), 1990 optionals, webSocketID, 1991 "Emulation.setDeviceMetricsOverride", 1992 width, height, deviceScaleFactor, mobile, scale, screenWidth, screenHeight, positionX, 1993 positionY, dontSetVisibleSize, screenOrientation, viewport, displayFeature, 1994 devicePosture 1995 ); 1996 1997 // This Remote Command does not have a Return-Value. 1998 return new Script<> 1999 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 2000 } 2001 2002 /** 2003 * Start reporting the given posture value to the Device Posture API. 2004 * This override can also be set in setDeviceMetricsOverride(). 2005 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 2006 * 2007 * @param posture - 2008 * 2009 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 2010 * {@link Ret0}></CODE> 2011 * 2012 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 2013 * browser receives the invocation-request. 2014 * 2015 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 2016 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 2017 * {@code >} to ensure the Browser Function has run to completion. 2018 */ 2019 public static Script<String, JsonObject, Ret0> setDevicePostureOverride 2020 (Emulation.DevicePosture posture) 2021 { 2022 // Exception-Check(s) to ensure that if any parameters which are not declared as 2023 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 2024 2025 if (posture == null) THROWS.throwNPE("posture"); 2026 2027 final int webSocketID = 23010000 + counter++; 2028 final boolean[] optionals = { false, }; 2029 2030 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 2031 String requestJSON = WriteJSON.get( 2032 parameterTypes.get("setDevicePostureOverride"), 2033 parameterNames.get("setDevicePostureOverride"), 2034 optionals, webSocketID, 2035 "Emulation.setDevicePostureOverride", 2036 posture 2037 ); 2038 2039 // This Remote Command does not have a Return-Value. 2040 return new Script<> 2041 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 2042 } 2043 2044 /** 2045 * Clears a device posture override set with either setDeviceMetricsOverride() 2046 * or setDevicePostureOverride() and starts using posture information from the 2047 * platform again. 2048 * Does nothing if no override is set. 2049 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 2050 * 2051 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 2052 * {@link Ret0}></CODE> 2053 * 2054 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 2055 * browser receives the invocation-request. 2056 * 2057 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 2058 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 2059 * {@code >} to ensure the Browser Function has run to completion. 2060 */ 2061 public static Script<String, JsonObject, Ret0> clearDevicePostureOverride() 2062 { 2063 final int webSocketID = 23011000 + counter++; 2064 final boolean[] optionals = new boolean[0]; 2065 2066 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 2067 String requestJSON = WriteJSON.get( 2068 parameterTypes.get("clearDevicePostureOverride"), 2069 parameterNames.get("clearDevicePostureOverride"), 2070 optionals, webSocketID, 2071 "Emulation.clearDevicePostureOverride" 2072 ); 2073 2074 // This Remote Command does not have a Return-Value. 2075 return new Script<> 2076 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 2077 } 2078 2079 /** 2080 * Start using the given display features to pupulate the Viewport Segments API. 2081 * This override can also be set in setDeviceMetricsOverride(). 2082 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 2083 * 2084 * @param features - 2085 * 2086 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 2087 * {@link Ret0}></CODE> 2088 * 2089 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 2090 * browser receives the invocation-request. 2091 * 2092 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 2093 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 2094 * {@code >} to ensure the Browser Function has run to completion. 2095 */ 2096 public static Script<String, JsonObject, Ret0> setDisplayFeaturesOverride 2097 (Emulation.DisplayFeature[] features) 2098 { 2099 // Exception-Check(s) to ensure that if any parameters which are not declared as 2100 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 2101 2102 if (features == null) THROWS.throwNPE("features"); 2103 2104 final int webSocketID = 23012000 + counter++; 2105 final boolean[] optionals = { false, }; 2106 2107 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 2108 String requestJSON = WriteJSON.get( 2109 parameterTypes.get("setDisplayFeaturesOverride"), 2110 parameterNames.get("setDisplayFeaturesOverride"), 2111 optionals, webSocketID, 2112 "Emulation.setDisplayFeaturesOverride", 2113 (Object) features 2114 ); 2115 2116 // This Remote Command does not have a Return-Value. 2117 return new Script<> 2118 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 2119 } 2120 2121 /** 2122 * Clears the display features override set with either setDeviceMetricsOverride() 2123 * or setDisplayFeaturesOverride() and starts using display features from the 2124 * platform again. 2125 * Does nothing if no override is set. 2126 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 2127 * 2128 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 2129 * {@link Ret0}></CODE> 2130 * 2131 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 2132 * browser receives the invocation-request. 2133 * 2134 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 2135 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 2136 * {@code >} to ensure the Browser Function has run to completion. 2137 */ 2138 public static Script<String, JsonObject, Ret0> clearDisplayFeaturesOverride() 2139 { 2140 final int webSocketID = 23013000 + counter++; 2141 final boolean[] optionals = new boolean[0]; 2142 2143 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 2144 String requestJSON = WriteJSON.get( 2145 parameterTypes.get("clearDisplayFeaturesOverride"), 2146 parameterNames.get("clearDisplayFeaturesOverride"), 2147 optionals, webSocketID, 2148 "Emulation.clearDisplayFeaturesOverride" 2149 ); 2150 2151 // This Remote Command does not have a Return-Value. 2152 return new Script<> 2153 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 2154 } 2155 2156 /** 2157 * <CODE>[No Description Provided by Google]</CODE> 2158 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 2159 * 2160 * @param hidden Whether scrollbars should be always hidden. 2161 * 2162 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 2163 * {@link Ret0}></CODE> 2164 * 2165 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 2166 * browser receives the invocation-request. 2167 * 2168 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 2169 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 2170 * {@code >} to ensure the Browser Function has run to completion. 2171 */ 2172 public static Script<String, JsonObject, Ret0> setScrollbarsHidden(boolean hidden) 2173 { 2174 final int webSocketID = 23014000 + counter++; 2175 final boolean[] optionals = { false, }; 2176 2177 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 2178 String requestJSON = WriteJSON.get( 2179 parameterTypes.get("setScrollbarsHidden"), 2180 parameterNames.get("setScrollbarsHidden"), 2181 optionals, webSocketID, 2182 "Emulation.setScrollbarsHidden", 2183 hidden 2184 ); 2185 2186 // This Remote Command does not have a Return-Value. 2187 return new Script<> 2188 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 2189 } 2190 2191 /** 2192 * <CODE>[No Description Provided by Google]</CODE> 2193 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 2194 * 2195 * @param disabled Whether document.coookie API should be disabled. 2196 * 2197 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 2198 * {@link Ret0}></CODE> 2199 * 2200 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 2201 * browser receives the invocation-request. 2202 * 2203 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 2204 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 2205 * {@code >} to ensure the Browser Function has run to completion. 2206 */ 2207 public static Script<String, JsonObject, Ret0> setDocumentCookieDisabled(boolean disabled) 2208 { 2209 final int webSocketID = 23015000 + counter++; 2210 final boolean[] optionals = { false, }; 2211 2212 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 2213 String requestJSON = WriteJSON.get( 2214 parameterTypes.get("setDocumentCookieDisabled"), 2215 parameterNames.get("setDocumentCookieDisabled"), 2216 optionals, webSocketID, 2217 "Emulation.setDocumentCookieDisabled", 2218 disabled 2219 ); 2220 2221 // This Remote Command does not have a Return-Value. 2222 return new Script<> 2223 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 2224 } 2225 2226 /** 2227 * <CODE>[No Description Provided by Google]</CODE> 2228 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 2229 * 2230 * @param enabled Whether touch emulation based on mouse input should be enabled. 2231 * 2232 * @param configuration Touch/gesture events configuration. Default: current platform. 2233 * <BR />Acceptable Values: ["mobile", "desktop"] 2234 * <BR /><B CLASS=Opt>OPTIONAL</B> 2235 * 2236 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 2237 * {@link Ret0}></CODE> 2238 * 2239 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 2240 * browser receives the invocation-request. 2241 * 2242 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 2243 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 2244 * {@code >} to ensure the Browser Function has run to completion. 2245 */ 2246 public static Script<String, JsonObject, Ret0> setEmitTouchEventsForMouse 2247 (boolean enabled, String configuration) 2248 { 2249 // Exception-Check(s) to ensure that if any parameters which must adhere to a 2250 // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw. 2251 2252 THROWS.checkIAE( 2253 "configuration", configuration, 2254 "mobile", "desktop" 2255 ); 2256 2257 final int webSocketID = 23016000 + counter++; 2258 final boolean[] optionals = { false, true, }; 2259 2260 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 2261 String requestJSON = WriteJSON.get( 2262 parameterTypes.get("setEmitTouchEventsForMouse"), 2263 parameterNames.get("setEmitTouchEventsForMouse"), 2264 optionals, webSocketID, 2265 "Emulation.setEmitTouchEventsForMouse", 2266 enabled, configuration 2267 ); 2268 2269 // This Remote Command does not have a Return-Value. 2270 return new Script<> 2271 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 2272 } 2273 2274 /** 2275 * Emulates the given media type or media feature for CSS media queries. 2276 * 2277 * @param media Media type to emulate. Empty string disables the override. 2278 * <BR /><B CLASS=Opt>OPTIONAL</B> 2279 * 2280 * @param features Media features to emulate. 2281 * <BR /><B CLASS=Opt>OPTIONAL</B> 2282 * 2283 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 2284 * {@link Ret0}></CODE> 2285 * 2286 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 2287 * browser receives the invocation-request. 2288 * 2289 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 2290 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 2291 * {@code >} to ensure the Browser Function has run to completion. 2292 */ 2293 public static Script<String, JsonObject, Ret0> setEmulatedMedia 2294 (String media, Emulation.MediaFeature[] features) 2295 { 2296 final int webSocketID = 23017000 + counter++; 2297 final boolean[] optionals = { true, true, }; 2298 2299 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 2300 String requestJSON = WriteJSON.get( 2301 parameterTypes.get("setEmulatedMedia"), 2302 parameterNames.get("setEmulatedMedia"), 2303 optionals, webSocketID, 2304 "Emulation.setEmulatedMedia", 2305 media, features 2306 ); 2307 2308 // This Remote Command does not have a Return-Value. 2309 return new Script<> 2310 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 2311 } 2312 2313 /** 2314 * Emulates the given vision deficiency. 2315 * 2316 * @param type 2317 * Vision deficiency to emulate. Order: best-effort emulations come first, followed by any 2318 * physiologically accurate emulations for medically recognized color vision deficiencies. 2319 * <BR />Acceptable Values: ["none", "blurredVision", "reducedContrast", "achromatopsia", "deuteranopia", "protanopia", "tritanopia"] 2320 * 2321 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 2322 * {@link Ret0}></CODE> 2323 * 2324 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 2325 * browser receives the invocation-request. 2326 * 2327 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 2328 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 2329 * {@code >} to ensure the Browser Function has run to completion. 2330 */ 2331 public static Script<String, JsonObject, Ret0> setEmulatedVisionDeficiency(String type) 2332 { 2333 // Exception-Check(s) to ensure that if any parameters which are not declared as 2334 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 2335 2336 if (type == null) THROWS.throwNPE("type"); 2337 2338 // Exception-Check(s) to ensure that if any parameters which must adhere to a 2339 // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw. 2340 2341 THROWS.checkIAE( 2342 "type", type, 2343 "none", "blurredVision", "reducedContrast", "achromatopsia", "deuteranopia", "protanopia", "tritanopia" 2344 ); 2345 2346 final int webSocketID = 23018000 + counter++; 2347 final boolean[] optionals = { false, }; 2348 2349 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 2350 String requestJSON = WriteJSON.get( 2351 parameterTypes.get("setEmulatedVisionDeficiency"), 2352 parameterNames.get("setEmulatedVisionDeficiency"), 2353 optionals, webSocketID, 2354 "Emulation.setEmulatedVisionDeficiency", 2355 type 2356 ); 2357 2358 // This Remote Command does not have a Return-Value. 2359 return new Script<> 2360 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 2361 } 2362 2363 /** 2364 * Emulates the given OS text scale. 2365 * 2366 * @param scale - 2367 * <BR /><B CLASS=Opt>OPTIONAL</B> 2368 * 2369 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 2370 * {@link Ret0}></CODE> 2371 * 2372 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 2373 * browser receives the invocation-request. 2374 * 2375 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 2376 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 2377 * {@code >} to ensure the Browser Function has run to completion. 2378 */ 2379 public static Script<String, JsonObject, Ret0> setEmulatedOSTextScale(Number scale) 2380 { 2381 final int webSocketID = 23019000 + counter++; 2382 final boolean[] optionals = { true, }; 2383 2384 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 2385 String requestJSON = WriteJSON.get( 2386 parameterTypes.get("setEmulatedOSTextScale"), 2387 parameterNames.get("setEmulatedOSTextScale"), 2388 optionals, webSocketID, 2389 "Emulation.setEmulatedOSTextScale", 2390 scale 2391 ); 2392 2393 // This Remote Command does not have a Return-Value. 2394 return new Script<> 2395 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 2396 } 2397 2398 /** 2399 * Overrides the Geolocation Position or Error. Omitting latitude, longitude or 2400 * accuracy emulates position unavailable. 2401 * 2402 * @param latitude Mock latitude 2403 * <BR /><B CLASS=Opt>OPTIONAL</B> 2404 * 2405 * @param longitude Mock longitude 2406 * <BR /><B CLASS=Opt>OPTIONAL</B> 2407 * 2408 * @param accuracy Mock accuracy 2409 * <BR /><B CLASS=Opt>OPTIONAL</B> 2410 * 2411 * @param altitude Mock altitude 2412 * <BR /><B CLASS=Opt>OPTIONAL</B> 2413 * 2414 * @param altitudeAccuracy Mock altitudeAccuracy 2415 * <BR /><B CLASS=Opt>OPTIONAL</B> 2416 * 2417 * @param heading Mock heading 2418 * <BR /><B CLASS=Opt>OPTIONAL</B> 2419 * 2420 * @param speed Mock speed 2421 * <BR /><B CLASS=Opt>OPTIONAL</B> 2422 * 2423 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 2424 * {@link Ret0}></CODE> 2425 * 2426 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 2427 * browser receives the invocation-request. 2428 * 2429 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 2430 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 2431 * {@code >} to ensure the Browser Function has run to completion. 2432 */ 2433 public static Script<String, JsonObject, Ret0> setGeolocationOverride( 2434 Number latitude, Number longitude, Number accuracy, Number altitude, 2435 Number altitudeAccuracy, Number heading, Number speed 2436 ) 2437 { 2438 final int webSocketID = 23020000 + counter++; 2439 final boolean[] optionals = { true, true, true, true, true, true, true, }; 2440 2441 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 2442 String requestJSON = WriteJSON.get( 2443 parameterTypes.get("setGeolocationOverride"), 2444 parameterNames.get("setGeolocationOverride"), 2445 optionals, webSocketID, 2446 "Emulation.setGeolocationOverride", 2447 latitude, longitude, accuracy, altitude, altitudeAccuracy, heading, speed 2448 ); 2449 2450 // This Remote Command does not have a Return-Value. 2451 return new Script<> 2452 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 2453 } 2454 2455 /** 2456 * <CODE>[No Description Provided by Google]</CODE> 2457 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 2458 * 2459 * @param type - 2460 * 2461 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 2462 * Number></CODE> 2463 * 2464 * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using 2465 * {@link Script#exec()}, and afterwards, a {@link Promise}<CODE><JsonObject, 2466 * Number></CODE> will be returned. 2467 * 2468 * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>, 2469 * using {@link Promise#await()}, <I>and the returned result of this Browser Function may 2470 * may be retrieved.</I> 2471 * 2472 * <BR /><BR />This Browser Function <B STYLE='color: red'>returns</B> 2473 * <BR /><BR /><UL CLASS=JDUL> 2474 * <LI><CODE>Number (<B>requestedSamplingFrequency</B></CODE>) 2475 * <BR />- 2476 * </LI> 2477 * </UL> */ 2478 public static Script<String, JsonObject, Number> getOverriddenSensorInformation(String type) 2479 { 2480 // Exception-Check(s) to ensure that if any parameters which are not declared as 2481 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 2482 2483 if (type == null) THROWS.throwNPE("type"); 2484 2485 // Exception-Check(s) to ensure that if any parameters which must adhere to a 2486 // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw. 2487 2488 THROWS.checkIAE("type", type, "Emulation.SensorType", Emulation.SensorType); 2489 2490 final int webSocketID = 23021000 + counter++; 2491 final boolean[] optionals = { false, }; 2492 2493 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 2494 String requestJSON = WriteJSON.get( 2495 parameterTypes.get("getOverriddenSensorInformation"), 2496 parameterNames.get("getOverriddenSensorInformation"), 2497 optionals, webSocketID, 2498 "Emulation.getOverriddenSensorInformation", 2499 type 2500 ); 2501 2502 // 'JSON Binding' ... Converts Browser Response-JSON to 'Number' 2503 Function<JsonObject, Number> responseProcessor = (JsonObject jo) -> 2504 ReadNumberJSON.get(jo, "requestedSamplingFrequency", false, true); 2505 2506 return new Script<>(webSocketID, requestJSON, responseProcessor); 2507 } 2508 2509 /** 2510 * Overrides a platform sensor of a given type. If |enabled| is true, calls to 2511 * Sensor.start() will use a virtual sensor as backend rather than fetching 2512 * data from a real hardware sensor. Otherwise, existing virtual 2513 * sensor-backend Sensor objects will fire an error event and new calls to 2514 * Sensor.start() will attempt to use a real sensor instead. 2515 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 2516 * 2517 * @param enabled - 2518 * 2519 * @param type - 2520 * 2521 * @param metadata - 2522 * <BR /><B CLASS=Opt>OPTIONAL</B> 2523 * 2524 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 2525 * {@link Ret0}></CODE> 2526 * 2527 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 2528 * browser receives the invocation-request. 2529 * 2530 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 2531 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 2532 * {@code >} to ensure the Browser Function has run to completion. 2533 */ 2534 public static Script<String, JsonObject, Ret0> setSensorOverrideEnabled 2535 (boolean enabled, String type, Emulation.SensorMetadata metadata) 2536 { 2537 // Exception-Check(s) to ensure that if any parameters which are not declared as 2538 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 2539 2540 if (type == null) THROWS.throwNPE("type"); 2541 2542 // Exception-Check(s) to ensure that if any parameters which must adhere to a 2543 // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw. 2544 2545 THROWS.checkIAE("type", type, "Emulation.SensorType", Emulation.SensorType); 2546 2547 final int webSocketID = 23022000 + counter++; 2548 final boolean[] optionals = { false, false, true, }; 2549 2550 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 2551 String requestJSON = WriteJSON.get( 2552 parameterTypes.get("setSensorOverrideEnabled"), 2553 parameterNames.get("setSensorOverrideEnabled"), 2554 optionals, webSocketID, 2555 "Emulation.setSensorOverrideEnabled", 2556 enabled, type, metadata 2557 ); 2558 2559 // This Remote Command does not have a Return-Value. 2560 return new Script<> 2561 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 2562 } 2563 2564 /** 2565 * Updates the sensor readings reported by a sensor type previously overridden 2566 * by setSensorOverrideEnabled. 2567 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 2568 * 2569 * @param type - 2570 * 2571 * @param reading - 2572 * 2573 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 2574 * {@link Ret0}></CODE> 2575 * 2576 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 2577 * browser receives the invocation-request. 2578 * 2579 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 2580 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 2581 * {@code >} to ensure the Browser Function has run to completion. 2582 */ 2583 public static Script<String, JsonObject, Ret0> setSensorOverrideReadings 2584 (String type, Emulation.SensorReading reading) 2585 { 2586 // Exception-Check(s) to ensure that if any parameters which are not declared as 2587 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 2588 2589 if (type == null) THROWS.throwNPE("type"); 2590 if (reading == null) THROWS.throwNPE("reading"); 2591 2592 // Exception-Check(s) to ensure that if any parameters which must adhere to a 2593 // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw. 2594 2595 THROWS.checkIAE("type", type, "Emulation.SensorType", Emulation.SensorType); 2596 2597 final int webSocketID = 23023000 + counter++; 2598 final boolean[] optionals = { false, false, }; 2599 2600 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 2601 String requestJSON = WriteJSON.get( 2602 parameterTypes.get("setSensorOverrideReadings"), 2603 parameterNames.get("setSensorOverrideReadings"), 2604 optionals, webSocketID, 2605 "Emulation.setSensorOverrideReadings", 2606 type, reading 2607 ); 2608 2609 // This Remote Command does not have a Return-Value. 2610 return new Script<> 2611 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 2612 } 2613 2614 /** 2615 * Overrides a pressure source of a given type, as used by the Compute 2616 * Pressure API, so that updates to PressureObserver.observe() are provided 2617 * via setPressureStateOverride instead of being retrieved from 2618 * platform-provided telemetry data. 2619 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 2620 * 2621 * @param enabled - 2622 * 2623 * @param source - 2624 * 2625 * @param metadata - 2626 * <BR /><B CLASS=Opt>OPTIONAL</B> 2627 * 2628 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 2629 * {@link Ret0}></CODE> 2630 * 2631 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 2632 * browser receives the invocation-request. 2633 * 2634 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 2635 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 2636 * {@code >} to ensure the Browser Function has run to completion. 2637 */ 2638 public static Script<String, JsonObject, Ret0> setPressureSourceOverrideEnabled 2639 (boolean enabled, String source, Emulation.PressureMetadata metadata) 2640 { 2641 // Exception-Check(s) to ensure that if any parameters which are not declared as 2642 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 2643 2644 if (source == null) THROWS.throwNPE("source"); 2645 2646 // Exception-Check(s) to ensure that if any parameters which must adhere to a 2647 // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw. 2648 2649 THROWS.checkIAE("source", source, "Emulation.PressureSource", Emulation.PressureSource); 2650 2651 final int webSocketID = 23024000 + counter++; 2652 final boolean[] optionals = { false, false, true, }; 2653 2654 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 2655 String requestJSON = WriteJSON.get( 2656 parameterTypes.get("setPressureSourceOverrideEnabled"), 2657 parameterNames.get("setPressureSourceOverrideEnabled"), 2658 optionals, webSocketID, 2659 "Emulation.setPressureSourceOverrideEnabled", 2660 enabled, source, metadata 2661 ); 2662 2663 // This Remote Command does not have a Return-Value. 2664 return new Script<> 2665 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 2666 } 2667 2668 /** 2669 * TODO: OBSOLETE: To remove when setPressureDataOverride is merged. 2670 * Provides a given pressure state that will be processed and eventually be 2671 * delivered to PressureObserver users. |source| must have been previously 2672 * overridden by setPressureSourceOverrideEnabled. 2673 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 2674 * 2675 * @param source - 2676 * 2677 * @param state - 2678 * 2679 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 2680 * {@link Ret0}></CODE> 2681 * 2682 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 2683 * browser receives the invocation-request. 2684 * 2685 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 2686 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 2687 * {@code >} to ensure the Browser Function has run to completion. 2688 */ 2689 public static Script<String, JsonObject, Ret0> setPressureStateOverride 2690 (String source, String state) 2691 { 2692 // Exception-Check(s) to ensure that if any parameters which are not declared as 2693 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 2694 2695 if (source == null) THROWS.throwNPE("source"); 2696 if (state == null) THROWS.throwNPE("state"); 2697 2698 // Exception-Check(s) to ensure that if any parameters which must adhere to a 2699 // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw. 2700 2701 THROWS.checkIAE("source", source, "Emulation.PressureSource", Emulation.PressureSource); 2702 THROWS.checkIAE("state", state, "Emulation.PressureState", Emulation.PressureState); 2703 2704 final int webSocketID = 23025000 + counter++; 2705 final boolean[] optionals = { false, false, }; 2706 2707 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 2708 String requestJSON = WriteJSON.get( 2709 parameterTypes.get("setPressureStateOverride"), 2710 parameterNames.get("setPressureStateOverride"), 2711 optionals, webSocketID, 2712 "Emulation.setPressureStateOverride", 2713 source, state 2714 ); 2715 2716 // This Remote Command does not have a Return-Value. 2717 return new Script<> 2718 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 2719 } 2720 2721 /** 2722 * Provides a given pressure data set that will be processed and eventually be 2723 * delivered to PressureObserver users. |source| must have been previously 2724 * overridden by setPressureSourceOverrideEnabled. 2725 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 2726 * 2727 * @param source - 2728 * 2729 * @param state - 2730 * 2731 * @param ownContributionEstimate - 2732 * <BR /><B CLASS=Opt>OPTIONAL</B> 2733 * 2734 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 2735 * {@link Ret0}></CODE> 2736 * 2737 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 2738 * browser receives the invocation-request. 2739 * 2740 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 2741 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 2742 * {@code >} to ensure the Browser Function has run to completion. 2743 */ 2744 public static Script<String, JsonObject, Ret0> setPressureDataOverride 2745 (String source, String state, Number ownContributionEstimate) 2746 { 2747 // Exception-Check(s) to ensure that if any parameters which are not declared as 2748 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 2749 2750 if (source == null) THROWS.throwNPE("source"); 2751 if (state == null) THROWS.throwNPE("state"); 2752 2753 // Exception-Check(s) to ensure that if any parameters which must adhere to a 2754 // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw. 2755 2756 THROWS.checkIAE("source", source, "Emulation.PressureSource", Emulation.PressureSource); 2757 THROWS.checkIAE("state", state, "Emulation.PressureState", Emulation.PressureState); 2758 2759 final int webSocketID = 23026000 + counter++; 2760 final boolean[] optionals = { false, false, true, }; 2761 2762 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 2763 String requestJSON = WriteJSON.get( 2764 parameterTypes.get("setPressureDataOverride"), 2765 parameterNames.get("setPressureDataOverride"), 2766 optionals, webSocketID, 2767 "Emulation.setPressureDataOverride", 2768 source, state, ownContributionEstimate 2769 ); 2770 2771 // This Remote Command does not have a Return-Value. 2772 return new Script<> 2773 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 2774 } 2775 2776 /** 2777 * Overrides the Idle state. 2778 * 2779 * @param isUserActive Mock isUserActive 2780 * 2781 * @param isScreenUnlocked Mock isScreenUnlocked 2782 * 2783 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 2784 * {@link Ret0}></CODE> 2785 * 2786 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 2787 * browser receives the invocation-request. 2788 * 2789 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 2790 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 2791 * {@code >} to ensure the Browser Function has run to completion. 2792 */ 2793 public static Script<String, JsonObject, Ret0> setIdleOverride 2794 (boolean isUserActive, boolean isScreenUnlocked) 2795 { 2796 final int webSocketID = 23027000 + counter++; 2797 final boolean[] optionals = { false, false, }; 2798 2799 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 2800 String requestJSON = WriteJSON.get( 2801 parameterTypes.get("setIdleOverride"), 2802 parameterNames.get("setIdleOverride"), 2803 optionals, webSocketID, 2804 "Emulation.setIdleOverride", 2805 isUserActive, isScreenUnlocked 2806 ); 2807 2808 // This Remote Command does not have a Return-Value. 2809 return new Script<> 2810 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 2811 } 2812 2813 /** 2814 * Clears Idle state overrides. 2815 * 2816 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 2817 * {@link Ret0}></CODE> 2818 * 2819 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 2820 * browser receives the invocation-request. 2821 * 2822 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 2823 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 2824 * {@code >} to ensure the Browser Function has run to completion. 2825 */ 2826 public static Script<String, JsonObject, Ret0> clearIdleOverride() 2827 { 2828 final int webSocketID = 23028000 + counter++; 2829 final boolean[] optionals = new boolean[0]; 2830 2831 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 2832 String requestJSON = WriteJSON.get( 2833 parameterTypes.get("clearIdleOverride"), 2834 parameterNames.get("clearIdleOverride"), 2835 optionals, webSocketID, 2836 "Emulation.clearIdleOverride" 2837 ); 2838 2839 // This Remote Command does not have a Return-Value. 2840 return new Script<> 2841 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 2842 } 2843 2844 /** 2845 * Overrides value returned by the javascript navigator object. 2846 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B><B CLASS=Dep-Top>DEPRECATED</B> 2847 * 2848 * @param platform The platform navigator.platform should return. 2849 * 2850 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 2851 * {@link Ret0}></CODE> 2852 * 2853 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 2854 * browser receives the invocation-request. 2855 * 2856 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 2857 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 2858 * {@code >} to ensure the Browser Function has run to completion. 2859 */ 2860 public static Script<String, JsonObject, Ret0> setNavigatorOverrides(String platform) 2861 { 2862 // Exception-Check(s) to ensure that if any parameters which are not declared as 2863 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 2864 2865 if (platform == null) THROWS.throwNPE("platform"); 2866 2867 final int webSocketID = 23029000 + counter++; 2868 final boolean[] optionals = { false, }; 2869 2870 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 2871 String requestJSON = WriteJSON.get( 2872 parameterTypes.get("setNavigatorOverrides"), 2873 parameterNames.get("setNavigatorOverrides"), 2874 optionals, webSocketID, 2875 "Emulation.setNavigatorOverrides", 2876 platform 2877 ); 2878 2879 // This Remote Command does not have a Return-Value. 2880 return new Script<> 2881 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 2882 } 2883 2884 /** 2885 * Sets a specified page scale factor. 2886 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 2887 * 2888 * @param pageScaleFactor Page scale factor. 2889 * 2890 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 2891 * {@link Ret0}></CODE> 2892 * 2893 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 2894 * browser receives the invocation-request. 2895 * 2896 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 2897 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 2898 * {@code >} to ensure the Browser Function has run to completion. 2899 */ 2900 public static Script<String, JsonObject, Ret0> setPageScaleFactor(Number pageScaleFactor) 2901 { 2902 // Exception-Check(s) to ensure that if any parameters which are not declared as 2903 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 2904 2905 if (pageScaleFactor == null) THROWS.throwNPE("pageScaleFactor"); 2906 2907 final int webSocketID = 23030000 + counter++; 2908 final boolean[] optionals = { false, }; 2909 2910 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 2911 String requestJSON = WriteJSON.get( 2912 parameterTypes.get("setPageScaleFactor"), 2913 parameterNames.get("setPageScaleFactor"), 2914 optionals, webSocketID, 2915 "Emulation.setPageScaleFactor", 2916 pageScaleFactor 2917 ); 2918 2919 // This Remote Command does not have a Return-Value. 2920 return new Script<> 2921 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 2922 } 2923 2924 /** 2925 * Switches script execution in the page. 2926 * 2927 * @param value Whether script execution should be disabled in the page. 2928 * 2929 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 2930 * {@link Ret0}></CODE> 2931 * 2932 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 2933 * browser receives the invocation-request. 2934 * 2935 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 2936 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 2937 * {@code >} to ensure the Browser Function has run to completion. 2938 */ 2939 public static Script<String, JsonObject, Ret0> setScriptExecutionDisabled(boolean value) 2940 { 2941 final int webSocketID = 23031000 + counter++; 2942 final boolean[] optionals = { false, }; 2943 2944 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 2945 String requestJSON = WriteJSON.get( 2946 parameterTypes.get("setScriptExecutionDisabled"), 2947 parameterNames.get("setScriptExecutionDisabled"), 2948 optionals, webSocketID, 2949 "Emulation.setScriptExecutionDisabled", 2950 value 2951 ); 2952 2953 // This Remote Command does not have a Return-Value. 2954 return new Script<> 2955 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 2956 } 2957 2958 /** 2959 * Enables touch on platforms which do not support them. 2960 * 2961 * @param enabled Whether the touch event emulation should be enabled. 2962 * 2963 * @param maxTouchPoints Maximum touch points supported. Defaults to one. 2964 * <BR /><B CLASS=Opt>OPTIONAL</B> 2965 * 2966 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 2967 * {@link Ret0}></CODE> 2968 * 2969 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 2970 * browser receives the invocation-request. 2971 * 2972 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 2973 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 2974 * {@code >} to ensure the Browser Function has run to completion. 2975 */ 2976 public static Script<String, JsonObject, Ret0> setTouchEmulationEnabled 2977 (boolean enabled, Integer maxTouchPoints) 2978 { 2979 final int webSocketID = 23032000 + counter++; 2980 final boolean[] optionals = { false, true, }; 2981 2982 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 2983 String requestJSON = WriteJSON.get( 2984 parameterTypes.get("setTouchEmulationEnabled"), 2985 parameterNames.get("setTouchEmulationEnabled"), 2986 optionals, webSocketID, 2987 "Emulation.setTouchEmulationEnabled", 2988 enabled, maxTouchPoints 2989 ); 2990 2991 // This Remote Command does not have a Return-Value. 2992 return new Script<> 2993 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 2994 } 2995 2996 /** 2997 * Turns on virtual time for all frames (replacing real-time with a synthetic time source) and sets 2998 * the current virtual time policy. Note this supersedes any previous time budget. 2999 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 3000 * 3001 * @param policy - 3002 * 3003 * @param budget 3004 * If set, after this many virtual milliseconds have elapsed virtual time will be paused and a 3005 * virtualTimeBudgetExpired event is sent. 3006 * <BR /><B CLASS=Opt>OPTIONAL</B> 3007 * 3008 * @param maxVirtualTimeTaskStarvationCount 3009 * If set this specifies the maximum number of tasks that can be run before virtual is forced 3010 * forwards to prevent deadlock. 3011 * <BR /><B CLASS=Opt>OPTIONAL</B> 3012 * 3013 * @param initialVirtualTime If set, base::Time::Now will be overridden to initially return this value. 3014 * <BR /><B CLASS=Opt>OPTIONAL</B> 3015 * 3016 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 3017 * Number></CODE> 3018 * 3019 * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using 3020 * {@link Script#exec()}, and afterwards, a {@link Promise}<CODE><JsonObject, 3021 * Number></CODE> will be returned. 3022 * 3023 * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>, 3024 * using {@link Promise#await()}, <I>and the returned result of this Browser Function may 3025 * may be retrieved.</I> 3026 * 3027 * <BR /><BR />This Browser Function <B STYLE='color: red'>returns</B> 3028 * <BR /><BR /><UL CLASS=JDUL> 3029 * <LI><CODE>Number (<B>virtualTimeTicksBase</B></CODE>) 3030 * <BR />Absolute timestamp at which virtual time was first enabled (up time in milliseconds). 3031 * </LI> 3032 * </UL> */ 3033 public static Script<String, JsonObject, Number> setVirtualTimePolicy( 3034 String policy, Number budget, Integer maxVirtualTimeTaskStarvationCount, 3035 Number initialVirtualTime 3036 ) 3037 { 3038 // Exception-Check(s) to ensure that if any parameters which are not declared as 3039 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 3040 3041 if (policy == null) THROWS.throwNPE("policy"); 3042 3043 // Exception-Check(s) to ensure that if any parameters which must adhere to a 3044 // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw. 3045 3046 THROWS.checkIAE("policy", policy, "Emulation.VirtualTimePolicy", Emulation.VirtualTimePolicy); 3047 3048 final int webSocketID = 23033000 + counter++; 3049 final boolean[] optionals = { false, true, true, true, }; 3050 3051 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 3052 String requestJSON = WriteJSON.get( 3053 parameterTypes.get("setVirtualTimePolicy"), 3054 parameterNames.get("setVirtualTimePolicy"), 3055 optionals, webSocketID, 3056 "Emulation.setVirtualTimePolicy", 3057 policy, budget, maxVirtualTimeTaskStarvationCount, initialVirtualTime 3058 ); 3059 3060 // 'JSON Binding' ... Converts Browser Response-JSON to 'Number' 3061 Function<JsonObject, Number> responseProcessor = (JsonObject jo) -> 3062 ReadNumberJSON.get(jo, "virtualTimeTicksBase", false, true); 3063 3064 return new Script<>(webSocketID, requestJSON, responseProcessor); 3065 } 3066 3067 /** 3068 * Overrides default host system locale with the specified one. 3069 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 3070 * 3071 * @param locale 3072 * ICU style C locale (e.g. "en_US"). If not specified or empty, disables the override and 3073 * restores default host system locale. 3074 * <BR /><B CLASS=Opt>OPTIONAL</B> 3075 * 3076 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 3077 * {@link Ret0}></CODE> 3078 * 3079 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 3080 * browser receives the invocation-request. 3081 * 3082 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 3083 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 3084 * {@code >} to ensure the Browser Function has run to completion. 3085 */ 3086 public static Script<String, JsonObject, Ret0> setLocaleOverride(String locale) 3087 { 3088 final int webSocketID = 23034000 + counter++; 3089 final boolean[] optionals = { true, }; 3090 3091 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 3092 String requestJSON = WriteJSON.get( 3093 parameterTypes.get("setLocaleOverride"), 3094 parameterNames.get("setLocaleOverride"), 3095 optionals, webSocketID, 3096 "Emulation.setLocaleOverride", 3097 locale 3098 ); 3099 3100 // This Remote Command does not have a Return-Value. 3101 return new Script<> 3102 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 3103 } 3104 3105 /** 3106 * Overrides default host system timezone with the specified one. 3107 * 3108 * @param timezoneId 3109 * The timezone identifier. List of supported timezones: 3110 * https://source.chromium.org/chromium/chromium/deps/icu.git/+/faee8bc70570192d82d2978a71e2a615788597d1:source/data/misc/metaZones.txt 3111 * If empty, disables the override and restores default host system timezone. 3112 * 3113 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 3114 * {@link Ret0}></CODE> 3115 * 3116 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 3117 * browser receives the invocation-request. 3118 * 3119 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 3120 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 3121 * {@code >} to ensure the Browser Function has run to completion. 3122 */ 3123 public static Script<String, JsonObject, Ret0> setTimezoneOverride(String timezoneId) 3124 { 3125 // Exception-Check(s) to ensure that if any parameters which are not declared as 3126 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 3127 3128 if (timezoneId == null) THROWS.throwNPE("timezoneId"); 3129 3130 final int webSocketID = 23035000 + counter++; 3131 final boolean[] optionals = { false, }; 3132 3133 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 3134 String requestJSON = WriteJSON.get( 3135 parameterTypes.get("setTimezoneOverride"), 3136 parameterNames.get("setTimezoneOverride"), 3137 optionals, webSocketID, 3138 "Emulation.setTimezoneOverride", 3139 timezoneId 3140 ); 3141 3142 // This Remote Command does not have a Return-Value. 3143 return new Script<> 3144 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 3145 } 3146 3147 /** 3148 * Resizes the frame/viewport of the page. Note that this does not affect the frame's container 3149 * (e.g. browser window). Can be used to produce screenshots of the specified size. Not supported 3150 * on Android. 3151 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B><B CLASS=Dep-Top>DEPRECATED</B> 3152 * 3153 * @param width Frame width (DIP). 3154 * 3155 * @param height Frame height (DIP). 3156 * 3157 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 3158 * {@link Ret0}></CODE> 3159 * 3160 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 3161 * browser receives the invocation-request. 3162 * 3163 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 3164 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 3165 * {@code >} to ensure the Browser Function has run to completion. 3166 */ 3167 public static Script<String, JsonObject, Ret0> setVisibleSize(int width, int height) 3168 { 3169 final int webSocketID = 23036000 + counter++; 3170 final boolean[] optionals = { false, false, }; 3171 3172 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 3173 String requestJSON = WriteJSON.get( 3174 parameterTypes.get("setVisibleSize"), 3175 parameterNames.get("setVisibleSize"), 3176 optionals, webSocketID, 3177 "Emulation.setVisibleSize", 3178 width, height 3179 ); 3180 3181 // This Remote Command does not have a Return-Value. 3182 return new Script<> 3183 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 3184 } 3185 3186 /** 3187 * <CODE>[No Description Provided by Google]</CODE> 3188 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 3189 * 3190 * @param imageTypes Image types to disable. 3191 * 3192 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 3193 * {@link Ret0}></CODE> 3194 * 3195 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 3196 * browser receives the invocation-request. 3197 * 3198 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 3199 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 3200 * {@code >} to ensure the Browser Function has run to completion. 3201 */ 3202 public static Script<String, JsonObject, Ret0> setDisabledImageTypes(String[] imageTypes) 3203 { 3204 // Exception-Check(s) to ensure that if any parameters which are not declared as 3205 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 3206 3207 if (imageTypes == null) THROWS.throwNPE("imageTypes"); 3208 3209 final int webSocketID = 23037000 + counter++; 3210 final boolean[] optionals = { false, }; 3211 3212 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 3213 String requestJSON = WriteJSON.get( 3214 parameterTypes.get("setDisabledImageTypes"), 3215 parameterNames.get("setDisabledImageTypes"), 3216 optionals, webSocketID, 3217 "Emulation.setDisabledImageTypes", 3218 (Object) imageTypes 3219 ); 3220 3221 // This Remote Command does not have a Return-Value. 3222 return new Script<> 3223 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 3224 } 3225 3226 /** 3227 * Override the value of navigator.connection.saveData 3228 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 3229 * 3230 * @param dataSaverEnabled Override value. Omitting the parameter disables the override. 3231 * <BR /><B CLASS=Opt>OPTIONAL</B> 3232 * 3233 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 3234 * {@link Ret0}></CODE> 3235 * 3236 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 3237 * browser receives the invocation-request. 3238 * 3239 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 3240 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 3241 * {@code >} to ensure the Browser Function has run to completion. 3242 */ 3243 public static Script<String, JsonObject, Ret0> setDataSaverOverride 3244 (Boolean dataSaverEnabled) 3245 { 3246 final int webSocketID = 23038000 + counter++; 3247 final boolean[] optionals = { true, }; 3248 3249 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 3250 String requestJSON = WriteJSON.get( 3251 parameterTypes.get("setDataSaverOverride"), 3252 parameterNames.get("setDataSaverOverride"), 3253 optionals, webSocketID, 3254 "Emulation.setDataSaverOverride", 3255 dataSaverEnabled 3256 ); 3257 3258 // This Remote Command does not have a Return-Value. 3259 return new Script<> 3260 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 3261 } 3262 3263 /** 3264 * <CODE>[No Description Provided by Google]</CODE> 3265 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 3266 * 3267 * @param hardwareConcurrency Hardware concurrency to report 3268 * 3269 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 3270 * {@link Ret0}></CODE> 3271 * 3272 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 3273 * browser receives the invocation-request. 3274 * 3275 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 3276 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 3277 * {@code >} to ensure the Browser Function has run to completion. 3278 */ 3279 public static Script<String, JsonObject, Ret0> setHardwareConcurrencyOverride 3280 (int hardwareConcurrency) 3281 { 3282 final int webSocketID = 23039000 + counter++; 3283 final boolean[] optionals = { false, }; 3284 3285 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 3286 String requestJSON = WriteJSON.get( 3287 parameterTypes.get("setHardwareConcurrencyOverride"), 3288 parameterNames.get("setHardwareConcurrencyOverride"), 3289 optionals, webSocketID, 3290 "Emulation.setHardwareConcurrencyOverride", 3291 hardwareConcurrency 3292 ); 3293 3294 // This Remote Command does not have a Return-Value. 3295 return new Script<> 3296 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 3297 } 3298 3299 /** 3300 * Allows overriding user agent with the given string. 3301 * {@code userAgentMetadata} must be set for Client Hint headers to be sent. 3302 * 3303 * @param userAgent User agent to use. 3304 * 3305 * @param acceptLanguage Browser language to emulate. 3306 * <BR /><B CLASS=Opt>OPTIONAL</B> 3307 * 3308 * @param platform The platform navigator.platform should return. 3309 * <BR /><B CLASS=Opt>OPTIONAL</B> 3310 * 3311 * @param userAgentMetadata To be sent in Sec-CH-UA-* headers and returned in navigator.userAgentData 3312 * <BR /><B CLASS=Opt>OPTIONAL</B><B CLASS=Exp>EXPERIMENTAL</B> 3313 * 3314 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 3315 * {@link Ret0}></CODE> 3316 * 3317 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 3318 * browser receives the invocation-request. 3319 * 3320 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 3321 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 3322 * {@code >} to ensure the Browser Function has run to completion. 3323 */ 3324 public static Script<String, JsonObject, Ret0> setUserAgentOverride( 3325 String userAgent, String acceptLanguage, String platform, 3326 Emulation.UserAgentMetadata userAgentMetadata 3327 ) 3328 { 3329 // Exception-Check(s) to ensure that if any parameters which are not declared as 3330 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 3331 3332 if (userAgent == null) THROWS.throwNPE("userAgent"); 3333 3334 final int webSocketID = 23040000 + counter++; 3335 final boolean[] optionals = { false, true, true, true, }; 3336 3337 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 3338 String requestJSON = WriteJSON.get( 3339 parameterTypes.get("setUserAgentOverride"), 3340 parameterNames.get("setUserAgentOverride"), 3341 optionals, webSocketID, 3342 "Emulation.setUserAgentOverride", 3343 userAgent, acceptLanguage, platform, userAgentMetadata 3344 ); 3345 3346 // This Remote Command does not have a Return-Value. 3347 return new Script<> 3348 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 3349 } 3350 3351 /** 3352 * Allows overriding the automation flag. 3353 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 3354 * 3355 * @param enabled Whether the override should be enabled. 3356 * 3357 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 3358 * {@link Ret0}></CODE> 3359 * 3360 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 3361 * browser receives the invocation-request. 3362 * 3363 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 3364 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 3365 * {@code >} to ensure the Browser Function has run to completion. 3366 */ 3367 public static Script<String, JsonObject, Ret0> setAutomationOverride(boolean enabled) 3368 { 3369 final int webSocketID = 23041000 + counter++; 3370 final boolean[] optionals = { false, }; 3371 3372 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 3373 String requestJSON = WriteJSON.get( 3374 parameterTypes.get("setAutomationOverride"), 3375 parameterNames.get("setAutomationOverride"), 3376 optionals, webSocketID, 3377 "Emulation.setAutomationOverride", 3378 enabled 3379 ); 3380 3381 // This Remote Command does not have a Return-Value. 3382 return new Script<> 3383 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 3384 } 3385 3386 /** 3387 * Allows overriding the difference between the small and large viewport sizes, which determine the 3388 * value of the {@code svh} and {@code lvh} unit, respectively. Only supported for top-level frames. 3389 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 3390 * 3391 * @param difference 3392 * This will cause an element of size 100svh to be {@code difference} pixels smaller than an element 3393 * of size 100lvh. 3394 * 3395 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 3396 * {@link Ret0}></CODE> 3397 * 3398 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 3399 * browser receives the invocation-request. 3400 * 3401 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 3402 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 3403 * {@code >} to ensure the Browser Function has run to completion. 3404 */ 3405 public static Script<String, JsonObject, Ret0> setSmallViewportHeightDifferenceOverride 3406 (int difference) 3407 { 3408 final int webSocketID = 23042000 + counter++; 3409 final boolean[] optionals = { false, }; 3410 3411 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 3412 String requestJSON = WriteJSON.get( 3413 parameterTypes.get("setSmallViewportHeightDifferenceOverride"), 3414 parameterNames.get("setSmallViewportHeightDifferenceOverride"), 3415 optionals, webSocketID, 3416 "Emulation.setSmallViewportHeightDifferenceOverride", 3417 difference 3418 ); 3419 3420 // This Remote Command does not have a Return-Value. 3421 return new Script<> 3422 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 3423 } 3424 3425}