src/domains/page

Search:
Group by:

This module provides a direct mapping of CDP events and commands for v1.3 (stable) of the Page Domain.

Actions and events related to the inspected page belong to the page domain.

Types

Page {.pure.} = enum
  domContentEventFired = "Page.domContentEventFired",
  fileChooserOpened = "Page.fileChooserOpened",
  frameAttached = "Page.frameAttached", frameDetached = "Page.frameDetached",
  frameNavigated = "Page.frameNavigated",
  interstitialHidden = "Page.interstitialHidden",
  interstitialShown = "Page.interstitialShown",
  javascriptDialogClosed = "Page.javascriptDialogClosed",
  javascriptDialogOpening = "Page.javascriptDialogOpening",
  lifecycleEvent = "Page.lifecycleEvent",
  loadEventFired = "Page.loadEventFired", windowOpen = "Page.windowOpen"
Page Domain events

Procs

proc addScriptToEvaluateOnLoad(tab: Tab; source: string): Future[JsonNode] {.
    ...stackTrace: false, raises: [Exception, ValueError],
    tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
proc addScriptToEvaluateOnLoad(tab: Tab; source: string; params: JsonNode): Future[
    JsonNode] {....stackTrace: false, raises: [Exception, ValueError],
                tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect],
                forbids: [].}

Page.addScriptToEvaluateOnLoad

Evaluates given script in every frame upon creation (before loading frame's scripts).

proc bringToFront(tab: Tab): owned(Future[void]) {....stackTrace: false,
    raises: [Exception],
    tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}

Page.bringToFront

Brings page to front (activates tab).

proc captureScreenshot(tab: Tab): Future[JsonNode] {....stackTrace: false,
    raises: [Exception, ValueError],
    tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
proc captureScreenshot(tab: Tab; params: JsonNode): Future[JsonNode] {.
    ...stackTrace: false, raises: [Exception, ValueError],
    tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}

Page.captureScreenshot

Capture page screenshot.

proc closePageDomain(tab: Tab): owned(Future[void]) {....stackTrace: false,
    raises: [Exception],
    tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}

Page.close

Tries to close page, running its beforeunload hooks, if any.

proc createIsolatedWorld(tab: Tab; frameId: string): Future[JsonNode] {.
    ...stackTrace: false, raises: [Exception, ValueError],
    tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
proc createIsolatedWorld(tab: Tab; frameId: string; params: JsonNode): Future[
    JsonNode] {....stackTrace: false, raises: [Exception, ValueError],
                tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect],
                forbids: [].}

Page.createIsolatedWorld

Creates an isolated world for the given frame.

proc disablePageDomain(tab: Tab): owned(Future[void]) {....stackTrace: false,
    raises: [Exception],
    tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}

Page.disable

Disables page domain notifications.

proc enablePageDomain(tab: Tab): owned(Future[void]) {....stackTrace: false,
    raises: [Exception],
    tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}

Page.enable

Enables page domain notifications.

proc getAppManifest(tab: Tab): Future[JsonNode] {....stackTrace: false,
    raises: [Exception, ValueError],
    tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
Page.getAppManifest
proc getFrameTree(tab: Tab): Future[JsonNode] {....stackTrace: false,
    raises: [Exception, ValueError],
    tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}

Page.getFrameTree

Returns present frame tree structure.

proc getLayoutMetrics(tab: Tab): Future[JsonNode] {....stackTrace: false,
    raises: [Exception, ValueError],
    tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}

Page.getLayoutMetrics

Returns metrics relating to the layouting of the page, such as viewport bounds/scale.

proc getNavigationHistory(tab: Tab): Future[JsonNode] {....stackTrace: false,
    raises: [Exception, ValueError],
    tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}

Page.getNavigationHistory

Returns navigation history for the current page.

proc handleJavaScriptDialog(tab: Tab; accept: bool): Future[JsonNode] {.
    ...stackTrace: false, raises: [Exception, ValueError],
    tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
proc handleJavaScriptDialog(tab: Tab; accept: bool; params: JsonNode): Future[
    JsonNode] {....stackTrace: false, raises: [Exception, ValueError],
                tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect],
                forbids: [].}

Page.handleJavaScriptDialog

Accepts or dismisses a JavaScript initiated dialog (alert, confirm, prompt, or onbeforeunload).

proc printToPDF(tab: Tab; params: JsonNode): Future[JsonNode] {.
    ...stackTrace: false, raises: [Exception, ValueError],
    tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}

Page.printToPDF

Print page as PDF.

proc reload(tab: Tab): owned(Future[void]) {....stackTrace: false,
    raises: [Exception],
    tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
proc reload(tab: Tab; params: JsonNode): owned(Future[void]) {.
    ...stackTrace: false, raises: [Exception],
    tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}

Page.reload

Reloads given page optionally ignoring the cache.

proc removeScriptToEvaluateOnNewDocument(tab: Tab; identifier: string): owned(
    Future[void]) {....stackTrace: false, raises: [Exception], tags: [RootEffect,
    WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}

Page.removeScriptToEvaluateOnNewDocument

Removes given script from the list.

proc resetNavigationHistory(tab: Tab): owned(Future[void]) {....stackTrace: false,
    raises: [Exception],
    tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}

Page.resetNavigationHistory

Resets navigation history for the current page.

proc setBypassCSP(tab: Tab; enabled: bool): owned(Future[void]) {.
    ...stackTrace: false, raises: [Exception],
    tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}

Page.setBypassCSP

Enable page Content Security Policy by-passing.

proc setDocumentContent(tab: Tab; frameId, html: string): owned(Future[void]) {.
    ...stackTrace: false, raises: [Exception],
    tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}

Page.setDocumentContent

Sets given markup as the document's HTML.

proc setInterceptFileChooserDialog(tab: Tab; enabled: bool): owned(
    Future[void]) {....stackTrace: false, raises: [Exception], tags: [RootEffect,
    WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}

Page.setInterceptFileChooserDialog

Intercept file chooser requests and transfer control to protocol clients. When file chooser interception is enabled, native file chooser dialog is not shown. Instead, a protocol event Page.fileChooserOpened is emitted.

proc setLifecycleEventsEnabled(tab: Tab; enabled: bool): owned(Future[void]) {.
    ...stackTrace: false, raises: [Exception],
    tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}

Page.setLifecycleEventsEnabled

Controls whether page will emit lifecycle events.

proc stopLoading(tab: Tab): owned(Future[void]) {....stackTrace: false,
    raises: [Exception],
    tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}

Page.stopLoading

Force the page stop all navigations and pending resource fetches.