Class RuntimeImpl

java.lang.Object
io.webfolder.cdp.command.RuntimeImpl
All Implemented Interfaces:
Runtime

public class RuntimeImpl
extends java.lang.Object
implements Runtime
  • Constructor Summary

    Constructors 
    Constructor Description
    RuntimeImpl​(SessionInvocationHandler handler)  
  • Method Summary

    Modifier and Type Method Description
    void addBinding​(java.lang.String name)
    If executionContextId is empty, adds binding with the given name on the global objects of all inspected contexts, including those created later, bindings survive reloads.
    void addBinding​(java.lang.String name, java.lang.Integer executionContextId)
    If executionContextId is empty, adds binding with the given name on the global objects of all inspected contexts, including those created later, bindings survive reloads.
    AwaitPromiseResult awaitPromise​(java.lang.String promiseObjectId)
    Add handler to promise with given promise object id.
    AwaitPromiseResult awaitPromise​(java.lang.String promiseObjectId, java.lang.Boolean returnByValue, java.lang.Boolean generatePreview)
    Add handler to promise with given promise object id.
    CallFunctionOnResult callFunctionOn​(java.lang.String functionDeclaration)
    Calls function with given declaration on the given object.
    CallFunctionOnResult callFunctionOn​(java.lang.String functionDeclaration, java.lang.String objectId, java.util.List<CallArgument> arguments, java.lang.Boolean silent, java.lang.Boolean returnByValue, java.lang.Boolean generatePreview, java.lang.Boolean userGesture, java.lang.Boolean awaitPromise, java.lang.Integer executionContextId, java.lang.String objectGroup)
    Calls function with given declaration on the given object.
    CompileScriptResult compileScript​(java.lang.String expression, java.lang.String sourceURL, java.lang.Boolean persistScript)
    Compiles expression.
    CompileScriptResult compileScript​(java.lang.String expression, java.lang.String sourceURL, java.lang.Boolean persistScript, java.lang.Integer executionContextId)
    Compiles expression.
    void disable()
    Disables reporting of execution contexts creation.
    void discardConsoleEntries()
    Discards collected exceptions and console API calls.
    void enable()
    Enables reporting of execution contexts creation by means of `executionContextCreated` event.
    EvaluateResult evaluate​(java.lang.String expression)
    Evaluates expression on global object.
    EvaluateResult evaluate​(java.lang.String expression, java.lang.String objectGroup, java.lang.Boolean includeCommandLineAPI, java.lang.Boolean silent, java.lang.Integer contextId, java.lang.Boolean returnByValue, java.lang.Boolean generatePreview, java.lang.Boolean userGesture, java.lang.Boolean awaitPromise, java.lang.Boolean throwOnSideEffect, java.lang.Double timeout, java.lang.Boolean disableBreaks, java.lang.Boolean replMode)
    Evaluates expression on global object.
    GetHeapUsageResult getHeapUsage()
    Returns the JavaScript heap usage.
    java.lang.String getIsolateId()
    Returns the isolate id.
    GetPropertiesResult getProperties​(java.lang.String objectId)
    Returns properties of a given object.
    GetPropertiesResult getProperties​(java.lang.String objectId, java.lang.Boolean ownProperties, java.lang.Boolean accessorPropertiesOnly, java.lang.Boolean generatePreview)
    Returns properties of a given object.
    java.util.List<java.lang.String> globalLexicalScopeNames()
    Returns all let, const and class variables from global scope.
    java.util.List<java.lang.String> globalLexicalScopeNames​(java.lang.Integer executionContextId)
    Returns all let, const and class variables from global scope.
    RemoteObject queryObjects​(java.lang.String prototypeObjectId)  
    RemoteObject queryObjects​(java.lang.String prototypeObjectId, java.lang.String objectGroup)  
    void releaseObject​(java.lang.String objectId)
    Releases remote object with given id.
    void releaseObjectGroup​(java.lang.String objectGroup)
    Releases all remote objects that belong to a given group.
    void removeBinding​(java.lang.String name)
    This method does not remove binding function from global object but unsubscribes current runtime agent from Runtime.bindingCalled notifications.
    void runIfWaitingForDebugger()
    Tells inspected instance to run if it was waiting for debugger to attach.
    RunScriptResult runScript​(java.lang.String scriptId)
    Runs script with given id in a given context.
    RunScriptResult runScript​(java.lang.String scriptId, java.lang.Integer executionContextId, java.lang.String objectGroup, java.lang.Boolean silent, java.lang.Boolean includeCommandLineAPI, java.lang.Boolean returnByValue, java.lang.Boolean generatePreview, java.lang.Boolean awaitPromise)
    Runs script with given id in a given context.
    void setAsyncCallStackDepth​(java.lang.Integer maxDepth)
    Enables or disables async call stacks tracking.
    void setCustomObjectFormatterEnabled​(java.lang.Boolean enabled)  
    void setMaxCallStackSizeToCapture​(java.lang.Integer size)  
    void terminateExecution()
    Terminate current or next JavaScript execution.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • awaitPromise

      public AwaitPromiseResult awaitPromise​(java.lang.String promiseObjectId, java.lang.Boolean returnByValue, java.lang.Boolean generatePreview)
      Description copied from interface: Runtime
      Add handler to promise with given promise object id.
      Specified by:
      awaitPromise in interface Runtime
      Parameters:
      promiseObjectId - Identifier of the promise.
      returnByValue - Whether the result is expected to be a JSON object that should be sent by value.
      generatePreview - Whether preview should be generated for the result.
      Returns:
      AwaitPromiseResult
    • callFunctionOn

      public CallFunctionOnResult callFunctionOn​(java.lang.String functionDeclaration, java.lang.String objectId, java.util.List<CallArgument> arguments, java.lang.Boolean silent, java.lang.Boolean returnByValue, java.lang.Boolean generatePreview, java.lang.Boolean userGesture, java.lang.Boolean awaitPromise, java.lang.Integer executionContextId, java.lang.String objectGroup)
      Description copied from interface: Runtime
      Calls function with given declaration on the given object. Object group of the result is inherited from the target object.
      Specified by:
      callFunctionOn in interface Runtime
      Parameters:
      functionDeclaration - Declaration of the function to call.
      objectId - Identifier of the object to call function on. Either objectId or executionContextId should be specified.
      arguments - Call arguments. All call arguments must belong to the same JavaScript world as the target object.
      silent - In silent mode exceptions thrown during evaluation are not reported and do not pause execution. Overrides `setPauseOnException` state.
      returnByValue - Whether the result is expected to be a JSON object which should be sent by value.
      generatePreview - Whether preview should be generated for the result.
      userGesture - Whether execution should be treated as initiated by user in the UI.
      awaitPromise - Whether execution should `await` for resulting value and return once awaited promise is resolved.
      executionContextId - Specifies execution context which global object will be used to call function on. Either executionContextId or objectId should be specified.
      objectGroup - Symbolic group name that can be used to release multiple objects. If objectGroup is not specified and objectId is, objectGroup will be inherited from object.
      Returns:
      CallFunctionOnResult
    • compileScript

      public CompileScriptResult compileScript​(java.lang.String expression, java.lang.String sourceURL, java.lang.Boolean persistScript, java.lang.Integer executionContextId)
      Description copied from interface: Runtime
      Compiles expression.
      Specified by:
      compileScript in interface Runtime
      Parameters:
      expression - Expression to compile.
      sourceURL - Source url to be set for the script.
      persistScript - Specifies whether the compiled script should be persisted.
      executionContextId - Specifies in which execution context to perform script run. If the parameter is omitted the evaluation will be performed in the context of the inspected page.
      Returns:
      CompileScriptResult
    • disable

      public void disable()
      Description copied from interface: Runtime
      Disables reporting of execution contexts creation.
      Specified by:
      disable in interface Runtime
    • discardConsoleEntries

      public void discardConsoleEntries()
      Description copied from interface: Runtime
      Discards collected exceptions and console API calls.
      Specified by:
      discardConsoleEntries in interface Runtime
    • enable

      public void enable()
      Description copied from interface: Runtime
      Enables reporting of execution contexts creation by means of `executionContextCreated` event. When the reporting gets enabled the event will be sent immediately for each existing execution context.
      Specified by:
      enable in interface Runtime
    • evaluate

      public EvaluateResult evaluate​(java.lang.String expression, java.lang.String objectGroup, java.lang.Boolean includeCommandLineAPI, java.lang.Boolean silent, java.lang.Integer contextId, java.lang.Boolean returnByValue, java.lang.Boolean generatePreview, java.lang.Boolean userGesture, java.lang.Boolean awaitPromise, java.lang.Boolean throwOnSideEffect, java.lang.Double timeout, java.lang.Boolean disableBreaks, java.lang.Boolean replMode)
      Description copied from interface: Runtime
      Evaluates expression on global object.
      Specified by:
      evaluate in interface Runtime
      Parameters:
      expression - Expression to evaluate.
      objectGroup - Symbolic group name that can be used to release multiple objects.
      includeCommandLineAPI - Determines whether Command Line API should be available during the evaluation.
      silent - In silent mode exceptions thrown during evaluation are not reported and do not pause execution. Overrides `setPauseOnException` state.
      contextId - Specifies in which execution context to perform evaluation. If the parameter is omitted the evaluation will be performed in the context of the inspected page.
      returnByValue - Whether the result is expected to be a JSON object that should be sent by value.
      generatePreview - Whether preview should be generated for the result.
      userGesture - Whether execution should be treated as initiated by user in the UI.
      awaitPromise - Whether execution should `await` for resulting value and return once awaited promise is resolved.
      throwOnSideEffect - Whether to throw an exception if side effect cannot be ruled out during evaluation. This implies `disableBreaks` below.
      timeout - Terminate execution after timing out (number of milliseconds).
      disableBreaks - Disable breakpoints during execution.
      replMode - Reserved flag for future REPL mode support. Setting this flag has currently no effect.
      Returns:
      EvaluateResult
    • getIsolateId

      public java.lang.String getIsolateId()
      Description copied from interface: Runtime
      Returns the isolate id.
      Specified by:
      getIsolateId in interface Runtime
      Returns:
      The isolate id.
    • getHeapUsage

      public GetHeapUsageResult getHeapUsage()
      Description copied from interface: Runtime
      Returns the JavaScript heap usage. It is the total usage of the corresponding isolate not scoped to a particular Runtime.
      Specified by:
      getHeapUsage in interface Runtime
      Returns:
      GetHeapUsageResult
    • getProperties

      public GetPropertiesResult getProperties​(java.lang.String objectId, java.lang.Boolean ownProperties, java.lang.Boolean accessorPropertiesOnly, java.lang.Boolean generatePreview)
      Description copied from interface: Runtime
      Returns properties of a given object. Object group of the result is inherited from the target object.
      Specified by:
      getProperties in interface Runtime
      Parameters:
      objectId - Identifier of the object to return properties for.
      ownProperties - If true, returns properties belonging only to the element itself, not to its prototype chain.
      accessorPropertiesOnly - If true, returns accessor properties (with getter/setter) only; internal properties are not returned either.
      generatePreview - Whether preview should be generated for the results.
      Returns:
      GetPropertiesResult
    • globalLexicalScopeNames

      public java.util.List<java.lang.String> globalLexicalScopeNames​(java.lang.Integer executionContextId)
      Description copied from interface: Runtime
      Returns all let, const and class variables from global scope.
      Specified by:
      globalLexicalScopeNames in interface Runtime
      Parameters:
      executionContextId - Specifies in which execution context to lookup global scope variables.
    • queryObjects

      public RemoteObject queryObjects​(java.lang.String prototypeObjectId, java.lang.String objectGroup)
      Specified by:
      queryObjects in interface Runtime
    • releaseObject

      public void releaseObject​(java.lang.String objectId)
      Description copied from interface: Runtime
      Releases remote object with given id.
      Specified by:
      releaseObject in interface Runtime
      Parameters:
      objectId - Identifier of the object to release.
    • releaseObjectGroup

      public void releaseObjectGroup​(java.lang.String objectGroup)
      Description copied from interface: Runtime
      Releases all remote objects that belong to a given group.
      Specified by:
      releaseObjectGroup in interface Runtime
      Parameters:
      objectGroup - Symbolic object group name.
    • runIfWaitingForDebugger

      public void runIfWaitingForDebugger()
      Description copied from interface: Runtime
      Tells inspected instance to run if it was waiting for debugger to attach.
      Specified by:
      runIfWaitingForDebugger in interface Runtime
    • runScript

      public RunScriptResult runScript​(java.lang.String scriptId, java.lang.Integer executionContextId, java.lang.String objectGroup, java.lang.Boolean silent, java.lang.Boolean includeCommandLineAPI, java.lang.Boolean returnByValue, java.lang.Boolean generatePreview, java.lang.Boolean awaitPromise)
      Description copied from interface: Runtime
      Runs script with given id in a given context.
      Specified by:
      runScript in interface Runtime
      Parameters:
      scriptId - Id of the script to run.
      executionContextId - Specifies in which execution context to perform script run. If the parameter is omitted the evaluation will be performed in the context of the inspected page.
      objectGroup - Symbolic group name that can be used to release multiple objects.
      silent - In silent mode exceptions thrown during evaluation are not reported and do not pause execution. Overrides `setPauseOnException` state.
      includeCommandLineAPI - Determines whether Command Line API should be available during the evaluation.
      returnByValue - Whether the result is expected to be a JSON object which should be sent by value.
      generatePreview - Whether preview should be generated for the result.
      awaitPromise - Whether execution should `await` for resulting value and return once awaited promise is resolved.
      Returns:
      RunScriptResult
    • setAsyncCallStackDepth

      public void setAsyncCallStackDepth​(java.lang.Integer maxDepth)
      Description copied from interface: Runtime
      Enables or disables async call stacks tracking.
      Specified by:
      setAsyncCallStackDepth in interface Runtime
      Parameters:
      maxDepth - Maximum depth of async call stacks. Setting to `0` will effectively disable collecting async call stacks (default).
    • setCustomObjectFormatterEnabled

      public void setCustomObjectFormatterEnabled​(java.lang.Boolean enabled)
      Specified by:
      setCustomObjectFormatterEnabled in interface Runtime
    • setMaxCallStackSizeToCapture

      public void setMaxCallStackSizeToCapture​(java.lang.Integer size)
      Specified by:
      setMaxCallStackSizeToCapture in interface Runtime
    • terminateExecution

      public void terminateExecution()
      Description copied from interface: Runtime
      Terminate current or next JavaScript execution. Will cancel the termination when the outer-most script execution ends.
      Specified by:
      terminateExecution in interface Runtime
    • addBinding

      public void addBinding​(java.lang.String name, java.lang.Integer executionContextId)
      Description copied from interface: Runtime
      If executionContextId is empty, adds binding with the given name on the global objects of all inspected contexts, including those created later, bindings survive reloads. If executionContextId is specified, adds binding only on global object of given execution context. Binding function takes exactly one argument, this argument should be string, in case of any other input, function throws an exception. Each binding function call produces Runtime.bindingCalled notification.
      Specified by:
      addBinding in interface Runtime
    • removeBinding

      public void removeBinding​(java.lang.String name)
      Description copied from interface: Runtime
      This method does not remove binding function from global object but unsubscribes current runtime agent from Runtime.bindingCalled notifications.
      Specified by:
      removeBinding in interface Runtime
    • awaitPromise

      public AwaitPromiseResult awaitPromise​(java.lang.String promiseObjectId)
      Description copied from interface: Runtime
      Add handler to promise with given promise object id.
      Specified by:
      awaitPromise in interface Runtime
      Parameters:
      promiseObjectId - Identifier of the promise.
      Returns:
      AwaitPromiseResult
    • callFunctionOn

      public CallFunctionOnResult callFunctionOn​(java.lang.String functionDeclaration)
      Description copied from interface: Runtime
      Calls function with given declaration on the given object. Object group of the result is inherited from the target object.
      Specified by:
      callFunctionOn in interface Runtime
      Parameters:
      functionDeclaration - Declaration of the function to call.
      Returns:
      CallFunctionOnResult
    • compileScript

      public CompileScriptResult compileScript​(java.lang.String expression, java.lang.String sourceURL, java.lang.Boolean persistScript)
      Description copied from interface: Runtime
      Compiles expression.
      Specified by:
      compileScript in interface Runtime
      Parameters:
      expression - Expression to compile.
      sourceURL - Source url to be set for the script.
      persistScript - Specifies whether the compiled script should be persisted.
      Returns:
      CompileScriptResult
    • evaluate

      public EvaluateResult evaluate​(java.lang.String expression)
      Description copied from interface: Runtime
      Evaluates expression on global object.
      Specified by:
      evaluate in interface Runtime
      Parameters:
      expression - Expression to evaluate.
      Returns:
      EvaluateResult
    • getProperties

      public GetPropertiesResult getProperties​(java.lang.String objectId)
      Description copied from interface: Runtime
      Returns properties of a given object. Object group of the result is inherited from the target object.
      Specified by:
      getProperties in interface Runtime
      Parameters:
      objectId - Identifier of the object to return properties for.
      Returns:
      GetPropertiesResult
    • globalLexicalScopeNames

      public java.util.List<java.lang.String> globalLexicalScopeNames()
      Description copied from interface: Runtime
      Returns all let, const and class variables from global scope.
      Specified by:
      globalLexicalScopeNames in interface Runtime
    • queryObjects

      public RemoteObject queryObjects​(java.lang.String prototypeObjectId)
      Specified by:
      queryObjects in interface Runtime
    • runScript

      public RunScriptResult runScript​(java.lang.String scriptId)
      Description copied from interface: Runtime
      Runs script with given id in a given context.
      Specified by:
      runScript in interface Runtime
      Parameters:
      scriptId - Id of the script to run.
      Returns:
      RunScriptResult
    • addBinding

      public void addBinding​(java.lang.String name)
      Description copied from interface: Runtime
      If executionContextId is empty, adds binding with the given name on the global objects of all inspected contexts, including those created later, bindings survive reloads. If executionContextId is specified, adds binding only on global object of given execution context. Binding function takes exactly one argument, this argument should be string, in case of any other input, function throws an exception. Each binding function call produces Runtime.bindingCalled notification.
      Specified by:
      addBinding in interface Runtime