Interface Runtime


  • public interface Runtime
    Runtime domain exposes JavaScript runtime by means of remote evaluation and mirror objects Evaluation results are returned as mirror object that expose object type, string representation and unique identifier that can be used for further object reference Original objects are maintained in memory unless they are either explicitly released or are released along with the other objects in their object group
    • 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)
      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.
    • Method Detail

      • awaitPromise

        AwaitPromiseResult awaitPromise​(java.lang.String promiseObjectId,
                                        java.lang.Boolean returnByValue,
                                        java.lang.Boolean generatePreview)
        Add handler to promise with given promise object id.
        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

        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. Object group of the result is inherited from the target object.
        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

        CompileScriptResult compileScript​(java.lang.String expression,
                                          java.lang.String sourceURL,
                                          java.lang.Boolean persistScript,
                                          java.lang.Integer executionContextId)
        Compiles expression.
        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

        void disable()
        Disables reporting of execution contexts creation.
      • discardConsoleEntries

        void discardConsoleEntries()
        Discards collected exceptions and console API calls.
      • enable

        void enable()
        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.
      • evaluate

        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)
        Evaluates expression on global object.
        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.
        timeout - Terminate execution after timing out (number of milliseconds).
        Returns:
        EvaluateResult
      • getIsolateId

        java.lang.String getIsolateId()
        Returns the isolate id.
        Returns:
        The isolate id.
      • getHeapUsage

        GetHeapUsageResult getHeapUsage()
        Returns the JavaScript heap usage. It is the total usage of the corresponding isolate not scoped to a particular Runtime.
        Returns:
        GetHeapUsageResult
      • getProperties

        GetPropertiesResult getProperties​(java.lang.String objectId,
                                          java.lang.Boolean ownProperties,
                                          java.lang.Boolean accessorPropertiesOnly,
                                          java.lang.Boolean generatePreview)
        Returns properties of a given object. Object group of the result is inherited from the target object.
        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

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

        RemoteObject queryObjects​(java.lang.String prototypeObjectId,
                                  java.lang.String objectGroup)
      • releaseObject

        void releaseObject​(java.lang.String objectId)
        Releases remote object with given id.
        Parameters:
        objectId - Identifier of the object to release.
      • releaseObjectGroup

        void releaseObjectGroup​(java.lang.String objectGroup)
        Releases all remote objects that belong to a given group.
        Parameters:
        objectGroup - Symbolic object group name.
      • runIfWaitingForDebugger

        void runIfWaitingForDebugger()
        Tells inspected instance to run if it was waiting for debugger to attach.
      • runScript

        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.
        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

        void setAsyncCallStackDepth​(java.lang.Integer maxDepth)
        Enables or disables async call stacks tracking.
        Parameters:
        maxDepth - Maximum depth of async call stacks. Setting to 0 will effectively disable collecting async call stacks (default).
      • setCustomObjectFormatterEnabled

        void setCustomObjectFormatterEnabled​(java.lang.Boolean enabled)
      • setMaxCallStackSizeToCapture

        void setMaxCallStackSizeToCapture​(java.lang.Integer size)
      • terminateExecution

        void terminateExecution()
        Terminate current or next JavaScript execution. Will cancel the termination when the outer-most script execution ends.
      • addBinding

        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. 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.
      • removeBinding

        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.
      • awaitPromise

        AwaitPromiseResult awaitPromise​(java.lang.String promiseObjectId)
        Add handler to promise with given promise object id.
        Parameters:
        promiseObjectId - Identifier of the promise.
        Returns:
        AwaitPromiseResult
      • callFunctionOn

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

        CompileScriptResult compileScript​(java.lang.String expression,
                                          java.lang.String sourceURL,
                                          java.lang.Boolean persistScript)
        Compiles expression.
        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

        EvaluateResult evaluate​(java.lang.String expression)
        Evaluates expression on global object.
        Parameters:
        expression - Expression to evaluate.
        Returns:
        EvaluateResult
      • getProperties

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

        java.util.List<java.lang.String> globalLexicalScopeNames()
        Returns all let, const and class variables from global scope.
      • queryObjects

        RemoteObject queryObjects​(java.lang.String prototypeObjectId)
      • runScript

        RunScriptResult runScript​(java.lang.String scriptId)
        Runs script with given id in a given context.
        Parameters:
        scriptId - Id of the script to run.
        Returns:
        RunScriptResult
      • addBinding

        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. 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.