Skip to content

Latest commit

 

History

History
871 lines (686 loc) · 20 KB

WebKitBrowserPlugin.md

File metadata and controls

871 lines (686 loc) · 20 KB

WebKit Browser Plugin

Version: 1.0

Status: ⚫⚫⚫

WebKitBrowser plugin for Thunder framework.

Table of Contents

Introduction

Scope

This document describes purpose and functionality of the WebKitBrowser plugin. It includes detailed specification of its configuration, methods and properties provided, as well as notifications sent.

Case Sensitivity

All identifiers on the interface described in this document are case-sensitive. Thus, unless stated otherwise, all keywords, entities, properties, relations and actions should be treated as such.

Acronyms, Abbreviations and Terms

The table below provides and overview of acronyms used in this document and their definitions.

Acronym Description
API Application Programming Interface
HTTP Hypertext Transfer Protocol
JSON JavaScript Object Notation; a data interchange format
JSON-RPC A remote procedure call protocol encoded in JSON

The table below provides and overview of terms and abbreviations used in this document and their definitions.

Term Description
callsign The name given to an instance of a plugin. One plugin can be instantiated multiple times, but each instance the instance name, callsign, must be unique.

References

Ref ID Description
HTTP HTTP specification
JSON-RPC JSON-RPC 2.0 specification
JSON JSON specification
Thunder Thunder API Reference

Description

The WebKitBrowser plugin provides web browsing functionality based on the WebKit engine.

The plugin is designed to be loaded and executed within the Thunder framework. For more information about the framework refer to [Thunder].

Configuration

The table below lists configuration options of the plugin.

Name Type Description
callsign string Plugin instance name (default: WebKitBrowser)
classname string Class name: WebKitBrowser
locator string Library name: libWPEFrameworkWebKitBrowser.so
autostart boolean Determines if the plugin is to be started automatically along with the framework
configuration object (optional)
configuration?.useragent string (optional) The UserAgent used during communication with the web server
configuration?.url string (optional) The URL that is loaded upon starting the browser
configuration?.injectedbundle string (optional) The name of the .so loaded to extend the HTML5 with customized JavaScript handlers
configuration?.cookiestorage string (optional) Post-fixed path to the persistent location on where cookies will be stored
configuration?.localstorage string (optional) Post-fixed path to the persistent location on where local-storage will be stored
configuration?.certificatecheck boolean (optional) If enabled, SSL certificate error will lead to a page error
configuration?.javascript object (optional)
configuration?.javascript?.useLLInt boolean (optional) Enable Low Level Interpreter
configuration?.javascript?.useJIT boolean (optional) Enable JIT
configuration?.javascript?.useDFG boolean (optional) Enable Data-Flow-Graph-JIT compiler
configuration?.javascript?.useFTL boolean (optional) Enable Faster-Than-Light-JIT compiler
configuration?.javascript?.useDOM boolean (optional) Enable the DOM-JIT compiler
configuration?.javascript?.dumpOptions string (optional) Dump options: 0 = None, 1 = Overridden only, 2 = All, 3 = Verbose
configuration?.secure boolean (optional) If false, every domain can access any other domain, otherwise fill in fields in whitelist definition table
configuration?.whitelist object (optional)
configuration?.whitelist?.origin string (optional) Origin domain allowed to access domains in domain
configuration?.whitelist?.domain array (optional)
configuration?.whitelist?.domain[#] string (optional) Domain allowed to access from origin
configuration?.whitelist?.subdomain string (optional) whether it is also OK to access subdomains of domains listed in domain
configuration?.localstorageenabled boolean (optional) Controls the local storage availability

Methods

The following methods are provided by the WebKitBrowser plugin:

WebKitBrowser interface methods:

Method Description
bridgereply A response for legacy $badger
bridgeevent Send legacy $badger event

bridgereply method

A response for legacy $badger.

Parameters

Name Type Description
params string A base64 encoded JSON string response to be delivered to $badger.callback(pid, success, json)

Result

Name Type Description
result null

Example

Request

{
    "jsonrpc": "2.0",
    "id": 1234567890,
    "method": "WebKitBrowser.1.bridgereply",
    "params": ""
}

Response

{
    "jsonrpc": "2.0",
    "id": 1234567890,
    "result": null
}

bridgeevent method

Send legacy $badger event.

Parameters

Name Type Description
params string A base64 encoded JSON string response to be delivered to window.$badger.event(handlerId, json)

Result

Name Type Description
result null

Example

Request

{
    "jsonrpc": "2.0",
    "id": 1234567890,
    "method": "WebKitBrowser.1.bridgeevent",
    "params": ""
}

Response

{
    "jsonrpc": "2.0",
    "id": 1234567890,
    "result": null
}

Properties

The following properties are provided by the WebKitBrowser plugin:

WebKitBrowser interface properties:

Property Description
useragent UserAgent string used by browser
httpcookieacceptpolicy HTTP cookies accept policy
localstorageenabled Controls the local storage availability
languages User preferred languages
headers Headers to send on all requests that the browser makes

Browser interface properties:

Property Description
url URL loaded in the browser
visibility Current browser visibility
fps RO Current number of frames per second the browser is rendering

StateControl interface properties:

Property Description
state Running state of the service

useragent property

Provides access to the userAgent string used by browser.

Value

Name Type Description
(property) string UserAgent string used by browser

Example

Get Request

{
    "jsonrpc": "2.0",
    "id": 1234567890,
    "method": "WebKitBrowser.1.useragent"
}

Get Response

{
    "jsonrpc": "2.0",
    "id": 1234567890,
    "result": "Mozilla/5.0 (Linux; x86_64 GNU/Linux) AppleWebKit/601.1 (KHTML, like Gecko) Version/8.0 Safari/601.1 WP"
}

Set Request

{
    "jsonrpc": "2.0",
    "id": 1234567890,
    "method": "WebKitBrowser.1.useragent",
    "params": "Mozilla/5.0 (Linux; x86_64 GNU/Linux) AppleWebKit/601.1 (KHTML, like Gecko) Version/8.0 Safari/601.1 WP"
}

Set Response

{
    "jsonrpc": "2.0",
    "id": 1234567890,
    "result": "null"
}

httpcookieacceptpolicy property

Provides access to the HTTP cookies accept policy.

Value

Name Type Description
(property) string HTTP cookies accept policy (must be one of the following: always, never, onlyfrommaindocumentdomain, exclusivelyfrommaindocumentdomain)

Errors

Code Message Description
22 ERROR_UNKNOWN_KEY Unknown policy

Example

Get Request

{
    "jsonrpc": "2.0",
    "id": 1234567890,
    "method": "WebKitBrowser.1.httpcookieacceptpolicy"
}

Get Response

{
    "jsonrpc": "2.0",
    "id": 1234567890,
    "result": "always"
}

Set Request

{
    "jsonrpc": "2.0",
    "id": 1234567890,
    "method": "WebKitBrowser.1.httpcookieacceptpolicy",
    "params": "always"
}

Set Response

{
    "jsonrpc": "2.0",
    "id": 1234567890,
    "result": "null"
}

localstorageenabled property

Provides access to the controls the local storage availability.

Value

Name Type Description
(property) boolean Controls the local storage availability

Example

Get Request

{
    "jsonrpc": "2.0",
    "id": 1234567890,
    "method": "WebKitBrowser.1.localstorageenabled"
}

Get Response

{
    "jsonrpc": "2.0",
    "id": 1234567890,
    "result": false
}

Set Request

{
    "jsonrpc": "2.0",
    "id": 1234567890,
    "method": "WebKitBrowser.1.localstorageenabled",
    "params": false
}

Set Response

{
    "jsonrpc": "2.0",
    "id": 1234567890,
    "result": "null"
}

languages property

Provides access to the user preferred languages.

Value

Name Type Description
(property) array User preferred languages
(property)[#] string

Example

Get Request

{
    "jsonrpc": "2.0",
    "id": 1234567890,
    "method": "WebKitBrowser.1.languages"
}

Get Response

{
    "jsonrpc": "2.0",
    "id": 1234567890,
    "result": [
        "en-US"
    ]
}

Set Request

{
    "jsonrpc": "2.0",
    "id": 1234567890,
    "method": "WebKitBrowser.1.languages",
    "params": [
        "en-US"
    ]
}

Set Response

{
    "jsonrpc": "2.0",
    "id": 1234567890,
    "result": "null"
}

headers property

Provides access to the headers to send on all requests that the browser makes.

Value

Name Type Description
(property) array Headers to send on all requests that the browser makes
(property)[#] object
(property)[#]?.name string (optional) Header name
(property)[#]?.value string (optional) Header value

Example

Get Request

{
    "jsonrpc": "2.0",
    "id": 1234567890,
    "method": "WebKitBrowser.1.headers"
}

Get Response

{
    "jsonrpc": "2.0",
    "id": 1234567890,
    "result": [
        {
            "name": "X-Forwarded-For",
            "value": "::1"
        }
    ]
}

Set Request

{
    "jsonrpc": "2.0",
    "id": 1234567890,
    "method": "WebKitBrowser.1.headers",
    "params": [
        {
            "name": "X-Forwarded-For",
            "value": "::1"
        }
    ]
}

Set Response

{
    "jsonrpc": "2.0",
    "id": 1234567890,
    "result": "null"
}

url property

Provides access to the URL loaded in the browser.

Also see: urlchange

Value

Name Type Description
(property) string URL loaded in the browser

Errors

Code Message Description
15 ERROR_INCORRECT_URL Incorrect URL given

Example

Get Request

{
    "jsonrpc": "2.0",
    "id": 1234567890,
    "method": "WebKitBrowser.1.url"
}

Get Response

{
    "jsonrpc": "2.0",
    "id": 1234567890,
    "result": "https://www.google.com"
}

Set Request

{
    "jsonrpc": "2.0",
    "id": 1234567890,
    "method": "WebKitBrowser.1.url",
    "params": "https://www.google.com"
}

Set Response

{
    "jsonrpc": "2.0",
    "id": 1234567890,
    "result": "null"
}

visibility property

Provides access to the current browser visibility.

Also see: visibilitychange

Value

Name Type Description
(property) string Current browser visibility (must be one of the following: visible, hidden)

Example

Get Request

{
    "jsonrpc": "2.0",
    "id": 1234567890,
    "method": "WebKitBrowser.1.visibility"
}

Get Response

{
    "jsonrpc": "2.0",
    "id": 1234567890,
    "result": "visible"
}

Set Request

{
    "jsonrpc": "2.0",
    "id": 1234567890,
    "method": "WebKitBrowser.1.visibility",
    "params": "visible"
}

Set Response

{
    "jsonrpc": "2.0",
    "id": 1234567890,
    "result": "null"
}

fps property

Provides access to the current number of frames per second the browser is rendering.

This property is read-only.

Value

Name Type Description
(property) number Current number of frames per second the browser is rendering

Example

Get Request

{
    "jsonrpc": "2.0",
    "id": 1234567890,
    "method": "WebKitBrowser.1.fps"
}

Get Response

{
    "jsonrpc": "2.0",
    "id": 1234567890,
    "result": 30
}

state property

Provides access to the running state of the service.

Also see: statechange

Value

Name Type Description
(property) string Running state of the service (must be one of the following: resumed, suspended)

Example

Get Request

{
    "jsonrpc": "2.0",
    "id": 1234567890,
    "method": "WebKitBrowser.1.state"
}

Get Response

{
    "jsonrpc": "2.0",
    "id": 1234567890,
    "result": "resumed"
}

Set Request

{
    "jsonrpc": "2.0",
    "id": 1234567890,
    "method": "WebKitBrowser.1.state",
    "params": "resumed"
}

Set Response

{
    "jsonrpc": "2.0",
    "id": 1234567890,
    "result": "null"
}

Notifications

Notifications are autonomous events, triggered by the internals of the implementation, and broadcasted via JSON-RPC to all registered observers.Refer to [Thunder] for information on how to register for a notification.

The following events are provided by the WebKitBrowser plugin:

WebKitBrowser interface events:

Event Description
loadfinished Initial HTML document has been completely loaded and parsed
loadfailed Browser failed to load page
bridgequery A Base64 encoded JSON message from legacy $badger bridge

Browser interface events:

Event Description
urlchange Signals a URL change in the browser
visibilitychange Signals a visibility change of the browser
pageclosure Notifies that the web page requests to close its window

StateControl interface events:

Event Description
statechange Signals a state change of the service

loadfinished event

Initial HTML document has been completely loaded and parsed.

Parameters

Name Type Description
params object
params.url string The URL that has been loaded
params.httpstatus integer The response code of main resource request

Example

{
    "jsonrpc": "2.0",
    "method": "client.events.1.loadfinished",
    "params": {
        "url": "https://example.com",
        "httpstatus": 200
    }
}

loadfailed event

Browser failed to load page.

Parameters

Name Type Description
params object
params.url string The URL that browser failed to load

Example

{
    "jsonrpc": "2.0",
    "method": "client.events.1.loadfailed",
    "params": {
        "url": "https://example.com"
    }
}

bridgequery event

A Base64 encoded JSON message from legacy $badger bridge.

Parameters

Name Type Description
params string

Example

{
    "jsonrpc": "2.0",
    "method": "client.events.1.bridgequery",
    "params": ""
}

urlchange event

Signals a URL change in the browser.

Parameters

Name Type Description
params object
params.url string The URL that has been loaded or requested
params.loaded boolean Determines if the URL has just been loaded (true) or if URL change has been requested (false)

Example

{
    "jsonrpc": "2.0",
    "method": "client.events.1.urlchange",
    "params": {
        "url": "https://www.google.com",
        "loaded": false
    }
}

visibilitychange event

Signals a visibility change of the browser.

Parameters

Name Type Description
params object
params.hidden boolean Determines if the browser has been hidden (true) or made visible (false)

Example

{
    "jsonrpc": "2.0",
    "method": "client.events.1.visibilitychange",
    "params": {
        "hidden": false
    }
}

pageclosure event

Notifies that the web page requests to close its window.

Parameters

This event carries no parameters.

Example

{
    "jsonrpc": "2.0",
    "method": "client.events.1.pageclosure"
}

statechange event

Signals a state change of the service.

Parameters

Name Type Description
params object
params.suspended boolean Determines if the service has entered suspended state (true) or resumed state (false)

Example

{
    "jsonrpc": "2.0",
    "method": "client.events.1.statechange",
    "params": {
        "suspended": false
    }
}