Wren

Module frames

Nested browsing contexts for JavaScript (src/page/frames.odin, frames_scripts.odin, frames_access.odin; native/js/odin/frames.odin). A window of another document is named by its navigable's id: each document runs in its own engine instance, so another window is a WindowProxy of the calling realm. Across origins it reaches what HTML lets a cross-origin window reach (postMessage, location as a setter, closed, frames, length, top, parent, opener, window, self, close, focus, blur). The windows a script opens (window.open, links to _blank) are top-level navigables of the same kind (src/page/auxiliary.odin). Between documents of one origin, nodes are reached directly: every node handle names its document (base.pool_insert_tagged), the browser routes the call to it and checks the origin on each call.

Exposed to: Window. Source: api/frames.widl.

Odin: import "wren:frames".

Functions

Frame_self

u64 Frame_self()

The navigable of the calling document.

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

Frame_ofElement

u64 Frame_ofElement(u64 element)

The navigable of a frame element (<iframe>, <frame>) of the calling document; 0 when it has none (not connected, frames off).

Host: Frame_ofElement :: proc(c: ^Call, element: u64) -> u64

Frame_parent

u64 Frame_parent(u64 navigable)

The parent navigable; 0 for a top-level one, or one that is gone.

Host: Frame_parent :: proc(c: ^Call, navigable: u64) -> u64

Frame_top

u64 Frame_top(u64 navigable)

The top-level navigable of its tab; 0 when it is gone.

Host: Frame_top :: proc(c: ^Call, navigable: u64) -> u64

Frame_length

u32 Frame_length(u64 navigable)

How many child navigables its document has (window.length).

Host: Frame_length :: proc(c: ^Call, navigable: u64) -> u32

Frame_child

u64 Frame_child(u64 navigable, u32 index)

Its document's index-th child navigable in tree order of their containers (window[index]); 0 when none.

Host: Frame_child :: proc(c: ^Call, navigable: u64, index: u32) -> u64

Frame_named

u64 Frame_named(u64 navigable, string name)

Its document's child navigable named name (window[name], reachable across origins); 0 when none.

Host: Frame_named :: proc(c: ^Call, navigable: u64, name: string) -> u64

Frame_childNames

string Frame_childNames(u64 navigable)

The names of its document's child navigables, NUL separated (the WindowProxy's own property names).

Host: Frame_childNames :: proc(c: ^Call, navigable: u64) -> string

Frame_closed

bool Frame_closed(u64 navigable)

window.closed: the navigable is gone, or has no document.

Host: Frame_closed :: proc(c: ^Call, navigable: u64) -> bool

Frame_sameOrigin

bool Frame_sameOrigin(u64 navigable)

Whether its document is same origin with the calling one.

Host: Frame_sameOrigin :: proc(c: ^Call, navigable: u64) -> bool

Frame_documentOf

u64 Frame_documentOf(u64 navigable)

Its document's Document node, when the calling document may reach it (same origin); 0 otherwise. iframe.contentDocument, otherWindow.document.

Host: Frame_documentOf :: proc(c: ^Call, navigable: u64) -> u64

Frame_elementOf

u64 Frame_elementOf(u64 navigable)

The frame element holding this navigable's document, when the calling document may reach it; 0 otherwise (window.frameElement).

Host: Frame_elementOf :: proc(c: ^Call, navigable: u64) -> u64

Frame_ofDocument

u64 Frame_ofDocument(u64 node)

The navigable whose document holds node, a node the calling document may reach; 0 otherwise (document.defaultView of another document).

Host: Frame_ofDocument :: proc(c: ^Call, node: u64) -> u64

Frame_target

bool Frame_target(u64 node)

The next import of the calling realm that names no node acts on the document holding node (document.createTextNode of another document). False when that document cannot be reached (gone, another origin).

Host: Frame_target :: proc(c: ^Call, node: u64) -> bool

Frame_windowTarget

u64 Frame_windowTarget(u64 navigable)

The browser's object for the window of this navigable (a target for events), when the calling document may reach it; 0 otherwise.

Host: Frame_windowTarget :: proc(c: ^Call, navigable: u64) -> u64

Frame_realmSelf

u64 Frame_realmSelf()

The realm of the calling document (a number for Frame_bridge).

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

Frame_realmOf

u64 Frame_realmOf(u64 navigable)

The realm of the document this navigable shows, when the calling document may reach it; 0 otherwise.

Host: Frame_realmOf :: proc(c: ^Call, navigable: u64) -> u64

Frame_bridge

u32 Frame_bridge(u64 realm, bytes request)

A request of the value bridge (native/js/odin/frames_bridge.odin) to another realm: the size of its reply, read with Frame_bridgeReply; 0 when that realm is gone or may not be reached.

Host: Frame_bridge :: proc(c: ^Call, realm: u64, request: []u8) -> u32

Frame_bridgeReply

bytes Frame_bridgeReply()

The reply of the last Frame_bridge.

Host: Frame_bridgeReply :: proc(c: ^Call) -> []u8

Frame_adoptNode

bytes Frame_adoptNode(u64 node, u64 into) raises

Moves node, of another document, to the document holding into (DOM "adopt"), as lone nodes: the handles of the nodes moved, each old one (u64) followed by its new one (the first pair is node's). Security when one of the two cannot be reached.

Raises: returns an Error (see web).

Host: Frame_adoptNode :: proc(c: ^Call, node: u64, into: u64) -> ([]u8, Api_Error)

Frame_postMessage

void Frame_postMessage(u64 navigable, bytes data, usvstring target_origin) raises

otherWindow.postMessage(message, targetOrigin): data is the message's structured serialization (runtime/clone.c); target_origin is "*", "/" or a URL. The message is delivered from a task of the target's, if its document's origin then matches. Syntax for an invalid target origin, Data_Clone for a message over frames.max_message_bytes.

Raises: returns an Error (see web).

Host: Frame_postMessage :: proc(c: ^Call, navigable: u64, data: []u8, target_origin: string) -> Api_Error

Frame_navigate

void Frame_navigate(u64 navigable, usvstring url, bool replace) raises

otherWindow.location = url, location.href = url, location.replace(url): Security when the calling document may not navigate it (HTML "allowed to navigate", the sandbox; the console says why), Syntax for an invalid URL.

Raises: returns an Error (see web).

Host: Frame_navigate :: proc(c: ^Call, navigable: u64, url: string, replace: bool) -> Api_Error

Frame_open

u64 Frame_open(usvstring url, string target, string features) raises

window.open(url, target, features): _self, _parent, _top, or the name of a frame or of a window of the calling document's browsing context group is navigated and its navigable returned; _blank or a name nothing has opens a new window (when the embedder can: src/page/auxiliary.odin) whose opener is the calling document, and gives its navigable. 0 when nothing was opened, and under the features noopener / noreferrer. Syntax for an invalid URL.

Raises: returns an Error (see web).

Host: Frame_open :: proc(c: ^Call, url: string, target: string, features: string) -> (u64, Api_Error)

Frame_opener

u64 Frame_opener(u64 navigable)

window.opener: the navigable whose document opened this top-level one; 0 for a frame, a window opened with noopener, one whose opener relationship ended (Cross-Origin-Opener-Policy, opener = null), or once the opener is gone.

Host: Frame_opener :: proc(c: ^Call, navigable: u64) -> u64

Frame_close

void Frame_close(u64 navigable)

window.close(): a window a script opened is closed (closed is true at once; its embedder closes it in a task). Any other window stays open (the console says why).

Host: Frame_close :: proc(c: ^Call, navigable: u64)

Frame_disown

void Frame_disown()

window.opener = null: the calling document's window has no opener any more.

Host: Frame_disown :: proc(c: ^Call)

Frame_postMessagePorts

void Frame_postMessagePorts(u64 navigable, bytes data, usvstring target_origin, u64[] ports) raises

otherWindow.postMessage(message, targetOrigin, [ports]): the same, with the MessagePorts of the transfer list shipped as port ends (Port_ship / Port_entangle): the receiver's MessageEvent.ports are bound to them.

Raises: returns an Error (see web).

Host: Frame_postMessagePorts :: proc(c: ^Call, navigable: u64, data: []u8, target_origin: string, ports: []u64) -> Api_Error

Window_get_name

string Window_get_name()

window.name: its navigable's name.

Host: Window_get_name :: proc(c: ^Call) -> string

Window_set_name

void Window_set_name(string value)

window.name = value

Host: Window_set_name :: proc(c: ^Call, value: string)

Edit this page on GitHub