WebBrowser

class WebBrowser(val sessionId: String, val httpRequestInfo: HttpRequestInfo, val kweb: Kweb)(source)

A conduit for communicating with a remote web browser, can be used to execute JavaScript and evaluate JavaScript expressions and retrieve the result.

Constructors

Link copied to clipboard
constructor(sessionId: String, httpRequestInfo: HttpRequestInfo, kweb: Kweb)

Types

Link copied to clipboard
Link copied to clipboard
data class FuncDeclaration(val js: String, val params: String)
Link copied to clipboard
data class OutboundMessageCatcher(var catcherType: WebBrowser.CatcherType, val functionList: MutableList<FunctionCall>)

Properties

Link copied to clipboard
Link copied to clipboard
val gurl: KVar<URL>

The absolute URL of the page, mapped to a io.mola.galimatias.URL for convenience.

Link copied to clipboard

During page render, the initial HTML document will be available for modification as a JSoup Document in this AtomicReference.

Link copied to clipboard
Link copied to clipboard
val kweb: Kweb
Link copied to clipboard

Allow us to catch outbound messages temporarily and only for this thread. This is used for immediate execution of event handlers, see Element.onImmediate

Link copied to clipboard
Link copied to clipboard

The URL of the page, relative to the origin - so for the page http://foo/bar?baz#1, the value would be /bar?baz#1.

Link copied to clipboard

Functions

Link copied to clipboard
fun addCloseListener(listener: () -> Unit): Int
Link copied to clipboard
fun <R> batch(catchingType: WebBrowser.CatcherType, f: () -> R): R
Link copied to clipboard
fun callJsFunction(jsBody: String, vararg args: JsonElement)

Calls a JavaScript function in the browser passing it the supplied parameters, which will be substituted into jsBody wherever a {} is present.

Link copied to clipboard
fun callJsFunctionWithCallback(jsBody: String, callbackId: Int, callback: (JsonElement) -> Unit, vararg args: JsonElement)

Calls a JavaScript function that can return a value via a callback

Link copied to clipboard
suspend fun callJsFunctionWithResult(jsBody: String, vararg args: JsonElement): JsonElement

Calls a JavaScript function that can return a value, note that to do this jsBody MUST end with a return statement, eg:

Link copied to clipboard
fun <R> catchOutbound(catchingType: WebBrowser.CatcherType, f: () -> R): Pair<List<FunctionCall>, R>

Execute a block of code in which any JavaScript sent to the browser during the execution of the block will be stored and returned by this function.

Link copied to clipboard
fun close()
Link copied to clipboard
Link copied to clipboard

Are outbound messages being cached for this thread (for example, because we're inside an immediateEvent callback block)?

Link copied to clipboard
fun onMessage(customFunction: (data: JsonElement?) -> Unit)
Link copied to clipboard
fun removeCallback(callbackId: Int)
Link copied to clipboard
Link copied to clipboard
fun sendMessage(data: JsonElement? = null)