001package Torello.Browser.JavaScriptAPI; 002 003import java.util.*; 004import javax.json.*; 005import javax.json.stream.*; 006import java.io.*; 007 008import java.lang.reflect.Method; 009import java.lang.reflect.Parameter; 010import java.util.function.Function; 011 012import Torello.Browser.BrowserEvent; 013import Torello.Browser.BrowserAPI.*; 014import Torello.Browser.helper.*; 015 016import Torello.Java.Additional.*; 017import Torello.Java.JSON.*; 018 019import static Torello.Java.JSON.JFlag.*; 020 021import Torello.Java.StrCmpr; 022import Torello.JavaDoc.StaticFunctional; 023import Torello.JavaDoc.JDHeaderBackgroundImg; 024import Torello.JavaDoc.Excuse; 025 026/** 027 * <SPAN CLASS=COPIEDJDK><B>RunTime domain exposes JavaScript runtime by means of remote evaluation and mirror objects. 028 * Evaluation results are returned as mirror object that expose object type, string representation 029 * and unique identifier that can be used for further object reference. Original objects are 030 * maintained in memory unless they are either explicitly released or are released along with the 031 * other objects in their object group.</B></SPAN> 032 * 033 * <EMBED CLASS='external-html' DATA-FILE-ID=CODE_GEN_NOTE> 034 */ 035@StaticFunctional(Excused={"counter"}, Excuses={Excuse.CONFIGURATION}) 036@JDHeaderBackgroundImg(EmbedTagFileID="WOOD_PLANK_NOTE") 037public class RunTime 038{ 039 // ******************************************************************************************** 040 // ******************************************************************************************** 041 // Class Header Stuff 042 // ******************************************************************************************** 043 // ******************************************************************************************** 044 045 046 // No Pubic Constructors 047 private RunTime () { } 048 049 // These two Vector's are used by all the "Methods" exported by this class. java.lang.reflect 050 // is used to generate the JSON String's. It saves thousands of lines of Auto-Generated Code. 051 private static final Map<String, Vector<String>> parameterNames = new HashMap<>(); 052 private static final Map<String, Vector<Class<?>>> parameterTypes = new HashMap<>(); 053 054 // Some Methods do not take any parameters - for instance all the "enable()" and "disable()" 055 // I simply could not get ride of RAW-TYPES and UNCHECKED warnings... so there are now, 056 // offically, two empty-vectors. One for String's, and the other for Classes. 057 058 private static final Vector<String> EMPTY_VEC_STR = new Vector<>(); 059 private static final Vector<Class<?>> EMPTY_VEC_CLASS = new Vector<>(); 060 061 static 062 { 063 for (Method m : RunTime.class.getMethods()) 064 { 065 // This doesn't work! The parameter names are all "arg0" ... "argN" 066 // It works for java.lang.reflect.Field, BUT NOT java.lang.reflect.Parameter! 067 // 068 // Vector<String> parameterNamesList = new Vector<>(); -- NOPE! 069 070 Vector<Class<?>> parameterTypesList = new Vector<>(); 071 072 for (Parameter p : m.getParameters()) parameterTypesList.add(p.getType()); 073 074 parameterTypes.put( 075 m.getName(), 076 (parameterTypesList.size() > 0) ? parameterTypesList : EMPTY_VEC_CLASS 077 ); 078 } 079 } 080 081 static 082 { 083 Vector<String> v = null; 084 085 v = new Vector<String>(3); 086 parameterNames.put("awaitPromise", v); 087 Collections.addAll(v, new String[] 088 { "promiseObjectId", "returnByValue", "generatePreview", }); 089 090 v = new Vector<String>(13); 091 parameterNames.put("callFunctionOn", v); 092 Collections.addAll(v, new String[] 093 { "functionDeclaration", "objectId", "arguments", "silent", "returnByValue", "generatePreview", "userGesture", "awaitPromise", "executionContextId", "objectGroup", "throwOnSideEffect", "uniqueContextId", "serializationOptions", }); 094 095 v = new Vector<String>(4); 096 parameterNames.put("compileScript", v); 097 Collections.addAll(v, new String[] 098 { "expression", "sourceURL", "persistScript", "executionContextId", }); 099 100 parameterNames.put("disable", EMPTY_VEC_STR); 101 102 parameterNames.put("discardConsoleEntries", EMPTY_VEC_STR); 103 104 parameterNames.put("enable", EMPTY_VEC_STR); 105 106 v = new Vector<String>(16); 107 parameterNames.put("evaluate", v); 108 Collections.addAll(v, new String[] 109 { "expression", "objectGroup", "includeCommandLineAPI", "silent", "contextId", "returnByValue", "generatePreview", "userGesture", "awaitPromise", "throwOnSideEffect", "timeout", "disableBreaks", "replMode", "allowUnsafeEvalBlockedByCSP", "uniqueContextId", "serializationOptions", }); 110 111 parameterNames.put("getIsolateId", EMPTY_VEC_STR); 112 113 parameterNames.put("getHeapUsage", EMPTY_VEC_STR); 114 115 v = new Vector<String>(5); 116 parameterNames.put("getProperties", v); 117 Collections.addAll(v, new String[] 118 { "objectId", "ownProperties", "accessorPropertiesOnly", "generatePreview", "nonIndexedPropertiesOnly", }); 119 120 v = new Vector<String>(1); 121 parameterNames.put("globalLexicalScopeNames", v); 122 Collections.addAll(v, new String[] 123 { "executionContextId", }); 124 125 v = new Vector<String>(2); 126 parameterNames.put("queryObjects", v); 127 Collections.addAll(v, new String[] 128 { "prototypeObjectId", "objectGroup", }); 129 130 v = new Vector<String>(1); 131 parameterNames.put("releaseObject", v); 132 Collections.addAll(v, new String[] 133 { "objectId", }); 134 135 v = new Vector<String>(1); 136 parameterNames.put("releaseObjectGroup", v); 137 Collections.addAll(v, new String[] 138 { "objectGroup", }); 139 140 parameterNames.put("runIfWaitingForDebugger", EMPTY_VEC_STR); 141 142 v = new Vector<String>(8); 143 parameterNames.put("runScript", v); 144 Collections.addAll(v, new String[] 145 { "scriptId", "executionContextId", "objectGroup", "silent", "includeCommandLineAPI", "returnByValue", "generatePreview", "awaitPromise", }); 146 147 v = new Vector<String>(1); 148 parameterNames.put("setAsyncCallStackDepth", v); 149 Collections.addAll(v, new String[] 150 { "maxDepth", }); 151 152 v = new Vector<String>(1); 153 parameterNames.put("setCustomObjectFormatterEnabled", v); 154 Collections.addAll(v, new String[] 155 { "enabled", }); 156 157 v = new Vector<String>(1); 158 parameterNames.put("setMaxCallStackSizeToCapture", v); 159 Collections.addAll(v, new String[] 160 { "size", }); 161 162 parameterNames.put("terminateExecution", EMPTY_VEC_STR); 163 164 v = new Vector<String>(3); 165 parameterNames.put("addBinding", v); 166 Collections.addAll(v, new String[] 167 { "name", "executionContextId", "executionContextName", }); 168 169 v = new Vector<String>(1); 170 parameterNames.put("removeBinding", v); 171 Collections.addAll(v, new String[] 172 { "name", }); 173 174 v = new Vector<String>(1); 175 parameterNames.put("getExceptionDetails", v); 176 Collections.addAll(v, new String[] 177 { "errorObjectId", }); 178 } 179 180 181 // ******************************************************************************************** 182 // ******************************************************************************************** 183 // Types - Static Inner Classes 184 // ******************************************************************************************** 185 // ******************************************************************************************** 186 187 // public static class ScriptId => String 188 189 // public static class RemoteObjectId => String 190 191 // public static class UnserializableValue => String 192 193 // public static class ExecutionContextId => Integer 194 195 // public static class Timestamp => Number 196 197 // public static class TimeDelta => Number 198 199 // public static class UniqueDebuggerId => String 200 201 /** Represents options for serialization. Overrides {@code generatePreview} and {@code returnByValue}. */ 202 public static class SerializationOptions 203 extends BaseType 204 implements java.io.Serializable 205 { 206 /** For Object Serialization. java.io.Serializable */ 207 protected static final long serialVersionUID = 1; 208 209 public boolean[] optionals() 210 { return new boolean[] { false, true, true, }; } 211 212 /** <CODE>[No Description Provided by Google]</CODE> */ 213 public final String serialization; 214 215 /** 216 * Deep serialization depth. Default is full depth. Respected only in {@code deep} serialization mode. 217 * <BR /><B CLASS=Opt>OPTIONAL</B> 218 */ 219 public final Integer maxDepth; 220 221 /** 222 * Embedder-specific parameters. For example if connected to V8 in Chrome these control DOM 223 * serialization via {@code maxNodeDepth: integer} and {@code includeShadowTree: "none" | "open" | "all"}. 224 * Values can be only of type string or integer. 225 * <BR /><B CLASS=Opt>OPTIONAL</B> 226 */ 227 public final JsonObject additionalParameters; 228 229 /** 230 * Constructor 231 * 232 * @param serialization - 233 * <BR />Acceptable Values: ["deep", "json", "idOnly"] 234 * 235 * @param maxDepth Deep serialization depth. Default is full depth. Respected only in {@code deep} serialization mode. 236 * <BR /><B CLASS=Opt>OPTIONAL</B> 237 * 238 * @param additionalParameters 239 * Embedder-specific parameters. For example if connected to V8 in Chrome these control DOM 240 * serialization via {@code maxNodeDepth: integer} and {@code includeShadowTree: "none" | "open" | "all"}. 241 * Values can be only of type string or integer. 242 * <BR /><B CLASS=Opt>OPTIONAL</B> 243 */ 244 public SerializationOptions 245 (String serialization, Integer maxDepth, JsonObject additionalParameters) 246 { 247 // Exception-Check(s) to ensure that if any parameters which are not declared as 248 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 249 250 if (serialization == null) THROWS.throwNPE("serialization"); 251 252 // Exception-Check(s) to ensure that if any parameters which must adhere to a 253 // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw. 254 255 THROWS.checkIAE( 256 "serialization", serialization, 257 "deep", "json", "idOnly" 258 ); 259 260 this.serialization = serialization; 261 this.maxDepth = maxDepth; 262 this.additionalParameters = additionalParameters; 263 } 264 265 /** 266 * JSON Object Constructor 267 * @param jo A Json-Object having data about an instance of {@code 'SerializationOptions'}. 268 */ 269 public SerializationOptions (JsonObject jo) 270 { 271 this.serialization = ReadJSON.getString(jo, "serialization", false, true); 272 this.maxDepth = ReadBoxedJSON.getInteger(jo, "maxDepth", true); 273 this.additionalParameters = jo.getJsonObject("additionalParameters"); 274 } 275 276 277 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 278 public boolean equals(Object other) 279 { 280 if (this == other) return true; 281 if (other == null) return false; 282 if (other.getClass() != this.getClass()) return false; 283 284 SerializationOptions o = (SerializationOptions) other; 285 286 return 287 Objects.equals(this.serialization, o.serialization) 288 && Objects.equals(this.maxDepth, o.maxDepth) 289 && Objects.equals(this.additionalParameters, o.additionalParameters); 290 } 291 292 /** Generates a Hash-Code for {@code 'this'} instance */ 293 public int hashCode() 294 { 295 return 296 Objects.hashCode(this.serialization) 297 + Objects.hashCode(this.maxDepth) 298 + Objects.hashCode(this.additionalParameters); 299 } 300 } 301 302 /** Represents deep serialized value. */ 303 public static class DeepSerializedValue 304 extends BaseType 305 implements java.io.Serializable 306 { 307 /** For Object Serialization. java.io.Serializable */ 308 protected static final long serialVersionUID = 1; 309 310 public boolean[] optionals() 311 { return new boolean[] { false, true, true, true, }; } 312 313 /** <CODE>[No Description Provided by Google]</CODE> */ 314 public final String type; 315 316 /** 317 * <CODE>[No Description Provided by Google]</CODE> 318 * <BR /><B CLASS=Opt>OPTIONAL</B> 319 */ 320 public final JsonValue value; 321 322 /** 323 * <CODE>[No Description Provided by Google]</CODE> 324 * <BR /><B CLASS=Opt>OPTIONAL</B> 325 */ 326 public final String objectId; 327 328 /** 329 * Set if value reference met more then once during serialization. In such 330 * case, value is provided only to one of the serialized values. Unique 331 * per value in the scope of one CDP call. 332 * <BR /><B CLASS=Opt>OPTIONAL</B> 333 */ 334 public final Integer weakLocalObjectReference; 335 336 /** 337 * Constructor 338 * 339 * @param type - 340 * <BR />Acceptable Values: ["undefined", "null", "string", "number", "boolean", "bigint", "regexp", "date", "symbol", "array", "object", "function", "map", "set", "weakmap", "weakset", "error", "proxy", "promise", "typedarray", "arraybuffer", "node", "window", "generator"] 341 * 342 * @param value - 343 * <BR /><B CLASS=Opt>OPTIONAL</B> 344 * 345 * @param objectId - 346 * <BR /><B CLASS=Opt>OPTIONAL</B> 347 * 348 * @param weakLocalObjectReference 349 * Set if value reference met more then once during serialization. In such 350 * case, value is provided only to one of the serialized values. Unique 351 * per value in the scope of one CDP call. 352 * <BR /><B CLASS=Opt>OPTIONAL</B> 353 */ 354 public DeepSerializedValue 355 (String type, JsonValue value, String objectId, Integer weakLocalObjectReference) 356 { 357 // Exception-Check(s) to ensure that if any parameters which are not declared as 358 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 359 360 if (type == null) THROWS.throwNPE("type"); 361 362 // Exception-Check(s) to ensure that if any parameters which must adhere to a 363 // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw. 364 365 THROWS.checkIAE( 366 "type", type, 367 "undefined", "null", "string", "number", "boolean", "bigint", "regexp", "date", "symbol", "array", "object", "function", "map", "set", "weakmap", "weakset", "error", "proxy", "promise", "typedarray", "arraybuffer", "node", "window", "generator" 368 ); 369 370 this.type = type; 371 this.value = value; 372 this.objectId = objectId; 373 this.weakLocalObjectReference = weakLocalObjectReference; 374 } 375 376 /** 377 * JSON Object Constructor 378 * @param jo A Json-Object having data about an instance of {@code 'DeepSerializedValue'}. 379 */ 380 public DeepSerializedValue (JsonObject jo) 381 { 382 this.type = ReadJSON.getString(jo, "type", false, true); 383 this.value = jo.get("value"); 384 this.objectId = ReadJSON.getString(jo, "objectId", true, false); 385 this.weakLocalObjectReference = ReadBoxedJSON.getInteger(jo, "weakLocalObjectReference", true); 386 } 387 388 389 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 390 public boolean equals(Object other) 391 { 392 if (this == other) return true; 393 if (other == null) return false; 394 if (other.getClass() != this.getClass()) return false; 395 396 DeepSerializedValue o = (DeepSerializedValue) other; 397 398 return 399 Objects.equals(this.type, o.type) 400 && Objects.equals(this.value, o.value) 401 && Objects.equals(this.objectId, o.objectId) 402 && Objects.equals(this.weakLocalObjectReference, o.weakLocalObjectReference); 403 } 404 405 /** Generates a Hash-Code for {@code 'this'} instance */ 406 public int hashCode() 407 { 408 return 409 Objects.hashCode(this.type) 410 + Objects.hashCode(this.value) 411 + Objects.hashCode(this.objectId) 412 + Objects.hashCode(this.weakLocalObjectReference); 413 } 414 } 415 416 /** Mirror object referencing original JavaScript object. */ 417 public static class RemoteObject 418 extends BaseType 419 implements java.io.Serializable 420 { 421 /** For Object Serialization. java.io.Serializable */ 422 protected static final long serialVersionUID = 1; 423 424 public boolean[] optionals() 425 { return new boolean[] { false, true, true, true, true, true, true, true, true, true, }; } 426 427 /** Object type. */ 428 public final String type; 429 430 /** 431 * Object subtype hint. Specified for {@code object} type values only. 432 * NOTE: If you change anything here, make sure to also update 433 * {@code subtype} in {@code ObjectPreview} and {@code PropertyPreview} below. 434 * <BR /><B CLASS=Opt>OPTIONAL</B> 435 */ 436 public final String subtype; 437 438 /** 439 * Object class (constructor) name. Specified for {@code object} type values only. 440 * <BR /><B CLASS=Opt>OPTIONAL</B> 441 */ 442 public final String className; 443 444 /** 445 * Remote object value in case of primitive values or JSON values (if it was requested). 446 * <BR /><B CLASS=Opt>OPTIONAL</B> 447 */ 448 public final JsonValue value; 449 450 /** 451 * Primitive value which can not be JSON-stringified does not have {@code value}, but gets this 452 * property. 453 * <BR /><B CLASS=Opt>OPTIONAL</B> 454 */ 455 public final String unserializableValue; 456 457 /** 458 * String representation of the object. 459 * <BR /><B CLASS=Opt>OPTIONAL</B> 460 */ 461 public final String description; 462 463 /** 464 * Deep serialized value. 465 * <BR /><B CLASS=Opt>OPTIONAL</B> 466 <B CLASS=Exp>EXPERIMENTAL</B> 467 */ 468 public final RunTime.DeepSerializedValue deepSerializedValue; 469 470 /** 471 * Unique object identifier (for non-primitive values). 472 * <BR /><B CLASS=Opt>OPTIONAL</B> 473 */ 474 public final String objectId; 475 476 /** 477 * Preview containing abbreviated property values. Specified for {@code object} type values only. 478 * <BR /><B CLASS=Opt>OPTIONAL</B> 479 <B CLASS=Exp>EXPERIMENTAL</B> 480 */ 481 public final RunTime.ObjectPreview preview; 482 483 /** 484 * <CODE>[No Description Provided by Google]</CODE> 485 * <BR /><B CLASS=Opt>OPTIONAL</B> 486 <B CLASS=Exp>EXPERIMENTAL</B> 487 */ 488 public final RunTime.CustomPreview customPreview; 489 490 /** 491 * Constructor 492 * 493 * @param type Object type. 494 * <BR />Acceptable Values: ["object", "function", "undefined", "string", "number", "boolean", "symbol", "bigint"] 495 * 496 * @param subtype 497 * Object subtype hint. Specified for {@code object} type values only. 498 * NOTE: If you change anything here, make sure to also update 499 * {@code subtype} in {@code ObjectPreview} and {@code PropertyPreview} below. 500 * <BR />Acceptable Values: ["array", "null", "node", "regexp", "date", "map", "set", "weakmap", "weakset", "iterator", "generator", "error", "proxy", "promise", "typedarray", "arraybuffer", "dataview", "webassemblymemory", "wasmvalue"] 501 * <BR /><B CLASS=Opt>OPTIONAL</B> 502 * 503 * @param className Object class (constructor) name. Specified for {@code object} type values only. 504 * <BR /><B CLASS=Opt>OPTIONAL</B> 505 * 506 * @param value Remote object value in case of primitive values or JSON values (if it was requested). 507 * <BR /><B CLASS=Opt>OPTIONAL</B> 508 * 509 * @param unserializableValue 510 * Primitive value which can not be JSON-stringified does not have {@code value}, but gets this 511 * property. 512 * <BR /><B CLASS=Opt>OPTIONAL</B> 513 * 514 * @param description String representation of the object. 515 * <BR /><B CLASS=Opt>OPTIONAL</B> 516 * 517 * @param deepSerializedValue Deep serialized value. 518 * <BR /><B CLASS=Opt>OPTIONAL</B><B CLASS=Exp>EXPERIMENTAL</B> 519 * 520 * @param objectId Unique object identifier (for non-primitive values). 521 * <BR /><B CLASS=Opt>OPTIONAL</B> 522 * 523 * @param preview Preview containing abbreviated property values. Specified for {@code object} type values only. 524 * <BR /><B CLASS=Opt>OPTIONAL</B><B CLASS=Exp>EXPERIMENTAL</B> 525 * 526 * @param customPreview - 527 * <BR /><B CLASS=Opt>OPTIONAL</B><B CLASS=Exp>EXPERIMENTAL</B> 528 */ 529 public RemoteObject( 530 String type, String subtype, String className, JsonValue value, 531 String unserializableValue, String description, 532 RunTime.DeepSerializedValue deepSerializedValue, String objectId, 533 RunTime.ObjectPreview preview, RunTime.CustomPreview customPreview 534 ) 535 { 536 // Exception-Check(s) to ensure that if any parameters which are not declared as 537 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 538 539 if (type == null) THROWS.throwNPE("type"); 540 541 // Exception-Check(s) to ensure that if any parameters which must adhere to a 542 // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw. 543 544 THROWS.checkIAE( 545 "type", type, 546 "object", "function", "undefined", "string", "number", "boolean", "symbol", "bigint" 547 ); 548 THROWS.checkIAE( 549 "subtype", subtype, 550 "array", "null", "node", "regexp", "date", "map", "set", "weakmap", "weakset", "iterator", "generator", "error", "proxy", "promise", "typedarray", "arraybuffer", "dataview", "webassemblymemory", "wasmvalue" 551 ); 552 553 this.type = type; 554 this.subtype = subtype; 555 this.className = className; 556 this.value = value; 557 this.unserializableValue = unserializableValue; 558 this.description = description; 559 this.deepSerializedValue = deepSerializedValue; 560 this.objectId = objectId; 561 this.preview = preview; 562 this.customPreview = customPreview; 563 } 564 565 /** 566 * JSON Object Constructor 567 * @param jo A Json-Object having data about an instance of {@code 'RemoteObject'}. 568 */ 569 public RemoteObject (JsonObject jo) 570 { 571 this.type = ReadJSON.getString(jo, "type", false, true); 572 this.subtype = ReadJSON.getString(jo, "subtype", true, false); 573 this.className = ReadJSON.getString(jo, "className", true, false); 574 this.value = jo.get("value"); 575 this.unserializableValue = ReadJSON.getString(jo, "unserializableValue", true, false); 576 this.description = ReadJSON.getString(jo, "description", true, false); 577 this.deepSerializedValue = ReadJSON.getObject(jo, "deepSerializedValue", RunTime.DeepSerializedValue.class, true, false); 578 this.objectId = ReadJSON.getString(jo, "objectId", true, false); 579 this.preview = ReadJSON.getObject(jo, "preview", RunTime.ObjectPreview.class, true, false); 580 this.customPreview = ReadJSON.getObject(jo, "customPreview", RunTime.CustomPreview.class, true, false); 581 } 582 583 584 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 585 public boolean equals(Object other) 586 { 587 if (this == other) return true; 588 if (other == null) return false; 589 if (other.getClass() != this.getClass()) return false; 590 591 RemoteObject o = (RemoteObject) other; 592 593 return 594 Objects.equals(this.type, o.type) 595 && Objects.equals(this.subtype, o.subtype) 596 && Objects.equals(this.className, o.className) 597 && Objects.equals(this.value, o.value) 598 && Objects.equals(this.unserializableValue, o.unserializableValue) 599 && Objects.equals(this.description, o.description) 600 && Objects.equals(this.deepSerializedValue, o.deepSerializedValue) 601 && Objects.equals(this.objectId, o.objectId) 602 && Objects.equals(this.preview, o.preview) 603 && Objects.equals(this.customPreview, o.customPreview); 604 } 605 606 /** Generates a Hash-Code for {@code 'this'} instance */ 607 public int hashCode() 608 { 609 return 610 Objects.hashCode(this.type) 611 + Objects.hashCode(this.subtype) 612 + Objects.hashCode(this.className) 613 + Objects.hashCode(this.value) 614 + Objects.hashCode(this.unserializableValue) 615 + Objects.hashCode(this.description) 616 + this.deepSerializedValue.hashCode() 617 + Objects.hashCode(this.objectId) 618 + this.preview.hashCode() 619 + this.customPreview.hashCode(); 620 } 621 } 622 623 /** 624 * <CODE>[No Description Provided by Google]</CODE> 625 * <BR /><B CLASS=Exp>EXPERIMENTAL</B> 626 */ 627 public static class CustomPreview 628 extends BaseType 629 implements java.io.Serializable 630 { 631 /** For Object Serialization. java.io.Serializable */ 632 protected static final long serialVersionUID = 1; 633 634 public boolean[] optionals() 635 { return new boolean[] { false, true, }; } 636 637 /** 638 * The JSON-stringified result of formatter.header(object, config) call. 639 * It contains json ML array that represents RemoteObject. 640 */ 641 public final String header; 642 643 /** 644 * If formatter returns true as a result of formatter.hasBody call then bodyGetterId will 645 * contain RemoteObjectId for the function that returns result of formatter.body(object, config) call. 646 * The result value is json ML array. 647 * <BR /><B CLASS=Opt>OPTIONAL</B> 648 */ 649 public final String bodyGetterId; 650 651 /** 652 * Constructor 653 * 654 * @param header 655 * The JSON-stringified result of formatter.header(object, config) call. 656 * It contains json ML array that represents RemoteObject. 657 * 658 * @param bodyGetterId 659 * If formatter returns true as a result of formatter.hasBody call then bodyGetterId will 660 * contain RemoteObjectId for the function that returns result of formatter.body(object, config) call. 661 * The result value is json ML array. 662 * <BR /><B CLASS=Opt>OPTIONAL</B> 663 */ 664 public CustomPreview(String header, String bodyGetterId) 665 { 666 // Exception-Check(s) to ensure that if any parameters which are not declared as 667 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 668 669 if (header == null) THROWS.throwNPE("header"); 670 671 this.header = header; 672 this.bodyGetterId = bodyGetterId; 673 } 674 675 /** 676 * JSON Object Constructor 677 * @param jo A Json-Object having data about an instance of {@code 'CustomPreview'}. 678 */ 679 public CustomPreview (JsonObject jo) 680 { 681 this.header = ReadJSON.getString(jo, "header", false, true); 682 this.bodyGetterId = ReadJSON.getString(jo, "bodyGetterId", true, false); 683 } 684 685 686 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 687 public boolean equals(Object other) 688 { 689 if (this == other) return true; 690 if (other == null) return false; 691 if (other.getClass() != this.getClass()) return false; 692 693 CustomPreview o = (CustomPreview) other; 694 695 return 696 Objects.equals(this.header, o.header) 697 && Objects.equals(this.bodyGetterId, o.bodyGetterId); 698 } 699 700 /** Generates a Hash-Code for {@code 'this'} instance */ 701 public int hashCode() 702 { 703 return 704 Objects.hashCode(this.header) 705 + Objects.hashCode(this.bodyGetterId); 706 } 707 } 708 709 /** 710 * Object containing abbreviated remote object value. 711 * <BR /><B CLASS=Exp>EXPERIMENTAL</B> 712 */ 713 public static class ObjectPreview 714 extends BaseType 715 implements java.io.Serializable 716 { 717 /** For Object Serialization. java.io.Serializable */ 718 protected static final long serialVersionUID = 1; 719 720 public boolean[] optionals() 721 { return new boolean[] { false, true, true, false, false, true, }; } 722 723 /** Object type. */ 724 public final String type; 725 726 /** 727 * Object subtype hint. Specified for {@code object} type values only. 728 * <BR /><B CLASS=Opt>OPTIONAL</B> 729 */ 730 public final String subtype; 731 732 /** 733 * String representation of the object. 734 * <BR /><B CLASS=Opt>OPTIONAL</B> 735 */ 736 public final String description; 737 738 /** True iff some of the properties or entries of the original object did not fit. */ 739 public final boolean overflow; 740 741 /** List of the properties. */ 742 public final RunTime.PropertyPreview[] properties; 743 744 /** 745 * List of the entries. Specified for {@code map} and {@code set} subtype values only. 746 * <BR /><B CLASS=Opt>OPTIONAL</B> 747 */ 748 public final RunTime.EntryPreview[] entries; 749 750 /** 751 * Constructor 752 * 753 * @param type Object type. 754 * <BR />Acceptable Values: ["object", "function", "undefined", "string", "number", "boolean", "symbol", "bigint"] 755 * 756 * @param subtype Object subtype hint. Specified for {@code object} type values only. 757 * <BR />Acceptable Values: ["array", "null", "node", "regexp", "date", "map", "set", "weakmap", "weakset", "iterator", "generator", "error", "proxy", "promise", "typedarray", "arraybuffer", "dataview", "webassemblymemory", "wasmvalue"] 758 * <BR /><B CLASS=Opt>OPTIONAL</B> 759 * 760 * @param description String representation of the object. 761 * <BR /><B CLASS=Opt>OPTIONAL</B> 762 * 763 * @param overflow True iff some of the properties or entries of the original object did not fit. 764 * 765 * @param properties List of the properties. 766 * 767 * @param entries List of the entries. Specified for {@code map} and {@code set} subtype values only. 768 * <BR /><B CLASS=Opt>OPTIONAL</B> 769 */ 770 public ObjectPreview( 771 String type, String subtype, String description, boolean overflow, 772 RunTime.PropertyPreview[] properties, RunTime.EntryPreview[] entries 773 ) 774 { 775 // Exception-Check(s) to ensure that if any parameters which are not declared as 776 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 777 778 if (type == null) THROWS.throwNPE("type"); 779 if (properties == null) THROWS.throwNPE("properties"); 780 781 // Exception-Check(s) to ensure that if any parameters which must adhere to a 782 // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw. 783 784 THROWS.checkIAE( 785 "type", type, 786 "object", "function", "undefined", "string", "number", "boolean", "symbol", "bigint" 787 ); 788 THROWS.checkIAE( 789 "subtype", subtype, 790 "array", "null", "node", "regexp", "date", "map", "set", "weakmap", "weakset", "iterator", "generator", "error", "proxy", "promise", "typedarray", "arraybuffer", "dataview", "webassemblymemory", "wasmvalue" 791 ); 792 793 this.type = type; 794 this.subtype = subtype; 795 this.description = description; 796 this.overflow = overflow; 797 this.properties = properties; 798 this.entries = entries; 799 } 800 801 /** 802 * JSON Object Constructor 803 * @param jo A Json-Object having data about an instance of {@code 'ObjectPreview'}. 804 */ 805 public ObjectPreview (JsonObject jo) 806 { 807 this.type = ReadJSON.getString(jo, "type", false, true); 808 this.subtype = ReadJSON.getString(jo, "subtype", true, false); 809 this.description = ReadJSON.getString(jo, "description", true, false); 810 this.overflow = ReadPrimJSON.getBoolean(jo, "overflow"); 811 this.properties = (jo.getJsonArray("properties") == null) 812 ? null 813 : RJArrIntoStream.objArr(jo.getJsonArray("properties"), null, 0, RunTime.PropertyPreview.class).toArray(RunTime.PropertyPreview[]::new); 814 815 this.entries = (jo.getJsonArray("entries") == null) 816 ? null 817 : RJArrIntoStream.objArr(jo.getJsonArray("entries"), null, 0, RunTime.EntryPreview.class).toArray(RunTime.EntryPreview[]::new); 818 819 } 820 821 822 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 823 public boolean equals(Object other) 824 { 825 if (this == other) return true; 826 if (other == null) return false; 827 if (other.getClass() != this.getClass()) return false; 828 829 ObjectPreview o = (ObjectPreview) other; 830 831 return 832 Objects.equals(this.type, o.type) 833 && Objects.equals(this.subtype, o.subtype) 834 && Objects.equals(this.description, o.description) 835 && (this.overflow == o.overflow) 836 && Arrays.deepEquals(this.properties, o.properties) 837 && Arrays.deepEquals(this.entries, o.entries); 838 } 839 840 /** Generates a Hash-Code for {@code 'this'} instance */ 841 public int hashCode() 842 { 843 return 844 Objects.hashCode(this.type) 845 + Objects.hashCode(this.subtype) 846 + Objects.hashCode(this.description) 847 + (this.overflow ? 1 : 0) 848 + Arrays.deepHashCode(this.properties) 849 + Arrays.deepHashCode(this.entries); 850 } 851 } 852 853 /** 854 * <CODE>[No Description Provided by Google]</CODE> 855 * <BR /><B CLASS=Exp>EXPERIMENTAL</B> 856 */ 857 public static class PropertyPreview 858 extends BaseType 859 implements java.io.Serializable 860 { 861 /** For Object Serialization. java.io.Serializable */ 862 protected static final long serialVersionUID = 1; 863 864 public boolean[] optionals() 865 { return new boolean[] { false, false, true, true, true, }; } 866 867 /** Property name. */ 868 public final String name; 869 870 /** Object type. Accessor means that the property itself is an accessor property. */ 871 public final String type; 872 873 /** 874 * User-friendly property value string. 875 * <BR /><B CLASS=Opt>OPTIONAL</B> 876 */ 877 public final String value; 878 879 /** 880 * Nested value preview. 881 * <BR /><B CLASS=Opt>OPTIONAL</B> 882 */ 883 public final RunTime.ObjectPreview valuePreview; 884 885 /** 886 * Object subtype hint. Specified for {@code object} type values only. 887 * <BR /><B CLASS=Opt>OPTIONAL</B> 888 */ 889 public final String subtype; 890 891 /** 892 * Constructor 893 * 894 * @param name Property name. 895 * 896 * @param type Object type. Accessor means that the property itself is an accessor property. 897 * <BR />Acceptable Values: ["object", "function", "undefined", "string", "number", "boolean", "symbol", "accessor", "bigint"] 898 * 899 * @param value User-friendly property value string. 900 * <BR /><B CLASS=Opt>OPTIONAL</B> 901 * 902 * @param valuePreview Nested value preview. 903 * <BR /><B CLASS=Opt>OPTIONAL</B> 904 * 905 * @param subtype Object subtype hint. Specified for {@code object} type values only. 906 * <BR />Acceptable Values: ["array", "null", "node", "regexp", "date", "map", "set", "weakmap", "weakset", "iterator", "generator", "error", "proxy", "promise", "typedarray", "arraybuffer", "dataview", "webassemblymemory", "wasmvalue"] 907 * <BR /><B CLASS=Opt>OPTIONAL</B> 908 */ 909 public PropertyPreview( 910 String name, String type, String value, RunTime.ObjectPreview valuePreview, 911 String subtype 912 ) 913 { 914 // Exception-Check(s) to ensure that if any parameters which are not declared as 915 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 916 917 if (name == null) THROWS.throwNPE("name"); 918 if (type == null) THROWS.throwNPE("type"); 919 920 // Exception-Check(s) to ensure that if any parameters which must adhere to a 921 // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw. 922 923 THROWS.checkIAE( 924 "type", type, 925 "object", "function", "undefined", "string", "number", "boolean", "symbol", "accessor", "bigint" 926 ); 927 THROWS.checkIAE( 928 "subtype", subtype, 929 "array", "null", "node", "regexp", "date", "map", "set", "weakmap", "weakset", "iterator", "generator", "error", "proxy", "promise", "typedarray", "arraybuffer", "dataview", "webassemblymemory", "wasmvalue" 930 ); 931 932 this.name = name; 933 this.type = type; 934 this.value = value; 935 this.valuePreview = valuePreview; 936 this.subtype = subtype; 937 } 938 939 /** 940 * JSON Object Constructor 941 * @param jo A Json-Object having data about an instance of {@code 'PropertyPreview'}. 942 */ 943 public PropertyPreview (JsonObject jo) 944 { 945 this.name = ReadJSON.getString(jo, "name", false, true); 946 this.type = ReadJSON.getString(jo, "type", false, true); 947 this.value = ReadJSON.getString(jo, "value", true, false); 948 this.valuePreview = ReadJSON.getObject(jo, "valuePreview", RunTime.ObjectPreview.class, true, false); 949 this.subtype = ReadJSON.getString(jo, "subtype", true, false); 950 } 951 952 953 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 954 public boolean equals(Object other) 955 { 956 if (this == other) return true; 957 if (other == null) return false; 958 if (other.getClass() != this.getClass()) return false; 959 960 PropertyPreview o = (PropertyPreview) other; 961 962 return 963 Objects.equals(this.name, o.name) 964 && Objects.equals(this.type, o.type) 965 && Objects.equals(this.value, o.value) 966 && Objects.equals(this.valuePreview, o.valuePreview) 967 && Objects.equals(this.subtype, o.subtype); 968 } 969 970 /** Generates a Hash-Code for {@code 'this'} instance */ 971 public int hashCode() 972 { 973 return 974 Objects.hashCode(this.name) 975 + Objects.hashCode(this.type) 976 + Objects.hashCode(this.value) 977 + this.valuePreview.hashCode() 978 + Objects.hashCode(this.subtype); 979 } 980 } 981 982 /** 983 * <CODE>[No Description Provided by Google]</CODE> 984 * <BR /><B CLASS=Exp>EXPERIMENTAL</B> 985 */ 986 public static class EntryPreview 987 extends BaseType 988 implements java.io.Serializable 989 { 990 /** For Object Serialization. java.io.Serializable */ 991 protected static final long serialVersionUID = 1; 992 993 public boolean[] optionals() 994 { return new boolean[] { true, false, }; } 995 996 /** 997 * Preview of the key. Specified for map-like collection entries. 998 * <BR /><B CLASS=Opt>OPTIONAL</B> 999 */ 1000 public final RunTime.ObjectPreview key; 1001 1002 /** Preview of the value. */ 1003 public final RunTime.ObjectPreview value; 1004 1005 /** 1006 * Constructor 1007 * 1008 * @param key Preview of the key. Specified for map-like collection entries. 1009 * <BR /><B CLASS=Opt>OPTIONAL</B> 1010 * 1011 * @param value Preview of the value. 1012 */ 1013 public EntryPreview(RunTime.ObjectPreview key, RunTime.ObjectPreview value) 1014 { 1015 // Exception-Check(s) to ensure that if any parameters which are not declared as 1016 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 1017 1018 if (value == null) THROWS.throwNPE("value"); 1019 1020 this.key = key; 1021 this.value = value; 1022 } 1023 1024 /** 1025 * JSON Object Constructor 1026 * @param jo A Json-Object having data about an instance of {@code 'EntryPreview'}. 1027 */ 1028 public EntryPreview (JsonObject jo) 1029 { 1030 this.key = ReadJSON.getObject(jo, "key", RunTime.ObjectPreview.class, true, false); 1031 this.value = ReadJSON.getObject(jo, "value", RunTime.ObjectPreview.class, false, true); 1032 } 1033 1034 1035 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 1036 public boolean equals(Object other) 1037 { 1038 if (this == other) return true; 1039 if (other == null) return false; 1040 if (other.getClass() != this.getClass()) return false; 1041 1042 EntryPreview o = (EntryPreview) other; 1043 1044 return 1045 Objects.equals(this.key, o.key) 1046 && Objects.equals(this.value, o.value); 1047 } 1048 1049 /** Generates a Hash-Code for {@code 'this'} instance */ 1050 public int hashCode() 1051 { 1052 return 1053 this.key.hashCode() 1054 + this.value.hashCode(); 1055 } 1056 } 1057 1058 /** Object property descriptor. */ 1059 public static class PropertyDescriptor 1060 extends BaseType 1061 implements java.io.Serializable 1062 { 1063 /** For Object Serialization. java.io.Serializable */ 1064 protected static final long serialVersionUID = 1; 1065 1066 public boolean[] optionals() 1067 { return new boolean[] { false, true, true, true, true, false, false, true, true, true, }; } 1068 1069 /** Property name or symbol description. */ 1070 public final String name; 1071 1072 /** 1073 * The value associated with the property. 1074 * <BR /><B CLASS=Opt>OPTIONAL</B> 1075 */ 1076 public final RunTime.RemoteObject value; 1077 1078 /** 1079 * True if the value associated with the property may be changed (data descriptors only). 1080 * <BR /><B CLASS=Opt>OPTIONAL</B> 1081 */ 1082 public final Boolean writable; 1083 1084 /** 1085 * A function which serves as a getter for the property, or {@code undefined} if there is no getter 1086 * (accessor descriptors only). 1087 * <BR /><B CLASS=Opt>OPTIONAL</B> 1088 */ 1089 public final RunTime.RemoteObject get; 1090 1091 /** 1092 * A function which serves as a setter for the property, or {@code undefined} if there is no setter 1093 * (accessor descriptors only). 1094 * <BR /><B CLASS=Opt>OPTIONAL</B> 1095 */ 1096 public final RunTime.RemoteObject set; 1097 1098 /** 1099 * True if the type of this property descriptor may be changed and if the property may be 1100 * deleted from the corresponding object. 1101 */ 1102 public final boolean configurable; 1103 1104 /** 1105 * True if this property shows up during enumeration of the properties on the corresponding 1106 * object. 1107 */ 1108 public final boolean enumerable; 1109 1110 /** 1111 * True if the result was thrown during the evaluation. 1112 * <BR /><B CLASS=Opt>OPTIONAL</B> 1113 */ 1114 public final Boolean wasThrown; 1115 1116 /** 1117 * True if the property is owned for the object. 1118 * <BR /><B CLASS=Opt>OPTIONAL</B> 1119 */ 1120 public final Boolean isOwn; 1121 1122 /** 1123 * Property symbol object, if the property is of the {@code symbol} type. 1124 * <BR /><B CLASS=Opt>OPTIONAL</B> 1125 */ 1126 public final RunTime.RemoteObject symbol; 1127 1128 /** 1129 * Constructor 1130 * 1131 * @param name Property name or symbol description. 1132 * 1133 * @param value The value associated with the property. 1134 * <BR /><B CLASS=Opt>OPTIONAL</B> 1135 * 1136 * @param writable True if the value associated with the property may be changed (data descriptors only). 1137 * <BR /><B CLASS=Opt>OPTIONAL</B> 1138 * 1139 * @param get 1140 * A function which serves as a getter for the property, or {@code undefined} if there is no getter 1141 * (accessor descriptors only). 1142 * <BR /><B CLASS=Opt>OPTIONAL</B> 1143 * 1144 * @param set 1145 * A function which serves as a setter for the property, or {@code undefined} if there is no setter 1146 * (accessor descriptors only). 1147 * <BR /><B CLASS=Opt>OPTIONAL</B> 1148 * 1149 * @param configurable 1150 * True if the type of this property descriptor may be changed and if the property may be 1151 * deleted from the corresponding object. 1152 * 1153 * @param enumerable 1154 * True if this property shows up during enumeration of the properties on the corresponding 1155 * object. 1156 * 1157 * @param wasThrown True if the result was thrown during the evaluation. 1158 * <BR /><B CLASS=Opt>OPTIONAL</B> 1159 * 1160 * @param isOwn True if the property is owned for the object. 1161 * <BR /><B CLASS=Opt>OPTIONAL</B> 1162 * 1163 * @param symbol Property symbol object, if the property is of the {@code symbol} type. 1164 * <BR /><B CLASS=Opt>OPTIONAL</B> 1165 */ 1166 public PropertyDescriptor( 1167 String name, RunTime.RemoteObject value, Boolean writable, RunTime.RemoteObject get, 1168 RunTime.RemoteObject set, boolean configurable, boolean enumerable, 1169 Boolean wasThrown, Boolean isOwn, RunTime.RemoteObject symbol 1170 ) 1171 { 1172 // Exception-Check(s) to ensure that if any parameters which are not declared as 1173 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 1174 1175 if (name == null) THROWS.throwNPE("name"); 1176 1177 this.name = name; 1178 this.value = value; 1179 this.writable = writable; 1180 this.get = get; 1181 this.set = set; 1182 this.configurable = configurable; 1183 this.enumerable = enumerable; 1184 this.wasThrown = wasThrown; 1185 this.isOwn = isOwn; 1186 this.symbol = symbol; 1187 } 1188 1189 /** 1190 * JSON Object Constructor 1191 * @param jo A Json-Object having data about an instance of {@code 'PropertyDescriptor'}. 1192 */ 1193 public PropertyDescriptor (JsonObject jo) 1194 { 1195 this.name = ReadJSON.getString(jo, "name", false, true); 1196 this.value = ReadJSON.getObject(jo, "value", RunTime.RemoteObject.class, true, false); 1197 this.writable = ReadBoxedJSON.getBoolean(jo, "writable", true); 1198 this.get = ReadJSON.getObject(jo, "get", RunTime.RemoteObject.class, true, false); 1199 this.set = ReadJSON.getObject(jo, "set", RunTime.RemoteObject.class, true, false); 1200 this.configurable = ReadPrimJSON.getBoolean(jo, "configurable"); 1201 this.enumerable = ReadPrimJSON.getBoolean(jo, "enumerable"); 1202 this.wasThrown = ReadBoxedJSON.getBoolean(jo, "wasThrown", true); 1203 this.isOwn = ReadBoxedJSON.getBoolean(jo, "isOwn", true); 1204 this.symbol = ReadJSON.getObject(jo, "symbol", RunTime.RemoteObject.class, true, false); 1205 } 1206 1207 1208 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 1209 public boolean equals(Object other) 1210 { 1211 if (this == other) return true; 1212 if (other == null) return false; 1213 if (other.getClass() != this.getClass()) return false; 1214 1215 PropertyDescriptor o = (PropertyDescriptor) other; 1216 1217 return 1218 Objects.equals(this.name, o.name) 1219 && Objects.equals(this.value, o.value) 1220 && Objects.equals(this.writable, o.writable) 1221 && Objects.equals(this.get, o.get) 1222 && Objects.equals(this.set, o.set) 1223 && (this.configurable == o.configurable) 1224 && (this.enumerable == o.enumerable) 1225 && Objects.equals(this.wasThrown, o.wasThrown) 1226 && Objects.equals(this.isOwn, o.isOwn) 1227 && Objects.equals(this.symbol, o.symbol); 1228 } 1229 1230 /** Generates a Hash-Code for {@code 'this'} instance */ 1231 public int hashCode() 1232 { 1233 return 1234 Objects.hashCode(this.name) 1235 + this.value.hashCode() 1236 + Objects.hashCode(this.writable) 1237 + this.get.hashCode() 1238 + this.set.hashCode() 1239 + (this.configurable ? 1 : 0) 1240 + (this.enumerable ? 1 : 0) 1241 + Objects.hashCode(this.wasThrown) 1242 + Objects.hashCode(this.isOwn) 1243 + this.symbol.hashCode(); 1244 } 1245 } 1246 1247 /** Object internal property descriptor. This property isn't normally visible in JavaScript code. */ 1248 public static class InternalPropertyDescriptor 1249 extends BaseType 1250 implements java.io.Serializable 1251 { 1252 /** For Object Serialization. java.io.Serializable */ 1253 protected static final long serialVersionUID = 1; 1254 1255 public boolean[] optionals() 1256 { return new boolean[] { false, true, }; } 1257 1258 /** Conventional property name. */ 1259 public final String name; 1260 1261 /** 1262 * The value associated with the property. 1263 * <BR /><B CLASS=Opt>OPTIONAL</B> 1264 */ 1265 public final RunTime.RemoteObject value; 1266 1267 /** 1268 * Constructor 1269 * 1270 * @param name Conventional property name. 1271 * 1272 * @param value The value associated with the property. 1273 * <BR /><B CLASS=Opt>OPTIONAL</B> 1274 */ 1275 public InternalPropertyDescriptor(String name, RunTime.RemoteObject value) 1276 { 1277 // Exception-Check(s) to ensure that if any parameters which are not declared as 1278 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 1279 1280 if (name == null) THROWS.throwNPE("name"); 1281 1282 this.name = name; 1283 this.value = value; 1284 } 1285 1286 /** 1287 * JSON Object Constructor 1288 * @param jo A Json-Object having data about an instance of {@code 'InternalPropertyDescriptor'}. 1289 */ 1290 public InternalPropertyDescriptor (JsonObject jo) 1291 { 1292 this.name = ReadJSON.getString(jo, "name", false, true); 1293 this.value = ReadJSON.getObject(jo, "value", RunTime.RemoteObject.class, true, false); 1294 } 1295 1296 1297 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 1298 public boolean equals(Object other) 1299 { 1300 if (this == other) return true; 1301 if (other == null) return false; 1302 if (other.getClass() != this.getClass()) return false; 1303 1304 InternalPropertyDescriptor o = (InternalPropertyDescriptor) other; 1305 1306 return 1307 Objects.equals(this.name, o.name) 1308 && Objects.equals(this.value, o.value); 1309 } 1310 1311 /** Generates a Hash-Code for {@code 'this'} instance */ 1312 public int hashCode() 1313 { 1314 return 1315 Objects.hashCode(this.name) 1316 + this.value.hashCode(); 1317 } 1318 } 1319 1320 /** 1321 * Object private field descriptor. 1322 * <BR /><B CLASS=Exp>EXPERIMENTAL</B> 1323 */ 1324 public static class PrivatePropertyDescriptor 1325 extends BaseType 1326 implements java.io.Serializable 1327 { 1328 /** For Object Serialization. java.io.Serializable */ 1329 protected static final long serialVersionUID = 1; 1330 1331 public boolean[] optionals() 1332 { return new boolean[] { false, true, true, true, }; } 1333 1334 /** Private property name. */ 1335 public final String name; 1336 1337 /** 1338 * The value associated with the private property. 1339 * <BR /><B CLASS=Opt>OPTIONAL</B> 1340 */ 1341 public final RunTime.RemoteObject value; 1342 1343 /** 1344 * A function which serves as a getter for the private property, 1345 * or {@code undefined} if there is no getter (accessor descriptors only). 1346 * <BR /><B CLASS=Opt>OPTIONAL</B> 1347 */ 1348 public final RunTime.RemoteObject get; 1349 1350 /** 1351 * A function which serves as a setter for the private property, 1352 * or {@code undefined} if there is no setter (accessor descriptors only). 1353 * <BR /><B CLASS=Opt>OPTIONAL</B> 1354 */ 1355 public final RunTime.RemoteObject set; 1356 1357 /** 1358 * Constructor 1359 * 1360 * @param name Private property name. 1361 * 1362 * @param value The value associated with the private property. 1363 * <BR /><B CLASS=Opt>OPTIONAL</B> 1364 * 1365 * @param get 1366 * A function which serves as a getter for the private property, 1367 * or {@code undefined} if there is no getter (accessor descriptors only). 1368 * <BR /><B CLASS=Opt>OPTIONAL</B> 1369 * 1370 * @param set 1371 * A function which serves as a setter for the private property, 1372 * or {@code undefined} if there is no setter (accessor descriptors only). 1373 * <BR /><B CLASS=Opt>OPTIONAL</B> 1374 */ 1375 public PrivatePropertyDescriptor( 1376 String name, RunTime.RemoteObject value, RunTime.RemoteObject get, 1377 RunTime.RemoteObject set 1378 ) 1379 { 1380 // Exception-Check(s) to ensure that if any parameters which are not declared as 1381 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 1382 1383 if (name == null) THROWS.throwNPE("name"); 1384 1385 this.name = name; 1386 this.value = value; 1387 this.get = get; 1388 this.set = set; 1389 } 1390 1391 /** 1392 * JSON Object Constructor 1393 * @param jo A Json-Object having data about an instance of {@code 'PrivatePropertyDescriptor'}. 1394 */ 1395 public PrivatePropertyDescriptor (JsonObject jo) 1396 { 1397 this.name = ReadJSON.getString(jo, "name", false, true); 1398 this.value = ReadJSON.getObject(jo, "value", RunTime.RemoteObject.class, true, false); 1399 this.get = ReadJSON.getObject(jo, "get", RunTime.RemoteObject.class, true, false); 1400 this.set = ReadJSON.getObject(jo, "set", RunTime.RemoteObject.class, true, false); 1401 } 1402 1403 1404 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 1405 public boolean equals(Object other) 1406 { 1407 if (this == other) return true; 1408 if (other == null) return false; 1409 if (other.getClass() != this.getClass()) return false; 1410 1411 PrivatePropertyDescriptor o = (PrivatePropertyDescriptor) other; 1412 1413 return 1414 Objects.equals(this.name, o.name) 1415 && Objects.equals(this.value, o.value) 1416 && Objects.equals(this.get, o.get) 1417 && Objects.equals(this.set, o.set); 1418 } 1419 1420 /** Generates a Hash-Code for {@code 'this'} instance */ 1421 public int hashCode() 1422 { 1423 return 1424 Objects.hashCode(this.name) 1425 + this.value.hashCode() 1426 + this.get.hashCode() 1427 + this.set.hashCode(); 1428 } 1429 } 1430 1431 /** 1432 * Represents function call argument. Either remote object id {@code objectId}, primitive {@code value}, 1433 * unserializable primitive value or neither of (for undefined) them should be specified. 1434 */ 1435 public static class CallArgument 1436 extends BaseType 1437 implements java.io.Serializable 1438 { 1439 /** For Object Serialization. java.io.Serializable */ 1440 protected static final long serialVersionUID = 1; 1441 1442 public boolean[] optionals() 1443 { return new boolean[] { true, true, true, }; } 1444 1445 /** 1446 * Primitive value or serializable javascript object. 1447 * <BR /><B CLASS=Opt>OPTIONAL</B> 1448 */ 1449 public final JsonValue value; 1450 1451 /** 1452 * Primitive value which can not be JSON-stringified. 1453 * <BR /><B CLASS=Opt>OPTIONAL</B> 1454 */ 1455 public final String unserializableValue; 1456 1457 /** 1458 * Remote object handle. 1459 * <BR /><B CLASS=Opt>OPTIONAL</B> 1460 */ 1461 public final String objectId; 1462 1463 /** 1464 * Constructor 1465 * 1466 * @param value Primitive value or serializable javascript object. 1467 * <BR /><B CLASS=Opt>OPTIONAL</B> 1468 * 1469 * @param unserializableValue Primitive value which can not be JSON-stringified. 1470 * <BR /><B CLASS=Opt>OPTIONAL</B> 1471 * 1472 * @param objectId Remote object handle. 1473 * <BR /><B CLASS=Opt>OPTIONAL</B> 1474 */ 1475 public CallArgument(JsonValue value, String unserializableValue, String objectId) 1476 { 1477 this.value = value; 1478 this.unserializableValue = unserializableValue; 1479 this.objectId = objectId; 1480 } 1481 1482 /** 1483 * JSON Object Constructor 1484 * @param jo A Json-Object having data about an instance of {@code 'CallArgument'}. 1485 */ 1486 public CallArgument (JsonObject jo) 1487 { 1488 this.value = jo.get("value"); 1489 this.unserializableValue = ReadJSON.getString(jo, "unserializableValue", true, false); 1490 this.objectId = ReadJSON.getString(jo, "objectId", true, false); 1491 } 1492 1493 1494 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 1495 public boolean equals(Object other) 1496 { 1497 if (this == other) return true; 1498 if (other == null) return false; 1499 if (other.getClass() != this.getClass()) return false; 1500 1501 CallArgument o = (CallArgument) other; 1502 1503 return 1504 Objects.equals(this.value, o.value) 1505 && Objects.equals(this.unserializableValue, o.unserializableValue) 1506 && Objects.equals(this.objectId, o.objectId); 1507 } 1508 1509 /** Generates a Hash-Code for {@code 'this'} instance */ 1510 public int hashCode() 1511 { 1512 return 1513 Objects.hashCode(this.value) 1514 + Objects.hashCode(this.unserializableValue) 1515 + Objects.hashCode(this.objectId); 1516 } 1517 } 1518 1519 /** Description of an isolated world. */ 1520 public static class ExecutionContextDescription 1521 extends BaseType 1522 implements java.io.Serializable 1523 { 1524 /** For Object Serialization. java.io.Serializable */ 1525 protected static final long serialVersionUID = 1; 1526 1527 public boolean[] optionals() 1528 { return new boolean[] { false, false, false, false, true, }; } 1529 1530 /** 1531 * Unique id of the execution context. It can be used to specify in which execution context 1532 * script evaluation should be performed. 1533 */ 1534 public final int id; 1535 1536 /** Execution context origin. */ 1537 public final String origin; 1538 1539 /** Human readable name describing given context. */ 1540 public final String name; 1541 1542 /** 1543 * A system-unique execution context identifier. Unlike the id, this is unique across 1544 * multiple processes, so can be reliably used to identify specific context while backend 1545 * performs a cross-process navigation. 1546 * <BR /><B CLASS=Exp>EXPERIMENTAL</B> 1547 */ 1548 public final String uniqueId; 1549 1550 /** 1551 * Embedder-specific auxiliary data likely matching {isDefault: boolean, type: 'default'|'isolated'|'worker', frameId: string} 1552 * <BR /><B CLASS=Opt>OPTIONAL</B> 1553 */ 1554 public final JsonObject auxData; 1555 1556 /** 1557 * Constructor 1558 * 1559 * @param id 1560 * Unique id of the execution context. It can be used to specify in which execution context 1561 * script evaluation should be performed. 1562 * 1563 * @param origin Execution context origin. 1564 * 1565 * @param name Human readable name describing given context. 1566 * 1567 * @param uniqueId 1568 * A system-unique execution context identifier. Unlike the id, this is unique across 1569 * multiple processes, so can be reliably used to identify specific context while backend 1570 * performs a cross-process navigation. 1571 * <BR /><B CLASS=Exp>EXPERIMENTAL</B> 1572 * 1573 * @param auxData Embedder-specific auxiliary data likely matching {isDefault: boolean, type: 'default'|'isolated'|'worker', frameId: string} 1574 * <BR /><B CLASS=Opt>OPTIONAL</B> 1575 */ 1576 public ExecutionContextDescription 1577 (int id, String origin, String name, String uniqueId, JsonObject auxData) 1578 { 1579 // Exception-Check(s) to ensure that if any parameters which are not declared as 1580 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 1581 1582 if (origin == null) THROWS.throwNPE("origin"); 1583 if (name == null) THROWS.throwNPE("name"); 1584 if (uniqueId == null) THROWS.throwNPE("uniqueId"); 1585 1586 this.id = id; 1587 this.origin = origin; 1588 this.name = name; 1589 this.uniqueId = uniqueId; 1590 this.auxData = auxData; 1591 } 1592 1593 /** 1594 * JSON Object Constructor 1595 * @param jo A Json-Object having data about an instance of {@code 'ExecutionContextDescription'}. 1596 */ 1597 public ExecutionContextDescription (JsonObject jo) 1598 { 1599 this.id = ReadPrimJSON.getInt(jo, "id"); 1600 this.origin = ReadJSON.getString(jo, "origin", false, true); 1601 this.name = ReadJSON.getString(jo, "name", false, true); 1602 this.uniqueId = ReadJSON.getString(jo, "uniqueId", false, true); 1603 this.auxData = jo.getJsonObject("auxData"); 1604 } 1605 1606 1607 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 1608 public boolean equals(Object other) 1609 { 1610 if (this == other) return true; 1611 if (other == null) return false; 1612 if (other.getClass() != this.getClass()) return false; 1613 1614 ExecutionContextDescription o = (ExecutionContextDescription) other; 1615 1616 return 1617 Objects.equals(this.id, o.id) 1618 && Objects.equals(this.origin, o.origin) 1619 && Objects.equals(this.name, o.name) 1620 && Objects.equals(this.uniqueId, o.uniqueId) 1621 && Objects.equals(this.auxData, o.auxData); 1622 } 1623 1624 /** Generates a Hash-Code for {@code 'this'} instance */ 1625 public int hashCode() 1626 { 1627 return 1628 this.id 1629 + Objects.hashCode(this.origin) 1630 + Objects.hashCode(this.name) 1631 + Objects.hashCode(this.uniqueId) 1632 + Objects.hashCode(this.auxData); 1633 } 1634 } 1635 1636 /** 1637 * Detailed information about exception (or error) that was thrown during script compilation or 1638 * execution. 1639 */ 1640 public static class ExceptionDetails 1641 extends BaseType 1642 implements java.io.Serializable 1643 { 1644 /** For Object Serialization. java.io.Serializable */ 1645 protected static final long serialVersionUID = 1; 1646 1647 public boolean[] optionals() 1648 { return new boolean[] { false, false, false, false, true, true, true, true, true, true, }; } 1649 1650 /** Exception id. */ 1651 public final int exceptionId; 1652 1653 /** Exception text, which should be used together with exception object when available. */ 1654 public final String text; 1655 1656 /** Line number of the exception location (0-based). */ 1657 public final int lineNumber; 1658 1659 /** Column number of the exception location (0-based). */ 1660 public final int columnNumber; 1661 1662 /** 1663 * Script ID of the exception location. 1664 * <BR /><B CLASS=Opt>OPTIONAL</B> 1665 */ 1666 public final String scriptId; 1667 1668 /** 1669 * URL of the exception location, to be used when the script was not reported. 1670 * <BR /><B CLASS=Opt>OPTIONAL</B> 1671 */ 1672 public final String url; 1673 1674 /** 1675 * JavaScript stack trace if available. 1676 * <BR /><B CLASS=Opt>OPTIONAL</B> 1677 */ 1678 public final RunTime.StackTrace stackTrace; 1679 1680 /** 1681 * Exception object if available. 1682 * <BR /><B CLASS=Opt>OPTIONAL</B> 1683 */ 1684 public final RunTime.RemoteObject exception; 1685 1686 /** 1687 * Identifier of the context where exception happened. 1688 * <BR /><B CLASS=Opt>OPTIONAL</B> 1689 */ 1690 public final Integer executionContextId; 1691 1692 /** 1693 * Dictionary with entries of meta data that the client associated 1694 * with this exception, such as information about associated network 1695 * requests, etc. 1696 * <BR /><B CLASS=Opt>OPTIONAL</B> 1697 <B CLASS=Exp>EXPERIMENTAL</B> 1698 */ 1699 public final JsonObject exceptionMetaData; 1700 1701 /** 1702 * Constructor 1703 * 1704 * @param exceptionId Exception id. 1705 * 1706 * @param text Exception text, which should be used together with exception object when available. 1707 * 1708 * @param lineNumber Line number of the exception location (0-based). 1709 * 1710 * @param columnNumber Column number of the exception location (0-based). 1711 * 1712 * @param scriptId Script ID of the exception location. 1713 * <BR /><B CLASS=Opt>OPTIONAL</B> 1714 * 1715 * @param url URL of the exception location, to be used when the script was not reported. 1716 * <BR /><B CLASS=Opt>OPTIONAL</B> 1717 * 1718 * @param stackTrace JavaScript stack trace if available. 1719 * <BR /><B CLASS=Opt>OPTIONAL</B> 1720 * 1721 * @param exception Exception object if available. 1722 * <BR /><B CLASS=Opt>OPTIONAL</B> 1723 * 1724 * @param executionContextId Identifier of the context where exception happened. 1725 * <BR /><B CLASS=Opt>OPTIONAL</B> 1726 * 1727 * @param exceptionMetaData 1728 * Dictionary with entries of meta data that the client associated 1729 * with this exception, such as information about associated network 1730 * requests, etc. 1731 * <BR /><B CLASS=Opt>OPTIONAL</B><B CLASS=Exp>EXPERIMENTAL</B> 1732 */ 1733 public ExceptionDetails( 1734 int exceptionId, String text, int lineNumber, int columnNumber, String scriptId, 1735 String url, RunTime.StackTrace stackTrace, RunTime.RemoteObject exception, 1736 Integer executionContextId, JsonObject exceptionMetaData 1737 ) 1738 { 1739 // Exception-Check(s) to ensure that if any parameters which are not declared as 1740 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 1741 1742 if (text == null) THROWS.throwNPE("text"); 1743 1744 this.exceptionId = exceptionId; 1745 this.text = text; 1746 this.lineNumber = lineNumber; 1747 this.columnNumber = columnNumber; 1748 this.scriptId = scriptId; 1749 this.url = url; 1750 this.stackTrace = stackTrace; 1751 this.exception = exception; 1752 this.executionContextId = executionContextId; 1753 this.exceptionMetaData = exceptionMetaData; 1754 } 1755 1756 /** 1757 * JSON Object Constructor 1758 * @param jo A Json-Object having data about an instance of {@code 'ExceptionDetails'}. 1759 */ 1760 public ExceptionDetails (JsonObject jo) 1761 { 1762 this.exceptionId = ReadPrimJSON.getInt(jo, "exceptionId"); 1763 this.text = ReadJSON.getString(jo, "text", false, true); 1764 this.lineNumber = ReadPrimJSON.getInt(jo, "lineNumber"); 1765 this.columnNumber = ReadPrimJSON.getInt(jo, "columnNumber"); 1766 this.scriptId = ReadJSON.getString(jo, "scriptId", true, false); 1767 this.url = ReadJSON.getString(jo, "url", true, false); 1768 this.stackTrace = ReadJSON.getObject(jo, "stackTrace", RunTime.StackTrace.class, true, false); 1769 this.exception = ReadJSON.getObject(jo, "exception", RunTime.RemoteObject.class, true, false); 1770 this.executionContextId = ReadBoxedJSON.getInteger(jo, "executionContextId", true); 1771 this.exceptionMetaData = jo.getJsonObject("exceptionMetaData"); 1772 } 1773 1774 1775 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 1776 public boolean equals(Object other) 1777 { 1778 if (this == other) return true; 1779 if (other == null) return false; 1780 if (other.getClass() != this.getClass()) return false; 1781 1782 ExceptionDetails o = (ExceptionDetails) other; 1783 1784 return 1785 (this.exceptionId == o.exceptionId) 1786 && Objects.equals(this.text, o.text) 1787 && (this.lineNumber == o.lineNumber) 1788 && (this.columnNumber == o.columnNumber) 1789 && Objects.equals(this.scriptId, o.scriptId) 1790 && Objects.equals(this.url, o.url) 1791 && Objects.equals(this.stackTrace, o.stackTrace) 1792 && Objects.equals(this.exception, o.exception) 1793 && Objects.equals(this.executionContextId, o.executionContextId) 1794 && Objects.equals(this.exceptionMetaData, o.exceptionMetaData); 1795 } 1796 1797 /** Generates a Hash-Code for {@code 'this'} instance */ 1798 public int hashCode() 1799 { 1800 return 1801 this.exceptionId 1802 + Objects.hashCode(this.text) 1803 + this.lineNumber 1804 + this.columnNumber 1805 + Objects.hashCode(this.scriptId) 1806 + Objects.hashCode(this.url) 1807 + this.stackTrace.hashCode() 1808 + this.exception.hashCode() 1809 + Objects.hashCode(this.executionContextId) 1810 + Objects.hashCode(this.exceptionMetaData); 1811 } 1812 } 1813 1814 /** Stack entry for runtime errors and assertions. */ 1815 public static class CallFrame 1816 extends BaseType 1817 implements java.io.Serializable 1818 { 1819 /** For Object Serialization. java.io.Serializable */ 1820 protected static final long serialVersionUID = 1; 1821 1822 public boolean[] optionals() 1823 { return new boolean[] { false, false, false, false, false, }; } 1824 1825 /** JavaScript function name. */ 1826 public final String functionName; 1827 1828 /** JavaScript script id. */ 1829 public final String scriptId; 1830 1831 /** JavaScript script name or url. */ 1832 public final String url; 1833 1834 /** JavaScript script line number (0-based). */ 1835 public final int lineNumber; 1836 1837 /** JavaScript script column number (0-based). */ 1838 public final int columnNumber; 1839 1840 /** 1841 * Constructor 1842 * 1843 * @param functionName JavaScript function name. 1844 * 1845 * @param scriptId JavaScript script id. 1846 * 1847 * @param url JavaScript script name or url. 1848 * 1849 * @param lineNumber JavaScript script line number (0-based). 1850 * 1851 * @param columnNumber JavaScript script column number (0-based). 1852 */ 1853 public CallFrame 1854 (String functionName, String scriptId, String url, int lineNumber, int columnNumber) 1855 { 1856 // Exception-Check(s) to ensure that if any parameters which are not declared as 1857 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 1858 1859 if (functionName == null) THROWS.throwNPE("functionName"); 1860 if (scriptId == null) THROWS.throwNPE("scriptId"); 1861 if (url == null) THROWS.throwNPE("url"); 1862 1863 this.functionName = functionName; 1864 this.scriptId = scriptId; 1865 this.url = url; 1866 this.lineNumber = lineNumber; 1867 this.columnNumber = columnNumber; 1868 } 1869 1870 /** 1871 * JSON Object Constructor 1872 * @param jo A Json-Object having data about an instance of {@code 'CallFrame'}. 1873 */ 1874 public CallFrame (JsonObject jo) 1875 { 1876 this.functionName = ReadJSON.getString(jo, "functionName", false, true); 1877 this.scriptId = ReadJSON.getString(jo, "scriptId", false, true); 1878 this.url = ReadJSON.getString(jo, "url", false, true); 1879 this.lineNumber = ReadPrimJSON.getInt(jo, "lineNumber"); 1880 this.columnNumber = ReadPrimJSON.getInt(jo, "columnNumber"); 1881 } 1882 1883 1884 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 1885 public boolean equals(Object other) 1886 { 1887 if (this == other) return true; 1888 if (other == null) return false; 1889 if (other.getClass() != this.getClass()) return false; 1890 1891 CallFrame o = (CallFrame) other; 1892 1893 return 1894 Objects.equals(this.functionName, o.functionName) 1895 && Objects.equals(this.scriptId, o.scriptId) 1896 && Objects.equals(this.url, o.url) 1897 && (this.lineNumber == o.lineNumber) 1898 && (this.columnNumber == o.columnNumber); 1899 } 1900 1901 /** Generates a Hash-Code for {@code 'this'} instance */ 1902 public int hashCode() 1903 { 1904 return 1905 Objects.hashCode(this.functionName) 1906 + Objects.hashCode(this.scriptId) 1907 + Objects.hashCode(this.url) 1908 + this.lineNumber 1909 + this.columnNumber; 1910 } 1911 } 1912 1913 /** Call frames for assertions or error messages. */ 1914 public static class StackTrace 1915 extends BaseType 1916 implements java.io.Serializable 1917 { 1918 /** For Object Serialization. java.io.Serializable */ 1919 protected static final long serialVersionUID = 1; 1920 1921 public boolean[] optionals() 1922 { return new boolean[] { true, false, true, true, }; } 1923 1924 /** 1925 * String label of this stack trace. For async traces this may be a name of the function that 1926 * initiated the async call. 1927 * <BR /><B CLASS=Opt>OPTIONAL</B> 1928 */ 1929 public final String description; 1930 1931 /** JavaScript function name. */ 1932 public final RunTime.CallFrame[] callFrames; 1933 1934 /** 1935 * Asynchronous JavaScript stack trace that preceded this stack, if available. 1936 * <BR /><B CLASS=Opt>OPTIONAL</B> 1937 */ 1938 public final RunTime.StackTrace parent; 1939 1940 /** 1941 * Asynchronous JavaScript stack trace that preceded this stack, if available. 1942 * <BR /><B CLASS=Opt>OPTIONAL</B> 1943 <B CLASS=Exp>EXPERIMENTAL</B> 1944 */ 1945 public final RunTime.StackTraceId parentId; 1946 1947 /** 1948 * Constructor 1949 * 1950 * @param description 1951 * String label of this stack trace. For async traces this may be a name of the function that 1952 * initiated the async call. 1953 * <BR /><B CLASS=Opt>OPTIONAL</B> 1954 * 1955 * @param callFrames JavaScript function name. 1956 * 1957 * @param parent Asynchronous JavaScript stack trace that preceded this stack, if available. 1958 * <BR /><B CLASS=Opt>OPTIONAL</B> 1959 * 1960 * @param parentId Asynchronous JavaScript stack trace that preceded this stack, if available. 1961 * <BR /><B CLASS=Opt>OPTIONAL</B><B CLASS=Exp>EXPERIMENTAL</B> 1962 */ 1963 public StackTrace( 1964 String description, RunTime.CallFrame[] callFrames, RunTime.StackTrace parent, 1965 RunTime.StackTraceId parentId 1966 ) 1967 { 1968 // Exception-Check(s) to ensure that if any parameters which are not declared as 1969 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 1970 1971 if (callFrames == null) THROWS.throwNPE("callFrames"); 1972 1973 this.description = description; 1974 this.callFrames = callFrames; 1975 this.parent = parent; 1976 this.parentId = parentId; 1977 } 1978 1979 /** 1980 * JSON Object Constructor 1981 * @param jo A Json-Object having data about an instance of {@code 'StackTrace'}. 1982 */ 1983 public StackTrace (JsonObject jo) 1984 { 1985 this.description = ReadJSON.getString(jo, "description", true, false); 1986 this.callFrames = (jo.getJsonArray("callFrames") == null) 1987 ? null 1988 : RJArrIntoStream.objArr(jo.getJsonArray("callFrames"), null, 0, RunTime.CallFrame.class).toArray(RunTime.CallFrame[]::new); 1989 1990 this.parent = ReadJSON.getObject(jo, "parent", RunTime.StackTrace.class, true, false); 1991 this.parentId = ReadJSON.getObject(jo, "parentId", RunTime.StackTraceId.class, true, false); 1992 } 1993 1994 1995 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 1996 public boolean equals(Object other) 1997 { 1998 if (this == other) return true; 1999 if (other == null) return false; 2000 if (other.getClass() != this.getClass()) return false; 2001 2002 StackTrace o = (StackTrace) other; 2003 2004 return 2005 Objects.equals(this.description, o.description) 2006 && Arrays.deepEquals(this.callFrames, o.callFrames) 2007 && Objects.equals(this.parent, o.parent) 2008 && Objects.equals(this.parentId, o.parentId); 2009 } 2010 2011 /** Generates a Hash-Code for {@code 'this'} instance */ 2012 public int hashCode() 2013 { 2014 return 2015 Objects.hashCode(this.description) 2016 + Arrays.deepHashCode(this.callFrames) 2017 + this.parent.hashCode() 2018 + this.parentId.hashCode(); 2019 } 2020 } 2021 2022 /** 2023 * If {@code debuggerId} is set stack trace comes from another debugger and can be resolved there. This 2024 * allows to track cross-debugger calls. See {@code RunTime.StackTrace} and {@code Debugger.paused} for usages. 2025 * <BR /><B CLASS=Exp>EXPERIMENTAL</B> 2026 */ 2027 public static class StackTraceId 2028 extends BaseType 2029 implements java.io.Serializable 2030 { 2031 /** For Object Serialization. java.io.Serializable */ 2032 protected static final long serialVersionUID = 1; 2033 2034 public boolean[] optionals() 2035 { return new boolean[] { false, true, }; } 2036 2037 /** <CODE>[No Description Provided by Google]</CODE> */ 2038 public final String id; 2039 2040 /** 2041 * <CODE>[No Description Provided by Google]</CODE> 2042 * <BR /><B CLASS=Opt>OPTIONAL</B> 2043 */ 2044 public final String debuggerId; 2045 2046 /** 2047 * Constructor 2048 * 2049 * @param id - 2050 * 2051 * @param debuggerId - 2052 * <BR /><B CLASS=Opt>OPTIONAL</B> 2053 */ 2054 public StackTraceId(String id, String debuggerId) 2055 { 2056 // Exception-Check(s) to ensure that if any parameters which are not declared as 2057 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 2058 2059 if (id == null) THROWS.throwNPE("id"); 2060 2061 this.id = id; 2062 this.debuggerId = debuggerId; 2063 } 2064 2065 /** 2066 * JSON Object Constructor 2067 * @param jo A Json-Object having data about an instance of {@code 'StackTraceId'}. 2068 */ 2069 public StackTraceId (JsonObject jo) 2070 { 2071 this.id = ReadJSON.getString(jo, "id", false, true); 2072 this.debuggerId = ReadJSON.getString(jo, "debuggerId", true, false); 2073 } 2074 2075 2076 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 2077 public boolean equals(Object other) 2078 { 2079 if (this == other) return true; 2080 if (other == null) return false; 2081 if (other.getClass() != this.getClass()) return false; 2082 2083 StackTraceId o = (StackTraceId) other; 2084 2085 return 2086 Objects.equals(this.id, o.id) 2087 && Objects.equals(this.debuggerId, o.debuggerId); 2088 } 2089 2090 /** Generates a Hash-Code for {@code 'this'} instance */ 2091 public int hashCode() 2092 { 2093 return 2094 Objects.hashCode(this.id) 2095 + Objects.hashCode(this.debuggerId); 2096 } 2097 } 2098 2099 /** 2100 * Issued when all executionContexts were cleared in browser 2101 * 2102 * <BR /><BR />This is Marker-Event. Marker-Event's are Events that do not posses 2103 * any data, fields or state. When they are fired, only the event name is supplied. 2104 */ 2105 public static class executionContextsCleared 2106 extends BrowserEvent 2107 implements java.io.Serializable 2108 { 2109 /** For Object Serialization. java.io.Serializable */ 2110 protected static final long serialVersionUID = 1; 2111 2112 public boolean[] optionals() { return new boolean[0]; } 2113 2114 /** JSON Object Constructor */ 2115 public executionContextsCleared(JsonObject jo) 2116 { super("RunTime", "executionContextsCleared", 0); } 2117 2118 @Override 2119 public String toString() { return "RunTime.executionContextsCleared Marker Event\n"; } 2120 } 2121 2122 /** 2123 * Notification is issued every time when binding is called. 2124 * <BR /><B CLASS=Exp>EXPERIMENTAL</B> 2125 */ 2126 public static class bindingCalled 2127 extends BrowserEvent 2128 implements java.io.Serializable 2129 { 2130 /** For Object Serialization. java.io.Serializable */ 2131 protected static final long serialVersionUID = 1; 2132 2133 public boolean[] optionals() 2134 { return new boolean[] { false, false, false, }; } 2135 2136 /** <CODE>[No Description Provided by Google]</CODE> */ 2137 public final String name; 2138 2139 /** <CODE>[No Description Provided by Google]</CODE> */ 2140 public final String payload; 2141 2142 /** Identifier of the context where the call was made. */ 2143 public final int executionContextId; 2144 2145 /** 2146 * Constructor 2147 * 2148 * @param name - 2149 * 2150 * @param payload - 2151 * 2152 * @param executionContextId Identifier of the context where the call was made. 2153 */ 2154 public bindingCalled(String name, String payload, int executionContextId) 2155 { 2156 super("RunTime", "bindingCalled", 3); 2157 2158 // Exception-Check(s) to ensure that if any parameters which are not declared as 2159 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 2160 2161 if (name == null) THROWS.throwNPE("name"); 2162 if (payload == null) THROWS.throwNPE("payload"); 2163 2164 this.name = name; 2165 this.payload = payload; 2166 this.executionContextId = executionContextId; 2167 } 2168 2169 /** 2170 * JSON Object Constructor 2171 * @param jo A Json-Object having data about an instance of {@code 'bindingCalled'}. 2172 */ 2173 public bindingCalled (JsonObject jo) 2174 { 2175 super("RunTime", "bindingCalled", 3); 2176 2177 this.name = ReadJSON.getString(jo, "name", false, true); 2178 this.payload = ReadJSON.getString(jo, "payload", false, true); 2179 this.executionContextId = ReadPrimJSON.getInt(jo, "executionContextId"); 2180 } 2181 2182 2183 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 2184 public boolean equals(Object other) 2185 { 2186 if (this == other) return true; 2187 if (other == null) return false; 2188 if (other.getClass() != this.getClass()) return false; 2189 2190 bindingCalled o = (bindingCalled) other; 2191 2192 return 2193 Objects.equals(this.name, o.name) 2194 && Objects.equals(this.payload, o.payload) 2195 && Objects.equals(this.executionContextId, o.executionContextId); 2196 } 2197 2198 /** Generates a Hash-Code for {@code 'this'} instance */ 2199 public int hashCode() 2200 { 2201 return 2202 Objects.hashCode(this.name) 2203 + Objects.hashCode(this.payload) 2204 + this.executionContextId; 2205 } 2206 } 2207 2208 /** Issued when console API was called. */ 2209 public static class consoleAPICalled 2210 extends BrowserEvent 2211 implements java.io.Serializable 2212 { 2213 /** For Object Serialization. java.io.Serializable */ 2214 protected static final long serialVersionUID = 1; 2215 2216 public boolean[] optionals() 2217 { return new boolean[] { false, false, false, false, true, true, }; } 2218 2219 /** Type of the call. */ 2220 public final String type; 2221 2222 /** Call arguments. */ 2223 public final RunTime.RemoteObject[] args; 2224 2225 /** Identifier of the context where the call was made. */ 2226 public final int executionContextId; 2227 2228 /** Call timestamp. */ 2229 public final Number timestamp; 2230 2231 /** 2232 * Stack trace captured when the call was made. The async stack chain is automatically reported for 2233 * the following call types: {@code assert}, {@code error}, {@code trace}, {@code warning}. For other types the async call 2234 * chain can be retrieved using {@code Debugger.getStackTrace} and {@code stackTrace.parentId} field. 2235 * <BR /><B CLASS=Opt>OPTIONAL</B> 2236 */ 2237 public final RunTime.StackTrace stackTrace; 2238 2239 /** 2240 * Console context descriptor for calls on non-default console context (not console.*): 2241 * 'anonymous#unique-logger-id' for call on unnamed context, 'name#unique-logger-id' for call 2242 * on named context. 2243 * <BR /><B CLASS=Opt>OPTIONAL</B> 2244 <B CLASS=Exp>EXPERIMENTAL</B> 2245 */ 2246 public final String context; 2247 2248 /** 2249 * Constructor 2250 * 2251 * @param type Type of the call. 2252 * <BR />Acceptable Values: ["log", "debug", "info", "error", "warning", "dir", "dirxml", "table", "trace", "clear", "startGroup", "startGroupCollapsed", "endGroup", "assert", "profile", "profileEnd", "count", "timeEnd"] 2253 * 2254 * @param args Call arguments. 2255 * 2256 * @param executionContextId Identifier of the context where the call was made. 2257 * 2258 * @param timestamp Call timestamp. 2259 * 2260 * @param stackTrace 2261 * Stack trace captured when the call was made. The async stack chain is automatically reported for 2262 * the following call types: {@code assert}, {@code error}, {@code trace}, {@code warning}. For other types the async call 2263 * chain can be retrieved using {@code Debugger.getStackTrace} and {@code stackTrace.parentId} field. 2264 * <BR /><B CLASS=Opt>OPTIONAL</B> 2265 * 2266 * @param context 2267 * Console context descriptor for calls on non-default console context (not console.*): 2268 * 'anonymous#unique-logger-id' for call on unnamed context, 'name#unique-logger-id' for call 2269 * on named context. 2270 * <BR /><B CLASS=Opt>OPTIONAL</B><B CLASS=Exp>EXPERIMENTAL</B> 2271 */ 2272 public consoleAPICalled( 2273 String type, RunTime.RemoteObject[] args, int executionContextId, Number timestamp, 2274 RunTime.StackTrace stackTrace, String context 2275 ) 2276 { 2277 super("RunTime", "consoleAPICalled", 6); 2278 2279 // Exception-Check(s) to ensure that if any parameters which are not declared as 2280 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 2281 2282 if (type == null) THROWS.throwNPE("type"); 2283 if (args == null) THROWS.throwNPE("args"); 2284 if (timestamp == null) THROWS.throwNPE("timestamp"); 2285 2286 // Exception-Check(s) to ensure that if any parameters which must adhere to a 2287 // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw. 2288 2289 THROWS.checkIAE( 2290 "type", type, 2291 "log", "debug", "info", "error", "warning", "dir", "dirxml", "table", "trace", "clear", "startGroup", "startGroupCollapsed", "endGroup", "assert", "profile", "profileEnd", "count", "timeEnd" 2292 ); 2293 2294 this.type = type; 2295 this.args = args; 2296 this.executionContextId = executionContextId; 2297 this.timestamp = timestamp; 2298 this.stackTrace = stackTrace; 2299 this.context = context; 2300 } 2301 2302 /** 2303 * JSON Object Constructor 2304 * @param jo A Json-Object having data about an instance of {@code 'consoleAPICalled'}. 2305 */ 2306 public consoleAPICalled (JsonObject jo) 2307 { 2308 super("RunTime", "consoleAPICalled", 6); 2309 2310 this.type = ReadJSON.getString(jo, "type", false, true); 2311 this.args = (jo.getJsonArray("args") == null) 2312 ? null 2313 : RJArrIntoStream.objArr(jo.getJsonArray("args"), null, 0, RunTime.RemoteObject.class).toArray(RunTime.RemoteObject[]::new); 2314 2315 this.executionContextId = ReadPrimJSON.getInt(jo, "executionContextId"); 2316 this.timestamp = ReadNumberJSON.get(jo, "timestamp", false, true); 2317 this.stackTrace = ReadJSON.getObject(jo, "stackTrace", RunTime.StackTrace.class, true, false); 2318 this.context = ReadJSON.getString(jo, "context", true, false); 2319 } 2320 2321 2322 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 2323 public boolean equals(Object other) 2324 { 2325 if (this == other) return true; 2326 if (other == null) return false; 2327 if (other.getClass() != this.getClass()) return false; 2328 2329 consoleAPICalled o = (consoleAPICalled) other; 2330 2331 return 2332 Objects.equals(this.type, o.type) 2333 && Arrays.deepEquals(this.args, o.args) 2334 && Objects.equals(this.executionContextId, o.executionContextId) 2335 && Objects.equals(this.timestamp, o.timestamp) 2336 && Objects.equals(this.stackTrace, o.stackTrace) 2337 && Objects.equals(this.context, o.context); 2338 } 2339 2340 /** Generates a Hash-Code for {@code 'this'} instance */ 2341 public int hashCode() 2342 { 2343 return 2344 Objects.hashCode(this.type) 2345 + Arrays.deepHashCode(this.args) 2346 + this.executionContextId 2347 + Objects.hashCode(this.timestamp) 2348 + this.stackTrace.hashCode() 2349 + Objects.hashCode(this.context); 2350 } 2351 } 2352 2353 /** Issued when unhandled exception was revoked. */ 2354 public static class exceptionRevoked 2355 extends BrowserEvent 2356 implements java.io.Serializable 2357 { 2358 /** For Object Serialization. java.io.Serializable */ 2359 protected static final long serialVersionUID = 1; 2360 2361 public boolean[] optionals() 2362 { return new boolean[] { false, false, }; } 2363 2364 /** Reason describing why exception was revoked. */ 2365 public final String reason; 2366 2367 /** The id of revoked exception, as reported in {@code exceptionThrown}. */ 2368 public final int exceptionId; 2369 2370 /** 2371 * Constructor 2372 * 2373 * @param reason Reason describing why exception was revoked. 2374 * 2375 * @param exceptionId The id of revoked exception, as reported in {@code exceptionThrown}. 2376 */ 2377 public exceptionRevoked(String reason, int exceptionId) 2378 { 2379 super("RunTime", "exceptionRevoked", 2); 2380 2381 // Exception-Check(s) to ensure that if any parameters which are not declared as 2382 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 2383 2384 if (reason == null) THROWS.throwNPE("reason"); 2385 2386 this.reason = reason; 2387 this.exceptionId = exceptionId; 2388 } 2389 2390 /** 2391 * JSON Object Constructor 2392 * @param jo A Json-Object having data about an instance of {@code 'exceptionRevoked'}. 2393 */ 2394 public exceptionRevoked (JsonObject jo) 2395 { 2396 super("RunTime", "exceptionRevoked", 2); 2397 2398 this.reason = ReadJSON.getString(jo, "reason", false, true); 2399 this.exceptionId = ReadPrimJSON.getInt(jo, "exceptionId"); 2400 } 2401 2402 2403 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 2404 public boolean equals(Object other) 2405 { 2406 if (this == other) return true; 2407 if (other == null) return false; 2408 if (other.getClass() != this.getClass()) return false; 2409 2410 exceptionRevoked o = (exceptionRevoked) other; 2411 2412 return 2413 Objects.equals(this.reason, o.reason) 2414 && (this.exceptionId == o.exceptionId); 2415 } 2416 2417 /** Generates a Hash-Code for {@code 'this'} instance */ 2418 public int hashCode() 2419 { 2420 return 2421 Objects.hashCode(this.reason) 2422 + this.exceptionId; 2423 } 2424 } 2425 2426 /** Issued when exception was thrown and unhandled. */ 2427 public static class exceptionThrown 2428 extends BrowserEvent 2429 implements java.io.Serializable 2430 { 2431 /** For Object Serialization. java.io.Serializable */ 2432 protected static final long serialVersionUID = 1; 2433 2434 public boolean[] optionals() 2435 { return new boolean[] { false, false, }; } 2436 2437 /** Timestamp of the exception. */ 2438 public final Number timestamp; 2439 2440 /** <CODE>[No Description Provided by Google]</CODE> */ 2441 public final RunTime.ExceptionDetails exceptionDetails; 2442 2443 /** 2444 * Constructor 2445 * 2446 * @param timestamp Timestamp of the exception. 2447 * 2448 * @param exceptionDetails - 2449 */ 2450 public exceptionThrown(Number timestamp, RunTime.ExceptionDetails exceptionDetails) 2451 { 2452 super("RunTime", "exceptionThrown", 2); 2453 2454 // Exception-Check(s) to ensure that if any parameters which are not declared as 2455 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 2456 2457 if (timestamp == null) THROWS.throwNPE("timestamp"); 2458 if (exceptionDetails == null) THROWS.throwNPE("exceptionDetails"); 2459 2460 this.timestamp = timestamp; 2461 this.exceptionDetails = exceptionDetails; 2462 } 2463 2464 /** 2465 * JSON Object Constructor 2466 * @param jo A Json-Object having data about an instance of {@code 'exceptionThrown'}. 2467 */ 2468 public exceptionThrown (JsonObject jo) 2469 { 2470 super("RunTime", "exceptionThrown", 2); 2471 2472 this.timestamp = ReadNumberJSON.get(jo, "timestamp", false, true); 2473 this.exceptionDetails = ReadJSON.getObject(jo, "exceptionDetails", RunTime.ExceptionDetails.class, false, true); 2474 } 2475 2476 2477 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 2478 public boolean equals(Object other) 2479 { 2480 if (this == other) return true; 2481 if (other == null) return false; 2482 if (other.getClass() != this.getClass()) return false; 2483 2484 exceptionThrown o = (exceptionThrown) other; 2485 2486 return 2487 Objects.equals(this.timestamp, o.timestamp) 2488 && Objects.equals(this.exceptionDetails, o.exceptionDetails); 2489 } 2490 2491 /** Generates a Hash-Code for {@code 'this'} instance */ 2492 public int hashCode() 2493 { 2494 return 2495 Objects.hashCode(this.timestamp) 2496 + this.exceptionDetails.hashCode(); 2497 } 2498 } 2499 2500 /** Issued when new execution context is created. */ 2501 public static class executionContextCreated 2502 extends BrowserEvent 2503 implements java.io.Serializable 2504 { 2505 /** For Object Serialization. java.io.Serializable */ 2506 protected static final long serialVersionUID = 1; 2507 2508 public boolean[] optionals() 2509 { return new boolean[] { false, }; } 2510 2511 /** A newly created execution context. */ 2512 public final RunTime.ExecutionContextDescription context; 2513 2514 /** 2515 * Constructor 2516 * 2517 * @param context A newly created execution context. 2518 */ 2519 public executionContextCreated(RunTime.ExecutionContextDescription context) 2520 { 2521 super("RunTime", "executionContextCreated", 1); 2522 2523 // Exception-Check(s) to ensure that if any parameters which are not declared as 2524 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 2525 2526 if (context == null) THROWS.throwNPE("context"); 2527 2528 this.context = context; 2529 } 2530 2531 /** 2532 * JSON Object Constructor 2533 * @param jo A Json-Object having data about an instance of {@code 'executionContextCreated'}. 2534 */ 2535 public executionContextCreated (JsonObject jo) 2536 { 2537 super("RunTime", "executionContextCreated", 1); 2538 2539 this.context = ReadJSON.getObject(jo, "context", RunTime.ExecutionContextDescription.class, false, true); 2540 } 2541 2542 2543 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 2544 public boolean equals(Object other) 2545 { 2546 if (this == other) return true; 2547 if (other == null) return false; 2548 if (other.getClass() != this.getClass()) return false; 2549 2550 executionContextCreated o = (executionContextCreated) other; 2551 2552 return 2553 Objects.equals(this.context, o.context); 2554 } 2555 2556 /** Generates a Hash-Code for {@code 'this'} instance */ 2557 public int hashCode() 2558 { 2559 return 2560 this.context.hashCode(); 2561 } 2562 } 2563 2564 /** Issued when execution context is destroyed. */ 2565 public static class executionContextDestroyed 2566 extends BrowserEvent 2567 implements java.io.Serializable 2568 { 2569 /** For Object Serialization. java.io.Serializable */ 2570 protected static final long serialVersionUID = 1; 2571 2572 public boolean[] optionals() 2573 { return new boolean[] { false, false, }; } 2574 2575 /** 2576 * Id of the destroyed context 2577 * <BR /><B CLASS=Dep>DEPRECATED</B> 2578 */ 2579 public final int executionContextId; 2580 2581 /** 2582 * Unique Id of the destroyed context 2583 * <BR /><B CLASS=Exp>EXPERIMENTAL</B> 2584 */ 2585 public final String executionContextUniqueId; 2586 2587 /** 2588 * Constructor 2589 * 2590 * @param executionContextId Id of the destroyed context 2591 * <BR /><B CLASS=Dep>DEPRECATED</B> 2592 * 2593 * @param executionContextUniqueId Unique Id of the destroyed context 2594 * <BR /><B CLASS=Exp>EXPERIMENTAL</B> 2595 */ 2596 public executionContextDestroyed 2597 (int executionContextId, String executionContextUniqueId) 2598 { 2599 super("RunTime", "executionContextDestroyed", 2); 2600 2601 // Exception-Check(s) to ensure that if any parameters which are not declared as 2602 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 2603 2604 if (executionContextUniqueId == null) THROWS.throwNPE("executionContextUniqueId"); 2605 2606 this.executionContextId = executionContextId; 2607 this.executionContextUniqueId = executionContextUniqueId; 2608 } 2609 2610 /** 2611 * JSON Object Constructor 2612 * @param jo A Json-Object having data about an instance of {@code 'executionContextDestroyed'}. 2613 */ 2614 public executionContextDestroyed (JsonObject jo) 2615 { 2616 super("RunTime", "executionContextDestroyed", 2); 2617 2618 this.executionContextId = ReadPrimJSON.getInt(jo, "executionContextId"); 2619 this.executionContextUniqueId = ReadJSON.getString(jo, "executionContextUniqueId", false, true); 2620 } 2621 2622 2623 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 2624 public boolean equals(Object other) 2625 { 2626 if (this == other) return true; 2627 if (other == null) return false; 2628 if (other.getClass() != this.getClass()) return false; 2629 2630 executionContextDestroyed o = (executionContextDestroyed) other; 2631 2632 return 2633 Objects.equals(this.executionContextId, o.executionContextId) 2634 && Objects.equals(this.executionContextUniqueId, o.executionContextUniqueId); 2635 } 2636 2637 /** Generates a Hash-Code for {@code 'this'} instance */ 2638 public int hashCode() 2639 { 2640 return 2641 this.executionContextId 2642 + Objects.hashCode(this.executionContextUniqueId); 2643 } 2644 } 2645 2646 /** 2647 * Issued when object should be inspected (for example, as a result of inspect() command line API 2648 * call). 2649 */ 2650 public static class inspectRequested 2651 extends BrowserEvent 2652 implements java.io.Serializable 2653 { 2654 /** For Object Serialization. java.io.Serializable */ 2655 protected static final long serialVersionUID = 1; 2656 2657 public boolean[] optionals() 2658 { return new boolean[] { false, false, true, }; } 2659 2660 /** <CODE>[No Description Provided by Google]</CODE> */ 2661 public final RunTime.RemoteObject object; 2662 2663 /** <CODE>[No Description Provided by Google]</CODE> */ 2664 public final JsonObject hints; 2665 2666 /** 2667 * Identifier of the context where the call was made. 2668 * <BR /><B CLASS=Opt>OPTIONAL</B> 2669 <B CLASS=Exp>EXPERIMENTAL</B> 2670 */ 2671 public final Integer executionContextId; 2672 2673 /** 2674 * Constructor 2675 * 2676 * @param object - 2677 * 2678 * @param hints - 2679 * 2680 * @param executionContextId Identifier of the context where the call was made. 2681 * <BR /><B CLASS=Opt>OPTIONAL</B><B CLASS=Exp>EXPERIMENTAL</B> 2682 */ 2683 public inspectRequested 2684 (RunTime.RemoteObject object, JsonObject hints, Integer executionContextId) 2685 { 2686 super("RunTime", "inspectRequested", 3); 2687 2688 // Exception-Check(s) to ensure that if any parameters which are not declared as 2689 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 2690 2691 if (object == null) THROWS.throwNPE("object"); 2692 if (hints == null) THROWS.throwNPE("hints"); 2693 2694 this.object = object; 2695 this.hints = hints; 2696 this.executionContextId = executionContextId; 2697 } 2698 2699 /** 2700 * JSON Object Constructor 2701 * @param jo A Json-Object having data about an instance of {@code 'inspectRequested'}. 2702 */ 2703 public inspectRequested (JsonObject jo) 2704 { 2705 super("RunTime", "inspectRequested", 3); 2706 2707 this.object = ReadJSON.getObject(jo, "object", RunTime.RemoteObject.class, false, true); 2708 this.hints = jo.getJsonObject("hints"); 2709 this.executionContextId = ReadBoxedJSON.getInteger(jo, "executionContextId", true); 2710 } 2711 2712 2713 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 2714 public boolean equals(Object other) 2715 { 2716 if (this == other) return true; 2717 if (other == null) return false; 2718 if (other.getClass() != this.getClass()) return false; 2719 2720 inspectRequested o = (inspectRequested) other; 2721 2722 return 2723 Objects.equals(this.object, o.object) 2724 && Objects.equals(this.hints, o.hints) 2725 && Objects.equals(this.executionContextId, o.executionContextId); 2726 } 2727 2728 /** Generates a Hash-Code for {@code 'this'} instance */ 2729 public int hashCode() 2730 { 2731 return 2732 this.object.hashCode() 2733 + Objects.hashCode(this.hints) 2734 + Objects.hashCode(this.executionContextId); 2735 } 2736 } 2737 2738 2739 // Counter for keeping the WebSocket Request ID's distinct. 2740 private static int counter = 1; 2741 2742 /** 2743 * Add handler to promise with given promise object id. 2744 * 2745 * @param promiseObjectId Identifier of the promise. 2746 * 2747 * @param returnByValue Whether the result is expected to be a JSON object that should be sent by value. 2748 * <BR /><B CLASS=Opt>OPTIONAL</B> 2749 * 2750 * @param generatePreview Whether preview should be generated for the result. 2751 * <BR /><B CLASS=Opt>OPTIONAL</B> 2752 * 2753 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 2754 * {@link Ret2}></CODE> 2755 * 2756 * <BR /><BR />This {@link Script} may be <B STYLE='color:red'>executed</B> (using 2757 * {@link Script#exec()}), and a {@link Promise} returned. 2758 * 2759 * <BR /><BR />When the {@code Promise} is <B STYLE='color: red'>awaited</B> 2760 * (using {@link Promise#await()}), the {@code Ret2} will subsequently 2761 * be returned from that call. 2762 * 2763 * <BR /><BR />The <B STYLE='color: red'>returned</B> values are encapsulated 2764 * in an instance of <B>{@link Ret2}</B> 2765 * 2766 * <BR /><BR /><UL CLASS=JDUL> 2767 * <LI><CODE><B>Ret2.a:</B> {@link RunTime.RemoteObject} (<B>result</B>)</CODE> 2768 * <BR />Promise result. Will contain rejected value if promise was rejected. 2769 * <BR /><BR /></LI> 2770 * <LI><CODE><B>Ret2.b:</B> {@link RunTime.ExceptionDetails} (<B>exceptionDetails</B>)</CODE> 2771 * <BR />Exception details if stack strace is available. 2772 * </LI> 2773 * </UL> 2774 */ 2775 public static Script<String, JsonObject, Ret2<RunTime.RemoteObject, RunTime.ExceptionDetails>> awaitPromise 2776 (String promiseObjectId, Boolean returnByValue, Boolean generatePreview) 2777 { 2778 // Exception-Check(s) to ensure that if any parameters which are not declared as 2779 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 2780 2781 if (promiseObjectId == null) THROWS.throwNPE("promiseObjectId"); 2782 2783 final int webSocketID = 5000000 + counter++; 2784 final boolean[] optionals = { false, true, true, }; 2785 2786 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 2787 String requestJSON = WriteJSON.get( 2788 parameterTypes.get("awaitPromise"), 2789 parameterNames.get("awaitPromise"), 2790 optionals, webSocketID, 2791 "Runtime.awaitPromise", 2792 promiseObjectId, returnByValue, generatePreview 2793 ); 2794 2795 // 'JSON Binding' ... Converts Browser Response-JSON into Java-Type 'Ret2' 2796 Function<JsonObject, Ret2<RunTime.RemoteObject, RunTime.ExceptionDetails>> 2797 responseProcessor = (JsonObject jo) -> new Ret2<>( 2798 ReadJSON.getObject(jo, "result", RunTime.RemoteObject.class, false, true), 2799 ReadJSON.getObject(jo, "exceptionDetails", RunTime.ExceptionDetails.class, true, false) 2800 ); 2801 2802 return new Script<>(webSocketID, requestJSON, responseProcessor); 2803 } 2804 2805 /** 2806 * Calls function with given declaration on the given object. Object group of the result is 2807 * inherited from the target object. 2808 * 2809 * @param functionDeclaration Declaration of the function to call. 2810 * 2811 * @param objectId 2812 * Identifier of the object to call function on. Either objectId or executionContextId should 2813 * be specified. 2814 * <BR /><B CLASS=Opt>OPTIONAL</B> 2815 * 2816 * @param arguments 2817 * Call arguments. All call arguments must belong to the same JavaScript world as the target 2818 * object. 2819 * <BR /><B CLASS=Opt>OPTIONAL</B> 2820 * 2821 * @param silent 2822 * In silent mode exceptions thrown during evaluation are not reported and do not pause 2823 * execution. Overrides {@code setPauseOnException} state. 2824 * <BR /><B CLASS=Opt>OPTIONAL</B> 2825 * 2826 * @param returnByValue 2827 * Whether the result is expected to be a JSON object which should be sent by value. 2828 * Can be overriden by {@code serializationOptions}. 2829 * <BR /><B CLASS=Opt>OPTIONAL</B> 2830 * 2831 * @param generatePreview Whether preview should be generated for the result. 2832 * <BR /><B CLASS=Opt>OPTIONAL</B><B CLASS=Exp>EXPERIMENTAL</B> 2833 * 2834 * @param userGesture Whether execution should be treated as initiated by user in the UI. 2835 * <BR /><B CLASS=Opt>OPTIONAL</B> 2836 * 2837 * @param awaitPromise 2838 * Whether execution should {@code await} for resulting value and return once awaited promise is 2839 * resolved. 2840 * <BR /><B CLASS=Opt>OPTIONAL</B> 2841 * 2842 * @param executionContextId 2843 * Specifies execution context which global object will be used to call function on. Either 2844 * executionContextId or objectId should be specified. 2845 * <BR /><B CLASS=Opt>OPTIONAL</B> 2846 * 2847 * @param objectGroup 2848 * Symbolic group name that can be used to release multiple objects. If objectGroup is not 2849 * specified and objectId is, objectGroup will be inherited from object. 2850 * <BR /><B CLASS=Opt>OPTIONAL</B> 2851 * 2852 * @param throwOnSideEffect Whether to throw an exception if side effect cannot be ruled out during evaluation. 2853 * <BR /><B CLASS=Opt>OPTIONAL</B><B CLASS=Exp>EXPERIMENTAL</B> 2854 * 2855 * @param uniqueContextId 2856 * An alternative way to specify the execution context to call function on. 2857 * Compared to contextId that may be reused across processes, this is guaranteed to be 2858 * system-unique, so it can be used to prevent accidental function call 2859 * in context different than intended (e.g. as a result of navigation across process 2860 * boundaries). 2861 * This is mutually exclusive with {@code executionContextId}. 2862 * <BR /><B CLASS=Opt>OPTIONAL</B><B CLASS=Exp>EXPERIMENTAL</B> 2863 * 2864 * @param serializationOptions 2865 * Specifies the result serialization. If provided, overrides 2866 * {@code generatePreview} and {@code returnByValue}. 2867 * <BR /><B CLASS=Opt>OPTIONAL</B><B CLASS=Exp>EXPERIMENTAL</B> 2868 * 2869 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 2870 * {@link Ret2}></CODE> 2871 * 2872 * <BR /><BR />This {@link Script} may be <B STYLE='color:red'>executed</B> (using 2873 * {@link Script#exec()}), and a {@link Promise} returned. 2874 * 2875 * <BR /><BR />When the {@code Promise} is <B STYLE='color: red'>awaited</B> 2876 * (using {@link Promise#await()}), the {@code Ret2} will subsequently 2877 * be returned from that call. 2878 * 2879 * <BR /><BR />The <B STYLE='color: red'>returned</B> values are encapsulated 2880 * in an instance of <B>{@link Ret2}</B> 2881 * 2882 * <BR /><BR /><UL CLASS=JDUL> 2883 * <LI><CODE><B>Ret2.a:</B> {@link RunTime.RemoteObject} (<B>result</B>)</CODE> 2884 * <BR />Call result. 2885 * <BR /><BR /></LI> 2886 * <LI><CODE><B>Ret2.b:</B> {@link RunTime.ExceptionDetails} (<B>exceptionDetails</B>)</CODE> 2887 * <BR />Exception details. 2888 * </LI> 2889 * </UL> 2890 */ 2891 public static Script<String, JsonObject, Ret2<RunTime.RemoteObject, RunTime.ExceptionDetails>> callFunctionOn( 2892 String functionDeclaration, String objectId, RunTime.CallArgument[] arguments, 2893 Boolean silent, Boolean returnByValue, Boolean generatePreview, Boolean userGesture, 2894 Boolean awaitPromise, Integer executionContextId, String objectGroup, 2895 Boolean throwOnSideEffect, String uniqueContextId, 2896 RunTime.SerializationOptions serializationOptions 2897 ) 2898 { 2899 // Exception-Check(s) to ensure that if any parameters which are not declared as 2900 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 2901 2902 if (functionDeclaration == null) THROWS.throwNPE("functionDeclaration"); 2903 2904 final int webSocketID = 5001000 + counter++; 2905 final boolean[] optionals = { false, true, true, true, true, true, true, true, true, true, true, true, true, }; 2906 2907 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 2908 String requestJSON = WriteJSON.get( 2909 parameterTypes.get("callFunctionOn"), 2910 parameterNames.get("callFunctionOn"), 2911 optionals, webSocketID, 2912 "Runtime.callFunctionOn", 2913 functionDeclaration, objectId, arguments, silent, returnByValue, generatePreview, 2914 userGesture, awaitPromise, executionContextId, objectGroup, throwOnSideEffect, 2915 uniqueContextId, serializationOptions 2916 ); 2917 2918 // 'JSON Binding' ... Converts Browser Response-JSON into Java-Type 'Ret2' 2919 Function<JsonObject, Ret2<RunTime.RemoteObject, RunTime.ExceptionDetails>> 2920 responseProcessor = (JsonObject jo) -> new Ret2<>( 2921 ReadJSON.getObject(jo, "result", RunTime.RemoteObject.class, false, true), 2922 ReadJSON.getObject(jo, "exceptionDetails", RunTime.ExceptionDetails.class, true, false) 2923 ); 2924 2925 return new Script<>(webSocketID, requestJSON, responseProcessor); 2926 } 2927 2928 /** 2929 * Compiles expression. 2930 * 2931 * @param expression Expression to compile. 2932 * 2933 * @param sourceURL Source url to be set for the script. 2934 * 2935 * @param persistScript Specifies whether the compiled script should be persisted. 2936 * 2937 * @param executionContextId 2938 * Specifies in which execution context to perform script run. If the parameter is omitted the 2939 * evaluation will be performed in the context of the inspected page. 2940 * <BR /><B CLASS=Opt>OPTIONAL</B> 2941 * 2942 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 2943 * {@link Ret2}></CODE> 2944 * 2945 * <BR /><BR />This {@link Script} may be <B STYLE='color:red'>executed</B> (using 2946 * {@link Script#exec()}), and a {@link Promise} returned. 2947 * 2948 * <BR /><BR />When the {@code Promise} is <B STYLE='color: red'>awaited</B> 2949 * (using {@link Promise#await()}), the {@code Ret2} will subsequently 2950 * be returned from that call. 2951 * 2952 * <BR /><BR />The <B STYLE='color: red'>returned</B> values are encapsulated 2953 * in an instance of <B>{@link Ret2}</B> 2954 * 2955 * <BR /><BR /><UL CLASS=JDUL> 2956 * <LI><CODE><B>Ret2.a:</B> String (<B>scriptId</B>)</CODE> 2957 * <BR />Id of the script. 2958 * <BR /><BR /></LI> 2959 * <LI><CODE><B>Ret2.b:</B> {@link RunTime.ExceptionDetails} (<B>exceptionDetails</B>)</CODE> 2960 * <BR />Exception details. 2961 * </LI> 2962 * </UL> 2963 */ 2964 public static Script<String, JsonObject, Ret2<String, RunTime.ExceptionDetails>> compileScript 2965 (String expression, String sourceURL, boolean persistScript, Integer executionContextId) 2966 { 2967 // Exception-Check(s) to ensure that if any parameters which are not declared as 2968 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 2969 2970 if (expression == null) THROWS.throwNPE("expression"); 2971 if (sourceURL == null) THROWS.throwNPE("sourceURL"); 2972 2973 final int webSocketID = 5002000 + counter++; 2974 final boolean[] optionals = { false, false, false, true, }; 2975 2976 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 2977 String requestJSON = WriteJSON.get( 2978 parameterTypes.get("compileScript"), 2979 parameterNames.get("compileScript"), 2980 optionals, webSocketID, 2981 "Runtime.compileScript", 2982 expression, sourceURL, persistScript, executionContextId 2983 ); 2984 2985 // 'JSON Binding' ... Converts Browser Response-JSON into Java-Type 'Ret2' 2986 Function<JsonObject, Ret2<String, RunTime.ExceptionDetails>> 2987 responseProcessor = (JsonObject jo) -> new Ret2<>( 2988 ReadJSON.getString(jo, "scriptId", true, false), 2989 ReadJSON.getObject(jo, "exceptionDetails", RunTime.ExceptionDetails.class, true, false) 2990 ); 2991 2992 return new Script<>(webSocketID, requestJSON, responseProcessor); 2993 } 2994 2995 /** 2996 * Disables reporting of execution contexts creation. 2997 * 2998 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 2999 * {@link Ret0}></CODE> 3000 * 3001 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 3002 * browser receives the invocation-request. 3003 * 3004 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 3005 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 3006 * {@code >} to ensure the Browser Function has run to completion. 3007 */ 3008 public static Script<String, JsonObject, Ret0> disable() 3009 { 3010 final int webSocketID = 5003000 + counter++; 3011 final boolean[] optionals = new boolean[0]; 3012 3013 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 3014 String requestJSON = WriteJSON.get( 3015 parameterTypes.get("disable"), 3016 parameterNames.get("disable"), 3017 optionals, webSocketID, 3018 "Runtime.disable" 3019 ); 3020 3021 // This Remote Command does not have a Return-Value. 3022 return new Script<> 3023 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 3024 } 3025 3026 /** 3027 * Discards collected exceptions and console API calls. 3028 * 3029 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 3030 * {@link Ret0}></CODE> 3031 * 3032 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 3033 * browser receives the invocation-request. 3034 * 3035 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 3036 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 3037 * {@code >} to ensure the Browser Function has run to completion. 3038 */ 3039 public static Script<String, JsonObject, Ret0> discardConsoleEntries() 3040 { 3041 final int webSocketID = 5004000 + counter++; 3042 final boolean[] optionals = new boolean[0]; 3043 3044 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 3045 String requestJSON = WriteJSON.get( 3046 parameterTypes.get("discardConsoleEntries"), 3047 parameterNames.get("discardConsoleEntries"), 3048 optionals, webSocketID, 3049 "Runtime.discardConsoleEntries" 3050 ); 3051 3052 // This Remote Command does not have a Return-Value. 3053 return new Script<> 3054 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 3055 } 3056 3057 /** 3058 * Enables reporting of execution contexts creation by means of {@code executionContextCreated} event. 3059 * When the reporting gets enabled the event will be sent immediately for each existing execution 3060 * context. 3061 * 3062 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 3063 * {@link Ret0}></CODE> 3064 * 3065 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 3066 * browser receives the invocation-request. 3067 * 3068 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 3069 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 3070 * {@code >} to ensure the Browser Function has run to completion. 3071 */ 3072 public static Script<String, JsonObject, Ret0> enable() 3073 { 3074 final int webSocketID = 5005000 + counter++; 3075 final boolean[] optionals = new boolean[0]; 3076 3077 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 3078 String requestJSON = WriteJSON.get( 3079 parameterTypes.get("enable"), 3080 parameterNames.get("enable"), 3081 optionals, webSocketID, 3082 "Runtime.enable" 3083 ); 3084 3085 // This Remote Command does not have a Return-Value. 3086 return new Script<> 3087 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 3088 } 3089 3090 /** 3091 * Evaluates expression on global object. 3092 * 3093 * @param expression Expression to evaluate. 3094 * 3095 * @param objectGroup Symbolic group name that can be used to release multiple objects. 3096 * <BR /><B CLASS=Opt>OPTIONAL</B> 3097 * 3098 * @param includeCommandLineAPI Determines whether Command Line API should be available during the evaluation. 3099 * <BR /><B CLASS=Opt>OPTIONAL</B> 3100 * 3101 * @param silent 3102 * In silent mode exceptions thrown during evaluation are not reported and do not pause 3103 * execution. Overrides {@code setPauseOnException} state. 3104 * <BR /><B CLASS=Opt>OPTIONAL</B> 3105 * 3106 * @param contextId 3107 * Specifies in which execution context to perform evaluation. If the parameter is omitted the 3108 * evaluation will be performed in the context of the inspected page. 3109 * This is mutually exclusive with {@code uniqueContextId}, which offers an 3110 * alternative way to identify the execution context that is more reliable 3111 * in a multi-process environment. 3112 * <BR /><B CLASS=Opt>OPTIONAL</B> 3113 * 3114 * @param returnByValue Whether the result is expected to be a JSON object that should be sent by value. 3115 * <BR /><B CLASS=Opt>OPTIONAL</B> 3116 * 3117 * @param generatePreview Whether preview should be generated for the result. 3118 * <BR /><B CLASS=Opt>OPTIONAL</B><B CLASS=Exp>EXPERIMENTAL</B> 3119 * 3120 * @param userGesture Whether execution should be treated as initiated by user in the UI. 3121 * <BR /><B CLASS=Opt>OPTIONAL</B> 3122 * 3123 * @param awaitPromise 3124 * Whether execution should {@code await} for resulting value and return once awaited promise is 3125 * resolved. 3126 * <BR /><B CLASS=Opt>OPTIONAL</B> 3127 * 3128 * @param throwOnSideEffect 3129 * Whether to throw an exception if side effect cannot be ruled out during evaluation. 3130 * This implies {@code disableBreaks} below. 3131 * <BR /><B CLASS=Opt>OPTIONAL</B><B CLASS=Exp>EXPERIMENTAL</B> 3132 * 3133 * @param timeout Terminate execution after timing out (number of milliseconds). 3134 * <BR /><B CLASS=Opt>OPTIONAL</B><B CLASS=Exp>EXPERIMENTAL</B> 3135 * 3136 * @param disableBreaks Disable breakpoints during execution. 3137 * <BR /><B CLASS=Opt>OPTIONAL</B><B CLASS=Exp>EXPERIMENTAL</B> 3138 * 3139 * @param replMode 3140 * Setting this flag to true enables {@code let} re-declaration and top-level {@code await}. 3141 * Note that {@code let} variables can only be re-declared if they originate from 3142 * {@code replMode} themselves. 3143 * <BR /><B CLASS=Opt>OPTIONAL</B><B CLASS=Exp>EXPERIMENTAL</B> 3144 * 3145 * @param allowUnsafeEvalBlockedByCSP 3146 * The Content Security Policy (CSP) for the target might block 'unsafe-eval' 3147 * which includes eval(), Function(), setTimeout() and setInterval() 3148 * when called with non-callable arguments. This flag bypasses CSP for this 3149 * evaluation and allows unsafe-eval. Defaults to true. 3150 * <BR /><B CLASS=Opt>OPTIONAL</B><B CLASS=Exp>EXPERIMENTAL</B> 3151 * 3152 * @param uniqueContextId 3153 * An alternative way to specify the execution context to evaluate in. 3154 * Compared to contextId that may be reused across processes, this is guaranteed to be 3155 * system-unique, so it can be used to prevent accidental evaluation of the expression 3156 * in context different than intended (e.g. as a result of navigation across process 3157 * boundaries). 3158 * This is mutually exclusive with {@code contextId}. 3159 * <BR /><B CLASS=Opt>OPTIONAL</B><B CLASS=Exp>EXPERIMENTAL</B> 3160 * 3161 * @param serializationOptions 3162 * Specifies the result serialization. If provided, overrides 3163 * {@code generatePreview} and {@code returnByValue}. 3164 * <BR /><B CLASS=Opt>OPTIONAL</B><B CLASS=Exp>EXPERIMENTAL</B> 3165 * 3166 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 3167 * {@link Ret2}></CODE> 3168 * 3169 * <BR /><BR />This {@link Script} may be <B STYLE='color:red'>executed</B> (using 3170 * {@link Script#exec()}), and a {@link Promise} returned. 3171 * 3172 * <BR /><BR />When the {@code Promise} is <B STYLE='color: red'>awaited</B> 3173 * (using {@link Promise#await()}), the {@code Ret2} will subsequently 3174 * be returned from that call. 3175 * 3176 * <BR /><BR />The <B STYLE='color: red'>returned</B> values are encapsulated 3177 * in an instance of <B>{@link Ret2}</B> 3178 * 3179 * <BR /><BR /><UL CLASS=JDUL> 3180 * <LI><CODE><B>Ret2.a:</B> {@link RunTime.RemoteObject} (<B>result</B>)</CODE> 3181 * <BR />Evaluation result. 3182 * <BR /><BR /></LI> 3183 * <LI><CODE><B>Ret2.b:</B> {@link RunTime.ExceptionDetails} (<B>exceptionDetails</B>)</CODE> 3184 * <BR />Exception details. 3185 * </LI> 3186 * </UL> 3187 */ 3188 public static Script<String, JsonObject, Ret2<RunTime.RemoteObject, RunTime.ExceptionDetails>> evaluate( 3189 String expression, String objectGroup, Boolean includeCommandLineAPI, Boolean silent, 3190 Integer contextId, Boolean returnByValue, Boolean generatePreview, Boolean userGesture, 3191 Boolean awaitPromise, Boolean throwOnSideEffect, Number timeout, Boolean disableBreaks, 3192 Boolean replMode, Boolean allowUnsafeEvalBlockedByCSP, String uniqueContextId, 3193 RunTime.SerializationOptions serializationOptions 3194 ) 3195 { 3196 // Exception-Check(s) to ensure that if any parameters which are not declared as 3197 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 3198 3199 if (expression == null) THROWS.throwNPE("expression"); 3200 3201 final int webSocketID = 5006000 + counter++; 3202 final boolean[] optionals = { false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, }; 3203 3204 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 3205 String requestJSON = WriteJSON.get( 3206 parameterTypes.get("evaluate"), 3207 parameterNames.get("evaluate"), 3208 optionals, webSocketID, 3209 "Runtime.evaluate", 3210 expression, objectGroup, includeCommandLineAPI, silent, contextId, returnByValue, 3211 generatePreview, userGesture, awaitPromise, throwOnSideEffect, timeout, disableBreaks, 3212 replMode, allowUnsafeEvalBlockedByCSP, uniqueContextId, serializationOptions 3213 ); 3214 3215 // 'JSON Binding' ... Converts Browser Response-JSON into Java-Type 'Ret2' 3216 Function<JsonObject, Ret2<RunTime.RemoteObject, RunTime.ExceptionDetails>> 3217 responseProcessor = (JsonObject jo) -> new Ret2<>( 3218 ReadJSON.getObject(jo, "result", RunTime.RemoteObject.class, false, true), 3219 ReadJSON.getObject(jo, "exceptionDetails", RunTime.ExceptionDetails.class, true, false) 3220 ); 3221 3222 return new Script<>(webSocketID, requestJSON, responseProcessor); 3223 } 3224 3225 /** 3226 * Returns the isolate id. 3227 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 3228 * 3229 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 3230 * String></CODE> 3231 * 3232 * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using 3233 * {@link Script#exec()}, and afterwards, a {@link Promise}<CODE><JsonObject, 3234 * String></CODE> will be returned. 3235 * 3236 * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>, 3237 * using {@link Promise#await()}, <I>and the returned result of this Browser Function may 3238 * may be retrieved.</I> 3239 * 3240 * <BR /><BR />This Browser Function <B STYLE='color: red'>returns</B> 3241 * <BR /><BR /><UL CLASS=JDUL> 3242 * <LI><CODE>String (<B>id</B></CODE>) 3243 * <BR />The isolate id. 3244 * </LI> 3245 * </UL> */ 3246 public static Script<String, JsonObject, String> getIsolateId() 3247 { 3248 final int webSocketID = 5007000 + counter++; 3249 final boolean[] optionals = new boolean[0]; 3250 3251 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 3252 String requestJSON = WriteJSON.get( 3253 parameterTypes.get("getIsolateId"), 3254 parameterNames.get("getIsolateId"), 3255 optionals, webSocketID, 3256 "Runtime.getIsolateId" 3257 ); 3258 3259 // 'JSON Binding' ... Converts Browser Response-JSON to 'String' 3260 Function<JsonObject, String> responseProcessor = (JsonObject jo) -> 3261 ReadJSON.getString(jo, "id", false, true); 3262 3263 return new Script<>(webSocketID, requestJSON, responseProcessor); 3264 } 3265 3266 /** 3267 * Returns the JavaScript heap usage. 3268 * It is the total usage of the corresponding isolate not scoped to a particular RunTime. 3269 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 3270 * 3271 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 3272 * {@link Ret4}></CODE> 3273 * 3274 * <BR /><BR />This {@link Script} may be <B STYLE='color:red'>executed</B> (using 3275 * {@link Script#exec()}), and a {@link Promise} returned. 3276 * 3277 * <BR /><BR />When the {@code Promise} is <B STYLE='color: red'>awaited</B> 3278 * (using {@link Promise#await()}), the {@code Ret4} will subsequently 3279 * be returned from that call. 3280 * 3281 * <BR /><BR />The <B STYLE='color: red'>returned</B> values are encapsulated 3282 * in an instance of <B>{@link Ret4}</B> 3283 * 3284 * <BR /><BR /><UL CLASS=JDUL> 3285 * <LI><CODE><B>Ret4.a:</B> Number (<B>usedSize</B>)</CODE> 3286 * <BR />Used JavaScript heap size in bytes. 3287 * <BR /><BR /></LI> 3288 * <LI><CODE><B>Ret4.b:</B> Number (<B>totalSize</B>)</CODE> 3289 * <BR />Allocated JavaScript heap size in bytes. 3290 * <BR /><BR /></LI> 3291 * <LI><CODE><B>Ret4.c:</B> Number (<B>embedderHeapUsedSize</B>)</CODE> 3292 * <BR />Used size in bytes in the embedder's garbage-collected heap. 3293 * <BR /><BR /></LI> 3294 * <LI><CODE><B>Ret4.d:</B> Number (<B>backingStorageSize</B>)</CODE> 3295 * <BR />Size in bytes of backing storage for array buffers and external strings. 3296 * </LI> 3297 * </UL> 3298 */ 3299 public static Script<String, JsonObject, Ret4<Number, Number, Number, Number>> getHeapUsage() 3300 { 3301 final int webSocketID = 5008000 + 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("getHeapUsage"), 3307 parameterNames.get("getHeapUsage"), 3308 optionals, webSocketID, 3309 "Runtime.getHeapUsage" 3310 ); 3311 3312 // 'JSON Binding' ... Converts Browser Response-JSON into Java-Type 'Ret4' 3313 Function<JsonObject, Ret4<Number, Number, Number, Number>> 3314 responseProcessor = (JsonObject jo) -> new Ret4<>( 3315 ReadNumberJSON.get(jo, "usedSize", false, true), 3316 ReadNumberJSON.get(jo, "totalSize", false, true), 3317 ReadNumberJSON.get(jo, "embedderHeapUsedSize", false, true), 3318 ReadNumberJSON.get(jo, "backingStorageSize", false, true) 3319 ); 3320 3321 return new Script<>(webSocketID, requestJSON, responseProcessor); 3322 } 3323 3324 /** 3325 * Returns properties of a given object. Object group of the result is inherited from the target 3326 * object. 3327 * 3328 * @param objectId Identifier of the object to return properties for. 3329 * 3330 * @param ownProperties 3331 * If true, returns properties belonging only to the element itself, not to its prototype 3332 * chain. 3333 * <BR /><B CLASS=Opt>OPTIONAL</B> 3334 * 3335 * @param accessorPropertiesOnly 3336 * If true, returns accessor properties (with getter/setter) only; internal properties are not 3337 * returned either. 3338 * <BR /><B CLASS=Opt>OPTIONAL</B><B CLASS=Exp>EXPERIMENTAL</B> 3339 * 3340 * @param generatePreview Whether preview should be generated for the results. 3341 * <BR /><B CLASS=Opt>OPTIONAL</B><B CLASS=Exp>EXPERIMENTAL</B> 3342 * 3343 * @param nonIndexedPropertiesOnly If true, returns non-indexed properties only. 3344 * <BR /><B CLASS=Opt>OPTIONAL</B><B CLASS=Exp>EXPERIMENTAL</B> 3345 * 3346 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 3347 * {@link Ret4}></CODE> 3348 * 3349 * <BR /><BR />This {@link Script} may be <B STYLE='color:red'>executed</B> (using 3350 * {@link Script#exec()}), and a {@link Promise} returned. 3351 * 3352 * <BR /><BR />When the {@code Promise} is <B STYLE='color: red'>awaited</B> 3353 * (using {@link Promise#await()}), the {@code Ret4} will subsequently 3354 * be returned from that call. 3355 * 3356 * <BR /><BR />The <B STYLE='color: red'>returned</B> values are encapsulated 3357 * in an instance of <B>{@link Ret4}</B> 3358 * 3359 * <BR /><BR /><UL CLASS=JDUL> 3360 * <LI><CODE><B>Ret4.a:</B> {@link RunTime.PropertyDescriptor}[] (<B>result</B>)</CODE> 3361 * <BR />Object properties. 3362 * <BR /><BR /></LI> 3363 * <LI><CODE><B>Ret4.b:</B> {@link RunTime.InternalPropertyDescriptor}[] (<B>internalProperties</B>)</CODE> 3364 * <BR />Internal object properties (only of the element itself). 3365 * <BR /><BR /></LI> 3366 * <LI><CODE><B>Ret4.c:</B> {@link RunTime.PrivatePropertyDescriptor}[] (<B>privateProperties</B>)</CODE> 3367 * <BR />Object private properties. 3368 * <BR /><BR /></LI> 3369 * <LI><CODE><B>Ret4.d:</B> {@link RunTime.ExceptionDetails} (<B>exceptionDetails</B>)</CODE> 3370 * <BR />Exception details. 3371 * </LI> 3372 * </UL> 3373 */ 3374 public static Script<String, JsonObject, Ret4<RunTime.PropertyDescriptor[], RunTime.InternalPropertyDescriptor[], RunTime.PrivatePropertyDescriptor[], RunTime.ExceptionDetails>> 3375 getProperties( 3376 String objectId, Boolean ownProperties, Boolean accessorPropertiesOnly, 3377 Boolean generatePreview, Boolean nonIndexedPropertiesOnly 3378 ) 3379 { 3380 // Exception-Check(s) to ensure that if any parameters which are not declared as 3381 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 3382 3383 if (objectId == null) THROWS.throwNPE("objectId"); 3384 3385 final int webSocketID = 5009000 + counter++; 3386 final boolean[] optionals = { false, true, true, true, true, }; 3387 3388 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 3389 String requestJSON = WriteJSON.get( 3390 parameterTypes.get("getProperties"), 3391 parameterNames.get("getProperties"), 3392 optionals, webSocketID, 3393 "Runtime.getProperties", 3394 objectId, ownProperties, accessorPropertiesOnly, generatePreview, 3395 nonIndexedPropertiesOnly 3396 ); 3397 3398 // 'JSON Binding' ... Converts Browser Response-JSON into Java-Type 'Ret4' 3399 Function<JsonObject, Ret4<RunTime.PropertyDescriptor[], RunTime.InternalPropertyDescriptor[], RunTime.PrivatePropertyDescriptor[], RunTime.ExceptionDetails>> 3400 responseProcessor = (JsonObject jo) -> new Ret4<>( 3401 (jo.getJsonArray("result") == null) 3402 ? null 3403 : RJArrIntoStream.objArr(jo.getJsonArray("result"), null, 0, RunTime.PropertyDescriptor.class).toArray(RunTime.PropertyDescriptor[]::new), 3404 (jo.getJsonArray("internalProperties") == null) 3405 ? null 3406 : RJArrIntoStream.objArr(jo.getJsonArray("internalProperties"), null, 0, RunTime.InternalPropertyDescriptor.class).toArray(RunTime.InternalPropertyDescriptor[]::new), 3407 (jo.getJsonArray("privateProperties") == null) 3408 ? null 3409 : RJArrIntoStream.objArr(jo.getJsonArray("privateProperties"), null, 0, RunTime.PrivatePropertyDescriptor.class).toArray(RunTime.PrivatePropertyDescriptor[]::new), 3410 ReadJSON.getObject(jo, "exceptionDetails", RunTime.ExceptionDetails.class, true, false) 3411 ); 3412 3413 return new Script<>(webSocketID, requestJSON, responseProcessor); 3414 } 3415 3416 /** 3417 * Returns all let, const and class variables from global scope. 3418 * 3419 * @param executionContextId Specifies in which execution context to lookup global scope variables. 3420 * <BR /><B CLASS=Opt>OPTIONAL</B> 3421 * 3422 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 3423 * String[]></CODE> 3424 * 3425 * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using 3426 * {@link Script#exec()}, and afterwards, a {@link Promise}<CODE><JsonObject, 3427 * String[]></CODE> will be returned. 3428 * 3429 * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>, 3430 * using {@link Promise#await()}, <I>and the returned result of this Browser Function may 3431 * may be retrieved.</I> 3432 * 3433 * <BR /><BR />This Browser Function <B STYLE='color: red'>returns</B> 3434 * <BR /><BR /><UL CLASS=JDUL> 3435 * <LI><CODE>String[] (<B>names</B></CODE>) 3436 * <BR />- 3437 * </LI> 3438 * </UL> */ 3439 public static Script<String, JsonObject, String[]> globalLexicalScopeNames 3440 (Integer executionContextId) 3441 { 3442 final int webSocketID = 5010000 + counter++; 3443 final boolean[] optionals = { true, }; 3444 3445 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 3446 String requestJSON = WriteJSON.get( 3447 parameterTypes.get("globalLexicalScopeNames"), 3448 parameterNames.get("globalLexicalScopeNames"), 3449 optionals, webSocketID, 3450 "Runtime.globalLexicalScopeNames", 3451 executionContextId 3452 ); 3453 3454 // 'JSON Binding' ... Converts Browser Response-JSON to 'String[]' 3455 Function<JsonObject, String[]> responseProcessor = (JsonObject jo) -> 3456 (jo.getJsonArray("names") == null) 3457 ? null 3458 : RJArrIntoStream.strArr(jo.getJsonArray("names"), null, 0).toArray(String[]::new); 3459 3460 return new Script<>(webSocketID, requestJSON, responseProcessor); 3461 } 3462 3463 /** 3464 * <CODE>[No Description Provided by Google]</CODE> 3465 * 3466 * @param prototypeObjectId Identifier of the prototype to return objects for. 3467 * 3468 * @param objectGroup Symbolic group name that can be used to release the results. 3469 * <BR /><B CLASS=Opt>OPTIONAL</B> 3470 * 3471 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 3472 * {@link RunTime.RemoteObject}></CODE> 3473 * 3474 * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using 3475 * {@link Script#exec()}, and afterwards, a {@link Promise}<CODE><JsonObject, 3476 * {@link RunTime.RemoteObject}></CODE> will be returned. 3477 * 3478 * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>, 3479 * using {@link Promise#await()}, <I>and the returned result of this Browser Function may 3480 * may be retrieved.</I> 3481 * 3482 * <BR /><BR />This Browser Function <B STYLE='color: red'>returns</B> 3483 * <BR /><BR /><UL CLASS=JDUL> 3484 * <LI><CODE>{@link RunTime.RemoteObject} (<B>objects</B></CODE>) 3485 * <BR />Array with objects. 3486 * </LI> 3487 * </UL> */ 3488 public static Script<String, JsonObject, RunTime.RemoteObject> queryObjects 3489 (String prototypeObjectId, String objectGroup) 3490 { 3491 // Exception-Check(s) to ensure that if any parameters which are not declared as 3492 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 3493 3494 if (prototypeObjectId == null) THROWS.throwNPE("prototypeObjectId"); 3495 3496 final int webSocketID = 5011000 + counter++; 3497 final boolean[] optionals = { false, true, }; 3498 3499 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 3500 String requestJSON = WriteJSON.get( 3501 parameterTypes.get("queryObjects"), 3502 parameterNames.get("queryObjects"), 3503 optionals, webSocketID, 3504 "Runtime.queryObjects", 3505 prototypeObjectId, objectGroup 3506 ); 3507 3508 // 'JSON Binding' ... Converts Browser Response-JSON to 'RunTime.RemoteObject' 3509 Function<JsonObject, RunTime.RemoteObject> responseProcessor = (JsonObject jo) -> 3510 ReadJSON.getObject(jo, "objects", RunTime.RemoteObject.class, false, true); 3511 3512 return new Script<>(webSocketID, requestJSON, responseProcessor); 3513 } 3514 3515 /** 3516 * Releases remote object with given id. 3517 * 3518 * @param objectId Identifier of the object to release. 3519 * 3520 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 3521 * {@link Ret0}></CODE> 3522 * 3523 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 3524 * browser receives the invocation-request. 3525 * 3526 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 3527 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 3528 * {@code >} to ensure the Browser Function has run to completion. 3529 */ 3530 public static Script<String, JsonObject, Ret0> releaseObject(String objectId) 3531 { 3532 // Exception-Check(s) to ensure that if any parameters which are not declared as 3533 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 3534 3535 if (objectId == null) THROWS.throwNPE("objectId"); 3536 3537 final int webSocketID = 5012000 + counter++; 3538 final boolean[] optionals = { false, }; 3539 3540 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 3541 String requestJSON = WriteJSON.get( 3542 parameterTypes.get("releaseObject"), 3543 parameterNames.get("releaseObject"), 3544 optionals, webSocketID, 3545 "Runtime.releaseObject", 3546 objectId 3547 ); 3548 3549 // This Remote Command does not have a Return-Value. 3550 return new Script<> 3551 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 3552 } 3553 3554 /** 3555 * Releases all remote objects that belong to a given group. 3556 * 3557 * @param objectGroup Symbolic object group name. 3558 * 3559 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 3560 * {@link Ret0}></CODE> 3561 * 3562 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 3563 * browser receives the invocation-request. 3564 * 3565 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 3566 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 3567 * {@code >} to ensure the Browser Function has run to completion. 3568 */ 3569 public static Script<String, JsonObject, Ret0> releaseObjectGroup(String objectGroup) 3570 { 3571 // Exception-Check(s) to ensure that if any parameters which are not declared as 3572 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 3573 3574 if (objectGroup == null) THROWS.throwNPE("objectGroup"); 3575 3576 final int webSocketID = 5013000 + counter++; 3577 final boolean[] optionals = { false, }; 3578 3579 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 3580 String requestJSON = WriteJSON.get( 3581 parameterTypes.get("releaseObjectGroup"), 3582 parameterNames.get("releaseObjectGroup"), 3583 optionals, webSocketID, 3584 "Runtime.releaseObjectGroup", 3585 objectGroup 3586 ); 3587 3588 // This Remote Command does not have a Return-Value. 3589 return new Script<> 3590 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 3591 } 3592 3593 /** 3594 * Tells inspected instance to run if it was waiting for debugger to attach. 3595 * 3596 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 3597 * {@link Ret0}></CODE> 3598 * 3599 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 3600 * browser receives the invocation-request. 3601 * 3602 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 3603 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 3604 * {@code >} to ensure the Browser Function has run to completion. 3605 */ 3606 public static Script<String, JsonObject, Ret0> runIfWaitingForDebugger() 3607 { 3608 final int webSocketID = 5014000 + counter++; 3609 final boolean[] optionals = new boolean[0]; 3610 3611 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 3612 String requestJSON = WriteJSON.get( 3613 parameterTypes.get("runIfWaitingForDebugger"), 3614 parameterNames.get("runIfWaitingForDebugger"), 3615 optionals, webSocketID, 3616 "Runtime.runIfWaitingForDebugger" 3617 ); 3618 3619 // This Remote Command does not have a Return-Value. 3620 return new Script<> 3621 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 3622 } 3623 3624 /** 3625 * Runs script with given id in a given context. 3626 * 3627 * @param scriptId Id of the script to run. 3628 * 3629 * @param executionContextId 3630 * Specifies in which execution context to perform script run. If the parameter is omitted the 3631 * evaluation will be performed in the context of the inspected page. 3632 * <BR /><B CLASS=Opt>OPTIONAL</B> 3633 * 3634 * @param objectGroup Symbolic group name that can be used to release multiple objects. 3635 * <BR /><B CLASS=Opt>OPTIONAL</B> 3636 * 3637 * @param silent 3638 * In silent mode exceptions thrown during evaluation are not reported and do not pause 3639 * execution. Overrides {@code setPauseOnException} state. 3640 * <BR /><B CLASS=Opt>OPTIONAL</B> 3641 * 3642 * @param includeCommandLineAPI Determines whether Command Line API should be available during the evaluation. 3643 * <BR /><B CLASS=Opt>OPTIONAL</B> 3644 * 3645 * @param returnByValue Whether the result is expected to be a JSON object which should be sent by value. 3646 * <BR /><B CLASS=Opt>OPTIONAL</B> 3647 * 3648 * @param generatePreview Whether preview should be generated for the result. 3649 * <BR /><B CLASS=Opt>OPTIONAL</B> 3650 * 3651 * @param awaitPromise 3652 * Whether execution should {@code await} for resulting value and return once awaited promise is 3653 * resolved. 3654 * <BR /><B CLASS=Opt>OPTIONAL</B> 3655 * 3656 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 3657 * {@link Ret2}></CODE> 3658 * 3659 * <BR /><BR />This {@link Script} may be <B STYLE='color:red'>executed</B> (using 3660 * {@link Script#exec()}), and a {@link Promise} returned. 3661 * 3662 * <BR /><BR />When the {@code Promise} is <B STYLE='color: red'>awaited</B> 3663 * (using {@link Promise#await()}), the {@code Ret2} will subsequently 3664 * be returned from that call. 3665 * 3666 * <BR /><BR />The <B STYLE='color: red'>returned</B> values are encapsulated 3667 * in an instance of <B>{@link Ret2}</B> 3668 * 3669 * <BR /><BR /><UL CLASS=JDUL> 3670 * <LI><CODE><B>Ret2.a:</B> {@link RunTime.RemoteObject} (<B>result</B>)</CODE> 3671 * <BR />Run result. 3672 * <BR /><BR /></LI> 3673 * <LI><CODE><B>Ret2.b:</B> {@link RunTime.ExceptionDetails} (<B>exceptionDetails</B>)</CODE> 3674 * <BR />Exception details. 3675 * </LI> 3676 * </UL> 3677 */ 3678 public static Script<String, JsonObject, Ret2<RunTime.RemoteObject, RunTime.ExceptionDetails>> runScript( 3679 String scriptId, Integer executionContextId, String objectGroup, Boolean silent, 3680 Boolean includeCommandLineAPI, Boolean returnByValue, Boolean generatePreview, 3681 Boolean awaitPromise 3682 ) 3683 { 3684 // Exception-Check(s) to ensure that if any parameters which are not declared as 3685 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 3686 3687 if (scriptId == null) THROWS.throwNPE("scriptId"); 3688 3689 final int webSocketID = 5015000 + counter++; 3690 final boolean[] optionals = { false, true, true, true, true, true, true, true, }; 3691 3692 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 3693 String requestJSON = WriteJSON.get( 3694 parameterTypes.get("runScript"), 3695 parameterNames.get("runScript"), 3696 optionals, webSocketID, 3697 "Runtime.runScript", 3698 scriptId, executionContextId, objectGroup, silent, includeCommandLineAPI, returnByValue, 3699 generatePreview, awaitPromise 3700 ); 3701 3702 // 'JSON Binding' ... Converts Browser Response-JSON into Java-Type 'Ret2' 3703 Function<JsonObject, Ret2<RunTime.RemoteObject, RunTime.ExceptionDetails>> 3704 responseProcessor = (JsonObject jo) -> new Ret2<>( 3705 ReadJSON.getObject(jo, "result", RunTime.RemoteObject.class, false, true), 3706 ReadJSON.getObject(jo, "exceptionDetails", RunTime.ExceptionDetails.class, true, false) 3707 ); 3708 3709 return new Script<>(webSocketID, requestJSON, responseProcessor); 3710 } 3711 3712 /** 3713 * Enables or disables async call stacks tracking. 3714 * 3715 * @param maxDepth 3716 * Maximum depth of async call stacks. Setting to {@code 0} will effectively disable collecting async 3717 * call stacks (default). 3718 * 3719 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 3720 * {@link Ret0}></CODE> 3721 * 3722 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 3723 * browser receives the invocation-request. 3724 * 3725 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 3726 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 3727 * {@code >} to ensure the Browser Function has run to completion. 3728 */ 3729 public static Script<String, JsonObject, Ret0> setAsyncCallStackDepth(int maxDepth) 3730 { 3731 final int webSocketID = 5016000 + counter++; 3732 final boolean[] optionals = { false, }; 3733 3734 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 3735 String requestJSON = WriteJSON.get( 3736 parameterTypes.get("setAsyncCallStackDepth"), 3737 parameterNames.get("setAsyncCallStackDepth"), 3738 optionals, webSocketID, 3739 "Runtime.setAsyncCallStackDepth", 3740 maxDepth 3741 ); 3742 3743 // This Remote Command does not have a Return-Value. 3744 return new Script<> 3745 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 3746 } 3747 3748 /** 3749 * <CODE>[No Description Provided by Google]</CODE> 3750 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 3751 * 3752 * @param enabled - 3753 * 3754 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 3755 * {@link Ret0}></CODE> 3756 * 3757 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 3758 * browser receives the invocation-request. 3759 * 3760 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 3761 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 3762 * {@code >} to ensure the Browser Function has run to completion. 3763 */ 3764 public static Script<String, JsonObject, Ret0> setCustomObjectFormatterEnabled 3765 (boolean enabled) 3766 { 3767 final int webSocketID = 5017000 + counter++; 3768 final boolean[] optionals = { false, }; 3769 3770 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 3771 String requestJSON = WriteJSON.get( 3772 parameterTypes.get("setCustomObjectFormatterEnabled"), 3773 parameterNames.get("setCustomObjectFormatterEnabled"), 3774 optionals, webSocketID, 3775 "Runtime.setCustomObjectFormatterEnabled", 3776 enabled 3777 ); 3778 3779 // This Remote Command does not have a Return-Value. 3780 return new Script<> 3781 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 3782 } 3783 3784 /** 3785 * <CODE>[No Description Provided by Google]</CODE> 3786 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 3787 * 3788 * @param size - 3789 * 3790 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 3791 * {@link Ret0}></CODE> 3792 * 3793 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 3794 * browser receives the invocation-request. 3795 * 3796 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 3797 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 3798 * {@code >} to ensure the Browser Function has run to completion. 3799 */ 3800 public static Script<String, JsonObject, Ret0> setMaxCallStackSizeToCapture(int size) 3801 { 3802 final int webSocketID = 5018000 + counter++; 3803 final boolean[] optionals = { false, }; 3804 3805 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 3806 String requestJSON = WriteJSON.get( 3807 parameterTypes.get("setMaxCallStackSizeToCapture"), 3808 parameterNames.get("setMaxCallStackSizeToCapture"), 3809 optionals, webSocketID, 3810 "Runtime.setMaxCallStackSizeToCapture", 3811 size 3812 ); 3813 3814 // This Remote Command does not have a Return-Value. 3815 return new Script<> 3816 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 3817 } 3818 3819 /** 3820 * Terminate current or next JavaScript execution. 3821 * Will cancel the termination when the outer-most script execution ends. 3822 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 3823 * 3824 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 3825 * {@link Ret0}></CODE> 3826 * 3827 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 3828 * browser receives the invocation-request. 3829 * 3830 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 3831 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 3832 * {@code >} to ensure the Browser Function has run to completion. 3833 */ 3834 public static Script<String, JsonObject, Ret0> terminateExecution() 3835 { 3836 final int webSocketID = 5019000 + counter++; 3837 final boolean[] optionals = new boolean[0]; 3838 3839 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 3840 String requestJSON = WriteJSON.get( 3841 parameterTypes.get("terminateExecution"), 3842 parameterNames.get("terminateExecution"), 3843 optionals, webSocketID, 3844 "Runtime.terminateExecution" 3845 ); 3846 3847 // This Remote Command does not have a Return-Value. 3848 return new Script<> 3849 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 3850 } 3851 3852 /** 3853 * If executionContextId is empty, adds binding with the given name on the 3854 * global objects of all inspected contexts, including those created later, 3855 * bindings survive reloads. 3856 * Binding function takes exactly one argument, this argument should be string, 3857 * in case of any other input, function throws an exception. 3858 * Each binding function call produces RunTime.bindingCalled notification. 3859 * 3860 * @param name - 3861 * 3862 * @param executionContextId 3863 * If specified, the binding would only be exposed to the specified 3864 * execution context. If omitted and {@code executionContextName} is not set, 3865 * the binding is exposed to all execution contexts of the target. 3866 * This parameter is mutually exclusive with {@code executionContextName}. 3867 * Deprecated in favor of {@code executionContextName} due to an unclear use case 3868 * and bugs in implementation (crbug.com/1169639). {@code executionContextId} will be 3869 * removed in the future. 3870 * <BR /><B CLASS=Opt>OPTIONAL</B><B CLASS=Exp>EXPERIMENTAL</B><B CLASS=Dep>DEPRECATED</B> 3871 * 3872 * @param executionContextName 3873 * If specified, the binding is exposed to the executionContext with 3874 * matching name, even for contexts created after the binding is added. 3875 * See also {@code ExecutionContext.name} and {@code worldName} parameter to 3876 * {@code Page.addScriptToEvaluateOnNewDocument}. 3877 * This parameter is mutually exclusive with {@code executionContextId}. 3878 * <BR /><B CLASS=Opt>OPTIONAL</B> 3879 * 3880 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 3881 * {@link Ret0}></CODE> 3882 * 3883 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 3884 * browser receives the invocation-request. 3885 * 3886 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 3887 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 3888 * {@code >} to ensure the Browser Function has run to completion. 3889 */ 3890 public static Script<String, JsonObject, Ret0> addBinding 3891 (String name, Integer executionContextId, String executionContextName) 3892 { 3893 // Exception-Check(s) to ensure that if any parameters which are not declared as 3894 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 3895 3896 if (name == null) THROWS.throwNPE("name"); 3897 3898 final int webSocketID = 5020000 + counter++; 3899 final boolean[] optionals = { false, true, true, }; 3900 3901 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 3902 String requestJSON = WriteJSON.get( 3903 parameterTypes.get("addBinding"), 3904 parameterNames.get("addBinding"), 3905 optionals, webSocketID, 3906 "Runtime.addBinding", 3907 name, executionContextId, executionContextName 3908 ); 3909 3910 // This Remote Command does not have a Return-Value. 3911 return new Script<> 3912 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 3913 } 3914 3915 /** 3916 * This method does not remove binding function from global object but 3917 * unsubscribes current runtime agent from RunTime.bindingCalled notifications. 3918 * 3919 * @param name - 3920 * 3921 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 3922 * {@link Ret0}></CODE> 3923 * 3924 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 3925 * browser receives the invocation-request. 3926 * 3927 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 3928 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 3929 * {@code >} to ensure the Browser Function has run to completion. 3930 */ 3931 public static Script<String, JsonObject, Ret0> removeBinding(String name) 3932 { 3933 // Exception-Check(s) to ensure that if any parameters which are not declared as 3934 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 3935 3936 if (name == null) THROWS.throwNPE("name"); 3937 3938 final int webSocketID = 5021000 + counter++; 3939 final boolean[] optionals = { false, }; 3940 3941 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 3942 String requestJSON = WriteJSON.get( 3943 parameterTypes.get("removeBinding"), 3944 parameterNames.get("removeBinding"), 3945 optionals, webSocketID, 3946 "Runtime.removeBinding", 3947 name 3948 ); 3949 3950 // This Remote Command does not have a Return-Value. 3951 return new Script<> 3952 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 3953 } 3954 3955 /** 3956 * This method tries to lookup and populate exception details for a 3957 * JavaScript Error object. 3958 * Note that the stackTrace portion of the resulting exceptionDetails will 3959 * only be populated if the RunTime domain was enabled at the time when the 3960 * Error was thrown. 3961 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 3962 * 3963 * @param errorObjectId The error object for which to resolve the exception details. 3964 * 3965 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 3966 * {@link RunTime.ExceptionDetails}></CODE> 3967 * 3968 * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using 3969 * {@link Script#exec()}, and afterwards, a {@link Promise}<CODE><JsonObject, 3970 * {@link RunTime.ExceptionDetails}></CODE> will be returned. 3971 * 3972 * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>, 3973 * using {@link Promise#await()}, <I>and the returned result of this Browser Function may 3974 * may be retrieved.</I> 3975 * 3976 * <BR /><BR />This Browser Function <B STYLE='color: red'>returns</B> 3977 * <BR /><BR /><UL CLASS=JDUL> 3978 * <LI><CODE>{@link RunTime.ExceptionDetails} (<B>exceptionDetails</B></CODE>) 3979 * <BR />- 3980 * </LI> 3981 * </UL> */ 3982 public static Script<String, JsonObject, RunTime.ExceptionDetails> getExceptionDetails 3983 (String errorObjectId) 3984 { 3985 // Exception-Check(s) to ensure that if any parameters which are not declared as 3986 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 3987 3988 if (errorObjectId == null) THROWS.throwNPE("errorObjectId"); 3989 3990 final int webSocketID = 5022000 + counter++; 3991 final boolean[] optionals = { false, }; 3992 3993 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 3994 String requestJSON = WriteJSON.get( 3995 parameterTypes.get("getExceptionDetails"), 3996 parameterNames.get("getExceptionDetails"), 3997 optionals, webSocketID, 3998 "Runtime.getExceptionDetails", 3999 errorObjectId 4000 ); 4001 4002 // 'JSON Binding' ... Converts Browser Response-JSON to 'RunTime.ExceptionDetails' 4003 Function<JsonObject, RunTime.ExceptionDetails> responseProcessor = (JsonObject jo) -> 4004 ReadJSON.getObject(jo, "exceptionDetails", RunTime.ExceptionDetails.class, true, false); 4005 4006 return new Script<>(webSocketID, requestJSON, responseProcessor); 4007 } 4008 4009}