001package Torello.Browser.BrowserAPI; 002 003// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 004// Java-HTML Imports 005// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 006 007import Torello.Browser.*; 008import Torello.Browser.helper.*; 009import Torello.Browser.JavaScriptAPI.*; 010import Torello.JSON.*; 011 012import Torello.Java.ReadOnly.ReadOnlyList; 013import Torello.Java.ReadOnly.ReadOnlyArrayList; 014 015import Torello.JavaDoc.Annotations.StaticFunctional; 016import Torello.JavaDoc.Annotations.JDHeaderBackgroundImg; 017 018import Torello.Browser.BrowserAPI.NestedHelpers.Commands.Target$$Commands; 019 020 021// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 022// JDK Imports 023// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 024 025import javax.json.JsonObject; 026import javax.json.JsonValue; 027 028/** 029 * <SPAN CLASS=COPIEDJDK><B>Supports additional targets discovery and allows to attach to them.</B></SPAN> 030 * <EMBED CLASS='external-html' DATA-FILE-ID=CDP.CODE_GEN_NOTE> 031 */ 032@StaticFunctional@JDHeaderBackgroundImg(EmbedTagFileID="CDP.WOOD_PLANK_NOTE") 033public class Target 034{ 035 // No Pubic Constructors 036 private Target() { } 037 038 039 // ******************************************************************************************** 040 // ******************************************************************************************** 041 // Eliminated Types 042 // ******************************************************************************************** 043 // ******************************************************************************************** 044 045 046 /** 047 * Unique identifier of attached debugging session. 048 049 * <EMBED CLASS='external-html' DATA-CTAS='String' DATA-FILE-ID=CDP.EliminatedType 050 * DATA-NAME=SessionID> 051 */ 052 public static final String SessionID = 053 "SessionID has been eliminated.\n" + 054 "It was replaced with the standard Java-Type: String"; 055 056 /** 057 * The entries in TargetFilter are matched sequentially against targets and 058 * the first entry that matches determines if the target is included or not, 059 * depending on the value of <CODE>exclude</CODE> field in the entry. 060 * If filter is not specified, the one assumed is 061 * [{type: "browser", exclude: true}, {type: "tab", exclude: true}, {}] 062 * (i.e. include everything but <CODE>browser</CODE> and <CODE>tab</CODE>). 063 * 064 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 065 066 * <EMBED CLASS='external-html' DATA-CTAS='FilterEntry[]' DATA-FILE-ID=CDP.EliminatedType 067 * DATA-NAME=TargetFilter> 068 */ 069 public static final String TargetFilter = 070 "TargetFilter has been eliminated.\n" + 071 "It was replaced with the standard Java-Type: FilterEntry[]"; 072 073 /** 074 * <CODE>[No Description Provided by Google]</CODE> 075 076 * <EMBED CLASS='external-html' DATA-CTAS='String' DATA-FILE-ID=CDP.EliminatedType 077 * DATA-NAME=TargetID> 078 */ 079 public static final String TargetID = 080 "TargetID has been eliminated.\n" + 081 "It was replaced with the standard Java-Type: String"; 082 083 084 // ******************************************************************************************** 085 // ******************************************************************************************** 086 // Enumerated String Constants Lists 087 // ******************************************************************************************** 088 // ******************************************************************************************** 089 090 091 /** 092 * The state of the target window. 093 * 094 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 095 * <BR /><BR /><B CLASS=StrEnumType>String-Enumeration Type</B> 096 */ 097 public static final ReadOnlyList<String> WindowState = new ReadOnlyArrayList<> 098 (String.class, "fullscreen", "maximized", "minimized", "normal"); 099 100 101 102 // ******************************************************************************************** 103 // ******************************************************************************************** 104 // Basic Types 105 // ******************************************************************************************** 106 // ******************************************************************************************** 107 108 109 /** 110 * A filter used by target query/discovery/auto-attach operations. 111 * 112 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 113 * <EMBED CLASS=globalDefs DATA-DOMAIN=Target DATA-API=BrowserAPI> 114 */ 115 @JDHeaderBackgroundImg(EmbedTagFileID="CDP.NESTED_TYPE_JDHBI") 116 public static class FilterEntry 117 extends BaseType<FilterEntry> 118 implements java.io.Serializable 119 { 120 /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUID> */ 121 protected static final long serialVersionUID = 1; 122 123 private static final NestedHelper<Target.FilterEntry> singleton = 124 Torello.Browser.BrowserAPI.NestedHelpers.Types. 125 Target$$FilterEntry$$.singleton; 126 127 /** 128 * If set, causes exclusion of matching targets from the list. 129 * <BR /><B CLASS=Opt-Top>OPTIONAL</B> 130 */ 131 public final Boolean exclude; 132 133 /** 134 * If not present, matches any type. 135 * <BR /><B CLASS=Opt-Top>OPTIONAL</B> 136 */ 137 public final String type; 138 139 /** Constructor. Please review this class' fields for documentation. */ 140 public FilterEntry(ReadOnlyList<Boolean> isPresent, Boolean exclude, String type) 141 { 142 super(singleton, Domains.Target, "FilterEntry", 2); 143 144 this.exclude = exclude; 145 this.type = type; 146 147 this.isPresent = (isPresent == null) 148 ? singleton.generateIsPresentList(this) 149 : THROWS.check(isPresent, 2, "Target.FilterEntry"); 150 } 151 152 /** Creates an instance of this class from a {@link JsonObject}.*/ 153 public static FilterEntry fromJSON(JsonObject jo) 154 { return singleton.fromJSON(jo); } 155 156 /** Returns this class's {@link NestedDescriptor} singleton-instance. class / type.*/ 157 public static NestedDescriptor<FilterEntry> descriptor() 158 { return singleton.descriptor(); } 159 } 160 161 /** 162 * <CODE>[No Description Provided by Google]</CODE> 163 * 164 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 165 * <EMBED CLASS=globalDefs DATA-DOMAIN=Target DATA-API=BrowserAPI> 166 */ 167 @JDHeaderBackgroundImg(EmbedTagFileID="CDP.NESTED_TYPE_JDHBI") 168 public static class RemoteLocation 169 extends BaseType<RemoteLocation> 170 implements java.io.Serializable 171 { 172 /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUID> */ 173 protected static final long serialVersionUID = 1; 174 175 private static final NestedHelper<Target.RemoteLocation> singleton = 176 Torello.Browser.BrowserAPI.NestedHelpers.Types. 177 Target$$RemoteLocation$$.singleton; 178 179 /** <CODE>[No Description Provided by Google]</CODE> */ 180 public final String host; 181 182 /** <CODE>[No Description Provided by Google]</CODE> */ 183 public final int port; 184 185 /** Constructor. Please review this class' fields for documentation. */ 186 public RemoteLocation(ReadOnlyList<Boolean> isPresent, String host, int port) 187 { 188 super(singleton, Domains.Target, "RemoteLocation", 2); 189 190 this.host = host; 191 this.port = port; 192 193 this.isPresent = (isPresent == null) 194 ? singleton.generateIsPresentList(this) 195 : THROWS.check(isPresent, 2, "Target.RemoteLocation"); 196 } 197 198 /** Creates an instance of this class from a {@link JsonObject}.*/ 199 public static RemoteLocation fromJSON(JsonObject jo) 200 { return singleton.fromJSON(jo); } 201 202 /** Returns this class's {@link NestedDescriptor} singleton-instance. class / type.*/ 203 public static NestedDescriptor<RemoteLocation> descriptor() 204 { return singleton.descriptor(); } 205 } 206 207 /** 208 * <CODE>[No Description Provided by Google]</CODE> 209 * 210 * <EMBED CLASS=globalDefs DATA-DOMAIN=Target DATA-API=BrowserAPI> 211 */ 212 @JDHeaderBackgroundImg(EmbedTagFileID="CDP.NESTED_TYPE_JDHBI") 213 public static class TargetInfo 214 extends BaseType<TargetInfo> 215 implements java.io.Serializable 216 { 217 /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUID> */ 218 protected static final long serialVersionUID = 1; 219 220 private static final NestedHelper<Target.TargetInfo> singleton = 221 Torello.Browser.BrowserAPI.NestedHelpers.Types. 222 Target$$TargetInfo$$.singleton; 223 224 /** <CODE>[No Description Provided by Google]</CODE> */ 225 public final String targetId; 226 227 /** List of types: https://source.chromium.org/chromium/chromium/src/+/main:content/browser/devtools/devtools_agent_host_impl.cc?ss=chromium&q=f:devtools%20-f:out%20%22::kTypeTab%5B%5D%22 */ 228 public final String type; 229 230 /** <CODE>[No Description Provided by Google]</CODE> */ 231 public final String title; 232 233 /** <CODE>[No Description Provided by Google]</CODE> */ 234 public final String url; 235 236 /** Whether the target has an attached client. */ 237 public final boolean attached; 238 239 /** 240 * Opener target Id 241 * <BR /><B CLASS=Opt-Top>OPTIONAL</B> 242 */ 243 public final String openerId; 244 245 /** 246 * Whether the target has access to the originating window. 247 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 248 */ 249 public final boolean canAccessOpener; 250 251 /** 252 * Frame id of originating window (is only set if target has an opener). 253 * <BR /><B CLASS=Opt-Top>OPTIONAL</B><B CLASS=Exp-Top>EXPERIMENTAL</B> 254 */ 255 public final String openerFrameId; 256 257 /** 258 * <CODE>[No Description Provided by Google]</CODE> 259 * <BR /><B CLASS=Opt-Top>OPTIONAL</B><B CLASS=Exp-Top>EXPERIMENTAL</B> 260 */ 261 public final String browserContextId; 262 263 /** 264 * Provides additional details for specific target types. For example, for 265 * the type of "page", this may be set to "prerender". 266 * <BR /><B CLASS=Opt-Top>OPTIONAL</B><B CLASS=Exp-Top>EXPERIMENTAL</B> 267 */ 268 public final String subtype; 269 270 /** Constructor. Please review this class' fields for documentation. */ 271 public TargetInfo( 272 ReadOnlyList<Boolean> isPresent, String targetId, String type, String title, 273 String url, boolean attached, String openerId, boolean canAccessOpener, 274 String openerFrameId, String browserContextId, String subtype 275 ) 276 { 277 super(singleton, Domains.Target, "TargetInfo", 10); 278 279 this.targetId = targetId; 280 this.type = type; 281 this.title = title; 282 this.url = url; 283 this.attached = attached; 284 this.openerId = openerId; 285 this.canAccessOpener = canAccessOpener; 286 this.openerFrameId = openerFrameId; 287 this.browserContextId = browserContextId; 288 this.subtype = subtype; 289 290 this.isPresent = (isPresent == null) 291 ? singleton.generateIsPresentList(this) 292 : THROWS.check(isPresent, 10, "Target.TargetInfo"); 293 } 294 295 /** Creates an instance of this class from a {@link JsonObject}.*/ 296 public static TargetInfo fromJSON(JsonObject jo) 297 { return singleton.fromJSON(jo); } 298 299 /** Returns this class's {@link NestedDescriptor} singleton-instance. class / type.*/ 300 public static NestedDescriptor<TargetInfo> descriptor() 301 { return singleton.descriptor(); } 302 } 303 304 305 // ******************************************************************************************** 306 // ******************************************************************************************** 307 // Event Types 308 // ******************************************************************************************** 309 // ******************************************************************************************** 310 311 312 /** 313 * Issued when attached to target because of auto-attach or <CODE>attachToTarget</CODE> command. 314 * 315 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 316 * <EMBED CLASS=globalDefs DATA-DOMAIN=Target DATA-API=BrowserAPI> 317 */ 318 @JDHeaderBackgroundImg(EmbedTagFileID="CDP.NESTED_EVENT_JDHBI") 319 public static class attachedToTarget 320 extends BrowserEvent<attachedToTarget> 321 implements java.io.Serializable 322 { 323 /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUID> */ 324 protected static final long serialVersionUID = 1; 325 326 private static final NestedHelper<Target.attachedToTarget> singleton = 327 Torello.Browser.BrowserAPI.NestedHelpers.Events. 328 Target$$attachedToTarget$$.singleton; 329 330 /** Identifier assigned to the session used to send/receive messages. */ 331 public final String sessionId; 332 333 /** <CODE>[No Description Provided by Google]</CODE> */ 334 public final Target.TargetInfo targetInfo; 335 336 /** <CODE>[No Description Provided by Google]</CODE> */ 337 public final boolean waitingForDebugger; 338 339 /** Constructor. Please review this class' fields for documentation. */ 340 public attachedToTarget( 341 ReadOnlyList<Boolean> isPresent, String sessionId, TargetInfo targetInfo, 342 boolean waitingForDebugger 343 ) 344 { 345 super(singleton, Domains.Target, "attachedToTarget", 3); 346 347 this.sessionId = sessionId; 348 this.targetInfo = targetInfo; 349 this.waitingForDebugger = waitingForDebugger; 350 351 this.isPresent = (isPresent == null) 352 ? singleton.generateIsPresentList(this) 353 : THROWS.check(isPresent, 3, "Target.attachedToTarget"); 354 } 355 356 /** Creates an instance of this class from a {@link JsonObject}.*/ 357 public static attachedToTarget fromJSON(JsonObject jo) 358 { return singleton.fromJSON(jo); } 359 360 /** Returns this class's {@link NestedDescriptor} singleton-instance. class / type.*/ 361 public static NestedDescriptor<attachedToTarget> descriptor() 362 { return singleton.descriptor(); } 363 } 364 365 /** 366 * Issued when detached from target for any reason (including <CODE>detachFromTarget</CODE> command). Can be 367 * issued multiple times per target if multiple sessions have been attached to it. 368 * 369 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 370 * <EMBED CLASS=globalDefs DATA-DOMAIN=Target DATA-API=BrowserAPI> 371 */ 372 @JDHeaderBackgroundImg(EmbedTagFileID="CDP.NESTED_EVENT_JDHBI") 373 public static class detachedFromTarget 374 extends BrowserEvent<detachedFromTarget> 375 implements java.io.Serializable 376 { 377 /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUID> */ 378 protected static final long serialVersionUID = 1; 379 380 private static final NestedHelper<Target.detachedFromTarget> singleton = 381 Torello.Browser.BrowserAPI.NestedHelpers.Events. 382 Target$$detachedFromTarget$$.singleton; 383 384 /** Detached session identifier. */ 385 public final String sessionId; 386 387 /** 388 * Deprecated. 389 * <BR /><B CLASS=Opt-Top>OPTIONAL</B><B CLASS=Dep-Top>DEPRECATED</B> 390 */ 391 public final String targetId; 392 393 /** Constructor. Please review this class' fields for documentation. */ 394 public detachedFromTarget 395 (ReadOnlyList<Boolean> isPresent, String sessionId, String targetId) 396 { 397 super(singleton, Domains.Target, "detachedFromTarget", 2); 398 399 this.sessionId = sessionId; 400 this.targetId = targetId; 401 402 this.isPresent = (isPresent == null) 403 ? singleton.generateIsPresentList(this) 404 : THROWS.check(isPresent, 2, "Target.detachedFromTarget"); 405 } 406 407 /** Creates an instance of this class from a {@link JsonObject}.*/ 408 public static detachedFromTarget fromJSON(JsonObject jo) 409 { return singleton.fromJSON(jo); } 410 411 /** Returns this class's {@link NestedDescriptor} singleton-instance. class / type.*/ 412 public static NestedDescriptor<detachedFromTarget> descriptor() 413 { return singleton.descriptor(); } 414 } 415 416 /** 417 * Notifies about a new protocol message received from the session (as reported in 418 * <CODE>attachedToTarget</CODE> event). 419 * 420 * <EMBED CLASS=globalDefs DATA-DOMAIN=Target DATA-API=BrowserAPI> 421 */ 422 @JDHeaderBackgroundImg(EmbedTagFileID="CDP.NESTED_EVENT_JDHBI") 423 public static class receivedMessageFromTarget 424 extends BrowserEvent<receivedMessageFromTarget> 425 implements java.io.Serializable 426 { 427 /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUID> */ 428 protected static final long serialVersionUID = 1; 429 430 private static final NestedHelper<Target.receivedMessageFromTarget> singleton = 431 Torello.Browser.BrowserAPI.NestedHelpers.Events. 432 Target$$receivedMessageFromTarget$$.singleton; 433 434 /** Identifier of a session which sends a message. */ 435 public final String sessionId; 436 437 /** <CODE>[No Description Provided by Google]</CODE> */ 438 public final String message; 439 440 /** 441 * Deprecated. 442 * <BR /><B CLASS=Opt-Top>OPTIONAL</B><B CLASS=Dep-Top>DEPRECATED</B> 443 */ 444 public final String targetId; 445 446 /** Constructor. Please review this class' fields for documentation. */ 447 public receivedMessageFromTarget 448 (ReadOnlyList<Boolean> isPresent, String sessionId, String message, String targetId) 449 { 450 super(singleton, Domains.Target, "receivedMessageFromTarget", 3); 451 452 this.sessionId = sessionId; 453 this.message = message; 454 this.targetId = targetId; 455 456 this.isPresent = (isPresent == null) 457 ? singleton.generateIsPresentList(this) 458 : THROWS.check(isPresent, 3, "Target.receivedMessageFromTarget"); 459 } 460 461 /** Creates an instance of this class from a {@link JsonObject}.*/ 462 public static receivedMessageFromTarget fromJSON(JsonObject jo) 463 { return singleton.fromJSON(jo); } 464 465 /** Returns this class's {@link NestedDescriptor} singleton-instance. class / type.*/ 466 public static NestedDescriptor<receivedMessageFromTarget> descriptor() 467 { return singleton.descriptor(); } 468 } 469 470 /** 471 * Issued when a target has crashed. 472 * 473 * <EMBED CLASS=globalDefs DATA-DOMAIN=Target DATA-API=BrowserAPI> 474 */ 475 @JDHeaderBackgroundImg(EmbedTagFileID="CDP.NESTED_EVENT_JDHBI") 476 public static class targetCrashed 477 extends BrowserEvent<targetCrashed> 478 implements java.io.Serializable 479 { 480 /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUID> */ 481 protected static final long serialVersionUID = 1; 482 483 private static final NestedHelper<Target.targetCrashed> singleton = 484 Torello.Browser.BrowserAPI.NestedHelpers.Events. 485 Target$$targetCrashed$$.singleton; 486 487 /** <CODE>[No Description Provided by Google]</CODE> */ 488 public final String targetId; 489 490 /** Termination status type. */ 491 public final String status; 492 493 /** Termination error code. */ 494 public final int errorCode; 495 496 /** Constructor. Please review this class' fields for documentation. */ 497 public targetCrashed 498 (ReadOnlyList<Boolean> isPresent, String targetId, String status, int errorCode) 499 { 500 super(singleton, Domains.Target, "targetCrashed", 3); 501 502 this.targetId = targetId; 503 this.status = status; 504 this.errorCode = errorCode; 505 506 this.isPresent = (isPresent == null) 507 ? singleton.generateIsPresentList(this) 508 : THROWS.check(isPresent, 3, "Target.targetCrashed"); 509 } 510 511 /** Creates an instance of this class from a {@link JsonObject}.*/ 512 public static targetCrashed fromJSON(JsonObject jo) 513 { return singleton.fromJSON(jo); } 514 515 /** Returns this class's {@link NestedDescriptor} singleton-instance. class / type.*/ 516 public static NestedDescriptor<targetCrashed> descriptor() 517 { return singleton.descriptor(); } 518 } 519 520 /** 521 * Issued when a possible inspection target is created. 522 * 523 * <EMBED CLASS=globalDefs DATA-DOMAIN=Target DATA-API=BrowserAPI> 524 */ 525 @JDHeaderBackgroundImg(EmbedTagFileID="CDP.NESTED_EVENT_JDHBI") 526 public static class targetCreated 527 extends BrowserEvent<targetCreated> 528 implements java.io.Serializable 529 { 530 /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUID> */ 531 protected static final long serialVersionUID = 1; 532 533 private static final NestedHelper<Target.targetCreated> singleton = 534 Torello.Browser.BrowserAPI.NestedHelpers.Events. 535 Target$$targetCreated$$.singleton; 536 537 /** <CODE>[No Description Provided by Google]</CODE> */ 538 public final Target.TargetInfo targetInfo; 539 540 /** Constructor. Please review this class' fields for documentation. */ 541 public targetCreated(ReadOnlyList<Boolean> isPresent, TargetInfo targetInfo) 542 { 543 super(singleton, Domains.Target, "targetCreated", 1); 544 545 this.targetInfo = targetInfo; 546 547 this.isPresent = (isPresent == null) 548 ? singleton.generateIsPresentList(this) 549 : THROWS.check(isPresent, 1, "Target.targetCreated"); 550 } 551 552 /** Creates an instance of this class from a {@link JsonObject}.*/ 553 public static targetCreated fromJSON(JsonObject jo) 554 { return singleton.fromJSON(jo); } 555 556 /** Returns this class's {@link NestedDescriptor} singleton-instance. class / type.*/ 557 public static NestedDescriptor<targetCreated> descriptor() 558 { return singleton.descriptor(); } 559 } 560 561 /** 562 * Issued when a target is destroyed. 563 * 564 * <EMBED CLASS=globalDefs DATA-DOMAIN=Target DATA-API=BrowserAPI> 565 */ 566 @JDHeaderBackgroundImg(EmbedTagFileID="CDP.NESTED_EVENT_JDHBI") 567 public static class targetDestroyed 568 extends BrowserEvent<targetDestroyed> 569 implements java.io.Serializable 570 { 571 /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUID> */ 572 protected static final long serialVersionUID = 1; 573 574 private static final NestedHelper<Target.targetDestroyed> singleton = 575 Torello.Browser.BrowserAPI.NestedHelpers.Events. 576 Target$$targetDestroyed$$.singleton; 577 578 /** <CODE>[No Description Provided by Google]</CODE> */ 579 public final String targetId; 580 581 /** Constructor. Please review this class' fields for documentation. */ 582 public targetDestroyed(ReadOnlyList<Boolean> isPresent, String targetId) 583 { 584 super(singleton, Domains.Target, "targetDestroyed", 1); 585 586 this.targetId = targetId; 587 588 this.isPresent = (isPresent == null) 589 ? singleton.generateIsPresentList(this) 590 : THROWS.check(isPresent, 1, "Target.targetDestroyed"); 591 } 592 593 /** Creates an instance of this class from a {@link JsonObject}.*/ 594 public static targetDestroyed fromJSON(JsonObject jo) 595 { return singleton.fromJSON(jo); } 596 597 /** Returns this class's {@link NestedDescriptor} singleton-instance. class / type.*/ 598 public static NestedDescriptor<targetDestroyed> descriptor() 599 { return singleton.descriptor(); } 600 } 601 602 /** 603 * Issued when some information about a target has changed. This only happens between 604 * <CODE>targetCreated</CODE> and <CODE>targetDestroyed</CODE>. 605 * 606 * <EMBED CLASS=globalDefs DATA-DOMAIN=Target DATA-API=BrowserAPI> 607 */ 608 @JDHeaderBackgroundImg(EmbedTagFileID="CDP.NESTED_EVENT_JDHBI") 609 public static class targetInfoChanged 610 extends BrowserEvent<targetInfoChanged> 611 implements java.io.Serializable 612 { 613 /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUID> */ 614 protected static final long serialVersionUID = 1; 615 616 private static final NestedHelper<Target.targetInfoChanged> singleton = 617 Torello.Browser.BrowserAPI.NestedHelpers.Events. 618 Target$$targetInfoChanged$$.singleton; 619 620 /** <CODE>[No Description Provided by Google]</CODE> */ 621 public final Target.TargetInfo targetInfo; 622 623 /** Constructor. Please review this class' fields for documentation. */ 624 public targetInfoChanged(ReadOnlyList<Boolean> isPresent, TargetInfo targetInfo) 625 { 626 super(singleton, Domains.Target, "targetInfoChanged", 1); 627 628 this.targetInfo = targetInfo; 629 630 this.isPresent = (isPresent == null) 631 ? singleton.generateIsPresentList(this) 632 : THROWS.check(isPresent, 1, "Target.targetInfoChanged"); 633 } 634 635 /** Creates an instance of this class from a {@link JsonObject}.*/ 636 public static targetInfoChanged fromJSON(JsonObject jo) 637 { return singleton.fromJSON(jo); } 638 639 /** Returns this class's {@link NestedDescriptor} singleton-instance. class / type.*/ 640 public static NestedDescriptor<targetInfoChanged> descriptor() 641 { return singleton.descriptor(); } 642 } 643 644 645 646 647 // ******************************************************************************************** 648 // ******************************************************************************************** 649 // Commands 650 // ******************************************************************************************** 651 // ******************************************************************************************** 652 653 654 /** 655 * Activates (focuses) the target. 656 * 657 * @param targetId - 658 * 659 * @return An instance of <CODE>{@link Script}<Void></CODE> 660 * 661 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 662 * browser receives the invocation-request. 663 * 664 * <BR /><BR /><DIV CLASS=JDHint> 665 * This Browser-Function <I>does not have</I> a return-value. You may choose to 666 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <Void>} to ensure that 667 * the Browser Function has run to completion. 668 * </DIV> 669 */ 670 public static Script<Void> activateTarget(String targetId) 671 { 672 // Build the JSON Request-Object (as a String); only 1 Parameter is passed 673 final String requestJSON = WriteJSON.get 674 (CDPTypes.STRING, "targetId", false, "Target.activateTarget", targetId); 675 676 return Script.NO_RET(Domains.Target, "activateTarget", requestJSON); 677 } 678 679 /** 680 * Attaches to the browser target, only uses flat sessionId mode. 681 * 682 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 683 * 684 * @return An instance of <CODE>{@link Script}<String></CODE> 685 * 686 * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using 687 * {@link Script#exec(WebSocketSender) Script.exec}, and afterwards, a {@link Promise} 688 * <CODE><String></CODE> will be returned 689 * 690 * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>, 691 * using {@link Promise#await()}, <I>and the returned result of this Browser Function may 692 * be retrieved.</I> 693 * 694 * <BR /><BR /><DIV CLASS=JDHint> 695 * This Browser Function's {@code Promise} returns: 696 * <CODE>String (<B>sessionId</B>)</CODE> 697 * <BR /> 698 * Id assigned to the session. 699 * </DIV> 700 */ 701 public static Script<String> attachToBrowserTarget() 702 { 703 // Ultra-Simple Request JSON - Because this method has no parameters 704 final String requestJSON = "{\"method\":\"Target.attachToBrowserTarget\"}"; 705 706 return new Script<>( 707 Domains.Target, "attachToBrowserTarget", requestJSON, 708 jo -> ReadJSON.getString(jo, "sessionId", true, false), 709 String.class 710 ); 711 } 712 713 /** 714 * Attaches to the target with given id. 715 * 716 * @param targetId - 717 * 718 * @param flatten 719 * Enables "flat" access to the session via specifying sessionId attribute in the commands. 720 * We plan to make this the default, deprecate non-flattened mode, 721 * and eventually retire it. See crbug.com/991325. 722 * <BR /><B CLASS=Opt-Top>OPTIONAL</B> 723 * 724 * @return An instance of <CODE>{@link Script}<String></CODE> 725 * 726 * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using 727 * {@link Script#exec(WebSocketSender) Script.exec}, and afterwards, a {@link Promise} 728 * <CODE><String></CODE> will be returned 729 * 730 * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>, 731 * using {@link Promise#await()}, <I>and the returned result of this Browser Function may 732 * be retrieved.</I> 733 * 734 * <BR /><BR /><DIV CLASS=JDHint> 735 * This Browser Function's {@code Promise} returns: 736 * <CODE>String (<B>sessionId</B>)</CODE> 737 * <BR /> 738 * Id assigned to the session. 739 * </DIV> 740 */ 741 public static Script<String> attachToTarget(String targetId, Boolean flatten) 742 { 743 // Convert all Method Parameters into a JSON Request-Object (as a String) 744 final String requestJSON = WriteJSON.get( 745 Target$$Commands.attachToTarget$$, "Target.attachToTarget", 746 targetId, flatten 747 ); 748 749 return new Script<>( 750 Domains.Target, "attachToTarget", requestJSON, 751 jo -> ReadJSON.getString(jo, "sessionId", true, false), 752 String.class 753 ); 754 } 755 756 /** 757 * Adds the specified target to the list of targets that will be monitored for any related target 758 * creation (such as child frames, child workers and new versions of service worker) and reported 759 * through <CODE>attachedToTarget</CODE>. The specified target is also auto-attached. 760 * This cancels the effect of any previous <CODE>setAutoAttach</CODE> and is also cancelled by subsequent 761 * <CODE>setAutoAttach</CODE>. Only available at the Browser target. 762 * 763 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 764 * 765 * @param targetId - 766 * 767 * @param waitForDebuggerOnStart 768 * Whether to pause new targets when attaching to them. Use <CODE>RunTime.runIfWaitingForDebugger</CODE> 769 * to run paused targets. 770 * 771 * @param filter Only targets matching filter will be attached. 772 * <BR /><B CLASS=Opt-Top>OPTIONAL</B><B CLASS=Exp-Top>EXPERIMENTAL</B> 773 * 774 * @return An instance of <CODE>{@link Script}<Void></CODE> 775 * 776 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 777 * browser receives the invocation-request. 778 * 779 * <BR /><BR /><DIV CLASS=JDHint> 780 * This Browser-Function <I>does not have</I> a return-value. You may choose to 781 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <Void>} to ensure that 782 * the Browser Function has run to completion. 783 * </DIV> 784 */ 785 public static Script<Void> autoAttachRelated 786 (String targetId, boolean waitForDebuggerOnStart, FilterEntry[] filter) 787 { 788 // Convert all Method Parameters into a JSON Request-Object (as a String) 789 final String requestJSON = WriteJSON.get( 790 Target$$Commands.autoAttachRelated$$, "Target.autoAttachRelated", 791 targetId, waitForDebuggerOnStart, filter 792 ); 793 794 return Script.NO_RET(Domains.Target, "autoAttachRelated", requestJSON); 795 } 796 797 /** 798 * Closes the target. If the target is a page that gets closed too. 799 * 800 * @param targetId - 801 * 802 * @return An instance of <CODE>{@link Script}<Boolean></CODE> 803 * 804 * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using 805 * {@link Script#exec(WebSocketSender) Script.exec}, and afterwards, a {@link Promise} 806 * <CODE><Boolean></CODE> will be returned 807 * 808 * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>, 809 * using {@link Promise#await()}, <I>and the returned result of this Browser Function may 810 * be retrieved.</I> 811 * 812 * <BR /><BR /><DIV CLASS=JDHint> 813 * This Browser Function's {@code Promise} returns: 814 * <CODE>Boolean (<B>success</B>)</CODE> 815 * <BR /> 816 * Always set to true. If an error occurs, the response indicates protocol error. 817 * </DIV> 818 */ 819 public static Script<Boolean> closeTarget(String targetId) 820 { 821 // Build the JSON Request-Object (as a String); only 1 Parameter is passed 822 final String requestJSON = WriteJSON.get 823 (CDPTypes.STRING, "targetId", false, "Target.closeTarget", targetId); 824 825 return new Script<>( 826 Domains.Target, "closeTarget", requestJSON, 827 jo -> ReadBoxedJSON.getBoolean(jo, "success", JFlag.RD_N | JFlag.RD_M, DV.NULL_BOOL), 828 Boolean.class 829 ); 830 } 831 832 /** 833 * Creates a new empty BrowserContext. Similar to an incognito profile but you can have more than 834 * one. 835 * 836 * @param disposeOnDetach If specified, disposes this context when debugging session disconnects. 837 * <BR /><B CLASS=Opt-Top>OPTIONAL</B><B CLASS=Exp-Top>EXPERIMENTAL</B> 838 * 839 * @param proxyServer Proxy server, similar to the one passed to --proxy-server 840 * <BR /><B CLASS=Opt-Top>OPTIONAL</B><B CLASS=Exp-Top>EXPERIMENTAL</B> 841 * 842 * @param proxyBypassList Proxy bypass list, similar to the one passed to --proxy-bypass-list 843 * <BR /><B CLASS=Opt-Top>OPTIONAL</B><B CLASS=Exp-Top>EXPERIMENTAL</B> 844 * 845 * @param originsWithUniversalNetworkAccess 846 * An optional list of origins to grant unlimited cross-origin access to. 847 * Parts of the URL other than those constituting origin are ignored. 848 * <BR /><B CLASS=Opt-Top>OPTIONAL</B><B CLASS=Exp-Top>EXPERIMENTAL</B> 849 * 850 * @return An instance of <CODE>{@link Script}<String></CODE> 851 * 852 * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using 853 * {@link Script#exec(WebSocketSender) Script.exec}, and afterwards, a {@link Promise} 854 * <CODE><String></CODE> will be returned 855 * 856 * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>, 857 * using {@link Promise#await()}, <I>and the returned result of this Browser Function may 858 * be retrieved.</I> 859 * 860 * <BR /><BR /><DIV CLASS=JDHint> 861 * This Browser Function's {@code Promise} returns: 862 * <CODE>String (<B>browserContextId</B>)</CODE> 863 * <BR /> 864 * The id of the context created. 865 * </DIV> 866 */ 867 public static Script<String> createBrowserContext( 868 Boolean disposeOnDetach, String proxyServer, String proxyBypassList, 869 String[] originsWithUniversalNetworkAccess 870 ) 871 { 872 // Convert all Method Parameters into a JSON Request-Object (as a String) 873 final String requestJSON = WriteJSON.get( 874 Target$$Commands.createBrowserContext$$, "Target.createBrowserContext", 875 disposeOnDetach, proxyServer, proxyBypassList, originsWithUniversalNetworkAccess 876 ); 877 878 return new Script<>( 879 Domains.Target, "createBrowserContext", requestJSON, 880 jo -> ReadJSON.getString(jo, "browserContextId", true, false), 881 String.class 882 ); 883 } 884 885 /** 886 * Creates a new page. 887 * 888 * <BR /><BR /><DIV CLASS=JDHint> 889 * 👍 Because of the sheer number of input parameters to this method, there is a 890 * a {@link CommandBuilder} variant to this method which may be invoked instead. 891 * 892 * <BR /><BR /> 893 * Please View: {@link #createTarget()} 894 * </DIV> 895 * 896 * @param url The initial URL the page will be navigated to. An empty string indicates about:blank. 897 * 898 * @param left Frame left origin in DIP (requires newWindow to be true or headless shell). 899 * <BR /><B CLASS=Opt-Top>OPTIONAL</B><B CLASS=Exp-Top>EXPERIMENTAL</B> 900 * 901 * @param top Frame top origin in DIP (requires newWindow to be true or headless shell). 902 * <BR /><B CLASS=Opt-Top>OPTIONAL</B><B CLASS=Exp-Top>EXPERIMENTAL</B> 903 * 904 * @param width Frame width in DIP (requires newWindow to be true or headless shell). 905 * <BR /><B CLASS=Opt-Top>OPTIONAL</B> 906 * 907 * @param height Frame height in DIP (requires newWindow to be true or headless shell). 908 * <BR /><B CLASS=Opt-Top>OPTIONAL</B> 909 * 910 * @param windowState 911 * Frame window state (requires newWindow to be true or headless shell). 912 * Default is normal. 913 * <BR /><B CLASS=Opt-Top>OPTIONAL</B> 914 * 915 * @param browserContextId The browser context to create the page in. 916 * <BR /><B CLASS=Opt-Top>OPTIONAL</B><B CLASS=Exp-Top>EXPERIMENTAL</B> 917 * 918 * @param enableBeginFrameControl 919 * Whether BeginFrames for this target will be controlled via DevTools (headless shell only, 920 * not supported on MacOS yet, false by default). 921 * <BR /><B CLASS=Opt-Top>OPTIONAL</B><B CLASS=Exp-Top>EXPERIMENTAL</B> 922 * 923 * @param newWindow Whether to create a new Window or Tab (false by default, not supported by headless shell). 924 * <BR /><B CLASS=Opt-Top>OPTIONAL</B> 925 * 926 * @param background 927 * Whether to create the target in background or foreground (false by default, not supported 928 * by headless shell). 929 * <BR /><B CLASS=Opt-Top>OPTIONAL</B> 930 * 931 * @param forTab Whether to create the target of type "tab". 932 * <BR /><B CLASS=Opt-Top>OPTIONAL</B><B CLASS=Exp-Top>EXPERIMENTAL</B> 933 * 934 * @param hidden 935 * Whether to create a hidden target. The hidden target is observable via protocol, but not 936 * present in the tab UI strip. Cannot be created with <CODE>forTab: true</CODE>, <CODE>newWindow: true</CODE> or 937 * <CODE>background: false</CODE>. The life-time of the tab is limited to the life-time of the session. 938 * <BR /><B CLASS=Opt-Top>OPTIONAL</B><B CLASS=Exp-Top>EXPERIMENTAL</B> 939 * 940 * @return An instance of <CODE>{@link Script}<String></CODE> 941 * 942 * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using 943 * {@link Script#exec(WebSocketSender) Script.exec}, and afterwards, a {@link Promise} 944 * <CODE><String></CODE> will be returned 945 * 946 * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>, 947 * using {@link Promise#await()}, <I>and the returned result of this Browser Function may 948 * be retrieved.</I> 949 * 950 * <BR /><BR /><DIV CLASS=JDHint> 951 * This Browser Function's {@code Promise} returns: 952 * <CODE>String (<B>targetId</B>)</CODE> 953 * <BR /> 954 * The id of the page opened. 955 * </DIV> 956 */ 957 public static Script<String> createTarget( 958 String url, Integer left, Integer top, Integer width, Integer height, 959 String windowState, String browserContextId, Boolean enableBeginFrameControl, 960 Boolean newWindow, Boolean background, Boolean forTab, Boolean hidden 961 ) 962 { 963 // Convert all Method Parameters into a JSON Request-Object (as a String) 964 final String requestJSON = WriteJSON.get( 965 Target$$Commands.createTarget$$, "Target.createTarget", 966 url, left, top, width, height, windowState, browserContextId, enableBeginFrameControl, 967 newWindow, background, forTab, hidden 968 ); 969 970 return new Script<>( 971 Domains.Target, "createTarget", requestJSON, 972 jo -> ReadJSON.getString(jo, "targetId", true, false), 973 String.class 974 ); 975 } 976 977 /** 978 * Detaches session with given id. 979 * 980 * @param sessionId Session to detach. 981 * <BR /><B CLASS=Opt-Top>OPTIONAL</B> 982 * 983 * @param targetId Deprecated. 984 * <BR /><B CLASS=Opt-Top>OPTIONAL</B><B CLASS=Dep-Top>DEPRECATED</B> 985 * 986 * @return An instance of <CODE>{@link Script}<Void></CODE> 987 * 988 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 989 * browser receives the invocation-request. 990 * 991 * <BR /><BR /><DIV CLASS=JDHint> 992 * This Browser-Function <I>does not have</I> a return-value. You may choose to 993 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <Void>} to ensure that 994 * the Browser Function has run to completion. 995 * </DIV> 996 */ 997 public static Script<Void> detachFromTarget(String sessionId, String targetId) 998 { 999 // Convert all Method Parameters into a JSON Request-Object (as a String) 1000 final String requestJSON = WriteJSON.get( 1001 Target$$Commands.detachFromTarget$$, "Target.detachFromTarget", 1002 sessionId, targetId 1003 ); 1004 1005 return Script.NO_RET(Domains.Target, "detachFromTarget", requestJSON); 1006 } 1007 1008 /** 1009 * Deletes a BrowserContext. All the belonging pages will be closed without calling their 1010 * beforeunload hooks. 1011 * 1012 * @param browserContextId - 1013 * 1014 * @return An instance of <CODE>{@link Script}<Void></CODE> 1015 * 1016 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 1017 * browser receives the invocation-request. 1018 * 1019 * <BR /><BR /><DIV CLASS=JDHint> 1020 * This Browser-Function <I>does not have</I> a return-value. You may choose to 1021 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <Void>} to ensure that 1022 * the Browser Function has run to completion. 1023 * </DIV> 1024 */ 1025 public static Script<Void> disposeBrowserContext(String browserContextId) 1026 { 1027 // Build the JSON Request-Object (as a String); only 1 Parameter is passed 1028 final String requestJSON = WriteJSON.get( 1029 CDPTypes.STRING, "browserContextId", false, "Target.disposeBrowserContext", 1030 browserContextId 1031 ); 1032 1033 return Script.NO_RET(Domains.Target, "disposeBrowserContext", requestJSON); 1034 } 1035 1036 /** 1037 * Inject object to the target's main frame that provides a communication 1038 * channel with browser target. 1039 * 1040 * Injected object will be available as <CODE>window[bindingName]</CODE>. 1041 * 1042 * The object has the following API: 1043 * - <CODE>binding.send(json)</CODE> - a method to send messages over the remote debugging protocol 1044 * - <CODE>binding.onmessage = json => handleMessage(json)</CODE> - a callback that will be called for the protocol notifications and command responses. 1045 * 1046 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 1047 * 1048 * @param targetId - 1049 * 1050 * @param bindingName Binding name, 'cdp' if not specified. 1051 * <BR /><B CLASS=Opt-Top>OPTIONAL</B> 1052 * 1053 * @param inheritPermissions If true, inherits the current root session's permissions (default: false). 1054 * <BR /><B CLASS=Opt-Top>OPTIONAL</B> 1055 * 1056 * @return An instance of <CODE>{@link Script}<Void></CODE> 1057 * 1058 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 1059 * browser receives the invocation-request. 1060 * 1061 * <BR /><BR /><DIV CLASS=JDHint> 1062 * This Browser-Function <I>does not have</I> a return-value. You may choose to 1063 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <Void>} to ensure that 1064 * the Browser Function has run to completion. 1065 * </DIV> 1066 */ 1067 public static Script<Void> exposeDevToolsProtocol 1068 (String targetId, String bindingName, Boolean inheritPermissions) 1069 { 1070 // Convert all Method Parameters into a JSON Request-Object (as a String) 1071 final String requestJSON = WriteJSON.get( 1072 Target$$Commands.exposeDevToolsProtocol$$, "Target.exposeDevToolsProtocol", 1073 targetId, bindingName, inheritPermissions 1074 ); 1075 1076 return Script.NO_RET(Domains.Target, "exposeDevToolsProtocol", requestJSON); 1077 } 1078 1079 /** 1080 * Returns all browser contexts created with <CODE>Target.createBrowserContext</CODE> method. 1081 * 1082 * @return An instance of <CODE>{@link Script}<String[]></CODE> 1083 * 1084 * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using 1085 * {@link Script#exec(WebSocketSender) Script.exec}, and afterwards, a {@link Promise} 1086 * <CODE><String[]></CODE> will be returned 1087 * 1088 * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>, 1089 * using {@link Promise#await()}, <I>and the returned result of this Browser Function may 1090 * be retrieved.</I> 1091 * 1092 * <BR /><BR /><DIV CLASS=JDHint> 1093 * This Browser Function's {@code Promise} returns: 1094 * <CODE>String[] (<B>browserContextIds</B>)</CODE> 1095 * <BR /> 1096 * An array of browser context ids. 1097 * </DIV> 1098 */ 1099 public static Script<String[]> getBrowserContexts() 1100 { 1101 // Ultra-Simple Request JSON - Because this method has no parameters 1102 final String requestJSON = "{\"method\":\"Target.getBrowserContexts\"}"; 1103 1104 return new Script<>( 1105 Domains.Target, "getBrowserContexts", requestJSON, 1106 Target$$Commands::getBrowserContexts, 1107 String[].class 1108 ); 1109 } 1110 1111 /** 1112 * Returns information about a target. 1113 * 1114 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 1115 * 1116 * @param targetId - 1117 * <BR /><B CLASS=Opt-Top>OPTIONAL</B> 1118 * 1119 * @return An instance of <CODE>{@link Script}<{@link Target.TargetInfo}></CODE> 1120 * 1121 * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using 1122 * {@link Script#exec(WebSocketSender) Script.exec}, and afterwards, a {@link Promise} 1123 * <CODE><{@link Target.TargetInfo}></CODE> will be returned 1124 * 1125 * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>, 1126 * using {@link Promise#await()}, <I>and the returned result of this Browser Function may 1127 * be retrieved.</I> 1128 * 1129 * <BR /><BR /><DIV CLASS=JDHint> 1130 * This Browser Function's {@code Promise} returns: 1131 * <CODE>{@link Target.TargetInfo} (<B>targetInfo</B>)</CODE> 1132 * </DIV> 1133 */ 1134 public static Script<Target.TargetInfo> getTargetInfo(String targetId) 1135 { 1136 // Build the JSON Request-Object (as a String); only 1 Parameter is passed 1137 final String requestJSON = WriteJSON.get 1138 (CDPTypes.STRING, "targetId", true, "Target.getTargetInfo", targetId); 1139 1140 return new Script<>( 1141 Domains.Target, "getTargetInfo", requestJSON, 1142 Target$$Commands::getTargetInfo, 1143 Target.TargetInfo.class 1144 ); 1145 } 1146 1147 /** 1148 * Retrieves a list of available targets. 1149 * 1150 * @param filter 1151 * Only targets matching filter will be reported. If filter is not specified 1152 * and target discovery is currently enabled, a filter used for target discovery 1153 * is used for consistency. 1154 * <BR /><B CLASS=Opt-Top>OPTIONAL</B><B CLASS=Exp-Top>EXPERIMENTAL</B> 1155 * 1156 * @return An instance of <CODE>{@link Script}<{@link Target.TargetInfo}[]></CODE> 1157 * 1158 * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using 1159 * {@link Script#exec(WebSocketSender) Script.exec}, and afterwards, a {@link Promise} 1160 * <CODE><{@link Target.TargetInfo}[]></CODE> will be returned 1161 * 1162 * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>, 1163 * using {@link Promise#await()}, <I>and the returned result of this Browser Function may 1164 * be retrieved.</I> 1165 * 1166 * <BR /><BR /><DIV CLASS=JDHint> 1167 * This Browser Function's {@code Promise} returns: 1168 * <CODE>{@link Target.TargetInfo}[] (<B>targetInfos</B>)</CODE> 1169 * <BR /> 1170 * The list of targets. 1171 * </DIV> 1172 */ 1173 public static Script<Target.TargetInfo[]> getTargets(FilterEntry[] filter) 1174 { 1175 // Build the JSON Request-Object (as a String); only 1 Parameter is passed 1176 final String requestJSON = WriteJSON.get 1177 (CDPTypes.CDP_TYPE, "filter", true, "Target.getTargets", (Object) filter); 1178 1179 return new Script<>( 1180 Domains.Target, "getTargets", requestJSON, 1181 Target$$Commands::getTargets, 1182 Target.TargetInfo[].class 1183 ); 1184 } 1185 1186 /** 1187 * Opens a DevTools window for the target. 1188 * 1189 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 1190 * 1191 * @param targetId This can be the page or tab target ID. 1192 * 1193 * @return An instance of <CODE>{@link Script}<String></CODE> 1194 * 1195 * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using 1196 * {@link Script#exec(WebSocketSender) Script.exec}, and afterwards, a {@link Promise} 1197 * <CODE><String></CODE> will be returned 1198 * 1199 * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>, 1200 * using {@link Promise#await()}, <I>and the returned result of this Browser Function may 1201 * be retrieved.</I> 1202 * 1203 * <BR /><BR /><DIV CLASS=JDHint> 1204 * This Browser Function's {@code Promise} returns: 1205 * <CODE>String (<B>targetId</B>)</CODE> 1206 * <BR /> 1207 * The targetId of DevTools page target. 1208 * </DIV> 1209 */ 1210 public static Script<String> openDevTools(String targetId) 1211 { 1212 // Build the JSON Request-Object (as a String); only 1 Parameter is passed 1213 final String requestJSON = WriteJSON.get 1214 (CDPTypes.STRING, "targetId", false, "Target.openDevTools", targetId); 1215 1216 return new Script<>( 1217 Domains.Target, "openDevTools", requestJSON, 1218 jo -> ReadJSON.getString(jo, "targetId", true, false), 1219 String.class 1220 ); 1221 } 1222 1223 /** 1224 * Sends protocol message over session with given id. 1225 * Consider using flat mode instead; see commands attachToTarget, setAutoAttach, 1226 * and crbug.com/991325. 1227 * 1228 * <BR /><B CLASS=Dep-Top>DEPRECATED</B> 1229 * 1230 * @param message - 1231 * 1232 * @param sessionId Identifier of the session. 1233 * <BR /><B CLASS=Opt-Top>OPTIONAL</B> 1234 * 1235 * @param targetId Deprecated. 1236 * <BR /><B CLASS=Opt-Top>OPTIONAL</B><B CLASS=Dep-Top>DEPRECATED</B> 1237 * 1238 * @return An instance of <CODE>{@link Script}<Void></CODE> 1239 * 1240 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 1241 * browser receives the invocation-request. 1242 * 1243 * <BR /><BR /><DIV CLASS=JDHint> 1244 * This Browser-Function <I>does not have</I> a return-value. You may choose to 1245 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <Void>} to ensure that 1246 * the Browser Function has run to completion. 1247 * </DIV> 1248 */ 1249 public static Script<Void> sendMessageToTarget 1250 (String message, String sessionId, String targetId) 1251 { 1252 // Convert all Method Parameters into a JSON Request-Object (as a String) 1253 final String requestJSON = WriteJSON.get( 1254 Target$$Commands.sendMessageToTarget$$, "Target.sendMessageToTarget", 1255 message, sessionId, targetId 1256 ); 1257 1258 return Script.NO_RET(Domains.Target, "sendMessageToTarget", requestJSON); 1259 } 1260 1261 /** 1262 * Controls whether to automatically attach to new targets which are considered 1263 * to be directly related to this one (for example, iframes or workers). 1264 * When turned on, attaches to all existing related targets as well. When turned off, 1265 * automatically detaches from all currently attached targets. 1266 * This also clears all targets added by <CODE>autoAttachRelated</CODE> from the list of targets to watch 1267 * for creation of related targets. 1268 * You might want to call this recursively for auto-attached targets to attach 1269 * to all available targets. 1270 * 1271 * @param autoAttach Whether to auto-attach to related targets. 1272 * 1273 * @param waitForDebuggerOnStart 1274 * Whether to pause new targets when attaching to them. Use <CODE>RunTime.runIfWaitingForDebugger</CODE> 1275 * to run paused targets. 1276 * 1277 * @param flatten 1278 * Enables "flat" access to the session via specifying sessionId attribute in the commands. 1279 * We plan to make this the default, deprecate non-flattened mode, 1280 * and eventually retire it. See crbug.com/991325. 1281 * <BR /><B CLASS=Opt-Top>OPTIONAL</B><B CLASS=Exp-Top>EXPERIMENTAL</B> 1282 * 1283 * @param filter Only targets matching filter will be attached. 1284 * <BR /><B CLASS=Opt-Top>OPTIONAL</B><B CLASS=Exp-Top>EXPERIMENTAL</B> 1285 * 1286 * @return An instance of <CODE>{@link Script}<Void></CODE> 1287 * 1288 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 1289 * browser receives the invocation-request. 1290 * 1291 * <BR /><BR /><DIV CLASS=JDHint> 1292 * This Browser-Function <I>does not have</I> a return-value. You may choose to 1293 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <Void>} to ensure that 1294 * the Browser Function has run to completion. 1295 * </DIV> 1296 */ 1297 public static Script<Void> setAutoAttach 1298 (boolean autoAttach, boolean waitForDebuggerOnStart, Boolean flatten, FilterEntry[] filter) 1299 { 1300 // Convert all Method Parameters into a JSON Request-Object (as a String) 1301 final String requestJSON = WriteJSON.get( 1302 Target$$Commands.setAutoAttach$$, "Target.setAutoAttach", 1303 autoAttach, waitForDebuggerOnStart, flatten, filter 1304 ); 1305 1306 return Script.NO_RET(Domains.Target, "setAutoAttach", requestJSON); 1307 } 1308 1309 /** 1310 * Controls whether to discover available targets and notify via 1311 * <CODE>targetCreated/targetInfoChanged/targetDestroyed</CODE> events. 1312 * 1313 * @param discover Whether to discover available targets. 1314 * 1315 * @param filter 1316 * Only targets matching filter will be attached. If <CODE>discover</CODE> is false, 1317 * <CODE>filter</CODE> must be omitted or empty. 1318 * <BR /><B CLASS=Opt-Top>OPTIONAL</B><B CLASS=Exp-Top>EXPERIMENTAL</B> 1319 * 1320 * @return An instance of <CODE>{@link Script}<Void></CODE> 1321 * 1322 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 1323 * browser receives the invocation-request. 1324 * 1325 * <BR /><BR /><DIV CLASS=JDHint> 1326 * This Browser-Function <I>does not have</I> a return-value. You may choose to 1327 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <Void>} to ensure that 1328 * the Browser Function has run to completion. 1329 * </DIV> 1330 */ 1331 public static Script<Void> setDiscoverTargets(boolean discover, FilterEntry[] filter) 1332 { 1333 // Convert all Method Parameters into a JSON Request-Object (as a String) 1334 final String requestJSON = WriteJSON.get( 1335 Target$$Commands.setDiscoverTargets$$, "Target.setDiscoverTargets", 1336 discover, filter 1337 ); 1338 1339 return Script.NO_RET(Domains.Target, "setDiscoverTargets", requestJSON); 1340 } 1341 1342 /** 1343 * Enables target discovery for the specified locations, when <CODE>setDiscoverTargets</CODE> was set to 1344 * <CODE>true</CODE>. 1345 * 1346 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 1347 * 1348 * @param locations List of remote locations. 1349 * 1350 * @return An instance of <CODE>{@link Script}<Void></CODE> 1351 * 1352 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 1353 * browser receives the invocation-request. 1354 * 1355 * <BR /><BR /><DIV CLASS=JDHint> 1356 * This Browser-Function <I>does not have</I> a return-value. You may choose to 1357 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <Void>} to ensure that 1358 * the Browser Function has run to completion. 1359 * </DIV> 1360 */ 1361 public static Script<Void> setRemoteLocations(RemoteLocation[] locations) 1362 { 1363 // Build the JSON Request-Object (as a String); only 1 Parameter is passed 1364 final String requestJSON = WriteJSON.get( 1365 CDPTypes.CDP_TYPE_ARRAY_1D, "locations", false, "Target.setRemoteLocations", 1366 (Object) locations 1367 ); 1368 1369 return Script.NO_RET(Domains.Target, "setRemoteLocations", requestJSON); 1370 } 1371 1372 1373 // ******************************************************************************************** 1374 // ******************************************************************************************** 1375 // CommandBuilder Getter-Methods 1376 // ******************************************************************************************** 1377 // ******************************************************************************************** 1378 1379 1380 /** 1381 * Creates a buider for conveniently assigning parameters to this method. 1382 * 1383 * <BR /><BR /><DIV CLASS=JDHint> 1384 * Note that the original method expects 12 parameters, and can be cumbersome. 1385 * </DIV> 1386 * 1387 * @return {@link CommandBuilder} instance, for assigning parameter values, one by one. 1388 * @see #createTarget 1389 */ 1390 public static CommandBuilder<String> createTarget() 1391 { return CommandBuilder.builder(Target$$Commands.createTarget$$); } 1392 1393 1394}