001package Torello.Browser; 002 003import java.util.*; 004import javax.json.*; 005import javax.json.stream.*; 006import java.io.*; 007 008import java.lang.reflect.Method; 009import java.lang.reflect.Parameter; 010import java.util.function.Function; 011 012import Torello.Java.Additional.*; 013import Torello.Java.JSON.*; 014 015import static Torello.Java.JSON.JFlag.*; 016 017import Torello.Java.StrCmpr; 018import Torello.JavaDoc.StaticFunctional; 019import Torello.JavaDoc.JDHeaderBackgroundImg; 020import Torello.JavaDoc.Excuse; 021 022/** 023 * <SPAN CLASS=COPIEDJDK><B>Debugger domain exposes JavaScript debugging capabilities. It allows setting and removing 024 * breakpoints, stepping through execution, exploring stack traces, etc.</B></SPAN> 025 * 026 * <EMBED CLASS='external-html' DATA-FILE-ID=CODE_GEN_NOTE> 027 */ 028@StaticFunctional(Excused={"counter"}, Excuses={Excuse.CONFIGURATION}) 029@JDHeaderBackgroundImg(EmbedTagFileID="WOOD_PLANK_NOTE") 030public class Debugger 031{ 032 // ******************************************************************************************** 033 // ******************************************************************************************** 034 // Class Header Stuff 035 // ******************************************************************************************** 036 // ******************************************************************************************** 037 038 039 // No Pubic Constructors 040 private Debugger () { } 041 042 // These two Vector's are used by all the "Methods" exported by this class. java.lang.reflect 043 // is used to generate the JSON String's. It saves thousands of lines of Auto-Generated Code. 044 private static final Map<String, Vector<String>> parameterNames = new HashMap<>(); 045 private static final Map<String, Vector<Class<?>>> parameterTypes = new HashMap<>(); 046 047 // Some Methods do not take any parameters - for instance all the "enable()" and "disable()" 048 // I simply could not get ride of RAW-TYPES and UNCHECKED warnings... so there are now, 049 // offically, two empty-vectors. One for String's, and the other for Classes. 050 051 private static final Vector<String> EMPTY_VEC_STR = new Vector<>(); 052 private static final Vector<Class<?>> EMPTY_VEC_CLASS = new Vector<>(); 053 054 static 055 { 056 for (Method m : Debugger.class.getMethods()) 057 { 058 // This doesn't work! The parameter names are all "arg0" ... "argN" 059 // It works for java.lang.reflect.Field, BUT NOT java.lang.reflect.Parameter! 060 // 061 // Vector<String> parameterNamesList = new Vector<>(); -- NOPE! 062 063 Vector<Class<?>> parameterTypesList = new Vector<>(); 064 065 for (Parameter p : m.getParameters()) parameterTypesList.add(p.getType()); 066 067 parameterTypes.put( 068 m.getName(), 069 (parameterTypesList.size() > 0) ? parameterTypesList : EMPTY_VEC_CLASS 070 ); 071 } 072 } 073 074 static 075 { 076 Vector<String> v = null; 077 078 v = new Vector<String>(2); 079 parameterNames.put("continueToLocation", v); 080 Collections.addAll(v, new String[] 081 { "location", "targetCallFrames", }); 082 083 parameterNames.put("disable", EMPTY_VEC_STR); 084 085 v = new Vector<String>(1); 086 parameterNames.put("enable", v); 087 Collections.addAll(v, new String[] 088 { "maxScriptsCacheSize", }); 089 090 v = new Vector<String>(9); 091 parameterNames.put("evaluateOnCallFrame", v); 092 Collections.addAll(v, new String[] 093 { "callFrameId", "expression", "objectGroup", "includeCommandLineAPI", "silent", "returnByValue", "generatePreview", "throwOnSideEffect", "timeout", }); 094 095 v = new Vector<String>(3); 096 parameterNames.put("getPossibleBreakpoints", v); 097 Collections.addAll(v, new String[] 098 { "start", "end", "restrictToFunction", }); 099 100 v = new Vector<String>(1); 101 parameterNames.put("getScriptSource", v); 102 Collections.addAll(v, new String[] 103 { "scriptId", }); 104 105 v = new Vector<String>(1); 106 parameterNames.put("getWasmBytecode", v); 107 Collections.addAll(v, new String[] 108 { "scriptId", }); 109 110 v = new Vector<String>(1); 111 parameterNames.put("getStackTrace", v); 112 Collections.addAll(v, new String[] 113 { "stackTraceId", }); 114 115 parameterNames.put("pause", EMPTY_VEC_STR); 116 117 v = new Vector<String>(1); 118 parameterNames.put("pauseOnAsyncCall", v); 119 Collections.addAll(v, new String[] 120 { "parentStackTraceId", }); 121 122 v = new Vector<String>(1); 123 parameterNames.put("removeBreakpoint", v); 124 Collections.addAll(v, new String[] 125 { "breakpointId", }); 126 127 v = new Vector<String>(1); 128 parameterNames.put("restartFrame", v); 129 Collections.addAll(v, new String[] 130 { "callFrameId", }); 131 132 v = new Vector<String>(1); 133 parameterNames.put("resume", v); 134 Collections.addAll(v, new String[] 135 { "terminateOnResume", }); 136 137 v = new Vector<String>(4); 138 parameterNames.put("searchInContent", v); 139 Collections.addAll(v, new String[] 140 { "scriptId", "query", "caseSensitive", "isRegex", }); 141 142 v = new Vector<String>(1); 143 parameterNames.put("setAsyncCallStackDepth", v); 144 Collections.addAll(v, new String[] 145 { "maxDepth", }); 146 147 v = new Vector<String>(1); 148 parameterNames.put("setBlackboxPatterns", v); 149 Collections.addAll(v, new String[] 150 { "patterns", }); 151 152 v = new Vector<String>(2); 153 parameterNames.put("setBlackboxedRanges", v); 154 Collections.addAll(v, new String[] 155 { "scriptId", "positions", }); 156 157 v = new Vector<String>(2); 158 parameterNames.put("setBreakpoint", v); 159 Collections.addAll(v, new String[] 160 { "location", "condition", }); 161 162 v = new Vector<String>(1); 163 parameterNames.put("setInstrumentationBreakpoint", v); 164 Collections.addAll(v, new String[] 165 { "instrumentation", }); 166 167 v = new Vector<String>(6); 168 parameterNames.put("setBreakpointByUrl", v); 169 Collections.addAll(v, new String[] 170 { "lineNumber", "url", "urlRegex", "scriptHash", "columnNumber", "condition", }); 171 172 v = new Vector<String>(2); 173 parameterNames.put("setBreakpointOnFunctionCall", v); 174 Collections.addAll(v, new String[] 175 { "objectId", "condition", }); 176 177 v = new Vector<String>(1); 178 parameterNames.put("setBreakpointsActive", v); 179 Collections.addAll(v, new String[] 180 { "active", }); 181 182 v = new Vector<String>(1); 183 parameterNames.put("setPauseOnExceptions", v); 184 Collections.addAll(v, new String[] 185 { "state", }); 186 187 v = new Vector<String>(1); 188 parameterNames.put("setReturnValue", v); 189 Collections.addAll(v, new String[] 190 { "newValue", }); 191 192 v = new Vector<String>(3); 193 parameterNames.put("setScriptSource", v); 194 Collections.addAll(v, new String[] 195 { "scriptId", "scriptSource", "dryRun", }); 196 197 v = new Vector<String>(1); 198 parameterNames.put("setSkipAllPauses", v); 199 Collections.addAll(v, new String[] 200 { "skip", }); 201 202 v = new Vector<String>(4); 203 parameterNames.put("setVariableValue", v); 204 Collections.addAll(v, new String[] 205 { "scopeNumber", "variableName", "newValue", "callFrameId", }); 206 207 v = new Vector<String>(2); 208 parameterNames.put("stepInto", v); 209 Collections.addAll(v, new String[] 210 { "breakOnAsyncCall", "skipList", }); 211 212 parameterNames.put("stepOut", EMPTY_VEC_STR); 213 214 v = new Vector<String>(1); 215 parameterNames.put("stepOver", v); 216 Collections.addAll(v, new String[] 217 { "skipList", }); 218 } 219 220 221 // ******************************************************************************************** 222 // ******************************************************************************************** 223 // Types - Static Inner Classes 224 // ******************************************************************************************** 225 // ******************************************************************************************** 226 227 // public static class BreakpointId => String 228 229 // public static class CallFrameId => String 230 231 /** Enum of possible script languages. */ 232 public static final String[] ScriptLanguage = 233 { "JavaScript", "WebAssembly", }; 234 235 /** Location in the source code. */ 236 public static class Location 237 extends BaseType 238 implements java.io.Serializable 239 { 240 /** For Object Serialization. java.io.Serializable */ 241 protected static final long serialVersionUID = 1; 242 243 public boolean[] optionals() 244 { return new boolean[] { false, false, true, }; } 245 246 /** Script identifier as reported in the <CODE>Debugger.scriptParsed</CODE>. */ 247 public final String scriptId; 248 249 /** Line number in the script (0-based). */ 250 public final int lineNumber; 251 252 /** 253 * Column number in the script (0-based). 254 * <BR /> 255 * <BR /><B>OPTIONAL</B> 256 */ 257 public final Integer columnNumber; 258 259 /** 260 * Constructor 261 * 262 * @param scriptId Script identifier as reported in the <CODE>Debugger.scriptParsed</CODE>. 263 * 264 * @param lineNumber Line number in the script (0-based). 265 * 266 * @param columnNumber Column number in the script (0-based). 267 * <BR /><B>OPTIONAL</B> 268 */ 269 public Location(String scriptId, int lineNumber, Integer columnNumber) 270 { 271 // Exception-Check(s) to ensure that if any parameters which are not declared as 272 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 273 274 if (scriptId == null) THROWS.throwNPE("scriptId"); 275 276 this.scriptId = scriptId; 277 this.lineNumber = lineNumber; 278 this.columnNumber = columnNumber; 279 } 280 281 /** 282 * JSON Object Constructor 283 * @param jo A Json-Object having data about an instance of {@code 'Location'}. 284 */ 285 public Location (JsonObject jo) 286 { 287 this.scriptId = ReadJSON.getString(jo, "scriptId", false, true); 288 this.lineNumber = ReadPrimJSON.getInt(jo, "lineNumber"); 289 this.columnNumber = ReadBoxedJSON.getInteger(jo, "columnNumber", true); 290 } 291 292 293 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 294 public boolean equals(Object other) 295 { 296 if (this == other) return true; 297 if (other == null) return false; 298 if (other.getClass() != this.getClass()) return false; 299 300 Location o = (Location) other; 301 302 return 303 Objects.equals(this.scriptId, o.scriptId) 304 && (this.lineNumber == o.lineNumber) 305 && Objects.equals(this.columnNumber, o.columnNumber); 306 } 307 308 /** Generates a Hash-Code for {@code 'this'} instance */ 309 public int hashCode() 310 { 311 return 312 Objects.hashCode(this.scriptId) 313 + this.lineNumber 314 + Objects.hashCode(this.columnNumber); 315 } 316 } 317 318 /** 319 * Location in the source code. 320 * <BR /> 321 * <BR /><B>EXPERIMENTAL</B> 322 */ 323 public static class ScriptPosition 324 extends BaseType 325 implements java.io.Serializable 326 { 327 /** For Object Serialization. java.io.Serializable */ 328 protected static final long serialVersionUID = 1; 329 330 public boolean[] optionals() 331 { return new boolean[] { false, false, }; } 332 333 /** <CODE>[No Description Provided by Google]</CODE> */ 334 public final int lineNumber; 335 336 /** <CODE>[No Description Provided by Google]</CODE> */ 337 public final int columnNumber; 338 339 /** 340 * Constructor 341 * 342 * @param lineNumber - 343 * 344 * @param columnNumber - 345 */ 346 public ScriptPosition(int lineNumber, int columnNumber) 347 { 348 this.lineNumber = lineNumber; 349 this.columnNumber = columnNumber; 350 } 351 352 /** 353 * JSON Object Constructor 354 * @param jo A Json-Object having data about an instance of {@code 'ScriptPosition'}. 355 */ 356 public ScriptPosition (JsonObject jo) 357 { 358 this.lineNumber = ReadPrimJSON.getInt(jo, "lineNumber"); 359 this.columnNumber = ReadPrimJSON.getInt(jo, "columnNumber"); 360 } 361 362 363 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 364 public boolean equals(Object other) 365 { 366 if (this == other) return true; 367 if (other == null) return false; 368 if (other.getClass() != this.getClass()) return false; 369 370 ScriptPosition o = (ScriptPosition) other; 371 372 return 373 (this.lineNumber == o.lineNumber) 374 && (this.columnNumber == o.columnNumber); 375 } 376 377 /** Generates a Hash-Code for {@code 'this'} instance */ 378 public int hashCode() 379 { 380 return 381 this.lineNumber 382 + this.columnNumber; 383 } 384 } 385 386 /** 387 * Location range within one script. 388 * <BR /> 389 * <BR /><B>EXPERIMENTAL</B> 390 */ 391 public static class LocationRange 392 extends BaseType 393 implements java.io.Serializable 394 { 395 /** For Object Serialization. java.io.Serializable */ 396 protected static final long serialVersionUID = 1; 397 398 public boolean[] optionals() 399 { return new boolean[] { false, false, false, }; } 400 401 /** <CODE>[No Description Provided by Google]</CODE> */ 402 public final String scriptId; 403 404 /** <CODE>[No Description Provided by Google]</CODE> */ 405 public final Debugger.ScriptPosition start; 406 407 /** <CODE>[No Description Provided by Google]</CODE> */ 408 public final Debugger.ScriptPosition end; 409 410 /** 411 * Constructor 412 * 413 * @param scriptId - 414 * 415 * @param start - 416 * 417 * @param end - 418 */ 419 public LocationRange 420 (String scriptId, Debugger.ScriptPosition start, Debugger.ScriptPosition end) 421 { 422 // Exception-Check(s) to ensure that if any parameters which are not declared as 423 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 424 425 if (scriptId == null) THROWS.throwNPE("scriptId"); 426 if (start == null) THROWS.throwNPE("start"); 427 if (end == null) THROWS.throwNPE("end"); 428 429 this.scriptId = scriptId; 430 this.start = start; 431 this.end = end; 432 } 433 434 /** 435 * JSON Object Constructor 436 * @param jo A Json-Object having data about an instance of {@code 'LocationRange'}. 437 */ 438 public LocationRange (JsonObject jo) 439 { 440 this.scriptId = ReadJSON.getString(jo, "scriptId", false, true); 441 this.start = ReadJSON.getObject(jo, "start", Debugger.ScriptPosition.class, false, true); 442 this.end = ReadJSON.getObject(jo, "end", Debugger.ScriptPosition.class, false, true); 443 } 444 445 446 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 447 public boolean equals(Object other) 448 { 449 if (this == other) return true; 450 if (other == null) return false; 451 if (other.getClass() != this.getClass()) return false; 452 453 LocationRange o = (LocationRange) other; 454 455 return 456 Objects.equals(this.scriptId, o.scriptId) 457 && Objects.equals(this.start, o.start) 458 && Objects.equals(this.end, o.end); 459 } 460 461 /** Generates a Hash-Code for {@code 'this'} instance */ 462 public int hashCode() 463 { 464 return 465 Objects.hashCode(this.scriptId) 466 + this.start.hashCode() 467 + this.end.hashCode(); 468 } 469 } 470 471 /** JavaScript call frame. Array of call frames form the call stack. */ 472 public static class CallFrame 473 extends BaseType 474 implements java.io.Serializable 475 { 476 /** For Object Serialization. java.io.Serializable */ 477 protected static final long serialVersionUID = 1; 478 479 public boolean[] optionals() 480 { return new boolean[] { false, false, true, false, false, false, false, true, }; } 481 482 /** Call frame identifier. This identifier is only valid while the virtual machine is paused. */ 483 public final String callFrameId; 484 485 /** Name of the JavaScript function called on this call frame. */ 486 public final String functionName; 487 488 /** 489 * Location in the source code. 490 * <BR /> 491 * <BR /><B>OPTIONAL</B> 492 */ 493 public final Debugger.Location functionLocation; 494 495 /** Location in the source code. */ 496 public final Debugger.Location location; 497 498 /** JavaScript script name or url. */ 499 public final String url; 500 501 /** Scope chain for this call frame. */ 502 public final Debugger.Scope[] scopeChain; 503 504 /** <CODE>this</CODE> object for this call frame. */ 505 public final RunTime.RemoteObject _this; 506 507 /** 508 * The value being returned, if the function is at return point. 509 * <BR /> 510 * <BR /><B>OPTIONAL</B> 511 */ 512 public final RunTime.RemoteObject returnValue; 513 514 /** 515 * Constructor 516 * 517 * @param callFrameId Call frame identifier. This identifier is only valid while the virtual machine is paused. 518 * 519 * @param functionName Name of the JavaScript function called on this call frame. 520 * 521 * @param functionLocation Location in the source code. 522 * <BR /><B>OPTIONAL</B> 523 * 524 * @param location Location in the source code. 525 * 526 * @param url JavaScript script name or url. 527 * 528 * @param scopeChain Scope chain for this call frame. 529 * 530 * @param _this <CODE>this</CODE> object for this call frame. 531 * 532 * @param returnValue The value being returned, if the function is at return point. 533 * <BR /><B>OPTIONAL</B> 534 */ 535 public CallFrame( 536 String callFrameId, String functionName, Debugger.Location functionLocation, 537 Debugger.Location location, String url, Debugger.Scope[] scopeChain, 538 RunTime.RemoteObject _this, RunTime.RemoteObject returnValue 539 ) 540 { 541 // Exception-Check(s) to ensure that if any parameters which are not declared as 542 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 543 544 if (callFrameId == null) THROWS.throwNPE("callFrameId"); 545 if (functionName == null) THROWS.throwNPE("functionName"); 546 if (location == null) THROWS.throwNPE("location"); 547 if (url == null) THROWS.throwNPE("url"); 548 if (scopeChain == null) THROWS.throwNPE("scopeChain"); 549 if (_this == null) THROWS.throwNPE("_this"); 550 551 this.callFrameId = callFrameId; 552 this.functionName = functionName; 553 this.functionLocation = functionLocation; 554 this.location = location; 555 this.url = url; 556 this.scopeChain = scopeChain; 557 this._this = _this; 558 this.returnValue = returnValue; 559 } 560 561 /** 562 * JSON Object Constructor 563 * @param jo A Json-Object having data about an instance of {@code 'CallFrame'}. 564 */ 565 public CallFrame (JsonObject jo) 566 { 567 this.callFrameId = ReadJSON.getString(jo, "callFrameId", false, true); 568 this.functionName = ReadJSON.getString(jo, "functionName", false, true); 569 this.functionLocation = ReadJSON.getObject(jo, "functionLocation", Debugger.Location.class, true, false); 570 this.location = ReadJSON.getObject(jo, "location", Debugger.Location.class, false, true); 571 this.url = ReadJSON.getString(jo, "url", false, true); 572 this.scopeChain = (jo.getJsonArray("scopeChain") == null) 573 ? null 574 : RJArrIntoStream.objArr(jo.getJsonArray("scopeChain"), null, 0, Debugger.Scope.class).toArray(Debugger.Scope[]::new); 575 576 this._this = ReadJSON.getObject(jo, "this", RunTime.RemoteObject.class, false, true); 577 this.returnValue = ReadJSON.getObject(jo, "returnValue", RunTime.RemoteObject.class, true, false); 578 } 579 580 581 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 582 public boolean equals(Object other) 583 { 584 if (this == other) return true; 585 if (other == null) return false; 586 if (other.getClass() != this.getClass()) return false; 587 588 CallFrame o = (CallFrame) other; 589 590 return 591 Objects.equals(this.callFrameId, o.callFrameId) 592 && Objects.equals(this.functionName, o.functionName) 593 && Objects.equals(this.functionLocation, o.functionLocation) 594 && Objects.equals(this.location, o.location) 595 && Objects.equals(this.url, o.url) 596 && Arrays.deepEquals(this.scopeChain, o.scopeChain) 597 && Objects.equals(this._this, o._this) 598 && Objects.equals(this.returnValue, o.returnValue); 599 } 600 601 /** Generates a Hash-Code for {@code 'this'} instance */ 602 public int hashCode() 603 { 604 return 605 Objects.hashCode(this.callFrameId) 606 + Objects.hashCode(this.functionName) 607 + this.functionLocation.hashCode() 608 + this.location.hashCode() 609 + Objects.hashCode(this.url) 610 + Arrays.deepHashCode(this.scopeChain) 611 + this._this.hashCode() 612 + this.returnValue.hashCode(); 613 } 614 } 615 616 /** Scope description. */ 617 public static class Scope 618 extends BaseType 619 implements java.io.Serializable 620 { 621 /** For Object Serialization. java.io.Serializable */ 622 protected static final long serialVersionUID = 1; 623 624 public boolean[] optionals() 625 { return new boolean[] { false, false, true, true, true, }; } 626 627 /** Scope type. */ 628 public final String type; 629 630 /** 631 * Object representing the scope. For <CODE>global</CODE> and <CODE>with</CODE> scopes it represents the actual 632 * object; for the rest of the scopes, it is artificial transient object enumerating scope 633 * variables as its properties. 634 */ 635 public final RunTime.RemoteObject object; 636 637 /** 638 * <CODE>[No Description Provided by Google]</CODE> 639 * <BR /> 640 * <BR /><B>OPTIONAL</B> 641 */ 642 public final String name; 643 644 /** 645 * Location in the source code where scope starts 646 * <BR /> 647 * <BR /><B>OPTIONAL</B> 648 */ 649 public final Debugger.Location startLocation; 650 651 /** 652 * Location in the source code where scope ends 653 * <BR /> 654 * <BR /><B>OPTIONAL</B> 655 */ 656 public final Debugger.Location endLocation; 657 658 /** 659 * Constructor 660 * 661 * @param type Scope type. 662 * <BR />Acceptable Values: ["global", "local", "with", "closure", "catch", "block", "script", "eval", "module", "wasm-expression-stack"] 663 * 664 * @param object 665 * Object representing the scope. For <CODE>global</CODE> and <CODE>with</CODE> scopes it represents the actual 666 * object; for the rest of the scopes, it is artificial transient object enumerating scope 667 * variables as its properties. 668 * 669 * @param name - 670 * <BR /><B>OPTIONAL</B> 671 * 672 * @param startLocation Location in the source code where scope starts 673 * <BR /><B>OPTIONAL</B> 674 * 675 * @param endLocation Location in the source code where scope ends 676 * <BR /><B>OPTIONAL</B> 677 */ 678 public Scope( 679 String type, RunTime.RemoteObject object, String name, 680 Debugger.Location startLocation, Debugger.Location endLocation 681 ) 682 { 683 // Exception-Check(s) to ensure that if any parameters which are not declared as 684 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 685 686 if (type == null) THROWS.throwNPE("type"); 687 if (object == null) THROWS.throwNPE("object"); 688 689 // Exception-Check(s) to ensure that if any parameters which must adhere to a 690 // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw. 691 692 THROWS.checkIAE( 693 "type", type, 694 "global", "local", "with", "closure", "catch", "block", "script", "eval", "module", "wasm-expression-stack" 695 ); 696 697 this.type = type; 698 this.object = object; 699 this.name = name; 700 this.startLocation = startLocation; 701 this.endLocation = endLocation; 702 } 703 704 /** 705 * JSON Object Constructor 706 * @param jo A Json-Object having data about an instance of {@code 'Scope'}. 707 */ 708 public Scope (JsonObject jo) 709 { 710 this.type = ReadJSON.getString(jo, "type", false, true); 711 this.object = ReadJSON.getObject(jo, "object", RunTime.RemoteObject.class, false, true); 712 this.name = ReadJSON.getString(jo, "name", true, false); 713 this.startLocation = ReadJSON.getObject(jo, "startLocation", Debugger.Location.class, true, false); 714 this.endLocation = ReadJSON.getObject(jo, "endLocation", Debugger.Location.class, true, false); 715 } 716 717 718 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 719 public boolean equals(Object other) 720 { 721 if (this == other) return true; 722 if (other == null) return false; 723 if (other.getClass() != this.getClass()) return false; 724 725 Scope o = (Scope) other; 726 727 return 728 Objects.equals(this.type, o.type) 729 && Objects.equals(this.object, o.object) 730 && Objects.equals(this.name, o.name) 731 && Objects.equals(this.startLocation, o.startLocation) 732 && Objects.equals(this.endLocation, o.endLocation); 733 } 734 735 /** Generates a Hash-Code for {@code 'this'} instance */ 736 public int hashCode() 737 { 738 return 739 Objects.hashCode(this.type) 740 + this.object.hashCode() 741 + Objects.hashCode(this.name) 742 + this.startLocation.hashCode() 743 + this.endLocation.hashCode(); 744 } 745 } 746 747 /** Search match for resource. */ 748 public static class SearchMatch 749 extends BaseType 750 implements java.io.Serializable 751 { 752 /** For Object Serialization. java.io.Serializable */ 753 protected static final long serialVersionUID = 1; 754 755 public boolean[] optionals() 756 { return new boolean[] { false, false, }; } 757 758 /** Line number in resource content. */ 759 public final Number lineNumber; 760 761 /** Line with match content. */ 762 public final String lineContent; 763 764 /** 765 * Constructor 766 * 767 * @param lineNumber Line number in resource content. 768 * 769 * @param lineContent Line with match content. 770 */ 771 public SearchMatch(Number lineNumber, String lineContent) 772 { 773 // Exception-Check(s) to ensure that if any parameters which are not declared as 774 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 775 776 if (lineNumber == null) THROWS.throwNPE("lineNumber"); 777 if (lineContent == null) THROWS.throwNPE("lineContent"); 778 779 this.lineNumber = lineNumber; 780 this.lineContent = lineContent; 781 } 782 783 /** 784 * JSON Object Constructor 785 * @param jo A Json-Object having data about an instance of {@code 'SearchMatch'}. 786 */ 787 public SearchMatch (JsonObject jo) 788 { 789 this.lineNumber = ReadNumberJSON.get(jo, "lineNumber", false, true); 790 this.lineContent = ReadJSON.getString(jo, "lineContent", false, true); 791 } 792 793 794 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 795 public boolean equals(Object other) 796 { 797 if (this == other) return true; 798 if (other == null) return false; 799 if (other.getClass() != this.getClass()) return false; 800 801 SearchMatch o = (SearchMatch) other; 802 803 return 804 Objects.equals(this.lineNumber, o.lineNumber) 805 && Objects.equals(this.lineContent, o.lineContent); 806 } 807 808 /** Generates a Hash-Code for {@code 'this'} instance */ 809 public int hashCode() 810 { 811 return 812 Objects.hashCode(this.lineNumber) 813 + Objects.hashCode(this.lineContent); 814 } 815 } 816 817 /** <CODE>[No Description Provided by Google]</CODE> */ 818 public static class BreakLocation 819 extends BaseType 820 implements java.io.Serializable 821 { 822 /** For Object Serialization. java.io.Serializable */ 823 protected static final long serialVersionUID = 1; 824 825 public boolean[] optionals() 826 { return new boolean[] { false, false, true, true, }; } 827 828 /** Script identifier as reported in the <CODE>Debugger.scriptParsed</CODE>. */ 829 public final String scriptId; 830 831 /** Line number in the script (0-based). */ 832 public final int lineNumber; 833 834 /** 835 * Column number in the script (0-based). 836 * <BR /> 837 * <BR /><B>OPTIONAL</B> 838 */ 839 public final Integer columnNumber; 840 841 /** 842 * <CODE>[No Description Provided by Google]</CODE> 843 * <BR /> 844 * <BR /><B>OPTIONAL</B> 845 */ 846 public final String type; 847 848 /** 849 * Constructor 850 * 851 * @param scriptId Script identifier as reported in the <CODE>Debugger.scriptParsed</CODE>. 852 * 853 * @param lineNumber Line number in the script (0-based). 854 * 855 * @param columnNumber Column number in the script (0-based). 856 * <BR /><B>OPTIONAL</B> 857 * 858 * @param type - 859 * <BR />Acceptable Values: ["debuggerStatement", "call", "return"] 860 * <BR /><B>OPTIONAL</B> 861 */ 862 public BreakLocation(String scriptId, int lineNumber, Integer columnNumber, String type) 863 { 864 // Exception-Check(s) to ensure that if any parameters which are not declared as 865 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 866 867 if (scriptId == null) THROWS.throwNPE("scriptId"); 868 869 // Exception-Check(s) to ensure that if any parameters which must adhere to a 870 // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw. 871 872 THROWS.checkIAE( 873 "type", type, 874 "debuggerStatement", "call", "return" 875 ); 876 877 this.scriptId = scriptId; 878 this.lineNumber = lineNumber; 879 this.columnNumber = columnNumber; 880 this.type = type; 881 } 882 883 /** 884 * JSON Object Constructor 885 * @param jo A Json-Object having data about an instance of {@code 'BreakLocation'}. 886 */ 887 public BreakLocation (JsonObject jo) 888 { 889 this.scriptId = ReadJSON.getString(jo, "scriptId", false, true); 890 this.lineNumber = ReadPrimJSON.getInt(jo, "lineNumber"); 891 this.columnNumber = ReadBoxedJSON.getInteger(jo, "columnNumber", true); 892 this.type = ReadJSON.getString(jo, "type", true, false); 893 } 894 895 896 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 897 public boolean equals(Object other) 898 { 899 if (this == other) return true; 900 if (other == null) return false; 901 if (other.getClass() != this.getClass()) return false; 902 903 BreakLocation o = (BreakLocation) other; 904 905 return 906 Objects.equals(this.scriptId, o.scriptId) 907 && (this.lineNumber == o.lineNumber) 908 && Objects.equals(this.columnNumber, o.columnNumber) 909 && Objects.equals(this.type, o.type); 910 } 911 912 /** Generates a Hash-Code for {@code 'this'} instance */ 913 public int hashCode() 914 { 915 return 916 Objects.hashCode(this.scriptId) 917 + this.lineNumber 918 + Objects.hashCode(this.columnNumber) 919 + Objects.hashCode(this.type); 920 } 921 } 922 923 /** Debug symbols available for a wasm script. */ 924 public static class DebugSymbols 925 extends BaseType 926 implements java.io.Serializable 927 { 928 /** For Object Serialization. java.io.Serializable */ 929 protected static final long serialVersionUID = 1; 930 931 public boolean[] optionals() 932 { return new boolean[] { false, true, }; } 933 934 /** Type of the debug symbols. */ 935 public final String type; 936 937 /** 938 * URL of the external symbol source. 939 * <BR /> 940 * <BR /><B>OPTIONAL</B> 941 */ 942 public final String externalURL; 943 944 /** 945 * Constructor 946 * 947 * @param type Type of the debug symbols. 948 * <BR />Acceptable Values: ["None", "SourceMap", "EmbeddedDWARF", "ExternalDWARF"] 949 * 950 * @param externalURL URL of the external symbol source. 951 * <BR /><B>OPTIONAL</B> 952 */ 953 public DebugSymbols(String type, String externalURL) 954 { 955 // Exception-Check(s) to ensure that if any parameters which are not declared as 956 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 957 958 if (type == null) THROWS.throwNPE("type"); 959 960 // Exception-Check(s) to ensure that if any parameters which must adhere to a 961 // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw. 962 963 THROWS.checkIAE( 964 "type", type, 965 "None", "SourceMap", "EmbeddedDWARF", "ExternalDWARF" 966 ); 967 968 this.type = type; 969 this.externalURL = externalURL; 970 } 971 972 /** 973 * JSON Object Constructor 974 * @param jo A Json-Object having data about an instance of {@code 'DebugSymbols'}. 975 */ 976 public DebugSymbols (JsonObject jo) 977 { 978 this.type = ReadJSON.getString(jo, "type", false, true); 979 this.externalURL = ReadJSON.getString(jo, "externalURL", true, false); 980 } 981 982 983 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 984 public boolean equals(Object other) 985 { 986 if (this == other) return true; 987 if (other == null) return false; 988 if (other.getClass() != this.getClass()) return false; 989 990 DebugSymbols o = (DebugSymbols) other; 991 992 return 993 Objects.equals(this.type, o.type) 994 && Objects.equals(this.externalURL, o.externalURL); 995 } 996 997 /** Generates a Hash-Code for {@code 'this'} instance */ 998 public int hashCode() 999 { 1000 return 1001 Objects.hashCode(this.type) 1002 + Objects.hashCode(this.externalURL); 1003 } 1004 } 1005 1006 /** 1007 * Fired when the virtual machine resumed execution. 1008 * 1009 * <BR /><BR />This is Marker-Event. Marker-Event's are Events that do not posses 1010 * any data, fields or state. When they are fired, only the event name is supplied. 1011 */ 1012 public static class resumed 1013 extends BrowserEvent 1014 implements java.io.Serializable 1015 { 1016 /** For Object Serialization. java.io.Serializable */ 1017 protected static final long serialVersionUID = 1; 1018 1019 public boolean[] optionals() { return new boolean[0]; } 1020 1021 /** JSON Object Constructor */ 1022 public resumed(JsonObject jo) 1023 { super("Debugger", "resumed", 0); } 1024 1025 @Override 1026 public String toString() { return "Debugger.resumed Marker Event\n"; } 1027 } 1028 1029 /** Fired when breakpoint is resolved to an actual script and location. */ 1030 public static class breakpointResolved 1031 extends BrowserEvent 1032 implements java.io.Serializable 1033 { 1034 /** For Object Serialization. java.io.Serializable */ 1035 protected static final long serialVersionUID = 1; 1036 1037 public boolean[] optionals() 1038 { return new boolean[] { false, false, }; } 1039 1040 /** Breakpoint unique identifier. */ 1041 public final String breakpointId; 1042 1043 /** Actual breakpoint location. */ 1044 public final Debugger.Location location; 1045 1046 /** 1047 * Constructor 1048 * 1049 * @param breakpointId Breakpoint unique identifier. 1050 * 1051 * @param location Actual breakpoint location. 1052 */ 1053 public breakpointResolved(String breakpointId, Debugger.Location location) 1054 { 1055 super("Debugger", "breakpointResolved", 2); 1056 1057 // Exception-Check(s) to ensure that if any parameters which are not declared as 1058 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 1059 1060 if (breakpointId == null) THROWS.throwNPE("breakpointId"); 1061 if (location == null) THROWS.throwNPE("location"); 1062 1063 this.breakpointId = breakpointId; 1064 this.location = location; 1065 } 1066 1067 /** 1068 * JSON Object Constructor 1069 * @param jo A Json-Object having data about an instance of {@code 'breakpointResolved'}. 1070 */ 1071 public breakpointResolved (JsonObject jo) 1072 { 1073 super("Debugger", "breakpointResolved", 2); 1074 1075 this.breakpointId = ReadJSON.getString(jo, "breakpointId", false, true); 1076 this.location = ReadJSON.getObject(jo, "location", Debugger.Location.class, false, true); 1077 } 1078 1079 1080 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 1081 public boolean equals(Object other) 1082 { 1083 if (this == other) return true; 1084 if (other == null) return false; 1085 if (other.getClass() != this.getClass()) return false; 1086 1087 breakpointResolved o = (breakpointResolved) other; 1088 1089 return 1090 Objects.equals(this.breakpointId, o.breakpointId) 1091 && Objects.equals(this.location, o.location); 1092 } 1093 1094 /** Generates a Hash-Code for {@code 'this'} instance */ 1095 public int hashCode() 1096 { 1097 return 1098 Objects.hashCode(this.breakpointId) 1099 + this.location.hashCode(); 1100 } 1101 } 1102 1103 /** Fired when the virtual machine stopped on breakpoint or exception or any other stop criteria. */ 1104 public static class paused 1105 extends BrowserEvent 1106 implements java.io.Serializable 1107 { 1108 /** For Object Serialization. java.io.Serializable */ 1109 protected static final long serialVersionUID = 1; 1110 1111 public boolean[] optionals() 1112 { return new boolean[] { false, false, true, true, true, true, true, }; } 1113 1114 /** Call stack the virtual machine stopped on. */ 1115 public final Debugger.CallFrame[] callFrames; 1116 1117 /** Pause reason. */ 1118 public final String reason; 1119 1120 /** 1121 * Object containing break-specific auxiliary properties. 1122 * <BR /> 1123 * <BR /><B>OPTIONAL</B> 1124 */ 1125 public final JsonObject data; 1126 1127 /** 1128 * Hit breakpoints IDs 1129 * <BR /> 1130 * <BR /><B>OPTIONAL</B> 1131 */ 1132 public final String[] hitBreakpoints; 1133 1134 /** 1135 * Async stack trace, if any. 1136 * <BR /> 1137 * <BR /><B>OPTIONAL</B> 1138 */ 1139 public final RunTime.StackTrace asyncStackTrace; 1140 1141 /** 1142 * Async stack trace, if any. 1143 * <BR /> 1144 * <BR /><B>OPTIONAL</B> 1145 * <BR /><B>EXPERIMENTAL</B> 1146 */ 1147 public final RunTime.StackTraceId asyncStackTraceId; 1148 1149 /** 1150 * Never present, will be removed. 1151 * <BR /> 1152 * <BR /><B>OPTIONAL</B> 1153 * <BR /><B>EXPERIMENTAL</B> 1154 * <BR /><B>DEPRECATED</B> 1155 */ 1156 public final RunTime.StackTraceId asyncCallStackTraceId; 1157 1158 /** 1159 * Constructor 1160 * 1161 * @param callFrames Call stack the virtual machine stopped on. 1162 * 1163 * @param reason Pause reason. 1164 * <BR />Acceptable Values: ["ambiguous", "assert", "CSPViolation", "debugCommand", "DOM", "EventListener", "exception", "instrumentation", "OOM", "other", "promiseRejection", "XHR"] 1165 * 1166 * @param data Object containing break-specific auxiliary properties. 1167 * <BR /><B>OPTIONAL</B> 1168 * 1169 * @param hitBreakpoints Hit breakpoints IDs 1170 * <BR /><B>OPTIONAL</B> 1171 * 1172 * @param asyncStackTrace Async stack trace, if any. 1173 * <BR /><B>OPTIONAL</B> 1174 * 1175 * @param asyncStackTraceId Async stack trace, if any. 1176 * <BR /><B>OPTIONAL</B> 1177 * <BR /><B>EXPERIMENTAL</B> 1178 * 1179 * @param asyncCallStackTraceId Never present, will be removed. 1180 * <BR /><B>OPTIONAL</B> 1181 * <BR /><B>EXPERIMENTAL</B> 1182 * <BR /><B>DEPRECATED</B> 1183 */ 1184 public paused( 1185 Debugger.CallFrame[] callFrames, String reason, JsonObject data, 1186 String[] hitBreakpoints, RunTime.StackTrace asyncStackTrace, 1187 RunTime.StackTraceId asyncStackTraceId, RunTime.StackTraceId asyncCallStackTraceId 1188 ) 1189 { 1190 super("Debugger", "paused", 7); 1191 1192 // Exception-Check(s) to ensure that if any parameters which are not declared as 1193 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 1194 1195 if (callFrames == null) THROWS.throwNPE("callFrames"); 1196 if (reason == null) THROWS.throwNPE("reason"); 1197 1198 // Exception-Check(s) to ensure that if any parameters which must adhere to a 1199 // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw. 1200 1201 THROWS.checkIAE( 1202 "reason", reason, 1203 "ambiguous", "assert", "CSPViolation", "debugCommand", "DOM", "EventListener", "exception", "instrumentation", "OOM", "other", "promiseRejection", "XHR" 1204 ); 1205 1206 this.callFrames = callFrames; 1207 this.reason = reason; 1208 this.data = data; 1209 this.hitBreakpoints = hitBreakpoints; 1210 this.asyncStackTrace = asyncStackTrace; 1211 this.asyncStackTraceId = asyncStackTraceId; 1212 this.asyncCallStackTraceId = asyncCallStackTraceId; 1213 } 1214 1215 /** 1216 * JSON Object Constructor 1217 * @param jo A Json-Object having data about an instance of {@code 'paused'}. 1218 */ 1219 public paused (JsonObject jo) 1220 { 1221 super("Debugger", "paused", 7); 1222 1223 this.callFrames = (jo.getJsonArray("callFrames") == null) 1224 ? null 1225 : RJArrIntoStream.objArr(jo.getJsonArray("callFrames"), null, 0, Debugger.CallFrame.class).toArray(Debugger.CallFrame[]::new); 1226 1227 this.reason = ReadJSON.getString(jo, "reason", false, true); 1228 this.data = jo.getJsonObject("data"); 1229 this.hitBreakpoints = (jo.getJsonArray("hitBreakpoints") == null) 1230 ? null 1231 : RJArrIntoStream.strArr(jo.getJsonArray("hitBreakpoints"), null, 0).toArray(String[]::new); 1232 1233 this.asyncStackTrace = ReadJSON.getObject(jo, "asyncStackTrace", RunTime.StackTrace.class, true, false); 1234 this.asyncStackTraceId = ReadJSON.getObject(jo, "asyncStackTraceId", RunTime.StackTraceId.class, true, false); 1235 this.asyncCallStackTraceId = ReadJSON.getObject(jo, "asyncCallStackTraceId", RunTime.StackTraceId.class, true, false); 1236 } 1237 1238 1239 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 1240 public boolean equals(Object other) 1241 { 1242 if (this == other) return true; 1243 if (other == null) return false; 1244 if (other.getClass() != this.getClass()) return false; 1245 1246 paused o = (paused) other; 1247 1248 return 1249 Arrays.deepEquals(this.callFrames, o.callFrames) 1250 && Objects.equals(this.reason, o.reason) 1251 && Objects.equals(this.data, o.data) 1252 && Arrays.deepEquals(this.hitBreakpoints, o.hitBreakpoints) 1253 && Objects.equals(this.asyncStackTrace, o.asyncStackTrace) 1254 && Objects.equals(this.asyncStackTraceId, o.asyncStackTraceId) 1255 && Objects.equals(this.asyncCallStackTraceId, o.asyncCallStackTraceId); 1256 } 1257 1258 /** Generates a Hash-Code for {@code 'this'} instance */ 1259 public int hashCode() 1260 { 1261 return 1262 Arrays.deepHashCode(this.callFrames) 1263 + Objects.hashCode(this.reason) 1264 + Objects.hashCode(this.data) 1265 + Arrays.deepHashCode(this.hitBreakpoints) 1266 + this.asyncStackTrace.hashCode() 1267 + this.asyncStackTraceId.hashCode() 1268 + this.asyncCallStackTraceId.hashCode(); 1269 } 1270 } 1271 1272 /** Fired when virtual machine fails to parse the script. */ 1273 public static class scriptFailedToParse 1274 extends BrowserEvent 1275 implements java.io.Serializable 1276 { 1277 /** For Object Serialization. java.io.Serializable */ 1278 protected static final long serialVersionUID = 1; 1279 1280 public boolean[] optionals() 1281 { return new boolean[] { false, false, false, false, false, false, false, false, true, true, true, true, true, true, true, true, true, }; } 1282 1283 /** Identifier of the script parsed. */ 1284 public final String scriptId; 1285 1286 /** URL or name of the script parsed (if any). */ 1287 public final String url; 1288 1289 /** Line offset of the script within the resource with given URL (for script tags). */ 1290 public final int startLine; 1291 1292 /** Column offset of the script within the resource with given URL. */ 1293 public final int startColumn; 1294 1295 /** Last line of the script. */ 1296 public final int endLine; 1297 1298 /** Length of the last line of the script. */ 1299 public final int endColumn; 1300 1301 /** Specifies script creation context. */ 1302 public final int executionContextId; 1303 1304 /** Content hash of the script. */ 1305 public final String hash; 1306 1307 /** 1308 * Embedder-specific auxiliary data. 1309 * <BR /> 1310 * <BR /><B>OPTIONAL</B> 1311 */ 1312 public final JsonObject executionContextAuxData; 1313 1314 /** 1315 * URL of source map associated with script (if any). 1316 * <BR /> 1317 * <BR /><B>OPTIONAL</B> 1318 */ 1319 public final String sourceMapURL; 1320 1321 /** 1322 * True, if this script has sourceURL. 1323 * <BR /> 1324 * <BR /><B>OPTIONAL</B> 1325 */ 1326 public final Boolean hasSourceURL; 1327 1328 /** 1329 * True, if this script is ES6 module. 1330 * <BR /> 1331 * <BR /><B>OPTIONAL</B> 1332 */ 1333 public final Boolean isModule; 1334 1335 /** 1336 * This script length. 1337 * <BR /> 1338 * <BR /><B>OPTIONAL</B> 1339 */ 1340 public final Integer length; 1341 1342 /** 1343 * JavaScript top stack frame of where the script parsed event was triggered if available. 1344 * <BR /> 1345 * <BR /><B>OPTIONAL</B> 1346 * <BR /><B>EXPERIMENTAL</B> 1347 */ 1348 public final RunTime.StackTrace stackTrace; 1349 1350 /** 1351 * If the scriptLanguage is WebAssembly, the code section offset in the module. 1352 * <BR /> 1353 * <BR /><B>OPTIONAL</B> 1354 * <BR /><B>EXPERIMENTAL</B> 1355 */ 1356 public final Integer codeOffset; 1357 1358 /** 1359 * The language of the script. 1360 * <BR /> 1361 * <BR /><B>OPTIONAL</B> 1362 * <BR /><B>EXPERIMENTAL</B> 1363 */ 1364 public final String scriptLanguage; 1365 1366 /** 1367 * The name the embedder supplied for this script. 1368 * <BR /> 1369 * <BR /><B>OPTIONAL</B> 1370 * <BR /><B>EXPERIMENTAL</B> 1371 */ 1372 public final String embedderName; 1373 1374 /** 1375 * Constructor 1376 * 1377 * @param scriptId Identifier of the script parsed. 1378 * 1379 * @param url URL or name of the script parsed (if any). 1380 * 1381 * @param startLine Line offset of the script within the resource with given URL (for script tags). 1382 * 1383 * @param startColumn Column offset of the script within the resource with given URL. 1384 * 1385 * @param endLine Last line of the script. 1386 * 1387 * @param endColumn Length of the last line of the script. 1388 * 1389 * @param executionContextId Specifies script creation context. 1390 * 1391 * @param hash Content hash of the script. 1392 * 1393 * @param executionContextAuxData Embedder-specific auxiliary data. 1394 * <BR /><B>OPTIONAL</B> 1395 * 1396 * @param sourceMapURL URL of source map associated with script (if any). 1397 * <BR /><B>OPTIONAL</B> 1398 * 1399 * @param hasSourceURL True, if this script has sourceURL. 1400 * <BR /><B>OPTIONAL</B> 1401 * 1402 * @param isModule True, if this script is ES6 module. 1403 * <BR /><B>OPTIONAL</B> 1404 * 1405 * @param length This script length. 1406 * <BR /><B>OPTIONAL</B> 1407 * 1408 * @param stackTrace JavaScript top stack frame of where the script parsed event was triggered if available. 1409 * <BR /><B>OPTIONAL</B> 1410 * <BR /><B>EXPERIMENTAL</B> 1411 * 1412 * @param codeOffset If the scriptLanguage is WebAssembly, the code section offset in the module. 1413 * <BR /><B>OPTIONAL</B> 1414 * <BR /><B>EXPERIMENTAL</B> 1415 * 1416 * @param scriptLanguage The language of the script. 1417 * <BR /><B>OPTIONAL</B> 1418 * <BR /><B>EXPERIMENTAL</B> 1419 * 1420 * @param embedderName The name the embedder supplied for this script. 1421 * <BR /><B>OPTIONAL</B> 1422 * <BR /><B>EXPERIMENTAL</B> 1423 */ 1424 public scriptFailedToParse( 1425 String scriptId, String url, int startLine, int startColumn, int endLine, 1426 int endColumn, int executionContextId, String hash, 1427 JsonObject executionContextAuxData, String sourceMapURL, Boolean hasSourceURL, 1428 Boolean isModule, Integer length, RunTime.StackTrace stackTrace, Integer codeOffset, 1429 String scriptLanguage, String embedderName 1430 ) 1431 { 1432 super("Debugger", "scriptFailedToParse", 17); 1433 1434 // Exception-Check(s) to ensure that if any parameters which are not declared as 1435 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 1436 1437 if (scriptId == null) THROWS.throwNPE("scriptId"); 1438 if (url == null) THROWS.throwNPE("url"); 1439 if (hash == null) THROWS.throwNPE("hash"); 1440 1441 // Exception-Check(s) to ensure that if any parameters which must adhere to a 1442 // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw. 1443 1444 THROWS.checkIAE("scriptLanguage", scriptLanguage, "Debugger.ScriptLanguage", Debugger.ScriptLanguage); 1445 1446 this.scriptId = scriptId; 1447 this.url = url; 1448 this.startLine = startLine; 1449 this.startColumn = startColumn; 1450 this.endLine = endLine; 1451 this.endColumn = endColumn; 1452 this.executionContextId = executionContextId; 1453 this.hash = hash; 1454 this.executionContextAuxData = executionContextAuxData; 1455 this.sourceMapURL = sourceMapURL; 1456 this.hasSourceURL = hasSourceURL; 1457 this.isModule = isModule; 1458 this.length = length; 1459 this.stackTrace = stackTrace; 1460 this.codeOffset = codeOffset; 1461 this.scriptLanguage = scriptLanguage; 1462 this.embedderName = embedderName; 1463 } 1464 1465 /** 1466 * JSON Object Constructor 1467 * @param jo A Json-Object having data about an instance of {@code 'scriptFailedToParse'}. 1468 */ 1469 public scriptFailedToParse (JsonObject jo) 1470 { 1471 super("Debugger", "scriptFailedToParse", 17); 1472 1473 this.scriptId = ReadJSON.getString(jo, "scriptId", false, true); 1474 this.url = ReadJSON.getString(jo, "url", false, true); 1475 this.startLine = ReadPrimJSON.getInt(jo, "startLine"); 1476 this.startColumn = ReadPrimJSON.getInt(jo, "startColumn"); 1477 this.endLine = ReadPrimJSON.getInt(jo, "endLine"); 1478 this.endColumn = ReadPrimJSON.getInt(jo, "endColumn"); 1479 this.executionContextId = ReadPrimJSON.getInt(jo, "executionContextId"); 1480 this.hash = ReadJSON.getString(jo, "hash", false, true); 1481 this.executionContextAuxData = jo.getJsonObject("executionContextAuxData"); 1482 this.sourceMapURL = ReadJSON.getString(jo, "sourceMapURL", true, false); 1483 this.hasSourceURL = ReadBoxedJSON.getBoolean(jo, "hasSourceURL", true); 1484 this.isModule = ReadBoxedJSON.getBoolean(jo, "isModule", true); 1485 this.length = ReadBoxedJSON.getInteger(jo, "length", true); 1486 this.stackTrace = ReadJSON.getObject(jo, "stackTrace", RunTime.StackTrace.class, true, false); 1487 this.codeOffset = ReadBoxedJSON.getInteger(jo, "codeOffset", true); 1488 this.scriptLanguage = ReadJSON.getString(jo, "scriptLanguage", true, false); 1489 this.embedderName = ReadJSON.getString(jo, "embedderName", true, false); 1490 } 1491 1492 1493 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 1494 public boolean equals(Object other) 1495 { 1496 if (this == other) return true; 1497 if (other == null) return false; 1498 if (other.getClass() != this.getClass()) return false; 1499 1500 scriptFailedToParse o = (scriptFailedToParse) other; 1501 1502 return 1503 Objects.equals(this.scriptId, o.scriptId) 1504 && Objects.equals(this.url, o.url) 1505 && (this.startLine == o.startLine) 1506 && (this.startColumn == o.startColumn) 1507 && (this.endLine == o.endLine) 1508 && (this.endColumn == o.endColumn) 1509 && Objects.equals(this.executionContextId, o.executionContextId) 1510 && Objects.equals(this.hash, o.hash) 1511 && Objects.equals(this.executionContextAuxData, o.executionContextAuxData) 1512 && Objects.equals(this.sourceMapURL, o.sourceMapURL) 1513 && Objects.equals(this.hasSourceURL, o.hasSourceURL) 1514 && Objects.equals(this.isModule, o.isModule) 1515 && Objects.equals(this.length, o.length) 1516 && Objects.equals(this.stackTrace, o.stackTrace) 1517 && Objects.equals(this.codeOffset, o.codeOffset) 1518 && Objects.equals(this.scriptLanguage, o.scriptLanguage) 1519 && Objects.equals(this.embedderName, o.embedderName); 1520 } 1521 1522 /** Generates a Hash-Code for {@code 'this'} instance */ 1523 public int hashCode() 1524 { 1525 return 1526 Objects.hashCode(this.scriptId) 1527 + Objects.hashCode(this.url) 1528 + this.startLine 1529 + this.startColumn 1530 + this.endLine 1531 + this.endColumn 1532 + this.executionContextId 1533 + Objects.hashCode(this.hash) 1534 + Objects.hashCode(this.executionContextAuxData) 1535 + Objects.hashCode(this.sourceMapURL) 1536 + Objects.hashCode(this.hasSourceURL) 1537 + Objects.hashCode(this.isModule) 1538 + Objects.hashCode(this.length) 1539 + this.stackTrace.hashCode() 1540 + Objects.hashCode(this.codeOffset) 1541 + Objects.hashCode(this.scriptLanguage) 1542 + Objects.hashCode(this.embedderName); 1543 } 1544 } 1545 1546 /** 1547 * Fired when virtual machine parses script. This event is also fired for all known and uncollected 1548 * scripts upon enabling debugger. 1549 */ 1550 public static class scriptParsed 1551 extends BrowserEvent 1552 implements java.io.Serializable 1553 { 1554 /** For Object Serialization. java.io.Serializable */ 1555 protected static final long serialVersionUID = 1; 1556 1557 public boolean[] optionals() 1558 { return new boolean[] { false, false, false, false, false, false, false, false, true, true, true, true, true, true, true, true, true, true, true, }; } 1559 1560 /** Identifier of the script parsed. */ 1561 public final String scriptId; 1562 1563 /** URL or name of the script parsed (if any). */ 1564 public final String url; 1565 1566 /** Line offset of the script within the resource with given URL (for script tags). */ 1567 public final int startLine; 1568 1569 /** Column offset of the script within the resource with given URL. */ 1570 public final int startColumn; 1571 1572 /** Last line of the script. */ 1573 public final int endLine; 1574 1575 /** Length of the last line of the script. */ 1576 public final int endColumn; 1577 1578 /** Specifies script creation context. */ 1579 public final int executionContextId; 1580 1581 /** Content hash of the script. */ 1582 public final String hash; 1583 1584 /** 1585 * Embedder-specific auxiliary data. 1586 * <BR /> 1587 * <BR /><B>OPTIONAL</B> 1588 */ 1589 public final JsonObject executionContextAuxData; 1590 1591 /** 1592 * True, if this script is generated as a result of the live edit operation. 1593 * <BR /> 1594 * <BR /><B>OPTIONAL</B> 1595 * <BR /><B>EXPERIMENTAL</B> 1596 */ 1597 public final Boolean isLiveEdit; 1598 1599 /** 1600 * URL of source map associated with script (if any). 1601 * <BR /> 1602 * <BR /><B>OPTIONAL</B> 1603 */ 1604 public final String sourceMapURL; 1605 1606 /** 1607 * True, if this script has sourceURL. 1608 * <BR /> 1609 * <BR /><B>OPTIONAL</B> 1610 */ 1611 public final Boolean hasSourceURL; 1612 1613 /** 1614 * True, if this script is ES6 module. 1615 * <BR /> 1616 * <BR /><B>OPTIONAL</B> 1617 */ 1618 public final Boolean isModule; 1619 1620 /** 1621 * This script length. 1622 * <BR /> 1623 * <BR /><B>OPTIONAL</B> 1624 */ 1625 public final Integer length; 1626 1627 /** 1628 * JavaScript top stack frame of where the script parsed event was triggered if available. 1629 * <BR /> 1630 * <BR /><B>OPTIONAL</B> 1631 * <BR /><B>EXPERIMENTAL</B> 1632 */ 1633 public final RunTime.StackTrace stackTrace; 1634 1635 /** 1636 * If the scriptLanguage is WebAssembly, the code section offset in the module. 1637 * <BR /> 1638 * <BR /><B>OPTIONAL</B> 1639 * <BR /><B>EXPERIMENTAL</B> 1640 */ 1641 public final Integer codeOffset; 1642 1643 /** 1644 * The language of the script. 1645 * <BR /> 1646 * <BR /><B>OPTIONAL</B> 1647 * <BR /><B>EXPERIMENTAL</B> 1648 */ 1649 public final String scriptLanguage; 1650 1651 /** 1652 * If the scriptLanguage is WebASsembly, the source of debug symbols for the module. 1653 * <BR /> 1654 * <BR /><B>OPTIONAL</B> 1655 * <BR /><B>EXPERIMENTAL</B> 1656 */ 1657 public final Debugger.DebugSymbols debugSymbols; 1658 1659 /** 1660 * The name the embedder supplied for this script. 1661 * <BR /> 1662 * <BR /><B>OPTIONAL</B> 1663 * <BR /><B>EXPERIMENTAL</B> 1664 */ 1665 public final String embedderName; 1666 1667 /** 1668 * Constructor 1669 * 1670 * @param scriptId Identifier of the script parsed. 1671 * 1672 * @param url URL or name of the script parsed (if any). 1673 * 1674 * @param startLine Line offset of the script within the resource with given URL (for script tags). 1675 * 1676 * @param startColumn Column offset of the script within the resource with given URL. 1677 * 1678 * @param endLine Last line of the script. 1679 * 1680 * @param endColumn Length of the last line of the script. 1681 * 1682 * @param executionContextId Specifies script creation context. 1683 * 1684 * @param hash Content hash of the script. 1685 * 1686 * @param executionContextAuxData Embedder-specific auxiliary data. 1687 * <BR /><B>OPTIONAL</B> 1688 * 1689 * @param isLiveEdit True, if this script is generated as a result of the live edit operation. 1690 * <BR /><B>OPTIONAL</B> 1691 * <BR /><B>EXPERIMENTAL</B> 1692 * 1693 * @param sourceMapURL URL of source map associated with script (if any). 1694 * <BR /><B>OPTIONAL</B> 1695 * 1696 * @param hasSourceURL True, if this script has sourceURL. 1697 * <BR /><B>OPTIONAL</B> 1698 * 1699 * @param isModule True, if this script is ES6 module. 1700 * <BR /><B>OPTIONAL</B> 1701 * 1702 * @param length This script length. 1703 * <BR /><B>OPTIONAL</B> 1704 * 1705 * @param stackTrace JavaScript top stack frame of where the script parsed event was triggered if available. 1706 * <BR /><B>OPTIONAL</B> 1707 * <BR /><B>EXPERIMENTAL</B> 1708 * 1709 * @param codeOffset If the scriptLanguage is WebAssembly, the code section offset in the module. 1710 * <BR /><B>OPTIONAL</B> 1711 * <BR /><B>EXPERIMENTAL</B> 1712 * 1713 * @param scriptLanguage The language of the script. 1714 * <BR /><B>OPTIONAL</B> 1715 * <BR /><B>EXPERIMENTAL</B> 1716 * 1717 * @param debugSymbols If the scriptLanguage is WebASsembly, the source of debug symbols for the module. 1718 * <BR /><B>OPTIONAL</B> 1719 * <BR /><B>EXPERIMENTAL</B> 1720 * 1721 * @param embedderName The name the embedder supplied for this script. 1722 * <BR /><B>OPTIONAL</B> 1723 * <BR /><B>EXPERIMENTAL</B> 1724 */ 1725 public scriptParsed( 1726 String scriptId, String url, int startLine, int startColumn, int endLine, 1727 int endColumn, int executionContextId, String hash, 1728 JsonObject executionContextAuxData, Boolean isLiveEdit, String sourceMapURL, 1729 Boolean hasSourceURL, Boolean isModule, Integer length, 1730 RunTime.StackTrace stackTrace, Integer codeOffset, String scriptLanguage, 1731 Debugger.DebugSymbols debugSymbols, String embedderName 1732 ) 1733 { 1734 super("Debugger", "scriptParsed", 19); 1735 1736 // Exception-Check(s) to ensure that if any parameters which are not declared as 1737 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 1738 1739 if (scriptId == null) THROWS.throwNPE("scriptId"); 1740 if (url == null) THROWS.throwNPE("url"); 1741 if (hash == null) THROWS.throwNPE("hash"); 1742 1743 // Exception-Check(s) to ensure that if any parameters which must adhere to a 1744 // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw. 1745 1746 THROWS.checkIAE("scriptLanguage", scriptLanguage, "Debugger.ScriptLanguage", Debugger.ScriptLanguage); 1747 1748 this.scriptId = scriptId; 1749 this.url = url; 1750 this.startLine = startLine; 1751 this.startColumn = startColumn; 1752 this.endLine = endLine; 1753 this.endColumn = endColumn; 1754 this.executionContextId = executionContextId; 1755 this.hash = hash; 1756 this.executionContextAuxData = executionContextAuxData; 1757 this.isLiveEdit = isLiveEdit; 1758 this.sourceMapURL = sourceMapURL; 1759 this.hasSourceURL = hasSourceURL; 1760 this.isModule = isModule; 1761 this.length = length; 1762 this.stackTrace = stackTrace; 1763 this.codeOffset = codeOffset; 1764 this.scriptLanguage = scriptLanguage; 1765 this.debugSymbols = debugSymbols; 1766 this.embedderName = embedderName; 1767 } 1768 1769 /** 1770 * JSON Object Constructor 1771 * @param jo A Json-Object having data about an instance of {@code 'scriptParsed'}. 1772 */ 1773 public scriptParsed (JsonObject jo) 1774 { 1775 super("Debugger", "scriptParsed", 19); 1776 1777 this.scriptId = ReadJSON.getString(jo, "scriptId", false, true); 1778 this.url = ReadJSON.getString(jo, "url", false, true); 1779 this.startLine = ReadPrimJSON.getInt(jo, "startLine"); 1780 this.startColumn = ReadPrimJSON.getInt(jo, "startColumn"); 1781 this.endLine = ReadPrimJSON.getInt(jo, "endLine"); 1782 this.endColumn = ReadPrimJSON.getInt(jo, "endColumn"); 1783 this.executionContextId = ReadPrimJSON.getInt(jo, "executionContextId"); 1784 this.hash = ReadJSON.getString(jo, "hash", false, true); 1785 this.executionContextAuxData = jo.getJsonObject("executionContextAuxData"); 1786 this.isLiveEdit = ReadBoxedJSON.getBoolean(jo, "isLiveEdit", true); 1787 this.sourceMapURL = ReadJSON.getString(jo, "sourceMapURL", true, false); 1788 this.hasSourceURL = ReadBoxedJSON.getBoolean(jo, "hasSourceURL", true); 1789 this.isModule = ReadBoxedJSON.getBoolean(jo, "isModule", true); 1790 this.length = ReadBoxedJSON.getInteger(jo, "length", true); 1791 this.stackTrace = ReadJSON.getObject(jo, "stackTrace", RunTime.StackTrace.class, true, false); 1792 this.codeOffset = ReadBoxedJSON.getInteger(jo, "codeOffset", true); 1793 this.scriptLanguage = ReadJSON.getString(jo, "scriptLanguage", true, false); 1794 this.debugSymbols = ReadJSON.getObject(jo, "debugSymbols", Debugger.DebugSymbols.class, true, false); 1795 this.embedderName = ReadJSON.getString(jo, "embedderName", true, false); 1796 } 1797 1798 1799 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 1800 public boolean equals(Object other) 1801 { 1802 if (this == other) return true; 1803 if (other == null) return false; 1804 if (other.getClass() != this.getClass()) return false; 1805 1806 scriptParsed o = (scriptParsed) other; 1807 1808 return 1809 Objects.equals(this.scriptId, o.scriptId) 1810 && Objects.equals(this.url, o.url) 1811 && (this.startLine == o.startLine) 1812 && (this.startColumn == o.startColumn) 1813 && (this.endLine == o.endLine) 1814 && (this.endColumn == o.endColumn) 1815 && Objects.equals(this.executionContextId, o.executionContextId) 1816 && Objects.equals(this.hash, o.hash) 1817 && Objects.equals(this.executionContextAuxData, o.executionContextAuxData) 1818 && Objects.equals(this.isLiveEdit, o.isLiveEdit) 1819 && Objects.equals(this.sourceMapURL, o.sourceMapURL) 1820 && Objects.equals(this.hasSourceURL, o.hasSourceURL) 1821 && Objects.equals(this.isModule, o.isModule) 1822 && Objects.equals(this.length, o.length) 1823 && Objects.equals(this.stackTrace, o.stackTrace) 1824 && Objects.equals(this.codeOffset, o.codeOffset) 1825 && Objects.equals(this.scriptLanguage, o.scriptLanguage) 1826 && Objects.equals(this.debugSymbols, o.debugSymbols) 1827 && Objects.equals(this.embedderName, o.embedderName); 1828 } 1829 1830 /** Generates a Hash-Code for {@code 'this'} instance */ 1831 public int hashCode() 1832 { 1833 return 1834 Objects.hashCode(this.scriptId) 1835 + Objects.hashCode(this.url) 1836 + this.startLine 1837 + this.startColumn 1838 + this.endLine 1839 + this.endColumn 1840 + this.executionContextId 1841 + Objects.hashCode(this.hash) 1842 + Objects.hashCode(this.executionContextAuxData) 1843 + Objects.hashCode(this.isLiveEdit) 1844 + Objects.hashCode(this.sourceMapURL) 1845 + Objects.hashCode(this.hasSourceURL) 1846 + Objects.hashCode(this.isModule) 1847 + Objects.hashCode(this.length) 1848 + this.stackTrace.hashCode() 1849 + Objects.hashCode(this.codeOffset) 1850 + Objects.hashCode(this.scriptLanguage) 1851 + this.debugSymbols.hashCode() 1852 + Objects.hashCode(this.embedderName); 1853 } 1854 } 1855 1856 1857 // Counter for keeping the WebSocket Request ID's distinct. 1858 private static int counter = 1; 1859 1860 /** 1861 * Continues execution until specific location is reached. 1862 * 1863 * @param location Location to continue to. 1864 * 1865 * @param targetCallFrames - 1866 * <BR />Acceptable Values: ["any", "current"] 1867 * <BR /><B>OPTIONAL</B> 1868 * 1869 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 1870 * {@link Ret0}></CODE> 1871 * 1872 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 1873 * browser receives the invocation-request. 1874 * 1875 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 1876 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 1877 * {@code >} to ensure the Browser Function has run to completion. 1878 */ 1879 public static Script<String, JsonObject, Ret0> continueToLocation 1880 (Debugger.Location location, String targetCallFrames) 1881 { 1882 // Exception-Check(s) to ensure that if any parameters which are not declared as 1883 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 1884 1885 if (location == null) THROWS.throwNPE("location"); 1886 1887 // Exception-Check(s) to ensure that if any parameters which must adhere to a 1888 // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw. 1889 1890 THROWS.checkIAE( 1891 "targetCallFrames", targetCallFrames, 1892 "any", "current" 1893 ); 1894 1895 final int webSocketID = 2000000 + counter++; 1896 final boolean[] optionals = { false, true, }; 1897 1898 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 1899 String requestJSON = WriteJSON.get( 1900 parameterTypes.get("continueToLocation"), 1901 parameterNames.get("continueToLocation"), 1902 optionals, webSocketID, 1903 "Debugger.continueToLocation", 1904 location, targetCallFrames 1905 ); 1906 1907 // This Remote Command does not have a Return-Value. 1908 return new Script<> 1909 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 1910 } 1911 1912 /** 1913 * Disables debugger for given page. 1914 * 1915 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 1916 * {@link Ret0}></CODE> 1917 * 1918 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 1919 * browser receives the invocation-request. 1920 * 1921 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 1922 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 1923 * {@code >} to ensure the Browser Function has run to completion. 1924 */ 1925 public static Script<String, JsonObject, Ret0> disable() 1926 { 1927 final int webSocketID = 2001000 + counter++; 1928 final boolean[] optionals = new boolean[0]; 1929 1930 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 1931 String requestJSON = WriteJSON.get( 1932 parameterTypes.get("disable"), 1933 parameterNames.get("disable"), 1934 optionals, webSocketID, 1935 "Debugger.disable" 1936 ); 1937 1938 // This Remote Command does not have a Return-Value. 1939 return new Script<> 1940 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 1941 } 1942 1943 /** 1944 * Enables debugger for the given page. Clients should not assume that the debugging has been 1945 * enabled until the result for this command is received. 1946 * 1947 * @param maxScriptsCacheSize 1948 * The maximum size in bytes of collected scripts (not referenced by other heap objects) 1949 * the debugger can hold. Puts no limit if parameter is omitted. 1950 * <BR /><B>OPTIONAL</B> 1951 * <BR /><B>EXPERIMENTAL</B> 1952 * 1953 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 1954 * String></CODE> 1955 * 1956 * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using 1957 * {@link Script#exec()}, and afterwards, a {@link Promise}<CODE><JsonObject, 1958 * String></CODE> will be returned. 1959 * 1960 * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>, 1961 * using {@link Promise#await()}, <I>and the returned result of this Browser Function may 1962 * may be retrieved.</I> 1963 * 1964 * <BR /><BR />This Browser Function <B STYLE='color: red'>returns</B> 1965 * <BR /><BR /><UL CLASS=JDUL> 1966 * <LI><CODE>String (<B>debuggerId</B></CODE>) 1967 * <BR />Unique identifier of the debugger. 1968 * </LI> 1969 * </UL> */ 1970 public static Script<String, JsonObject, String> enable(Number maxScriptsCacheSize) 1971 { 1972 final int webSocketID = 2002000 + counter++; 1973 final boolean[] optionals = { true, }; 1974 1975 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 1976 String requestJSON = WriteJSON.get( 1977 parameterTypes.get("enable"), 1978 parameterNames.get("enable"), 1979 optionals, webSocketID, 1980 "Debugger.enable", 1981 maxScriptsCacheSize 1982 ); 1983 1984 // 'JSON Binding' ... Converts Browser Response-JSON to 'String' 1985 Function<JsonObject, String> responseProcessor = (JsonObject jo) -> 1986 ReadJSON.getString(jo, "debuggerId", false, true); 1987 1988 return new Script<>(webSocketID, requestJSON, responseProcessor); 1989 } 1990 1991 /** 1992 * Evaluates expression on a given call frame. 1993 * 1994 * @param callFrameId Call frame identifier to evaluate on. 1995 * 1996 * @param expression Expression to evaluate. 1997 * 1998 * @param objectGroup 1999 * String object group name to put result into (allows rapid releasing resulting object handles 2000 * using <CODE>releaseObjectGroup</CODE>). 2001 * <BR /><B>OPTIONAL</B> 2002 * 2003 * @param includeCommandLineAPI 2004 * Specifies whether command line API should be available to the evaluated expression, defaults 2005 * to false. 2006 * <BR /><B>OPTIONAL</B> 2007 * 2008 * @param silent 2009 * In silent mode exceptions thrown during evaluation are not reported and do not pause 2010 * execution. Overrides <CODE>setPauseOnException</CODE> state. 2011 * <BR /><B>OPTIONAL</B> 2012 * 2013 * @param returnByValue Whether the result is expected to be a JSON object that should be sent by value. 2014 * <BR /><B>OPTIONAL</B> 2015 * 2016 * @param generatePreview Whether preview should be generated for the result. 2017 * <BR /><B>OPTIONAL</B> 2018 * <BR /><B>EXPERIMENTAL</B> 2019 * 2020 * @param throwOnSideEffect Whether to throw an exception if side effect cannot be ruled out during evaluation. 2021 * <BR /><B>OPTIONAL</B> 2022 * 2023 * @param timeout Terminate execution after timing out (number of milliseconds). 2024 * <BR /><B>OPTIONAL</B> 2025 * <BR /><B>EXPERIMENTAL</B> 2026 * 2027 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 2028 * {@link Ret2}></CODE> 2029 * 2030 * <BR /><BR />This {@link Script} may be <B STYLE='color:red'>executed</B> (using 2031 * {@link Script#exec()}), and a {@link Promise} returned. 2032 * 2033 * <BR /><BR />When the {@code Promise} is <B STYLE='color: red'>awaited</B> 2034 * (using {@link Promise#await()}), the {@code Ret2} will subsequently 2035 * be returned from that call. 2036 * 2037 * <BR /><BR />The <B STYLE='color: red'>returned</B> values are encapsulated 2038 * in an instance of <B>{@link Ret2}</B> 2039 * 2040 * <BR /><BR /><UL CLASS=JDUL> 2041 * <LI><CODE><B>Ret2.a:</B> {@link RunTime.RemoteObject} (<B>result</B>)</CODE> 2042 * <BR />Object wrapper for the evaluation result. 2043 * <BR /><BR /></LI> 2044 * <LI><CODE><B>Ret2.b:</B> {@link RunTime.ExceptionDetails} (<B>exceptionDetails</B>)</CODE> 2045 * <BR />Exception details. 2046 * </LI> 2047 * </UL> 2048 */ 2049 public static Script<String, JsonObject, Ret2<RunTime.RemoteObject, RunTime.ExceptionDetails>> evaluateOnCallFrame( 2050 String callFrameId, String expression, String objectGroup, 2051 Boolean includeCommandLineAPI, Boolean silent, Boolean returnByValue, 2052 Boolean generatePreview, Boolean throwOnSideEffect, Number timeout 2053 ) 2054 { 2055 // Exception-Check(s) to ensure that if any parameters which are not declared as 2056 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 2057 2058 if (callFrameId == null) THROWS.throwNPE("callFrameId"); 2059 if (expression == null) THROWS.throwNPE("expression"); 2060 2061 final int webSocketID = 2003000 + counter++; 2062 final boolean[] optionals = { false, false, true, true, true, true, true, true, true, }; 2063 2064 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 2065 String requestJSON = WriteJSON.get( 2066 parameterTypes.get("evaluateOnCallFrame"), 2067 parameterNames.get("evaluateOnCallFrame"), 2068 optionals, webSocketID, 2069 "Debugger.evaluateOnCallFrame", 2070 callFrameId, expression, objectGroup, includeCommandLineAPI, silent, returnByValue, 2071 generatePreview, throwOnSideEffect, timeout 2072 ); 2073 2074 // 'JSON Binding' ... Converts Browser Response-JSON into Java-Type 'Ret2' 2075 Function<JsonObject, Ret2<RunTime.RemoteObject, RunTime.ExceptionDetails>> 2076 responseProcessor = (JsonObject jo) -> new Ret2<>( 2077 ReadJSON.getObject(jo, "result", RunTime.RemoteObject.class, false, true), 2078 ReadJSON.getObject(jo, "exceptionDetails", RunTime.ExceptionDetails.class, true, false) 2079 ); 2080 2081 return new Script<>(webSocketID, requestJSON, responseProcessor); 2082 } 2083 2084 /** 2085 * Returns possible locations for breakpoint. scriptId in start and end range locations should be 2086 * the same. 2087 * 2088 * @param start Start of range to search possible breakpoint locations in. 2089 * 2090 * @param end 2091 * End of range to search possible breakpoint locations in (excluding). When not specified, end 2092 * of scripts is used as end of range. 2093 * <BR /><B>OPTIONAL</B> 2094 * 2095 * @param restrictToFunction Only consider locations which are in the same (non-nested) function as start. 2096 * <BR /><B>OPTIONAL</B> 2097 * 2098 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 2099 * {@link Debugger.BreakLocation}[]></CODE> 2100 * 2101 * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using 2102 * {@link Script#exec()}, and afterwards, a {@link Promise}<CODE><JsonObject, 2103 * {@link Debugger.BreakLocation}[]></CODE> will be returned. 2104 * 2105 * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>, 2106 * using {@link Promise#await()}, <I>and the returned result of this Browser Function may 2107 * may be retrieved.</I> 2108 * 2109 * <BR /><BR />This Browser Function <B STYLE='color: red'>returns</B> 2110 * <BR /><BR /><UL CLASS=JDUL> 2111 * <LI><CODE>{@link Debugger.BreakLocation}[] (<B>locations</B></CODE>) 2112 * <BR />List of the possible breakpoint locations. 2113 * </LI> 2114 * </UL> */ 2115 public static Script<String, JsonObject, Debugger.BreakLocation[]> getPossibleBreakpoints 2116 (Debugger.Location start, Debugger.Location end, Boolean restrictToFunction) 2117 { 2118 // Exception-Check(s) to ensure that if any parameters which are not declared as 2119 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 2120 2121 if (start == null) THROWS.throwNPE("start"); 2122 2123 final int webSocketID = 2004000 + counter++; 2124 final boolean[] optionals = { false, true, true, }; 2125 2126 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 2127 String requestJSON = WriteJSON.get( 2128 parameterTypes.get("getPossibleBreakpoints"), 2129 parameterNames.get("getPossibleBreakpoints"), 2130 optionals, webSocketID, 2131 "Debugger.getPossibleBreakpoints", 2132 start, end, restrictToFunction 2133 ); 2134 2135 // 'JSON Binding' ... Converts Browser Response-JSON to 'Debugger.BreakLocation[]' 2136 Function<JsonObject, Debugger.BreakLocation[]> responseProcessor = (JsonObject jo) -> 2137 (jo.getJsonArray("locations") == null) 2138 ? null 2139 : RJArrIntoStream.objArr(jo.getJsonArray("locations"), null, 0, Debugger.BreakLocation.class).toArray(Debugger.BreakLocation[]::new); 2140 2141 return new Script<>(webSocketID, requestJSON, responseProcessor); 2142 } 2143 2144 /** 2145 * Returns source for the script with given id. 2146 * 2147 * @param scriptId Id of the script to get source for. 2148 * 2149 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 2150 * {@link Ret2}></CODE> 2151 * 2152 * <BR /><BR />This {@link Script} may be <B STYLE='color:red'>executed</B> (using 2153 * {@link Script#exec()}), and a {@link Promise} returned. 2154 * 2155 * <BR /><BR />When the {@code Promise} is <B STYLE='color: red'>awaited</B> 2156 * (using {@link Promise#await()}), the {@code Ret2} will subsequently 2157 * be returned from that call. 2158 * 2159 * <BR /><BR />The <B STYLE='color: red'>returned</B> values are encapsulated 2160 * in an instance of <B>{@link Ret2}</B> 2161 * 2162 * <BR /><BR /><UL CLASS=JDUL> 2163 * <LI><CODE><B>Ret2.a:</B> String (<B>scriptSource</B>)</CODE> 2164 * <BR />Script source (empty in case of Wasm bytecode). 2165 * <BR /><BR /></LI> 2166 * <LI><CODE><B>Ret2.b:</B> String (<B>bytecode</B>)</CODE> 2167 * <BR />Wasm bytecode. (Encoded as a base64 string when passed over JSON) 2168 * </LI> 2169 * </UL> 2170 */ 2171 public static Script<String, JsonObject, Ret2<String, String>> getScriptSource 2172 (String scriptId) 2173 { 2174 // Exception-Check(s) to ensure that if any parameters which are not declared as 2175 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 2176 2177 if (scriptId == null) THROWS.throwNPE("scriptId"); 2178 2179 final int webSocketID = 2005000 + counter++; 2180 final boolean[] optionals = { false, }; 2181 2182 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 2183 String requestJSON = WriteJSON.get( 2184 parameterTypes.get("getScriptSource"), 2185 parameterNames.get("getScriptSource"), 2186 optionals, webSocketID, 2187 "Debugger.getScriptSource", 2188 scriptId 2189 ); 2190 2191 // 'JSON Binding' ... Converts Browser Response-JSON into Java-Type 'Ret2' 2192 Function<JsonObject, Ret2<String, String>> 2193 responseProcessor = (JsonObject jo) -> new Ret2<>( 2194 ReadJSON.getString(jo, "scriptSource", false, true), 2195 ReadJSON.getString(jo, "bytecode", true, false) 2196 ); 2197 2198 return new Script<>(webSocketID, requestJSON, responseProcessor); 2199 } 2200 2201 /** 2202 * This command is deprecated. Use getScriptSource instead. 2203 * <BR /><B>DEPRECATED</B> 2204 * 2205 * @param scriptId Id of the Wasm script to get source for. 2206 * 2207 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 2208 * String></CODE> 2209 * 2210 * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using 2211 * {@link Script#exec()}, and afterwards, a {@link Promise}<CODE><JsonObject, 2212 * String></CODE> will be returned. 2213 * 2214 * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>, 2215 * using {@link Promise#await()}, <I>and the returned result of this Browser Function may 2216 * may be retrieved.</I> 2217 * 2218 * <BR /><BR />This Browser Function <B STYLE='color: red'>returns</B> 2219 * <BR /><BR /><UL CLASS=JDUL> 2220 * <LI><CODE>String (<B>bytecode</B></CODE>) 2221 * <BR />Script source. (Encoded as a base64 string when passed over JSON) 2222 * </LI> 2223 * </UL> */ 2224 public static Script<String, JsonObject, String> getWasmBytecode(String scriptId) 2225 { 2226 // Exception-Check(s) to ensure that if any parameters which are not declared as 2227 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 2228 2229 if (scriptId == null) THROWS.throwNPE("scriptId"); 2230 2231 final int webSocketID = 2006000 + counter++; 2232 final boolean[] optionals = { false, }; 2233 2234 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 2235 String requestJSON = WriteJSON.get( 2236 parameterTypes.get("getWasmBytecode"), 2237 parameterNames.get("getWasmBytecode"), 2238 optionals, webSocketID, 2239 "Debugger.getWasmBytecode", 2240 scriptId 2241 ); 2242 2243 // 'JSON Binding' ... Converts Browser Response-JSON to 'String' 2244 Function<JsonObject, String> responseProcessor = (JsonObject jo) -> 2245 ReadJSON.getString(jo, "bytecode", false, true); 2246 2247 return new Script<>(webSocketID, requestJSON, responseProcessor); 2248 } 2249 2250 /** 2251 * Returns stack trace with given <CODE>stackTraceId</CODE>. 2252 * <BR /><B>EXPERIMENTAL</B> 2253 * 2254 * @param stackTraceId - 2255 * 2256 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 2257 * {@link RunTime.StackTrace}></CODE> 2258 * 2259 * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using 2260 * {@link Script#exec()}, and afterwards, a {@link Promise}<CODE><JsonObject, 2261 * {@link RunTime.StackTrace}></CODE> will be returned. 2262 * 2263 * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>, 2264 * using {@link Promise#await()}, <I>and the returned result of this Browser Function may 2265 * may be retrieved.</I> 2266 * 2267 * <BR /><BR />This Browser Function <B STYLE='color: red'>returns</B> 2268 * <BR /><BR /><UL CLASS=JDUL> 2269 * <LI><CODE>{@link RunTime.StackTrace} (<B>stackTrace</B></CODE>) 2270 * <BR />- 2271 * </LI> 2272 * </UL> */ 2273 public static Script<String, JsonObject, RunTime.StackTrace> getStackTrace 2274 (RunTime.StackTraceId stackTraceId) 2275 { 2276 // Exception-Check(s) to ensure that if any parameters which are not declared as 2277 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 2278 2279 if (stackTraceId == null) THROWS.throwNPE("stackTraceId"); 2280 2281 final int webSocketID = 2007000 + counter++; 2282 final boolean[] optionals = { false, }; 2283 2284 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 2285 String requestJSON = WriteJSON.get( 2286 parameterTypes.get("getStackTrace"), 2287 parameterNames.get("getStackTrace"), 2288 optionals, webSocketID, 2289 "Debugger.getStackTrace", 2290 stackTraceId 2291 ); 2292 2293 // 'JSON Binding' ... Converts Browser Response-JSON to 'RunTime.StackTrace' 2294 Function<JsonObject, RunTime.StackTrace> responseProcessor = (JsonObject jo) -> 2295 ReadJSON.getObject(jo, "stackTrace", RunTime.StackTrace.class, false, true); 2296 2297 return new Script<>(webSocketID, requestJSON, responseProcessor); 2298 } 2299 2300 /** 2301 * Stops on the next JavaScript statement. 2302 * 2303 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 2304 * {@link Ret0}></CODE> 2305 * 2306 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 2307 * browser receives the invocation-request. 2308 * 2309 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 2310 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 2311 * {@code >} to ensure the Browser Function has run to completion. 2312 */ 2313 public static Script<String, JsonObject, Ret0> pause() 2314 { 2315 final int webSocketID = 2008000 + counter++; 2316 final boolean[] optionals = new boolean[0]; 2317 2318 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 2319 String requestJSON = WriteJSON.get( 2320 parameterTypes.get("pause"), 2321 parameterNames.get("pause"), 2322 optionals, webSocketID, 2323 "Debugger.pause" 2324 ); 2325 2326 // This Remote Command does not have a Return-Value. 2327 return new Script<> 2328 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 2329 } 2330 2331 /** 2332 * <CODE>[No Description Provided by Google]</CODE> 2333 * <BR /><B>EXPERIMENTAL</B> 2334 * <BR /><B>DEPRECATED</B> 2335 * 2336 * @param parentStackTraceId Debugger will pause when async call with given stack trace is started. 2337 * 2338 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 2339 * {@link Ret0}></CODE> 2340 * 2341 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 2342 * browser receives the invocation-request. 2343 * 2344 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 2345 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 2346 * {@code >} to ensure the Browser Function has run to completion. 2347 */ 2348 public static Script<String, JsonObject, Ret0> pauseOnAsyncCall 2349 (RunTime.StackTraceId parentStackTraceId) 2350 { 2351 // Exception-Check(s) to ensure that if any parameters which are not declared as 2352 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 2353 2354 if (parentStackTraceId == null) THROWS.throwNPE("parentStackTraceId"); 2355 2356 final int webSocketID = 2009000 + counter++; 2357 final boolean[] optionals = { false, }; 2358 2359 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 2360 String requestJSON = WriteJSON.get( 2361 parameterTypes.get("pauseOnAsyncCall"), 2362 parameterNames.get("pauseOnAsyncCall"), 2363 optionals, webSocketID, 2364 "Debugger.pauseOnAsyncCall", 2365 parentStackTraceId 2366 ); 2367 2368 // This Remote Command does not have a Return-Value. 2369 return new Script<> 2370 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 2371 } 2372 2373 /** 2374 * Removes JavaScript breakpoint. 2375 * 2376 * @param breakpointId - 2377 * 2378 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 2379 * {@link Ret0}></CODE> 2380 * 2381 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 2382 * browser receives the invocation-request. 2383 * 2384 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 2385 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 2386 * {@code >} to ensure the Browser Function has run to completion. 2387 */ 2388 public static Script<String, JsonObject, Ret0> removeBreakpoint(String breakpointId) 2389 { 2390 // Exception-Check(s) to ensure that if any parameters which are not declared as 2391 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 2392 2393 if (breakpointId == null) THROWS.throwNPE("breakpointId"); 2394 2395 final int webSocketID = 2010000 + counter++; 2396 final boolean[] optionals = { false, }; 2397 2398 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 2399 String requestJSON = WriteJSON.get( 2400 parameterTypes.get("removeBreakpoint"), 2401 parameterNames.get("removeBreakpoint"), 2402 optionals, webSocketID, 2403 "Debugger.removeBreakpoint", 2404 breakpointId 2405 ); 2406 2407 // This Remote Command does not have a Return-Value. 2408 return new Script<> 2409 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 2410 } 2411 2412 /** 2413 * Restarts particular call frame from the beginning. 2414 * <BR /><B>DEPRECATED</B> 2415 * 2416 * @param callFrameId Call frame identifier to evaluate on. 2417 * 2418 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 2419 * {@link Ret3}></CODE> 2420 * 2421 * <BR /><BR />This {@link Script} may be <B STYLE='color:red'>executed</B> (using 2422 * {@link Script#exec()}), and a {@link Promise} returned. 2423 * 2424 * <BR /><BR />When the {@code Promise} is <B STYLE='color: red'>awaited</B> 2425 * (using {@link Promise#await()}), the {@code Ret3} will subsequently 2426 * be returned from that call. 2427 * 2428 * <BR /><BR />The <B STYLE='color: red'>returned</B> values are encapsulated 2429 * in an instance of <B>{@link Ret3}</B> 2430 * 2431 * <BR /><BR /><UL CLASS=JDUL> 2432 * <LI><CODE><B>Ret3.a:</B> {@link Debugger.CallFrame}[] (<B>callFrames</B>)</CODE> 2433 * <BR />New stack trace. 2434 * <BR /><BR /></LI> 2435 * <LI><CODE><B>Ret3.b:</B> {@link RunTime.StackTrace} (<B>asyncStackTrace</B>)</CODE> 2436 * <BR />Async stack trace, if any. 2437 * <BR /><BR /></LI> 2438 * <LI><CODE><B>Ret3.c:</B> {@link RunTime.StackTraceId} (<B>asyncStackTraceId</B>)</CODE> 2439 * <BR />Async stack trace, if any. 2440 * </LI> 2441 * </UL> 2442 */ 2443 public static Script<String, JsonObject, Ret3<Debugger.CallFrame[], RunTime.StackTrace, RunTime.StackTraceId>> 2444 restartFrame(String callFrameId) 2445 { 2446 // Exception-Check(s) to ensure that if any parameters which are not declared as 2447 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 2448 2449 if (callFrameId == null) THROWS.throwNPE("callFrameId"); 2450 2451 final int webSocketID = 2011000 + counter++; 2452 final boolean[] optionals = { false, }; 2453 2454 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 2455 String requestJSON = WriteJSON.get( 2456 parameterTypes.get("restartFrame"), 2457 parameterNames.get("restartFrame"), 2458 optionals, webSocketID, 2459 "Debugger.restartFrame", 2460 callFrameId 2461 ); 2462 2463 // 'JSON Binding' ... Converts Browser Response-JSON into Java-Type 'Ret3' 2464 Function<JsonObject, Ret3<Debugger.CallFrame[], RunTime.StackTrace, RunTime.StackTraceId>> 2465 responseProcessor = (JsonObject jo) -> new Ret3<>( 2466 (jo.getJsonArray("callFrames") == null) 2467 ? null 2468 : RJArrIntoStream.objArr(jo.getJsonArray("callFrames"), null, 0, Debugger.CallFrame.class).toArray(Debugger.CallFrame[]::new), 2469 ReadJSON.getObject(jo, "asyncStackTrace", RunTime.StackTrace.class, true, false), 2470 ReadJSON.getObject(jo, "asyncStackTraceId", RunTime.StackTraceId.class, true, false) 2471 ); 2472 2473 return new Script<>(webSocketID, requestJSON, responseProcessor); 2474 } 2475 2476 /** 2477 * Resumes JavaScript execution. 2478 * 2479 * @param terminateOnResume 2480 * Set to true to terminate execution upon resuming execution. In contrast 2481 * to RunTime.terminateExecution, this will allows to execute further 2482 * JavaScript (i.e. via evaluation) until execution of the paused code 2483 * is actually resumed, at which point termination is triggered. 2484 * If execution is currently not paused, this parameter has no effect. 2485 * <BR /><B>OPTIONAL</B> 2486 * 2487 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 2488 * {@link Ret0}></CODE> 2489 * 2490 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 2491 * browser receives the invocation-request. 2492 * 2493 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 2494 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 2495 * {@code >} to ensure the Browser Function has run to completion. 2496 */ 2497 public static Script<String, JsonObject, Ret0> resume(Boolean terminateOnResume) 2498 { 2499 final int webSocketID = 2012000 + counter++; 2500 final boolean[] optionals = { true, }; 2501 2502 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 2503 String requestJSON = WriteJSON.get( 2504 parameterTypes.get("resume"), 2505 parameterNames.get("resume"), 2506 optionals, webSocketID, 2507 "Debugger.resume", 2508 terminateOnResume 2509 ); 2510 2511 // This Remote Command does not have a Return-Value. 2512 return new Script<> 2513 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 2514 } 2515 2516 /** 2517 * Searches for given string in script content. 2518 * 2519 * @param scriptId Id of the script to search in. 2520 * 2521 * @param query String to search for. 2522 * 2523 * @param caseSensitive If true, search is case sensitive. 2524 * <BR /><B>OPTIONAL</B> 2525 * 2526 * @param isRegex If true, treats string parameter as regex. 2527 * <BR /><B>OPTIONAL</B> 2528 * 2529 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 2530 * {@link Debugger.SearchMatch}[]></CODE> 2531 * 2532 * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using 2533 * {@link Script#exec()}, and afterwards, a {@link Promise}<CODE><JsonObject, 2534 * {@link Debugger.SearchMatch}[]></CODE> will be returned. 2535 * 2536 * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>, 2537 * using {@link Promise#await()}, <I>and the returned result of this Browser Function may 2538 * may be retrieved.</I> 2539 * 2540 * <BR /><BR />This Browser Function <B STYLE='color: red'>returns</B> 2541 * <BR /><BR /><UL CLASS=JDUL> 2542 * <LI><CODE>{@link Debugger.SearchMatch}[] (<B>result</B></CODE>) 2543 * <BR />List of search matches. 2544 * </LI> 2545 * </UL> */ 2546 public static Script<String, JsonObject, Debugger.SearchMatch[]> searchInContent 2547 (String scriptId, String query, Boolean caseSensitive, Boolean isRegex) 2548 { 2549 // Exception-Check(s) to ensure that if any parameters which are not declared as 2550 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 2551 2552 if (scriptId == null) THROWS.throwNPE("scriptId"); 2553 if (query == null) THROWS.throwNPE("query"); 2554 2555 final int webSocketID = 2013000 + counter++; 2556 final boolean[] optionals = { false, false, true, true, }; 2557 2558 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 2559 String requestJSON = WriteJSON.get( 2560 parameterTypes.get("searchInContent"), 2561 parameterNames.get("searchInContent"), 2562 optionals, webSocketID, 2563 "Debugger.searchInContent", 2564 scriptId, query, caseSensitive, isRegex 2565 ); 2566 2567 // 'JSON Binding' ... Converts Browser Response-JSON to 'Debugger.SearchMatch[]' 2568 Function<JsonObject, Debugger.SearchMatch[]> responseProcessor = (JsonObject jo) -> 2569 (jo.getJsonArray("result") == null) 2570 ? null 2571 : RJArrIntoStream.objArr(jo.getJsonArray("result"), null, 0, Debugger.SearchMatch.class).toArray(Debugger.SearchMatch[]::new); 2572 2573 return new Script<>(webSocketID, requestJSON, responseProcessor); 2574 } 2575 2576 /** 2577 * Enables or disables async call stacks tracking. 2578 * 2579 * @param maxDepth 2580 * Maximum depth of async call stacks. Setting to <CODE>0</CODE> will effectively disable collecting async 2581 * call stacks (default). 2582 * 2583 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 2584 * {@link Ret0}></CODE> 2585 * 2586 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 2587 * browser receives the invocation-request. 2588 * 2589 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 2590 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 2591 * {@code >} to ensure the Browser Function has run to completion. 2592 */ 2593 public static Script<String, JsonObject, Ret0> setAsyncCallStackDepth(int maxDepth) 2594 { 2595 final int webSocketID = 2014000 + counter++; 2596 final boolean[] optionals = { false, }; 2597 2598 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 2599 String requestJSON = WriteJSON.get( 2600 parameterTypes.get("setAsyncCallStackDepth"), 2601 parameterNames.get("setAsyncCallStackDepth"), 2602 optionals, webSocketID, 2603 "Debugger.setAsyncCallStackDepth", 2604 maxDepth 2605 ); 2606 2607 // This Remote Command does not have a Return-Value. 2608 return new Script<> 2609 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 2610 } 2611 2612 /** 2613 * Replace previous blackbox patterns with passed ones. Forces backend to skip stepping/pausing in 2614 * scripts with url matching one of the patterns. VM will try to leave blackboxed script by 2615 * performing 'step in' several times, finally resorting to 'step out' if unsuccessful. 2616 * <BR /><B>EXPERIMENTAL</B> 2617 * 2618 * @param patterns Array of regexps that will be used to check script url for blackbox state. 2619 * 2620 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 2621 * {@link Ret0}></CODE> 2622 * 2623 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 2624 * browser receives the invocation-request. 2625 * 2626 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 2627 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 2628 * {@code >} to ensure the Browser Function has run to completion. 2629 */ 2630 public static Script<String, JsonObject, Ret0> setBlackboxPatterns(String[] patterns) 2631 { 2632 // Exception-Check(s) to ensure that if any parameters which are not declared as 2633 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 2634 2635 if (patterns == null) THROWS.throwNPE("patterns"); 2636 2637 final int webSocketID = 2015000 + counter++; 2638 final boolean[] optionals = { false, }; 2639 2640 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 2641 String requestJSON = WriteJSON.get( 2642 parameterTypes.get("setBlackboxPatterns"), 2643 parameterNames.get("setBlackboxPatterns"), 2644 optionals, webSocketID, 2645 "Debugger.setBlackboxPatterns", 2646 (Object) patterns 2647 ); 2648 2649 // This Remote Command does not have a Return-Value. 2650 return new Script<> 2651 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 2652 } 2653 2654 /** 2655 * Makes backend skip steps in the script in blackboxed ranges. VM will try leave blacklisted 2656 * scripts by performing 'step in' several times, finally resorting to 'step out' if unsuccessful. 2657 * Positions array contains positions where blackbox state is changed. First interval isn't 2658 * blackboxed. Array should be sorted. 2659 * <BR /><B>EXPERIMENTAL</B> 2660 * 2661 * @param scriptId Id of the script. 2662 * 2663 * @param positions - 2664 * 2665 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 2666 * {@link Ret0}></CODE> 2667 * 2668 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 2669 * browser receives the invocation-request. 2670 * 2671 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 2672 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 2673 * {@code >} to ensure the Browser Function has run to completion. 2674 */ 2675 public static Script<String, JsonObject, Ret0> setBlackboxedRanges 2676 (String scriptId, Debugger.ScriptPosition[] positions) 2677 { 2678 // Exception-Check(s) to ensure that if any parameters which are not declared as 2679 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 2680 2681 if (scriptId == null) THROWS.throwNPE("scriptId"); 2682 if (positions == null) THROWS.throwNPE("positions"); 2683 2684 final int webSocketID = 2016000 + counter++; 2685 final boolean[] optionals = { false, false, }; 2686 2687 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 2688 String requestJSON = WriteJSON.get( 2689 parameterTypes.get("setBlackboxedRanges"), 2690 parameterNames.get("setBlackboxedRanges"), 2691 optionals, webSocketID, 2692 "Debugger.setBlackboxedRanges", 2693 scriptId, positions 2694 ); 2695 2696 // This Remote Command does not have a Return-Value. 2697 return new Script<> 2698 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 2699 } 2700 2701 /** 2702 * Sets JavaScript breakpoint at a given location. 2703 * 2704 * @param location Location to set breakpoint in. 2705 * 2706 * @param condition 2707 * Expression to use as a breakpoint condition. When specified, debugger will only stop on the 2708 * breakpoint if this expression evaluates to true. 2709 * <BR /><B>OPTIONAL</B> 2710 * 2711 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 2712 * {@link Ret2}></CODE> 2713 * 2714 * <BR /><BR />This {@link Script} may be <B STYLE='color:red'>executed</B> (using 2715 * {@link Script#exec()}), and a {@link Promise} returned. 2716 * 2717 * <BR /><BR />When the {@code Promise} is <B STYLE='color: red'>awaited</B> 2718 * (using {@link Promise#await()}), the {@code Ret2} will subsequently 2719 * be returned from that call. 2720 * 2721 * <BR /><BR />The <B STYLE='color: red'>returned</B> values are encapsulated 2722 * in an instance of <B>{@link Ret2}</B> 2723 * 2724 * <BR /><BR /><UL CLASS=JDUL> 2725 * <LI><CODE><B>Ret2.a:</B> String (<B>breakpointId</B>)</CODE> 2726 * <BR />Id of the created breakpoint for further reference. 2727 * <BR /><BR /></LI> 2728 * <LI><CODE><B>Ret2.b:</B> {@link Debugger.Location} (<B>actualLocation</B>)</CODE> 2729 * <BR />Location this breakpoint resolved into. 2730 * </LI> 2731 * </UL> 2732 */ 2733 public static Script<String, JsonObject, Ret2<String, Debugger.Location>> setBreakpoint 2734 (Debugger.Location location, String condition) 2735 { 2736 // Exception-Check(s) to ensure that if any parameters which are not declared as 2737 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 2738 2739 if (location == null) THROWS.throwNPE("location"); 2740 2741 final int webSocketID = 2017000 + counter++; 2742 final boolean[] optionals = { false, true, }; 2743 2744 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 2745 String requestJSON = WriteJSON.get( 2746 parameterTypes.get("setBreakpoint"), 2747 parameterNames.get("setBreakpoint"), 2748 optionals, webSocketID, 2749 "Debugger.setBreakpoint", 2750 location, condition 2751 ); 2752 2753 // 'JSON Binding' ... Converts Browser Response-JSON into Java-Type 'Ret2' 2754 Function<JsonObject, Ret2<String, Debugger.Location>> 2755 responseProcessor = (JsonObject jo) -> new Ret2<>( 2756 ReadJSON.getString(jo, "breakpointId", false, true), 2757 ReadJSON.getObject(jo, "actualLocation", Debugger.Location.class, false, true) 2758 ); 2759 2760 return new Script<>(webSocketID, requestJSON, responseProcessor); 2761 } 2762 2763 /** 2764 * Sets instrumentation breakpoint. 2765 * 2766 * @param instrumentation Instrumentation name. 2767 * <BR />Acceptable Values: ["beforeScriptExecution", "beforeScriptWithSourceMapExecution"] 2768 * 2769 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 2770 * String></CODE> 2771 * 2772 * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using 2773 * {@link Script#exec()}, and afterwards, a {@link Promise}<CODE><JsonObject, 2774 * String></CODE> will be returned. 2775 * 2776 * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>, 2777 * using {@link Promise#await()}, <I>and the returned result of this Browser Function may 2778 * may be retrieved.</I> 2779 * 2780 * <BR /><BR />This Browser Function <B STYLE='color: red'>returns</B> 2781 * <BR /><BR /><UL CLASS=JDUL> 2782 * <LI><CODE>String (<B>breakpointId</B></CODE>) 2783 * <BR />Id of the created breakpoint for further reference. 2784 * </LI> 2785 * </UL> */ 2786 public static Script<String, JsonObject, String> setInstrumentationBreakpoint 2787 (String instrumentation) 2788 { 2789 // Exception-Check(s) to ensure that if any parameters which are not declared as 2790 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 2791 2792 if (instrumentation == null) THROWS.throwNPE("instrumentation"); 2793 2794 // Exception-Check(s) to ensure that if any parameters which must adhere to a 2795 // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw. 2796 2797 THROWS.checkIAE( 2798 "instrumentation", instrumentation, 2799 "beforeScriptExecution", "beforeScriptWithSourceMapExecution" 2800 ); 2801 2802 final int webSocketID = 2018000 + counter++; 2803 final boolean[] optionals = { false, }; 2804 2805 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 2806 String requestJSON = WriteJSON.get( 2807 parameterTypes.get("setInstrumentationBreakpoint"), 2808 parameterNames.get("setInstrumentationBreakpoint"), 2809 optionals, webSocketID, 2810 "Debugger.setInstrumentationBreakpoint", 2811 instrumentation 2812 ); 2813 2814 // 'JSON Binding' ... Converts Browser Response-JSON to 'String' 2815 Function<JsonObject, String> responseProcessor = (JsonObject jo) -> 2816 ReadJSON.getString(jo, "breakpointId", false, true); 2817 2818 return new Script<>(webSocketID, requestJSON, responseProcessor); 2819 } 2820 2821 /** 2822 * Sets JavaScript breakpoint at given location specified either by URL or URL regex. Once this 2823 * command is issued, all existing parsed scripts will have breakpoints resolved and returned in 2824 * <CODE>locations</CODE> property. Further matching script parsing will result in subsequent 2825 * <CODE>breakpointResolved</CODE> events issued. This logical breakpoint will survive page reloads. 2826 * 2827 * @param lineNumber Line number to set breakpoint at. 2828 * 2829 * @param url URL of the resources to set breakpoint on. 2830 * <BR /><B>OPTIONAL</B> 2831 * 2832 * @param urlRegex 2833 * Regex pattern for the URLs of the resources to set breakpoints on. Either <CODE>url</CODE> or 2834 * <CODE>urlRegex</CODE> must be specified. 2835 * <BR /><B>OPTIONAL</B> 2836 * 2837 * @param scriptHash Script hash of the resources to set breakpoint on. 2838 * <BR /><B>OPTIONAL</B> 2839 * 2840 * @param columnNumber Offset in the line to set breakpoint at. 2841 * <BR /><B>OPTIONAL</B> 2842 * 2843 * @param condition 2844 * Expression to use as a breakpoint condition. When specified, debugger will only stop on the 2845 * breakpoint if this expression evaluates to true. 2846 * <BR /><B>OPTIONAL</B> 2847 * 2848 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 2849 * {@link Ret2}></CODE> 2850 * 2851 * <BR /><BR />This {@link Script} may be <B STYLE='color:red'>executed</B> (using 2852 * {@link Script#exec()}), and a {@link Promise} returned. 2853 * 2854 * <BR /><BR />When the {@code Promise} is <B STYLE='color: red'>awaited</B> 2855 * (using {@link Promise#await()}), the {@code Ret2} will subsequently 2856 * be returned from that call. 2857 * 2858 * <BR /><BR />The <B STYLE='color: red'>returned</B> values are encapsulated 2859 * in an instance of <B>{@link Ret2}</B> 2860 * 2861 * <BR /><BR /><UL CLASS=JDUL> 2862 * <LI><CODE><B>Ret2.a:</B> String (<B>breakpointId</B>)</CODE> 2863 * <BR />Id of the created breakpoint for further reference. 2864 * <BR /><BR /></LI> 2865 * <LI><CODE><B>Ret2.b:</B> {@link Debugger.Location}[] (<B>locations</B>)</CODE> 2866 * <BR />List of the locations this breakpoint resolved into upon addition. 2867 * </LI> 2868 * </UL> 2869 */ 2870 public static Script<String, JsonObject, Ret2<String, Debugger.Location[]>> setBreakpointByUrl( 2871 int lineNumber, String url, String urlRegex, String scriptHash, Integer columnNumber, 2872 String condition 2873 ) 2874 { 2875 final int webSocketID = 2019000 + counter++; 2876 final boolean[] optionals = { false, true, true, true, true, true, }; 2877 2878 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 2879 String requestJSON = WriteJSON.get( 2880 parameterTypes.get("setBreakpointByUrl"), 2881 parameterNames.get("setBreakpointByUrl"), 2882 optionals, webSocketID, 2883 "Debugger.setBreakpointByUrl", 2884 lineNumber, url, urlRegex, scriptHash, columnNumber, condition 2885 ); 2886 2887 // 'JSON Binding' ... Converts Browser Response-JSON into Java-Type 'Ret2' 2888 Function<JsonObject, Ret2<String, Debugger.Location[]>> 2889 responseProcessor = (JsonObject jo) -> new Ret2<>( 2890 ReadJSON.getString(jo, "breakpointId", false, true), 2891 (jo.getJsonArray("locations") == null) 2892 ? null 2893 : RJArrIntoStream.objArr(jo.getJsonArray("locations"), null, 0, Debugger.Location.class).toArray(Debugger.Location[]::new) 2894 ); 2895 2896 return new Script<>(webSocketID, requestJSON, responseProcessor); 2897 } 2898 2899 /** 2900 * Sets JavaScript breakpoint before each call to the given function. 2901 * If another function was created from the same source as a given one, 2902 * calling it will also trigger the breakpoint. 2903 * <BR /><B>EXPERIMENTAL</B> 2904 * 2905 * @param objectId Function object id. 2906 * 2907 * @param condition 2908 * Expression to use as a breakpoint condition. When specified, debugger will 2909 * stop on the breakpoint if this expression evaluates to true. 2910 * <BR /><B>OPTIONAL</B> 2911 * 2912 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 2913 * String></CODE> 2914 * 2915 * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using 2916 * {@link Script#exec()}, and afterwards, a {@link Promise}<CODE><JsonObject, 2917 * String></CODE> will be returned. 2918 * 2919 * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>, 2920 * using {@link Promise#await()}, <I>and the returned result of this Browser Function may 2921 * may be retrieved.</I> 2922 * 2923 * <BR /><BR />This Browser Function <B STYLE='color: red'>returns</B> 2924 * <BR /><BR /><UL CLASS=JDUL> 2925 * <LI><CODE>String (<B>breakpointId</B></CODE>) 2926 * <BR />Id of the created breakpoint for further reference. 2927 * </LI> 2928 * </UL> */ 2929 public static Script<String, JsonObject, String> setBreakpointOnFunctionCall 2930 (String objectId, String condition) 2931 { 2932 // Exception-Check(s) to ensure that if any parameters which are not declared as 2933 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 2934 2935 if (objectId == null) THROWS.throwNPE("objectId"); 2936 2937 final int webSocketID = 2020000 + counter++; 2938 final boolean[] optionals = { false, true, }; 2939 2940 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 2941 String requestJSON = WriteJSON.get( 2942 parameterTypes.get("setBreakpointOnFunctionCall"), 2943 parameterNames.get("setBreakpointOnFunctionCall"), 2944 optionals, webSocketID, 2945 "Debugger.setBreakpointOnFunctionCall", 2946 objectId, condition 2947 ); 2948 2949 // 'JSON Binding' ... Converts Browser Response-JSON to 'String' 2950 Function<JsonObject, String> responseProcessor = (JsonObject jo) -> 2951 ReadJSON.getString(jo, "breakpointId", false, true); 2952 2953 return new Script<>(webSocketID, requestJSON, responseProcessor); 2954 } 2955 2956 /** 2957 * Activates / deactivates all breakpoints on the page. 2958 * 2959 * @param active New value for breakpoints active state. 2960 * 2961 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 2962 * {@link Ret0}></CODE> 2963 * 2964 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 2965 * browser receives the invocation-request. 2966 * 2967 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 2968 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 2969 * {@code >} to ensure the Browser Function has run to completion. 2970 */ 2971 public static Script<String, JsonObject, Ret0> setBreakpointsActive(boolean active) 2972 { 2973 final int webSocketID = 2021000 + counter++; 2974 final boolean[] optionals = { false, }; 2975 2976 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 2977 String requestJSON = WriteJSON.get( 2978 parameterTypes.get("setBreakpointsActive"), 2979 parameterNames.get("setBreakpointsActive"), 2980 optionals, webSocketID, 2981 "Debugger.setBreakpointsActive", 2982 active 2983 ); 2984 2985 // This Remote Command does not have a Return-Value. 2986 return new Script<> 2987 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 2988 } 2989 2990 /** 2991 * Defines pause on exceptions state. Can be set to stop on all exceptions, uncaught exceptions or 2992 * no exceptions. Initial pause on exceptions state is <CODE>none</CODE>. 2993 * 2994 * @param state Pause on exceptions mode. 2995 * <BR />Acceptable Values: ["none", "uncaught", "all"] 2996 * 2997 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 2998 * {@link Ret0}></CODE> 2999 * 3000 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 3001 * browser receives the invocation-request. 3002 * 3003 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 3004 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 3005 * {@code >} to ensure the Browser Function has run to completion. 3006 */ 3007 public static Script<String, JsonObject, Ret0> setPauseOnExceptions(String state) 3008 { 3009 // Exception-Check(s) to ensure that if any parameters which are not declared as 3010 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 3011 3012 if (state == null) THROWS.throwNPE("state"); 3013 3014 // Exception-Check(s) to ensure that if any parameters which must adhere to a 3015 // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw. 3016 3017 THROWS.checkIAE( 3018 "state", state, 3019 "none", "uncaught", "all" 3020 ); 3021 3022 final int webSocketID = 2022000 + counter++; 3023 final boolean[] optionals = { false, }; 3024 3025 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 3026 String requestJSON = WriteJSON.get( 3027 parameterTypes.get("setPauseOnExceptions"), 3028 parameterNames.get("setPauseOnExceptions"), 3029 optionals, webSocketID, 3030 "Debugger.setPauseOnExceptions", 3031 state 3032 ); 3033 3034 // This Remote Command does not have a Return-Value. 3035 return new Script<> 3036 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 3037 } 3038 3039 /** 3040 * Changes return value in top frame. Available only at return break position. 3041 * <BR /><B>EXPERIMENTAL</B> 3042 * 3043 * @param newValue New return value. 3044 * 3045 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 3046 * {@link Ret0}></CODE> 3047 * 3048 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 3049 * browser receives the invocation-request. 3050 * 3051 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 3052 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 3053 * {@code >} to ensure the Browser Function has run to completion. 3054 */ 3055 public static Script<String, JsonObject, Ret0> setReturnValue(RunTime.CallArgument newValue) 3056 { 3057 // Exception-Check(s) to ensure that if any parameters which are not declared as 3058 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 3059 3060 if (newValue == null) THROWS.throwNPE("newValue"); 3061 3062 final int webSocketID = 2023000 + counter++; 3063 final boolean[] optionals = { false, }; 3064 3065 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 3066 String requestJSON = WriteJSON.get( 3067 parameterTypes.get("setReturnValue"), 3068 parameterNames.get("setReturnValue"), 3069 optionals, webSocketID, 3070 "Debugger.setReturnValue", 3071 newValue 3072 ); 3073 3074 // This Remote Command does not have a Return-Value. 3075 return new Script<> 3076 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 3077 } 3078 3079 /** 3080 * Edits JavaScript source live. 3081 * 3082 * @param scriptId Id of the script to edit. 3083 * 3084 * @param scriptSource New content of the script. 3085 * 3086 * @param dryRun 3087 * If true the change will not actually be applied. Dry run may be used to get result 3088 * description without actually modifying the code. 3089 * <BR /><B>OPTIONAL</B> 3090 * 3091 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 3092 * {@link Ret5}></CODE> 3093 * 3094 * <BR /><BR />This {@link Script} may be <B STYLE='color:red'>executed</B> (using 3095 * {@link Script#exec()}), and a {@link Promise} returned. 3096 * 3097 * <BR /><BR />When the {@code Promise} is <B STYLE='color: red'>awaited</B> 3098 * (using {@link Promise#await()}), the {@code Ret5} will subsequently 3099 * be returned from that call. 3100 * 3101 * <BR /><BR />The <B STYLE='color: red'>returned</B> values are encapsulated 3102 * in an instance of <B>{@link Ret5}</B> 3103 * 3104 * <BR /><BR /><UL CLASS=JDUL> 3105 * <LI><CODE><B>Ret5.a:</B> {@link Debugger.CallFrame}[] (<B>callFrames</B>)</CODE> 3106 * <BR />New stack trace in case editing has happened while VM was stopped. 3107 * <BR /><BR /></LI> 3108 * <LI><CODE><B>Ret5.b:</B> Boolean (<B>stackChanged</B>)</CODE> 3109 * <BR />Whether current call stack was modified after applying the changes. 3110 * <BR /><BR /></LI> 3111 * <LI><CODE><B>Ret5.c:</B> {@link RunTime.StackTrace} (<B>asyncStackTrace</B>)</CODE> 3112 * <BR />Async stack trace, if any. 3113 * <BR /><BR /></LI> 3114 * <LI><CODE><B>Ret5.d:</B> {@link RunTime.StackTraceId} (<B>asyncStackTraceId</B>)</CODE> 3115 * <BR />Async stack trace, if any. 3116 * <BR /><BR /></LI> 3117 * <LI><CODE><B>Ret5.e:</B> {@link RunTime.ExceptionDetails} (<B>exceptionDetails</B>)</CODE> 3118 * <BR />Exception details if any. 3119 * </LI> 3120 * </UL> 3121 */ 3122 public static Script<String, JsonObject, Ret5<Debugger.CallFrame[], Boolean, RunTime.StackTrace, RunTime.StackTraceId, RunTime.ExceptionDetails>> 3123 setScriptSource(String scriptId, String scriptSource, Boolean dryRun) 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 (scriptId == null) THROWS.throwNPE("scriptId"); 3129 if (scriptSource == null) THROWS.throwNPE("scriptSource"); 3130 3131 final int webSocketID = 2024000 + counter++; 3132 final boolean[] optionals = { false, false, true, }; 3133 3134 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 3135 String requestJSON = WriteJSON.get( 3136 parameterTypes.get("setScriptSource"), 3137 parameterNames.get("setScriptSource"), 3138 optionals, webSocketID, 3139 "Debugger.setScriptSource", 3140 scriptId, scriptSource, dryRun 3141 ); 3142 3143 // 'JSON Binding' ... Converts Browser Response-JSON into Java-Type 'Ret5' 3144 Function<JsonObject, Ret5<Debugger.CallFrame[], Boolean, RunTime.StackTrace, RunTime.StackTraceId, RunTime.ExceptionDetails>> 3145 responseProcessor = (JsonObject jo) -> new Ret5<>( 3146 (jo.getJsonArray("callFrames") == null) 3147 ? null 3148 : RJArrIntoStream.objArr(jo.getJsonArray("callFrames"), null, 0, Debugger.CallFrame.class).toArray(Debugger.CallFrame[]::new), 3149 ReadBoxedJSON.getBoolean(jo, "stackChanged", true), 3150 ReadJSON.getObject(jo, "asyncStackTrace", RunTime.StackTrace.class, true, false), 3151 ReadJSON.getObject(jo, "asyncStackTraceId", RunTime.StackTraceId.class, true, false), 3152 ReadJSON.getObject(jo, "exceptionDetails", RunTime.ExceptionDetails.class, true, false) 3153 ); 3154 3155 return new Script<>(webSocketID, requestJSON, responseProcessor); 3156 } 3157 3158 /** 3159 * Makes page not interrupt on any pauses (breakpoint, exception, dom exception etc). 3160 * 3161 * @param skip New value for skip pauses state. 3162 * 3163 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 3164 * {@link Ret0}></CODE> 3165 * 3166 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 3167 * browser receives the invocation-request. 3168 * 3169 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 3170 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 3171 * {@code >} to ensure the Browser Function has run to completion. 3172 */ 3173 public static Script<String, JsonObject, Ret0> setSkipAllPauses(boolean skip) 3174 { 3175 final int webSocketID = 2025000 + counter++; 3176 final boolean[] optionals = { false, }; 3177 3178 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 3179 String requestJSON = WriteJSON.get( 3180 parameterTypes.get("setSkipAllPauses"), 3181 parameterNames.get("setSkipAllPauses"), 3182 optionals, webSocketID, 3183 "Debugger.setSkipAllPauses", 3184 skip 3185 ); 3186 3187 // This Remote Command does not have a Return-Value. 3188 return new Script<> 3189 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 3190 } 3191 3192 /** 3193 * Changes value of variable in a callframe. Object-based scopes are not supported and must be 3194 * mutated manually. 3195 * 3196 * @param scopeNumber 3197 * 0-based number of scope as was listed in scope chain. Only 'local', 'closure' and 'catch' 3198 * scope types are allowed. Other scopes could be manipulated manually. 3199 * 3200 * @param variableName Variable name. 3201 * 3202 * @param newValue New variable value. 3203 * 3204 * @param callFrameId Id of callframe that holds variable. 3205 * 3206 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 3207 * {@link Ret0}></CODE> 3208 * 3209 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 3210 * browser receives the invocation-request. 3211 * 3212 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 3213 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 3214 * {@code >} to ensure the Browser Function has run to completion. 3215 */ 3216 public static Script<String, JsonObject, Ret0> setVariableValue 3217 (int scopeNumber, String variableName, RunTime.CallArgument newValue, String callFrameId) 3218 { 3219 // Exception-Check(s) to ensure that if any parameters which are not declared as 3220 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 3221 3222 if (variableName == null) THROWS.throwNPE("variableName"); 3223 if (newValue == null) THROWS.throwNPE("newValue"); 3224 if (callFrameId == null) THROWS.throwNPE("callFrameId"); 3225 3226 final int webSocketID = 2026000 + counter++; 3227 final boolean[] optionals = { false, false, false, false, }; 3228 3229 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 3230 String requestJSON = WriteJSON.get( 3231 parameterTypes.get("setVariableValue"), 3232 parameterNames.get("setVariableValue"), 3233 optionals, webSocketID, 3234 "Debugger.setVariableValue", 3235 scopeNumber, variableName, newValue, callFrameId 3236 ); 3237 3238 // This Remote Command does not have a Return-Value. 3239 return new Script<> 3240 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 3241 } 3242 3243 /** 3244 * Steps into the function call. 3245 * 3246 * @param breakOnAsyncCall 3247 * Debugger will pause on the execution of the first async task which was scheduled 3248 * before next pause. 3249 * <BR /><B>OPTIONAL</B> 3250 * <BR /><B>EXPERIMENTAL</B> 3251 * 3252 * @param skipList The skipList specifies location ranges that should be skipped on step into. 3253 * <BR /><B>OPTIONAL</B> 3254 * <BR /><B>EXPERIMENTAL</B> 3255 * 3256 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 3257 * {@link Ret0}></CODE> 3258 * 3259 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 3260 * browser receives the invocation-request. 3261 * 3262 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 3263 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 3264 * {@code >} to ensure the Browser Function has run to completion. 3265 */ 3266 public static Script<String, JsonObject, Ret0> stepInto 3267 (Boolean breakOnAsyncCall, Debugger.LocationRange[] skipList) 3268 { 3269 final int webSocketID = 2027000 + counter++; 3270 final boolean[] optionals = { true, true, }; 3271 3272 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 3273 String requestJSON = WriteJSON.get( 3274 parameterTypes.get("stepInto"), 3275 parameterNames.get("stepInto"), 3276 optionals, webSocketID, 3277 "Debugger.stepInto", 3278 breakOnAsyncCall, skipList 3279 ); 3280 3281 // This Remote Command does not have a Return-Value. 3282 return new Script<> 3283 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 3284 } 3285 3286 /** 3287 * Steps out of the function call. 3288 * 3289 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 3290 * {@link Ret0}></CODE> 3291 * 3292 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 3293 * browser receives the invocation-request. 3294 * 3295 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 3296 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 3297 * {@code >} to ensure the Browser Function has run to completion. 3298 */ 3299 public static Script<String, JsonObject, Ret0> stepOut() 3300 { 3301 final int webSocketID = 2028000 + counter++; 3302 final boolean[] optionals = new boolean[0]; 3303 3304 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 3305 String requestJSON = WriteJSON.get( 3306 parameterTypes.get("stepOut"), 3307 parameterNames.get("stepOut"), 3308 optionals, webSocketID, 3309 "Debugger.stepOut" 3310 ); 3311 3312 // This Remote Command does not have a Return-Value. 3313 return new Script<> 3314 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 3315 } 3316 3317 /** 3318 * Steps over the statement. 3319 * 3320 * @param skipList The skipList specifies location ranges that should be skipped on step over. 3321 * <BR /><B>OPTIONAL</B> 3322 * <BR /><B>EXPERIMENTAL</B> 3323 * 3324 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 3325 * {@link Ret0}></CODE> 3326 * 3327 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 3328 * browser receives the invocation-request. 3329 * 3330 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 3331 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 3332 * {@code >} to ensure the Browser Function has run to completion. 3333 */ 3334 public static Script<String, JsonObject, Ret0> stepOver(Debugger.LocationRange[] skipList) 3335 { 3336 final int webSocketID = 2029000 + counter++; 3337 final boolean[] optionals = { true, }; 3338 3339 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 3340 String requestJSON = WriteJSON.get( 3341 parameterTypes.get("stepOver"), 3342 parameterNames.get("stepOver"), 3343 optionals, webSocketID, 3344 "Debugger.stepOver", 3345 (Object) skipList 3346 ); 3347 3348 // This Remote Command does not have a Return-Value. 3349 return new Script<> 3350 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 3351 } 3352 3353}