blob: 43146777d4be70ad3fbe6c8c4fed03cc3b34e02b [file] [log] [blame]
from typing import Any, Optional, Mapping, MutableMapping
from ._module import BidiModule, command
class BrowsingContext(BidiModule):
@command
def get_tree(self,
max_depth: Optional[int] = None,
parent: Optional[str] = None) -> Mapping[str, Any]:
params: MutableMapping[str, Any] = {}
if max_depth is not None:
params["maxDepth"] = max_depth
if parent is not None:
params["parent"] = parent
return params
@get_tree.result
def _get_tree(self, result: Mapping[str, Any]) -> Any:
assert result["contexts"] is not None
assert isinstance(result["contexts"], list)
return result["contexts"]