Wren a web browser where WebAssembly runs everything, JavaScript included

Module navigator

What the web APIs of JavaScript need beyond the modules Wasm pages use (native/js/runtime/web*.c): the browser's identity for navigator, beacons, the screen, media queries scripts evaluate (matchMedia), and FormData file entries.

Exposed to: Window, Worker. Source: api/js_web.widl.

Odin: import "wren:navigator".

Types

enum NavigatorField : i32

A string member of Navigator.

membervalue
User_Agent0navigator.userAgent: the User-Agent header the browser sends (network.user_agent).
App_Version1navigator.appVersion: the user agent without its leading "Mozilla/".
Platform2navigator.platform ("Win32").
Vendor3navigator.vendor.
Languages4navigator.languages, comma separated, from the Accept-Language preference (network.accept_language), without quality values.
Do_Not_Track5navigator.doNotTrack: "1", or "" for null (privacy.do_not_track).

Functions

string Navigator_get(NavigatorField field)

A string member of Navigator.

Odin: navigator.get.

Host: Navigator_get :: proc(c: ^Call, field: Api_NavigatorField) -> string

i32 Navigator_hardwareConcurrency()

navigator.hardwareConcurrency: the logical processors the page may use.

Odin: navigator.hardwareConcurrency.

Host: Navigator_hardwareConcurrency :: proc(c: ^Call) -> i32

bool Navigator_onLine()

navigator.onLine: whether the system has a network connection.

Odin: navigator.onLine.

Host: Navigator_onLine :: proc(c: ^Call) -> bool

i32 Navigator_maxTouchPoints()

navigator.maxTouchPoints: the touches the touch screen takes at once (0: none), as browser.touch.expose says.

Odin: navigator.maxTouchPoints.

Host: Navigator_maxTouchPoints :: proc(c: ^Call) -> i32

bool Navigator_cookieEnabled()

navigator.cookieEnabled: whether the document may use cookies.

Odin: navigator.cookieEnabled.

Host: Navigator_cookieEnabled :: proc(c: ^Call) -> bool

UserActivation_isActive

bool UserActivation_isActive()

navigator.userActivation.isActive: whether the document has transient activation now (a recent click or key press within the transient activation window, security.webauthn.user_activation_ms).

Host: UserActivation_isActive :: proc(c: ^Call) -> bool

UserActivation_hasBeenActive

bool UserActivation_hasBeenActive()

navigator.userActivation.hasBeenActive: whether the document has ever had an activation-triggering input (sticky: it does not expire).

Host: UserActivation_hasBeenActive :: proc(c: ^Call) -> bool

Beacon_send

bool Beacon_send(string url, optional bytes data, string content_type = "")

navigator.sendBeacon(url, data): a POST queued with the page's policy (CORS no-cors mode, credentials included), whose response nobody reads; it is not cancelled when the page closes. False when the beacon is refused (too large: navigator.beacon_max_bytes, or an invalid URL). content_type "" sends none.

Host: Beacon_send :: proc(c: ^Call, url: string, data: Maybe([]u8), content_type: string) -> bool

Clipboard_writeText

Promise Clipboard_writeText(string data)

navigator.clipboard.writeText(data): puts the text on the system clipboard. Fulfilled when it is there; rejected with NotAllowedError when the document is not focused and has no recent click or key press, when the clipboard cannot be had, or when writing is turned off (navigator.clipboard_write).

Host: Clipboard_writeText :: proc(c: ^Call, data: string) -> u64

Clipboard_readText

Promise<string> Clipboard_readText()

navigator.clipboard.readText(): the text on the system clipboard (an empty string when it holds none). Rejected with NotAllowedError unless the document is focused and has a recent click or key press (there is no permission prompt), or when reading is turned off (navigator.clipboard_read).

Host: Clipboard_readText :: proc(c: ^Call) -> u64

Edit this page on GitHub