Class WorkerImpl

    • Constructor Detail

      • WorkerImpl

        WorkerImpl​(ChannelOwner parent,
                   java.lang.String type,
                   java.lang.String guid,
                   com.google.gson.JsonObject initializer)
    • Method Detail

      • onClose

        public void onClose​(java.util.function.Consumer<Worker> handler)
        Description copied from interface: Worker
        Emitted when this dedicated WebWorker is terminated.
        Specified by:
        onClose in interface Worker
      • offClose

        public void offClose​(java.util.function.Consumer<Worker> handler)
        Description copied from interface: Worker
        Removes handler that was previously added with onClose(handler).
        Specified by:
        offClose in interface Worker
      • waitForEventWithTimeout

        private <T> T waitForEventWithTimeout​(WorkerImpl.EventType eventType,
                                              java.lang.Runnable code,
                                              java.lang.Double timeout)
      • waitForClose

        public Worker waitForClose​(Worker.WaitForCloseOptions options,
                                   java.lang.Runnable code)
        Description copied from interface: Worker
        Performs action and waits for the Worker to close.
        Specified by:
        waitForClose in interface Worker
        code - Callback that performs the action triggering the event.
      • evaluate

        public java.lang.Object evaluate​(java.lang.String pageFunction,
                                         java.lang.Object arg)
        Description copied from interface: Worker
        Returns the return value of expression.

        If the function passed to the Worker.evaluate() returns a Promise, then Worker.evaluate() would wait for the promise to resolve and return its value.

        If the function passed to the Worker.evaluate() returns a non-[Serializable] value, then Worker.evaluate() returns undefined. Playwright also supports transferring some additional values that are not serializable by JSON: -0, NaN, Infinity, -Infinity.

        Specified by:
        evaluate in interface Worker
        Parameters:
        pageFunction - JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is automatically invoked.
        arg - Optional argument to pass to expression.
      • evaluateHandle

        public JSHandle evaluateHandle​(java.lang.String pageFunction,
                                       java.lang.Object arg)
        Description copied from interface: Worker
        Returns the return value of expression as a JSHandle.

        The only difference between Worker.evaluate() and Worker.evaluateHandle() is that Worker.evaluateHandle() returns JSHandle.

        If the function passed to the Worker.evaluateHandle() returns a Promise, then Worker.evaluateHandle() would wait for the promise to resolve and return its value.

        Specified by:
        evaluateHandle in interface Worker
        Parameters:
        pageFunction - JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is automatically invoked.
        arg - Optional argument to pass to expression.
      • url

        public java.lang.String url()
        Specified by:
        url in interface Worker
      • handleEvent

        protected void handleEvent​(java.lang.String event,
                                   com.google.gson.JsonObject params)
        Overrides:
        handleEvent in class ChannelOwner