AI Newsletter Digest improvements: fixed QP soft line break decoding, URL extraction, and content cleaning
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
|
||||
|
||||
# Copyright 2024 by UltrafunkAmsterdam (https://github.com/UltrafunkAmsterdam)
|
||||
# All rights reserved.
|
||||
# This file is part of the nodriver package.
|
||||
# and is released under the "GNU AFFERO GENERAL PUBLIC LICENSE".
|
||||
# Please see the LICENSE.txt file that should have been included as part of this package.
|
||||
|
||||
from nodriver import cdp
|
||||
from nodriver.core import util
|
||||
from nodriver.core._contradict import ContraDict # noqa
|
||||
from nodriver.core._contradict import cdict
|
||||
from nodriver.core.browser import Browser, BrowserContext
|
||||
from nodriver.core.config import Config
|
||||
from nodriver.core.connection import Connection
|
||||
from nodriver.core.connection import ProtocolException
|
||||
from nodriver.core.element import Element
|
||||
from nodriver.core.tab import Tab
|
||||
from nodriver.core.util import loop, start
|
||||
|
||||
__all__ = [
|
||||
"loop",
|
||||
"Browser",
|
||||
"Tab",
|
||||
"cdp",
|
||||
"Config",
|
||||
"start",
|
||||
"util",
|
||||
"Element",
|
||||
"ContraDict",
|
||||
"ProtocolException"
|
||||
]
|
||||
Binary file not shown.
@@ -0,0 +1,4 @@
|
||||
|
||||
## Generated by PyCDP
|
||||
The modules of this package were generated by [pycdp], do not modify their contents because the
|
||||
changes will be overwritten in next generations.
|
||||
@@ -0,0 +1,6 @@
|
||||
# DO NOT EDIT THIS FILE!
|
||||
#
|
||||
# This file is generated from the CDP specification. If you need to make
|
||||
# changes, edit the generator and regenerate all of the modules.
|
||||
|
||||
from . import (accessibility, animation, audits, autofill, background_service, bluetooth_emulation, browser, css, cache_storage, cast, console, dom, dom_debugger, dom_snapshot, dom_storage, debugger, device_access, device_orientation, emulation, event_breakpoints, extensions, fed_cm, fetch, file_system, headless_experimental, heap_profiler, io, indexed_db, input_, inspector, layer_tree, log, media, memory, network, overlay, pwa, page, performance, performance_timeline, preload, profiler, runtime, schema, security, service_worker, storage, system_info, target, tethering, tracing, web_audio, web_authn)
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,668 @@
|
||||
# DO NOT EDIT THIS FILE!
|
||||
#
|
||||
# This file is generated from the CDP specification. If you need to make
|
||||
# changes, edit the generator and regenerate all of the modules.
|
||||
#
|
||||
# CDP domain: Accessibility (experimental)
|
||||
|
||||
from __future__ import annotations
|
||||
import enum
|
||||
import typing
|
||||
from dataclasses import dataclass
|
||||
from .util import event_class, T_JSON_DICT
|
||||
|
||||
from . import dom
|
||||
from . import page
|
||||
from . import runtime
|
||||
|
||||
|
||||
class AXNodeId(str):
|
||||
'''
|
||||
Unique accessibility node identifier.
|
||||
'''
|
||||
def to_json(self) -> str:
|
||||
return self
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: str) -> AXNodeId:
|
||||
return cls(json)
|
||||
|
||||
def __repr__(self):
|
||||
return 'AXNodeId({})'.format(super().__repr__())
|
||||
|
||||
|
||||
class AXValueType(enum.Enum):
|
||||
'''
|
||||
Enum of possible property types.
|
||||
'''
|
||||
BOOLEAN = "boolean"
|
||||
TRISTATE = "tristate"
|
||||
BOOLEAN_OR_UNDEFINED = "booleanOrUndefined"
|
||||
IDREF = "idref"
|
||||
IDREF_LIST = "idrefList"
|
||||
INTEGER = "integer"
|
||||
NODE = "node"
|
||||
NODE_LIST = "nodeList"
|
||||
NUMBER = "number"
|
||||
STRING = "string"
|
||||
COMPUTED_STRING = "computedString"
|
||||
TOKEN = "token"
|
||||
TOKEN_LIST = "tokenList"
|
||||
DOM_RELATION = "domRelation"
|
||||
ROLE = "role"
|
||||
INTERNAL_ROLE = "internalRole"
|
||||
VALUE_UNDEFINED = "valueUndefined"
|
||||
|
||||
def to_json(self) -> str:
|
||||
return self.value
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: str) -> AXValueType:
|
||||
return cls(json)
|
||||
|
||||
|
||||
class AXValueSourceType(enum.Enum):
|
||||
'''
|
||||
Enum of possible property sources.
|
||||
'''
|
||||
ATTRIBUTE = "attribute"
|
||||
IMPLICIT = "implicit"
|
||||
STYLE = "style"
|
||||
CONTENTS = "contents"
|
||||
PLACEHOLDER = "placeholder"
|
||||
RELATED_ELEMENT = "relatedElement"
|
||||
|
||||
def to_json(self) -> str:
|
||||
return self.value
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: str) -> AXValueSourceType:
|
||||
return cls(json)
|
||||
|
||||
|
||||
class AXValueNativeSourceType(enum.Enum):
|
||||
'''
|
||||
Enum of possible native property sources (as a subtype of a particular AXValueSourceType).
|
||||
'''
|
||||
DESCRIPTION = "description"
|
||||
FIGCAPTION = "figcaption"
|
||||
LABEL = "label"
|
||||
LABELFOR = "labelfor"
|
||||
LABELWRAPPED = "labelwrapped"
|
||||
LEGEND = "legend"
|
||||
RUBYANNOTATION = "rubyannotation"
|
||||
TABLECAPTION = "tablecaption"
|
||||
TITLE = "title"
|
||||
OTHER = "other"
|
||||
|
||||
def to_json(self) -> str:
|
||||
return self.value
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: str) -> AXValueNativeSourceType:
|
||||
return cls(json)
|
||||
|
||||
|
||||
@dataclass
|
||||
class AXValueSource:
|
||||
'''
|
||||
A single source for a computed AX property.
|
||||
'''
|
||||
#: What type of source this is.
|
||||
type_: AXValueSourceType
|
||||
|
||||
#: The value of this property source.
|
||||
value: typing.Optional[AXValue] = None
|
||||
|
||||
#: The name of the relevant attribute, if any.
|
||||
attribute: typing.Optional[str] = None
|
||||
|
||||
#: The value of the relevant attribute, if any.
|
||||
attribute_value: typing.Optional[AXValue] = None
|
||||
|
||||
#: Whether this source is superseded by a higher priority source.
|
||||
superseded: typing.Optional[bool] = None
|
||||
|
||||
#: The native markup source for this value, e.g. a ``<label>`` element.
|
||||
native_source: typing.Optional[AXValueNativeSourceType] = None
|
||||
|
||||
#: The value, such as a node or node list, of the native source.
|
||||
native_source_value: typing.Optional[AXValue] = None
|
||||
|
||||
#: Whether the value for this property is invalid.
|
||||
invalid: typing.Optional[bool] = None
|
||||
|
||||
#: Reason for the value being invalid, if it is.
|
||||
invalid_reason: typing.Optional[str] = None
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['type'] = self.type_.to_json()
|
||||
if self.value is not None:
|
||||
json['value'] = self.value.to_json()
|
||||
if self.attribute is not None:
|
||||
json['attribute'] = self.attribute
|
||||
if self.attribute_value is not None:
|
||||
json['attributeValue'] = self.attribute_value.to_json()
|
||||
if self.superseded is not None:
|
||||
json['superseded'] = self.superseded
|
||||
if self.native_source is not None:
|
||||
json['nativeSource'] = self.native_source.to_json()
|
||||
if self.native_source_value is not None:
|
||||
json['nativeSourceValue'] = self.native_source_value.to_json()
|
||||
if self.invalid is not None:
|
||||
json['invalid'] = self.invalid
|
||||
if self.invalid_reason is not None:
|
||||
json['invalidReason'] = self.invalid_reason
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> AXValueSource:
|
||||
return cls(
|
||||
type_=AXValueSourceType.from_json(json['type']),
|
||||
value=AXValue.from_json(json['value']) if json.get('value', None) is not None else None,
|
||||
attribute=str(json['attribute']) if json.get('attribute', None) is not None else None,
|
||||
attribute_value=AXValue.from_json(json['attributeValue']) if json.get('attributeValue', None) is not None else None,
|
||||
superseded=bool(json['superseded']) if json.get('superseded', None) is not None else None,
|
||||
native_source=AXValueNativeSourceType.from_json(json['nativeSource']) if json.get('nativeSource', None) is not None else None,
|
||||
native_source_value=AXValue.from_json(json['nativeSourceValue']) if json.get('nativeSourceValue', None) is not None else None,
|
||||
invalid=bool(json['invalid']) if json.get('invalid', None) is not None else None,
|
||||
invalid_reason=str(json['invalidReason']) if json.get('invalidReason', None) is not None else None,
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class AXRelatedNode:
|
||||
#: The BackendNodeId of the related DOM node.
|
||||
backend_dom_node_id: dom.BackendNodeId
|
||||
|
||||
#: The IDRef value provided, if any.
|
||||
idref: typing.Optional[str] = None
|
||||
|
||||
#: The text alternative of this node in the current context.
|
||||
text: typing.Optional[str] = None
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['backendDOMNodeId'] = self.backend_dom_node_id.to_json()
|
||||
if self.idref is not None:
|
||||
json['idref'] = self.idref
|
||||
if self.text is not None:
|
||||
json['text'] = self.text
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> AXRelatedNode:
|
||||
return cls(
|
||||
backend_dom_node_id=dom.BackendNodeId.from_json(json['backendDOMNodeId']),
|
||||
idref=str(json['idref']) if json.get('idref', None) is not None else None,
|
||||
text=str(json['text']) if json.get('text', None) is not None else None,
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class AXProperty:
|
||||
#: The name of this property.
|
||||
name: AXPropertyName
|
||||
|
||||
#: The value of this property.
|
||||
value: AXValue
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['name'] = self.name.to_json()
|
||||
json['value'] = self.value.to_json()
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> AXProperty:
|
||||
return cls(
|
||||
name=AXPropertyName.from_json(json['name']),
|
||||
value=AXValue.from_json(json['value']),
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class AXValue:
|
||||
'''
|
||||
A single computed AX property.
|
||||
'''
|
||||
#: The type of this value.
|
||||
type_: AXValueType
|
||||
|
||||
#: The computed value of this property.
|
||||
value: typing.Optional[typing.Any] = None
|
||||
|
||||
#: One or more related nodes, if applicable.
|
||||
related_nodes: typing.Optional[typing.List[AXRelatedNode]] = None
|
||||
|
||||
#: The sources which contributed to the computation of this property.
|
||||
sources: typing.Optional[typing.List[AXValueSource]] = None
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['type'] = self.type_.to_json()
|
||||
if self.value is not None:
|
||||
json['value'] = self.value
|
||||
if self.related_nodes is not None:
|
||||
json['relatedNodes'] = [i.to_json() for i in self.related_nodes]
|
||||
if self.sources is not None:
|
||||
json['sources'] = [i.to_json() for i in self.sources]
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> AXValue:
|
||||
return cls(
|
||||
type_=AXValueType.from_json(json['type']),
|
||||
value=json['value'] if json.get('value', None) is not None else None,
|
||||
related_nodes=[AXRelatedNode.from_json(i) for i in json['relatedNodes']] if json.get('relatedNodes', None) is not None else None,
|
||||
sources=[AXValueSource.from_json(i) for i in json['sources']] if json.get('sources', None) is not None else None,
|
||||
)
|
||||
|
||||
|
||||
class AXPropertyName(enum.Enum):
|
||||
'''
|
||||
Values of AXProperty name:
|
||||
- from 'busy' to 'roledescription': states which apply to every AX node
|
||||
- from 'live' to 'root': attributes which apply to nodes in live regions
|
||||
- from 'autocomplete' to 'valuetext': attributes which apply to widgets
|
||||
- from 'checked' to 'selected': states which apply to widgets
|
||||
- from 'activedescendant' to 'owns': relationships between elements other than parent/child/sibling
|
||||
- from 'activeFullscreenElement' to 'uninteresting': reasons why this noode is hidden
|
||||
'''
|
||||
ACTIONS = "actions"
|
||||
BUSY = "busy"
|
||||
DISABLED = "disabled"
|
||||
EDITABLE = "editable"
|
||||
FOCUSABLE = "focusable"
|
||||
FOCUSED = "focused"
|
||||
HIDDEN = "hidden"
|
||||
HIDDEN_ROOT = "hiddenRoot"
|
||||
INVALID = "invalid"
|
||||
KEYSHORTCUTS = "keyshortcuts"
|
||||
SETTABLE = "settable"
|
||||
ROLEDESCRIPTION = "roledescription"
|
||||
LIVE = "live"
|
||||
ATOMIC = "atomic"
|
||||
RELEVANT = "relevant"
|
||||
ROOT = "root"
|
||||
AUTOCOMPLETE = "autocomplete"
|
||||
HAS_POPUP = "hasPopup"
|
||||
LEVEL = "level"
|
||||
MULTISELECTABLE = "multiselectable"
|
||||
ORIENTATION = "orientation"
|
||||
MULTILINE = "multiline"
|
||||
READONLY = "readonly"
|
||||
REQUIRED = "required"
|
||||
VALUEMIN = "valuemin"
|
||||
VALUEMAX = "valuemax"
|
||||
VALUETEXT = "valuetext"
|
||||
CHECKED = "checked"
|
||||
EXPANDED = "expanded"
|
||||
MODAL = "modal"
|
||||
PRESSED = "pressed"
|
||||
SELECTED = "selected"
|
||||
ACTIVEDESCENDANT = "activedescendant"
|
||||
CONTROLS = "controls"
|
||||
DESCRIBEDBY = "describedby"
|
||||
DETAILS = "details"
|
||||
ERRORMESSAGE = "errormessage"
|
||||
FLOWTO = "flowto"
|
||||
LABELLEDBY = "labelledby"
|
||||
OWNS = "owns"
|
||||
URL = "url"
|
||||
ACTIVE_FULLSCREEN_ELEMENT = "activeFullscreenElement"
|
||||
ACTIVE_MODAL_DIALOG = "activeModalDialog"
|
||||
ACTIVE_ARIA_MODAL_DIALOG = "activeAriaModalDialog"
|
||||
ARIA_HIDDEN_ELEMENT = "ariaHiddenElement"
|
||||
ARIA_HIDDEN_SUBTREE = "ariaHiddenSubtree"
|
||||
EMPTY_ALT = "emptyAlt"
|
||||
EMPTY_TEXT = "emptyText"
|
||||
INERT_ELEMENT = "inertElement"
|
||||
INERT_SUBTREE = "inertSubtree"
|
||||
LABEL_CONTAINER = "labelContainer"
|
||||
LABEL_FOR = "labelFor"
|
||||
NOT_RENDERED = "notRendered"
|
||||
NOT_VISIBLE = "notVisible"
|
||||
PRESENTATIONAL_ROLE = "presentationalRole"
|
||||
PROBABLY_PRESENTATIONAL = "probablyPresentational"
|
||||
INACTIVE_CAROUSEL_TAB_CONTENT = "inactiveCarouselTabContent"
|
||||
UNINTERESTING = "uninteresting"
|
||||
|
||||
def to_json(self) -> str:
|
||||
return self.value
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: str) -> AXPropertyName:
|
||||
return cls(json)
|
||||
|
||||
|
||||
@dataclass
|
||||
class AXNode:
|
||||
'''
|
||||
A node in the accessibility tree.
|
||||
'''
|
||||
#: Unique identifier for this node.
|
||||
node_id: AXNodeId
|
||||
|
||||
#: Whether this node is ignored for accessibility
|
||||
ignored: bool
|
||||
|
||||
#: Collection of reasons why this node is hidden.
|
||||
ignored_reasons: typing.Optional[typing.List[AXProperty]] = None
|
||||
|
||||
#: This ``Node``'s role, whether explicit or implicit.
|
||||
role: typing.Optional[AXValue] = None
|
||||
|
||||
#: This ``Node``'s Chrome raw role.
|
||||
chrome_role: typing.Optional[AXValue] = None
|
||||
|
||||
#: The accessible name for this ``Node``.
|
||||
name: typing.Optional[AXValue] = None
|
||||
|
||||
#: The accessible description for this ``Node``.
|
||||
description: typing.Optional[AXValue] = None
|
||||
|
||||
#: The value for this ``Node``.
|
||||
value: typing.Optional[AXValue] = None
|
||||
|
||||
#: All other properties
|
||||
properties: typing.Optional[typing.List[AXProperty]] = None
|
||||
|
||||
#: ID for this node's parent.
|
||||
parent_id: typing.Optional[AXNodeId] = None
|
||||
|
||||
#: IDs for each of this node's child nodes.
|
||||
child_ids: typing.Optional[typing.List[AXNodeId]] = None
|
||||
|
||||
#: The backend ID for the associated DOM node, if any.
|
||||
backend_dom_node_id: typing.Optional[dom.BackendNodeId] = None
|
||||
|
||||
#: The frame ID for the frame associated with this nodes document.
|
||||
frame_id: typing.Optional[page.FrameId] = None
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['nodeId'] = self.node_id.to_json()
|
||||
json['ignored'] = self.ignored
|
||||
if self.ignored_reasons is not None:
|
||||
json['ignoredReasons'] = [i.to_json() for i in self.ignored_reasons]
|
||||
if self.role is not None:
|
||||
json['role'] = self.role.to_json()
|
||||
if self.chrome_role is not None:
|
||||
json['chromeRole'] = self.chrome_role.to_json()
|
||||
if self.name is not None:
|
||||
json['name'] = self.name.to_json()
|
||||
if self.description is not None:
|
||||
json['description'] = self.description.to_json()
|
||||
if self.value is not None:
|
||||
json['value'] = self.value.to_json()
|
||||
if self.properties is not None:
|
||||
json['properties'] = [i.to_json() for i in self.properties]
|
||||
if self.parent_id is not None:
|
||||
json['parentId'] = self.parent_id.to_json()
|
||||
if self.child_ids is not None:
|
||||
json['childIds'] = [i.to_json() for i in self.child_ids]
|
||||
if self.backend_dom_node_id is not None:
|
||||
json['backendDOMNodeId'] = self.backend_dom_node_id.to_json()
|
||||
if self.frame_id is not None:
|
||||
json['frameId'] = self.frame_id.to_json()
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> AXNode:
|
||||
return cls(
|
||||
node_id=AXNodeId.from_json(json['nodeId']),
|
||||
ignored=bool(json['ignored']),
|
||||
ignored_reasons=[AXProperty.from_json(i) for i in json['ignoredReasons']] if json.get('ignoredReasons', None) is not None else None,
|
||||
role=AXValue.from_json(json['role']) if json.get('role', None) is not None else None,
|
||||
chrome_role=AXValue.from_json(json['chromeRole']) if json.get('chromeRole', None) is not None else None,
|
||||
name=AXValue.from_json(json['name']) if json.get('name', None) is not None else None,
|
||||
description=AXValue.from_json(json['description']) if json.get('description', None) is not None else None,
|
||||
value=AXValue.from_json(json['value']) if json.get('value', None) is not None else None,
|
||||
properties=[AXProperty.from_json(i) for i in json['properties']] if json.get('properties', None) is not None else None,
|
||||
parent_id=AXNodeId.from_json(json['parentId']) if json.get('parentId', None) is not None else None,
|
||||
child_ids=[AXNodeId.from_json(i) for i in json['childIds']] if json.get('childIds', None) is not None else None,
|
||||
backend_dom_node_id=dom.BackendNodeId.from_json(json['backendDOMNodeId']) if json.get('backendDOMNodeId', None) is not None else None,
|
||||
frame_id=page.FrameId.from_json(json['frameId']) if json.get('frameId', None) is not None else None,
|
||||
)
|
||||
|
||||
|
||||
def disable() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Disables the accessibility domain.
|
||||
'''
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Accessibility.disable',
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def enable() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Enables the accessibility domain which causes ``AXNodeId``'s to remain consistent between method calls.
|
||||
This turns on accessibility for the page, which can impact performance until accessibility is disabled.
|
||||
'''
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Accessibility.enable',
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def get_partial_ax_tree(
|
||||
node_id: typing.Optional[dom.NodeId] = None,
|
||||
backend_node_id: typing.Optional[dom.BackendNodeId] = None,
|
||||
object_id: typing.Optional[runtime.RemoteObjectId] = None,
|
||||
fetch_relatives: typing.Optional[bool] = None
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.List[AXNode]]:
|
||||
'''
|
||||
Fetches the accessibility node and partial accessibility tree for this DOM node, if it exists.
|
||||
|
||||
**EXPERIMENTAL**
|
||||
|
||||
:param node_id: *(Optional)* Identifier of the node to get the partial accessibility tree for.
|
||||
:param backend_node_id: *(Optional)* Identifier of the backend node to get the partial accessibility tree for.
|
||||
:param object_id: *(Optional)* JavaScript object id of the node wrapper to get the partial accessibility tree for.
|
||||
:param fetch_relatives: *(Optional)* Whether to fetch this node's ancestors, siblings and children. Defaults to true.
|
||||
:returns: The ``Accessibility.AXNode`` for this DOM node, if it exists, plus its ancestors, siblings and children, if requested.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
if node_id is not None:
|
||||
params['nodeId'] = node_id.to_json()
|
||||
if backend_node_id is not None:
|
||||
params['backendNodeId'] = backend_node_id.to_json()
|
||||
if object_id is not None:
|
||||
params['objectId'] = object_id.to_json()
|
||||
if fetch_relatives is not None:
|
||||
params['fetchRelatives'] = fetch_relatives
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Accessibility.getPartialAXTree',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
return [AXNode.from_json(i) for i in json['nodes']]
|
||||
|
||||
|
||||
def get_full_ax_tree(
|
||||
depth: typing.Optional[int] = None,
|
||||
frame_id: typing.Optional[page.FrameId] = None
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.List[AXNode]]:
|
||||
'''
|
||||
Fetches the entire accessibility tree for the root Document
|
||||
|
||||
**EXPERIMENTAL**
|
||||
|
||||
:param depth: *(Optional)* The maximum depth at which descendants of the root node should be retrieved. If omitted, the full tree is returned.
|
||||
:param frame_id: *(Optional)* The frame for whose document the AX tree should be retrieved. If omitted, the root frame is used.
|
||||
:returns:
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
if depth is not None:
|
||||
params['depth'] = depth
|
||||
if frame_id is not None:
|
||||
params['frameId'] = frame_id.to_json()
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Accessibility.getFullAXTree',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
return [AXNode.from_json(i) for i in json['nodes']]
|
||||
|
||||
|
||||
def get_root_ax_node(
|
||||
frame_id: typing.Optional[page.FrameId] = None
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,AXNode]:
|
||||
'''
|
||||
Fetches the root node.
|
||||
Requires ``enable()`` to have been called previously.
|
||||
|
||||
**EXPERIMENTAL**
|
||||
|
||||
:param frame_id: *(Optional)* The frame in whose document the node resides. If omitted, the root frame is used.
|
||||
:returns:
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
if frame_id is not None:
|
||||
params['frameId'] = frame_id.to_json()
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Accessibility.getRootAXNode',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
return AXNode.from_json(json['node'])
|
||||
|
||||
|
||||
def get_ax_node_and_ancestors(
|
||||
node_id: typing.Optional[dom.NodeId] = None,
|
||||
backend_node_id: typing.Optional[dom.BackendNodeId] = None,
|
||||
object_id: typing.Optional[runtime.RemoteObjectId] = None
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.List[AXNode]]:
|
||||
'''
|
||||
Fetches a node and all ancestors up to and including the root.
|
||||
Requires ``enable()`` to have been called previously.
|
||||
|
||||
**EXPERIMENTAL**
|
||||
|
||||
:param node_id: *(Optional)* Identifier of the node to get.
|
||||
:param backend_node_id: *(Optional)* Identifier of the backend node to get.
|
||||
:param object_id: *(Optional)* JavaScript object id of the node wrapper to get.
|
||||
:returns:
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
if node_id is not None:
|
||||
params['nodeId'] = node_id.to_json()
|
||||
if backend_node_id is not None:
|
||||
params['backendNodeId'] = backend_node_id.to_json()
|
||||
if object_id is not None:
|
||||
params['objectId'] = object_id.to_json()
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Accessibility.getAXNodeAndAncestors',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
return [AXNode.from_json(i) for i in json['nodes']]
|
||||
|
||||
|
||||
def get_child_ax_nodes(
|
||||
id_: AXNodeId,
|
||||
frame_id: typing.Optional[page.FrameId] = None
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.List[AXNode]]:
|
||||
'''
|
||||
Fetches a particular accessibility node by AXNodeId.
|
||||
Requires ``enable()`` to have been called previously.
|
||||
|
||||
**EXPERIMENTAL**
|
||||
|
||||
:param id_:
|
||||
:param frame_id: *(Optional)* The frame in whose document the node resides. If omitted, the root frame is used.
|
||||
:returns:
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['id'] = id_.to_json()
|
||||
if frame_id is not None:
|
||||
params['frameId'] = frame_id.to_json()
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Accessibility.getChildAXNodes',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
return [AXNode.from_json(i) for i in json['nodes']]
|
||||
|
||||
|
||||
def query_ax_tree(
|
||||
node_id: typing.Optional[dom.NodeId] = None,
|
||||
backend_node_id: typing.Optional[dom.BackendNodeId] = None,
|
||||
object_id: typing.Optional[runtime.RemoteObjectId] = None,
|
||||
accessible_name: typing.Optional[str] = None,
|
||||
role: typing.Optional[str] = None
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.List[AXNode]]:
|
||||
'''
|
||||
Query a DOM node's accessibility subtree for accessible name and role.
|
||||
This command computes the name and role for all nodes in the subtree, including those that are
|
||||
ignored for accessibility, and returns those that match the specified name and role. If no DOM
|
||||
node is specified, or the DOM node does not exist, the command returns an error. If neither
|
||||
``accessibleName`` or ``role`` is specified, it returns all the accessibility nodes in the subtree.
|
||||
|
||||
**EXPERIMENTAL**
|
||||
|
||||
:param node_id: *(Optional)* Identifier of the node for the root to query.
|
||||
:param backend_node_id: *(Optional)* Identifier of the backend node for the root to query.
|
||||
:param object_id: *(Optional)* JavaScript object id of the node wrapper for the root to query.
|
||||
:param accessible_name: *(Optional)* Find nodes with this computed name.
|
||||
:param role: *(Optional)* Find nodes with this computed role.
|
||||
:returns: A list of ``Accessibility.AXNode`` matching the specified attributes, including nodes that are ignored for accessibility.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
if node_id is not None:
|
||||
params['nodeId'] = node_id.to_json()
|
||||
if backend_node_id is not None:
|
||||
params['backendNodeId'] = backend_node_id.to_json()
|
||||
if object_id is not None:
|
||||
params['objectId'] = object_id.to_json()
|
||||
if accessible_name is not None:
|
||||
params['accessibleName'] = accessible_name
|
||||
if role is not None:
|
||||
params['role'] = role
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Accessibility.queryAXTree',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
return [AXNode.from_json(i) for i in json['nodes']]
|
||||
|
||||
|
||||
@event_class('Accessibility.loadComplete')
|
||||
@dataclass
|
||||
class LoadComplete:
|
||||
'''
|
||||
**EXPERIMENTAL**
|
||||
|
||||
The loadComplete event mirrors the load complete event sent by the browser to assistive
|
||||
technology when the web page has finished loading.
|
||||
'''
|
||||
#: New document root node.
|
||||
root: AXNode
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> LoadComplete:
|
||||
return cls(
|
||||
root=AXNode.from_json(json['root'])
|
||||
)
|
||||
|
||||
|
||||
@event_class('Accessibility.nodesUpdated')
|
||||
@dataclass
|
||||
class NodesUpdated:
|
||||
'''
|
||||
**EXPERIMENTAL**
|
||||
|
||||
The nodesUpdated event is sent every time a previously requested node has changed the in tree.
|
||||
'''
|
||||
#: Updated node data.
|
||||
nodes: typing.List[AXNode]
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> NodesUpdated:
|
||||
return cls(
|
||||
nodes=[AXNode.from_json(i) for i in json['nodes']]
|
||||
)
|
||||
@@ -0,0 +1,493 @@
|
||||
# DO NOT EDIT THIS FILE!
|
||||
#
|
||||
# This file is generated from the CDP specification. If you need to make
|
||||
# changes, edit the generator and regenerate all of the modules.
|
||||
#
|
||||
# CDP domain: Animation (experimental)
|
||||
|
||||
from __future__ import annotations
|
||||
import enum
|
||||
import typing
|
||||
from dataclasses import dataclass
|
||||
from .util import event_class, T_JSON_DICT
|
||||
|
||||
from . import dom
|
||||
from . import runtime
|
||||
|
||||
|
||||
@dataclass
|
||||
class Animation:
|
||||
'''
|
||||
Animation instance.
|
||||
'''
|
||||
#: ``Animation``'s id.
|
||||
id_: str
|
||||
|
||||
#: ``Animation``'s name.
|
||||
name: str
|
||||
|
||||
#: ``Animation``'s internal paused state.
|
||||
paused_state: bool
|
||||
|
||||
#: ``Animation``'s play state.
|
||||
play_state: str
|
||||
|
||||
#: ``Animation``'s playback rate.
|
||||
playback_rate: float
|
||||
|
||||
#: ``Animation``'s start time.
|
||||
#: Milliseconds for time based animations and
|
||||
#: percentage [0 - 100] for scroll driven animations
|
||||
#: (i.e. when viewOrScrollTimeline exists).
|
||||
start_time: float
|
||||
|
||||
#: ``Animation``'s current time.
|
||||
current_time: float
|
||||
|
||||
#: Animation type of ``Animation``.
|
||||
type_: str
|
||||
|
||||
#: ``Animation``'s source animation node.
|
||||
source: typing.Optional[AnimationEffect] = None
|
||||
|
||||
#: A unique ID for ``Animation`` representing the sources that triggered this CSS
|
||||
#: animation/transition.
|
||||
css_id: typing.Optional[str] = None
|
||||
|
||||
#: View or scroll timeline
|
||||
view_or_scroll_timeline: typing.Optional[ViewOrScrollTimeline] = None
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['id'] = self.id_
|
||||
json['name'] = self.name
|
||||
json['pausedState'] = self.paused_state
|
||||
json['playState'] = self.play_state
|
||||
json['playbackRate'] = self.playback_rate
|
||||
json['startTime'] = self.start_time
|
||||
json['currentTime'] = self.current_time
|
||||
json['type'] = self.type_
|
||||
if self.source is not None:
|
||||
json['source'] = self.source.to_json()
|
||||
if self.css_id is not None:
|
||||
json['cssId'] = self.css_id
|
||||
if self.view_or_scroll_timeline is not None:
|
||||
json['viewOrScrollTimeline'] = self.view_or_scroll_timeline.to_json()
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> Animation:
|
||||
return cls(
|
||||
id_=str(json['id']),
|
||||
name=str(json['name']),
|
||||
paused_state=bool(json['pausedState']),
|
||||
play_state=str(json['playState']),
|
||||
playback_rate=float(json['playbackRate']),
|
||||
start_time=float(json['startTime']),
|
||||
current_time=float(json['currentTime']),
|
||||
type_=str(json['type']),
|
||||
source=AnimationEffect.from_json(json['source']) if json.get('source', None) is not None else None,
|
||||
css_id=str(json['cssId']) if json.get('cssId', None) is not None else None,
|
||||
view_or_scroll_timeline=ViewOrScrollTimeline.from_json(json['viewOrScrollTimeline']) if json.get('viewOrScrollTimeline', None) is not None else None,
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class ViewOrScrollTimeline:
|
||||
'''
|
||||
Timeline instance
|
||||
'''
|
||||
#: Orientation of the scroll
|
||||
axis: dom.ScrollOrientation
|
||||
|
||||
#: Scroll container node
|
||||
source_node_id: typing.Optional[dom.BackendNodeId] = None
|
||||
|
||||
#: Represents the starting scroll position of the timeline
|
||||
#: as a length offset in pixels from scroll origin.
|
||||
start_offset: typing.Optional[float] = None
|
||||
|
||||
#: Represents the ending scroll position of the timeline
|
||||
#: as a length offset in pixels from scroll origin.
|
||||
end_offset: typing.Optional[float] = None
|
||||
|
||||
#: The element whose principal box's visibility in the
|
||||
#: scrollport defined the progress of the timeline.
|
||||
#: Does not exist for animations with ScrollTimeline
|
||||
subject_node_id: typing.Optional[dom.BackendNodeId] = None
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['axis'] = self.axis.to_json()
|
||||
if self.source_node_id is not None:
|
||||
json['sourceNodeId'] = self.source_node_id.to_json()
|
||||
if self.start_offset is not None:
|
||||
json['startOffset'] = self.start_offset
|
||||
if self.end_offset is not None:
|
||||
json['endOffset'] = self.end_offset
|
||||
if self.subject_node_id is not None:
|
||||
json['subjectNodeId'] = self.subject_node_id.to_json()
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> ViewOrScrollTimeline:
|
||||
return cls(
|
||||
axis=dom.ScrollOrientation.from_json(json['axis']),
|
||||
source_node_id=dom.BackendNodeId.from_json(json['sourceNodeId']) if json.get('sourceNodeId', None) is not None else None,
|
||||
start_offset=float(json['startOffset']) if json.get('startOffset', None) is not None else None,
|
||||
end_offset=float(json['endOffset']) if json.get('endOffset', None) is not None else None,
|
||||
subject_node_id=dom.BackendNodeId.from_json(json['subjectNodeId']) if json.get('subjectNodeId', None) is not None else None,
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class AnimationEffect:
|
||||
'''
|
||||
AnimationEffect instance
|
||||
'''
|
||||
#: ``AnimationEffect``'s delay.
|
||||
delay: float
|
||||
|
||||
#: ``AnimationEffect``'s end delay.
|
||||
end_delay: float
|
||||
|
||||
#: ``AnimationEffect``'s iteration start.
|
||||
iteration_start: float
|
||||
|
||||
#: ``AnimationEffect``'s iterations.
|
||||
iterations: float
|
||||
|
||||
#: ``AnimationEffect``'s iteration duration.
|
||||
#: Milliseconds for time based animations and
|
||||
#: percentage [0 - 100] for scroll driven animations
|
||||
#: (i.e. when viewOrScrollTimeline exists).
|
||||
duration: float
|
||||
|
||||
#: ``AnimationEffect``'s playback direction.
|
||||
direction: str
|
||||
|
||||
#: ``AnimationEffect``'s fill mode.
|
||||
fill: str
|
||||
|
||||
#: ``AnimationEffect``'s timing function.
|
||||
easing: str
|
||||
|
||||
#: ``AnimationEffect``'s target node.
|
||||
backend_node_id: typing.Optional[dom.BackendNodeId] = None
|
||||
|
||||
#: ``AnimationEffect``'s keyframes.
|
||||
keyframes_rule: typing.Optional[KeyframesRule] = None
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['delay'] = self.delay
|
||||
json['endDelay'] = self.end_delay
|
||||
json['iterationStart'] = self.iteration_start
|
||||
json['iterations'] = self.iterations
|
||||
json['duration'] = self.duration
|
||||
json['direction'] = self.direction
|
||||
json['fill'] = self.fill
|
||||
json['easing'] = self.easing
|
||||
if self.backend_node_id is not None:
|
||||
json['backendNodeId'] = self.backend_node_id.to_json()
|
||||
if self.keyframes_rule is not None:
|
||||
json['keyframesRule'] = self.keyframes_rule.to_json()
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> AnimationEffect:
|
||||
return cls(
|
||||
delay=float(json['delay']),
|
||||
end_delay=float(json['endDelay']),
|
||||
iteration_start=float(json['iterationStart']),
|
||||
iterations=float(json['iterations']),
|
||||
duration=float(json['duration']),
|
||||
direction=str(json['direction']),
|
||||
fill=str(json['fill']),
|
||||
easing=str(json['easing']),
|
||||
backend_node_id=dom.BackendNodeId.from_json(json['backendNodeId']) if json.get('backendNodeId', None) is not None else None,
|
||||
keyframes_rule=KeyframesRule.from_json(json['keyframesRule']) if json.get('keyframesRule', None) is not None else None,
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class KeyframesRule:
|
||||
'''
|
||||
Keyframes Rule
|
||||
'''
|
||||
#: List of animation keyframes.
|
||||
keyframes: typing.List[KeyframeStyle]
|
||||
|
||||
#: CSS keyframed animation's name.
|
||||
name: typing.Optional[str] = None
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['keyframes'] = [i.to_json() for i in self.keyframes]
|
||||
if self.name is not None:
|
||||
json['name'] = self.name
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> KeyframesRule:
|
||||
return cls(
|
||||
keyframes=[KeyframeStyle.from_json(i) for i in json['keyframes']],
|
||||
name=str(json['name']) if json.get('name', None) is not None else None,
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class KeyframeStyle:
|
||||
'''
|
||||
Keyframe Style
|
||||
'''
|
||||
#: Keyframe's time offset.
|
||||
offset: str
|
||||
|
||||
#: ``AnimationEffect``'s timing function.
|
||||
easing: str
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['offset'] = self.offset
|
||||
json['easing'] = self.easing
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> KeyframeStyle:
|
||||
return cls(
|
||||
offset=str(json['offset']),
|
||||
easing=str(json['easing']),
|
||||
)
|
||||
|
||||
|
||||
def disable() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Disables animation domain notifications.
|
||||
'''
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Animation.disable',
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def enable() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Enables animation domain notifications.
|
||||
'''
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Animation.enable',
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def get_current_time(
|
||||
id_: str
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,float]:
|
||||
'''
|
||||
Returns the current time of the an animation.
|
||||
|
||||
:param id_: Id of animation.
|
||||
:returns: Current time of the page.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['id'] = id_
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Animation.getCurrentTime',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
return float(json['currentTime'])
|
||||
|
||||
|
||||
def get_playback_rate() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,float]:
|
||||
'''
|
||||
Gets the playback rate of the document timeline.
|
||||
|
||||
:returns: Playback rate for animations on page.
|
||||
'''
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Animation.getPlaybackRate',
|
||||
}
|
||||
json = yield cmd_dict
|
||||
return float(json['playbackRate'])
|
||||
|
||||
|
||||
def release_animations(
|
||||
animations: typing.List[str]
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Releases a set of animations to no longer be manipulated.
|
||||
|
||||
:param animations: List of animation ids to seek.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['animations'] = [i for i in animations]
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Animation.releaseAnimations',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def resolve_animation(
|
||||
animation_id: str
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,runtime.RemoteObject]:
|
||||
'''
|
||||
Gets the remote object of the Animation.
|
||||
|
||||
:param animation_id: Animation id.
|
||||
:returns: Corresponding remote object.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['animationId'] = animation_id
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Animation.resolveAnimation',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
return runtime.RemoteObject.from_json(json['remoteObject'])
|
||||
|
||||
|
||||
def seek_animations(
|
||||
animations: typing.List[str],
|
||||
current_time: float
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Seek a set of animations to a particular time within each animation.
|
||||
|
||||
:param animations: List of animation ids to seek.
|
||||
:param current_time: Set the current time of each animation.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['animations'] = [i for i in animations]
|
||||
params['currentTime'] = current_time
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Animation.seekAnimations',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def set_paused(
|
||||
animations: typing.List[str],
|
||||
paused: bool
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Sets the paused state of a set of animations.
|
||||
|
||||
:param animations: Animations to set the pause state of.
|
||||
:param paused: Paused state to set to.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['animations'] = [i for i in animations]
|
||||
params['paused'] = paused
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Animation.setPaused',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def set_playback_rate(
|
||||
playback_rate: float
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Sets the playback rate of the document timeline.
|
||||
|
||||
:param playback_rate: Playback rate for animations on page
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['playbackRate'] = playback_rate
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Animation.setPlaybackRate',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def set_timing(
|
||||
animation_id: str,
|
||||
duration: float,
|
||||
delay: float
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Sets the timing of an animation node.
|
||||
|
||||
:param animation_id: Animation id.
|
||||
:param duration: Duration of the animation.
|
||||
:param delay: Delay of the animation.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['animationId'] = animation_id
|
||||
params['duration'] = duration
|
||||
params['delay'] = delay
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Animation.setTiming',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
@event_class('Animation.animationCanceled')
|
||||
@dataclass
|
||||
class AnimationCanceled:
|
||||
'''
|
||||
Event for when an animation has been cancelled.
|
||||
'''
|
||||
#: Id of the animation that was cancelled.
|
||||
id_: str
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> AnimationCanceled:
|
||||
return cls(
|
||||
id_=str(json['id'])
|
||||
)
|
||||
|
||||
|
||||
@event_class('Animation.animationCreated')
|
||||
@dataclass
|
||||
class AnimationCreated:
|
||||
'''
|
||||
Event for each animation that has been created.
|
||||
'''
|
||||
#: Id of the animation that was created.
|
||||
id_: str
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> AnimationCreated:
|
||||
return cls(
|
||||
id_=str(json['id'])
|
||||
)
|
||||
|
||||
|
||||
@event_class('Animation.animationStarted')
|
||||
@dataclass
|
||||
class AnimationStarted:
|
||||
'''
|
||||
Event for animation that has been started.
|
||||
'''
|
||||
#: Animation that was started.
|
||||
animation: Animation
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> AnimationStarted:
|
||||
return cls(
|
||||
animation=Animation.from_json(json['animation'])
|
||||
)
|
||||
|
||||
|
||||
@event_class('Animation.animationUpdated')
|
||||
@dataclass
|
||||
class AnimationUpdated:
|
||||
'''
|
||||
Event for animation that has been updated.
|
||||
'''
|
||||
#: Animation that was updated.
|
||||
animation: Animation
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> AnimationUpdated:
|
||||
return cls(
|
||||
animation=Animation.from_json(json['animation'])
|
||||
)
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,292 @@
|
||||
# DO NOT EDIT THIS FILE!
|
||||
#
|
||||
# This file is generated from the CDP specification. If you need to make
|
||||
# changes, edit the generator and regenerate all of the modules.
|
||||
#
|
||||
# CDP domain: Autofill (experimental)
|
||||
|
||||
from __future__ import annotations
|
||||
import enum
|
||||
import typing
|
||||
from dataclasses import dataclass
|
||||
from .util import event_class, T_JSON_DICT
|
||||
|
||||
from . import dom
|
||||
from . import page
|
||||
|
||||
|
||||
@dataclass
|
||||
class CreditCard:
|
||||
#: 16-digit credit card number.
|
||||
number: str
|
||||
|
||||
#: Name of the credit card owner.
|
||||
name: str
|
||||
|
||||
#: 2-digit expiry month.
|
||||
expiry_month: str
|
||||
|
||||
#: 4-digit expiry year.
|
||||
expiry_year: str
|
||||
|
||||
#: 3-digit card verification code.
|
||||
cvc: str
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['number'] = self.number
|
||||
json['name'] = self.name
|
||||
json['expiryMonth'] = self.expiry_month
|
||||
json['expiryYear'] = self.expiry_year
|
||||
json['cvc'] = self.cvc
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> CreditCard:
|
||||
return cls(
|
||||
number=str(json['number']),
|
||||
name=str(json['name']),
|
||||
expiry_month=str(json['expiryMonth']),
|
||||
expiry_year=str(json['expiryYear']),
|
||||
cvc=str(json['cvc']),
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class AddressField:
|
||||
#: address field name, for example GIVEN_NAME.
|
||||
#: The full list of supported field names:
|
||||
#: https://source.chromium.org/chromium/chromium/src/+/main:components/autofill/core/browser/field_types.cc;l=38
|
||||
name: str
|
||||
|
||||
#: address field value, for example Jon Doe.
|
||||
value: str
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['name'] = self.name
|
||||
json['value'] = self.value
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> AddressField:
|
||||
return cls(
|
||||
name=str(json['name']),
|
||||
value=str(json['value']),
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class AddressFields:
|
||||
'''
|
||||
A list of address fields.
|
||||
'''
|
||||
fields: typing.List[AddressField]
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['fields'] = [i.to_json() for i in self.fields]
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> AddressFields:
|
||||
return cls(
|
||||
fields=[AddressField.from_json(i) for i in json['fields']],
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class Address:
|
||||
#: fields and values defining an address.
|
||||
fields: typing.List[AddressField]
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['fields'] = [i.to_json() for i in self.fields]
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> Address:
|
||||
return cls(
|
||||
fields=[AddressField.from_json(i) for i in json['fields']],
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class AddressUI:
|
||||
'''
|
||||
Defines how an address can be displayed like in chrome://settings/addresses.
|
||||
Address UI is a two dimensional array, each inner array is an "address information line", and when rendered in a UI surface should be displayed as such.
|
||||
The following address UI for instance:
|
||||
[[{name: "GIVE_NAME", value: "Jon"}, {name: "FAMILY_NAME", value: "Doe"}], [{name: "CITY", value: "Munich"}, {name: "ZIP", value: "81456"}]]
|
||||
should allow the receiver to render:
|
||||
Jon Doe
|
||||
Munich 81456
|
||||
'''
|
||||
#: A two dimension array containing the representation of values from an address profile.
|
||||
address_fields: typing.List[AddressFields]
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['addressFields'] = [i.to_json() for i in self.address_fields]
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> AddressUI:
|
||||
return cls(
|
||||
address_fields=[AddressFields.from_json(i) for i in json['addressFields']],
|
||||
)
|
||||
|
||||
|
||||
class FillingStrategy(enum.Enum):
|
||||
'''
|
||||
Specified whether a filled field was done so by using the html autocomplete attribute or autofill heuristics.
|
||||
'''
|
||||
AUTOCOMPLETE_ATTRIBUTE = "autocompleteAttribute"
|
||||
AUTOFILL_INFERRED = "autofillInferred"
|
||||
|
||||
def to_json(self) -> str:
|
||||
return self.value
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: str) -> FillingStrategy:
|
||||
return cls(json)
|
||||
|
||||
|
||||
@dataclass
|
||||
class FilledField:
|
||||
#: The type of the field, e.g text, password etc.
|
||||
html_type: str
|
||||
|
||||
#: the html id
|
||||
id_: str
|
||||
|
||||
#: the html name
|
||||
name: str
|
||||
|
||||
#: the field value
|
||||
value: str
|
||||
|
||||
#: The actual field type, e.g FAMILY_NAME
|
||||
autofill_type: str
|
||||
|
||||
#: The filling strategy
|
||||
filling_strategy: FillingStrategy
|
||||
|
||||
#: The frame the field belongs to
|
||||
frame_id: page.FrameId
|
||||
|
||||
#: The form field's DOM node
|
||||
field_id: dom.BackendNodeId
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['htmlType'] = self.html_type
|
||||
json['id'] = self.id_
|
||||
json['name'] = self.name
|
||||
json['value'] = self.value
|
||||
json['autofillType'] = self.autofill_type
|
||||
json['fillingStrategy'] = self.filling_strategy.to_json()
|
||||
json['frameId'] = self.frame_id.to_json()
|
||||
json['fieldId'] = self.field_id.to_json()
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> FilledField:
|
||||
return cls(
|
||||
html_type=str(json['htmlType']),
|
||||
id_=str(json['id']),
|
||||
name=str(json['name']),
|
||||
value=str(json['value']),
|
||||
autofill_type=str(json['autofillType']),
|
||||
filling_strategy=FillingStrategy.from_json(json['fillingStrategy']),
|
||||
frame_id=page.FrameId.from_json(json['frameId']),
|
||||
field_id=dom.BackendNodeId.from_json(json['fieldId']),
|
||||
)
|
||||
|
||||
|
||||
def trigger(
|
||||
field_id: dom.BackendNodeId,
|
||||
frame_id: typing.Optional[page.FrameId] = None,
|
||||
card: typing.Optional[CreditCard] = None,
|
||||
address: typing.Optional[Address] = None
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Trigger autofill on a form identified by the fieldId.
|
||||
If the field and related form cannot be autofilled, returns an error.
|
||||
|
||||
:param field_id: Identifies a field that serves as an anchor for autofill.
|
||||
:param frame_id: *(Optional)* Identifies the frame that field belongs to.
|
||||
:param card: *(Optional)* Credit card information to fill out the form. Credit card data is not saved. Mutually exclusive with ```address````.
|
||||
:param address: *(Optional)* Address to fill out the form. Address data is not saved. Mutually exclusive with ````card```.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['fieldId'] = field_id.to_json()
|
||||
if frame_id is not None:
|
||||
params['frameId'] = frame_id.to_json()
|
||||
if card is not None:
|
||||
params['card'] = card.to_json()
|
||||
if address is not None:
|
||||
params['address'] = address.to_json()
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Autofill.trigger',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def set_addresses(
|
||||
addresses: typing.List[Address]
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Set addresses so that developers can verify their forms implementation.
|
||||
|
||||
:param addresses:
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['addresses'] = [i.to_json() for i in addresses]
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Autofill.setAddresses',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def disable() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Disables autofill domain notifications.
|
||||
'''
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Autofill.disable',
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def enable() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Enables autofill domain notifications.
|
||||
'''
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Autofill.enable',
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
@event_class('Autofill.addressFormFilled')
|
||||
@dataclass
|
||||
class AddressFormFilled:
|
||||
'''
|
||||
Emitted when an address form is filled.
|
||||
'''
|
||||
#: Information about the fields that were filled
|
||||
filled_fields: typing.List[FilledField]
|
||||
#: An UI representation of the address used to fill the form.
|
||||
#: Consists of a 2D array where each child represents an address/profile line.
|
||||
address_ui: AddressUI
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> AddressFormFilled:
|
||||
return cls(
|
||||
filled_fields=[FilledField.from_json(i) for i in json['filledFields']],
|
||||
address_ui=AddressUI.from_json(json['addressUi'])
|
||||
)
|
||||
@@ -0,0 +1,215 @@
|
||||
# DO NOT EDIT THIS FILE!
|
||||
#
|
||||
# This file is generated from the CDP specification. If you need to make
|
||||
# changes, edit the generator and regenerate all of the modules.
|
||||
#
|
||||
# CDP domain: BackgroundService (experimental)
|
||||
|
||||
from __future__ import annotations
|
||||
import enum
|
||||
import typing
|
||||
from dataclasses import dataclass
|
||||
from .util import event_class, T_JSON_DICT
|
||||
|
||||
from . import network
|
||||
from . import service_worker
|
||||
|
||||
|
||||
class ServiceName(enum.Enum):
|
||||
'''
|
||||
The Background Service that will be associated with the commands/events.
|
||||
Every Background Service operates independently, but they share the same
|
||||
API.
|
||||
'''
|
||||
BACKGROUND_FETCH = "backgroundFetch"
|
||||
BACKGROUND_SYNC = "backgroundSync"
|
||||
PUSH_MESSAGING = "pushMessaging"
|
||||
NOTIFICATIONS = "notifications"
|
||||
PAYMENT_HANDLER = "paymentHandler"
|
||||
PERIODIC_BACKGROUND_SYNC = "periodicBackgroundSync"
|
||||
|
||||
def to_json(self) -> str:
|
||||
return self.value
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: str) -> ServiceName:
|
||||
return cls(json)
|
||||
|
||||
|
||||
@dataclass
|
||||
class EventMetadata:
|
||||
'''
|
||||
A key-value pair for additional event information to pass along.
|
||||
'''
|
||||
key: str
|
||||
|
||||
value: str
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['key'] = self.key
|
||||
json['value'] = self.value
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> EventMetadata:
|
||||
return cls(
|
||||
key=str(json['key']),
|
||||
value=str(json['value']),
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class BackgroundServiceEvent:
|
||||
#: Timestamp of the event (in seconds).
|
||||
timestamp: network.TimeSinceEpoch
|
||||
|
||||
#: The origin this event belongs to.
|
||||
origin: str
|
||||
|
||||
#: The Service Worker ID that initiated the event.
|
||||
service_worker_registration_id: service_worker.RegistrationID
|
||||
|
||||
#: The Background Service this event belongs to.
|
||||
service: ServiceName
|
||||
|
||||
#: A description of the event.
|
||||
event_name: str
|
||||
|
||||
#: An identifier that groups related events together.
|
||||
instance_id: str
|
||||
|
||||
#: A list of event-specific information.
|
||||
event_metadata: typing.List[EventMetadata]
|
||||
|
||||
#: Storage key this event belongs to.
|
||||
storage_key: str
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['timestamp'] = self.timestamp.to_json()
|
||||
json['origin'] = self.origin
|
||||
json['serviceWorkerRegistrationId'] = self.service_worker_registration_id.to_json()
|
||||
json['service'] = self.service.to_json()
|
||||
json['eventName'] = self.event_name
|
||||
json['instanceId'] = self.instance_id
|
||||
json['eventMetadata'] = [i.to_json() for i in self.event_metadata]
|
||||
json['storageKey'] = self.storage_key
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> BackgroundServiceEvent:
|
||||
return cls(
|
||||
timestamp=network.TimeSinceEpoch.from_json(json['timestamp']),
|
||||
origin=str(json['origin']),
|
||||
service_worker_registration_id=service_worker.RegistrationID.from_json(json['serviceWorkerRegistrationId']),
|
||||
service=ServiceName.from_json(json['service']),
|
||||
event_name=str(json['eventName']),
|
||||
instance_id=str(json['instanceId']),
|
||||
event_metadata=[EventMetadata.from_json(i) for i in json['eventMetadata']],
|
||||
storage_key=str(json['storageKey']),
|
||||
)
|
||||
|
||||
|
||||
def start_observing(
|
||||
service: ServiceName
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Enables event updates for the service.
|
||||
|
||||
:param service:
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['service'] = service.to_json()
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'BackgroundService.startObserving',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def stop_observing(
|
||||
service: ServiceName
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Disables event updates for the service.
|
||||
|
||||
:param service:
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['service'] = service.to_json()
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'BackgroundService.stopObserving',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def set_recording(
|
||||
should_record: bool,
|
||||
service: ServiceName
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Set the recording state for the service.
|
||||
|
||||
:param should_record:
|
||||
:param service:
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['shouldRecord'] = should_record
|
||||
params['service'] = service.to_json()
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'BackgroundService.setRecording',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def clear_events(
|
||||
service: ServiceName
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Clears all stored data for the service.
|
||||
|
||||
:param service:
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['service'] = service.to_json()
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'BackgroundService.clearEvents',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
@event_class('BackgroundService.recordingStateChanged')
|
||||
@dataclass
|
||||
class RecordingStateChanged:
|
||||
'''
|
||||
Called when the recording state for the service has been updated.
|
||||
'''
|
||||
is_recording: bool
|
||||
service: ServiceName
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> RecordingStateChanged:
|
||||
return cls(
|
||||
is_recording=bool(json['isRecording']),
|
||||
service=ServiceName.from_json(json['service'])
|
||||
)
|
||||
|
||||
|
||||
@event_class('BackgroundService.backgroundServiceEventReceived')
|
||||
@dataclass
|
||||
class BackgroundServiceEventReceived:
|
||||
'''
|
||||
Called with all existing backgroundServiceEvents when enabled, and all new
|
||||
events afterwards if enabled and recording.
|
||||
'''
|
||||
background_service_event: BackgroundServiceEvent
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> BackgroundServiceEventReceived:
|
||||
return cls(
|
||||
background_service_event=BackgroundServiceEvent.from_json(json['backgroundServiceEvent'])
|
||||
)
|
||||
@@ -0,0 +1,626 @@
|
||||
# DO NOT EDIT THIS FILE!
|
||||
#
|
||||
# This file is generated from the CDP specification. If you need to make
|
||||
# changes, edit the generator and regenerate all of the modules.
|
||||
#
|
||||
# CDP domain: BluetoothEmulation (experimental)
|
||||
|
||||
from __future__ import annotations
|
||||
import enum
|
||||
import typing
|
||||
from dataclasses import dataclass
|
||||
from .util import event_class, T_JSON_DICT
|
||||
|
||||
|
||||
class CentralState(enum.Enum):
|
||||
'''
|
||||
Indicates the various states of Central.
|
||||
'''
|
||||
ABSENT = "absent"
|
||||
POWERED_OFF = "powered-off"
|
||||
POWERED_ON = "powered-on"
|
||||
|
||||
def to_json(self) -> str:
|
||||
return self.value
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: str) -> CentralState:
|
||||
return cls(json)
|
||||
|
||||
|
||||
class GATTOperationType(enum.Enum):
|
||||
'''
|
||||
Indicates the various types of GATT event.
|
||||
'''
|
||||
CONNECTION = "connection"
|
||||
DISCOVERY = "discovery"
|
||||
|
||||
def to_json(self) -> str:
|
||||
return self.value
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: str) -> GATTOperationType:
|
||||
return cls(json)
|
||||
|
||||
|
||||
class CharacteristicWriteType(enum.Enum):
|
||||
'''
|
||||
Indicates the various types of characteristic write.
|
||||
'''
|
||||
WRITE_DEFAULT_DEPRECATED = "write-default-deprecated"
|
||||
WRITE_WITH_RESPONSE = "write-with-response"
|
||||
WRITE_WITHOUT_RESPONSE = "write-without-response"
|
||||
|
||||
def to_json(self) -> str:
|
||||
return self.value
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: str) -> CharacteristicWriteType:
|
||||
return cls(json)
|
||||
|
||||
|
||||
class CharacteristicOperationType(enum.Enum):
|
||||
'''
|
||||
Indicates the various types of characteristic operation.
|
||||
'''
|
||||
READ = "read"
|
||||
WRITE = "write"
|
||||
SUBSCRIBE_TO_NOTIFICATIONS = "subscribe-to-notifications"
|
||||
UNSUBSCRIBE_FROM_NOTIFICATIONS = "unsubscribe-from-notifications"
|
||||
|
||||
def to_json(self) -> str:
|
||||
return self.value
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: str) -> CharacteristicOperationType:
|
||||
return cls(json)
|
||||
|
||||
|
||||
class DescriptorOperationType(enum.Enum):
|
||||
'''
|
||||
Indicates the various types of descriptor operation.
|
||||
'''
|
||||
READ = "read"
|
||||
WRITE = "write"
|
||||
|
||||
def to_json(self) -> str:
|
||||
return self.value
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: str) -> DescriptorOperationType:
|
||||
return cls(json)
|
||||
|
||||
|
||||
@dataclass
|
||||
class ManufacturerData:
|
||||
'''
|
||||
Stores the manufacturer data
|
||||
'''
|
||||
#: Company identifier
|
||||
#: https://bitbucket.org/bluetooth-SIG/public/src/main/assigned_numbers/company_identifiers/company_identifiers.yaml
|
||||
#: https://usb.org/developers
|
||||
key: int
|
||||
|
||||
#: Manufacturer-specific data (Encoded as a base64 string when passed over JSON)
|
||||
data: str
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['key'] = self.key
|
||||
json['data'] = self.data
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> ManufacturerData:
|
||||
return cls(
|
||||
key=int(json['key']),
|
||||
data=str(json['data']),
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class ScanRecord:
|
||||
'''
|
||||
Stores the byte data of the advertisement packet sent by a Bluetooth device.
|
||||
'''
|
||||
name: typing.Optional[str] = None
|
||||
|
||||
uuids: typing.Optional[typing.List[str]] = None
|
||||
|
||||
#: Stores the external appearance description of the device.
|
||||
appearance: typing.Optional[int] = None
|
||||
|
||||
#: Stores the transmission power of a broadcasting device.
|
||||
tx_power: typing.Optional[int] = None
|
||||
|
||||
#: Key is the company identifier and the value is an array of bytes of
|
||||
#: manufacturer specific data.
|
||||
manufacturer_data: typing.Optional[typing.List[ManufacturerData]] = None
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
if self.name is not None:
|
||||
json['name'] = self.name
|
||||
if self.uuids is not None:
|
||||
json['uuids'] = [i for i in self.uuids]
|
||||
if self.appearance is not None:
|
||||
json['appearance'] = self.appearance
|
||||
if self.tx_power is not None:
|
||||
json['txPower'] = self.tx_power
|
||||
if self.manufacturer_data is not None:
|
||||
json['manufacturerData'] = [i.to_json() for i in self.manufacturer_data]
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> ScanRecord:
|
||||
return cls(
|
||||
name=str(json['name']) if json.get('name', None) is not None else None,
|
||||
uuids=[str(i) for i in json['uuids']] if json.get('uuids', None) is not None else None,
|
||||
appearance=int(json['appearance']) if json.get('appearance', None) is not None else None,
|
||||
tx_power=int(json['txPower']) if json.get('txPower', None) is not None else None,
|
||||
manufacturer_data=[ManufacturerData.from_json(i) for i in json['manufacturerData']] if json.get('manufacturerData', None) is not None else None,
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class ScanEntry:
|
||||
'''
|
||||
Stores the advertisement packet information that is sent by a Bluetooth device.
|
||||
'''
|
||||
device_address: str
|
||||
|
||||
rssi: int
|
||||
|
||||
scan_record: ScanRecord
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['deviceAddress'] = self.device_address
|
||||
json['rssi'] = self.rssi
|
||||
json['scanRecord'] = self.scan_record.to_json()
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> ScanEntry:
|
||||
return cls(
|
||||
device_address=str(json['deviceAddress']),
|
||||
rssi=int(json['rssi']),
|
||||
scan_record=ScanRecord.from_json(json['scanRecord']),
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class CharacteristicProperties:
|
||||
'''
|
||||
Describes the properties of a characteristic. This follows Bluetooth Core
|
||||
Specification BT 4.2 Vol 3 Part G 3.3.1. Characteristic Properties.
|
||||
'''
|
||||
broadcast: typing.Optional[bool] = None
|
||||
|
||||
read: typing.Optional[bool] = None
|
||||
|
||||
write_without_response: typing.Optional[bool] = None
|
||||
|
||||
write: typing.Optional[bool] = None
|
||||
|
||||
notify: typing.Optional[bool] = None
|
||||
|
||||
indicate: typing.Optional[bool] = None
|
||||
|
||||
authenticated_signed_writes: typing.Optional[bool] = None
|
||||
|
||||
extended_properties: typing.Optional[bool] = None
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
if self.broadcast is not None:
|
||||
json['broadcast'] = self.broadcast
|
||||
if self.read is not None:
|
||||
json['read'] = self.read
|
||||
if self.write_without_response is not None:
|
||||
json['writeWithoutResponse'] = self.write_without_response
|
||||
if self.write is not None:
|
||||
json['write'] = self.write
|
||||
if self.notify is not None:
|
||||
json['notify'] = self.notify
|
||||
if self.indicate is not None:
|
||||
json['indicate'] = self.indicate
|
||||
if self.authenticated_signed_writes is not None:
|
||||
json['authenticatedSignedWrites'] = self.authenticated_signed_writes
|
||||
if self.extended_properties is not None:
|
||||
json['extendedProperties'] = self.extended_properties
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> CharacteristicProperties:
|
||||
return cls(
|
||||
broadcast=bool(json['broadcast']) if json.get('broadcast', None) is not None else None,
|
||||
read=bool(json['read']) if json.get('read', None) is not None else None,
|
||||
write_without_response=bool(json['writeWithoutResponse']) if json.get('writeWithoutResponse', None) is not None else None,
|
||||
write=bool(json['write']) if json.get('write', None) is not None else None,
|
||||
notify=bool(json['notify']) if json.get('notify', None) is not None else None,
|
||||
indicate=bool(json['indicate']) if json.get('indicate', None) is not None else None,
|
||||
authenticated_signed_writes=bool(json['authenticatedSignedWrites']) if json.get('authenticatedSignedWrites', None) is not None else None,
|
||||
extended_properties=bool(json['extendedProperties']) if json.get('extendedProperties', None) is not None else None,
|
||||
)
|
||||
|
||||
|
||||
def enable(
|
||||
state: CentralState,
|
||||
le_supported: bool
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Enable the BluetoothEmulation domain.
|
||||
|
||||
:param state: State of the simulated central.
|
||||
:param le_supported: If the simulated central supports low-energy.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['state'] = state.to_json()
|
||||
params['leSupported'] = le_supported
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'BluetoothEmulation.enable',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def set_simulated_central_state(
|
||||
state: CentralState
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Set the state of the simulated central.
|
||||
|
||||
:param state: State of the simulated central.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['state'] = state.to_json()
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'BluetoothEmulation.setSimulatedCentralState',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def disable() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Disable the BluetoothEmulation domain.
|
||||
'''
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'BluetoothEmulation.disable',
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def simulate_preconnected_peripheral(
|
||||
address: str,
|
||||
name: str,
|
||||
manufacturer_data: typing.List[ManufacturerData],
|
||||
known_service_uuids: typing.List[str]
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Simulates a peripheral with ``address``, ``name`` and ``knownServiceUuids``
|
||||
that has already been connected to the system.
|
||||
|
||||
:param address:
|
||||
:param name:
|
||||
:param manufacturer_data:
|
||||
:param known_service_uuids:
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['address'] = address
|
||||
params['name'] = name
|
||||
params['manufacturerData'] = [i.to_json() for i in manufacturer_data]
|
||||
params['knownServiceUuids'] = [i for i in known_service_uuids]
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'BluetoothEmulation.simulatePreconnectedPeripheral',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def simulate_advertisement(
|
||||
entry: ScanEntry
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Simulates an advertisement packet described in ``entry`` being received by
|
||||
the central.
|
||||
|
||||
:param entry:
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['entry'] = entry.to_json()
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'BluetoothEmulation.simulateAdvertisement',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def simulate_gatt_operation_response(
|
||||
address: str,
|
||||
type_: GATTOperationType,
|
||||
code: int
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Simulates the response code from the peripheral with ``address`` for a
|
||||
GATT operation of ``type``. The ``code`` value follows the HCI Error Codes from
|
||||
Bluetooth Core Specification Vol 2 Part D 1.3 List Of Error Codes.
|
||||
|
||||
:param address:
|
||||
:param type_:
|
||||
:param code:
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['address'] = address
|
||||
params['type'] = type_.to_json()
|
||||
params['code'] = code
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'BluetoothEmulation.simulateGATTOperationResponse',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def simulate_characteristic_operation_response(
|
||||
characteristic_id: str,
|
||||
type_: CharacteristicOperationType,
|
||||
code: int,
|
||||
data: typing.Optional[str] = None
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Simulates the response from the characteristic with ``characteristicId`` for a
|
||||
characteristic operation of ``type``. The ``code`` value follows the Error
|
||||
Codes from Bluetooth Core Specification Vol 3 Part F 3.4.1.1 Error Response.
|
||||
The ``data`` is expected to exist when simulating a successful read operation
|
||||
response.
|
||||
|
||||
:param characteristic_id:
|
||||
:param type_:
|
||||
:param code:
|
||||
:param data: *(Optional)*
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['characteristicId'] = characteristic_id
|
||||
params['type'] = type_.to_json()
|
||||
params['code'] = code
|
||||
if data is not None:
|
||||
params['data'] = data
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'BluetoothEmulation.simulateCharacteristicOperationResponse',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def simulate_descriptor_operation_response(
|
||||
descriptor_id: str,
|
||||
type_: DescriptorOperationType,
|
||||
code: int,
|
||||
data: typing.Optional[str] = None
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Simulates the response from the descriptor with ``descriptorId`` for a
|
||||
descriptor operation of ``type``. The ``code`` value follows the Error
|
||||
Codes from Bluetooth Core Specification Vol 3 Part F 3.4.1.1 Error Response.
|
||||
The ``data`` is expected to exist when simulating a successful read operation
|
||||
response.
|
||||
|
||||
:param descriptor_id:
|
||||
:param type_:
|
||||
:param code:
|
||||
:param data: *(Optional)*
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['descriptorId'] = descriptor_id
|
||||
params['type'] = type_.to_json()
|
||||
params['code'] = code
|
||||
if data is not None:
|
||||
params['data'] = data
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'BluetoothEmulation.simulateDescriptorOperationResponse',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def add_service(
|
||||
address: str,
|
||||
service_uuid: str
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,str]:
|
||||
'''
|
||||
Adds a service with ``serviceUuid`` to the peripheral with ``address``.
|
||||
|
||||
:param address:
|
||||
:param service_uuid:
|
||||
:returns: An identifier that uniquely represents this service.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['address'] = address
|
||||
params['serviceUuid'] = service_uuid
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'BluetoothEmulation.addService',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
return str(json['serviceId'])
|
||||
|
||||
|
||||
def remove_service(
|
||||
service_id: str
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Removes the service respresented by ``serviceId`` from the simulated central.
|
||||
|
||||
:param service_id:
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['serviceId'] = service_id
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'BluetoothEmulation.removeService',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def add_characteristic(
|
||||
service_id: str,
|
||||
characteristic_uuid: str,
|
||||
properties: CharacteristicProperties
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,str]:
|
||||
'''
|
||||
Adds a characteristic with ``characteristicUuid`` and ``properties`` to the
|
||||
service represented by ``serviceId``.
|
||||
|
||||
:param service_id:
|
||||
:param characteristic_uuid:
|
||||
:param properties:
|
||||
:returns: An identifier that uniquely represents this characteristic.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['serviceId'] = service_id
|
||||
params['characteristicUuid'] = characteristic_uuid
|
||||
params['properties'] = properties.to_json()
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'BluetoothEmulation.addCharacteristic',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
return str(json['characteristicId'])
|
||||
|
||||
|
||||
def remove_characteristic(
|
||||
characteristic_id: str
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Removes the characteristic respresented by ``characteristicId`` from the
|
||||
simulated central.
|
||||
|
||||
:param characteristic_id:
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['characteristicId'] = characteristic_id
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'BluetoothEmulation.removeCharacteristic',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def add_descriptor(
|
||||
characteristic_id: str,
|
||||
descriptor_uuid: str
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,str]:
|
||||
'''
|
||||
Adds a descriptor with ``descriptorUuid`` to the characteristic respresented
|
||||
by ``characteristicId``.
|
||||
|
||||
:param characteristic_id:
|
||||
:param descriptor_uuid:
|
||||
:returns: An identifier that uniquely represents this descriptor.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['characteristicId'] = characteristic_id
|
||||
params['descriptorUuid'] = descriptor_uuid
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'BluetoothEmulation.addDescriptor',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
return str(json['descriptorId'])
|
||||
|
||||
|
||||
def remove_descriptor(
|
||||
descriptor_id: str
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Removes the descriptor with ``descriptorId`` from the simulated central.
|
||||
|
||||
:param descriptor_id:
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['descriptorId'] = descriptor_id
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'BluetoothEmulation.removeDescriptor',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def simulate_gatt_disconnection(
|
||||
address: str
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Simulates a GATT disconnection from the peripheral with ``address``.
|
||||
|
||||
:param address:
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['address'] = address
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'BluetoothEmulation.simulateGATTDisconnection',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
@event_class('BluetoothEmulation.gattOperationReceived')
|
||||
@dataclass
|
||||
class GattOperationReceived:
|
||||
'''
|
||||
Event for when a GATT operation of ``type`` to the peripheral with ``address``
|
||||
happened.
|
||||
'''
|
||||
address: str
|
||||
type_: GATTOperationType
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> GattOperationReceived:
|
||||
return cls(
|
||||
address=str(json['address']),
|
||||
type_=GATTOperationType.from_json(json['type'])
|
||||
)
|
||||
|
||||
|
||||
@event_class('BluetoothEmulation.characteristicOperationReceived')
|
||||
@dataclass
|
||||
class CharacteristicOperationReceived:
|
||||
'''
|
||||
Event for when a characteristic operation of ``type`` to the characteristic
|
||||
respresented by ``characteristicId`` happened. ``data`` and ``writeType`` is
|
||||
expected to exist when ``type`` is write.
|
||||
'''
|
||||
characteristic_id: str
|
||||
type_: CharacteristicOperationType
|
||||
data: typing.Optional[str]
|
||||
write_type: typing.Optional[CharacteristicWriteType]
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> CharacteristicOperationReceived:
|
||||
return cls(
|
||||
characteristic_id=str(json['characteristicId']),
|
||||
type_=CharacteristicOperationType.from_json(json['type']),
|
||||
data=str(json['data']) if json.get('data', None) is not None else None,
|
||||
write_type=CharacteristicWriteType.from_json(json['writeType']) if json.get('writeType', None) is not None else None
|
||||
)
|
||||
|
||||
|
||||
@event_class('BluetoothEmulation.descriptorOperationReceived')
|
||||
@dataclass
|
||||
class DescriptorOperationReceived:
|
||||
'''
|
||||
Event for when a descriptor operation of ``type`` to the descriptor
|
||||
respresented by ``descriptorId`` happened. ``data`` is expected to exist when
|
||||
``type`` is write.
|
||||
'''
|
||||
descriptor_id: str
|
||||
type_: DescriptorOperationType
|
||||
data: typing.Optional[str]
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> DescriptorOperationReceived:
|
||||
return cls(
|
||||
descriptor_id=str(json['descriptorId']),
|
||||
type_=DescriptorOperationType.from_json(json['type']),
|
||||
data=str(json['data']) if json.get('data', None) is not None else None
|
||||
)
|
||||
@@ -0,0 +1,819 @@
|
||||
# DO NOT EDIT THIS FILE!
|
||||
#
|
||||
# This file is generated from the CDP specification. If you need to make
|
||||
# changes, edit the generator and regenerate all of the modules.
|
||||
#
|
||||
# CDP domain: Browser
|
||||
|
||||
from __future__ import annotations
|
||||
import enum
|
||||
import typing
|
||||
from dataclasses import dataclass
|
||||
from .util import event_class, T_JSON_DICT
|
||||
|
||||
from . import page
|
||||
from . import target
|
||||
from deprecated.sphinx import deprecated # type: ignore
|
||||
|
||||
|
||||
class BrowserContextID(str):
|
||||
def to_json(self) -> str:
|
||||
return self
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: str) -> BrowserContextID:
|
||||
return cls(json)
|
||||
|
||||
def __repr__(self):
|
||||
return 'BrowserContextID({})'.format(super().__repr__())
|
||||
|
||||
|
||||
class WindowID(int):
|
||||
def to_json(self) -> int:
|
||||
return self
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: int) -> WindowID:
|
||||
return cls(json)
|
||||
|
||||
def __repr__(self):
|
||||
return 'WindowID({})'.format(super().__repr__())
|
||||
|
||||
|
||||
class WindowState(enum.Enum):
|
||||
'''
|
||||
The state of the browser window.
|
||||
'''
|
||||
NORMAL = "normal"
|
||||
MINIMIZED = "minimized"
|
||||
MAXIMIZED = "maximized"
|
||||
FULLSCREEN = "fullscreen"
|
||||
|
||||
def to_json(self) -> str:
|
||||
return self.value
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: str) -> WindowState:
|
||||
return cls(json)
|
||||
|
||||
|
||||
@dataclass
|
||||
class Bounds:
|
||||
'''
|
||||
Browser window bounds information
|
||||
'''
|
||||
#: The offset from the left edge of the screen to the window in pixels.
|
||||
left: typing.Optional[int] = None
|
||||
|
||||
#: The offset from the top edge of the screen to the window in pixels.
|
||||
top: typing.Optional[int] = None
|
||||
|
||||
#: The window width in pixels.
|
||||
width: typing.Optional[int] = None
|
||||
|
||||
#: The window height in pixels.
|
||||
height: typing.Optional[int] = None
|
||||
|
||||
#: The window state. Default to normal.
|
||||
window_state: typing.Optional[WindowState] = None
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
if self.left is not None:
|
||||
json['left'] = self.left
|
||||
if self.top is not None:
|
||||
json['top'] = self.top
|
||||
if self.width is not None:
|
||||
json['width'] = self.width
|
||||
if self.height is not None:
|
||||
json['height'] = self.height
|
||||
if self.window_state is not None:
|
||||
json['windowState'] = self.window_state.to_json()
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> Bounds:
|
||||
return cls(
|
||||
left=int(json['left']) if json.get('left', None) is not None else None,
|
||||
top=int(json['top']) if json.get('top', None) is not None else None,
|
||||
width=int(json['width']) if json.get('width', None) is not None else None,
|
||||
height=int(json['height']) if json.get('height', None) is not None else None,
|
||||
window_state=WindowState.from_json(json['windowState']) if json.get('windowState', None) is not None else None,
|
||||
)
|
||||
|
||||
|
||||
class PermissionType(enum.Enum):
|
||||
AR = "ar"
|
||||
AUDIO_CAPTURE = "audioCapture"
|
||||
AUTOMATIC_FULLSCREEN = "automaticFullscreen"
|
||||
BACKGROUND_FETCH = "backgroundFetch"
|
||||
BACKGROUND_SYNC = "backgroundSync"
|
||||
CAMERA_PAN_TILT_ZOOM = "cameraPanTiltZoom"
|
||||
CAPTURED_SURFACE_CONTROL = "capturedSurfaceControl"
|
||||
CLIPBOARD_READ_WRITE = "clipboardReadWrite"
|
||||
CLIPBOARD_SANITIZED_WRITE = "clipboardSanitizedWrite"
|
||||
DISPLAY_CAPTURE = "displayCapture"
|
||||
DURABLE_STORAGE = "durableStorage"
|
||||
GEOLOCATION = "geolocation"
|
||||
HAND_TRACKING = "handTracking"
|
||||
IDLE_DETECTION = "idleDetection"
|
||||
KEYBOARD_LOCK = "keyboardLock"
|
||||
LOCAL_FONTS = "localFonts"
|
||||
LOCAL_NETWORK_ACCESS = "localNetworkAccess"
|
||||
MIDI = "midi"
|
||||
MIDI_SYSEX = "midiSysex"
|
||||
NFC = "nfc"
|
||||
NOTIFICATIONS = "notifications"
|
||||
PAYMENT_HANDLER = "paymentHandler"
|
||||
PERIODIC_BACKGROUND_SYNC = "periodicBackgroundSync"
|
||||
POINTER_LOCK = "pointerLock"
|
||||
PROTECTED_MEDIA_IDENTIFIER = "protectedMediaIdentifier"
|
||||
SENSORS = "sensors"
|
||||
SMART_CARD = "smartCard"
|
||||
SPEAKER_SELECTION = "speakerSelection"
|
||||
STORAGE_ACCESS = "storageAccess"
|
||||
TOP_LEVEL_STORAGE_ACCESS = "topLevelStorageAccess"
|
||||
VIDEO_CAPTURE = "videoCapture"
|
||||
VR = "vr"
|
||||
WAKE_LOCK_SCREEN = "wakeLockScreen"
|
||||
WAKE_LOCK_SYSTEM = "wakeLockSystem"
|
||||
WEB_APP_INSTALLATION = "webAppInstallation"
|
||||
WEB_PRINTING = "webPrinting"
|
||||
WINDOW_MANAGEMENT = "windowManagement"
|
||||
|
||||
def to_json(self) -> str:
|
||||
return self.value
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: str) -> PermissionType:
|
||||
return cls(json)
|
||||
|
||||
|
||||
class PermissionSetting(enum.Enum):
|
||||
GRANTED = "granted"
|
||||
DENIED = "denied"
|
||||
PROMPT = "prompt"
|
||||
|
||||
def to_json(self) -> str:
|
||||
return self.value
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: str) -> PermissionSetting:
|
||||
return cls(json)
|
||||
|
||||
|
||||
@dataclass
|
||||
class PermissionDescriptor:
|
||||
'''
|
||||
Definition of PermissionDescriptor defined in the Permissions API:
|
||||
https://w3c.github.io/permissions/#dom-permissiondescriptor.
|
||||
'''
|
||||
#: Name of permission.
|
||||
#: See https://cs.chromium.org/chromium/src/third_party/blink/renderer/modules/permissions/permission_descriptor.idl for valid permission names.
|
||||
name: str
|
||||
|
||||
#: For "midi" permission, may also specify sysex control.
|
||||
sysex: typing.Optional[bool] = None
|
||||
|
||||
#: For "push" permission, may specify userVisibleOnly.
|
||||
#: Note that userVisibleOnly = true is the only currently supported type.
|
||||
user_visible_only: typing.Optional[bool] = None
|
||||
|
||||
#: For "clipboard" permission, may specify allowWithoutSanitization.
|
||||
allow_without_sanitization: typing.Optional[bool] = None
|
||||
|
||||
#: For "fullscreen" permission, must specify allowWithoutGesture:true.
|
||||
allow_without_gesture: typing.Optional[bool] = None
|
||||
|
||||
#: For "camera" permission, may specify panTiltZoom.
|
||||
pan_tilt_zoom: typing.Optional[bool] = None
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['name'] = self.name
|
||||
if self.sysex is not None:
|
||||
json['sysex'] = self.sysex
|
||||
if self.user_visible_only is not None:
|
||||
json['userVisibleOnly'] = self.user_visible_only
|
||||
if self.allow_without_sanitization is not None:
|
||||
json['allowWithoutSanitization'] = self.allow_without_sanitization
|
||||
if self.allow_without_gesture is not None:
|
||||
json['allowWithoutGesture'] = self.allow_without_gesture
|
||||
if self.pan_tilt_zoom is not None:
|
||||
json['panTiltZoom'] = self.pan_tilt_zoom
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> PermissionDescriptor:
|
||||
return cls(
|
||||
name=str(json['name']),
|
||||
sysex=bool(json['sysex']) if json.get('sysex', None) is not None else None,
|
||||
user_visible_only=bool(json['userVisibleOnly']) if json.get('userVisibleOnly', None) is not None else None,
|
||||
allow_without_sanitization=bool(json['allowWithoutSanitization']) if json.get('allowWithoutSanitization', None) is not None else None,
|
||||
allow_without_gesture=bool(json['allowWithoutGesture']) if json.get('allowWithoutGesture', None) is not None else None,
|
||||
pan_tilt_zoom=bool(json['panTiltZoom']) if json.get('panTiltZoom', None) is not None else None,
|
||||
)
|
||||
|
||||
|
||||
class BrowserCommandId(enum.Enum):
|
||||
'''
|
||||
Browser command ids used by executeBrowserCommand.
|
||||
'''
|
||||
OPEN_TAB_SEARCH = "openTabSearch"
|
||||
CLOSE_TAB_SEARCH = "closeTabSearch"
|
||||
OPEN_GLIC = "openGlic"
|
||||
|
||||
def to_json(self) -> str:
|
||||
return self.value
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: str) -> BrowserCommandId:
|
||||
return cls(json)
|
||||
|
||||
|
||||
@dataclass
|
||||
class Bucket:
|
||||
'''
|
||||
Chrome histogram bucket.
|
||||
'''
|
||||
#: Minimum value (inclusive).
|
||||
low: int
|
||||
|
||||
#: Maximum value (exclusive).
|
||||
high: int
|
||||
|
||||
#: Number of samples.
|
||||
count: int
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['low'] = self.low
|
||||
json['high'] = self.high
|
||||
json['count'] = self.count
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> Bucket:
|
||||
return cls(
|
||||
low=int(json['low']),
|
||||
high=int(json['high']),
|
||||
count=int(json['count']),
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class Histogram:
|
||||
'''
|
||||
Chrome histogram.
|
||||
'''
|
||||
#: Name.
|
||||
name: str
|
||||
|
||||
#: Sum of sample values.
|
||||
sum_: int
|
||||
|
||||
#: Total number of samples.
|
||||
count: int
|
||||
|
||||
#: Buckets.
|
||||
buckets: typing.List[Bucket]
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['name'] = self.name
|
||||
json['sum'] = self.sum_
|
||||
json['count'] = self.count
|
||||
json['buckets'] = [i.to_json() for i in self.buckets]
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> Histogram:
|
||||
return cls(
|
||||
name=str(json['name']),
|
||||
sum_=int(json['sum']),
|
||||
count=int(json['count']),
|
||||
buckets=[Bucket.from_json(i) for i in json['buckets']],
|
||||
)
|
||||
|
||||
|
||||
class PrivacySandboxAPI(enum.Enum):
|
||||
BIDDING_AND_AUCTION_SERVICES = "BiddingAndAuctionServices"
|
||||
TRUSTED_KEY_VALUE = "TrustedKeyValue"
|
||||
|
||||
def to_json(self) -> str:
|
||||
return self.value
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: str) -> PrivacySandboxAPI:
|
||||
return cls(json)
|
||||
|
||||
|
||||
def set_permission(
|
||||
permission: PermissionDescriptor,
|
||||
setting: PermissionSetting,
|
||||
origin: typing.Optional[str] = None,
|
||||
embedded_origin: typing.Optional[str] = None,
|
||||
browser_context_id: typing.Optional[BrowserContextID] = None
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Set permission settings for given embedding and embedded origins.
|
||||
|
||||
**EXPERIMENTAL**
|
||||
|
||||
:param permission: Descriptor of permission to override.
|
||||
:param setting: Setting of the permission.
|
||||
:param origin: *(Optional)* Embedding origin the permission applies to, all origins if not specified.
|
||||
:param embedded_origin: *(Optional)* Embedded origin the permission applies to. It is ignored unless the embedding origin is present and valid. If the embedding origin is provided but the embedded origin isn't, the embedding origin is used as the embedded origin.
|
||||
:param browser_context_id: *(Optional)* Context to override. When omitted, default browser context is used.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['permission'] = permission.to_json()
|
||||
params['setting'] = setting.to_json()
|
||||
if origin is not None:
|
||||
params['origin'] = origin
|
||||
if embedded_origin is not None:
|
||||
params['embeddedOrigin'] = embedded_origin
|
||||
if browser_context_id is not None:
|
||||
params['browserContextId'] = browser_context_id.to_json()
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Browser.setPermission',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
@deprecated(version="1.3")
|
||||
def grant_permissions(
|
||||
permissions: typing.List[PermissionType],
|
||||
origin: typing.Optional[str] = None,
|
||||
browser_context_id: typing.Optional[BrowserContextID] = None
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Grant specific permissions to the given origin and reject all others. Deprecated. Use
|
||||
setPermission instead.
|
||||
|
||||
.. deprecated:: 1.3
|
||||
|
||||
**EXPERIMENTAL**
|
||||
|
||||
:param permissions:
|
||||
:param origin: *(Optional)* Origin the permission applies to, all origins if not specified.
|
||||
:param browser_context_id: *(Optional)* BrowserContext to override permissions. When omitted, default browser context is used.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['permissions'] = [i.to_json() for i in permissions]
|
||||
if origin is not None:
|
||||
params['origin'] = origin
|
||||
if browser_context_id is not None:
|
||||
params['browserContextId'] = browser_context_id.to_json()
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Browser.grantPermissions',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def reset_permissions(
|
||||
browser_context_id: typing.Optional[BrowserContextID] = None
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Reset all permission management for all origins.
|
||||
|
||||
:param browser_context_id: *(Optional)* BrowserContext to reset permissions. When omitted, default browser context is used.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
if browser_context_id is not None:
|
||||
params['browserContextId'] = browser_context_id.to_json()
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Browser.resetPermissions',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def set_download_behavior(
|
||||
behavior: str,
|
||||
browser_context_id: typing.Optional[BrowserContextID] = None,
|
||||
download_path: typing.Optional[str] = None,
|
||||
events_enabled: typing.Optional[bool] = None
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Set the behavior when downloading a file.
|
||||
|
||||
**EXPERIMENTAL**
|
||||
|
||||
:param behavior: Whether to allow all or deny all download requests, or use default Chrome behavior if available (otherwise deny). ``allowAndName`` allows download and names files according to their download guids.
|
||||
:param browser_context_id: *(Optional)* BrowserContext to set download behavior. When omitted, default browser context is used.
|
||||
:param download_path: *(Optional)* The default path to save downloaded files to. This is required if behavior is set to 'allow' or 'allowAndName'.
|
||||
:param events_enabled: *(Optional)* Whether to emit download events (defaults to false).
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['behavior'] = behavior
|
||||
if browser_context_id is not None:
|
||||
params['browserContextId'] = browser_context_id.to_json()
|
||||
if download_path is not None:
|
||||
params['downloadPath'] = download_path
|
||||
if events_enabled is not None:
|
||||
params['eventsEnabled'] = events_enabled
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Browser.setDownloadBehavior',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def cancel_download(
|
||||
guid: str,
|
||||
browser_context_id: typing.Optional[BrowserContextID] = None
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Cancel a download if in progress
|
||||
|
||||
**EXPERIMENTAL**
|
||||
|
||||
:param guid: Global unique identifier of the download.
|
||||
:param browser_context_id: *(Optional)* BrowserContext to perform the action in. When omitted, default browser context is used.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['guid'] = guid
|
||||
if browser_context_id is not None:
|
||||
params['browserContextId'] = browser_context_id.to_json()
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Browser.cancelDownload',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def close() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Close browser gracefully.
|
||||
'''
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Browser.close',
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def crash() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Crashes browser on the main thread.
|
||||
|
||||
**EXPERIMENTAL**
|
||||
'''
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Browser.crash',
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def crash_gpu_process() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Crashes GPU process.
|
||||
|
||||
**EXPERIMENTAL**
|
||||
'''
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Browser.crashGpuProcess',
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def get_version() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.Tuple[str, str, str, str, str]]:
|
||||
'''
|
||||
Returns version information.
|
||||
|
||||
:returns: A tuple with the following items:
|
||||
|
||||
0. **protocolVersion** - Protocol version.
|
||||
1. **product** - Product name.
|
||||
2. **revision** - Product revision.
|
||||
3. **userAgent** - User-Agent.
|
||||
4. **jsVersion** - V8 version.
|
||||
'''
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Browser.getVersion',
|
||||
}
|
||||
json = yield cmd_dict
|
||||
return (
|
||||
str(json['protocolVersion']),
|
||||
str(json['product']),
|
||||
str(json['revision']),
|
||||
str(json['userAgent']),
|
||||
str(json['jsVersion'])
|
||||
)
|
||||
|
||||
|
||||
def get_browser_command_line() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.List[str]]:
|
||||
'''
|
||||
Returns the command line switches for the browser process if, and only if
|
||||
--enable-automation is on the commandline.
|
||||
|
||||
**EXPERIMENTAL**
|
||||
|
||||
:returns: Commandline parameters
|
||||
'''
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Browser.getBrowserCommandLine',
|
||||
}
|
||||
json = yield cmd_dict
|
||||
return [str(i) for i in json['arguments']]
|
||||
|
||||
|
||||
def get_histograms(
|
||||
query: typing.Optional[str] = None,
|
||||
delta: typing.Optional[bool] = None
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.List[Histogram]]:
|
||||
'''
|
||||
Get Chrome histograms.
|
||||
|
||||
**EXPERIMENTAL**
|
||||
|
||||
:param query: *(Optional)* Requested substring in name. Only histograms which have query as a substring in their name are extracted. An empty or absent query returns all histograms.
|
||||
:param delta: *(Optional)* If true, retrieve delta since last delta call.
|
||||
:returns: Histograms.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
if query is not None:
|
||||
params['query'] = query
|
||||
if delta is not None:
|
||||
params['delta'] = delta
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Browser.getHistograms',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
return [Histogram.from_json(i) for i in json['histograms']]
|
||||
|
||||
|
||||
def get_histogram(
|
||||
name: str,
|
||||
delta: typing.Optional[bool] = None
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,Histogram]:
|
||||
'''
|
||||
Get a Chrome histogram by name.
|
||||
|
||||
**EXPERIMENTAL**
|
||||
|
||||
:param name: Requested histogram name.
|
||||
:param delta: *(Optional)* If true, retrieve delta since last delta call.
|
||||
:returns: Histogram.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['name'] = name
|
||||
if delta is not None:
|
||||
params['delta'] = delta
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Browser.getHistogram',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
return Histogram.from_json(json['histogram'])
|
||||
|
||||
|
||||
def get_window_bounds(
|
||||
window_id: WindowID
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,Bounds]:
|
||||
'''
|
||||
Get position and size of the browser window.
|
||||
|
||||
**EXPERIMENTAL**
|
||||
|
||||
:param window_id: Browser window id.
|
||||
:returns: Bounds information of the window. When window state is 'minimized', the restored window position and size are returned.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['windowId'] = window_id.to_json()
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Browser.getWindowBounds',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
return Bounds.from_json(json['bounds'])
|
||||
|
||||
|
||||
def get_window_for_target(
|
||||
target_id: typing.Optional[target.TargetID] = None
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.Tuple[WindowID, Bounds]]:
|
||||
'''
|
||||
Get the browser window that contains the devtools target.
|
||||
|
||||
**EXPERIMENTAL**
|
||||
|
||||
:param target_id: *(Optional)* Devtools agent host id. If called as a part of the session, associated targetId is used.
|
||||
:returns: A tuple with the following items:
|
||||
|
||||
0. **windowId** - Browser window id.
|
||||
1. **bounds** - Bounds information of the window. When window state is 'minimized', the restored window position and size are returned.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
if target_id is not None:
|
||||
params['targetId'] = target_id.to_json()
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Browser.getWindowForTarget',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
return (
|
||||
WindowID.from_json(json['windowId']),
|
||||
Bounds.from_json(json['bounds'])
|
||||
)
|
||||
|
||||
|
||||
def set_window_bounds(
|
||||
window_id: WindowID,
|
||||
bounds: Bounds
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Set position and/or size of the browser window.
|
||||
|
||||
**EXPERIMENTAL**
|
||||
|
||||
:param window_id: Browser window id.
|
||||
:param bounds: New window bounds. The 'minimized', 'maximized' and 'fullscreen' states cannot be combined with 'left', 'top', 'width' or 'height'. Leaves unspecified fields unchanged.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['windowId'] = window_id.to_json()
|
||||
params['bounds'] = bounds.to_json()
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Browser.setWindowBounds',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def set_contents_size(
|
||||
window_id: WindowID,
|
||||
width: typing.Optional[int] = None,
|
||||
height: typing.Optional[int] = None
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Set size of the browser contents resizing browser window as necessary.
|
||||
|
||||
**EXPERIMENTAL**
|
||||
|
||||
:param window_id: Browser window id.
|
||||
:param width: *(Optional)* The window contents width in DIP. Assumes current width if omitted. Must be specified if 'height' is omitted.
|
||||
:param height: *(Optional)* The window contents height in DIP. Assumes current height if omitted. Must be specified if 'width' is omitted.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['windowId'] = window_id.to_json()
|
||||
if width is not None:
|
||||
params['width'] = width
|
||||
if height is not None:
|
||||
params['height'] = height
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Browser.setContentsSize',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def set_dock_tile(
|
||||
badge_label: typing.Optional[str] = None,
|
||||
image: typing.Optional[str] = None
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Set dock tile details, platform-specific.
|
||||
|
||||
**EXPERIMENTAL**
|
||||
|
||||
:param badge_label: *(Optional)*
|
||||
:param image: *(Optional)* Png encoded image. (Encoded as a base64 string when passed over JSON)
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
if badge_label is not None:
|
||||
params['badgeLabel'] = badge_label
|
||||
if image is not None:
|
||||
params['image'] = image
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Browser.setDockTile',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def execute_browser_command(
|
||||
command_id: BrowserCommandId
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Invoke custom browser commands used by telemetry.
|
||||
|
||||
**EXPERIMENTAL**
|
||||
|
||||
:param command_id:
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['commandId'] = command_id.to_json()
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Browser.executeBrowserCommand',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def add_privacy_sandbox_enrollment_override(
|
||||
url: str
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Allows a site to use privacy sandbox features that require enrollment
|
||||
without the site actually being enrolled. Only supported on page targets.
|
||||
|
||||
:param url:
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['url'] = url
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Browser.addPrivacySandboxEnrollmentOverride',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def add_privacy_sandbox_coordinator_key_config(
|
||||
api: PrivacySandboxAPI,
|
||||
coordinator_origin: str,
|
||||
key_config: str,
|
||||
browser_context_id: typing.Optional[BrowserContextID] = None
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Configures encryption keys used with a given privacy sandbox API to talk
|
||||
to a trusted coordinator. Since this is intended for test automation only,
|
||||
coordinatorOrigin must be a .test domain. No existing coordinator
|
||||
configuration for the origin may exist.
|
||||
|
||||
:param api:
|
||||
:param coordinator_origin:
|
||||
:param key_config:
|
||||
:param browser_context_id: *(Optional)* BrowserContext to perform the action in. When omitted, default browser context is used.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['api'] = api.to_json()
|
||||
params['coordinatorOrigin'] = coordinator_origin
|
||||
params['keyConfig'] = key_config
|
||||
if browser_context_id is not None:
|
||||
params['browserContextId'] = browser_context_id.to_json()
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Browser.addPrivacySandboxCoordinatorKeyConfig',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
@event_class('Browser.downloadWillBegin')
|
||||
@dataclass
|
||||
class DownloadWillBegin:
|
||||
'''
|
||||
**EXPERIMENTAL**
|
||||
|
||||
Fired when page is about to start a download.
|
||||
'''
|
||||
#: Id of the frame that caused the download to begin.
|
||||
frame_id: page.FrameId
|
||||
#: Global unique identifier of the download.
|
||||
guid: str
|
||||
#: URL of the resource being downloaded.
|
||||
url: str
|
||||
#: Suggested file name of the resource (the actual name of the file saved on disk may differ).
|
||||
suggested_filename: str
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> DownloadWillBegin:
|
||||
return cls(
|
||||
frame_id=page.FrameId.from_json(json['frameId']),
|
||||
guid=str(json['guid']),
|
||||
url=str(json['url']),
|
||||
suggested_filename=str(json['suggestedFilename'])
|
||||
)
|
||||
|
||||
|
||||
@event_class('Browser.downloadProgress')
|
||||
@dataclass
|
||||
class DownloadProgress:
|
||||
'''
|
||||
**EXPERIMENTAL**
|
||||
|
||||
Fired when download makes progress. Last call has ``done`` == true.
|
||||
'''
|
||||
#: Global unique identifier of the download.
|
||||
guid: str
|
||||
#: Total expected bytes to download.
|
||||
total_bytes: float
|
||||
#: Total bytes received.
|
||||
received_bytes: float
|
||||
#: Download status.
|
||||
state: str
|
||||
#: If download is "completed", provides the path of the downloaded file.
|
||||
#: Depending on the platform, it is not guaranteed to be set, nor the file
|
||||
#: is guaranteed to exist.
|
||||
file_path: typing.Optional[str]
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> DownloadProgress:
|
||||
return cls(
|
||||
guid=str(json['guid']),
|
||||
total_bytes=float(json['totalBytes']),
|
||||
received_bytes=float(json['receivedBytes']),
|
||||
state=str(json['state']),
|
||||
file_path=str(json['filePath']) if json.get('filePath', None) is not None else None
|
||||
)
|
||||
@@ -0,0 +1,311 @@
|
||||
# DO NOT EDIT THIS FILE!
|
||||
#
|
||||
# This file is generated from the CDP specification. If you need to make
|
||||
# changes, edit the generator and regenerate all of the modules.
|
||||
#
|
||||
# CDP domain: CacheStorage (experimental)
|
||||
|
||||
from __future__ import annotations
|
||||
import enum
|
||||
import typing
|
||||
from dataclasses import dataclass
|
||||
from .util import event_class, T_JSON_DICT
|
||||
|
||||
from . import storage
|
||||
|
||||
|
||||
class CacheId(str):
|
||||
'''
|
||||
Unique identifier of the Cache object.
|
||||
'''
|
||||
def to_json(self) -> str:
|
||||
return self
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: str) -> CacheId:
|
||||
return cls(json)
|
||||
|
||||
def __repr__(self):
|
||||
return 'CacheId({})'.format(super().__repr__())
|
||||
|
||||
|
||||
class CachedResponseType(enum.Enum):
|
||||
'''
|
||||
type of HTTP response cached
|
||||
'''
|
||||
BASIC = "basic"
|
||||
CORS = "cors"
|
||||
DEFAULT = "default"
|
||||
ERROR = "error"
|
||||
OPAQUE_RESPONSE = "opaqueResponse"
|
||||
OPAQUE_REDIRECT = "opaqueRedirect"
|
||||
|
||||
def to_json(self) -> str:
|
||||
return self.value
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: str) -> CachedResponseType:
|
||||
return cls(json)
|
||||
|
||||
|
||||
@dataclass
|
||||
class DataEntry:
|
||||
'''
|
||||
Data entry.
|
||||
'''
|
||||
#: Request URL.
|
||||
request_url: str
|
||||
|
||||
#: Request method.
|
||||
request_method: str
|
||||
|
||||
#: Request headers
|
||||
request_headers: typing.List[Header]
|
||||
|
||||
#: Number of seconds since epoch.
|
||||
response_time: float
|
||||
|
||||
#: HTTP response status code.
|
||||
response_status: int
|
||||
|
||||
#: HTTP response status text.
|
||||
response_status_text: str
|
||||
|
||||
#: HTTP response type
|
||||
response_type: CachedResponseType
|
||||
|
||||
#: Response headers
|
||||
response_headers: typing.List[Header]
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['requestURL'] = self.request_url
|
||||
json['requestMethod'] = self.request_method
|
||||
json['requestHeaders'] = [i.to_json() for i in self.request_headers]
|
||||
json['responseTime'] = self.response_time
|
||||
json['responseStatus'] = self.response_status
|
||||
json['responseStatusText'] = self.response_status_text
|
||||
json['responseType'] = self.response_type.to_json()
|
||||
json['responseHeaders'] = [i.to_json() for i in self.response_headers]
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> DataEntry:
|
||||
return cls(
|
||||
request_url=str(json['requestURL']),
|
||||
request_method=str(json['requestMethod']),
|
||||
request_headers=[Header.from_json(i) for i in json['requestHeaders']],
|
||||
response_time=float(json['responseTime']),
|
||||
response_status=int(json['responseStatus']),
|
||||
response_status_text=str(json['responseStatusText']),
|
||||
response_type=CachedResponseType.from_json(json['responseType']),
|
||||
response_headers=[Header.from_json(i) for i in json['responseHeaders']],
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class Cache:
|
||||
'''
|
||||
Cache identifier.
|
||||
'''
|
||||
#: An opaque unique id of the cache.
|
||||
cache_id: CacheId
|
||||
|
||||
#: Security origin of the cache.
|
||||
security_origin: str
|
||||
|
||||
#: Storage key of the cache.
|
||||
storage_key: str
|
||||
|
||||
#: The name of the cache.
|
||||
cache_name: str
|
||||
|
||||
#: Storage bucket of the cache.
|
||||
storage_bucket: typing.Optional[storage.StorageBucket] = None
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['cacheId'] = self.cache_id.to_json()
|
||||
json['securityOrigin'] = self.security_origin
|
||||
json['storageKey'] = self.storage_key
|
||||
json['cacheName'] = self.cache_name
|
||||
if self.storage_bucket is not None:
|
||||
json['storageBucket'] = self.storage_bucket.to_json()
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> Cache:
|
||||
return cls(
|
||||
cache_id=CacheId.from_json(json['cacheId']),
|
||||
security_origin=str(json['securityOrigin']),
|
||||
storage_key=str(json['storageKey']),
|
||||
cache_name=str(json['cacheName']),
|
||||
storage_bucket=storage.StorageBucket.from_json(json['storageBucket']) if json.get('storageBucket', None) is not None else None,
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class Header:
|
||||
name: str
|
||||
|
||||
value: str
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['name'] = self.name
|
||||
json['value'] = self.value
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> Header:
|
||||
return cls(
|
||||
name=str(json['name']),
|
||||
value=str(json['value']),
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class CachedResponse:
|
||||
'''
|
||||
Cached response
|
||||
'''
|
||||
#: Entry content, base64-encoded. (Encoded as a base64 string when passed over JSON)
|
||||
body: str
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['body'] = self.body
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> CachedResponse:
|
||||
return cls(
|
||||
body=str(json['body']),
|
||||
)
|
||||
|
||||
|
||||
def delete_cache(
|
||||
cache_id: CacheId
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Deletes a cache.
|
||||
|
||||
:param cache_id: Id of cache for deletion.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['cacheId'] = cache_id.to_json()
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'CacheStorage.deleteCache',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def delete_entry(
|
||||
cache_id: CacheId,
|
||||
request: str
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Deletes a cache entry.
|
||||
|
||||
:param cache_id: Id of cache where the entry will be deleted.
|
||||
:param request: URL spec of the request.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['cacheId'] = cache_id.to_json()
|
||||
params['request'] = request
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'CacheStorage.deleteEntry',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def request_cache_names(
|
||||
security_origin: typing.Optional[str] = None,
|
||||
storage_key: typing.Optional[str] = None,
|
||||
storage_bucket: typing.Optional[storage.StorageBucket] = None
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.List[Cache]]:
|
||||
'''
|
||||
Requests cache names.
|
||||
|
||||
:param security_origin: *(Optional)* At least and at most one of securityOrigin, storageKey, storageBucket must be specified. Security origin.
|
||||
:param storage_key: *(Optional)* Storage key.
|
||||
:param storage_bucket: *(Optional)* Storage bucket. If not specified, it uses the default bucket.
|
||||
:returns: Caches for the security origin.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
if security_origin is not None:
|
||||
params['securityOrigin'] = security_origin
|
||||
if storage_key is not None:
|
||||
params['storageKey'] = storage_key
|
||||
if storage_bucket is not None:
|
||||
params['storageBucket'] = storage_bucket.to_json()
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'CacheStorage.requestCacheNames',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
return [Cache.from_json(i) for i in json['caches']]
|
||||
|
||||
|
||||
def request_cached_response(
|
||||
cache_id: CacheId,
|
||||
request_url: str,
|
||||
request_headers: typing.List[Header]
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,CachedResponse]:
|
||||
'''
|
||||
Fetches cache entry.
|
||||
|
||||
:param cache_id: Id of cache that contains the entry.
|
||||
:param request_url: URL spec of the request.
|
||||
:param request_headers: headers of the request.
|
||||
:returns: Response read from the cache.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['cacheId'] = cache_id.to_json()
|
||||
params['requestURL'] = request_url
|
||||
params['requestHeaders'] = [i.to_json() for i in request_headers]
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'CacheStorage.requestCachedResponse',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
return CachedResponse.from_json(json['response'])
|
||||
|
||||
|
||||
def request_entries(
|
||||
cache_id: CacheId,
|
||||
skip_count: typing.Optional[int] = None,
|
||||
page_size: typing.Optional[int] = None,
|
||||
path_filter: typing.Optional[str] = None
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.Tuple[typing.List[DataEntry], float]]:
|
||||
'''
|
||||
Requests data from cache.
|
||||
|
||||
:param cache_id: ID of cache to get entries from.
|
||||
:param skip_count: *(Optional)* Number of records to skip.
|
||||
:param page_size: *(Optional)* Number of records to fetch.
|
||||
:param path_filter: *(Optional)* If present, only return the entries containing this substring in the path
|
||||
:returns: A tuple with the following items:
|
||||
|
||||
0. **cacheDataEntries** - Array of object store data entries.
|
||||
1. **returnCount** - Count of returned entries from this storage. If pathFilter is empty, it is the count of all entries from this storage.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['cacheId'] = cache_id.to_json()
|
||||
if skip_count is not None:
|
||||
params['skipCount'] = skip_count
|
||||
if page_size is not None:
|
||||
params['pageSize'] = page_size
|
||||
if path_filter is not None:
|
||||
params['pathFilter'] = path_filter
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'CacheStorage.requestEntries',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
return (
|
||||
[DataEntry.from_json(i) for i in json['cacheDataEntries']],
|
||||
float(json['returnCount'])
|
||||
)
|
||||
@@ -0,0 +1,172 @@
|
||||
# DO NOT EDIT THIS FILE!
|
||||
#
|
||||
# This file is generated from the CDP specification. If you need to make
|
||||
# changes, edit the generator and regenerate all of the modules.
|
||||
#
|
||||
# CDP domain: Cast (experimental)
|
||||
|
||||
from __future__ import annotations
|
||||
import enum
|
||||
import typing
|
||||
from dataclasses import dataclass
|
||||
from .util import event_class, T_JSON_DICT
|
||||
|
||||
|
||||
@dataclass
|
||||
class Sink:
|
||||
name: str
|
||||
|
||||
id_: str
|
||||
|
||||
#: Text describing the current session. Present only if there is an active
|
||||
#: session on the sink.
|
||||
session: typing.Optional[str] = None
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['name'] = self.name
|
||||
json['id'] = self.id_
|
||||
if self.session is not None:
|
||||
json['session'] = self.session
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> Sink:
|
||||
return cls(
|
||||
name=str(json['name']),
|
||||
id_=str(json['id']),
|
||||
session=str(json['session']) if json.get('session', None) is not None else None,
|
||||
)
|
||||
|
||||
|
||||
def enable(
|
||||
presentation_url: typing.Optional[str] = None
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Starts observing for sinks that can be used for tab mirroring, and if set,
|
||||
sinks compatible with ``presentationUrl`` as well. When sinks are found, a
|
||||
``sinksUpdated`` event is fired.
|
||||
Also starts observing for issue messages. When an issue is added or removed,
|
||||
an ``issueUpdated`` event is fired.
|
||||
|
||||
:param presentation_url: *(Optional)*
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
if presentation_url is not None:
|
||||
params['presentationUrl'] = presentation_url
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Cast.enable',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def disable() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Stops observing for sinks and issues.
|
||||
'''
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Cast.disable',
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def set_sink_to_use(
|
||||
sink_name: str
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Sets a sink to be used when the web page requests the browser to choose a
|
||||
sink via Presentation API, Remote Playback API, or Cast SDK.
|
||||
|
||||
:param sink_name:
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['sinkName'] = sink_name
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Cast.setSinkToUse',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def start_desktop_mirroring(
|
||||
sink_name: str
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Starts mirroring the desktop to the sink.
|
||||
|
||||
:param sink_name:
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['sinkName'] = sink_name
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Cast.startDesktopMirroring',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def start_tab_mirroring(
|
||||
sink_name: str
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Starts mirroring the tab to the sink.
|
||||
|
||||
:param sink_name:
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['sinkName'] = sink_name
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Cast.startTabMirroring',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def stop_casting(
|
||||
sink_name: str
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Stops the active Cast session on the sink.
|
||||
|
||||
:param sink_name:
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['sinkName'] = sink_name
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Cast.stopCasting',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
@event_class('Cast.sinksUpdated')
|
||||
@dataclass
|
||||
class SinksUpdated:
|
||||
'''
|
||||
This is fired whenever the list of available sinks changes. A sink is a
|
||||
device or a software surface that you can cast to.
|
||||
'''
|
||||
sinks: typing.List[Sink]
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> SinksUpdated:
|
||||
return cls(
|
||||
sinks=[Sink.from_json(i) for i in json['sinks']]
|
||||
)
|
||||
|
||||
|
||||
@event_class('Cast.issueUpdated')
|
||||
@dataclass
|
||||
class IssueUpdated:
|
||||
'''
|
||||
This is fired whenever the outstanding issue/error message changes.
|
||||
``issueMessage`` is empty if there is no issue.
|
||||
'''
|
||||
issue_message: str
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> IssueUpdated:
|
||||
return cls(
|
||||
issue_message=str(json['issueMessage'])
|
||||
)
|
||||
@@ -0,0 +1,107 @@
|
||||
# DO NOT EDIT THIS FILE!
|
||||
#
|
||||
# This file is generated from the CDP specification. If you need to make
|
||||
# changes, edit the generator and regenerate all of the modules.
|
||||
#
|
||||
# CDP domain: Console
|
||||
|
||||
from __future__ import annotations
|
||||
import enum
|
||||
import typing
|
||||
from dataclasses import dataclass
|
||||
from .util import event_class, T_JSON_DICT
|
||||
|
||||
|
||||
@dataclass
|
||||
class ConsoleMessage:
|
||||
'''
|
||||
Console message.
|
||||
'''
|
||||
#: Message source.
|
||||
source: str
|
||||
|
||||
#: Message severity.
|
||||
level: str
|
||||
|
||||
#: Message text.
|
||||
text: str
|
||||
|
||||
#: URL of the message origin.
|
||||
url: typing.Optional[str] = None
|
||||
|
||||
#: Line number in the resource that generated this message (1-based).
|
||||
line: typing.Optional[int] = None
|
||||
|
||||
#: Column number in the resource that generated this message (1-based).
|
||||
column: typing.Optional[int] = None
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['source'] = self.source
|
||||
json['level'] = self.level
|
||||
json['text'] = self.text
|
||||
if self.url is not None:
|
||||
json['url'] = self.url
|
||||
if self.line is not None:
|
||||
json['line'] = self.line
|
||||
if self.column is not None:
|
||||
json['column'] = self.column
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> ConsoleMessage:
|
||||
return cls(
|
||||
source=str(json['source']),
|
||||
level=str(json['level']),
|
||||
text=str(json['text']),
|
||||
url=str(json['url']) if json.get('url', None) is not None else None,
|
||||
line=int(json['line']) if json.get('line', None) is not None else None,
|
||||
column=int(json['column']) if json.get('column', None) is not None else None,
|
||||
)
|
||||
|
||||
|
||||
def clear_messages() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Does nothing.
|
||||
'''
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Console.clearMessages',
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def disable() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Disables console domain, prevents further console messages from being reported to the client.
|
||||
'''
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Console.disable',
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def enable() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Enables console domain, sends the messages collected so far to the client by means of the
|
||||
``messageAdded`` notification.
|
||||
'''
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Console.enable',
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
@event_class('Console.messageAdded')
|
||||
@dataclass
|
||||
class MessageAdded:
|
||||
'''
|
||||
Issued when new console message is added.
|
||||
'''
|
||||
#: Console message that has been added.
|
||||
message: ConsoleMessage
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> MessageAdded:
|
||||
return cls(
|
||||
message=ConsoleMessage.from_json(json['message'])
|
||||
)
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,179 @@
|
||||
# DO NOT EDIT THIS FILE!
|
||||
#
|
||||
# This file is generated from the CDP specification. If you need to make
|
||||
# changes, edit the generator and regenerate all of the modules.
|
||||
#
|
||||
# CDP domain: Database (experimental)
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import typing
|
||||
from dataclasses import dataclass
|
||||
|
||||
from .util import T_JSON_DICT, event_class
|
||||
|
||||
|
||||
class DatabaseId(str):
|
||||
"""
|
||||
Unique identifier of Database object.
|
||||
"""
|
||||
|
||||
def to_json(self) -> str:
|
||||
return self
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: str) -> DatabaseId:
|
||||
return cls(json)
|
||||
|
||||
def __repr__(self):
|
||||
return "DatabaseId({})".format(super().__repr__())
|
||||
|
||||
|
||||
@dataclass
|
||||
class Database:
|
||||
"""
|
||||
Database object.
|
||||
"""
|
||||
|
||||
#: Database ID.
|
||||
id_: DatabaseId
|
||||
|
||||
#: Database domain.
|
||||
domain: str
|
||||
|
||||
#: Database name.
|
||||
name: str
|
||||
|
||||
#: Database version.
|
||||
version: str
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json["id"] = self.id_.to_json()
|
||||
json["domain"] = self.domain
|
||||
json["name"] = self.name
|
||||
json["version"] = self.version
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> Database:
|
||||
return cls(
|
||||
id_=DatabaseId.from_json(json["id"]),
|
||||
domain=str(json["domain"]),
|
||||
name=str(json["name"]),
|
||||
version=str(json["version"]),
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class Error:
|
||||
"""
|
||||
Database error.
|
||||
"""
|
||||
|
||||
#: Error message.
|
||||
message: str
|
||||
|
||||
#: Error code.
|
||||
code: int
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json["message"] = self.message
|
||||
json["code"] = self.code
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> Error:
|
||||
return cls(
|
||||
message=str(json["message"]),
|
||||
code=int(json["code"]),
|
||||
)
|
||||
|
||||
|
||||
def disable() -> typing.Generator[T_JSON_DICT, T_JSON_DICT, None]:
|
||||
"""
|
||||
Disables database tracking, prevents database events from being sent to the client.
|
||||
"""
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
"method": "Database.disable",
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def enable() -> typing.Generator[T_JSON_DICT, T_JSON_DICT, None]:
|
||||
"""
|
||||
Enables database tracking, database events will now be delivered to the client.
|
||||
"""
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
"method": "Database.enable",
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def execute_sql(database_id: DatabaseId, query: str) -> typing.Generator[
|
||||
T_JSON_DICT,
|
||||
T_JSON_DICT,
|
||||
typing.Tuple[
|
||||
typing.Optional[typing.List[str]],
|
||||
typing.Optional[typing.List[typing.Any]],
|
||||
typing.Optional[Error],
|
||||
],
|
||||
]:
|
||||
"""
|
||||
:param database_id:
|
||||
:param query:
|
||||
:returns: A tuple with the following items:
|
||||
|
||||
0. **columnNames** -
|
||||
1. **values** -
|
||||
2. **sqlError** -
|
||||
"""
|
||||
params: T_JSON_DICT = dict()
|
||||
params["databaseId"] = database_id.to_json()
|
||||
params["query"] = query
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
"method": "Database.executeSQL",
|
||||
"params": params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
return (
|
||||
(
|
||||
[str(i) for i in json["columnNames"]]
|
||||
if json.get("columnNames", None) is not None
|
||||
else None
|
||||
),
|
||||
[i for i in json["values"]] if json.get("values", None) is not None else None,
|
||||
(
|
||||
Error.from_json(json["sqlError"])
|
||||
if json.get("sqlError", None) is not None
|
||||
else None
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
def get_database_table_names(
|
||||
database_id: DatabaseId,
|
||||
) -> typing.Generator[T_JSON_DICT, T_JSON_DICT, typing.List[str]]:
|
||||
"""
|
||||
:param database_id:
|
||||
:returns:
|
||||
"""
|
||||
params: T_JSON_DICT = dict()
|
||||
params["databaseId"] = database_id.to_json()
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
"method": "Database.getDatabaseTableNames",
|
||||
"params": params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
return [str(i) for i in json["tableNames"]]
|
||||
|
||||
|
||||
@event_class("Database.addDatabase")
|
||||
@dataclass
|
||||
class AddDatabase:
|
||||
database: Database
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> AddDatabase:
|
||||
return cls(database=Database.from_json(json["database"]))
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,141 @@
|
||||
# DO NOT EDIT THIS FILE!
|
||||
#
|
||||
# This file is generated from the CDP specification. If you need to make
|
||||
# changes, edit the generator and regenerate all of the modules.
|
||||
#
|
||||
# CDP domain: DeviceAccess (experimental)
|
||||
|
||||
from __future__ import annotations
|
||||
import enum
|
||||
import typing
|
||||
from dataclasses import dataclass
|
||||
from .util import event_class, T_JSON_DICT
|
||||
|
||||
|
||||
class RequestId(str):
|
||||
'''
|
||||
Device request id.
|
||||
'''
|
||||
def to_json(self) -> str:
|
||||
return self
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: str) -> RequestId:
|
||||
return cls(json)
|
||||
|
||||
def __repr__(self):
|
||||
return 'RequestId({})'.format(super().__repr__())
|
||||
|
||||
|
||||
class DeviceId(str):
|
||||
'''
|
||||
A device id.
|
||||
'''
|
||||
def to_json(self) -> str:
|
||||
return self
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: str) -> DeviceId:
|
||||
return cls(json)
|
||||
|
||||
def __repr__(self):
|
||||
return 'DeviceId({})'.format(super().__repr__())
|
||||
|
||||
|
||||
@dataclass
|
||||
class PromptDevice:
|
||||
'''
|
||||
Device information displayed in a user prompt to select a device.
|
||||
'''
|
||||
id_: DeviceId
|
||||
|
||||
#: Display name as it appears in a device request user prompt.
|
||||
name: str
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['id'] = self.id_.to_json()
|
||||
json['name'] = self.name
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> PromptDevice:
|
||||
return cls(
|
||||
id_=DeviceId.from_json(json['id']),
|
||||
name=str(json['name']),
|
||||
)
|
||||
|
||||
|
||||
def enable() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Enable events in this domain.
|
||||
'''
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'DeviceAccess.enable',
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def disable() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Disable events in this domain.
|
||||
'''
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'DeviceAccess.disable',
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def select_prompt(
|
||||
id_: RequestId,
|
||||
device_id: DeviceId
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Select a device in response to a DeviceAccess.deviceRequestPrompted event.
|
||||
|
||||
:param id_:
|
||||
:param device_id:
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['id'] = id_.to_json()
|
||||
params['deviceId'] = device_id.to_json()
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'DeviceAccess.selectPrompt',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def cancel_prompt(
|
||||
id_: RequestId
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Cancel a prompt in response to a DeviceAccess.deviceRequestPrompted event.
|
||||
|
||||
:param id_:
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['id'] = id_.to_json()
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'DeviceAccess.cancelPrompt',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
@event_class('DeviceAccess.deviceRequestPrompted')
|
||||
@dataclass
|
||||
class DeviceRequestPrompted:
|
||||
'''
|
||||
A device request opened a user prompt to select a device. Respond with the
|
||||
selectPrompt or cancelPrompt command.
|
||||
'''
|
||||
id_: RequestId
|
||||
devices: typing.List[PromptDevice]
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> DeviceRequestPrompted:
|
||||
return cls(
|
||||
id_=RequestId.from_json(json['id']),
|
||||
devices=[PromptDevice.from_json(i) for i in json['devices']]
|
||||
)
|
||||
@@ -0,0 +1,45 @@
|
||||
# DO NOT EDIT THIS FILE!
|
||||
#
|
||||
# This file is generated from the CDP specification. If you need to make
|
||||
# changes, edit the generator and regenerate all of the modules.
|
||||
#
|
||||
# CDP domain: DeviceOrientation (experimental)
|
||||
|
||||
from __future__ import annotations
|
||||
import enum
|
||||
import typing
|
||||
from dataclasses import dataclass
|
||||
from .util import event_class, T_JSON_DICT
|
||||
|
||||
|
||||
def clear_device_orientation_override() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Clears the overridden Device Orientation.
|
||||
'''
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'DeviceOrientation.clearDeviceOrientationOverride',
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def set_device_orientation_override(
|
||||
alpha: float,
|
||||
beta: float,
|
||||
gamma: float
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Overrides the Device Orientation.
|
||||
|
||||
:param alpha: Mock alpha
|
||||
:param beta: Mock beta
|
||||
:param gamma: Mock gamma
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['alpha'] = alpha
|
||||
params['beta'] = beta
|
||||
params['gamma'] = gamma
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'DeviceOrientation.setDeviceOrientationOverride',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,321 @@
|
||||
# DO NOT EDIT THIS FILE!
|
||||
#
|
||||
# This file is generated from the CDP specification. If you need to make
|
||||
# changes, edit the generator and regenerate all of the modules.
|
||||
#
|
||||
# CDP domain: DOMDebugger
|
||||
|
||||
from __future__ import annotations
|
||||
import enum
|
||||
import typing
|
||||
from dataclasses import dataclass
|
||||
from .util import event_class, T_JSON_DICT
|
||||
|
||||
from . import dom
|
||||
from . import runtime
|
||||
from deprecated.sphinx import deprecated # type: ignore
|
||||
|
||||
|
||||
class DOMBreakpointType(enum.Enum):
|
||||
'''
|
||||
DOM breakpoint type.
|
||||
'''
|
||||
SUBTREE_MODIFIED = "subtree-modified"
|
||||
ATTRIBUTE_MODIFIED = "attribute-modified"
|
||||
NODE_REMOVED = "node-removed"
|
||||
|
||||
def to_json(self) -> str:
|
||||
return self.value
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: str) -> DOMBreakpointType:
|
||||
return cls(json)
|
||||
|
||||
|
||||
class CSPViolationType(enum.Enum):
|
||||
'''
|
||||
CSP Violation type.
|
||||
'''
|
||||
TRUSTEDTYPE_SINK_VIOLATION = "trustedtype-sink-violation"
|
||||
TRUSTEDTYPE_POLICY_VIOLATION = "trustedtype-policy-violation"
|
||||
|
||||
def to_json(self) -> str:
|
||||
return self.value
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: str) -> CSPViolationType:
|
||||
return cls(json)
|
||||
|
||||
|
||||
@dataclass
|
||||
class EventListener:
|
||||
'''
|
||||
Object event listener.
|
||||
'''
|
||||
#: ``EventListener``'s type.
|
||||
type_: str
|
||||
|
||||
#: ``EventListener``'s useCapture.
|
||||
use_capture: bool
|
||||
|
||||
#: ``EventListener``'s passive flag.
|
||||
passive: bool
|
||||
|
||||
#: ``EventListener``'s once flag.
|
||||
once: bool
|
||||
|
||||
#: Script id of the handler code.
|
||||
script_id: runtime.ScriptId
|
||||
|
||||
#: Line number in the script (0-based).
|
||||
line_number: int
|
||||
|
||||
#: Column number in the script (0-based).
|
||||
column_number: int
|
||||
|
||||
#: Event handler function value.
|
||||
handler: typing.Optional[runtime.RemoteObject] = None
|
||||
|
||||
#: Event original handler function value.
|
||||
original_handler: typing.Optional[runtime.RemoteObject] = None
|
||||
|
||||
#: Node the listener is added to (if any).
|
||||
backend_node_id: typing.Optional[dom.BackendNodeId] = None
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['type'] = self.type_
|
||||
json['useCapture'] = self.use_capture
|
||||
json['passive'] = self.passive
|
||||
json['once'] = self.once
|
||||
json['scriptId'] = self.script_id.to_json()
|
||||
json['lineNumber'] = self.line_number
|
||||
json['columnNumber'] = self.column_number
|
||||
if self.handler is not None:
|
||||
json['handler'] = self.handler.to_json()
|
||||
if self.original_handler is not None:
|
||||
json['originalHandler'] = self.original_handler.to_json()
|
||||
if self.backend_node_id is not None:
|
||||
json['backendNodeId'] = self.backend_node_id.to_json()
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> EventListener:
|
||||
return cls(
|
||||
type_=str(json['type']),
|
||||
use_capture=bool(json['useCapture']),
|
||||
passive=bool(json['passive']),
|
||||
once=bool(json['once']),
|
||||
script_id=runtime.ScriptId.from_json(json['scriptId']),
|
||||
line_number=int(json['lineNumber']),
|
||||
column_number=int(json['columnNumber']),
|
||||
handler=runtime.RemoteObject.from_json(json['handler']) if json.get('handler', None) is not None else None,
|
||||
original_handler=runtime.RemoteObject.from_json(json['originalHandler']) if json.get('originalHandler', None) is not None else None,
|
||||
backend_node_id=dom.BackendNodeId.from_json(json['backendNodeId']) if json.get('backendNodeId', None) is not None else None,
|
||||
)
|
||||
|
||||
|
||||
def get_event_listeners(
|
||||
object_id: runtime.RemoteObjectId,
|
||||
depth: typing.Optional[int] = None,
|
||||
pierce: typing.Optional[bool] = None
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.List[EventListener]]:
|
||||
'''
|
||||
Returns event listeners of the given object.
|
||||
|
||||
:param object_id: Identifier of the object to return listeners for.
|
||||
:param depth: *(Optional)* The maximum depth at which Node children should be retrieved, defaults to 1. Use -1 for the entire subtree or provide an integer larger than 0.
|
||||
:param pierce: *(Optional)* Whether or not iframes and shadow roots should be traversed when returning the subtree (default is false). Reports listeners for all contexts if pierce is enabled.
|
||||
:returns: Array of relevant listeners.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['objectId'] = object_id.to_json()
|
||||
if depth is not None:
|
||||
params['depth'] = depth
|
||||
if pierce is not None:
|
||||
params['pierce'] = pierce
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'DOMDebugger.getEventListeners',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
return [EventListener.from_json(i) for i in json['listeners']]
|
||||
|
||||
|
||||
def remove_dom_breakpoint(
|
||||
node_id: dom.NodeId,
|
||||
type_: DOMBreakpointType
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Removes DOM breakpoint that was set using ``setDOMBreakpoint``.
|
||||
|
||||
:param node_id: Identifier of the node to remove breakpoint from.
|
||||
:param type_: Type of the breakpoint to remove.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['nodeId'] = node_id.to_json()
|
||||
params['type'] = type_.to_json()
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'DOMDebugger.removeDOMBreakpoint',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def remove_event_listener_breakpoint(
|
||||
event_name: str,
|
||||
target_name: typing.Optional[str] = None
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Removes breakpoint on particular DOM event.
|
||||
|
||||
:param event_name: Event name.
|
||||
:param target_name: **(EXPERIMENTAL)** *(Optional)* EventTarget interface name.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['eventName'] = event_name
|
||||
if target_name is not None:
|
||||
params['targetName'] = target_name
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'DOMDebugger.removeEventListenerBreakpoint',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
@deprecated(version="1.3")
|
||||
def remove_instrumentation_breakpoint(
|
||||
event_name: str
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Removes breakpoint on particular native event.
|
||||
|
||||
.. deprecated:: 1.3
|
||||
|
||||
**EXPERIMENTAL**
|
||||
|
||||
:param event_name: Instrumentation name to stop on.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['eventName'] = event_name
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'DOMDebugger.removeInstrumentationBreakpoint',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def remove_xhr_breakpoint(
|
||||
url: str
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Removes breakpoint from XMLHttpRequest.
|
||||
|
||||
:param url: Resource URL substring.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['url'] = url
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'DOMDebugger.removeXHRBreakpoint',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def set_break_on_csp_violation(
|
||||
violation_types: typing.List[CSPViolationType]
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Sets breakpoint on particular CSP violations.
|
||||
|
||||
**EXPERIMENTAL**
|
||||
|
||||
:param violation_types: CSP Violations to stop upon.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['violationTypes'] = [i.to_json() for i in violation_types]
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'DOMDebugger.setBreakOnCSPViolation',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def set_dom_breakpoint(
|
||||
node_id: dom.NodeId,
|
||||
type_: DOMBreakpointType
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Sets breakpoint on particular operation with DOM.
|
||||
|
||||
:param node_id: Identifier of the node to set breakpoint on.
|
||||
:param type_: Type of the operation to stop upon.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['nodeId'] = node_id.to_json()
|
||||
params['type'] = type_.to_json()
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'DOMDebugger.setDOMBreakpoint',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def set_event_listener_breakpoint(
|
||||
event_name: str,
|
||||
target_name: typing.Optional[str] = None
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Sets breakpoint on particular DOM event.
|
||||
|
||||
:param event_name: DOM Event name to stop on (any DOM event will do).
|
||||
:param target_name: **(EXPERIMENTAL)** *(Optional)* EventTarget interface name to stop on. If equal to ```"*"``` or not provided, will stop on any EventTarget.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['eventName'] = event_name
|
||||
if target_name is not None:
|
||||
params['targetName'] = target_name
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'DOMDebugger.setEventListenerBreakpoint',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
@deprecated(version="1.3")
|
||||
def set_instrumentation_breakpoint(
|
||||
event_name: str
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Sets breakpoint on particular native event.
|
||||
|
||||
.. deprecated:: 1.3
|
||||
|
||||
**EXPERIMENTAL**
|
||||
|
||||
:param event_name: Instrumentation name to stop on.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['eventName'] = event_name
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'DOMDebugger.setInstrumentationBreakpoint',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def set_xhr_breakpoint(
|
||||
url: str
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Sets breakpoint on XMLHttpRequest.
|
||||
|
||||
:param url: Resource URL substring. All XHRs having this substring in the URL will get stopped upon.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['url'] = url
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'DOMDebugger.setXHRBreakpoint',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
@@ -0,0 +1,876 @@
|
||||
# DO NOT EDIT THIS FILE!
|
||||
#
|
||||
# This file is generated from the CDP specification. If you need to make
|
||||
# changes, edit the generator and regenerate all of the modules.
|
||||
#
|
||||
# CDP domain: DOMSnapshot (experimental)
|
||||
|
||||
from __future__ import annotations
|
||||
import enum
|
||||
import typing
|
||||
from dataclasses import dataclass
|
||||
from .util import event_class, T_JSON_DICT
|
||||
|
||||
from . import dom
|
||||
from . import dom_debugger
|
||||
from . import page
|
||||
from deprecated.sphinx import deprecated # type: ignore
|
||||
|
||||
|
||||
@dataclass
|
||||
class DOMNode:
|
||||
'''
|
||||
A Node in the DOM tree.
|
||||
'''
|
||||
#: ``Node``'s nodeType.
|
||||
node_type: int
|
||||
|
||||
#: ``Node``'s nodeName.
|
||||
node_name: str
|
||||
|
||||
#: ``Node``'s nodeValue.
|
||||
node_value: str
|
||||
|
||||
#: ``Node``'s id, corresponds to DOM.Node.backendNodeId.
|
||||
backend_node_id: dom.BackendNodeId
|
||||
|
||||
#: Only set for textarea elements, contains the text value.
|
||||
text_value: typing.Optional[str] = None
|
||||
|
||||
#: Only set for input elements, contains the input's associated text value.
|
||||
input_value: typing.Optional[str] = None
|
||||
|
||||
#: Only set for radio and checkbox input elements, indicates if the element has been checked
|
||||
input_checked: typing.Optional[bool] = None
|
||||
|
||||
#: Only set for option elements, indicates if the element has been selected
|
||||
option_selected: typing.Optional[bool] = None
|
||||
|
||||
#: The indexes of the node's child nodes in the ``domNodes`` array returned by ``getSnapshot``, if
|
||||
#: any.
|
||||
child_node_indexes: typing.Optional[typing.List[int]] = None
|
||||
|
||||
#: Attributes of an ``Element`` node.
|
||||
attributes: typing.Optional[typing.List[NameValue]] = None
|
||||
|
||||
#: Indexes of pseudo elements associated with this node in the ``domNodes`` array returned by
|
||||
#: ``getSnapshot``, if any.
|
||||
pseudo_element_indexes: typing.Optional[typing.List[int]] = None
|
||||
|
||||
#: The index of the node's related layout tree node in the ``layoutTreeNodes`` array returned by
|
||||
#: ``getSnapshot``, if any.
|
||||
layout_node_index: typing.Optional[int] = None
|
||||
|
||||
#: Document URL that ``Document`` or ``FrameOwner`` node points to.
|
||||
document_url: typing.Optional[str] = None
|
||||
|
||||
#: Base URL that ``Document`` or ``FrameOwner`` node uses for URL completion.
|
||||
base_url: typing.Optional[str] = None
|
||||
|
||||
#: Only set for documents, contains the document's content language.
|
||||
content_language: typing.Optional[str] = None
|
||||
|
||||
#: Only set for documents, contains the document's character set encoding.
|
||||
document_encoding: typing.Optional[str] = None
|
||||
|
||||
#: ``DocumentType`` node's publicId.
|
||||
public_id: typing.Optional[str] = None
|
||||
|
||||
#: ``DocumentType`` node's systemId.
|
||||
system_id: typing.Optional[str] = None
|
||||
|
||||
#: Frame ID for frame owner elements and also for the document node.
|
||||
frame_id: typing.Optional[page.FrameId] = None
|
||||
|
||||
#: The index of a frame owner element's content document in the ``domNodes`` array returned by
|
||||
#: ``getSnapshot``, if any.
|
||||
content_document_index: typing.Optional[int] = None
|
||||
|
||||
#: Type of a pseudo element node.
|
||||
pseudo_type: typing.Optional[dom.PseudoType] = None
|
||||
|
||||
#: Shadow root type.
|
||||
shadow_root_type: typing.Optional[dom.ShadowRootType] = None
|
||||
|
||||
#: Whether this DOM node responds to mouse clicks. This includes nodes that have had click
|
||||
#: event listeners attached via JavaScript as well as anchor tags that naturally navigate when
|
||||
#: clicked.
|
||||
is_clickable: typing.Optional[bool] = None
|
||||
|
||||
#: Details of the node's event listeners, if any.
|
||||
event_listeners: typing.Optional[typing.List[dom_debugger.EventListener]] = None
|
||||
|
||||
#: The selected url for nodes with a srcset attribute.
|
||||
current_source_url: typing.Optional[str] = None
|
||||
|
||||
#: The url of the script (if any) that generates this node.
|
||||
origin_url: typing.Optional[str] = None
|
||||
|
||||
#: Scroll offsets, set when this node is a Document.
|
||||
scroll_offset_x: typing.Optional[float] = None
|
||||
|
||||
scroll_offset_y: typing.Optional[float] = None
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['nodeType'] = self.node_type
|
||||
json['nodeName'] = self.node_name
|
||||
json['nodeValue'] = self.node_value
|
||||
json['backendNodeId'] = self.backend_node_id.to_json()
|
||||
if self.text_value is not None:
|
||||
json['textValue'] = self.text_value
|
||||
if self.input_value is not None:
|
||||
json['inputValue'] = self.input_value
|
||||
if self.input_checked is not None:
|
||||
json['inputChecked'] = self.input_checked
|
||||
if self.option_selected is not None:
|
||||
json['optionSelected'] = self.option_selected
|
||||
if self.child_node_indexes is not None:
|
||||
json['childNodeIndexes'] = [i for i in self.child_node_indexes]
|
||||
if self.attributes is not None:
|
||||
json['attributes'] = [i.to_json() for i in self.attributes]
|
||||
if self.pseudo_element_indexes is not None:
|
||||
json['pseudoElementIndexes'] = [i for i in self.pseudo_element_indexes]
|
||||
if self.layout_node_index is not None:
|
||||
json['layoutNodeIndex'] = self.layout_node_index
|
||||
if self.document_url is not None:
|
||||
json['documentURL'] = self.document_url
|
||||
if self.base_url is not None:
|
||||
json['baseURL'] = self.base_url
|
||||
if self.content_language is not None:
|
||||
json['contentLanguage'] = self.content_language
|
||||
if self.document_encoding is not None:
|
||||
json['documentEncoding'] = self.document_encoding
|
||||
if self.public_id is not None:
|
||||
json['publicId'] = self.public_id
|
||||
if self.system_id is not None:
|
||||
json['systemId'] = self.system_id
|
||||
if self.frame_id is not None:
|
||||
json['frameId'] = self.frame_id.to_json()
|
||||
if self.content_document_index is not None:
|
||||
json['contentDocumentIndex'] = self.content_document_index
|
||||
if self.pseudo_type is not None:
|
||||
json['pseudoType'] = self.pseudo_type.to_json()
|
||||
if self.shadow_root_type is not None:
|
||||
json['shadowRootType'] = self.shadow_root_type.to_json()
|
||||
if self.is_clickable is not None:
|
||||
json['isClickable'] = self.is_clickable
|
||||
if self.event_listeners is not None:
|
||||
json['eventListeners'] = [i.to_json() for i in self.event_listeners]
|
||||
if self.current_source_url is not None:
|
||||
json['currentSourceURL'] = self.current_source_url
|
||||
if self.origin_url is not None:
|
||||
json['originURL'] = self.origin_url
|
||||
if self.scroll_offset_x is not None:
|
||||
json['scrollOffsetX'] = self.scroll_offset_x
|
||||
if self.scroll_offset_y is not None:
|
||||
json['scrollOffsetY'] = self.scroll_offset_y
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> DOMNode:
|
||||
return cls(
|
||||
node_type=int(json['nodeType']),
|
||||
node_name=str(json['nodeName']),
|
||||
node_value=str(json['nodeValue']),
|
||||
backend_node_id=dom.BackendNodeId.from_json(json['backendNodeId']),
|
||||
text_value=str(json['textValue']) if json.get('textValue', None) is not None else None,
|
||||
input_value=str(json['inputValue']) if json.get('inputValue', None) is not None else None,
|
||||
input_checked=bool(json['inputChecked']) if json.get('inputChecked', None) is not None else None,
|
||||
option_selected=bool(json['optionSelected']) if json.get('optionSelected', None) is not None else None,
|
||||
child_node_indexes=[int(i) for i in json['childNodeIndexes']] if json.get('childNodeIndexes', None) is not None else None,
|
||||
attributes=[NameValue.from_json(i) for i in json['attributes']] if json.get('attributes', None) is not None else None,
|
||||
pseudo_element_indexes=[int(i) for i in json['pseudoElementIndexes']] if json.get('pseudoElementIndexes', None) is not None else None,
|
||||
layout_node_index=int(json['layoutNodeIndex']) if json.get('layoutNodeIndex', None) is not None else None,
|
||||
document_url=str(json['documentURL']) if json.get('documentURL', None) is not None else None,
|
||||
base_url=str(json['baseURL']) if json.get('baseURL', None) is not None else None,
|
||||
content_language=str(json['contentLanguage']) if json.get('contentLanguage', None) is not None else None,
|
||||
document_encoding=str(json['documentEncoding']) if json.get('documentEncoding', None) is not None else None,
|
||||
public_id=str(json['publicId']) if json.get('publicId', None) is not None else None,
|
||||
system_id=str(json['systemId']) if json.get('systemId', None) is not None else None,
|
||||
frame_id=page.FrameId.from_json(json['frameId']) if json.get('frameId', None) is not None else None,
|
||||
content_document_index=int(json['contentDocumentIndex']) if json.get('contentDocumentIndex', None) is not None else None,
|
||||
pseudo_type=dom.PseudoType.from_json(json['pseudoType']) if json.get('pseudoType', None) is not None else None,
|
||||
shadow_root_type=dom.ShadowRootType.from_json(json['shadowRootType']) if json.get('shadowRootType', None) is not None else None,
|
||||
is_clickable=bool(json['isClickable']) if json.get('isClickable', None) is not None else None,
|
||||
event_listeners=[dom_debugger.EventListener.from_json(i) for i in json['eventListeners']] if json.get('eventListeners', None) is not None else None,
|
||||
current_source_url=str(json['currentSourceURL']) if json.get('currentSourceURL', None) is not None else None,
|
||||
origin_url=str(json['originURL']) if json.get('originURL', None) is not None else None,
|
||||
scroll_offset_x=float(json['scrollOffsetX']) if json.get('scrollOffsetX', None) is not None else None,
|
||||
scroll_offset_y=float(json['scrollOffsetY']) if json.get('scrollOffsetY', None) is not None else None,
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class InlineTextBox:
|
||||
'''
|
||||
Details of post layout rendered text positions. The exact layout should not be regarded as
|
||||
stable and may change between versions.
|
||||
'''
|
||||
#: The bounding box in document coordinates. Note that scroll offset of the document is ignored.
|
||||
bounding_box: dom.Rect
|
||||
|
||||
#: The starting index in characters, for this post layout textbox substring. Characters that
|
||||
#: would be represented as a surrogate pair in UTF-16 have length 2.
|
||||
start_character_index: int
|
||||
|
||||
#: The number of characters in this post layout textbox substring. Characters that would be
|
||||
#: represented as a surrogate pair in UTF-16 have length 2.
|
||||
num_characters: int
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['boundingBox'] = self.bounding_box.to_json()
|
||||
json['startCharacterIndex'] = self.start_character_index
|
||||
json['numCharacters'] = self.num_characters
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> InlineTextBox:
|
||||
return cls(
|
||||
bounding_box=dom.Rect.from_json(json['boundingBox']),
|
||||
start_character_index=int(json['startCharacterIndex']),
|
||||
num_characters=int(json['numCharacters']),
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class LayoutTreeNode:
|
||||
'''
|
||||
Details of an element in the DOM tree with a LayoutObject.
|
||||
'''
|
||||
#: The index of the related DOM node in the ``domNodes`` array returned by ``getSnapshot``.
|
||||
dom_node_index: int
|
||||
|
||||
#: The bounding box in document coordinates. Note that scroll offset of the document is ignored.
|
||||
bounding_box: dom.Rect
|
||||
|
||||
#: Contents of the LayoutText, if any.
|
||||
layout_text: typing.Optional[str] = None
|
||||
|
||||
#: The post-layout inline text nodes, if any.
|
||||
inline_text_nodes: typing.Optional[typing.List[InlineTextBox]] = None
|
||||
|
||||
#: Index into the ``computedStyles`` array returned by ``getSnapshot``.
|
||||
style_index: typing.Optional[int] = None
|
||||
|
||||
#: Global paint order index, which is determined by the stacking order of the nodes. Nodes
|
||||
#: that are painted together will have the same index. Only provided if includePaintOrder in
|
||||
#: getSnapshot was true.
|
||||
paint_order: typing.Optional[int] = None
|
||||
|
||||
#: Set to true to indicate the element begins a new stacking context.
|
||||
is_stacking_context: typing.Optional[bool] = None
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['domNodeIndex'] = self.dom_node_index
|
||||
json['boundingBox'] = self.bounding_box.to_json()
|
||||
if self.layout_text is not None:
|
||||
json['layoutText'] = self.layout_text
|
||||
if self.inline_text_nodes is not None:
|
||||
json['inlineTextNodes'] = [i.to_json() for i in self.inline_text_nodes]
|
||||
if self.style_index is not None:
|
||||
json['styleIndex'] = self.style_index
|
||||
if self.paint_order is not None:
|
||||
json['paintOrder'] = self.paint_order
|
||||
if self.is_stacking_context is not None:
|
||||
json['isStackingContext'] = self.is_stacking_context
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> LayoutTreeNode:
|
||||
return cls(
|
||||
dom_node_index=int(json['domNodeIndex']),
|
||||
bounding_box=dom.Rect.from_json(json['boundingBox']),
|
||||
layout_text=str(json['layoutText']) if json.get('layoutText', None) is not None else None,
|
||||
inline_text_nodes=[InlineTextBox.from_json(i) for i in json['inlineTextNodes']] if json.get('inlineTextNodes', None) is not None else None,
|
||||
style_index=int(json['styleIndex']) if json.get('styleIndex', None) is not None else None,
|
||||
paint_order=int(json['paintOrder']) if json.get('paintOrder', None) is not None else None,
|
||||
is_stacking_context=bool(json['isStackingContext']) if json.get('isStackingContext', None) is not None else None,
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class ComputedStyle:
|
||||
'''
|
||||
A subset of the full ComputedStyle as defined by the request whitelist.
|
||||
'''
|
||||
#: Name/value pairs of computed style properties.
|
||||
properties: typing.List[NameValue]
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['properties'] = [i.to_json() for i in self.properties]
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> ComputedStyle:
|
||||
return cls(
|
||||
properties=[NameValue.from_json(i) for i in json['properties']],
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class NameValue:
|
||||
'''
|
||||
A name/value pair.
|
||||
'''
|
||||
#: Attribute/property name.
|
||||
name: str
|
||||
|
||||
#: Attribute/property value.
|
||||
value: str
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['name'] = self.name
|
||||
json['value'] = self.value
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> NameValue:
|
||||
return cls(
|
||||
name=str(json['name']),
|
||||
value=str(json['value']),
|
||||
)
|
||||
|
||||
|
||||
class StringIndex(int):
|
||||
'''
|
||||
Index of the string in the strings table.
|
||||
'''
|
||||
def to_json(self) -> int:
|
||||
return self
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: int) -> StringIndex:
|
||||
return cls(json)
|
||||
|
||||
def __repr__(self):
|
||||
return 'StringIndex({})'.format(super().__repr__())
|
||||
|
||||
|
||||
class ArrayOfStrings(list):
|
||||
'''
|
||||
Index of the string in the strings table.
|
||||
'''
|
||||
def to_json(self) -> typing.List[StringIndex]:
|
||||
return self
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: typing.List[StringIndex]) -> ArrayOfStrings:
|
||||
return cls(json)
|
||||
|
||||
def __repr__(self):
|
||||
return 'ArrayOfStrings({})'.format(super().__repr__())
|
||||
|
||||
|
||||
@dataclass
|
||||
class RareStringData:
|
||||
'''
|
||||
Data that is only present on rare nodes.
|
||||
'''
|
||||
index: typing.List[int]
|
||||
|
||||
value: typing.List[StringIndex]
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['index'] = [i for i in self.index]
|
||||
json['value'] = [i.to_json() for i in self.value]
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> RareStringData:
|
||||
return cls(
|
||||
index=[int(i) for i in json['index']],
|
||||
value=[StringIndex.from_json(i) for i in json['value']],
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class RareBooleanData:
|
||||
index: typing.List[int]
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['index'] = [i for i in self.index]
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> RareBooleanData:
|
||||
return cls(
|
||||
index=[int(i) for i in json['index']],
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class RareIntegerData:
|
||||
index: typing.List[int]
|
||||
|
||||
value: typing.List[int]
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['index'] = [i for i in self.index]
|
||||
json['value'] = [i for i in self.value]
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> RareIntegerData:
|
||||
return cls(
|
||||
index=[int(i) for i in json['index']],
|
||||
value=[int(i) for i in json['value']],
|
||||
)
|
||||
|
||||
|
||||
class Rectangle(list):
|
||||
def to_json(self) -> typing.List[float]:
|
||||
return self
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: typing.List[float]) -> Rectangle:
|
||||
return cls(json)
|
||||
|
||||
def __repr__(self):
|
||||
return 'Rectangle({})'.format(super().__repr__())
|
||||
|
||||
|
||||
@dataclass
|
||||
class DocumentSnapshot:
|
||||
'''
|
||||
Document snapshot.
|
||||
'''
|
||||
#: Document URL that ``Document`` or ``FrameOwner`` node points to.
|
||||
document_url: StringIndex
|
||||
|
||||
#: Document title.
|
||||
title: StringIndex
|
||||
|
||||
#: Base URL that ``Document`` or ``FrameOwner`` node uses for URL completion.
|
||||
base_url: StringIndex
|
||||
|
||||
#: Contains the document's content language.
|
||||
content_language: StringIndex
|
||||
|
||||
#: Contains the document's character set encoding.
|
||||
encoding_name: StringIndex
|
||||
|
||||
#: ``DocumentType`` node's publicId.
|
||||
public_id: StringIndex
|
||||
|
||||
#: ``DocumentType`` node's systemId.
|
||||
system_id: StringIndex
|
||||
|
||||
#: Frame ID for frame owner elements and also for the document node.
|
||||
frame_id: StringIndex
|
||||
|
||||
#: A table with dom nodes.
|
||||
nodes: NodeTreeSnapshot
|
||||
|
||||
#: The nodes in the layout tree.
|
||||
layout: LayoutTreeSnapshot
|
||||
|
||||
#: The post-layout inline text nodes.
|
||||
text_boxes: TextBoxSnapshot
|
||||
|
||||
#: Horizontal scroll offset.
|
||||
scroll_offset_x: typing.Optional[float] = None
|
||||
|
||||
#: Vertical scroll offset.
|
||||
scroll_offset_y: typing.Optional[float] = None
|
||||
|
||||
#: Document content width.
|
||||
content_width: typing.Optional[float] = None
|
||||
|
||||
#: Document content height.
|
||||
content_height: typing.Optional[float] = None
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['documentURL'] = self.document_url.to_json()
|
||||
json['title'] = self.title.to_json()
|
||||
json['baseURL'] = self.base_url.to_json()
|
||||
json['contentLanguage'] = self.content_language.to_json()
|
||||
json['encodingName'] = self.encoding_name.to_json()
|
||||
json['publicId'] = self.public_id.to_json()
|
||||
json['systemId'] = self.system_id.to_json()
|
||||
json['frameId'] = self.frame_id.to_json()
|
||||
json['nodes'] = self.nodes.to_json()
|
||||
json['layout'] = self.layout.to_json()
|
||||
json['textBoxes'] = self.text_boxes.to_json()
|
||||
if self.scroll_offset_x is not None:
|
||||
json['scrollOffsetX'] = self.scroll_offset_x
|
||||
if self.scroll_offset_y is not None:
|
||||
json['scrollOffsetY'] = self.scroll_offset_y
|
||||
if self.content_width is not None:
|
||||
json['contentWidth'] = self.content_width
|
||||
if self.content_height is not None:
|
||||
json['contentHeight'] = self.content_height
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> DocumentSnapshot:
|
||||
return cls(
|
||||
document_url=StringIndex.from_json(json['documentURL']),
|
||||
title=StringIndex.from_json(json['title']),
|
||||
base_url=StringIndex.from_json(json['baseURL']),
|
||||
content_language=StringIndex.from_json(json['contentLanguage']),
|
||||
encoding_name=StringIndex.from_json(json['encodingName']),
|
||||
public_id=StringIndex.from_json(json['publicId']),
|
||||
system_id=StringIndex.from_json(json['systemId']),
|
||||
frame_id=StringIndex.from_json(json['frameId']),
|
||||
nodes=NodeTreeSnapshot.from_json(json['nodes']),
|
||||
layout=LayoutTreeSnapshot.from_json(json['layout']),
|
||||
text_boxes=TextBoxSnapshot.from_json(json['textBoxes']),
|
||||
scroll_offset_x=float(json['scrollOffsetX']) if json.get('scrollOffsetX', None) is not None else None,
|
||||
scroll_offset_y=float(json['scrollOffsetY']) if json.get('scrollOffsetY', None) is not None else None,
|
||||
content_width=float(json['contentWidth']) if json.get('contentWidth', None) is not None else None,
|
||||
content_height=float(json['contentHeight']) if json.get('contentHeight', None) is not None else None,
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class NodeTreeSnapshot:
|
||||
'''
|
||||
Table containing nodes.
|
||||
'''
|
||||
#: Parent node index.
|
||||
parent_index: typing.Optional[typing.List[int]] = None
|
||||
|
||||
#: ``Node``'s nodeType.
|
||||
node_type: typing.Optional[typing.List[int]] = None
|
||||
|
||||
#: Type of the shadow root the ``Node`` is in. String values are equal to the ``ShadowRootType`` enum.
|
||||
shadow_root_type: typing.Optional[RareStringData] = None
|
||||
|
||||
#: ``Node``'s nodeName.
|
||||
node_name: typing.Optional[typing.List[StringIndex]] = None
|
||||
|
||||
#: ``Node``'s nodeValue.
|
||||
node_value: typing.Optional[typing.List[StringIndex]] = None
|
||||
|
||||
#: ``Node``'s id, corresponds to DOM.Node.backendNodeId.
|
||||
backend_node_id: typing.Optional[typing.List[dom.BackendNodeId]] = None
|
||||
|
||||
#: Attributes of an ``Element`` node. Flatten name, value pairs.
|
||||
attributes: typing.Optional[typing.List[ArrayOfStrings]] = None
|
||||
|
||||
#: Only set for textarea elements, contains the text value.
|
||||
text_value: typing.Optional[RareStringData] = None
|
||||
|
||||
#: Only set for input elements, contains the input's associated text value.
|
||||
input_value: typing.Optional[RareStringData] = None
|
||||
|
||||
#: Only set for radio and checkbox input elements, indicates if the element has been checked
|
||||
input_checked: typing.Optional[RareBooleanData] = None
|
||||
|
||||
#: Only set for option elements, indicates if the element has been selected
|
||||
option_selected: typing.Optional[RareBooleanData] = None
|
||||
|
||||
#: The index of the document in the list of the snapshot documents.
|
||||
content_document_index: typing.Optional[RareIntegerData] = None
|
||||
|
||||
#: Type of a pseudo element node.
|
||||
pseudo_type: typing.Optional[RareStringData] = None
|
||||
|
||||
#: Pseudo element identifier for this node. Only present if there is a
|
||||
#: valid pseudoType.
|
||||
pseudo_identifier: typing.Optional[RareStringData] = None
|
||||
|
||||
#: Whether this DOM node responds to mouse clicks. This includes nodes that have had click
|
||||
#: event listeners attached via JavaScript as well as anchor tags that naturally navigate when
|
||||
#: clicked.
|
||||
is_clickable: typing.Optional[RareBooleanData] = None
|
||||
|
||||
#: The selected url for nodes with a srcset attribute.
|
||||
current_source_url: typing.Optional[RareStringData] = None
|
||||
|
||||
#: The url of the script (if any) that generates this node.
|
||||
origin_url: typing.Optional[RareStringData] = None
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
if self.parent_index is not None:
|
||||
json['parentIndex'] = [i for i in self.parent_index]
|
||||
if self.node_type is not None:
|
||||
json['nodeType'] = [i for i in self.node_type]
|
||||
if self.shadow_root_type is not None:
|
||||
json['shadowRootType'] = self.shadow_root_type.to_json()
|
||||
if self.node_name is not None:
|
||||
json['nodeName'] = [i.to_json() for i in self.node_name]
|
||||
if self.node_value is not None:
|
||||
json['nodeValue'] = [i.to_json() for i in self.node_value]
|
||||
if self.backend_node_id is not None:
|
||||
json['backendNodeId'] = [i.to_json() for i in self.backend_node_id]
|
||||
if self.attributes is not None:
|
||||
json['attributes'] = [i.to_json() for i in self.attributes]
|
||||
if self.text_value is not None:
|
||||
json['textValue'] = self.text_value.to_json()
|
||||
if self.input_value is not None:
|
||||
json['inputValue'] = self.input_value.to_json()
|
||||
if self.input_checked is not None:
|
||||
json['inputChecked'] = self.input_checked.to_json()
|
||||
if self.option_selected is not None:
|
||||
json['optionSelected'] = self.option_selected.to_json()
|
||||
if self.content_document_index is not None:
|
||||
json['contentDocumentIndex'] = self.content_document_index.to_json()
|
||||
if self.pseudo_type is not None:
|
||||
json['pseudoType'] = self.pseudo_type.to_json()
|
||||
if self.pseudo_identifier is not None:
|
||||
json['pseudoIdentifier'] = self.pseudo_identifier.to_json()
|
||||
if self.is_clickable is not None:
|
||||
json['isClickable'] = self.is_clickable.to_json()
|
||||
if self.current_source_url is not None:
|
||||
json['currentSourceURL'] = self.current_source_url.to_json()
|
||||
if self.origin_url is not None:
|
||||
json['originURL'] = self.origin_url.to_json()
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> NodeTreeSnapshot:
|
||||
return cls(
|
||||
parent_index=[int(i) for i in json['parentIndex']] if json.get('parentIndex', None) is not None else None,
|
||||
node_type=[int(i) for i in json['nodeType']] if json.get('nodeType', None) is not None else None,
|
||||
shadow_root_type=RareStringData.from_json(json['shadowRootType']) if json.get('shadowRootType', None) is not None else None,
|
||||
node_name=[StringIndex.from_json(i) for i in json['nodeName']] if json.get('nodeName', None) is not None else None,
|
||||
node_value=[StringIndex.from_json(i) for i in json['nodeValue']] if json.get('nodeValue', None) is not None else None,
|
||||
backend_node_id=[dom.BackendNodeId.from_json(i) for i in json['backendNodeId']] if json.get('backendNodeId', None) is not None else None,
|
||||
attributes=[ArrayOfStrings.from_json(i) for i in json['attributes']] if json.get('attributes', None) is not None else None,
|
||||
text_value=RareStringData.from_json(json['textValue']) if json.get('textValue', None) is not None else None,
|
||||
input_value=RareStringData.from_json(json['inputValue']) if json.get('inputValue', None) is not None else None,
|
||||
input_checked=RareBooleanData.from_json(json['inputChecked']) if json.get('inputChecked', None) is not None else None,
|
||||
option_selected=RareBooleanData.from_json(json['optionSelected']) if json.get('optionSelected', None) is not None else None,
|
||||
content_document_index=RareIntegerData.from_json(json['contentDocumentIndex']) if json.get('contentDocumentIndex', None) is not None else None,
|
||||
pseudo_type=RareStringData.from_json(json['pseudoType']) if json.get('pseudoType', None) is not None else None,
|
||||
pseudo_identifier=RareStringData.from_json(json['pseudoIdentifier']) if json.get('pseudoIdentifier', None) is not None else None,
|
||||
is_clickable=RareBooleanData.from_json(json['isClickable']) if json.get('isClickable', None) is not None else None,
|
||||
current_source_url=RareStringData.from_json(json['currentSourceURL']) if json.get('currentSourceURL', None) is not None else None,
|
||||
origin_url=RareStringData.from_json(json['originURL']) if json.get('originURL', None) is not None else None,
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class LayoutTreeSnapshot:
|
||||
'''
|
||||
Table of details of an element in the DOM tree with a LayoutObject.
|
||||
'''
|
||||
#: Index of the corresponding node in the ``NodeTreeSnapshot`` array returned by ``captureSnapshot``.
|
||||
node_index: typing.List[int]
|
||||
|
||||
#: Array of indexes specifying computed style strings, filtered according to the ``computedStyles`` parameter passed to ``captureSnapshot``.
|
||||
styles: typing.List[ArrayOfStrings]
|
||||
|
||||
#: The absolute position bounding box.
|
||||
bounds: typing.List[Rectangle]
|
||||
|
||||
#: Contents of the LayoutText, if any.
|
||||
text: typing.List[StringIndex]
|
||||
|
||||
#: Stacking context information.
|
||||
stacking_contexts: RareBooleanData
|
||||
|
||||
#: Global paint order index, which is determined by the stacking order of the nodes. Nodes
|
||||
#: that are painted together will have the same index. Only provided if includePaintOrder in
|
||||
#: captureSnapshot was true.
|
||||
paint_orders: typing.Optional[typing.List[int]] = None
|
||||
|
||||
#: The offset rect of nodes. Only available when includeDOMRects is set to true
|
||||
offset_rects: typing.Optional[typing.List[Rectangle]] = None
|
||||
|
||||
#: The scroll rect of nodes. Only available when includeDOMRects is set to true
|
||||
scroll_rects: typing.Optional[typing.List[Rectangle]] = None
|
||||
|
||||
#: The client rect of nodes. Only available when includeDOMRects is set to true
|
||||
client_rects: typing.Optional[typing.List[Rectangle]] = None
|
||||
|
||||
#: The list of background colors that are blended with colors of overlapping elements.
|
||||
blended_background_colors: typing.Optional[typing.List[StringIndex]] = None
|
||||
|
||||
#: The list of computed text opacities.
|
||||
text_color_opacities: typing.Optional[typing.List[float]] = None
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['nodeIndex'] = [i for i in self.node_index]
|
||||
json['styles'] = [i.to_json() for i in self.styles]
|
||||
json['bounds'] = [i.to_json() for i in self.bounds]
|
||||
json['text'] = [i.to_json() for i in self.text]
|
||||
json['stackingContexts'] = self.stacking_contexts.to_json()
|
||||
if self.paint_orders is not None:
|
||||
json['paintOrders'] = [i for i in self.paint_orders]
|
||||
if self.offset_rects is not None:
|
||||
json['offsetRects'] = [i.to_json() for i in self.offset_rects]
|
||||
if self.scroll_rects is not None:
|
||||
json['scrollRects'] = [i.to_json() for i in self.scroll_rects]
|
||||
if self.client_rects is not None:
|
||||
json['clientRects'] = [i.to_json() for i in self.client_rects]
|
||||
if self.blended_background_colors is not None:
|
||||
json['blendedBackgroundColors'] = [i.to_json() for i in self.blended_background_colors]
|
||||
if self.text_color_opacities is not None:
|
||||
json['textColorOpacities'] = [i for i in self.text_color_opacities]
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> LayoutTreeSnapshot:
|
||||
return cls(
|
||||
node_index=[int(i) for i in json['nodeIndex']],
|
||||
styles=[ArrayOfStrings.from_json(i) for i in json['styles']],
|
||||
bounds=[Rectangle.from_json(i) for i in json['bounds']],
|
||||
text=[StringIndex.from_json(i) for i in json['text']],
|
||||
stacking_contexts=RareBooleanData.from_json(json['stackingContexts']),
|
||||
paint_orders=[int(i) for i in json['paintOrders']] if json.get('paintOrders', None) is not None else None,
|
||||
offset_rects=[Rectangle.from_json(i) for i in json['offsetRects']] if json.get('offsetRects', None) is not None else None,
|
||||
scroll_rects=[Rectangle.from_json(i) for i in json['scrollRects']] if json.get('scrollRects', None) is not None else None,
|
||||
client_rects=[Rectangle.from_json(i) for i in json['clientRects']] if json.get('clientRects', None) is not None else None,
|
||||
blended_background_colors=[StringIndex.from_json(i) for i in json['blendedBackgroundColors']] if json.get('blendedBackgroundColors', None) is not None else None,
|
||||
text_color_opacities=[float(i) for i in json['textColorOpacities']] if json.get('textColorOpacities', None) is not None else None,
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class TextBoxSnapshot:
|
||||
'''
|
||||
Table of details of the post layout rendered text positions. The exact layout should not be regarded as
|
||||
stable and may change between versions.
|
||||
'''
|
||||
#: Index of the layout tree node that owns this box collection.
|
||||
layout_index: typing.List[int]
|
||||
|
||||
#: The absolute position bounding box.
|
||||
bounds: typing.List[Rectangle]
|
||||
|
||||
#: The starting index in characters, for this post layout textbox substring. Characters that
|
||||
#: would be represented as a surrogate pair in UTF-16 have length 2.
|
||||
start: typing.List[int]
|
||||
|
||||
#: The number of characters in this post layout textbox substring. Characters that would be
|
||||
#: represented as a surrogate pair in UTF-16 have length 2.
|
||||
length: typing.List[int]
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['layoutIndex'] = [i for i in self.layout_index]
|
||||
json['bounds'] = [i.to_json() for i in self.bounds]
|
||||
json['start'] = [i for i in self.start]
|
||||
json['length'] = [i for i in self.length]
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> TextBoxSnapshot:
|
||||
return cls(
|
||||
layout_index=[int(i) for i in json['layoutIndex']],
|
||||
bounds=[Rectangle.from_json(i) for i in json['bounds']],
|
||||
start=[int(i) for i in json['start']],
|
||||
length=[int(i) for i in json['length']],
|
||||
)
|
||||
|
||||
|
||||
def disable() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Disables DOM snapshot agent for the given page.
|
||||
'''
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'DOMSnapshot.disable',
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def enable() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Enables DOM snapshot agent for the given page.
|
||||
'''
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'DOMSnapshot.enable',
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
@deprecated(version="1.3")
|
||||
def get_snapshot(
|
||||
computed_style_whitelist: typing.List[str],
|
||||
include_event_listeners: typing.Optional[bool] = None,
|
||||
include_paint_order: typing.Optional[bool] = None,
|
||||
include_user_agent_shadow_tree: typing.Optional[bool] = None
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.Tuple[typing.List[DOMNode], typing.List[LayoutTreeNode], typing.List[ComputedStyle]]]:
|
||||
'''
|
||||
Returns a document snapshot, including the full DOM tree of the root node (including iframes,
|
||||
template contents, and imported documents) in a flattened array, as well as layout and
|
||||
white-listed computed style information for the nodes. Shadow DOM in the returned DOM tree is
|
||||
flattened.
|
||||
|
||||
.. deprecated:: 1.3
|
||||
|
||||
:param computed_style_whitelist: Whitelist of computed styles to return.
|
||||
:param include_event_listeners: *(Optional)* Whether or not to retrieve details of DOM listeners (default false).
|
||||
:param include_paint_order: *(Optional)* Whether to determine and include the paint order index of LayoutTreeNodes (default false).
|
||||
:param include_user_agent_shadow_tree: *(Optional)* Whether to include UA shadow tree in the snapshot (default false).
|
||||
:returns: A tuple with the following items:
|
||||
|
||||
0. **domNodes** - The nodes in the DOM tree. The DOMNode at index 0 corresponds to the root document.
|
||||
1. **layoutTreeNodes** - The nodes in the layout tree.
|
||||
2. **computedStyles** - Whitelisted ComputedStyle properties for each node in the layout tree.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['computedStyleWhitelist'] = [i for i in computed_style_whitelist]
|
||||
if include_event_listeners is not None:
|
||||
params['includeEventListeners'] = include_event_listeners
|
||||
if include_paint_order is not None:
|
||||
params['includePaintOrder'] = include_paint_order
|
||||
if include_user_agent_shadow_tree is not None:
|
||||
params['includeUserAgentShadowTree'] = include_user_agent_shadow_tree
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'DOMSnapshot.getSnapshot',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
return (
|
||||
[DOMNode.from_json(i) for i in json['domNodes']],
|
||||
[LayoutTreeNode.from_json(i) for i in json['layoutTreeNodes']],
|
||||
[ComputedStyle.from_json(i) for i in json['computedStyles']]
|
||||
)
|
||||
|
||||
|
||||
def capture_snapshot(
|
||||
computed_styles: typing.List[str],
|
||||
include_paint_order: typing.Optional[bool] = None,
|
||||
include_dom_rects: typing.Optional[bool] = None,
|
||||
include_blended_background_colors: typing.Optional[bool] = None,
|
||||
include_text_color_opacities: typing.Optional[bool] = None
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.Tuple[typing.List[DocumentSnapshot], typing.List[str]]]:
|
||||
'''
|
||||
Returns a document snapshot, including the full DOM tree of the root node (including iframes,
|
||||
template contents, and imported documents) in a flattened array, as well as layout and
|
||||
white-listed computed style information for the nodes. Shadow DOM in the returned DOM tree is
|
||||
flattened.
|
||||
|
||||
:param computed_styles: Whitelist of computed styles to return.
|
||||
:param include_paint_order: *(Optional)* Whether to include layout object paint orders into the snapshot.
|
||||
:param include_dom_rects: *(Optional)* Whether to include DOM rectangles (offsetRects, clientRects, scrollRects) into the snapshot
|
||||
:param include_blended_background_colors: **(EXPERIMENTAL)** *(Optional)* Whether to include blended background colors in the snapshot (default: false). Blended background color is achieved by blending background colors of all elements that overlap with the current element.
|
||||
:param include_text_color_opacities: **(EXPERIMENTAL)** *(Optional)* Whether to include text color opacity in the snapshot (default: false). An element might have the opacity property set that affects the text color of the element. The final text color opacity is computed based on the opacity of all overlapping elements.
|
||||
:returns: A tuple with the following items:
|
||||
|
||||
0. **documents** - The nodes in the DOM tree. The DOMNode at index 0 corresponds to the root document.
|
||||
1. **strings** - Shared string table that all string properties refer to with indexes.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['computedStyles'] = [i for i in computed_styles]
|
||||
if include_paint_order is not None:
|
||||
params['includePaintOrder'] = include_paint_order
|
||||
if include_dom_rects is not None:
|
||||
params['includeDOMRects'] = include_dom_rects
|
||||
if include_blended_background_colors is not None:
|
||||
params['includeBlendedBackgroundColors'] = include_blended_background_colors
|
||||
if include_text_color_opacities is not None:
|
||||
params['includeTextColorOpacities'] = include_text_color_opacities
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'DOMSnapshot.captureSnapshot',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
return (
|
||||
[DocumentSnapshot.from_json(i) for i in json['documents']],
|
||||
[str(i) for i in json['strings']]
|
||||
)
|
||||
@@ -0,0 +1,222 @@
|
||||
# DO NOT EDIT THIS FILE!
|
||||
#
|
||||
# This file is generated from the CDP specification. If you need to make
|
||||
# changes, edit the generator and regenerate all of the modules.
|
||||
#
|
||||
# CDP domain: DOMStorage (experimental)
|
||||
|
||||
from __future__ import annotations
|
||||
import enum
|
||||
import typing
|
||||
from dataclasses import dataclass
|
||||
from .util import event_class, T_JSON_DICT
|
||||
|
||||
|
||||
class SerializedStorageKey(str):
|
||||
def to_json(self) -> str:
|
||||
return self
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: str) -> SerializedStorageKey:
|
||||
return cls(json)
|
||||
|
||||
def __repr__(self):
|
||||
return 'SerializedStorageKey({})'.format(super().__repr__())
|
||||
|
||||
|
||||
@dataclass
|
||||
class StorageId:
|
||||
'''
|
||||
DOM Storage identifier.
|
||||
'''
|
||||
#: Whether the storage is local storage (not session storage).
|
||||
is_local_storage: bool
|
||||
|
||||
#: Security origin for the storage.
|
||||
security_origin: typing.Optional[str] = None
|
||||
|
||||
#: Represents a key by which DOM Storage keys its CachedStorageAreas
|
||||
storage_key: typing.Optional[SerializedStorageKey] = None
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['isLocalStorage'] = self.is_local_storage
|
||||
if self.security_origin is not None:
|
||||
json['securityOrigin'] = self.security_origin
|
||||
if self.storage_key is not None:
|
||||
json['storageKey'] = self.storage_key.to_json()
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> StorageId:
|
||||
return cls(
|
||||
is_local_storage=bool(json['isLocalStorage']),
|
||||
security_origin=str(json['securityOrigin']) if json.get('securityOrigin', None) is not None else None,
|
||||
storage_key=SerializedStorageKey.from_json(json['storageKey']) if json.get('storageKey', None) is not None else None,
|
||||
)
|
||||
|
||||
|
||||
class Item(list):
|
||||
'''
|
||||
DOM Storage item.
|
||||
'''
|
||||
def to_json(self) -> typing.List[str]:
|
||||
return self
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: typing.List[str]) -> Item:
|
||||
return cls(json)
|
||||
|
||||
def __repr__(self):
|
||||
return 'Item({})'.format(super().__repr__())
|
||||
|
||||
|
||||
def clear(
|
||||
storage_id: StorageId
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
:param storage_id:
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['storageId'] = storage_id.to_json()
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'DOMStorage.clear',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def disable() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Disables storage tracking, prevents storage events from being sent to the client.
|
||||
'''
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'DOMStorage.disable',
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def enable() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Enables storage tracking, storage events will now be delivered to the client.
|
||||
'''
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'DOMStorage.enable',
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def get_dom_storage_items(
|
||||
storage_id: StorageId
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.List[Item]]:
|
||||
'''
|
||||
:param storage_id:
|
||||
:returns:
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['storageId'] = storage_id.to_json()
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'DOMStorage.getDOMStorageItems',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
return [Item.from_json(i) for i in json['entries']]
|
||||
|
||||
|
||||
def remove_dom_storage_item(
|
||||
storage_id: StorageId,
|
||||
key: str
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
:param storage_id:
|
||||
:param key:
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['storageId'] = storage_id.to_json()
|
||||
params['key'] = key
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'DOMStorage.removeDOMStorageItem',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def set_dom_storage_item(
|
||||
storage_id: StorageId,
|
||||
key: str,
|
||||
value: str
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
:param storage_id:
|
||||
:param key:
|
||||
:param value:
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['storageId'] = storage_id.to_json()
|
||||
params['key'] = key
|
||||
params['value'] = value
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'DOMStorage.setDOMStorageItem',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
@event_class('DOMStorage.domStorageItemAdded')
|
||||
@dataclass
|
||||
class DomStorageItemAdded:
|
||||
storage_id: StorageId
|
||||
key: str
|
||||
new_value: str
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> DomStorageItemAdded:
|
||||
return cls(
|
||||
storage_id=StorageId.from_json(json['storageId']),
|
||||
key=str(json['key']),
|
||||
new_value=str(json['newValue'])
|
||||
)
|
||||
|
||||
|
||||
@event_class('DOMStorage.domStorageItemRemoved')
|
||||
@dataclass
|
||||
class DomStorageItemRemoved:
|
||||
storage_id: StorageId
|
||||
key: str
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> DomStorageItemRemoved:
|
||||
return cls(
|
||||
storage_id=StorageId.from_json(json['storageId']),
|
||||
key=str(json['key'])
|
||||
)
|
||||
|
||||
|
||||
@event_class('DOMStorage.domStorageItemUpdated')
|
||||
@dataclass
|
||||
class DomStorageItemUpdated:
|
||||
storage_id: StorageId
|
||||
key: str
|
||||
old_value: str
|
||||
new_value: str
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> DomStorageItemUpdated:
|
||||
return cls(
|
||||
storage_id=StorageId.from_json(json['storageId']),
|
||||
key=str(json['key']),
|
||||
old_value=str(json['oldValue']),
|
||||
new_value=str(json['newValue'])
|
||||
)
|
||||
|
||||
|
||||
@event_class('DOMStorage.domStorageItemsCleared')
|
||||
@dataclass
|
||||
class DomStorageItemsCleared:
|
||||
storage_id: StorageId
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> DomStorageItemsCleared:
|
||||
return cls(
|
||||
storage_id=StorageId.from_json(json['storageId'])
|
||||
)
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,56 @@
|
||||
# DO NOT EDIT THIS FILE!
|
||||
#
|
||||
# This file is generated from the CDP specification. If you need to make
|
||||
# changes, edit the generator and regenerate all of the modules.
|
||||
#
|
||||
# CDP domain: EventBreakpoints (experimental)
|
||||
|
||||
from __future__ import annotations
|
||||
import enum
|
||||
import typing
|
||||
from dataclasses import dataclass
|
||||
from .util import event_class, T_JSON_DICT
|
||||
|
||||
|
||||
def set_instrumentation_breakpoint(
|
||||
event_name: str
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Sets breakpoint on particular native event.
|
||||
|
||||
:param event_name: Instrumentation name to stop on.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['eventName'] = event_name
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'EventBreakpoints.setInstrumentationBreakpoint',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def remove_instrumentation_breakpoint(
|
||||
event_name: str
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Removes breakpoint on particular native event.
|
||||
|
||||
:param event_name: Instrumentation name to stop on.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['eventName'] = event_name
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'EventBreakpoints.removeInstrumentationBreakpoint',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def disable() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Removes all breakpoints
|
||||
'''
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'EventBreakpoints.disable',
|
||||
}
|
||||
json = yield cmd_dict
|
||||
@@ -0,0 +1,165 @@
|
||||
# DO NOT EDIT THIS FILE!
|
||||
#
|
||||
# This file is generated from the CDP specification. If you need to make
|
||||
# changes, edit the generator and regenerate all of the modules.
|
||||
#
|
||||
# CDP domain: Extensions (experimental)
|
||||
|
||||
from __future__ import annotations
|
||||
import enum
|
||||
import typing
|
||||
from dataclasses import dataclass
|
||||
from .util import event_class, T_JSON_DICT
|
||||
|
||||
|
||||
class StorageArea(enum.Enum):
|
||||
'''
|
||||
Storage areas.
|
||||
'''
|
||||
SESSION = "session"
|
||||
LOCAL = "local"
|
||||
SYNC = "sync"
|
||||
MANAGED = "managed"
|
||||
|
||||
def to_json(self) -> str:
|
||||
return self.value
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: str) -> StorageArea:
|
||||
return cls(json)
|
||||
|
||||
|
||||
def load_unpacked(
|
||||
path: str
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,str]:
|
||||
'''
|
||||
Installs an unpacked extension from the filesystem similar to
|
||||
--load-extension CLI flags. Returns extension ID once the extension
|
||||
has been installed. Available if the client is connected using the
|
||||
--remote-debugging-pipe flag and the --enable-unsafe-extension-debugging
|
||||
flag is set.
|
||||
|
||||
:param path: Absolute file path.
|
||||
:returns: Extension id.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['path'] = path
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Extensions.loadUnpacked',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
return str(json['id'])
|
||||
|
||||
|
||||
def uninstall(
|
||||
id_: str
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Uninstalls an unpacked extension (others not supported) from the profile.
|
||||
Available if the client is connected using the --remote-debugging-pipe flag
|
||||
and the --enable-unsafe-extension-debugging.
|
||||
|
||||
:param id_: Extension id.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['id'] = id_
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Extensions.uninstall',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def get_storage_items(
|
||||
id_: str,
|
||||
storage_area: StorageArea,
|
||||
keys: typing.Optional[typing.List[str]] = None
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,dict]:
|
||||
'''
|
||||
Gets data from extension storage in the given ``storageArea``. If ``keys`` is
|
||||
specified, these are used to filter the result.
|
||||
|
||||
:param id_: ID of extension.
|
||||
:param storage_area: StorageArea to retrieve data from.
|
||||
:param keys: *(Optional)* Keys to retrieve.
|
||||
:returns:
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['id'] = id_
|
||||
params['storageArea'] = storage_area.to_json()
|
||||
if keys is not None:
|
||||
params['keys'] = [i for i in keys]
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Extensions.getStorageItems',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
return dict(json['data'])
|
||||
|
||||
|
||||
def remove_storage_items(
|
||||
id_: str,
|
||||
storage_area: StorageArea,
|
||||
keys: typing.List[str]
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Removes ``keys`` from extension storage in the given ``storageArea``.
|
||||
|
||||
:param id_: ID of extension.
|
||||
:param storage_area: StorageArea to remove data from.
|
||||
:param keys: Keys to remove.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['id'] = id_
|
||||
params['storageArea'] = storage_area.to_json()
|
||||
params['keys'] = [i for i in keys]
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Extensions.removeStorageItems',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def clear_storage_items(
|
||||
id_: str,
|
||||
storage_area: StorageArea
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Clears extension storage in the given ``storageArea``.
|
||||
|
||||
:param id_: ID of extension.
|
||||
:param storage_area: StorageArea to remove data from.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['id'] = id_
|
||||
params['storageArea'] = storage_area.to_json()
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Extensions.clearStorageItems',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def set_storage_items(
|
||||
id_: str,
|
||||
storage_area: StorageArea,
|
||||
values: dict
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Sets ``values`` in extension storage in the given ``storageArea``. The provided ``values``
|
||||
will be merged with existing values in the storage area.
|
||||
|
||||
:param id_: ID of extension.
|
||||
:param storage_area: StorageArea to set data in.
|
||||
:param values: Values to set.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['id'] = id_
|
||||
params['storageArea'] = storage_area.to_json()
|
||||
params['values'] = values
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Extensions.setStorageItems',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
@@ -0,0 +1,283 @@
|
||||
# DO NOT EDIT THIS FILE!
|
||||
#
|
||||
# This file is generated from the CDP specification. If you need to make
|
||||
# changes, edit the generator and regenerate all of the modules.
|
||||
#
|
||||
# CDP domain: FedCm (experimental)
|
||||
|
||||
from __future__ import annotations
|
||||
import enum
|
||||
import typing
|
||||
from dataclasses import dataclass
|
||||
from .util import event_class, T_JSON_DICT
|
||||
|
||||
|
||||
class LoginState(enum.Enum):
|
||||
'''
|
||||
Whether this is a sign-up or sign-in action for this account, i.e.
|
||||
whether this account has ever been used to sign in to this RP before.
|
||||
'''
|
||||
SIGN_IN = "SignIn"
|
||||
SIGN_UP = "SignUp"
|
||||
|
||||
def to_json(self) -> str:
|
||||
return self.value
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: str) -> LoginState:
|
||||
return cls(json)
|
||||
|
||||
|
||||
class DialogType(enum.Enum):
|
||||
'''
|
||||
The types of FedCM dialogs.
|
||||
'''
|
||||
ACCOUNT_CHOOSER = "AccountChooser"
|
||||
AUTO_REAUTHN = "AutoReauthn"
|
||||
CONFIRM_IDP_LOGIN = "ConfirmIdpLogin"
|
||||
ERROR = "Error"
|
||||
|
||||
def to_json(self) -> str:
|
||||
return self.value
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: str) -> DialogType:
|
||||
return cls(json)
|
||||
|
||||
|
||||
class DialogButton(enum.Enum):
|
||||
'''
|
||||
The buttons on the FedCM dialog.
|
||||
'''
|
||||
CONFIRM_IDP_LOGIN_CONTINUE = "ConfirmIdpLoginContinue"
|
||||
ERROR_GOT_IT = "ErrorGotIt"
|
||||
ERROR_MORE_DETAILS = "ErrorMoreDetails"
|
||||
|
||||
def to_json(self) -> str:
|
||||
return self.value
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: str) -> DialogButton:
|
||||
return cls(json)
|
||||
|
||||
|
||||
class AccountUrlType(enum.Enum):
|
||||
'''
|
||||
The URLs that each account has
|
||||
'''
|
||||
TERMS_OF_SERVICE = "TermsOfService"
|
||||
PRIVACY_POLICY = "PrivacyPolicy"
|
||||
|
||||
def to_json(self) -> str:
|
||||
return self.value
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: str) -> AccountUrlType:
|
||||
return cls(json)
|
||||
|
||||
|
||||
@dataclass
|
||||
class Account:
|
||||
'''
|
||||
Corresponds to IdentityRequestAccount
|
||||
'''
|
||||
account_id: str
|
||||
|
||||
email: str
|
||||
|
||||
name: str
|
||||
|
||||
given_name: str
|
||||
|
||||
picture_url: str
|
||||
|
||||
idp_config_url: str
|
||||
|
||||
idp_login_url: str
|
||||
|
||||
login_state: LoginState
|
||||
|
||||
#: These two are only set if the loginState is signUp
|
||||
terms_of_service_url: typing.Optional[str] = None
|
||||
|
||||
privacy_policy_url: typing.Optional[str] = None
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['accountId'] = self.account_id
|
||||
json['email'] = self.email
|
||||
json['name'] = self.name
|
||||
json['givenName'] = self.given_name
|
||||
json['pictureUrl'] = self.picture_url
|
||||
json['idpConfigUrl'] = self.idp_config_url
|
||||
json['idpLoginUrl'] = self.idp_login_url
|
||||
json['loginState'] = self.login_state.to_json()
|
||||
if self.terms_of_service_url is not None:
|
||||
json['termsOfServiceUrl'] = self.terms_of_service_url
|
||||
if self.privacy_policy_url is not None:
|
||||
json['privacyPolicyUrl'] = self.privacy_policy_url
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> Account:
|
||||
return cls(
|
||||
account_id=str(json['accountId']),
|
||||
email=str(json['email']),
|
||||
name=str(json['name']),
|
||||
given_name=str(json['givenName']),
|
||||
picture_url=str(json['pictureUrl']),
|
||||
idp_config_url=str(json['idpConfigUrl']),
|
||||
idp_login_url=str(json['idpLoginUrl']),
|
||||
login_state=LoginState.from_json(json['loginState']),
|
||||
terms_of_service_url=str(json['termsOfServiceUrl']) if json.get('termsOfServiceUrl', None) is not None else None,
|
||||
privacy_policy_url=str(json['privacyPolicyUrl']) if json.get('privacyPolicyUrl', None) is not None else None,
|
||||
)
|
||||
|
||||
|
||||
def enable(
|
||||
disable_rejection_delay: typing.Optional[bool] = None
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
:param disable_rejection_delay: *(Optional)* Allows callers to disable the promise rejection delay that would normally happen, if this is unimportant to what's being tested. (step 4 of https://fedidcg.github.io/FedCM/#browser-api-rp-sign-in)
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
if disable_rejection_delay is not None:
|
||||
params['disableRejectionDelay'] = disable_rejection_delay
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'FedCm.enable',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def disable() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'FedCm.disable',
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def select_account(
|
||||
dialog_id: str,
|
||||
account_index: int
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
:param dialog_id:
|
||||
:param account_index:
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['dialogId'] = dialog_id
|
||||
params['accountIndex'] = account_index
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'FedCm.selectAccount',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def click_dialog_button(
|
||||
dialog_id: str,
|
||||
dialog_button: DialogButton
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
:param dialog_id:
|
||||
:param dialog_button:
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['dialogId'] = dialog_id
|
||||
params['dialogButton'] = dialog_button.to_json()
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'FedCm.clickDialogButton',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def open_url(
|
||||
dialog_id: str,
|
||||
account_index: int,
|
||||
account_url_type: AccountUrlType
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
:param dialog_id:
|
||||
:param account_index:
|
||||
:param account_url_type:
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['dialogId'] = dialog_id
|
||||
params['accountIndex'] = account_index
|
||||
params['accountUrlType'] = account_url_type.to_json()
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'FedCm.openUrl',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def dismiss_dialog(
|
||||
dialog_id: str,
|
||||
trigger_cooldown: typing.Optional[bool] = None
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
:param dialog_id:
|
||||
:param trigger_cooldown: *(Optional)*
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['dialogId'] = dialog_id
|
||||
if trigger_cooldown is not None:
|
||||
params['triggerCooldown'] = trigger_cooldown
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'FedCm.dismissDialog',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def reset_cooldown() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Resets the cooldown time, if any, to allow the next FedCM call to show
|
||||
a dialog even if one was recently dismissed by the user.
|
||||
'''
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'FedCm.resetCooldown',
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
@event_class('FedCm.dialogShown')
|
||||
@dataclass
|
||||
class DialogShown:
|
||||
dialog_id: str
|
||||
dialog_type: DialogType
|
||||
accounts: typing.List[Account]
|
||||
#: These exist primarily so that the caller can verify the
|
||||
#: RP context was used appropriately.
|
||||
title: str
|
||||
subtitle: typing.Optional[str]
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> DialogShown:
|
||||
return cls(
|
||||
dialog_id=str(json['dialogId']),
|
||||
dialog_type=DialogType.from_json(json['dialogType']),
|
||||
accounts=[Account.from_json(i) for i in json['accounts']],
|
||||
title=str(json['title']),
|
||||
subtitle=str(json['subtitle']) if json.get('subtitle', None) is not None else None
|
||||
)
|
||||
|
||||
|
||||
@event_class('FedCm.dialogClosed')
|
||||
@dataclass
|
||||
class DialogClosed:
|
||||
'''
|
||||
Triggered when a dialog is closed, either by user action, JS abort,
|
||||
or a command below.
|
||||
'''
|
||||
dialog_id: str
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> DialogClosed:
|
||||
return cls(
|
||||
dialog_id=str(json['dialogId'])
|
||||
)
|
||||
@@ -0,0 +1,507 @@
|
||||
# DO NOT EDIT THIS FILE!
|
||||
#
|
||||
# This file is generated from the CDP specification. If you need to make
|
||||
# changes, edit the generator and regenerate all of the modules.
|
||||
#
|
||||
# CDP domain: Fetch
|
||||
|
||||
from __future__ import annotations
|
||||
import enum
|
||||
import typing
|
||||
from dataclasses import dataclass
|
||||
from .util import event_class, T_JSON_DICT
|
||||
|
||||
from . import io
|
||||
from . import network
|
||||
from . import page
|
||||
|
||||
|
||||
class RequestId(str):
|
||||
'''
|
||||
Unique request identifier.
|
||||
Note that this does not identify individual HTTP requests that are part of
|
||||
a network request.
|
||||
'''
|
||||
def to_json(self) -> str:
|
||||
return self
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: str) -> RequestId:
|
||||
return cls(json)
|
||||
|
||||
def __repr__(self):
|
||||
return 'RequestId({})'.format(super().__repr__())
|
||||
|
||||
|
||||
class RequestStage(enum.Enum):
|
||||
'''
|
||||
Stages of the request to handle. Request will intercept before the request is
|
||||
sent. Response will intercept after the response is received (but before response
|
||||
body is received).
|
||||
'''
|
||||
REQUEST = "Request"
|
||||
RESPONSE = "Response"
|
||||
|
||||
def to_json(self) -> str:
|
||||
return self.value
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: str) -> RequestStage:
|
||||
return cls(json)
|
||||
|
||||
|
||||
@dataclass
|
||||
class RequestPattern:
|
||||
#: Wildcards (``'*'`` -> zero or more, ``'?'`` -> exactly one) are allowed. Escape character is
|
||||
#: backslash. Omitting is equivalent to ``"*"``.
|
||||
url_pattern: typing.Optional[str] = None
|
||||
|
||||
#: If set, only requests for matching resource types will be intercepted.
|
||||
resource_type: typing.Optional[network.ResourceType] = None
|
||||
|
||||
#: Stage at which to begin intercepting requests. Default is Request.
|
||||
request_stage: typing.Optional[RequestStage] = None
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
if self.url_pattern is not None:
|
||||
json['urlPattern'] = self.url_pattern
|
||||
if self.resource_type is not None:
|
||||
json['resourceType'] = self.resource_type.to_json()
|
||||
if self.request_stage is not None:
|
||||
json['requestStage'] = self.request_stage.to_json()
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> RequestPattern:
|
||||
return cls(
|
||||
url_pattern=str(json['urlPattern']) if json.get('urlPattern', None) is not None else None,
|
||||
resource_type=network.ResourceType.from_json(json['resourceType']) if json.get('resourceType', None) is not None else None,
|
||||
request_stage=RequestStage.from_json(json['requestStage']) if json.get('requestStage', None) is not None else None,
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class HeaderEntry:
|
||||
'''
|
||||
Response HTTP header entry
|
||||
'''
|
||||
name: str
|
||||
|
||||
value: str
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['name'] = self.name
|
||||
json['value'] = self.value
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> HeaderEntry:
|
||||
return cls(
|
||||
name=str(json['name']),
|
||||
value=str(json['value']),
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class AuthChallenge:
|
||||
'''
|
||||
Authorization challenge for HTTP status code 401 or 407.
|
||||
'''
|
||||
#: Origin of the challenger.
|
||||
origin: str
|
||||
|
||||
#: The authentication scheme used, such as basic or digest
|
||||
scheme: str
|
||||
|
||||
#: The realm of the challenge. May be empty.
|
||||
realm: str
|
||||
|
||||
#: Source of the authentication challenge.
|
||||
source: typing.Optional[str] = None
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['origin'] = self.origin
|
||||
json['scheme'] = self.scheme
|
||||
json['realm'] = self.realm
|
||||
if self.source is not None:
|
||||
json['source'] = self.source
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> AuthChallenge:
|
||||
return cls(
|
||||
origin=str(json['origin']),
|
||||
scheme=str(json['scheme']),
|
||||
realm=str(json['realm']),
|
||||
source=str(json['source']) if json.get('source', None) is not None else None,
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class AuthChallengeResponse:
|
||||
'''
|
||||
Response to an AuthChallenge.
|
||||
'''
|
||||
#: The decision on what to do in response to the authorization challenge. Default means
|
||||
#: deferring to the default behavior of the net stack, which will likely either the Cancel
|
||||
#: authentication or display a popup dialog box.
|
||||
response: str
|
||||
|
||||
#: The username to provide, possibly empty. Should only be set if response is
|
||||
#: ProvideCredentials.
|
||||
username: typing.Optional[str] = None
|
||||
|
||||
#: The password to provide, possibly empty. Should only be set if response is
|
||||
#: ProvideCredentials.
|
||||
password: typing.Optional[str] = None
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['response'] = self.response
|
||||
if self.username is not None:
|
||||
json['username'] = self.username
|
||||
if self.password is not None:
|
||||
json['password'] = self.password
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> AuthChallengeResponse:
|
||||
return cls(
|
||||
response=str(json['response']),
|
||||
username=str(json['username']) if json.get('username', None) is not None else None,
|
||||
password=str(json['password']) if json.get('password', None) is not None else None,
|
||||
)
|
||||
|
||||
|
||||
def disable() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Disables the fetch domain.
|
||||
'''
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Fetch.disable',
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def enable(
|
||||
patterns: typing.Optional[typing.List[RequestPattern]] = None,
|
||||
handle_auth_requests: typing.Optional[bool] = None
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Enables issuing of requestPaused events. A request will be paused until client
|
||||
calls one of failRequest, fulfillRequest or continueRequest/continueWithAuth.
|
||||
|
||||
:param patterns: *(Optional)* If specified, only requests matching any of these patterns will produce fetchRequested event and will be paused until clients response. If not set, all requests will be affected.
|
||||
:param handle_auth_requests: *(Optional)* If true, authRequired events will be issued and requests will be paused expecting a call to continueWithAuth.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
if patterns is not None:
|
||||
params['patterns'] = [i.to_json() for i in patterns]
|
||||
if handle_auth_requests is not None:
|
||||
params['handleAuthRequests'] = handle_auth_requests
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Fetch.enable',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def fail_request(
|
||||
request_id: RequestId,
|
||||
error_reason: network.ErrorReason
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Causes the request to fail with specified reason.
|
||||
|
||||
:param request_id: An id the client received in requestPaused event.
|
||||
:param error_reason: Causes the request to fail with the given reason.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['requestId'] = request_id.to_json()
|
||||
params['errorReason'] = error_reason.to_json()
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Fetch.failRequest',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def fulfill_request(
|
||||
request_id: RequestId,
|
||||
response_code: int,
|
||||
response_headers: typing.Optional[typing.List[HeaderEntry]] = None,
|
||||
binary_response_headers: typing.Optional[str] = None,
|
||||
body: typing.Optional[str] = None,
|
||||
response_phrase: typing.Optional[str] = None
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
r'''
|
||||
Provides response to the request.
|
||||
|
||||
:param request_id: An id the client received in requestPaused event.
|
||||
:param response_code: An HTTP response code.
|
||||
:param response_headers: *(Optional)* Response headers.
|
||||
:param binary_response_headers: *(Optional)* Alternative way of specifying response headers as a \0-separated series of name: value pairs. Prefer the above method unless you need to represent some non-UTF8 values that can't be transmitted over the protocol as text. (Encoded as a base64 string when passed over JSON)
|
||||
:param body: *(Optional)* A response body. If absent, original response body will be used if the request is intercepted at the response stage and empty body will be used if the request is intercepted at the request stage. (Encoded as a base64 string when passed over JSON)
|
||||
:param response_phrase: *(Optional)* A textual representation of responseCode. If absent, a standard phrase matching responseCode is used.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['requestId'] = request_id.to_json()
|
||||
params['responseCode'] = response_code
|
||||
if response_headers is not None:
|
||||
params['responseHeaders'] = [i.to_json() for i in response_headers]
|
||||
if binary_response_headers is not None:
|
||||
params['binaryResponseHeaders'] = binary_response_headers
|
||||
if body is not None:
|
||||
params['body'] = body
|
||||
if response_phrase is not None:
|
||||
params['responsePhrase'] = response_phrase
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Fetch.fulfillRequest',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def continue_request(
|
||||
request_id: RequestId,
|
||||
url: typing.Optional[str] = None,
|
||||
method: typing.Optional[str] = None,
|
||||
post_data: typing.Optional[str] = None,
|
||||
headers: typing.Optional[typing.List[HeaderEntry]] = None,
|
||||
intercept_response: typing.Optional[bool] = None
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Continues the request, optionally modifying some of its parameters.
|
||||
|
||||
:param request_id: An id the client received in requestPaused event.
|
||||
:param url: *(Optional)* If set, the request url will be modified in a way that's not observable by page.
|
||||
:param method: *(Optional)* If set, the request method is overridden.
|
||||
:param post_data: *(Optional)* If set, overrides the post data in the request. (Encoded as a base64 string when passed over JSON)
|
||||
:param headers: *(Optional)* If set, overrides the request headers. Note that the overrides do not extend to subsequent redirect hops, if a redirect happens. Another override may be applied to a different request produced by a redirect.
|
||||
:param intercept_response: **(EXPERIMENTAL)** *(Optional)* If set, overrides response interception behavior for this request.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['requestId'] = request_id.to_json()
|
||||
if url is not None:
|
||||
params['url'] = url
|
||||
if method is not None:
|
||||
params['method'] = method
|
||||
if post_data is not None:
|
||||
params['postData'] = post_data
|
||||
if headers is not None:
|
||||
params['headers'] = [i.to_json() for i in headers]
|
||||
if intercept_response is not None:
|
||||
params['interceptResponse'] = intercept_response
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Fetch.continueRequest',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def continue_with_auth(
|
||||
request_id: RequestId,
|
||||
auth_challenge_response: AuthChallengeResponse
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Continues a request supplying authChallengeResponse following authRequired event.
|
||||
|
||||
:param request_id: An id the client received in authRequired event.
|
||||
:param auth_challenge_response: Response to with an authChallenge.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['requestId'] = request_id.to_json()
|
||||
params['authChallengeResponse'] = auth_challenge_response.to_json()
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Fetch.continueWithAuth',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def continue_response(
|
||||
request_id: RequestId,
|
||||
response_code: typing.Optional[int] = None,
|
||||
response_phrase: typing.Optional[str] = None,
|
||||
response_headers: typing.Optional[typing.List[HeaderEntry]] = None,
|
||||
binary_response_headers: typing.Optional[str] = None
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
r'''
|
||||
Continues loading of the paused response, optionally modifying the
|
||||
response headers. If either responseCode or headers are modified, all of them
|
||||
must be present.
|
||||
|
||||
**EXPERIMENTAL**
|
||||
|
||||
:param request_id: An id the client received in requestPaused event.
|
||||
:param response_code: *(Optional)* An HTTP response code. If absent, original response code will be used.
|
||||
:param response_phrase: *(Optional)* A textual representation of responseCode. If absent, a standard phrase matching responseCode is used.
|
||||
:param response_headers: *(Optional)* Response headers. If absent, original response headers will be used.
|
||||
:param binary_response_headers: *(Optional)* Alternative way of specifying response headers as a \0-separated series of name: value pairs. Prefer the above method unless you need to represent some non-UTF8 values that can't be transmitted over the protocol as text. (Encoded as a base64 string when passed over JSON)
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['requestId'] = request_id.to_json()
|
||||
if response_code is not None:
|
||||
params['responseCode'] = response_code
|
||||
if response_phrase is not None:
|
||||
params['responsePhrase'] = response_phrase
|
||||
if response_headers is not None:
|
||||
params['responseHeaders'] = [i.to_json() for i in response_headers]
|
||||
if binary_response_headers is not None:
|
||||
params['binaryResponseHeaders'] = binary_response_headers
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Fetch.continueResponse',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def get_response_body(
|
||||
request_id: RequestId
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.Tuple[str, bool]]:
|
||||
'''
|
||||
Causes the body of the response to be received from the server and
|
||||
returned as a single string. May only be issued for a request that
|
||||
is paused in the Response stage and is mutually exclusive with
|
||||
takeResponseBodyForInterceptionAsStream. Calling other methods that
|
||||
affect the request or disabling fetch domain before body is received
|
||||
results in an undefined behavior.
|
||||
Note that the response body is not available for redirects. Requests
|
||||
paused in the _redirect received_ state may be differentiated by
|
||||
``responseCode`` and presence of ``location`` response header, see
|
||||
comments to ``requestPaused`` for details.
|
||||
|
||||
:param request_id: Identifier for the intercepted request to get body for.
|
||||
:returns: A tuple with the following items:
|
||||
|
||||
0. **body** - Response body.
|
||||
1. **base64Encoded** - True, if content was sent as base64.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['requestId'] = request_id.to_json()
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Fetch.getResponseBody',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
return (
|
||||
str(json['body']),
|
||||
bool(json['base64Encoded'])
|
||||
)
|
||||
|
||||
|
||||
def take_response_body_as_stream(
|
||||
request_id: RequestId
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,io.StreamHandle]:
|
||||
'''
|
||||
Returns a handle to the stream representing the response body.
|
||||
The request must be paused in the HeadersReceived stage.
|
||||
Note that after this command the request can't be continued
|
||||
as is -- client either needs to cancel it or to provide the
|
||||
response body.
|
||||
The stream only supports sequential read, IO.read will fail if the position
|
||||
is specified.
|
||||
This method is mutually exclusive with getResponseBody.
|
||||
Calling other methods that affect the request or disabling fetch
|
||||
domain before body is received results in an undefined behavior.
|
||||
|
||||
:param request_id:
|
||||
:returns:
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['requestId'] = request_id.to_json()
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Fetch.takeResponseBodyAsStream',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
return io.StreamHandle.from_json(json['stream'])
|
||||
|
||||
|
||||
@event_class('Fetch.requestPaused')
|
||||
@dataclass
|
||||
class RequestPaused:
|
||||
'''
|
||||
Issued when the domain is enabled and the request URL matches the
|
||||
specified filter. The request is paused until the client responds
|
||||
with one of continueRequest, failRequest or fulfillRequest.
|
||||
The stage of the request can be determined by presence of responseErrorReason
|
||||
and responseStatusCode -- the request is at the response stage if either
|
||||
of these fields is present and in the request stage otherwise.
|
||||
Redirect responses and subsequent requests are reported similarly to regular
|
||||
responses and requests. Redirect responses may be distinguished by the value
|
||||
of ``responseStatusCode`` (which is one of 301, 302, 303, 307, 308) along with
|
||||
presence of the ``location`` header. Requests resulting from a redirect will
|
||||
have ``redirectedRequestId`` field set.
|
||||
'''
|
||||
#: Each request the page makes will have a unique id.
|
||||
request_id: RequestId
|
||||
#: The details of the request.
|
||||
request: network.Request
|
||||
#: The id of the frame that initiated the request.
|
||||
frame_id: page.FrameId
|
||||
#: How the requested resource will be used.
|
||||
resource_type: network.ResourceType
|
||||
#: Response error if intercepted at response stage.
|
||||
response_error_reason: typing.Optional[network.ErrorReason]
|
||||
#: Response code if intercepted at response stage.
|
||||
response_status_code: typing.Optional[int]
|
||||
#: Response status text if intercepted at response stage.
|
||||
response_status_text: typing.Optional[str]
|
||||
#: Response headers if intercepted at the response stage.
|
||||
response_headers: typing.Optional[typing.List[HeaderEntry]]
|
||||
#: If the intercepted request had a corresponding Network.requestWillBeSent event fired for it,
|
||||
#: then this networkId will be the same as the requestId present in the requestWillBeSent event.
|
||||
network_id: typing.Optional[network.RequestId]
|
||||
#: If the request is due to a redirect response from the server, the id of the request that
|
||||
#: has caused the redirect.
|
||||
redirected_request_id: typing.Optional[RequestId]
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> RequestPaused:
|
||||
return cls(
|
||||
request_id=RequestId.from_json(json['requestId']),
|
||||
request=network.Request.from_json(json['request']),
|
||||
frame_id=page.FrameId.from_json(json['frameId']),
|
||||
resource_type=network.ResourceType.from_json(json['resourceType']),
|
||||
response_error_reason=network.ErrorReason.from_json(json['responseErrorReason']) if json.get('responseErrorReason', None) is not None else None,
|
||||
response_status_code=int(json['responseStatusCode']) if json.get('responseStatusCode', None) is not None else None,
|
||||
response_status_text=str(json['responseStatusText']) if json.get('responseStatusText', None) is not None else None,
|
||||
response_headers=[HeaderEntry.from_json(i) for i in json['responseHeaders']] if json.get('responseHeaders', None) is not None else None,
|
||||
network_id=network.RequestId.from_json(json['networkId']) if json.get('networkId', None) is not None else None,
|
||||
redirected_request_id=RequestId.from_json(json['redirectedRequestId']) if json.get('redirectedRequestId', None) is not None else None
|
||||
)
|
||||
|
||||
|
||||
@event_class('Fetch.authRequired')
|
||||
@dataclass
|
||||
class AuthRequired:
|
||||
'''
|
||||
Issued when the domain is enabled with handleAuthRequests set to true.
|
||||
The request is paused until client responds with continueWithAuth.
|
||||
'''
|
||||
#: Each request the page makes will have a unique id.
|
||||
request_id: RequestId
|
||||
#: The details of the request.
|
||||
request: network.Request
|
||||
#: The id of the frame that initiated the request.
|
||||
frame_id: page.FrameId
|
||||
#: How the requested resource will be used.
|
||||
resource_type: network.ResourceType
|
||||
#: Details of the Authorization Challenge encountered.
|
||||
#: If this is set, client should respond with continueRequest that
|
||||
#: contains AuthChallengeResponse.
|
||||
auth_challenge: AuthChallenge
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> AuthRequired:
|
||||
return cls(
|
||||
request_id=RequestId.from_json(json['requestId']),
|
||||
request=network.Request.from_json(json['request']),
|
||||
frame_id=page.FrameId.from_json(json['frameId']),
|
||||
resource_type=network.ResourceType.from_json(json['resourceType']),
|
||||
auth_challenge=AuthChallenge.from_json(json['authChallenge'])
|
||||
)
|
||||
@@ -0,0 +1,115 @@
|
||||
# DO NOT EDIT THIS FILE!
|
||||
#
|
||||
# This file is generated from the CDP specification. If you need to make
|
||||
# changes, edit the generator and regenerate all of the modules.
|
||||
#
|
||||
# CDP domain: FileSystem (experimental)
|
||||
|
||||
from __future__ import annotations
|
||||
import enum
|
||||
import typing
|
||||
from dataclasses import dataclass
|
||||
from .util import event_class, T_JSON_DICT
|
||||
|
||||
from . import network
|
||||
from . import storage
|
||||
|
||||
|
||||
@dataclass
|
||||
class File:
|
||||
name: str
|
||||
|
||||
#: Timestamp
|
||||
last_modified: network.TimeSinceEpoch
|
||||
|
||||
#: Size in bytes
|
||||
size: float
|
||||
|
||||
type_: str
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['name'] = self.name
|
||||
json['lastModified'] = self.last_modified.to_json()
|
||||
json['size'] = self.size
|
||||
json['type'] = self.type_
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> File:
|
||||
return cls(
|
||||
name=str(json['name']),
|
||||
last_modified=network.TimeSinceEpoch.from_json(json['lastModified']),
|
||||
size=float(json['size']),
|
||||
type_=str(json['type']),
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class Directory:
|
||||
name: str
|
||||
|
||||
nested_directories: typing.List[str]
|
||||
|
||||
#: Files that are directly nested under this directory.
|
||||
nested_files: typing.List[File]
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['name'] = self.name
|
||||
json['nestedDirectories'] = [i for i in self.nested_directories]
|
||||
json['nestedFiles'] = [i.to_json() for i in self.nested_files]
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> Directory:
|
||||
return cls(
|
||||
name=str(json['name']),
|
||||
nested_directories=[str(i) for i in json['nestedDirectories']],
|
||||
nested_files=[File.from_json(i) for i in json['nestedFiles']],
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class BucketFileSystemLocator:
|
||||
#: Storage key
|
||||
storage_key: storage.SerializedStorageKey
|
||||
|
||||
#: Path to the directory using each path component as an array item.
|
||||
path_components: typing.List[str]
|
||||
|
||||
#: Bucket name. Not passing a ``bucketName`` will retrieve the default Bucket. (https://developer.mozilla.org/en-US/docs/Web/API/Storage_API#storage_buckets)
|
||||
bucket_name: typing.Optional[str] = None
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['storageKey'] = self.storage_key.to_json()
|
||||
json['pathComponents'] = [i for i in self.path_components]
|
||||
if self.bucket_name is not None:
|
||||
json['bucketName'] = self.bucket_name
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> BucketFileSystemLocator:
|
||||
return cls(
|
||||
storage_key=storage.SerializedStorageKey.from_json(json['storageKey']),
|
||||
path_components=[str(i) for i in json['pathComponents']],
|
||||
bucket_name=str(json['bucketName']) if json.get('bucketName', None) is not None else None,
|
||||
)
|
||||
|
||||
|
||||
def get_directory(
|
||||
bucket_file_system_locator: BucketFileSystemLocator
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,Directory]:
|
||||
'''
|
||||
:param bucket_file_system_locator:
|
||||
:returns: Returns the directory object at the path.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['bucketFileSystemLocator'] = bucket_file_system_locator.to_json()
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'FileSystem.getDirectory',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
return Directory.from_json(json['directory'])
|
||||
@@ -0,0 +1,115 @@
|
||||
# DO NOT EDIT THIS FILE!
|
||||
#
|
||||
# This file is generated from the CDP specification. If you need to make
|
||||
# changes, edit the generator and regenerate all of the modules.
|
||||
#
|
||||
# CDP domain: HeadlessExperimental (experimental)
|
||||
|
||||
from __future__ import annotations
|
||||
import enum
|
||||
import typing
|
||||
from dataclasses import dataclass
|
||||
from .util import event_class, T_JSON_DICT
|
||||
|
||||
|
||||
from deprecated.sphinx import deprecated # type: ignore
|
||||
|
||||
|
||||
@dataclass
|
||||
class ScreenshotParams:
|
||||
'''
|
||||
Encoding options for a screenshot.
|
||||
'''
|
||||
#: Image compression format (defaults to png).
|
||||
format_: typing.Optional[str] = None
|
||||
|
||||
#: Compression quality from range [0..100] (jpeg and webp only).
|
||||
quality: typing.Optional[int] = None
|
||||
|
||||
#: Optimize image encoding for speed, not for resulting size (defaults to false)
|
||||
optimize_for_speed: typing.Optional[bool] = None
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
if self.format_ is not None:
|
||||
json['format'] = self.format_
|
||||
if self.quality is not None:
|
||||
json['quality'] = self.quality
|
||||
if self.optimize_for_speed is not None:
|
||||
json['optimizeForSpeed'] = self.optimize_for_speed
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> ScreenshotParams:
|
||||
return cls(
|
||||
format_=str(json['format']) if json.get('format', None) is not None else None,
|
||||
quality=int(json['quality']) if json.get('quality', None) is not None else None,
|
||||
optimize_for_speed=bool(json['optimizeForSpeed']) if json.get('optimizeForSpeed', None) is not None else None,
|
||||
)
|
||||
|
||||
|
||||
def begin_frame(
|
||||
frame_time_ticks: typing.Optional[float] = None,
|
||||
interval: typing.Optional[float] = None,
|
||||
no_display_updates: typing.Optional[bool] = None,
|
||||
screenshot: typing.Optional[ScreenshotParams] = None
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.Tuple[bool, typing.Optional[str]]]:
|
||||
'''
|
||||
Sends a BeginFrame to the target and returns when the frame was completed. Optionally captures a
|
||||
screenshot from the resulting frame. Requires that the target was created with enabled
|
||||
BeginFrameControl. Designed for use with --run-all-compositor-stages-before-draw, see also
|
||||
https://goo.gle/chrome-headless-rendering for more background.
|
||||
|
||||
:param frame_time_ticks: *(Optional)* Timestamp of this BeginFrame in Renderer TimeTicks (milliseconds of uptime). If not set, the current time will be used.
|
||||
:param interval: *(Optional)* The interval between BeginFrames that is reported to the compositor, in milliseconds. Defaults to a 60 frames/second interval, i.e. about 16.666 milliseconds.
|
||||
:param no_display_updates: *(Optional)* Whether updates should not be committed and drawn onto the display. False by default. If true, only side effects of the BeginFrame will be run, such as layout and animations, but any visual updates may not be visible on the display or in screenshots.
|
||||
:param screenshot: *(Optional)* If set, a screenshot of the frame will be captured and returned in the response. Otherwise, no screenshot will be captured. Note that capturing a screenshot can fail, for example, during renderer initialization. In such a case, no screenshot data will be returned.
|
||||
:returns: A tuple with the following items:
|
||||
|
||||
0. **hasDamage** - Whether the BeginFrame resulted in damage and, thus, a new frame was committed to the display. Reported for diagnostic uses, may be removed in the future.
|
||||
1. **screenshotData** - *(Optional)* Base64-encoded image data of the screenshot, if one was requested and successfully taken. (Encoded as a base64 string when passed over JSON)
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
if frame_time_ticks is not None:
|
||||
params['frameTimeTicks'] = frame_time_ticks
|
||||
if interval is not None:
|
||||
params['interval'] = interval
|
||||
if no_display_updates is not None:
|
||||
params['noDisplayUpdates'] = no_display_updates
|
||||
if screenshot is not None:
|
||||
params['screenshot'] = screenshot.to_json()
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'HeadlessExperimental.beginFrame',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
return (
|
||||
bool(json['hasDamage']),
|
||||
str(json['screenshotData']) if json.get('screenshotData', None) is not None else None
|
||||
)
|
||||
|
||||
|
||||
@deprecated(version="1.3")
|
||||
def disable() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Disables headless events for the target.
|
||||
|
||||
.. deprecated:: 1.3
|
||||
'''
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'HeadlessExperimental.disable',
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
@deprecated(version="1.3")
|
||||
def enable() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Enables headless events for the target.
|
||||
|
||||
.. deprecated:: 1.3
|
||||
'''
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'HeadlessExperimental.enable',
|
||||
}
|
||||
json = yield cmd_dict
|
||||
@@ -0,0 +1,401 @@
|
||||
# DO NOT EDIT THIS FILE!
|
||||
#
|
||||
# This file is generated from the CDP specification. If you need to make
|
||||
# changes, edit the generator and regenerate all of the modules.
|
||||
#
|
||||
# CDP domain: HeapProfiler (experimental)
|
||||
|
||||
from __future__ import annotations
|
||||
import enum
|
||||
import typing
|
||||
from dataclasses import dataclass
|
||||
from .util import event_class, T_JSON_DICT
|
||||
|
||||
from . import runtime
|
||||
|
||||
|
||||
class HeapSnapshotObjectId(str):
|
||||
'''
|
||||
Heap snapshot object id.
|
||||
'''
|
||||
def to_json(self) -> str:
|
||||
return self
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: str) -> HeapSnapshotObjectId:
|
||||
return cls(json)
|
||||
|
||||
def __repr__(self):
|
||||
return 'HeapSnapshotObjectId({})'.format(super().__repr__())
|
||||
|
||||
|
||||
@dataclass
|
||||
class SamplingHeapProfileNode:
|
||||
'''
|
||||
Sampling Heap Profile node. Holds callsite information, allocation statistics and child nodes.
|
||||
'''
|
||||
#: Function location.
|
||||
call_frame: runtime.CallFrame
|
||||
|
||||
#: Allocations size in bytes for the node excluding children.
|
||||
self_size: float
|
||||
|
||||
#: Node id. Ids are unique across all profiles collected between startSampling and stopSampling.
|
||||
id_: int
|
||||
|
||||
#: Child nodes.
|
||||
children: typing.List[SamplingHeapProfileNode]
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['callFrame'] = self.call_frame.to_json()
|
||||
json['selfSize'] = self.self_size
|
||||
json['id'] = self.id_
|
||||
json['children'] = [i.to_json() for i in self.children]
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> SamplingHeapProfileNode:
|
||||
return cls(
|
||||
call_frame=runtime.CallFrame.from_json(json['callFrame']),
|
||||
self_size=float(json['selfSize']),
|
||||
id_=int(json['id']),
|
||||
children=[SamplingHeapProfileNode.from_json(i) for i in json['children']],
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class SamplingHeapProfileSample:
|
||||
'''
|
||||
A single sample from a sampling profile.
|
||||
'''
|
||||
#: Allocation size in bytes attributed to the sample.
|
||||
size: float
|
||||
|
||||
#: Id of the corresponding profile tree node.
|
||||
node_id: int
|
||||
|
||||
#: Time-ordered sample ordinal number. It is unique across all profiles retrieved
|
||||
#: between startSampling and stopSampling.
|
||||
ordinal: float
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['size'] = self.size
|
||||
json['nodeId'] = self.node_id
|
||||
json['ordinal'] = self.ordinal
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> SamplingHeapProfileSample:
|
||||
return cls(
|
||||
size=float(json['size']),
|
||||
node_id=int(json['nodeId']),
|
||||
ordinal=float(json['ordinal']),
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class SamplingHeapProfile:
|
||||
'''
|
||||
Sampling profile.
|
||||
'''
|
||||
head: SamplingHeapProfileNode
|
||||
|
||||
samples: typing.List[SamplingHeapProfileSample]
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['head'] = self.head.to_json()
|
||||
json['samples'] = [i.to_json() for i in self.samples]
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> SamplingHeapProfile:
|
||||
return cls(
|
||||
head=SamplingHeapProfileNode.from_json(json['head']),
|
||||
samples=[SamplingHeapProfileSample.from_json(i) for i in json['samples']],
|
||||
)
|
||||
|
||||
|
||||
def add_inspected_heap_object(
|
||||
heap_object_id: HeapSnapshotObjectId
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Enables console to refer to the node with given id via $x (see Command Line API for more details
|
||||
$x functions).
|
||||
|
||||
:param heap_object_id: Heap snapshot object id to be accessible by means of $x command line API.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['heapObjectId'] = heap_object_id.to_json()
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'HeapProfiler.addInspectedHeapObject',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def collect_garbage() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'HeapProfiler.collectGarbage',
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def disable() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'HeapProfiler.disable',
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def enable() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'HeapProfiler.enable',
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def get_heap_object_id(
|
||||
object_id: runtime.RemoteObjectId
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,HeapSnapshotObjectId]:
|
||||
'''
|
||||
:param object_id: Identifier of the object to get heap object id for.
|
||||
:returns: Id of the heap snapshot object corresponding to the passed remote object id.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['objectId'] = object_id.to_json()
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'HeapProfiler.getHeapObjectId',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
return HeapSnapshotObjectId.from_json(json['heapSnapshotObjectId'])
|
||||
|
||||
|
||||
def get_object_by_heap_object_id(
|
||||
object_id: HeapSnapshotObjectId,
|
||||
object_group: typing.Optional[str] = None
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,runtime.RemoteObject]:
|
||||
'''
|
||||
:param object_id:
|
||||
:param object_group: *(Optional)* Symbolic group name that can be used to release multiple objects.
|
||||
:returns: Evaluation result.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['objectId'] = object_id.to_json()
|
||||
if object_group is not None:
|
||||
params['objectGroup'] = object_group
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'HeapProfiler.getObjectByHeapObjectId',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
return runtime.RemoteObject.from_json(json['result'])
|
||||
|
||||
|
||||
def get_sampling_profile() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,SamplingHeapProfile]:
|
||||
'''
|
||||
|
||||
|
||||
:returns: Return the sampling profile being collected.
|
||||
'''
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'HeapProfiler.getSamplingProfile',
|
||||
}
|
||||
json = yield cmd_dict
|
||||
return SamplingHeapProfile.from_json(json['profile'])
|
||||
|
||||
|
||||
def start_sampling(
|
||||
sampling_interval: typing.Optional[float] = None,
|
||||
stack_depth: typing.Optional[float] = None,
|
||||
include_objects_collected_by_major_gc: typing.Optional[bool] = None,
|
||||
include_objects_collected_by_minor_gc: typing.Optional[bool] = None
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
:param sampling_interval: *(Optional)* Average sample interval in bytes. Poisson distribution is used for the intervals. The default value is 32768 bytes.
|
||||
:param stack_depth: *(Optional)* Maximum stack depth. The default value is 128.
|
||||
:param include_objects_collected_by_major_gc: *(Optional)* By default, the sampling heap profiler reports only objects which are still alive when the profile is returned via getSamplingProfile or stopSampling, which is useful for determining what functions contribute the most to steady-state memory usage. This flag instructs the sampling heap profiler to also include information about objects discarded by major GC, which will show which functions cause large temporary memory usage or long GC pauses.
|
||||
:param include_objects_collected_by_minor_gc: *(Optional)* By default, the sampling heap profiler reports only objects which are still alive when the profile is returned via getSamplingProfile or stopSampling, which is useful for determining what functions contribute the most to steady-state memory usage. This flag instructs the sampling heap profiler to also include information about objects discarded by minor GC, which is useful when tuning a latency-sensitive application for minimal GC activity.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
if sampling_interval is not None:
|
||||
params['samplingInterval'] = sampling_interval
|
||||
if stack_depth is not None:
|
||||
params['stackDepth'] = stack_depth
|
||||
if include_objects_collected_by_major_gc is not None:
|
||||
params['includeObjectsCollectedByMajorGC'] = include_objects_collected_by_major_gc
|
||||
if include_objects_collected_by_minor_gc is not None:
|
||||
params['includeObjectsCollectedByMinorGC'] = include_objects_collected_by_minor_gc
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'HeapProfiler.startSampling',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def start_tracking_heap_objects(
|
||||
track_allocations: typing.Optional[bool] = None
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
:param track_allocations: *(Optional)*
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
if track_allocations is not None:
|
||||
params['trackAllocations'] = track_allocations
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'HeapProfiler.startTrackingHeapObjects',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def stop_sampling() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,SamplingHeapProfile]:
|
||||
'''
|
||||
|
||||
|
||||
:returns: Recorded sampling heap profile.
|
||||
'''
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'HeapProfiler.stopSampling',
|
||||
}
|
||||
json = yield cmd_dict
|
||||
return SamplingHeapProfile.from_json(json['profile'])
|
||||
|
||||
|
||||
def stop_tracking_heap_objects(
|
||||
report_progress: typing.Optional[bool] = None,
|
||||
treat_global_objects_as_roots: typing.Optional[bool] = None,
|
||||
capture_numeric_value: typing.Optional[bool] = None,
|
||||
expose_internals: typing.Optional[bool] = None
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
:param report_progress: *(Optional)* If true 'reportHeapSnapshotProgress' events will be generated while snapshot is being taken when the tracking is stopped.
|
||||
:param treat_global_objects_as_roots: **(DEPRECATED)** *(Optional)* Deprecated in favor of ```exposeInternals```.
|
||||
:param capture_numeric_value: *(Optional)* If true, numerical values are included in the snapshot
|
||||
:param expose_internals: **(EXPERIMENTAL)** *(Optional)* If true, exposes internals of the snapshot.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
if report_progress is not None:
|
||||
params['reportProgress'] = report_progress
|
||||
if treat_global_objects_as_roots is not None:
|
||||
params['treatGlobalObjectsAsRoots'] = treat_global_objects_as_roots
|
||||
if capture_numeric_value is not None:
|
||||
params['captureNumericValue'] = capture_numeric_value
|
||||
if expose_internals is not None:
|
||||
params['exposeInternals'] = expose_internals
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'HeapProfiler.stopTrackingHeapObjects',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def take_heap_snapshot(
|
||||
report_progress: typing.Optional[bool] = None,
|
||||
treat_global_objects_as_roots: typing.Optional[bool] = None,
|
||||
capture_numeric_value: typing.Optional[bool] = None,
|
||||
expose_internals: typing.Optional[bool] = None
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
:param report_progress: *(Optional)* If true 'reportHeapSnapshotProgress' events will be generated while snapshot is being taken.
|
||||
:param treat_global_objects_as_roots: **(DEPRECATED)** *(Optional)* If true, a raw snapshot without artificial roots will be generated. Deprecated in favor of ```exposeInternals```.
|
||||
:param capture_numeric_value: *(Optional)* If true, numerical values are included in the snapshot
|
||||
:param expose_internals: **(EXPERIMENTAL)** *(Optional)* If true, exposes internals of the snapshot.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
if report_progress is not None:
|
||||
params['reportProgress'] = report_progress
|
||||
if treat_global_objects_as_roots is not None:
|
||||
params['treatGlobalObjectsAsRoots'] = treat_global_objects_as_roots
|
||||
if capture_numeric_value is not None:
|
||||
params['captureNumericValue'] = capture_numeric_value
|
||||
if expose_internals is not None:
|
||||
params['exposeInternals'] = expose_internals
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'HeapProfiler.takeHeapSnapshot',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
@event_class('HeapProfiler.addHeapSnapshotChunk')
|
||||
@dataclass
|
||||
class AddHeapSnapshotChunk:
|
||||
chunk: str
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> AddHeapSnapshotChunk:
|
||||
return cls(
|
||||
chunk=str(json['chunk'])
|
||||
)
|
||||
|
||||
|
||||
@event_class('HeapProfiler.heapStatsUpdate')
|
||||
@dataclass
|
||||
class HeapStatsUpdate:
|
||||
'''
|
||||
If heap objects tracking has been started then backend may send update for one or more fragments
|
||||
'''
|
||||
#: An array of triplets. Each triplet describes a fragment. The first integer is the fragment
|
||||
#: index, the second integer is a total count of objects for the fragment, the third integer is
|
||||
#: a total size of the objects for the fragment.
|
||||
stats_update: typing.List[int]
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> HeapStatsUpdate:
|
||||
return cls(
|
||||
stats_update=[int(i) for i in json['statsUpdate']]
|
||||
)
|
||||
|
||||
|
||||
@event_class('HeapProfiler.lastSeenObjectId')
|
||||
@dataclass
|
||||
class LastSeenObjectId:
|
||||
'''
|
||||
If heap objects tracking has been started then backend regularly sends a current value for last
|
||||
seen object id and corresponding timestamp. If the were changes in the heap since last event
|
||||
then one or more heapStatsUpdate events will be sent before a new lastSeenObjectId event.
|
||||
'''
|
||||
last_seen_object_id: int
|
||||
timestamp: float
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> LastSeenObjectId:
|
||||
return cls(
|
||||
last_seen_object_id=int(json['lastSeenObjectId']),
|
||||
timestamp=float(json['timestamp'])
|
||||
)
|
||||
|
||||
|
||||
@event_class('HeapProfiler.reportHeapSnapshotProgress')
|
||||
@dataclass
|
||||
class ReportHeapSnapshotProgress:
|
||||
done: int
|
||||
total: int
|
||||
finished: typing.Optional[bool]
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> ReportHeapSnapshotProgress:
|
||||
return cls(
|
||||
done=int(json['done']),
|
||||
total=int(json['total']),
|
||||
finished=bool(json['finished']) if json.get('finished', None) is not None else None
|
||||
)
|
||||
|
||||
|
||||
@event_class('HeapProfiler.resetProfiles')
|
||||
@dataclass
|
||||
class ResetProfiles:
|
||||
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> ResetProfiles:
|
||||
return cls(
|
||||
|
||||
)
|
||||
@@ -0,0 +1,528 @@
|
||||
# DO NOT EDIT THIS FILE!
|
||||
#
|
||||
# This file is generated from the CDP specification. If you need to make
|
||||
# changes, edit the generator and regenerate all of the modules.
|
||||
#
|
||||
# CDP domain: IndexedDB (experimental)
|
||||
|
||||
from __future__ import annotations
|
||||
import enum
|
||||
import typing
|
||||
from dataclasses import dataclass
|
||||
from .util import event_class, T_JSON_DICT
|
||||
|
||||
from . import runtime
|
||||
from . import storage
|
||||
|
||||
|
||||
@dataclass
|
||||
class DatabaseWithObjectStores:
|
||||
'''
|
||||
Database with an array of object stores.
|
||||
'''
|
||||
#: Database name.
|
||||
name: str
|
||||
|
||||
#: Database version (type is not 'integer', as the standard
|
||||
#: requires the version number to be 'unsigned long long')
|
||||
version: float
|
||||
|
||||
#: Object stores in this database.
|
||||
object_stores: typing.List[ObjectStore]
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['name'] = self.name
|
||||
json['version'] = self.version
|
||||
json['objectStores'] = [i.to_json() for i in self.object_stores]
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> DatabaseWithObjectStores:
|
||||
return cls(
|
||||
name=str(json['name']),
|
||||
version=float(json['version']),
|
||||
object_stores=[ObjectStore.from_json(i) for i in json['objectStores']],
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class ObjectStore:
|
||||
'''
|
||||
Object store.
|
||||
'''
|
||||
#: Object store name.
|
||||
name: str
|
||||
|
||||
#: Object store key path.
|
||||
key_path: KeyPath
|
||||
|
||||
#: If true, object store has auto increment flag set.
|
||||
auto_increment: bool
|
||||
|
||||
#: Indexes in this object store.
|
||||
indexes: typing.List[ObjectStoreIndex]
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['name'] = self.name
|
||||
json['keyPath'] = self.key_path.to_json()
|
||||
json['autoIncrement'] = self.auto_increment
|
||||
json['indexes'] = [i.to_json() for i in self.indexes]
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> ObjectStore:
|
||||
return cls(
|
||||
name=str(json['name']),
|
||||
key_path=KeyPath.from_json(json['keyPath']),
|
||||
auto_increment=bool(json['autoIncrement']),
|
||||
indexes=[ObjectStoreIndex.from_json(i) for i in json['indexes']],
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class ObjectStoreIndex:
|
||||
'''
|
||||
Object store index.
|
||||
'''
|
||||
#: Index name.
|
||||
name: str
|
||||
|
||||
#: Index key path.
|
||||
key_path: KeyPath
|
||||
|
||||
#: If true, index is unique.
|
||||
unique: bool
|
||||
|
||||
#: If true, index allows multiple entries for a key.
|
||||
multi_entry: bool
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['name'] = self.name
|
||||
json['keyPath'] = self.key_path.to_json()
|
||||
json['unique'] = self.unique
|
||||
json['multiEntry'] = self.multi_entry
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> ObjectStoreIndex:
|
||||
return cls(
|
||||
name=str(json['name']),
|
||||
key_path=KeyPath.from_json(json['keyPath']),
|
||||
unique=bool(json['unique']),
|
||||
multi_entry=bool(json['multiEntry']),
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class Key:
|
||||
'''
|
||||
Key.
|
||||
'''
|
||||
#: Key type.
|
||||
type_: str
|
||||
|
||||
#: Number value.
|
||||
number: typing.Optional[float] = None
|
||||
|
||||
#: String value.
|
||||
string: typing.Optional[str] = None
|
||||
|
||||
#: Date value.
|
||||
date: typing.Optional[float] = None
|
||||
|
||||
#: Array value.
|
||||
array: typing.Optional[typing.List[Key]] = None
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['type'] = self.type_
|
||||
if self.number is not None:
|
||||
json['number'] = self.number
|
||||
if self.string is not None:
|
||||
json['string'] = self.string
|
||||
if self.date is not None:
|
||||
json['date'] = self.date
|
||||
if self.array is not None:
|
||||
json['array'] = [i.to_json() for i in self.array]
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> Key:
|
||||
return cls(
|
||||
type_=str(json['type']),
|
||||
number=float(json['number']) if json.get('number', None) is not None else None,
|
||||
string=str(json['string']) if json.get('string', None) is not None else None,
|
||||
date=float(json['date']) if json.get('date', None) is not None else None,
|
||||
array=[Key.from_json(i) for i in json['array']] if json.get('array', None) is not None else None,
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class KeyRange:
|
||||
'''
|
||||
Key range.
|
||||
'''
|
||||
#: If true lower bound is open.
|
||||
lower_open: bool
|
||||
|
||||
#: If true upper bound is open.
|
||||
upper_open: bool
|
||||
|
||||
#: Lower bound.
|
||||
lower: typing.Optional[Key] = None
|
||||
|
||||
#: Upper bound.
|
||||
upper: typing.Optional[Key] = None
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['lowerOpen'] = self.lower_open
|
||||
json['upperOpen'] = self.upper_open
|
||||
if self.lower is not None:
|
||||
json['lower'] = self.lower.to_json()
|
||||
if self.upper is not None:
|
||||
json['upper'] = self.upper.to_json()
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> KeyRange:
|
||||
return cls(
|
||||
lower_open=bool(json['lowerOpen']),
|
||||
upper_open=bool(json['upperOpen']),
|
||||
lower=Key.from_json(json['lower']) if json.get('lower', None) is not None else None,
|
||||
upper=Key.from_json(json['upper']) if json.get('upper', None) is not None else None,
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class DataEntry:
|
||||
'''
|
||||
Data entry.
|
||||
'''
|
||||
#: Key object.
|
||||
key: runtime.RemoteObject
|
||||
|
||||
#: Primary key object.
|
||||
primary_key: runtime.RemoteObject
|
||||
|
||||
#: Value object.
|
||||
value: runtime.RemoteObject
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['key'] = self.key.to_json()
|
||||
json['primaryKey'] = self.primary_key.to_json()
|
||||
json['value'] = self.value.to_json()
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> DataEntry:
|
||||
return cls(
|
||||
key=runtime.RemoteObject.from_json(json['key']),
|
||||
primary_key=runtime.RemoteObject.from_json(json['primaryKey']),
|
||||
value=runtime.RemoteObject.from_json(json['value']),
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class KeyPath:
|
||||
'''
|
||||
Key path.
|
||||
'''
|
||||
#: Key path type.
|
||||
type_: str
|
||||
|
||||
#: String value.
|
||||
string: typing.Optional[str] = None
|
||||
|
||||
#: Array value.
|
||||
array: typing.Optional[typing.List[str]] = None
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['type'] = self.type_
|
||||
if self.string is not None:
|
||||
json['string'] = self.string
|
||||
if self.array is not None:
|
||||
json['array'] = [i for i in self.array]
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> KeyPath:
|
||||
return cls(
|
||||
type_=str(json['type']),
|
||||
string=str(json['string']) if json.get('string', None) is not None else None,
|
||||
array=[str(i) for i in json['array']] if json.get('array', None) is not None else None,
|
||||
)
|
||||
|
||||
|
||||
def clear_object_store(
|
||||
database_name: str,
|
||||
object_store_name: str,
|
||||
security_origin: typing.Optional[str] = None,
|
||||
storage_key: typing.Optional[str] = None,
|
||||
storage_bucket: typing.Optional[storage.StorageBucket] = None
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Clears all entries from an object store.
|
||||
|
||||
:param security_origin: *(Optional)* At least and at most one of securityOrigin, storageKey, or storageBucket must be specified. Security origin.
|
||||
:param storage_key: *(Optional)* Storage key.
|
||||
:param storage_bucket: *(Optional)* Storage bucket. If not specified, it uses the default bucket.
|
||||
:param database_name: Database name.
|
||||
:param object_store_name: Object store name.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
if security_origin is not None:
|
||||
params['securityOrigin'] = security_origin
|
||||
if storage_key is not None:
|
||||
params['storageKey'] = storage_key
|
||||
if storage_bucket is not None:
|
||||
params['storageBucket'] = storage_bucket.to_json()
|
||||
params['databaseName'] = database_name
|
||||
params['objectStoreName'] = object_store_name
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'IndexedDB.clearObjectStore',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def delete_database(
|
||||
database_name: str,
|
||||
security_origin: typing.Optional[str] = None,
|
||||
storage_key: typing.Optional[str] = None,
|
||||
storage_bucket: typing.Optional[storage.StorageBucket] = None
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Deletes a database.
|
||||
|
||||
:param security_origin: *(Optional)* At least and at most one of securityOrigin, storageKey, or storageBucket must be specified. Security origin.
|
||||
:param storage_key: *(Optional)* Storage key.
|
||||
:param storage_bucket: *(Optional)* Storage bucket. If not specified, it uses the default bucket.
|
||||
:param database_name: Database name.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
if security_origin is not None:
|
||||
params['securityOrigin'] = security_origin
|
||||
if storage_key is not None:
|
||||
params['storageKey'] = storage_key
|
||||
if storage_bucket is not None:
|
||||
params['storageBucket'] = storage_bucket.to_json()
|
||||
params['databaseName'] = database_name
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'IndexedDB.deleteDatabase',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def delete_object_store_entries(
|
||||
database_name: str,
|
||||
object_store_name: str,
|
||||
key_range: KeyRange,
|
||||
security_origin: typing.Optional[str] = None,
|
||||
storage_key: typing.Optional[str] = None,
|
||||
storage_bucket: typing.Optional[storage.StorageBucket] = None
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Delete a range of entries from an object store
|
||||
|
||||
:param security_origin: *(Optional)* At least and at most one of securityOrigin, storageKey, or storageBucket must be specified. Security origin.
|
||||
:param storage_key: *(Optional)* Storage key.
|
||||
:param storage_bucket: *(Optional)* Storage bucket. If not specified, it uses the default bucket.
|
||||
:param database_name:
|
||||
:param object_store_name:
|
||||
:param key_range: Range of entry keys to delete
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
if security_origin is not None:
|
||||
params['securityOrigin'] = security_origin
|
||||
if storage_key is not None:
|
||||
params['storageKey'] = storage_key
|
||||
if storage_bucket is not None:
|
||||
params['storageBucket'] = storage_bucket.to_json()
|
||||
params['databaseName'] = database_name
|
||||
params['objectStoreName'] = object_store_name
|
||||
params['keyRange'] = key_range.to_json()
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'IndexedDB.deleteObjectStoreEntries',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def disable() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Disables events from backend.
|
||||
'''
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'IndexedDB.disable',
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def enable() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Enables events from backend.
|
||||
'''
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'IndexedDB.enable',
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def request_data(
|
||||
database_name: str,
|
||||
object_store_name: str,
|
||||
skip_count: int,
|
||||
page_size: int,
|
||||
security_origin: typing.Optional[str] = None,
|
||||
storage_key: typing.Optional[str] = None,
|
||||
storage_bucket: typing.Optional[storage.StorageBucket] = None,
|
||||
index_name: typing.Optional[str] = None,
|
||||
key_range: typing.Optional[KeyRange] = None
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.Tuple[typing.List[DataEntry], bool]]:
|
||||
'''
|
||||
Requests data from object store or index.
|
||||
|
||||
:param security_origin: *(Optional)* At least and at most one of securityOrigin, storageKey, or storageBucket must be specified. Security origin.
|
||||
:param storage_key: *(Optional)* Storage key.
|
||||
:param storage_bucket: *(Optional)* Storage bucket. If not specified, it uses the default bucket.
|
||||
:param database_name: Database name.
|
||||
:param object_store_name: Object store name.
|
||||
:param index_name: *(Optional)* Index name. If not specified, it performs an object store data request.
|
||||
:param skip_count: Number of records to skip.
|
||||
:param page_size: Number of records to fetch.
|
||||
:param key_range: *(Optional)* Key range.
|
||||
:returns: A tuple with the following items:
|
||||
|
||||
0. **objectStoreDataEntries** - Array of object store data entries.
|
||||
1. **hasMore** - If true, there are more entries to fetch in the given range.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
if security_origin is not None:
|
||||
params['securityOrigin'] = security_origin
|
||||
if storage_key is not None:
|
||||
params['storageKey'] = storage_key
|
||||
if storage_bucket is not None:
|
||||
params['storageBucket'] = storage_bucket.to_json()
|
||||
params['databaseName'] = database_name
|
||||
params['objectStoreName'] = object_store_name
|
||||
if index_name is not None:
|
||||
params['indexName'] = index_name
|
||||
params['skipCount'] = skip_count
|
||||
params['pageSize'] = page_size
|
||||
if key_range is not None:
|
||||
params['keyRange'] = key_range.to_json()
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'IndexedDB.requestData',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
return (
|
||||
[DataEntry.from_json(i) for i in json['objectStoreDataEntries']],
|
||||
bool(json['hasMore'])
|
||||
)
|
||||
|
||||
|
||||
def get_metadata(
|
||||
database_name: str,
|
||||
object_store_name: str,
|
||||
security_origin: typing.Optional[str] = None,
|
||||
storage_key: typing.Optional[str] = None,
|
||||
storage_bucket: typing.Optional[storage.StorageBucket] = None
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.Tuple[float, float]]:
|
||||
'''
|
||||
Gets metadata of an object store.
|
||||
|
||||
:param security_origin: *(Optional)* At least and at most one of securityOrigin, storageKey, or storageBucket must be specified. Security origin.
|
||||
:param storage_key: *(Optional)* Storage key.
|
||||
:param storage_bucket: *(Optional)* Storage bucket. If not specified, it uses the default bucket.
|
||||
:param database_name: Database name.
|
||||
:param object_store_name: Object store name.
|
||||
:returns: A tuple with the following items:
|
||||
|
||||
0. **entriesCount** - the entries count
|
||||
1. **keyGeneratorValue** - the current value of key generator, to become the next inserted key into the object store. Valid if objectStore.autoIncrement is true.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
if security_origin is not None:
|
||||
params['securityOrigin'] = security_origin
|
||||
if storage_key is not None:
|
||||
params['storageKey'] = storage_key
|
||||
if storage_bucket is not None:
|
||||
params['storageBucket'] = storage_bucket.to_json()
|
||||
params['databaseName'] = database_name
|
||||
params['objectStoreName'] = object_store_name
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'IndexedDB.getMetadata',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
return (
|
||||
float(json['entriesCount']),
|
||||
float(json['keyGeneratorValue'])
|
||||
)
|
||||
|
||||
|
||||
def request_database(
|
||||
database_name: str,
|
||||
security_origin: typing.Optional[str] = None,
|
||||
storage_key: typing.Optional[str] = None,
|
||||
storage_bucket: typing.Optional[storage.StorageBucket] = None
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,DatabaseWithObjectStores]:
|
||||
'''
|
||||
Requests database with given name in given frame.
|
||||
|
||||
:param security_origin: *(Optional)* At least and at most one of securityOrigin, storageKey, or storageBucket must be specified. Security origin.
|
||||
:param storage_key: *(Optional)* Storage key.
|
||||
:param storage_bucket: *(Optional)* Storage bucket. If not specified, it uses the default bucket.
|
||||
:param database_name: Database name.
|
||||
:returns: Database with an array of object stores.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
if security_origin is not None:
|
||||
params['securityOrigin'] = security_origin
|
||||
if storage_key is not None:
|
||||
params['storageKey'] = storage_key
|
||||
if storage_bucket is not None:
|
||||
params['storageBucket'] = storage_bucket.to_json()
|
||||
params['databaseName'] = database_name
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'IndexedDB.requestDatabase',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
return DatabaseWithObjectStores.from_json(json['databaseWithObjectStores'])
|
||||
|
||||
|
||||
def request_database_names(
|
||||
security_origin: typing.Optional[str] = None,
|
||||
storage_key: typing.Optional[str] = None,
|
||||
storage_bucket: typing.Optional[storage.StorageBucket] = None
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.List[str]]:
|
||||
'''
|
||||
Requests database names for given security origin.
|
||||
|
||||
:param security_origin: *(Optional)* At least and at most one of securityOrigin, storageKey, or storageBucket must be specified. Security origin.
|
||||
:param storage_key: *(Optional)* Storage key.
|
||||
:param storage_bucket: *(Optional)* Storage bucket. If not specified, it uses the default bucket.
|
||||
:returns: Database names for origin.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
if security_origin is not None:
|
||||
params['securityOrigin'] = security_origin
|
||||
if storage_key is not None:
|
||||
params['storageKey'] = storage_key
|
||||
if storage_bucket is not None:
|
||||
params['storageBucket'] = storage_bucket.to_json()
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'IndexedDB.requestDatabaseNames',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
return [str(i) for i in json['databaseNames']]
|
||||
@@ -0,0 +1,701 @@
|
||||
# DO NOT EDIT THIS FILE!
|
||||
#
|
||||
# This file is generated from the CDP specification. If you need to make
|
||||
# changes, edit the generator and regenerate all of the modules.
|
||||
#
|
||||
# CDP domain: Input
|
||||
|
||||
from __future__ import annotations
|
||||
import enum
|
||||
import typing
|
||||
from dataclasses import dataclass
|
||||
from .util import event_class, T_JSON_DICT
|
||||
|
||||
|
||||
@dataclass
|
||||
class TouchPoint:
|
||||
#: X coordinate of the event relative to the main frame's viewport in CSS pixels.
|
||||
x: float
|
||||
|
||||
#: Y coordinate of the event relative to the main frame's viewport in CSS pixels. 0 refers to
|
||||
#: the top of the viewport and Y increases as it proceeds towards the bottom of the viewport.
|
||||
y: float
|
||||
|
||||
#: X radius of the touch area (default: 1.0).
|
||||
radius_x: typing.Optional[float] = None
|
||||
|
||||
#: Y radius of the touch area (default: 1.0).
|
||||
radius_y: typing.Optional[float] = None
|
||||
|
||||
#: Rotation angle (default: 0.0).
|
||||
rotation_angle: typing.Optional[float] = None
|
||||
|
||||
#: Force (default: 1.0).
|
||||
force: typing.Optional[float] = None
|
||||
|
||||
#: The normalized tangential pressure, which has a range of [-1,1] (default: 0).
|
||||
tangential_pressure: typing.Optional[float] = None
|
||||
|
||||
#: The plane angle between the Y-Z plane and the plane containing both the stylus axis and the Y axis, in degrees of the range [-90,90], a positive tiltX is to the right (default: 0)
|
||||
tilt_x: typing.Optional[float] = None
|
||||
|
||||
#: The plane angle between the X-Z plane and the plane containing both the stylus axis and the X axis, in degrees of the range [-90,90], a positive tiltY is towards the user (default: 0).
|
||||
tilt_y: typing.Optional[float] = None
|
||||
|
||||
#: The clockwise rotation of a pen stylus around its own major axis, in degrees in the range [0,359] (default: 0).
|
||||
twist: typing.Optional[int] = None
|
||||
|
||||
#: Identifier used to track touch sources between events, must be unique within an event.
|
||||
id_: typing.Optional[float] = None
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['x'] = self.x
|
||||
json['y'] = self.y
|
||||
if self.radius_x is not None:
|
||||
json['radiusX'] = self.radius_x
|
||||
if self.radius_y is not None:
|
||||
json['radiusY'] = self.radius_y
|
||||
if self.rotation_angle is not None:
|
||||
json['rotationAngle'] = self.rotation_angle
|
||||
if self.force is not None:
|
||||
json['force'] = self.force
|
||||
if self.tangential_pressure is not None:
|
||||
json['tangentialPressure'] = self.tangential_pressure
|
||||
if self.tilt_x is not None:
|
||||
json['tiltX'] = self.tilt_x
|
||||
if self.tilt_y is not None:
|
||||
json['tiltY'] = self.tilt_y
|
||||
if self.twist is not None:
|
||||
json['twist'] = self.twist
|
||||
if self.id_ is not None:
|
||||
json['id'] = self.id_
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> TouchPoint:
|
||||
return cls(
|
||||
x=float(json['x']),
|
||||
y=float(json['y']),
|
||||
radius_x=float(json['radiusX']) if json.get('radiusX', None) is not None else None,
|
||||
radius_y=float(json['radiusY']) if json.get('radiusY', None) is not None else None,
|
||||
rotation_angle=float(json['rotationAngle']) if json.get('rotationAngle', None) is not None else None,
|
||||
force=float(json['force']) if json.get('force', None) is not None else None,
|
||||
tangential_pressure=float(json['tangentialPressure']) if json.get('tangentialPressure', None) is not None else None,
|
||||
tilt_x=float(json['tiltX']) if json.get('tiltX', None) is not None else None,
|
||||
tilt_y=float(json['tiltY']) if json.get('tiltY', None) is not None else None,
|
||||
twist=int(json['twist']) if json.get('twist', None) is not None else None,
|
||||
id_=float(json['id']) if json.get('id', None) is not None else None,
|
||||
)
|
||||
|
||||
|
||||
class GestureSourceType(enum.Enum):
|
||||
DEFAULT = "default"
|
||||
TOUCH = "touch"
|
||||
MOUSE = "mouse"
|
||||
|
||||
def to_json(self) -> str:
|
||||
return self.value
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: str) -> GestureSourceType:
|
||||
return cls(json)
|
||||
|
||||
|
||||
class MouseButton(enum.Enum):
|
||||
NONE = "none"
|
||||
LEFT = "left"
|
||||
MIDDLE = "middle"
|
||||
RIGHT = "right"
|
||||
BACK = "back"
|
||||
FORWARD = "forward"
|
||||
|
||||
def to_json(self) -> str:
|
||||
return self.value
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: str) -> MouseButton:
|
||||
return cls(json)
|
||||
|
||||
|
||||
class TimeSinceEpoch(float):
|
||||
'''
|
||||
UTC time in seconds, counted from January 1, 1970.
|
||||
'''
|
||||
def to_json(self) -> float:
|
||||
return self
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: float) -> TimeSinceEpoch:
|
||||
return cls(json)
|
||||
|
||||
def __repr__(self):
|
||||
return 'TimeSinceEpoch({})'.format(super().__repr__())
|
||||
|
||||
|
||||
@dataclass
|
||||
class DragDataItem:
|
||||
#: Mime type of the dragged data.
|
||||
mime_type: str
|
||||
|
||||
#: Depending of the value of ``mimeType``, it contains the dragged link,
|
||||
#: text, HTML markup or any other data.
|
||||
data: str
|
||||
|
||||
#: Title associated with a link. Only valid when ``mimeType`` == "text/uri-list".
|
||||
title: typing.Optional[str] = None
|
||||
|
||||
#: Stores the base URL for the contained markup. Only valid when ``mimeType``
|
||||
#: == "text/html".
|
||||
base_url: typing.Optional[str] = None
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['mimeType'] = self.mime_type
|
||||
json['data'] = self.data
|
||||
if self.title is not None:
|
||||
json['title'] = self.title
|
||||
if self.base_url is not None:
|
||||
json['baseURL'] = self.base_url
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> DragDataItem:
|
||||
return cls(
|
||||
mime_type=str(json['mimeType']),
|
||||
data=str(json['data']),
|
||||
title=str(json['title']) if json.get('title', None) is not None else None,
|
||||
base_url=str(json['baseURL']) if json.get('baseURL', None) is not None else None,
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class DragData:
|
||||
items: typing.List[DragDataItem]
|
||||
|
||||
#: Bit field representing allowed drag operations. Copy = 1, Link = 2, Move = 16
|
||||
drag_operations_mask: int
|
||||
|
||||
#: List of filenames that should be included when dropping
|
||||
files: typing.Optional[typing.List[str]] = None
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['items'] = [i.to_json() for i in self.items]
|
||||
json['dragOperationsMask'] = self.drag_operations_mask
|
||||
if self.files is not None:
|
||||
json['files'] = [i for i in self.files]
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> DragData:
|
||||
return cls(
|
||||
items=[DragDataItem.from_json(i) for i in json['items']],
|
||||
drag_operations_mask=int(json['dragOperationsMask']),
|
||||
files=[str(i) for i in json['files']] if json.get('files', None) is not None else None,
|
||||
)
|
||||
|
||||
|
||||
def dispatch_drag_event(
|
||||
type_: str,
|
||||
x: float,
|
||||
y: float,
|
||||
data: DragData,
|
||||
modifiers: typing.Optional[int] = None
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Dispatches a drag event into the page.
|
||||
|
||||
**EXPERIMENTAL**
|
||||
|
||||
:param type_: Type of the drag event.
|
||||
:param x: X coordinate of the event relative to the main frame's viewport in CSS pixels.
|
||||
:param y: Y coordinate of the event relative to the main frame's viewport in CSS pixels. 0 refers to the top of the viewport and Y increases as it proceeds towards the bottom of the viewport.
|
||||
:param data:
|
||||
:param modifiers: *(Optional)* Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8 (default: 0).
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['type'] = type_
|
||||
params['x'] = x
|
||||
params['y'] = y
|
||||
params['data'] = data.to_json()
|
||||
if modifiers is not None:
|
||||
params['modifiers'] = modifiers
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Input.dispatchDragEvent',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def dispatch_key_event(
|
||||
type_: str,
|
||||
modifiers: typing.Optional[int] = None,
|
||||
timestamp: typing.Optional[TimeSinceEpoch] = None,
|
||||
text: typing.Optional[str] = None,
|
||||
unmodified_text: typing.Optional[str] = None,
|
||||
key_identifier: typing.Optional[str] = None,
|
||||
code: typing.Optional[str] = None,
|
||||
key: typing.Optional[str] = None,
|
||||
windows_virtual_key_code: typing.Optional[int] = None,
|
||||
native_virtual_key_code: typing.Optional[int] = None,
|
||||
auto_repeat: typing.Optional[bool] = None,
|
||||
is_keypad: typing.Optional[bool] = None,
|
||||
is_system_key: typing.Optional[bool] = None,
|
||||
location: typing.Optional[int] = None,
|
||||
commands: typing.Optional[typing.List[str]] = None
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Dispatches a key event to the page.
|
||||
|
||||
:param type_: Type of the key event.
|
||||
:param modifiers: *(Optional)* Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8 (default: 0).
|
||||
:param timestamp: *(Optional)* Time at which the event occurred.
|
||||
:param text: *(Optional)* Text as generated by processing a virtual key code with a keyboard layout. Not needed for for ```keyUp```` and ````rawKeyDown```` events (default: "")
|
||||
:param unmodified_text: *(Optional)* Text that would have been generated by the keyboard if no modifiers were pressed (except for shift). Useful for shortcut (accelerator) key handling (default: "").
|
||||
:param key_identifier: *(Optional)* Unique key identifier (e.g., 'U+0041') (default: "").
|
||||
:param code: *(Optional)* Unique DOM defined string value for each physical key (e.g., 'KeyA') (default: "").
|
||||
:param key: *(Optional)* Unique DOM defined string value describing the meaning of the key in the context of active modifiers, keyboard layout, etc (e.g., 'AltGr') (default: "").
|
||||
:param windows_virtual_key_code: *(Optional)* Windows virtual key code (default: 0).
|
||||
:param native_virtual_key_code: *(Optional)* Native virtual key code (default: 0).
|
||||
:param auto_repeat: *(Optional)* Whether the event was generated from auto repeat (default: false).
|
||||
:param is_keypad: *(Optional)* Whether the event was generated from the keypad (default: false).
|
||||
:param is_system_key: *(Optional)* Whether the event was a system key event (default: false).
|
||||
:param location: *(Optional)* Whether the event was from the left or right side of the keyboard. 1=Left, 2=Right (default: 0).
|
||||
:param commands: **(EXPERIMENTAL)** *(Optional)* Editing commands to send with the key event (e.g., 'selectAll') (default: []). These are related to but not equal the command names used in ````document.execCommand``` and NSStandardKeyBindingResponding. See https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/editing/commands/editor_command_names.h for valid command names.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['type'] = type_
|
||||
if modifiers is not None:
|
||||
params['modifiers'] = modifiers
|
||||
if timestamp is not None:
|
||||
params['timestamp'] = timestamp.to_json()
|
||||
if text is not None:
|
||||
params['text'] = text
|
||||
if unmodified_text is not None:
|
||||
params['unmodifiedText'] = unmodified_text
|
||||
if key_identifier is not None:
|
||||
params['keyIdentifier'] = key_identifier
|
||||
if code is not None:
|
||||
params['code'] = code
|
||||
if key is not None:
|
||||
params['key'] = key
|
||||
if windows_virtual_key_code is not None:
|
||||
params['windowsVirtualKeyCode'] = windows_virtual_key_code
|
||||
if native_virtual_key_code is not None:
|
||||
params['nativeVirtualKeyCode'] = native_virtual_key_code
|
||||
if auto_repeat is not None:
|
||||
params['autoRepeat'] = auto_repeat
|
||||
if is_keypad is not None:
|
||||
params['isKeypad'] = is_keypad
|
||||
if is_system_key is not None:
|
||||
params['isSystemKey'] = is_system_key
|
||||
if location is not None:
|
||||
params['location'] = location
|
||||
if commands is not None:
|
||||
params['commands'] = [i for i in commands]
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Input.dispatchKeyEvent',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def insert_text(
|
||||
text: str
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
This method emulates inserting text that doesn't come from a key press,
|
||||
for example an emoji keyboard or an IME.
|
||||
|
||||
**EXPERIMENTAL**
|
||||
|
||||
:param text: The text to insert.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['text'] = text
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Input.insertText',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def ime_set_composition(
|
||||
text: str,
|
||||
selection_start: int,
|
||||
selection_end: int,
|
||||
replacement_start: typing.Optional[int] = None,
|
||||
replacement_end: typing.Optional[int] = None
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
This method sets the current candidate text for IME.
|
||||
Use imeCommitComposition to commit the final text.
|
||||
Use imeSetComposition with empty string as text to cancel composition.
|
||||
|
||||
**EXPERIMENTAL**
|
||||
|
||||
:param text: The text to insert
|
||||
:param selection_start: selection start
|
||||
:param selection_end: selection end
|
||||
:param replacement_start: *(Optional)* replacement start
|
||||
:param replacement_end: *(Optional)* replacement end
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['text'] = text
|
||||
params['selectionStart'] = selection_start
|
||||
params['selectionEnd'] = selection_end
|
||||
if replacement_start is not None:
|
||||
params['replacementStart'] = replacement_start
|
||||
if replacement_end is not None:
|
||||
params['replacementEnd'] = replacement_end
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Input.imeSetComposition',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def dispatch_mouse_event(
|
||||
type_: str,
|
||||
x: float,
|
||||
y: float,
|
||||
modifiers: typing.Optional[int] = None,
|
||||
timestamp: typing.Optional[TimeSinceEpoch] = None,
|
||||
button: typing.Optional[MouseButton] = None,
|
||||
buttons: typing.Optional[int] = None,
|
||||
click_count: typing.Optional[int] = None,
|
||||
force: typing.Optional[float] = None,
|
||||
tangential_pressure: typing.Optional[float] = None,
|
||||
tilt_x: typing.Optional[float] = None,
|
||||
tilt_y: typing.Optional[float] = None,
|
||||
twist: typing.Optional[int] = None,
|
||||
delta_x: typing.Optional[float] = None,
|
||||
delta_y: typing.Optional[float] = None,
|
||||
pointer_type: typing.Optional[str] = None
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Dispatches a mouse event to the page.
|
||||
|
||||
:param type_: Type of the mouse event.
|
||||
:param x: X coordinate of the event relative to the main frame's viewport in CSS pixels.
|
||||
:param y: Y coordinate of the event relative to the main frame's viewport in CSS pixels. 0 refers to the top of the viewport and Y increases as it proceeds towards the bottom of the viewport.
|
||||
:param modifiers: *(Optional)* Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8 (default: 0).
|
||||
:param timestamp: *(Optional)* Time at which the event occurred.
|
||||
:param button: *(Optional)* Mouse button (default: "none").
|
||||
:param buttons: *(Optional)* A number indicating which buttons are pressed on the mouse when a mouse event is triggered. Left=1, Right=2, Middle=4, Back=8, Forward=16, None=0.
|
||||
:param click_count: *(Optional)* Number of times the mouse button was clicked (default: 0).
|
||||
:param force: **(EXPERIMENTAL)** *(Optional)* The normalized pressure, which has a range of [0,1] (default: 0).
|
||||
:param tangential_pressure: **(EXPERIMENTAL)** *(Optional)* The normalized tangential pressure, which has a range of [-1,1] (default: 0).
|
||||
:param tilt_x: *(Optional)* The plane angle between the Y-Z plane and the plane containing both the stylus axis and the Y axis, in degrees of the range [-90,90], a positive tiltX is to the right (default: 0).
|
||||
:param tilt_y: *(Optional)* The plane angle between the X-Z plane and the plane containing both the stylus axis and the X axis, in degrees of the range [-90,90], a positive tiltY is towards the user (default: 0).
|
||||
:param twist: **(EXPERIMENTAL)** *(Optional)* The clockwise rotation of a pen stylus around its own major axis, in degrees in the range [0,359] (default: 0).
|
||||
:param delta_x: *(Optional)* X delta in CSS pixels for mouse wheel event (default: 0).
|
||||
:param delta_y: *(Optional)* Y delta in CSS pixels for mouse wheel event (default: 0).
|
||||
:param pointer_type: *(Optional)* Pointer type (default: "mouse").
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['type'] = type_
|
||||
params['x'] = x
|
||||
params['y'] = y
|
||||
if modifiers is not None:
|
||||
params['modifiers'] = modifiers
|
||||
if timestamp is not None:
|
||||
params['timestamp'] = timestamp.to_json()
|
||||
if button is not None:
|
||||
params['button'] = button.to_json()
|
||||
if buttons is not None:
|
||||
params['buttons'] = buttons
|
||||
if click_count is not None:
|
||||
params['clickCount'] = click_count
|
||||
if force is not None:
|
||||
params['force'] = force
|
||||
if tangential_pressure is not None:
|
||||
params['tangentialPressure'] = tangential_pressure
|
||||
if tilt_x is not None:
|
||||
params['tiltX'] = tilt_x
|
||||
if tilt_y is not None:
|
||||
params['tiltY'] = tilt_y
|
||||
if twist is not None:
|
||||
params['twist'] = twist
|
||||
if delta_x is not None:
|
||||
params['deltaX'] = delta_x
|
||||
if delta_y is not None:
|
||||
params['deltaY'] = delta_y
|
||||
if pointer_type is not None:
|
||||
params['pointerType'] = pointer_type
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Input.dispatchMouseEvent',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def dispatch_touch_event(
|
||||
type_: str,
|
||||
touch_points: typing.List[TouchPoint],
|
||||
modifiers: typing.Optional[int] = None,
|
||||
timestamp: typing.Optional[TimeSinceEpoch] = None
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Dispatches a touch event to the page.
|
||||
|
||||
:param type_: Type of the touch event. TouchEnd and TouchCancel must not contain any touch points, while TouchStart and TouchMove must contains at least one.
|
||||
:param touch_points: Active touch points on the touch device. One event per any changed point (compared to previous touch event in a sequence) is generated, emulating pressing/moving/releasing points one by one.
|
||||
:param modifiers: *(Optional)* Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8 (default: 0).
|
||||
:param timestamp: *(Optional)* Time at which the event occurred.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['type'] = type_
|
||||
params['touchPoints'] = [i.to_json() for i in touch_points]
|
||||
if modifiers is not None:
|
||||
params['modifiers'] = modifiers
|
||||
if timestamp is not None:
|
||||
params['timestamp'] = timestamp.to_json()
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Input.dispatchTouchEvent',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def cancel_dragging() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Cancels any active dragging in the page.
|
||||
'''
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Input.cancelDragging',
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def emulate_touch_from_mouse_event(
|
||||
type_: str,
|
||||
x: int,
|
||||
y: int,
|
||||
button: MouseButton,
|
||||
timestamp: typing.Optional[TimeSinceEpoch] = None,
|
||||
delta_x: typing.Optional[float] = None,
|
||||
delta_y: typing.Optional[float] = None,
|
||||
modifiers: typing.Optional[int] = None,
|
||||
click_count: typing.Optional[int] = None
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Emulates touch event from the mouse event parameters.
|
||||
|
||||
**EXPERIMENTAL**
|
||||
|
||||
:param type_: Type of the mouse event.
|
||||
:param x: X coordinate of the mouse pointer in DIP.
|
||||
:param y: Y coordinate of the mouse pointer in DIP.
|
||||
:param button: Mouse button. Only "none", "left", "right" are supported.
|
||||
:param timestamp: *(Optional)* Time at which the event occurred (default: current time).
|
||||
:param delta_x: *(Optional)* X delta in DIP for mouse wheel event (default: 0).
|
||||
:param delta_y: *(Optional)* Y delta in DIP for mouse wheel event (default: 0).
|
||||
:param modifiers: *(Optional)* Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8 (default: 0).
|
||||
:param click_count: *(Optional)* Number of times the mouse button was clicked (default: 0).
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['type'] = type_
|
||||
params['x'] = x
|
||||
params['y'] = y
|
||||
params['button'] = button.to_json()
|
||||
if timestamp is not None:
|
||||
params['timestamp'] = timestamp.to_json()
|
||||
if delta_x is not None:
|
||||
params['deltaX'] = delta_x
|
||||
if delta_y is not None:
|
||||
params['deltaY'] = delta_y
|
||||
if modifiers is not None:
|
||||
params['modifiers'] = modifiers
|
||||
if click_count is not None:
|
||||
params['clickCount'] = click_count
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Input.emulateTouchFromMouseEvent',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def set_ignore_input_events(
|
||||
ignore: bool
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Ignores input events (useful while auditing page).
|
||||
|
||||
:param ignore: Ignores input events processing when set to true.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['ignore'] = ignore
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Input.setIgnoreInputEvents',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def set_intercept_drags(
|
||||
enabled: bool
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Prevents default drag and drop behavior and instead emits ``Input.dragIntercepted`` events.
|
||||
Drag and drop behavior can be directly controlled via ``Input.dispatchDragEvent``.
|
||||
|
||||
**EXPERIMENTAL**
|
||||
|
||||
:param enabled:
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['enabled'] = enabled
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Input.setInterceptDrags',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def synthesize_pinch_gesture(
|
||||
x: float,
|
||||
y: float,
|
||||
scale_factor: float,
|
||||
relative_speed: typing.Optional[int] = None,
|
||||
gesture_source_type: typing.Optional[GestureSourceType] = None
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Synthesizes a pinch gesture over a time period by issuing appropriate touch events.
|
||||
|
||||
**EXPERIMENTAL**
|
||||
|
||||
:param x: X coordinate of the start of the gesture in CSS pixels.
|
||||
:param y: Y coordinate of the start of the gesture in CSS pixels.
|
||||
:param scale_factor: Relative scale factor after zooming (>1.0 zooms in, <1.0 zooms out).
|
||||
:param relative_speed: *(Optional)* Relative pointer speed in pixels per second (default: 800).
|
||||
:param gesture_source_type: *(Optional)* Which type of input events to be generated (default: 'default', which queries the platform for the preferred input type).
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['x'] = x
|
||||
params['y'] = y
|
||||
params['scaleFactor'] = scale_factor
|
||||
if relative_speed is not None:
|
||||
params['relativeSpeed'] = relative_speed
|
||||
if gesture_source_type is not None:
|
||||
params['gestureSourceType'] = gesture_source_type.to_json()
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Input.synthesizePinchGesture',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def synthesize_scroll_gesture(
|
||||
x: float,
|
||||
y: float,
|
||||
x_distance: typing.Optional[float] = None,
|
||||
y_distance: typing.Optional[float] = None,
|
||||
x_overscroll: typing.Optional[float] = None,
|
||||
y_overscroll: typing.Optional[float] = None,
|
||||
prevent_fling: typing.Optional[bool] = None,
|
||||
speed: typing.Optional[int] = None,
|
||||
gesture_source_type: typing.Optional[GestureSourceType] = None,
|
||||
repeat_count: typing.Optional[int] = None,
|
||||
repeat_delay_ms: typing.Optional[int] = None,
|
||||
interaction_marker_name: typing.Optional[str] = None
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Synthesizes a scroll gesture over a time period by issuing appropriate touch events.
|
||||
|
||||
**EXPERIMENTAL**
|
||||
|
||||
:param x: X coordinate of the start of the gesture in CSS pixels.
|
||||
:param y: Y coordinate of the start of the gesture in CSS pixels.
|
||||
:param x_distance: *(Optional)* The distance to scroll along the X axis (positive to scroll left).
|
||||
:param y_distance: *(Optional)* The distance to scroll along the Y axis (positive to scroll up).
|
||||
:param x_overscroll: *(Optional)* The number of additional pixels to scroll back along the X axis, in addition to the given distance.
|
||||
:param y_overscroll: *(Optional)* The number of additional pixels to scroll back along the Y axis, in addition to the given distance.
|
||||
:param prevent_fling: *(Optional)* Prevent fling (default: true).
|
||||
:param speed: *(Optional)* Swipe speed in pixels per second (default: 800).
|
||||
:param gesture_source_type: *(Optional)* Which type of input events to be generated (default: 'default', which queries the platform for the preferred input type).
|
||||
:param repeat_count: *(Optional)* The number of times to repeat the gesture (default: 0).
|
||||
:param repeat_delay_ms: *(Optional)* The number of milliseconds delay between each repeat. (default: 250).
|
||||
:param interaction_marker_name: *(Optional)* The name of the interaction markers to generate, if not empty (default: "").
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['x'] = x
|
||||
params['y'] = y
|
||||
if x_distance is not None:
|
||||
params['xDistance'] = x_distance
|
||||
if y_distance is not None:
|
||||
params['yDistance'] = y_distance
|
||||
if x_overscroll is not None:
|
||||
params['xOverscroll'] = x_overscroll
|
||||
if y_overscroll is not None:
|
||||
params['yOverscroll'] = y_overscroll
|
||||
if prevent_fling is not None:
|
||||
params['preventFling'] = prevent_fling
|
||||
if speed is not None:
|
||||
params['speed'] = speed
|
||||
if gesture_source_type is not None:
|
||||
params['gestureSourceType'] = gesture_source_type.to_json()
|
||||
if repeat_count is not None:
|
||||
params['repeatCount'] = repeat_count
|
||||
if repeat_delay_ms is not None:
|
||||
params['repeatDelayMs'] = repeat_delay_ms
|
||||
if interaction_marker_name is not None:
|
||||
params['interactionMarkerName'] = interaction_marker_name
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Input.synthesizeScrollGesture',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def synthesize_tap_gesture(
|
||||
x: float,
|
||||
y: float,
|
||||
duration: typing.Optional[int] = None,
|
||||
tap_count: typing.Optional[int] = None,
|
||||
gesture_source_type: typing.Optional[GestureSourceType] = None
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Synthesizes a tap gesture over a time period by issuing appropriate touch events.
|
||||
|
||||
**EXPERIMENTAL**
|
||||
|
||||
:param x: X coordinate of the start of the gesture in CSS pixels.
|
||||
:param y: Y coordinate of the start of the gesture in CSS pixels.
|
||||
:param duration: *(Optional)* Duration between touchdown and touchup events in ms (default: 50).
|
||||
:param tap_count: *(Optional)* Number of times to perform the tap (e.g. 2 for double tap, default: 1).
|
||||
:param gesture_source_type: *(Optional)* Which type of input events to be generated (default: 'default', which queries the platform for the preferred input type).
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['x'] = x
|
||||
params['y'] = y
|
||||
if duration is not None:
|
||||
params['duration'] = duration
|
||||
if tap_count is not None:
|
||||
params['tapCount'] = tap_count
|
||||
if gesture_source_type is not None:
|
||||
params['gestureSourceType'] = gesture_source_type.to_json()
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Input.synthesizeTapGesture',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
@event_class('Input.dragIntercepted')
|
||||
@dataclass
|
||||
class DragIntercepted:
|
||||
'''
|
||||
**EXPERIMENTAL**
|
||||
|
||||
Emitted only when ``Input.setInterceptDrags`` is enabled. Use this data with ``Input.dispatchDragEvent`` to
|
||||
restore normal drag and drop behavior.
|
||||
'''
|
||||
data: DragData
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> DragIntercepted:
|
||||
return cls(
|
||||
data=DragData.from_json(json['data'])
|
||||
)
|
||||
@@ -0,0 +1,95 @@
|
||||
# DO NOT EDIT THIS FILE!
|
||||
#
|
||||
# This file is generated from the CDP specification. If you need to make
|
||||
# changes, edit the generator and regenerate all of the modules.
|
||||
#
|
||||
# CDP domain: Inspector (experimental)
|
||||
|
||||
from __future__ import annotations
|
||||
import enum
|
||||
import typing
|
||||
from dataclasses import dataclass
|
||||
from .util import event_class, T_JSON_DICT
|
||||
|
||||
|
||||
def disable() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Disables inspector domain notifications.
|
||||
'''
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Inspector.disable',
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def enable() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Enables inspector domain notifications.
|
||||
'''
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Inspector.enable',
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
@event_class('Inspector.detached')
|
||||
@dataclass
|
||||
class Detached:
|
||||
'''
|
||||
Fired when remote debugging connection is about to be terminated. Contains detach reason.
|
||||
'''
|
||||
#: The reason why connection has been terminated.
|
||||
reason: str
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> Detached:
|
||||
return cls(
|
||||
reason=str(json['reason'])
|
||||
)
|
||||
|
||||
|
||||
@event_class('Inspector.targetCrashed')
|
||||
@dataclass
|
||||
class TargetCrashed:
|
||||
'''
|
||||
Fired when debugging target has crashed
|
||||
'''
|
||||
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> TargetCrashed:
|
||||
return cls(
|
||||
|
||||
)
|
||||
|
||||
|
||||
@event_class('Inspector.targetReloadedAfterCrash')
|
||||
@dataclass
|
||||
class TargetReloadedAfterCrash:
|
||||
'''
|
||||
Fired when debugging target has reloaded after crash
|
||||
'''
|
||||
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> TargetReloadedAfterCrash:
|
||||
return cls(
|
||||
|
||||
)
|
||||
|
||||
|
||||
@event_class('Inspector.workerScriptLoaded')
|
||||
@dataclass
|
||||
class WorkerScriptLoaded:
|
||||
'''
|
||||
**EXPERIMENTAL**
|
||||
|
||||
Fired on worker targets when main worker script and any imported scripts have been evaluated.
|
||||
'''
|
||||
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> WorkerScriptLoaded:
|
||||
return cls(
|
||||
|
||||
)
|
||||
@@ -0,0 +1,101 @@
|
||||
# DO NOT EDIT THIS FILE!
|
||||
#
|
||||
# This file is generated from the CDP specification. If you need to make
|
||||
# changes, edit the generator and regenerate all of the modules.
|
||||
#
|
||||
# CDP domain: IO
|
||||
|
||||
from __future__ import annotations
|
||||
import enum
|
||||
import typing
|
||||
from dataclasses import dataclass
|
||||
from .util import event_class, T_JSON_DICT
|
||||
|
||||
from . import runtime
|
||||
|
||||
|
||||
class StreamHandle(str):
|
||||
'''
|
||||
This is either obtained from another method or specified as ``blob:<uuid>`` where
|
||||
``<uuid>`` is an UUID of a Blob.
|
||||
'''
|
||||
def to_json(self) -> str:
|
||||
return self
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: str) -> StreamHandle:
|
||||
return cls(json)
|
||||
|
||||
def __repr__(self):
|
||||
return 'StreamHandle({})'.format(super().__repr__())
|
||||
|
||||
|
||||
def close(
|
||||
handle: StreamHandle
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Close the stream, discard any temporary backing storage.
|
||||
|
||||
:param handle: Handle of the stream to close.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['handle'] = handle.to_json()
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'IO.close',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def read(
|
||||
handle: StreamHandle,
|
||||
offset: typing.Optional[int] = None,
|
||||
size: typing.Optional[int] = None
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.Tuple[typing.Optional[bool], str, bool]]:
|
||||
'''
|
||||
Read a chunk of the stream
|
||||
|
||||
:param handle: Handle of the stream to read.
|
||||
:param offset: *(Optional)* Seek to the specified offset before reading (if not specified, proceed with offset following the last read). Some types of streams may only support sequential reads.
|
||||
:param size: *(Optional)* Maximum number of bytes to read (left upon the agent discretion if not specified).
|
||||
:returns: A tuple with the following items:
|
||||
|
||||
0. **base64Encoded** - *(Optional)* Set if the data is base64-encoded
|
||||
1. **data** - Data that were read.
|
||||
2. **eof** - Set if the end-of-file condition occurred while reading.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['handle'] = handle.to_json()
|
||||
if offset is not None:
|
||||
params['offset'] = offset
|
||||
if size is not None:
|
||||
params['size'] = size
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'IO.read',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
return (
|
||||
bool(json['base64Encoded']) if json.get('base64Encoded', None) is not None else None,
|
||||
str(json['data']),
|
||||
bool(json['eof'])
|
||||
)
|
||||
|
||||
|
||||
def resolve_blob(
|
||||
object_id: runtime.RemoteObjectId
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,str]:
|
||||
'''
|
||||
Return UUID of Blob object specified by a remote object id.
|
||||
|
||||
:param object_id: Object id of a Blob object wrapper.
|
||||
:returns: UUID of the specified Blob.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['objectId'] = object_id.to_json()
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'IO.resolveBlob',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
return str(json['uuid'])
|
||||
@@ -0,0 +1,464 @@
|
||||
# DO NOT EDIT THIS FILE!
|
||||
#
|
||||
# This file is generated from the CDP specification. If you need to make
|
||||
# changes, edit the generator and regenerate all of the modules.
|
||||
#
|
||||
# CDP domain: LayerTree (experimental)
|
||||
|
||||
from __future__ import annotations
|
||||
import enum
|
||||
import typing
|
||||
from dataclasses import dataclass
|
||||
from .util import event_class, T_JSON_DICT
|
||||
|
||||
from . import dom
|
||||
|
||||
|
||||
class LayerId(str):
|
||||
'''
|
||||
Unique Layer identifier.
|
||||
'''
|
||||
def to_json(self) -> str:
|
||||
return self
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: str) -> LayerId:
|
||||
return cls(json)
|
||||
|
||||
def __repr__(self):
|
||||
return 'LayerId({})'.format(super().__repr__())
|
||||
|
||||
|
||||
class SnapshotId(str):
|
||||
'''
|
||||
Unique snapshot identifier.
|
||||
'''
|
||||
def to_json(self) -> str:
|
||||
return self
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: str) -> SnapshotId:
|
||||
return cls(json)
|
||||
|
||||
def __repr__(self):
|
||||
return 'SnapshotId({})'.format(super().__repr__())
|
||||
|
||||
|
||||
@dataclass
|
||||
class ScrollRect:
|
||||
'''
|
||||
Rectangle where scrolling happens on the main thread.
|
||||
'''
|
||||
#: Rectangle itself.
|
||||
rect: dom.Rect
|
||||
|
||||
#: Reason for rectangle to force scrolling on the main thread
|
||||
type_: str
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['rect'] = self.rect.to_json()
|
||||
json['type'] = self.type_
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> ScrollRect:
|
||||
return cls(
|
||||
rect=dom.Rect.from_json(json['rect']),
|
||||
type_=str(json['type']),
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class StickyPositionConstraint:
|
||||
'''
|
||||
Sticky position constraints.
|
||||
'''
|
||||
#: Layout rectangle of the sticky element before being shifted
|
||||
sticky_box_rect: dom.Rect
|
||||
|
||||
#: Layout rectangle of the containing block of the sticky element
|
||||
containing_block_rect: dom.Rect
|
||||
|
||||
#: The nearest sticky layer that shifts the sticky box
|
||||
nearest_layer_shifting_sticky_box: typing.Optional[LayerId] = None
|
||||
|
||||
#: The nearest sticky layer that shifts the containing block
|
||||
nearest_layer_shifting_containing_block: typing.Optional[LayerId] = None
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['stickyBoxRect'] = self.sticky_box_rect.to_json()
|
||||
json['containingBlockRect'] = self.containing_block_rect.to_json()
|
||||
if self.nearest_layer_shifting_sticky_box is not None:
|
||||
json['nearestLayerShiftingStickyBox'] = self.nearest_layer_shifting_sticky_box.to_json()
|
||||
if self.nearest_layer_shifting_containing_block is not None:
|
||||
json['nearestLayerShiftingContainingBlock'] = self.nearest_layer_shifting_containing_block.to_json()
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> StickyPositionConstraint:
|
||||
return cls(
|
||||
sticky_box_rect=dom.Rect.from_json(json['stickyBoxRect']),
|
||||
containing_block_rect=dom.Rect.from_json(json['containingBlockRect']),
|
||||
nearest_layer_shifting_sticky_box=LayerId.from_json(json['nearestLayerShiftingStickyBox']) if json.get('nearestLayerShiftingStickyBox', None) is not None else None,
|
||||
nearest_layer_shifting_containing_block=LayerId.from_json(json['nearestLayerShiftingContainingBlock']) if json.get('nearestLayerShiftingContainingBlock', None) is not None else None,
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class PictureTile:
|
||||
'''
|
||||
Serialized fragment of layer picture along with its offset within the layer.
|
||||
'''
|
||||
#: Offset from owning layer left boundary
|
||||
x: float
|
||||
|
||||
#: Offset from owning layer top boundary
|
||||
y: float
|
||||
|
||||
#: Base64-encoded snapshot data. (Encoded as a base64 string when passed over JSON)
|
||||
picture: str
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['x'] = self.x
|
||||
json['y'] = self.y
|
||||
json['picture'] = self.picture
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> PictureTile:
|
||||
return cls(
|
||||
x=float(json['x']),
|
||||
y=float(json['y']),
|
||||
picture=str(json['picture']),
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class Layer:
|
||||
'''
|
||||
Information about a compositing layer.
|
||||
'''
|
||||
#: The unique id for this layer.
|
||||
layer_id: LayerId
|
||||
|
||||
#: Offset from parent layer, X coordinate.
|
||||
offset_x: float
|
||||
|
||||
#: Offset from parent layer, Y coordinate.
|
||||
offset_y: float
|
||||
|
||||
#: Layer width.
|
||||
width: float
|
||||
|
||||
#: Layer height.
|
||||
height: float
|
||||
|
||||
#: Indicates how many time this layer has painted.
|
||||
paint_count: int
|
||||
|
||||
#: Indicates whether this layer hosts any content, rather than being used for
|
||||
#: transform/scrolling purposes only.
|
||||
draws_content: bool
|
||||
|
||||
#: The id of parent (not present for root).
|
||||
parent_layer_id: typing.Optional[LayerId] = None
|
||||
|
||||
#: The backend id for the node associated with this layer.
|
||||
backend_node_id: typing.Optional[dom.BackendNodeId] = None
|
||||
|
||||
#: Transformation matrix for layer, default is identity matrix
|
||||
transform: typing.Optional[typing.List[float]] = None
|
||||
|
||||
#: Transform anchor point X, absent if no transform specified
|
||||
anchor_x: typing.Optional[float] = None
|
||||
|
||||
#: Transform anchor point Y, absent if no transform specified
|
||||
anchor_y: typing.Optional[float] = None
|
||||
|
||||
#: Transform anchor point Z, absent if no transform specified
|
||||
anchor_z: typing.Optional[float] = None
|
||||
|
||||
#: Set if layer is not visible.
|
||||
invisible: typing.Optional[bool] = None
|
||||
|
||||
#: Rectangles scrolling on main thread only.
|
||||
scroll_rects: typing.Optional[typing.List[ScrollRect]] = None
|
||||
|
||||
#: Sticky position constraint information
|
||||
sticky_position_constraint: typing.Optional[StickyPositionConstraint] = None
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['layerId'] = self.layer_id.to_json()
|
||||
json['offsetX'] = self.offset_x
|
||||
json['offsetY'] = self.offset_y
|
||||
json['width'] = self.width
|
||||
json['height'] = self.height
|
||||
json['paintCount'] = self.paint_count
|
||||
json['drawsContent'] = self.draws_content
|
||||
if self.parent_layer_id is not None:
|
||||
json['parentLayerId'] = self.parent_layer_id.to_json()
|
||||
if self.backend_node_id is not None:
|
||||
json['backendNodeId'] = self.backend_node_id.to_json()
|
||||
if self.transform is not None:
|
||||
json['transform'] = [i for i in self.transform]
|
||||
if self.anchor_x is not None:
|
||||
json['anchorX'] = self.anchor_x
|
||||
if self.anchor_y is not None:
|
||||
json['anchorY'] = self.anchor_y
|
||||
if self.anchor_z is not None:
|
||||
json['anchorZ'] = self.anchor_z
|
||||
if self.invisible is not None:
|
||||
json['invisible'] = self.invisible
|
||||
if self.scroll_rects is not None:
|
||||
json['scrollRects'] = [i.to_json() for i in self.scroll_rects]
|
||||
if self.sticky_position_constraint is not None:
|
||||
json['stickyPositionConstraint'] = self.sticky_position_constraint.to_json()
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> Layer:
|
||||
return cls(
|
||||
layer_id=LayerId.from_json(json['layerId']),
|
||||
offset_x=float(json['offsetX']),
|
||||
offset_y=float(json['offsetY']),
|
||||
width=float(json['width']),
|
||||
height=float(json['height']),
|
||||
paint_count=int(json['paintCount']),
|
||||
draws_content=bool(json['drawsContent']),
|
||||
parent_layer_id=LayerId.from_json(json['parentLayerId']) if json.get('parentLayerId', None) is not None else None,
|
||||
backend_node_id=dom.BackendNodeId.from_json(json['backendNodeId']) if json.get('backendNodeId', None) is not None else None,
|
||||
transform=[float(i) for i in json['transform']] if json.get('transform', None) is not None else None,
|
||||
anchor_x=float(json['anchorX']) if json.get('anchorX', None) is not None else None,
|
||||
anchor_y=float(json['anchorY']) if json.get('anchorY', None) is not None else None,
|
||||
anchor_z=float(json['anchorZ']) if json.get('anchorZ', None) is not None else None,
|
||||
invisible=bool(json['invisible']) if json.get('invisible', None) is not None else None,
|
||||
scroll_rects=[ScrollRect.from_json(i) for i in json['scrollRects']] if json.get('scrollRects', None) is not None else None,
|
||||
sticky_position_constraint=StickyPositionConstraint.from_json(json['stickyPositionConstraint']) if json.get('stickyPositionConstraint', None) is not None else None,
|
||||
)
|
||||
|
||||
|
||||
class PaintProfile(list):
|
||||
'''
|
||||
Array of timings, one per paint step.
|
||||
'''
|
||||
def to_json(self) -> typing.List[float]:
|
||||
return self
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: typing.List[float]) -> PaintProfile:
|
||||
return cls(json)
|
||||
|
||||
def __repr__(self):
|
||||
return 'PaintProfile({})'.format(super().__repr__())
|
||||
|
||||
|
||||
def compositing_reasons(
|
||||
layer_id: LayerId
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.Tuple[typing.List[str], typing.List[str]]]:
|
||||
'''
|
||||
Provides the reasons why the given layer was composited.
|
||||
|
||||
:param layer_id: The id of the layer for which we want to get the reasons it was composited.
|
||||
:returns: A tuple with the following items:
|
||||
|
||||
0. **compositingReasons** - A list of strings specifying reasons for the given layer to become composited.
|
||||
1. **compositingReasonIds** - A list of strings specifying reason IDs for the given layer to become composited.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['layerId'] = layer_id.to_json()
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'LayerTree.compositingReasons',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
return (
|
||||
[str(i) for i in json['compositingReasons']],
|
||||
[str(i) for i in json['compositingReasonIds']]
|
||||
)
|
||||
|
||||
|
||||
def disable() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Disables compositing tree inspection.
|
||||
'''
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'LayerTree.disable',
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def enable() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Enables compositing tree inspection.
|
||||
'''
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'LayerTree.enable',
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def load_snapshot(
|
||||
tiles: typing.List[PictureTile]
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,SnapshotId]:
|
||||
'''
|
||||
Returns the snapshot identifier.
|
||||
|
||||
:param tiles: An array of tiles composing the snapshot.
|
||||
:returns: The id of the snapshot.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['tiles'] = [i.to_json() for i in tiles]
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'LayerTree.loadSnapshot',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
return SnapshotId.from_json(json['snapshotId'])
|
||||
|
||||
|
||||
def make_snapshot(
|
||||
layer_id: LayerId
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,SnapshotId]:
|
||||
'''
|
||||
Returns the layer snapshot identifier.
|
||||
|
||||
:param layer_id: The id of the layer.
|
||||
:returns: The id of the layer snapshot.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['layerId'] = layer_id.to_json()
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'LayerTree.makeSnapshot',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
return SnapshotId.from_json(json['snapshotId'])
|
||||
|
||||
|
||||
def profile_snapshot(
|
||||
snapshot_id: SnapshotId,
|
||||
min_repeat_count: typing.Optional[int] = None,
|
||||
min_duration: typing.Optional[float] = None,
|
||||
clip_rect: typing.Optional[dom.Rect] = None
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.List[PaintProfile]]:
|
||||
'''
|
||||
:param snapshot_id: The id of the layer snapshot.
|
||||
:param min_repeat_count: *(Optional)* The maximum number of times to replay the snapshot (1, if not specified).
|
||||
:param min_duration: *(Optional)* The minimum duration (in seconds) to replay the snapshot.
|
||||
:param clip_rect: *(Optional)* The clip rectangle to apply when replaying the snapshot.
|
||||
:returns: The array of paint profiles, one per run.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['snapshotId'] = snapshot_id.to_json()
|
||||
if min_repeat_count is not None:
|
||||
params['minRepeatCount'] = min_repeat_count
|
||||
if min_duration is not None:
|
||||
params['minDuration'] = min_duration
|
||||
if clip_rect is not None:
|
||||
params['clipRect'] = clip_rect.to_json()
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'LayerTree.profileSnapshot',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
return [PaintProfile.from_json(i) for i in json['timings']]
|
||||
|
||||
|
||||
def release_snapshot(
|
||||
snapshot_id: SnapshotId
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Releases layer snapshot captured by the back-end.
|
||||
|
||||
:param snapshot_id: The id of the layer snapshot.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['snapshotId'] = snapshot_id.to_json()
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'LayerTree.releaseSnapshot',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def replay_snapshot(
|
||||
snapshot_id: SnapshotId,
|
||||
from_step: typing.Optional[int] = None,
|
||||
to_step: typing.Optional[int] = None,
|
||||
scale: typing.Optional[float] = None
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,str]:
|
||||
'''
|
||||
Replays the layer snapshot and returns the resulting bitmap.
|
||||
|
||||
:param snapshot_id: The id of the layer snapshot.
|
||||
:param from_step: *(Optional)* The first step to replay from (replay from the very start if not specified).
|
||||
:param to_step: *(Optional)* The last step to replay to (replay till the end if not specified).
|
||||
:param scale: *(Optional)* The scale to apply while replaying (defaults to 1).
|
||||
:returns: A data: URL for resulting image.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['snapshotId'] = snapshot_id.to_json()
|
||||
if from_step is not None:
|
||||
params['fromStep'] = from_step
|
||||
if to_step is not None:
|
||||
params['toStep'] = to_step
|
||||
if scale is not None:
|
||||
params['scale'] = scale
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'LayerTree.replaySnapshot',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
return str(json['dataURL'])
|
||||
|
||||
|
||||
def snapshot_command_log(
|
||||
snapshot_id: SnapshotId
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.List[dict]]:
|
||||
'''
|
||||
Replays the layer snapshot and returns canvas log.
|
||||
|
||||
:param snapshot_id: The id of the layer snapshot.
|
||||
:returns: The array of canvas function calls.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['snapshotId'] = snapshot_id.to_json()
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'LayerTree.snapshotCommandLog',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
return [dict(i) for i in json['commandLog']]
|
||||
|
||||
|
||||
@event_class('LayerTree.layerPainted')
|
||||
@dataclass
|
||||
class LayerPainted:
|
||||
#: The id of the painted layer.
|
||||
layer_id: LayerId
|
||||
#: Clip rectangle.
|
||||
clip: dom.Rect
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> LayerPainted:
|
||||
return cls(
|
||||
layer_id=LayerId.from_json(json['layerId']),
|
||||
clip=dom.Rect.from_json(json['clip'])
|
||||
)
|
||||
|
||||
|
||||
@event_class('LayerTree.layerTreeDidChange')
|
||||
@dataclass
|
||||
class LayerTreeDidChange:
|
||||
#: Layer tree, absent if not in the compositing mode.
|
||||
layers: typing.Optional[typing.List[Layer]]
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> LayerTreeDidChange:
|
||||
return cls(
|
||||
layers=[Layer.from_json(i) for i in json['layers']] if json.get('layers', None) is not None else None
|
||||
)
|
||||
@@ -0,0 +1,190 @@
|
||||
# DO NOT EDIT THIS FILE!
|
||||
#
|
||||
# This file is generated from the CDP specification. If you need to make
|
||||
# changes, edit the generator and regenerate all of the modules.
|
||||
#
|
||||
# CDP domain: Log
|
||||
|
||||
from __future__ import annotations
|
||||
import enum
|
||||
import typing
|
||||
from dataclasses import dataclass
|
||||
from .util import event_class, T_JSON_DICT
|
||||
|
||||
from . import network
|
||||
from . import runtime
|
||||
|
||||
|
||||
@dataclass
|
||||
class LogEntry:
|
||||
'''
|
||||
Log entry.
|
||||
'''
|
||||
#: Log entry source.
|
||||
source: str
|
||||
|
||||
#: Log entry severity.
|
||||
level: str
|
||||
|
||||
#: Logged text.
|
||||
text: str
|
||||
|
||||
#: Timestamp when this entry was added.
|
||||
timestamp: runtime.Timestamp
|
||||
|
||||
category: typing.Optional[str] = None
|
||||
|
||||
#: URL of the resource if known.
|
||||
url: typing.Optional[str] = None
|
||||
|
||||
#: Line number in the resource.
|
||||
line_number: typing.Optional[int] = None
|
||||
|
||||
#: JavaScript stack trace.
|
||||
stack_trace: typing.Optional[runtime.StackTrace] = None
|
||||
|
||||
#: Identifier of the network request associated with this entry.
|
||||
network_request_id: typing.Optional[network.RequestId] = None
|
||||
|
||||
#: Identifier of the worker associated with this entry.
|
||||
worker_id: typing.Optional[str] = None
|
||||
|
||||
#: Call arguments.
|
||||
args: typing.Optional[typing.List[runtime.RemoteObject]] = None
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['source'] = self.source
|
||||
json['level'] = self.level
|
||||
json['text'] = self.text
|
||||
json['timestamp'] = self.timestamp.to_json()
|
||||
if self.category is not None:
|
||||
json['category'] = self.category
|
||||
if self.url is not None:
|
||||
json['url'] = self.url
|
||||
if self.line_number is not None:
|
||||
json['lineNumber'] = self.line_number
|
||||
if self.stack_trace is not None:
|
||||
json['stackTrace'] = self.stack_trace.to_json()
|
||||
if self.network_request_id is not None:
|
||||
json['networkRequestId'] = self.network_request_id.to_json()
|
||||
if self.worker_id is not None:
|
||||
json['workerId'] = self.worker_id
|
||||
if self.args is not None:
|
||||
json['args'] = [i.to_json() for i in self.args]
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> LogEntry:
|
||||
return cls(
|
||||
source=str(json['source']),
|
||||
level=str(json['level']),
|
||||
text=str(json['text']),
|
||||
timestamp=runtime.Timestamp.from_json(json['timestamp']),
|
||||
category=str(json['category']) if json.get('category', None) is not None else None,
|
||||
url=str(json['url']) if json.get('url', None) is not None else None,
|
||||
line_number=int(json['lineNumber']) if json.get('lineNumber', None) is not None else None,
|
||||
stack_trace=runtime.StackTrace.from_json(json['stackTrace']) if json.get('stackTrace', None) is not None else None,
|
||||
network_request_id=network.RequestId.from_json(json['networkRequestId']) if json.get('networkRequestId', None) is not None else None,
|
||||
worker_id=str(json['workerId']) if json.get('workerId', None) is not None else None,
|
||||
args=[runtime.RemoteObject.from_json(i) for i in json['args']] if json.get('args', None) is not None else None,
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class ViolationSetting:
|
||||
'''
|
||||
Violation configuration setting.
|
||||
'''
|
||||
#: Violation type.
|
||||
name: str
|
||||
|
||||
#: Time threshold to trigger upon.
|
||||
threshold: float
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['name'] = self.name
|
||||
json['threshold'] = self.threshold
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> ViolationSetting:
|
||||
return cls(
|
||||
name=str(json['name']),
|
||||
threshold=float(json['threshold']),
|
||||
)
|
||||
|
||||
|
||||
def clear() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Clears the log.
|
||||
'''
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Log.clear',
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def disable() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Disables log domain, prevents further log entries from being reported to the client.
|
||||
'''
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Log.disable',
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def enable() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Enables log domain, sends the entries collected so far to the client by means of the
|
||||
``entryAdded`` notification.
|
||||
'''
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Log.enable',
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def start_violations_report(
|
||||
config: typing.List[ViolationSetting]
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
start violation reporting.
|
||||
|
||||
:param config: Configuration for violations.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['config'] = [i.to_json() for i in config]
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Log.startViolationsReport',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def stop_violations_report() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Stop violation reporting.
|
||||
'''
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Log.stopViolationsReport',
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
@event_class('Log.entryAdded')
|
||||
@dataclass
|
||||
class EntryAdded:
|
||||
'''
|
||||
Issued when new message was logged.
|
||||
'''
|
||||
#: The entry.
|
||||
entry: LogEntry
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> EntryAdded:
|
||||
return cls(
|
||||
entry=LogEntry.from_json(json['entry'])
|
||||
)
|
||||
@@ -0,0 +1,313 @@
|
||||
# DO NOT EDIT THIS FILE!
|
||||
#
|
||||
# This file is generated from the CDP specification. If you need to make
|
||||
# changes, edit the generator and regenerate all of the modules.
|
||||
#
|
||||
# CDP domain: Media (experimental)
|
||||
|
||||
from __future__ import annotations
|
||||
import enum
|
||||
import typing
|
||||
from dataclasses import dataclass
|
||||
from .util import event_class, T_JSON_DICT
|
||||
|
||||
from . import dom
|
||||
|
||||
|
||||
class PlayerId(str):
|
||||
'''
|
||||
Players will get an ID that is unique within the agent context.
|
||||
'''
|
||||
def to_json(self) -> str:
|
||||
return self
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: str) -> PlayerId:
|
||||
return cls(json)
|
||||
|
||||
def __repr__(self):
|
||||
return 'PlayerId({})'.format(super().__repr__())
|
||||
|
||||
|
||||
class Timestamp(float):
|
||||
def to_json(self) -> float:
|
||||
return self
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: float) -> Timestamp:
|
||||
return cls(json)
|
||||
|
||||
def __repr__(self):
|
||||
return 'Timestamp({})'.format(super().__repr__())
|
||||
|
||||
|
||||
@dataclass
|
||||
class PlayerMessage:
|
||||
'''
|
||||
Have one type per entry in MediaLogRecord::Type
|
||||
Corresponds to kMessage
|
||||
'''
|
||||
#: Keep in sync with MediaLogMessageLevel
|
||||
#: We are currently keeping the message level 'error' separate from the
|
||||
#: PlayerError type because right now they represent different things,
|
||||
#: this one being a DVLOG(ERROR) style log message that gets printed
|
||||
#: based on what log level is selected in the UI, and the other is a
|
||||
#: representation of a media::PipelineStatus object. Soon however we're
|
||||
#: going to be moving away from using PipelineStatus for errors and
|
||||
#: introducing a new error type which should hopefully let us integrate
|
||||
#: the error log level into the PlayerError type.
|
||||
level: str
|
||||
|
||||
message: str
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['level'] = self.level
|
||||
json['message'] = self.message
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> PlayerMessage:
|
||||
return cls(
|
||||
level=str(json['level']),
|
||||
message=str(json['message']),
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class PlayerProperty:
|
||||
'''
|
||||
Corresponds to kMediaPropertyChange
|
||||
'''
|
||||
name: str
|
||||
|
||||
value: str
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['name'] = self.name
|
||||
json['value'] = self.value
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> PlayerProperty:
|
||||
return cls(
|
||||
name=str(json['name']),
|
||||
value=str(json['value']),
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class PlayerEvent:
|
||||
'''
|
||||
Corresponds to kMediaEventTriggered
|
||||
'''
|
||||
timestamp: Timestamp
|
||||
|
||||
value: str
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['timestamp'] = self.timestamp.to_json()
|
||||
json['value'] = self.value
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> PlayerEvent:
|
||||
return cls(
|
||||
timestamp=Timestamp.from_json(json['timestamp']),
|
||||
value=str(json['value']),
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class PlayerErrorSourceLocation:
|
||||
'''
|
||||
Represents logged source line numbers reported in an error.
|
||||
NOTE: file and line are from chromium c++ implementation code, not js.
|
||||
'''
|
||||
file: str
|
||||
|
||||
line: int
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['file'] = self.file
|
||||
json['line'] = self.line
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> PlayerErrorSourceLocation:
|
||||
return cls(
|
||||
file=str(json['file']),
|
||||
line=int(json['line']),
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class PlayerError:
|
||||
'''
|
||||
Corresponds to kMediaError
|
||||
'''
|
||||
error_type: str
|
||||
|
||||
#: Code is the numeric enum entry for a specific set of error codes, such
|
||||
#: as PipelineStatusCodes in media/base/pipeline_status.h
|
||||
code: int
|
||||
|
||||
#: A trace of where this error was caused / where it passed through.
|
||||
stack: typing.List[PlayerErrorSourceLocation]
|
||||
|
||||
#: Errors potentially have a root cause error, ie, a DecoderError might be
|
||||
#: caused by an WindowsError
|
||||
cause: typing.List[PlayerError]
|
||||
|
||||
#: Extra data attached to an error, such as an HRESULT, Video Codec, etc.
|
||||
data: dict
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['errorType'] = self.error_type
|
||||
json['code'] = self.code
|
||||
json['stack'] = [i.to_json() for i in self.stack]
|
||||
json['cause'] = [i.to_json() for i in self.cause]
|
||||
json['data'] = self.data
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> PlayerError:
|
||||
return cls(
|
||||
error_type=str(json['errorType']),
|
||||
code=int(json['code']),
|
||||
stack=[PlayerErrorSourceLocation.from_json(i) for i in json['stack']],
|
||||
cause=[PlayerError.from_json(i) for i in json['cause']],
|
||||
data=dict(json['data']),
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class Player:
|
||||
player_id: PlayerId
|
||||
|
||||
dom_node_id: typing.Optional[dom.BackendNodeId] = None
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['playerId'] = self.player_id.to_json()
|
||||
if self.dom_node_id is not None:
|
||||
json['domNodeId'] = self.dom_node_id.to_json()
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> Player:
|
||||
return cls(
|
||||
player_id=PlayerId.from_json(json['playerId']),
|
||||
dom_node_id=dom.BackendNodeId.from_json(json['domNodeId']) if json.get('domNodeId', None) is not None else None,
|
||||
)
|
||||
|
||||
|
||||
def enable() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Enables the Media domain
|
||||
'''
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Media.enable',
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def disable() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Disables the Media domain.
|
||||
'''
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Media.disable',
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
@event_class('Media.playerPropertiesChanged')
|
||||
@dataclass
|
||||
class PlayerPropertiesChanged:
|
||||
'''
|
||||
This can be called multiple times, and can be used to set / override /
|
||||
remove player properties. A null propValue indicates removal.
|
||||
'''
|
||||
player_id: PlayerId
|
||||
properties: typing.List[PlayerProperty]
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> PlayerPropertiesChanged:
|
||||
return cls(
|
||||
player_id=PlayerId.from_json(json['playerId']),
|
||||
properties=[PlayerProperty.from_json(i) for i in json['properties']]
|
||||
)
|
||||
|
||||
|
||||
@event_class('Media.playerEventsAdded')
|
||||
@dataclass
|
||||
class PlayerEventsAdded:
|
||||
'''
|
||||
Send events as a list, allowing them to be batched on the browser for less
|
||||
congestion. If batched, events must ALWAYS be in chronological order.
|
||||
'''
|
||||
player_id: PlayerId
|
||||
events: typing.List[PlayerEvent]
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> PlayerEventsAdded:
|
||||
return cls(
|
||||
player_id=PlayerId.from_json(json['playerId']),
|
||||
events=[PlayerEvent.from_json(i) for i in json['events']]
|
||||
)
|
||||
|
||||
|
||||
@event_class('Media.playerMessagesLogged')
|
||||
@dataclass
|
||||
class PlayerMessagesLogged:
|
||||
'''
|
||||
Send a list of any messages that need to be delivered.
|
||||
'''
|
||||
player_id: PlayerId
|
||||
messages: typing.List[PlayerMessage]
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> PlayerMessagesLogged:
|
||||
return cls(
|
||||
player_id=PlayerId.from_json(json['playerId']),
|
||||
messages=[PlayerMessage.from_json(i) for i in json['messages']]
|
||||
)
|
||||
|
||||
|
||||
@event_class('Media.playerErrorsRaised')
|
||||
@dataclass
|
||||
class PlayerErrorsRaised:
|
||||
'''
|
||||
Send a list of any errors that need to be delivered.
|
||||
'''
|
||||
player_id: PlayerId
|
||||
errors: typing.List[PlayerError]
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> PlayerErrorsRaised:
|
||||
return cls(
|
||||
player_id=PlayerId.from_json(json['playerId']),
|
||||
errors=[PlayerError.from_json(i) for i in json['errors']]
|
||||
)
|
||||
|
||||
|
||||
@event_class('Media.playerCreated')
|
||||
@dataclass
|
||||
class PlayerCreated:
|
||||
'''
|
||||
Called whenever a player is created, or when a new agent joins and receives
|
||||
a list of active players. If an agent is restored, it will receive one
|
||||
event for each active player.
|
||||
'''
|
||||
player: Player
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> PlayerCreated:
|
||||
return cls(
|
||||
player=Player.from_json(json['player'])
|
||||
)
|
||||
@@ -0,0 +1,305 @@
|
||||
# DO NOT EDIT THIS FILE!
|
||||
#
|
||||
# This file is generated from the CDP specification. If you need to make
|
||||
# changes, edit the generator and regenerate all of the modules.
|
||||
#
|
||||
# CDP domain: Memory (experimental)
|
||||
|
||||
from __future__ import annotations
|
||||
import enum
|
||||
import typing
|
||||
from dataclasses import dataclass
|
||||
from .util import event_class, T_JSON_DICT
|
||||
|
||||
|
||||
class PressureLevel(enum.Enum):
|
||||
'''
|
||||
Memory pressure level.
|
||||
'''
|
||||
MODERATE = "moderate"
|
||||
CRITICAL = "critical"
|
||||
|
||||
def to_json(self) -> str:
|
||||
return self.value
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: str) -> PressureLevel:
|
||||
return cls(json)
|
||||
|
||||
|
||||
@dataclass
|
||||
class SamplingProfileNode:
|
||||
'''
|
||||
Heap profile sample.
|
||||
'''
|
||||
#: Size of the sampled allocation.
|
||||
size: float
|
||||
|
||||
#: Total bytes attributed to this sample.
|
||||
total: float
|
||||
|
||||
#: Execution stack at the point of allocation.
|
||||
stack: typing.List[str]
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['size'] = self.size
|
||||
json['total'] = self.total
|
||||
json['stack'] = [i for i in self.stack]
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> SamplingProfileNode:
|
||||
return cls(
|
||||
size=float(json['size']),
|
||||
total=float(json['total']),
|
||||
stack=[str(i) for i in json['stack']],
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class SamplingProfile:
|
||||
'''
|
||||
Array of heap profile samples.
|
||||
'''
|
||||
samples: typing.List[SamplingProfileNode]
|
||||
|
||||
modules: typing.List[Module]
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['samples'] = [i.to_json() for i in self.samples]
|
||||
json['modules'] = [i.to_json() for i in self.modules]
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> SamplingProfile:
|
||||
return cls(
|
||||
samples=[SamplingProfileNode.from_json(i) for i in json['samples']],
|
||||
modules=[Module.from_json(i) for i in json['modules']],
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class Module:
|
||||
'''
|
||||
Executable module information
|
||||
'''
|
||||
#: Name of the module.
|
||||
name: str
|
||||
|
||||
#: UUID of the module.
|
||||
uuid: str
|
||||
|
||||
#: Base address where the module is loaded into memory. Encoded as a decimal
|
||||
#: or hexadecimal (0x prefixed) string.
|
||||
base_address: str
|
||||
|
||||
#: Size of the module in bytes.
|
||||
size: float
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['name'] = self.name
|
||||
json['uuid'] = self.uuid
|
||||
json['baseAddress'] = self.base_address
|
||||
json['size'] = self.size
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> Module:
|
||||
return cls(
|
||||
name=str(json['name']),
|
||||
uuid=str(json['uuid']),
|
||||
base_address=str(json['baseAddress']),
|
||||
size=float(json['size']),
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class DOMCounter:
|
||||
'''
|
||||
DOM object counter data.
|
||||
'''
|
||||
#: Object name. Note: object names should be presumed volatile and clients should not expect
|
||||
#: the returned names to be consistent across runs.
|
||||
name: str
|
||||
|
||||
#: Object count.
|
||||
count: int
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['name'] = self.name
|
||||
json['count'] = self.count
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> DOMCounter:
|
||||
return cls(
|
||||
name=str(json['name']),
|
||||
count=int(json['count']),
|
||||
)
|
||||
|
||||
|
||||
def get_dom_counters() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.Tuple[int, int, int]]:
|
||||
'''
|
||||
Retruns current DOM object counters.
|
||||
|
||||
:returns: A tuple with the following items:
|
||||
|
||||
0. **documents** -
|
||||
1. **nodes** -
|
||||
2. **jsEventListeners** -
|
||||
'''
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Memory.getDOMCounters',
|
||||
}
|
||||
json = yield cmd_dict
|
||||
return (
|
||||
int(json['documents']),
|
||||
int(json['nodes']),
|
||||
int(json['jsEventListeners'])
|
||||
)
|
||||
|
||||
|
||||
def get_dom_counters_for_leak_detection() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.List[DOMCounter]]:
|
||||
'''
|
||||
Retruns DOM object counters after preparing renderer for leak detection.
|
||||
|
||||
:returns: DOM object counters.
|
||||
'''
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Memory.getDOMCountersForLeakDetection',
|
||||
}
|
||||
json = yield cmd_dict
|
||||
return [DOMCounter.from_json(i) for i in json['counters']]
|
||||
|
||||
|
||||
def prepare_for_leak_detection() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Prepares for leak detection by terminating workers, stopping spellcheckers,
|
||||
dropping non-essential internal caches, running garbage collections, etc.
|
||||
'''
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Memory.prepareForLeakDetection',
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def forcibly_purge_java_script_memory() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Simulate OomIntervention by purging V8 memory.
|
||||
'''
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Memory.forciblyPurgeJavaScriptMemory',
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def set_pressure_notifications_suppressed(
|
||||
suppressed: bool
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Enable/disable suppressing memory pressure notifications in all processes.
|
||||
|
||||
:param suppressed: If true, memory pressure notifications will be suppressed.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['suppressed'] = suppressed
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Memory.setPressureNotificationsSuppressed',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def simulate_pressure_notification(
|
||||
level: PressureLevel
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Simulate a memory pressure notification in all processes.
|
||||
|
||||
:param level: Memory pressure level of the notification.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['level'] = level.to_json()
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Memory.simulatePressureNotification',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def start_sampling(
|
||||
sampling_interval: typing.Optional[int] = None,
|
||||
suppress_randomness: typing.Optional[bool] = None
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Start collecting native memory profile.
|
||||
|
||||
:param sampling_interval: *(Optional)* Average number of bytes between samples.
|
||||
:param suppress_randomness: *(Optional)* Do not randomize intervals between samples.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
if sampling_interval is not None:
|
||||
params['samplingInterval'] = sampling_interval
|
||||
if suppress_randomness is not None:
|
||||
params['suppressRandomness'] = suppress_randomness
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Memory.startSampling',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def stop_sampling() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Stop collecting native memory profile.
|
||||
'''
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Memory.stopSampling',
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def get_all_time_sampling_profile() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,SamplingProfile]:
|
||||
'''
|
||||
Retrieve native memory allocations profile
|
||||
collected since renderer process startup.
|
||||
|
||||
:returns:
|
||||
'''
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Memory.getAllTimeSamplingProfile',
|
||||
}
|
||||
json = yield cmd_dict
|
||||
return SamplingProfile.from_json(json['profile'])
|
||||
|
||||
|
||||
def get_browser_sampling_profile() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,SamplingProfile]:
|
||||
'''
|
||||
Retrieve native memory allocations profile
|
||||
collected since browser process startup.
|
||||
|
||||
:returns:
|
||||
'''
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Memory.getBrowserSamplingProfile',
|
||||
}
|
||||
json = yield cmd_dict
|
||||
return SamplingProfile.from_json(json['profile'])
|
||||
|
||||
|
||||
def get_sampling_profile() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,SamplingProfile]:
|
||||
'''
|
||||
Retrieve native memory allocations profile collected since last
|
||||
``startSampling`` call.
|
||||
|
||||
:returns:
|
||||
'''
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Memory.getSamplingProfile',
|
||||
}
|
||||
json = yield cmd_dict
|
||||
return SamplingProfile.from_json(json['profile'])
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,124 @@
|
||||
# DO NOT EDIT THIS FILE!
|
||||
#
|
||||
# This file is generated from the CDP specification. If you need to make
|
||||
# changes, edit the generator and regenerate all of the modules.
|
||||
#
|
||||
# CDP domain: Performance
|
||||
|
||||
from __future__ import annotations
|
||||
import enum
|
||||
import typing
|
||||
from dataclasses import dataclass
|
||||
from .util import event_class, T_JSON_DICT
|
||||
|
||||
|
||||
from deprecated.sphinx import deprecated # type: ignore
|
||||
|
||||
|
||||
@dataclass
|
||||
class Metric:
|
||||
'''
|
||||
Run-time execution metric.
|
||||
'''
|
||||
#: Metric name.
|
||||
name: str
|
||||
|
||||
#: Metric value.
|
||||
value: float
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['name'] = self.name
|
||||
json['value'] = self.value
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> Metric:
|
||||
return cls(
|
||||
name=str(json['name']),
|
||||
value=float(json['value']),
|
||||
)
|
||||
|
||||
|
||||
def disable() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Disable collecting and reporting metrics.
|
||||
'''
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Performance.disable',
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def enable(
|
||||
time_domain: typing.Optional[str] = None
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Enable collecting and reporting metrics.
|
||||
|
||||
:param time_domain: *(Optional)* Time domain to use for collecting and reporting duration metrics.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
if time_domain is not None:
|
||||
params['timeDomain'] = time_domain
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Performance.enable',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
@deprecated(version="1.3")
|
||||
def set_time_domain(
|
||||
time_domain: str
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Sets time domain to use for collecting and reporting duration metrics.
|
||||
Note that this must be called before enabling metrics collection. Calling
|
||||
this method while metrics collection is enabled returns an error.
|
||||
|
||||
.. deprecated:: 1.3
|
||||
|
||||
**EXPERIMENTAL**
|
||||
|
||||
:param time_domain: Time domain
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['timeDomain'] = time_domain
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Performance.setTimeDomain',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
def get_metrics() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.List[Metric]]:
|
||||
'''
|
||||
Retrieve current values of run-time metrics.
|
||||
|
||||
:returns: Current values for run-time metrics.
|
||||
'''
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'Performance.getMetrics',
|
||||
}
|
||||
json = yield cmd_dict
|
||||
return [Metric.from_json(i) for i in json['metrics']]
|
||||
|
||||
|
||||
@event_class('Performance.metrics')
|
||||
@dataclass
|
||||
class Metrics:
|
||||
'''
|
||||
Current values of the metrics.
|
||||
'''
|
||||
#: Current values of the metrics.
|
||||
metrics: typing.List[Metric]
|
||||
#: Timestamp title.
|
||||
title: str
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> Metrics:
|
||||
return cls(
|
||||
metrics=[Metric.from_json(i) for i in json['metrics']],
|
||||
title=str(json['title'])
|
||||
)
|
||||
@@ -0,0 +1,200 @@
|
||||
# DO NOT EDIT THIS FILE!
|
||||
#
|
||||
# This file is generated from the CDP specification. If you need to make
|
||||
# changes, edit the generator and regenerate all of the modules.
|
||||
#
|
||||
# CDP domain: PerformanceTimeline (experimental)
|
||||
|
||||
from __future__ import annotations
|
||||
import enum
|
||||
import typing
|
||||
from dataclasses import dataclass
|
||||
from .util import event_class, T_JSON_DICT
|
||||
|
||||
from . import dom
|
||||
from . import network
|
||||
from . import page
|
||||
|
||||
|
||||
@dataclass
|
||||
class LargestContentfulPaint:
|
||||
'''
|
||||
See https://github.com/WICG/LargestContentfulPaint and largest_contentful_paint.idl
|
||||
'''
|
||||
render_time: network.TimeSinceEpoch
|
||||
|
||||
load_time: network.TimeSinceEpoch
|
||||
|
||||
#: The number of pixels being painted.
|
||||
size: float
|
||||
|
||||
#: The id attribute of the element, if available.
|
||||
element_id: typing.Optional[str] = None
|
||||
|
||||
#: The URL of the image (may be trimmed).
|
||||
url: typing.Optional[str] = None
|
||||
|
||||
node_id: typing.Optional[dom.BackendNodeId] = None
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['renderTime'] = self.render_time.to_json()
|
||||
json['loadTime'] = self.load_time.to_json()
|
||||
json['size'] = self.size
|
||||
if self.element_id is not None:
|
||||
json['elementId'] = self.element_id
|
||||
if self.url is not None:
|
||||
json['url'] = self.url
|
||||
if self.node_id is not None:
|
||||
json['nodeId'] = self.node_id.to_json()
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> LargestContentfulPaint:
|
||||
return cls(
|
||||
render_time=network.TimeSinceEpoch.from_json(json['renderTime']),
|
||||
load_time=network.TimeSinceEpoch.from_json(json['loadTime']),
|
||||
size=float(json['size']),
|
||||
element_id=str(json['elementId']) if json.get('elementId', None) is not None else None,
|
||||
url=str(json['url']) if json.get('url', None) is not None else None,
|
||||
node_id=dom.BackendNodeId.from_json(json['nodeId']) if json.get('nodeId', None) is not None else None,
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class LayoutShiftAttribution:
|
||||
previous_rect: dom.Rect
|
||||
|
||||
current_rect: dom.Rect
|
||||
|
||||
node_id: typing.Optional[dom.BackendNodeId] = None
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['previousRect'] = self.previous_rect.to_json()
|
||||
json['currentRect'] = self.current_rect.to_json()
|
||||
if self.node_id is not None:
|
||||
json['nodeId'] = self.node_id.to_json()
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> LayoutShiftAttribution:
|
||||
return cls(
|
||||
previous_rect=dom.Rect.from_json(json['previousRect']),
|
||||
current_rect=dom.Rect.from_json(json['currentRect']),
|
||||
node_id=dom.BackendNodeId.from_json(json['nodeId']) if json.get('nodeId', None) is not None else None,
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class LayoutShift:
|
||||
'''
|
||||
See https://wicg.github.io/layout-instability/#sec-layout-shift and layout_shift.idl
|
||||
'''
|
||||
#: Score increment produced by this event.
|
||||
value: float
|
||||
|
||||
had_recent_input: bool
|
||||
|
||||
last_input_time: network.TimeSinceEpoch
|
||||
|
||||
sources: typing.List[LayoutShiftAttribution]
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['value'] = self.value
|
||||
json['hadRecentInput'] = self.had_recent_input
|
||||
json['lastInputTime'] = self.last_input_time.to_json()
|
||||
json['sources'] = [i.to_json() for i in self.sources]
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> LayoutShift:
|
||||
return cls(
|
||||
value=float(json['value']),
|
||||
had_recent_input=bool(json['hadRecentInput']),
|
||||
last_input_time=network.TimeSinceEpoch.from_json(json['lastInputTime']),
|
||||
sources=[LayoutShiftAttribution.from_json(i) for i in json['sources']],
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class TimelineEvent:
|
||||
#: Identifies the frame that this event is related to. Empty for non-frame targets.
|
||||
frame_id: page.FrameId
|
||||
|
||||
#: The event type, as specified in https://w3c.github.io/performance-timeline/#dom-performanceentry-entrytype
|
||||
#: This determines which of the optional "details" fields is present.
|
||||
type_: str
|
||||
|
||||
#: Name may be empty depending on the type.
|
||||
name: str
|
||||
|
||||
#: Time in seconds since Epoch, monotonically increasing within document lifetime.
|
||||
time: network.TimeSinceEpoch
|
||||
|
||||
#: Event duration, if applicable.
|
||||
duration: typing.Optional[float] = None
|
||||
|
||||
lcp_details: typing.Optional[LargestContentfulPaint] = None
|
||||
|
||||
layout_shift_details: typing.Optional[LayoutShift] = None
|
||||
|
||||
def to_json(self) -> T_JSON_DICT:
|
||||
json: T_JSON_DICT = dict()
|
||||
json['frameId'] = self.frame_id.to_json()
|
||||
json['type'] = self.type_
|
||||
json['name'] = self.name
|
||||
json['time'] = self.time.to_json()
|
||||
if self.duration is not None:
|
||||
json['duration'] = self.duration
|
||||
if self.lcp_details is not None:
|
||||
json['lcpDetails'] = self.lcp_details.to_json()
|
||||
if self.layout_shift_details is not None:
|
||||
json['layoutShiftDetails'] = self.layout_shift_details.to_json()
|
||||
return json
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> TimelineEvent:
|
||||
return cls(
|
||||
frame_id=page.FrameId.from_json(json['frameId']),
|
||||
type_=str(json['type']),
|
||||
name=str(json['name']),
|
||||
time=network.TimeSinceEpoch.from_json(json['time']),
|
||||
duration=float(json['duration']) if json.get('duration', None) is not None else None,
|
||||
lcp_details=LargestContentfulPaint.from_json(json['lcpDetails']) if json.get('lcpDetails', None) is not None else None,
|
||||
layout_shift_details=LayoutShift.from_json(json['layoutShiftDetails']) if json.get('layoutShiftDetails', None) is not None else None,
|
||||
)
|
||||
|
||||
|
||||
def enable(
|
||||
event_types: typing.List[str]
|
||||
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
||||
'''
|
||||
Previously buffered events would be reported before method returns.
|
||||
See also: timelineEventAdded
|
||||
|
||||
:param event_types: The types of event to report, as specified in https://w3c.github.io/performance-timeline/#dom-performanceentry-entrytype The specified filter overrides any previous filters, passing empty filter disables recording. Note that not all types exposed to the web platform are currently supported.
|
||||
'''
|
||||
params: T_JSON_DICT = dict()
|
||||
params['eventTypes'] = [i for i in event_types]
|
||||
cmd_dict: T_JSON_DICT = {
|
||||
'method': 'PerformanceTimeline.enable',
|
||||
'params': params,
|
||||
}
|
||||
json = yield cmd_dict
|
||||
|
||||
|
||||
@event_class('PerformanceTimeline.timelineEventAdded')
|
||||
@dataclass
|
||||
class TimelineEventAdded:
|
||||
'''
|
||||
Sent when a performance timeline event is added. See reportPerformanceTimeline method.
|
||||
'''
|
||||
event: TimelineEvent
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: T_JSON_DICT) -> TimelineEventAdded:
|
||||
return cls(
|
||||
event=TimelineEvent.from_json(json['event'])
|
||||
)
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user