From 0572337f25b5ec917ce31b33cec26f643f04974b Mon Sep 17 00:00:00 2001 From: jiangsonglin2 Date: Sat, 29 Jan 2022 20:09:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86headless=5Fchrome=E7=9B=B4=E6=8E=A5?= =?UTF-8?q?=E5=BC=95=E5=85=A5=E9=A1=B9=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: jiangsonglin2 --- mdbook-pdf/Cargo.toml | 6 +- mdbook-pdf/README.md | 4 + mdbook-pdf/headless_chrome/.gitignore | 11 + mdbook-pdf/headless_chrome/.travis.yml | 48 + mdbook-pdf/headless_chrome/CHANGELOG.md | 166 + mdbook-pdf/headless_chrome/Cargo.toml | 51 + mdbook-pdf/headless_chrome/README.md | 128 + mdbook-pdf/headless_chrome/build.rs | 5 + .../examples/call_js_function_with_args.rs | 28 + .../headless_chrome/examples/local_storage.rs | 24 + .../headless_chrome/examples/print_to_pdf.rs | 47 + .../examples/query_wikipedia.rs | 29 + .../examples/settings_and_event.rs | 38 + .../examples/take_screenshot.rs | 31 + .../headless_chrome/src/browser/context.rs | 55 + .../headless_chrome/src/browser/fetcher.rs | 388 + mdbook-pdf/headless_chrome/src/browser/mod.rs | 480 + .../headless_chrome/src/browser/process.rs | 580 + .../src/browser/tab/element/box_model.rs | 198 + .../src/browser/tab/element/mod.rs | 556 + .../headless_chrome/src/browser/tab/keys.rs | 1549 ++ .../headless_chrome/src/browser/tab/mod.rs | 1620 ++ .../headless_chrome/src/browser/tab/point.rs | 38 + .../src/browser/transport/mod.rs | 357 + .../transport/waiting_call_registry.rs | 120 + .../transport/web_socket_connection.rs | 129 + mdbook-pdf/headless_chrome/src/lib.rs | 91 + mdbook-pdf/headless_chrome/src/protocol.rs | 16220 ++++++++++++++++ .../src/testing_utils/logging.rs | 60 + .../headless_chrome/src/testing_utils/mod.rs | 2 + .../src/testing_utils/server.rs | 124 + mdbook-pdf/headless_chrome/src/types.rs | 367 + mdbook-pdf/headless_chrome/src/util.rs | 127 + .../headless_chrome/tests/connect_to_url.rs | 17 + mdbook-pdf/headless_chrome/tests/coverage.rs | 128 + .../basic_page_with_js_scripts.html | 13 + .../coverage_fixtures/coverage_fixture1.js | 8 + .../coverage_fixtures/coverage_fixture2.js | 3 + .../tests/events_fixtures/events_page.html | 18 + .../headless_chrome/tests/events_listeners.rs | 85 + .../headless_chrome/tests/expose_function.rs | 36 + mdbook-pdf/headless_chrome/tests/extension.rs | 20 + .../tests/extension_sample/background.js | 5 + .../tests/extension_sample/manifest.json | 11 + .../headless_chrome/tests/file_chooser.rs | 67 + .../tests/file_chooser_fixtures/chooser.html | 9 + .../file_chooser_fixtures/file_to_upload.txt | 1 + mdbook-pdf/headless_chrome/tests/form.html | 23 + .../headless_chrome/tests/local_storage.rs | 50 + mdbook-pdf/headless_chrome/tests/logging.rs | 1 + mdbook-pdf/headless_chrome/tests/logs.rs | 30 + .../basic_page_with_console_messages.html | 15 + .../tests/pdfassets/index.html | 17 + .../tests/pdfassets/rust-logo.svg | 2 + .../headless_chrome/tests/pdfassets/style.css | 7 + mdbook-pdf/headless_chrome/tests/server.rs | 1 + .../headless_chrome/tests/shadow-dom.html | 24 + mdbook-pdf/headless_chrome/tests/simple.html | 91 + mdbook-pdf/headless_chrome/tests/simple.rs | 890 + .../headless_chrome/tests/temp/.gitkeep | 1 + .../headless_chrome/tests/transparent.html | 17 + 61 files changed, 25262 insertions(+), 5 deletions(-) create mode 100644 mdbook-pdf/headless_chrome/.gitignore create mode 100644 mdbook-pdf/headless_chrome/.travis.yml create mode 100644 mdbook-pdf/headless_chrome/CHANGELOG.md create mode 100644 mdbook-pdf/headless_chrome/Cargo.toml create mode 100644 mdbook-pdf/headless_chrome/README.md create mode 100644 mdbook-pdf/headless_chrome/build.rs create mode 100644 mdbook-pdf/headless_chrome/examples/call_js_function_with_args.rs create mode 100644 mdbook-pdf/headless_chrome/examples/local_storage.rs create mode 100644 mdbook-pdf/headless_chrome/examples/print_to_pdf.rs create mode 100644 mdbook-pdf/headless_chrome/examples/query_wikipedia.rs create mode 100644 mdbook-pdf/headless_chrome/examples/settings_and_event.rs create mode 100644 mdbook-pdf/headless_chrome/examples/take_screenshot.rs create mode 100644 mdbook-pdf/headless_chrome/src/browser/context.rs create mode 100644 mdbook-pdf/headless_chrome/src/browser/fetcher.rs create mode 100644 mdbook-pdf/headless_chrome/src/browser/mod.rs create mode 100644 mdbook-pdf/headless_chrome/src/browser/process.rs create mode 100644 mdbook-pdf/headless_chrome/src/browser/tab/element/box_model.rs create mode 100644 mdbook-pdf/headless_chrome/src/browser/tab/element/mod.rs create mode 100644 mdbook-pdf/headless_chrome/src/browser/tab/keys.rs create mode 100644 mdbook-pdf/headless_chrome/src/browser/tab/mod.rs create mode 100644 mdbook-pdf/headless_chrome/src/browser/tab/point.rs create mode 100644 mdbook-pdf/headless_chrome/src/browser/transport/mod.rs create mode 100644 mdbook-pdf/headless_chrome/src/browser/transport/waiting_call_registry.rs create mode 100644 mdbook-pdf/headless_chrome/src/browser/transport/web_socket_connection.rs create mode 100644 mdbook-pdf/headless_chrome/src/lib.rs create mode 100644 mdbook-pdf/headless_chrome/src/protocol.rs create mode 100644 mdbook-pdf/headless_chrome/src/testing_utils/logging.rs create mode 100644 mdbook-pdf/headless_chrome/src/testing_utils/mod.rs create mode 100644 mdbook-pdf/headless_chrome/src/testing_utils/server.rs create mode 100644 mdbook-pdf/headless_chrome/src/types.rs create mode 100644 mdbook-pdf/headless_chrome/src/util.rs create mode 100644 mdbook-pdf/headless_chrome/tests/connect_to_url.rs create mode 100644 mdbook-pdf/headless_chrome/tests/coverage.rs create mode 100644 mdbook-pdf/headless_chrome/tests/coverage_fixtures/basic_page_with_js_scripts.html create mode 100644 mdbook-pdf/headless_chrome/tests/coverage_fixtures/coverage_fixture1.js create mode 100644 mdbook-pdf/headless_chrome/tests/coverage_fixtures/coverage_fixture2.js create mode 100644 mdbook-pdf/headless_chrome/tests/events_fixtures/events_page.html create mode 100644 mdbook-pdf/headless_chrome/tests/events_listeners.rs create mode 100644 mdbook-pdf/headless_chrome/tests/expose_function.rs create mode 100644 mdbook-pdf/headless_chrome/tests/extension.rs create mode 100644 mdbook-pdf/headless_chrome/tests/extension_sample/background.js create mode 100644 mdbook-pdf/headless_chrome/tests/extension_sample/manifest.json create mode 100644 mdbook-pdf/headless_chrome/tests/file_chooser.rs create mode 100644 mdbook-pdf/headless_chrome/tests/file_chooser_fixtures/chooser.html create mode 100644 mdbook-pdf/headless_chrome/tests/file_chooser_fixtures/file_to_upload.txt create mode 100644 mdbook-pdf/headless_chrome/tests/form.html create mode 100644 mdbook-pdf/headless_chrome/tests/local_storage.rs create mode 100644 mdbook-pdf/headless_chrome/tests/logging.rs create mode 100644 mdbook-pdf/headless_chrome/tests/logs.rs create mode 100644 mdbook-pdf/headless_chrome/tests/logs_fixtures/basic_page_with_console_messages.html create mode 100644 mdbook-pdf/headless_chrome/tests/pdfassets/index.html create mode 100644 mdbook-pdf/headless_chrome/tests/pdfassets/rust-logo.svg create mode 100644 mdbook-pdf/headless_chrome/tests/pdfassets/style.css create mode 100644 mdbook-pdf/headless_chrome/tests/server.rs create mode 100644 mdbook-pdf/headless_chrome/tests/shadow-dom.html create mode 100644 mdbook-pdf/headless_chrome/tests/simple.html create mode 100644 mdbook-pdf/headless_chrome/tests/simple.rs create mode 100644 mdbook-pdf/headless_chrome/tests/temp/.gitkeep create mode 100644 mdbook-pdf/headless_chrome/tests/transparent.html diff --git a/mdbook-pdf/Cargo.toml b/mdbook-pdf/Cargo.toml index 0801313d..860f5645 100644 --- a/mdbook-pdf/Cargo.toml +++ b/mdbook-pdf/Cargo.toml @@ -12,11 +12,7 @@ readme = "README.md" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -# # Wait for automatic chrome download to be available: https://github.com/atroche/rust-headless-chrome/issues/286 -# headless_chrome = { git = "https://github.com/atroche/rust-headless-chrome", branch = "master", features= ["fetch"] } - -# A forked version to expand some response timeout to 300 seconds. -headless_chrome = { git = "https://gitee.com/HollowMan6/rust-headless-chrome" } +headless_chrome = { path = "headless_chrome", version = "0.9.0" } mdbook = "0.4.15" serde = "1.0.134" serde_derive = "1.0.134" diff --git a/mdbook-pdf/README.md b/mdbook-pdf/README.md index 104c34aa..f89069d4 100644 --- a/mdbook-pdf/README.md +++ b/mdbook-pdf/README.md @@ -26,3 +26,7 @@ title = "An Example" 支持自定义PDF纸张方向、页面缩放比例、纸张宽度和高度、页面边距、生成的PDF页面范围、是否显示页眉和页脚以及自定义其格式等。 查看 [book.toml](test_doc/book.toml#L10-L33) 以了解 `[output.pdf]` 可用配置的详细信息。 + +## 关于 [headless_chrome](headless_chrome) + +由于直接使用上游 [headless_chrome](https://github.com/atroche/rust-headless-chrome) crate 对生成 PDF 不友好,容易导致超时错误。向上游提出了增加管理所有计时器的选项要求,但[上游不同意相关请求,只下放了部分计时器控制权限](https://github.com/atroche/rust-headless-chrome/issues/287),因而无法满足需求。所以引入上游源代码文件(许可证为 MIT),并应用补丁,将相关PDF打印接口超时设置为5分钟,从而保证功能和编译。 diff --git a/mdbook-pdf/headless_chrome/.gitignore b/mdbook-pdf/headless_chrome/.gitignore new file mode 100644 index 00000000..686154ad --- /dev/null +++ b/mdbook-pdf/headless_chrome/.gitignore @@ -0,0 +1,11 @@ +/target +**/*.rs.bk +.idea +logs +Cargo.lock + +/tests/temp/* +!/tests/temp/.gitkeep + +debug.log +TAGS diff --git a/mdbook-pdf/headless_chrome/.travis.yml b/mdbook-pdf/headless_chrome/.travis.yml new file mode 100644 index 00000000..588592ca --- /dev/null +++ b/mdbook-pdf/headless_chrome/.travis.yml @@ -0,0 +1,48 @@ +language: rust + +rust: + - stable + - nightly + +addons: + chrome: stable + apt: + packages: + - libnss3 + +os: + - linux + - osx + +services: + - xvfb + +before_install: + - set -e + - export RUSTFLAGS="-D warnings" + - if [ "$TRAVIS_RUST_VERSION" != "nightly" ]; then + rustup self update && + rustup component add rustfmt clippy && + cargo clippy --version; + fi + +before_cache: + - cargo install cargo-prune || echo "already installed" + - cargo prune + +cache: + cargo: true + directories: + - $HOME/.local/share/ + - $HOME/Library/Application Support/ + +script: + - if [ "$TRAVIS_RUST_VERSION" != "nightly" ]; then + cargo fmt --all -- --check && + cargo clippy --all --tests --examples; + fi + - env RUST_BACKTRACE=1 RUST_LOG=headless_chrome=trace cargo test -- --nocapture + - cargo test --no-default-features + - if [ "$TRAVIS_RUST_VERSION" = "nightly" ]; then + cargo test --doc --features nightly -- README; + fi diff --git a/mdbook-pdf/headless_chrome/CHANGELOG.md b/mdbook-pdf/headless_chrome/CHANGELOG.md new file mode 100644 index 00000000..4f29e23f --- /dev/null +++ b/mdbook-pdf/headless_chrome/CHANGELOG.md @@ -0,0 +1,166 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +## [Unreleased](https://github.com/atroche/rust-headless-chrome/compare/v0.9.0...HEAD) + +### Added +* [`LaunchOptions::default_builder()`](https://github.com/atroche/rust-headless-chrome/pull/176) for easier access to LaunchOptionsBuilder (which, because it's created via `derive(Builder)` is hard for editors to deal with +* [Support for intercepting the file chooser dialog](https://github.com/atroche/rust-headless-chrome/pull/169) +* [Slow motion option for tab](https://github.com/atroche/rust-headless-chrome/pull/177) +* [`Element::get_inner_text()`](https://github.com/atroche/rust-headless-chrome/pull/178) +* [`Element::find_element` and `Element::find_elements`](https://github.com/atroche/rust-headless-chrome/pull/190) + +### Removed +### Changed +* Move env_logger to dev dependencies + +## 0.9.0 - 2019-08-22 + +### Added +* [Add get_title method to tab](https://github.com/atroche/rust-headless-chrome/pull/167) +* [Add way to set env vars for Chrome process](https://github.com/atroche/rust-headless-chrome/pull/168) +* [Improve Runtime Domain, Add ability to listen to all Events on a tab](https://github.com/atroche/rust-headless-chrome/pull/162) + +### Removed +### Changed + +## 0.8.0 - 2019-08-22 + +### Added + +* [tab.set_default_timeout](https://github.com/atroche/rust-headless-chrome/pull/161), a convenience method. + +### Removed +### Changed + +* [Run Chrome with same 'DEFAULT_ARGS' as puppeteer](https://github.com/atroche/rust-headless-chrome/pull/165) +* **BREAKING CHANGE**: [Remove the 'fetch' feature (which enables the fetcher module) from default features](https://github.com/atroche/rust-headless-chrome/pull/164). +* **BREAKING CHANGE**: [Use JsFloat / JsUInt / JsInt consistently in protocol module ](https://github.com/atroche/rust-headless-chrome/pull/166) + All 'integer' types in the protocol are now either i32 or u32, and all 'number' types are f64, via type aliases. + +## 0.7.0 - 2019-08-20 + +### Added + +* [`Tab.get_cookies()`](https://github.com/atroche/rust-headless-chrome/pull/159) +* [`Browser.getWindowBounds()`, `Tab.setWindowBounds()`](https://github.com/atroche/rust-headless-chrome/pull/102) + +### Removed +### Changed + +## 0.6.0 - 2019-08-20 + +### Added + +* [Support for Log domain](https://github.com/atroche/rust-headless-chrome/pull/155) (`tab.enable_logging()` and `tab.disable_logging()`, `tab.start_violations_report()` and `tab.stop_violations_report()`) +* [`protocol::runtime::StackTrace`](https://github.com/atroche/rust-headless-chrome/pull/155/files#diff-b42bc2ad3d82a3891748fd549d3e0a50R95) and `protocol::runtime::CallFrame`. + +### Removed +### Changed + +* `procotol::runtime::RemoteObject.object_type` is now an enum rather than any string. + + +## 0.5.0 - 2019-08-12 + +### Added + +* [`Tab.evaluate`](https://github.com/atroche/rust-headless-chrome/pull/150) + +### Removed +### Changed + +* [Fixed problem with compiling project with --no-default-features](https://github.com/atroche/rust-headless-chrome/pull/152) + +## 0.4.0 - 2019-08-02 + +### Added + +* [`Browser.setUserAgentOverride()`](https://github.com/atroche/rust-headless-chrome/pull/141) +* [`LaunchOptions.idle_browser_timeout`](https://github.com/atroche/rust-headless-chrome/pull/145): an option to specify timeout value for when the connection hasn't received any events from the browser + +### Removed +### Changed + +* Changed `protocol::dom::NodeId` from `u16` to `u32`. + +## 0.3.0 - 2019-07-07 + +### Added + +* Re-export Element struct in top level module +* Better crate-level docs, and also docs for the Element struct +* Browser::default convenience method for quickly getting a headless browser with default options + +### Removed +### Changed + +## 0.2.0 - 2019-07-07 + +Note: starting with this release we're going to bump the minor version whenever anything new is added to the public API. + +### Added + +* [Response handling callback for tabs (`Tab.enable_response_handler`)](https://github.com/atroche/rust-headless-chrome/pull/133) + +### Removed +### Changed + +* [Fixed a race condition in Tab.wait_until_navigated](https://github.com/atroche/rust-headless-chrome/pull/135) +* [Bump dependencies (rand, ureq, directories) and remove base64 dev dep](https://github.com/atroche/rust-headless-chrome/pull/134) + + +## 0.1.5 - 2019-06-19 + +### Added + +* [Tab.get_script_source, Tab.enable_debugger, Tab.disable_debugger](https://github.com/atroche/rust-headless-chrome/commit/625c59f9957d3ffa1853164d1d77e9c252d116ee) +* [Add ability to set window size of browser on launch](https://github.com/atroche/rust-headless-chrome/pull/123) +* [Scroll elements into view before clicking, mousing over or focusing on them](https://github.com/atroche/rust-headless-chrome/pull/128) +* [FrameTree.child_frames field](https://github.com/atroche/rust-headless-chrome/commit/9c86817fdbf8fa63620cad3700f7063781335d20) +* [When waiting for elements, return most errors early instead of retrying and timing out](https://github.com/atroche/rust-headless-chrome/pull/129) +* [Add `await_promise` argument to Tab.call_js_fn](https://github.com/atroche/rust-headless-chrome/commit/d82ffa8fd4c3efaed1721d8721068d2c6d6c7c9c) +* [Search for existing Chrome / Chromium binaries in more locations](https://github.com/atroche/rust-headless-chrome/pull/126/files) + +### Removed + +* [Remove some out-dated examples, along with a couple of dependencies](https://github.com/atroche/rust-headless-chrome/commit/7e99bb861bf8476192b6402a12e9c7d06f15911f) + +### Changed + +* [Fix Windows build](https://github.com/atroche/rust-headless-chrome/pull/118) +* [Use ureq instead of reqwest for fetching Chromium binaries](https://github.com/atroche/rust-headless-chrome/commit/acf336707759b646f59d68b05465a0e0ef2a0fa7) + + +## 0.1.4 - 2019-03-21 + +### Added +* [Tab.capture_screenshot](https://github.com/atroche/rust-headless-chrome/pull/48) +* [Tab.print_to_pdf](https://github.com/atroche/rust-headless-chrome/pull/107) +* [Element.wait_for_elements](https://github.com/atroche/rust-headless-chrome/pull/90) +* [Automatic downloading of Chromium binary for people who don't want to use their own binary](https://github.com/atroche/rust-headless-chrome/pull/83) +* [Tab.reload](https://github.com/atroche/rust-headless-chrome/pull/49) +* [Network request interception](https://github.com/atroche/rust-headless-chrome/pull/98) +* [Method chaining on Tab for common methods like click()](https://github.com/atroche/rust-headless-chrome/pull/44) +* [Browser.new_tab](https://github.com/atroche/rust-headless-chrome/pull/56) +* [Incognito support (Browser.new_context)](https://github.com/atroche/rust-headless-chrome/pull/97) +* [Element.capture_screenshot](https://github.com/atroche/rust-headless-chrome/pull/59) +* [Element.get_box_model](https://github.com/atroche/rust-headless-chrome/pull/67) +* [Support for preloading extensions](https://github.com/atroche/rust-headless-chrome/pull/69) +* [Support for watching JS / CSS coverage](https://github.com/atroche/rust-headless-chrome/pull/86) +* [Element.move_mouse_over and Tab.move_mouse_to_point functions](https://github.com/atroche/rust-headless-chrome/pull/96) +* [Browser.get_version](https://github.com/atroche/rust-headless-chrome/pull/66) +* [LaunchOptionsBuilder](https://github.com/atroche/rust-headless-chrome/pull/62) +* Added badge to [the Discord server](https://discord.gg/yyGEzcc) in README + +### Changed +* [Renamed cdtp module to protocol](https://github.com/atroche/rust-headless-chrome/pull/80) +* [Refactored Waiting helper](https://github.com/atroche/rust-headless-chrome/pull/88) +* [Exposed more modules (like Browser, Tab and Element) as public](https://github.com/atroche/rust-headless-chrome/pull/70) +* [protocol::dom::Node.attributes is now a HashMap](https://github.com/atroche/rust-headless-chrome/pull/52/files) +* Run Travis on stable and nightly on Linux and MacOS, with rustfmt and pedantic clippy. +* Fixed [some concurrency issues](https://github.com/atroche/rust-headless-chrome/pull/41) + +### Removed +* [Removed Element's found_via_selector field](https://github.com/atroche/rust-headless-chrome/pull/101/files) diff --git a/mdbook-pdf/headless_chrome/Cargo.toml b/mdbook-pdf/headless_chrome/Cargo.toml new file mode 100644 index 00000000..f9da7f51 --- /dev/null +++ b/mdbook-pdf/headless_chrome/Cargo.toml @@ -0,0 +1,51 @@ +[package] +name = "headless_chrome" +version = "0.9.0" +authors = ["Alistair Roche "] +edition = "2018" +description = "Control Chrome programatically" +license = "MIT" +homepage = "https://github.com/atroche/rust-headless-chrome" +repository = "https://github.com/atroche/rust-headless-chrome" +readme = "README.md" + +[dependencies] +websocket = { version = "0.23", default_features = false, features = ["sync"] } +regex = "1" +serde = { version = "1", features = ["derive"] } +serde_json = "1" +anyhow = '1' +thiserror = '1' +log = "0.4" +rand = "0.7" +tempfile = "3" +base64 = "0.10" +derive_builder = "0.8" +which = "3.0" +ureq = { version = "0.11", optional = true } +directories = { version = "2.0", optional = true } +zip = { version = "^0.5.3", optional = true } +walkdir = { version = "2", optional = true } + +[target.'cfg(windows)'.dependencies] +winreg = "0.6" + +[dev-dependencies] +env_logger = "0.7" +chrono = { version = "0.4", default_features = false } +tiny_http = "0.6" +png = { version = "0.15" } +jpeg-decoder = { version = "0.1", default_features = false } +filepath = "0.1.1" + +[build-dependencies] +auto_generate_cdp = "0.3.2" + +[lib] +name = "headless_chrome" +path = "src/lib.rs" + +[features] +default = [] +fetch = [ "ureq", "directories", "zip", "walkdir" ] +nightly = [] diff --git a/mdbook-pdf/headless_chrome/README.md b/mdbook-pdf/headless_chrome/README.md new file mode 100644 index 00000000..3969da95 --- /dev/null +++ b/mdbook-pdf/headless_chrome/README.md @@ -0,0 +1,128 @@ +# Headless Chrome + +[![Build Status](https://travis-ci.com/atroche/rust-headless-chrome.svg?branch=master)](https://travis-ci.com/atroche/rust-headless-chrome) +[![Crate](https://img.shields.io/crates/v/headless_chrome.svg)](https://crates.io/crates/headless_chrome) +[![API](https://docs.rs/headless_chrome/badge.svg)](https://docs.rs/headless_chrome) +[![Discord channel](https://img.shields.io/discord/557374784233799681.svg?logo=discord)](https://discord.gg/yyGEzcc) + +A high-level API to control headless Chrome or Chromium over the DevTools Protocol. It is the +Rust equivalent of [Puppeteer](https://github.com/GoogleChrome/puppeteer), a Node library +maintained by the Chrome DevTools team. + +It is not 100% feature compatible with Puppeteer, but there's enough here to satisfy most +browser testing / web crawling use cases, and there are several 'advanced' features such as: + +- [network request interception](https://docs.rs/headless_chrome/latest/headless_chrome/browser/tab/struct.Tab.html#method.enable_request_interception) +- [JavaScript coverage monitoring](https://docs.rs/headless_chrome/latest/headless_chrome/browser/tab/struct.Tab.html#method.take_precise_js_coverage) +- Opening incognito windows +- [taking screenshots of elements or the entire page](https://docs.rs/headless_chrome/latest/headless_chrome/browser/tab/struct.Tab.html#method.capture_screenshot) +- [saving pages to PDF](https://docs.rs/headless_chrome/latest/headless_chrome/browser/tab/struct.Tab.html#method.print_to_pdf) +- ['headful' browsing](https://docs.rs/headless_chrome/latest/headless_chrome/struct.LaunchOptionsBuilder.html#method.headless) +- automatic downloading of 'known good' Chromium binaries for Linux / Mac / Windows +- [extension pre-loading](https://docs.rs/headless_chrome/latest/headless_chrome/struct.LaunchOptionsBuilder.html#method.extensions) + +## Quick Start + +```rust +use headless_chrome::{Browser, protocol::page::ScreenshotFormat}; + +fn browse_wikipedia() -> Result<(), failure::Error> { + let browser = Browser::default()?; + + let tab = browser.wait_for_initial_tab()?; + + /// Navigate to wikipedia + tab.navigate_to("https://www.wikipedia.org")?; + + /// Wait for network/javascript/dom to make the search-box available + /// and click it. + tab.wait_for_element("input#searchInput")?.click()?; + + /// Type in a query and press `Enter` + tab.type_str("WebKit")?.press_key("Enter")?; + + /// We should end up on the WebKit-page once navigated + let elem = tab.wait_for_element("#firstHeading")?; + assert!(tab.get_url().ends_with("WebKit")); + + /// Take a screenshot of the entire browser window + let _jpeg_data = tab.capture_screenshot( + ScreenshotFormat::JPEG(Some(75)), + None, + true)?; + + /// Take a screenshot of just the WebKit-Infobox + let _png_data = tab + .wait_for_element("#mw-content-text > div > table.infobox.vevent")? + .capture_screenshot(ScreenshotFormat::PNG)?; + + // Run JavaScript in the page + match elem.call_js_fn(r#" + function getIdTwice () { + // `this` is always the element that you called `call_js_fn` on + const id = this.id; + return id + id; + } + "#, false)? { + serde_json::value::Value::String(returned_string) { + assert_eq!(returned_string, "firstHeadingfirstHeading".to_string()); + } + _ => unreachable!() + }; + + Ok(()) +} + +assert!(browse_wikipedia().is_ok()); +``` + +For fuller examples, take a look at [`tests/simple.rs`](tests/simple.rs) and [`examples`](examples/). + +> Before running examples. Make sure add [failure](https://crates.io/crates/failure) crate in your cargo project dependency of `Cargo.toml` + + +## What can't it do? + +The [Chrome DevTools Protocol](https://chromedevtools.github.io/devtools-protocol/tot/Browser) is huge. Currently, Puppeteer supports way more of it than we do. Some of the missing features include: + +- Dealing with frames +- Handling file picker / chooser interactions +- Tapping touchscreens +- Emulating different network conditions (DevTools can alter latency, throughput, offline status, 'connection type') +- Viewing timing information about network requests +- Reading the SSL certificate +- Replaying XHRs +- HTTP Basic Auth +- Inspecting `EventSource`s (aka server-sent events or SSEs) +- WebSocket inspection + +If you're interested in adding one of these features but would like some advice about how to start, please reach out by creating an issue or sending me an email at [`alistair@sunburnt.country`](mailto:alistair@sunburnt.country). + +## Related crates + +- [fantoccini](https://github.com/jonhoo/fantoccini) uses WebDriver, so it works with browsers other than Chrome. It's also asynchronous and based on Tokio, unlike `headless_chrome`, which has a synchronous API and is just implemented using plain old threads. Fantoccini has also been around longer and is more battle-tested. It doesn't support Chrome DevTools-specific functionality like JS Coverage. + +## Testing + +For debug output, set these environment variables before running `cargo test`: + +```RUST_BACKTRACE=1 RUST_LOG=headless_chrome=trace``` + +## Version numbers + +Starting with v0.2.0, we're trying to follow SemVar strictly. + +## Troubleshooting + +If you get errors related to timeouts, you likely need to enable sandboxing either in the kernel or as a setuid sandbox. Puppeteer has some information about how to do that [here](https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md) + +By default, `headless_chrome` will download a compatible version of chrome to `XDG_DATA_HOME` (or equivalent on Windows/Mac). This behaviour can be optionally turned off, and you can use the system version of chrome (assuming you have chrome installed) by disabling the default feature in your `Cargo.toml`: + +```toml +[dependencies.headless_chrome] +default-features = false +``` + +## Contributing + +Pull requests and issues are most welcome, even if they're just experience reports. If you find anything frustrating or confusing, let me know! diff --git a/mdbook-pdf/headless_chrome/build.rs b/mdbook-pdf/headless_chrome/build.rs new file mode 100644 index 00000000..bf030a82 --- /dev/null +++ b/mdbook-pdf/headless_chrome/build.rs @@ -0,0 +1,5 @@ +use auto_generate_cdp::init; + +fn main() { + init(); +} \ No newline at end of file diff --git a/mdbook-pdf/headless_chrome/examples/call_js_function_with_args.rs b/mdbook-pdf/headless_chrome/examples/call_js_function_with_args.rs new file mode 100644 index 00000000..9ff51e6a --- /dev/null +++ b/mdbook-pdf/headless_chrome/examples/call_js_function_with_args.rs @@ -0,0 +1,28 @@ +use anyhow::Result; + +use headless_chrome::{Browser, LaunchOptions}; + +fn main() -> Result<()> { + let browser = Browser::new( + LaunchOptions::default_builder() + .build() + .expect("Could not find chrome-executable"), + )?; + + let tab = browser.wait_for_initial_tab()?; + + tab.navigate_to("https://www.google.com") + .expect("failed to navigate"); + + tab.wait_until_navigated().unwrap(); + + let element = tab.wait_for_xpath("/html/body/div[1]/div[5]/div[1]")?; + + element.call_js_fn( + "function(...args) {if(arg[0]) {return this.innerText;}}", + vec![], + false, + )?; + + Ok(()) +} diff --git a/mdbook-pdf/headless_chrome/examples/local_storage.rs b/mdbook-pdf/headless_chrome/examples/local_storage.rs new file mode 100644 index 00000000..960dc95c --- /dev/null +++ b/mdbook-pdf/headless_chrome/examples/local_storage.rs @@ -0,0 +1,24 @@ +use anyhow::Result; + +use headless_chrome::{Browser, LaunchOptions}; + +fn main() -> Result<()> { + let browser = Browser::new( + LaunchOptions::default_builder() + .build() + .expect("Could not find chrome-executable"), + )?; + + let tab = browser.wait_for_initial_tab()?; + + tab.navigate_to("https://www.wikipedia.com") + .expect("failed to navigate"); + + tab.wait_until_navigated().unwrap(); + + let item: String = tab.get_storage("translationHash")?; + + println!("{}",item); + + Ok(()) +} diff --git a/mdbook-pdf/headless_chrome/examples/print_to_pdf.rs b/mdbook-pdf/headless_chrome/examples/print_to_pdf.rs new file mode 100644 index 00000000..4c4464c4 --- /dev/null +++ b/mdbook-pdf/headless_chrome/examples/print_to_pdf.rs @@ -0,0 +1,47 @@ +use std::{env, fs}; + +use anyhow::Result; + +use headless_chrome::{types::PrintToPdfOptions, Browser}; + +/// Run the example as follows: +/// ./print_to_pdf {debug_ws_url} /rust-headless-chrome/tests/pdfassets/index.html +fn main() -> Result<()> { + // Create a headless browser, navigate to index.html file, wait for the page + // to render completely, render a PDF of the page and save it to the filesystem. + + // webSocketDebuggerUrl is obtained by GET http request to + // http://{chromeservicehost}{port}/json/version + // and pass an empty-value host param: {host: ""} in header + // + // an example looks like this: "ws://127.0.0.1:9222/devtools/browser/14804b82-0392-43be-b20f-d75678460e43"; + let debug_ws_url = env::args().nth(1).expect("Must provide debug_ws_url"); + + let file_path = format!( + "file://{}", + env::args() + .nth(2) + .expect("Must provide path/to/file/index.html") + ); + + let browser = Browser::connect(debug_ws_url.to_string())?; + let tab = browser.wait_for_initial_tab()?; + + let wikidata = tab + .navigate_to("https://www.wikipedia.org")? + .wait_until_navigated()? + .print_to_pdf(None)?; + fs::write("wiki.pdf", &wikidata)?; + println!("PDF successfully created from internet web page."); + + // Browse to the file url and render a pdf of the web page. + let pdf_options: Option = None; // use chrome's defaults for this example + let local_pdf = tab + .navigate_to(&file_path)? + .wait_until_navigated()? + .print_to_pdf(pdf_options)?; + fs::write("rust.pdf", &local_pdf)?; + println!("PDF successfully created from local web page."); + + Ok(()) +} diff --git a/mdbook-pdf/headless_chrome/examples/query_wikipedia.rs b/mdbook-pdf/headless_chrome/examples/query_wikipedia.rs new file mode 100644 index 00000000..264385f2 --- /dev/null +++ b/mdbook-pdf/headless_chrome/examples/query_wikipedia.rs @@ -0,0 +1,29 @@ +use anyhow::Result; + +use headless_chrome::{Browser, LaunchOptions}; + +fn query(input: &str) -> Result<()> { + let browser = Browser::new( + LaunchOptions::default_builder() + .build() + .expect("Could not find chrome-executable"), + )?; + let tab = browser.wait_for_initial_tab()?; + tab.navigate_to("https://en.wikipedia.org")? + .wait_for_element("input#searchInput")? + .click()?; + tab.type_str(&input)?.press_key("Enter")?; + match tab.wait_for_element("div.shortdescription") { + Err(e) => eprintln!("Query failed: {:?}", e), + Ok(e) => match e.get_description()?.find(|n| n.node_name == "#text") { + Some(n) => println!("Result for `{}`: {}", &input, n.node_value), + None => eprintln!("No shortdescription-node found on page"), + }, + } + Ok(()) +} + +fn main() -> Result<()> { + let input = "Elvis Aaron Presley"; + query(input) +} diff --git a/mdbook-pdf/headless_chrome/examples/settings_and_event.rs b/mdbook-pdf/headless_chrome/examples/settings_and_event.rs new file mode 100644 index 00000000..2653dbac --- /dev/null +++ b/mdbook-pdf/headless_chrome/examples/settings_and_event.rs @@ -0,0 +1,38 @@ +use std::sync::Arc; + +use anyhow::Result; + +use headless_chrome::{protocol::cdp::types::Event, Browser, LaunchOptions}; + +fn start() -> Result<()> { + let browser = Browser::new(LaunchOptions { + headless: false, + ..Default::default() + })?; + + let tab = browser.wait_for_initial_tab().unwrap(); + + tab.navigate_to("https://www.google.com") + .expect("failed to navigate"); + + tab.wait_until_navigated().unwrap(); + + let new_tab = tab.clone(); + + let sync_event = Arc::new(move |event: &Event| match event { + Event::PageLifecycleEvent(lifecycle) => { + if lifecycle.params.name == "DOMContentLoaded" { + println!("{}", new_tab.get_url()); + } + } + _ => {} + }); + + tab.add_event_listener(sync_event).unwrap(); + + Ok(()) +} + +fn main() -> Result<()> { + start() +} diff --git a/mdbook-pdf/headless_chrome/examples/take_screenshot.rs b/mdbook-pdf/headless_chrome/examples/take_screenshot.rs new file mode 100644 index 00000000..1e1bc924 --- /dev/null +++ b/mdbook-pdf/headless_chrome/examples/take_screenshot.rs @@ -0,0 +1,31 @@ +use std::fs; + +use anyhow::Result; + +use headless_chrome::{protocol::cdp::Page::CaptureScreenshotFormatOption, Browser, LaunchOptions}; + +fn main() -> Result<()> { + // Create a headless browser, navigate to wikipedia.org, wait for the page + // to render completely, take a screenshot of the entire page + // in JPEG-format using 75% quality. + let options = LaunchOptions::default_builder() + .build() + .expect("Couldn't find appropriate Chrome binary."); + let browser = Browser::new(options)?; + let tab = browser.wait_for_initial_tab()?; + let jpeg_data = tab + .navigate_to("https://www.wikipedia.org")? + .wait_until_navigated()? + .capture_screenshot(CaptureScreenshotFormatOption::Jpeg,Some(75), None, true)?; + fs::write("screenshot.jpg", &jpeg_data)?; + + // Browse to the WebKit-Page and take a screenshot of the infobox. + let png_data = tab + .navigate_to("https://en.wikipedia.org/wiki/WebKit")? + .wait_for_element("#mw-content-text > div > table.infobox.vevent")? + .capture_screenshot(CaptureScreenshotFormatOption::Png)?; + fs::write("screenshot.png", &png_data)?; + + println!("Screenshots successfully created."); + Ok(()) +} diff --git a/mdbook-pdf/headless_chrome/src/browser/context.rs b/mdbook-pdf/headless_chrome/src/browser/context.rs new file mode 100644 index 00000000..ed0f3d70 --- /dev/null +++ b/mdbook-pdf/headless_chrome/src/browser/context.rs @@ -0,0 +1,55 @@ +use std::sync::Arc; + +use anyhow::Result; + +use crate::browser::tab::Tab; +use crate::protocol::cdp::Target::CreateTarget; + +/// Equivalent to a new incognito window +pub struct Context<'a> { + id: String, + browser: &'a super::Browser, +} + +impl<'a> Context<'a> { + pub fn new(browser: &'a super::Browser, context_id: String) -> Self { + Self { + id: context_id, + browser, + } + } + + /// Opens a new tab in this context. It will not share cookies or a cache with the default + /// browsing context or any other contexts created + pub fn new_tab(&self) -> Result> { + let tab_in_context = CreateTarget { + url: "about:blank".to_string(), + width: None, + height: None, + browser_context_id: Some(self.id.clone()), + enable_begin_frame_control: None, + new_window: None, + background: None, + }; + self.browser.new_tab_with_options(tab_in_context) + } + + /// The BrowserContextId associated with this context + pub fn get_id(&self) -> &str { + &self.id + } + + /// Any tabs created in this context + pub fn get_tabs(&self) -> Result>> { + let browser_tabs = self.browser.get_tabs().lock().unwrap(); + let mut tabs = vec![]; + for tab in browser_tabs.iter() { + if let Some(context_id) = tab.get_browser_context_id()? { + if context_id == self.id { + tabs.push(Arc::clone(tab)); + } + } + } + Ok(tabs) + } +} diff --git a/mdbook-pdf/headless_chrome/src/browser/fetcher.rs b/mdbook-pdf/headless_chrome/src/browser/fetcher.rs new file mode 100644 index 00000000..6e6af36d --- /dev/null +++ b/mdbook-pdf/headless_chrome/src/browser/fetcher.rs @@ -0,0 +1,388 @@ +use std::{ + fs::{self, File, OpenOptions}, + io::{self, BufWriter}, + path::{Path, PathBuf}, + str::FromStr, +}; + +use directories::ProjectDirs; +use failure::{format_err, Fallible}; +use log::*; +use ureq; +use walkdir::WalkDir; +use zip; + +pub const CUR_REV: &str = "634997"; + +const APP_NAME: &str = "headless-chrome"; +const DEFAULT_HOST: &str = "https://storage.googleapis.com"; + +#[cfg(target_os = "linux")] +const PLATFORM: &str = "linux"; +#[cfg(target_os = "macos")] +const PLATFORM: &str = "mac"; +#[cfg(windows)] +const PLATFORM: &str = "win"; + +#[derive(Clone)] +pub struct FetcherOptions { + /// The desired chrome revision. + /// + /// defaults to CUR_REV + revision: String, + + /// The prefered installation directory. If not None we will look here first + /// for existing installs. + /// + /// defaults to None + install_dir: Option, + + /// Allow headless_chrome to download and install the desired revision if not found. + /// + /// defaults to true + allow_download: bool, + + /// Allow looking in the standard installation directories for existing installs. + /// + /// defaults to true + allow_standard_dirs: bool, +} + +impl Default for FetcherOptions { + fn default() -> Self { + Self { + revision: CUR_REV.into(), + install_dir: None, + allow_download: true, + allow_standard_dirs: true, + } + } +} + +impl FetcherOptions { + pub fn with_revision>(mut self, revision: S) -> Self { + self.revision = revision.into(); + self + } + + pub fn with_install_dir>(mut self, install_dir: Option

) -> Self { + match install_dir { + Some(dir) => self.install_dir = Some(dir.into()), + None => self.install_dir = None, + } + self + } + + pub fn with_allow_download(mut self, allow_download: bool) -> Self { + self.allow_download = allow_download; + self + } + + pub fn with_allow_standard_dirs(mut self, allow_standard_dirs: bool) -> Self { + self.allow_standard_dirs = allow_standard_dirs; + self + } +} + +#[derive(Default)] +pub struct Fetcher { + options: FetcherOptions, +} + +impl Fetcher { + pub fn new(options: FetcherOptions) -> Result { + Ok(Self { options }) + } + + // look for good existing installation, if none exists then download and install + pub fn fetch(&self) -> Result { + if let Ok(chrome_path) = self.chrome_path() { + // we found it! + return Ok(chrome_path); + } + + if self.options.allow_download { + let zip_path = self.download()?; + + self.unzip(zip_path)?; + + // look again + return self.chrome_path(); + } + + // couldn't find and not allowed to download + Err(format_err!("Could not fetch")) + } + + // Look for an installation directory matching self.options.revision + fn base_path(&self) -> Result { + // we want to look in install_dir first, then data dir + let mut search_dirs: Vec<&Path> = Vec::new(); + let project_dirs = get_project_dirs()?; + if let Some(install_dir) = &self.options.install_dir { + search_dirs.push(install_dir.as_path()); + } + if self.options.allow_standard_dirs { + search_dirs.push(project_dirs.data_dir()); + } + + for root_dir in search_dirs { + for entry in WalkDir::new(root_dir).into_iter().filter_map(Result::ok) { + // filename is formatted as `{PLATFORM}-{REVISION}` + let filename_parts = entry + .file_name() + .to_str() + .ok_or_else(|| format_err!("Failed conversion to UTF-8"))? + .split('-') + .collect::>(); + + if filename_parts.len() == 2 + && filename_parts[0] == PLATFORM + && filename_parts[1] == self.options.revision + { + return Ok(entry.path().into()); + } + } + } + + Err(format_err!("Could not find an existing revision")) + } + + // find full path to chrome executable from base_path + fn chrome_path(&self) -> Result { + let mut path = self.base_path()?; + path.push(archive_name(&self.options.revision)?); + + #[cfg(target_os = "linux")] + { + path.push("chrome"); + } + #[cfg(target_os = "macos")] + { + path.push("Chromium.app"); + path.push("Contents"); + path.push("MacOS"); + path.push("Chromium"); + } + #[cfg(windows)] + { + path.push("chrome.exe"); + } + + Ok(path) + } + + // download a .zip of the revision we want + fn download(&self) -> Result { + let url = dl_url(&self.options.revision)?; + info!("Chrome download url: {}", url); + let total = get_size(&url)?; + info!("Total size of download: {} MiB", total); + + let mut path: PathBuf = if let Some(mut dir) = self.options.install_dir.clone() { + // we have a preferred install location + dir.push(format!("{}-{}", PLATFORM, self.options.revision)); + dir + } else if self.options.allow_standard_dirs { + let mut dir = get_project_dirs()?.data_dir().to_path_buf(); + dir.push(format!("{}-{}", PLATFORM, self.options.revision)); + dir + } else { + // No preferred install dir and not allowed to use standard dirs. + // Not likely for someone to try and do this on purpose. + return Err(format_err!("No allowed installation directory")); + }; + path = path.with_extension("zip"); + // we need to create this directory in case it doesn't exist yet + fs::create_dir_all( + path.parent() + .ok_or_else(|| format_err!("Path {:?} does not have a parent directory", path))?, + ) + .map_err(|_err| format_err!("Could not create directory at {:?}", path.parent()))?; + + println!("{:?}", path); + + info!("Creating file for download: {}", &path.display()); + let mut file = OpenOptions::new().create(true).write(true).open(&path)?; + + let resp = ureq::get(&url).call(); + io::copy(&mut resp.into_reader(), &mut file)?; + + Ok(path) + } + + #[cfg(target_os = "macos")] + fn do_unzip>(&self, zip_path: P, extract_path: &Path) -> Result<()> { + let out = std::process::Command::new("unzip") + .arg(zip_path.as_ref().as_os_str()) + .current_dir(&extract_path) + .output()?; + + if !out.status.success() { + error!( + "Unable to extract zip using unzip command: \n---- stdout:\n{}\n---- stderr:\n{}", + String::from_utf8_lossy(&out.stdout), + String::from_utf8_lossy(&out.stderr) + ); + } + Ok(()) + } + + #[cfg(not(target_os = "macos"))] + fn do_unzip>(&self, zip_path: P, extract_path: &Path) -> Result<()> { + let mut archive = zip::ZipArchive::new(File::open(zip_path.as_ref())?)?; + + for i in 0..archive.len() { + let mut file = archive.by_index(i)?; + let mut out_path = PathBuf::from(extract_path); + out_path.push(file.sanitized_name().as_path()); + + let comment = file.comment(); + if !comment.is_empty() { + trace!("File {} comment: {}", i, comment); + } + + if (&*file.name()).ends_with('/') { + trace!( + "File {} extracted to \"{}\"", + i, + out_path.as_path().display() + ); + fs::create_dir_all(&out_path)?; + } else { + trace!( + "File {} extracted to \"{}\" ({} bytes)", + i, + out_path.as_path().display(), + file.size() + ); + if let Some(p) = out_path.parent() { + if !p.exists() { + fs::create_dir_all(&p).unwrap(); + } + } + let mut out_file = BufWriter::new(File::create(&out_path)?); + io::copy(&mut file, &mut out_file)?; + } + // Get and Set permissions + #[cfg(unix)] + { + use std::os::unix::fs::PermissionsExt; + + if let Some(mode) = file.unix_mode() { + fs::set_permissions(&out_path, fs::Permissions::from_mode(mode)).unwrap(); + } + } + } + Ok(()) + } + // unzip the downloaded file and do all the needed file manipulation + fn unzip>(&self, zip_path: P) -> Result { + let mut extract_path: PathBuf = zip_path + .as_ref() + .parent() + .ok_or_else(|| format_err!("zip_path does not have a parent directory"))? + .to_path_buf(); + + let folder_name = zip_path + .as_ref() + .file_stem() + .ok_or_else(|| format_err!("zip_path does not have a file stem"))?; + + extract_path.push(folder_name); + + fs::create_dir_all(&extract_path)?; + + info!( + "Extracting (this can take a while): {}", + extract_path.display() + ); + + self.do_unzip(zip_path.as_ref(), &extract_path)?; + + info!("Cleaning up"); + if fs::remove_file(&zip_path).is_err() { + info!("Failed to delete zip"); + return Ok(extract_path); + } + + Ok(extract_path) + } +} + +fn get_size>(url: U) -> Result { + let resp = ureq::get(url.as_ref()).call(); + match resp.header("Content-Length") { + Some(len) => Ok(u64::from_str(len)? / 2_u64.pow(20)), + None => Err(format_err!("response doesn't include the content length")), + } +} + +fn get_project_dirs() -> Result { + info!("Getting project dir"); + match ProjectDirs::from("", "", APP_NAME) { + Some(dirs) => Ok(dirs), + None => Err(format_err!("Failed to retrieve project dirs")), + } +} + +fn dl_url(revision: R) -> Result +where + R: AsRef, +{ + #[cfg(target_os = "linux")] + { + Ok(format!( + "{}/chromium-browser-snapshots/Linux_x64/{}/{}.zip", + DEFAULT_HOST, + revision.as_ref(), + archive_name(revision.as_ref())? + )) + } + + #[cfg(target_os = "macos")] + { + Ok(format!( + "{}/chromium-browser-snapshots/Mac/{}/{}.zip", + DEFAULT_HOST, + revision.as_ref(), + archive_name(revision.as_ref())? + )) + } + + #[cfg(windows)] + { + Ok(format!( + "{}/chromium-browser-snapshots/Win_x64/{}/{}.zip", + DEFAULT_HOST, + revision.as_ref(), + archive_name(revision.as_ref())? + )) + } +} + +fn archive_name>(revision: R) -> Result<&'static str> { + #[cfg(target_os = "linux")] + { + drop(revision); + + Ok("chrome-linux") + } + + #[cfg(target_os = "macos")] + { + drop(revision); + + Ok("chrome-mac") + } + + #[cfg(windows)] + { + // Windows archive name changed at r591479. + if revision.as_ref().parse::()? > 591_479 { + Ok("chrome-win") + } else { + Ok("chrome-win32") + } + } +} diff --git a/mdbook-pdf/headless_chrome/src/browser/mod.rs b/mdbook-pdf/headless_chrome/src/browser/mod.rs new file mode 100644 index 00000000..5eb3918f --- /dev/null +++ b/mdbook-pdf/headless_chrome/src/browser/mod.rs @@ -0,0 +1,480 @@ +use std::sync::mpsc; +use std::sync::mpsc::{RecvTimeoutError, TryRecvError}; +use std::sync::Arc; +use std::sync::Mutex; +use std::time::Duration; + +use anyhow::{Result}; +use log::*; + +use process::Process; +pub use process::{LaunchOptions, LaunchOptionsBuilder}; +pub use tab::Tab; +pub use transport::ConnectionClosed; +use transport::Transport; +use websocket::url::Url; +use which::which; + +use crate::protocol::cdp::{types::Event, types::Method, Browser as B, Target, CSS, DOM}; + +use crate::browser::context::Context; +use crate::util; +use Target::{CreateTarget, SetDiscoverTargets}; +use B::GetVersion; +pub use B::GetVersionReturnObject; + +#[cfg(feature = "fetch")] +pub use fetcher::FetcherOptions; + +pub mod context; +#[cfg(feature = "fetch")] +mod fetcher; +mod process; +pub mod tab; +pub mod transport; + +/// A handle to an instance of Chrome / Chromium, which wraps a WebSocket connection to its debugging port. +/// +/// +/// Most of your actual "driving" (e.g. clicking, typing, navigating) will be via instances of [Tab](../tab/struct.Tab.html), which are accessible via methods such as `get_tabs`. +/// +/// A Browser can either manage its own Chrome process or connect to a remote one. +/// +/// `Browser::default().unwrap()` will return a headless instance of whatever browser can be found using +/// `default_executable`, which will search on your PATH for relevant binaries or use the path +/// specified in the `CHROME` env var. +/// +/// You can use [LaunchOptions](../process/LaunchOptions.struct.html) to automatically +/// download a revision of Chromium that has a compatible API into your `$XDG_DATA_DIR`. Alternatively, +/// you can specify your own path to a binary, or make use of the `default_executable` function to use +/// your already-installed copy of Chrome. +/// +/// Option 1: Managing a Chrome process +/// ```rust +/// # use anyhow::Result; +/// # fn main() -> Result<()> { +/// # +/// use headless_chrome::Browser; +/// let browser = Browser::default()?; +/// let first_tab = browser.wait_for_initial_tab()?; +/// assert_eq!("about:blank", first_tab.get_url()); +/// # +/// # Ok(()) +/// # } +/// ``` +/// +/// Option 2: Connecting to a remote Chrome service +/// - see /examples/print_to_pdf.rs for a working example +/// +/// +/// While the Chrome DevTools Protocl (CDTP) does define some methods in a +/// ["Browser" domain](https://chromedevtools.github.io/devtools-protocol/tot/Browser) +/// (such as for resizing the window in non-headless mode), we currently don't implement those. +pub struct Browser { + process: Option, + transport: Arc, + tabs: Arc>>>, + loop_shutdown_tx: mpsc::Sender<()>, +} + +impl Browser { + /// Launch a new Chrome browser. + /// + /// The browser will have its user data (aka "profile") directory stored in a temporary directory. + /// The browser process will be killed when this struct is dropped. + pub fn new(launch_options: LaunchOptions) -> Result { + let idle_browser_timeout = launch_options.idle_browser_timeout; + let process = Process::new(launch_options)?; + let process_id = process.get_id(); + + let transport = Arc::new(Transport::new( + process.debug_ws_url.clone(), + Some(process_id), + idle_browser_timeout, + )?); + + Self::create_browser(Some(process), transport, idle_browser_timeout) + } + + /// Calls [`new`] with options to launch a headless browser using whatever Chrome / Chromium + /// binary can be found on the system. + pub fn default() -> Result { + let launch_options = LaunchOptions::default_builder() + .path(Some(default_executable().unwrap())) + .build() + .unwrap(); + Ok(Self::new(launch_options).unwrap()) + } + + /// Allows you to drive an externally-launched Chrome process instead of launch one via [`new`]. + /// If the browser is idle for 30 seconds, the connection will be dropped. + pub fn connect(debug_ws_url: String) -> Result { + Self::connect_with_timeout(debug_ws_url, Duration::from_secs(30)) + } + + /// Allows you to drive an externally-launched Chrome process instead of launch one via [`new`]. + /// If the browser is idle for `idle_browser_timeout`, the connection will be dropped. + pub fn connect_with_timeout( + debug_ws_url: String, + idle_browser_timeout: Duration, + ) -> Result { + let url = Url::parse(&debug_ws_url)?; + + let transport = Arc::new(Transport::new(url, None, idle_browser_timeout)?); + trace!("created transport"); + + Self::create_browser(None, transport, idle_browser_timeout) + } + + fn create_browser( + process: Option, + transport: Arc, + idle_browser_timeout: Duration, + ) -> Result { + let tabs = Arc::new(Mutex::new(vec![])); + + let (shutdown_tx, shutdown_rx) = mpsc::channel(); + + let browser = Self { + process, + tabs, + transport, + loop_shutdown_tx: shutdown_tx, + }; + + let incoming_events_rx = browser.transport.listen_to_browser_events(); + + browser.handle_browser_level_events( + incoming_events_rx, + browser.get_process_id(), + shutdown_rx, + idle_browser_timeout, + ); + trace!("created browser event listener"); + + // so we get events like 'targetCreated' and 'targetDestroyed' + trace!("Calling set discover"); + browser.call_method(SetDiscoverTargets { discover: true })?; + + let tab = browser.wait_for_initial_tab()?; + + tab.call_method(DOM::Enable(None))?; + tab.call_method(CSS::Enable(None))?; + + Ok(browser) + } + + pub fn get_process_id(&self) -> Option { + if let Some(process) = &self.process { + Some(process.get_id()) + } else { + None + } + } + + /// The tabs are behind an `Arc` and `Mutex` because they're accessible from multiple threads + /// (including the one that handles incoming protocol events about new or changed tabs). + pub fn get_tabs(&self) -> &Arc>>> { + &self.tabs + } + + /// Chrome always launches with at least one tab. The reason we have to 'wait' is because information + /// about that tab isn't available *immediately* after starting the process. Tabs are behind `Arc`s + /// because they each have their own thread which handles events and method responses directed to them. + pub fn wait_for_initial_tab(&self) -> Result> { + util::Wait::with_timeout(Duration::from_secs(300)) + .until(|| self.tabs.lock().unwrap().first().map(|tab| Arc::clone(tab))) + .map_err(Into::into) + } + + /// Create a new tab and return a handle to it. + /// + /// If you want to specify its starting options, see `new_tab_with_options`. + /// + /// ```rust + /// # use anyhow::Result; + /// # fn main() -> Result<()> { + /// # + /// # use headless_chrome::Browser; + /// # let browser = Browser::default()?; + /// let first_tab = browser.wait_for_initial_tab()?; + /// let new_tab = browser.new_tab()?; + /// let num_tabs = browser.get_tabs().lock().unwrap().len(); + /// assert_eq!(2, num_tabs); + /// # + /// # Ok(()) + /// # } + /// ``` + pub fn new_tab(&self) -> Result> { + let default_blank_tab = CreateTarget { + url: "about:blank".to_string(), + width: None, + height: None, + browser_context_id: None, + enable_begin_frame_control: None, + new_window: None, + background: None, + }; + self.new_tab_with_options(default_blank_tab) + } + + /// Create a new tab with a starting url, height / width, context ID and 'frame control' + /// ```rust + /// # use anyhow::Result; + /// # fn main() -> Result<()> { + /// # + /// # use headless_chrome::{Browser, protocol::target::methods::CreateTarget}; + /// # let browser = Browser::default()?; + /// let new_tab = browser.new_tab_with_options(CreateTarget { + /// url: "chrome://version", + /// width: Some(1024), + /// height: Some(800), + /// browser_context_id: None, + /// enable_begin_frame_control: None, + /// })?; + /// # + /// # Ok(()) + /// # } + /// ``` + pub fn new_tab_with_options(&self, create_target_params: CreateTarget) -> Result> { + let target_id = self.call_method(create_target_params)?.target_id; + + util::Wait::with_timeout(Duration::from_secs(20)) + .until(|| { + let tabs = self.tabs.lock().unwrap(); + tabs.iter().find_map(|tab| { + if *tab.get_target_id() == target_id { + Some(tab.clone()) + } else { + None + } + }) + }) + .map_err(Into::into) + } + + /// Creates the equivalent of a new incognito window, AKA a browser context + pub fn new_context(&self) -> Result { + debug!("Creating new browser context"); + let context_id = self + .call_method(Target::CreateBrowserContext { + dispose_on_detach: None, + proxy_server: None, + proxy_bypass_list: None, + origins_with_universal_network_access: None, + })? + .browser_context_id; + debug!("Created new browser context: {:?}", context_id); + Ok(Context::new(self, context_id)) + } + + /// Get version information + /// + /// ```rust + /// # use anyhow::Result; + /// # fn main() -> Result<()> { + /// # + /// # use headless_chrome::Browser; + /// # let browser = Browser::default()?; + /// let version_info = browser.get_version()?; + /// println!("User-Agent is `{}`", version_info.user_agent); + /// # + /// # Ok(()) + /// # } + /// ``` + pub fn get_version(&self) -> Result { + self.call_method(GetVersion(None)) + } + + fn handle_browser_level_events( + &self, + events_rx: mpsc::Receiver, + process_id: Option, + shutdown_rx: mpsc::Receiver<()>, + idle_browser_timeout: Duration, + ) { + let tabs = Arc::clone(&self.tabs); + let transport = Arc::clone(&self.transport); + + std::thread::spawn(move || { + trace!("Starting browser's event handling loop"); + loop { + match shutdown_rx.try_recv() { + Ok(_) | Err(TryRecvError::Disconnected) => { + info!("Browser event loop received shutdown message"); + break; + } + Err(TryRecvError::Empty) => {} + } + + match events_rx.recv_timeout(idle_browser_timeout) { + Err(recv_timeout_error) => { + match recv_timeout_error { + RecvTimeoutError::Timeout => { + error!( + "Got a timeout while listening for browser events (Chrome #{:?})", + process_id + ); + } + RecvTimeoutError::Disconnected => { + debug!( + "Browser event sender disconnected while loop was waiting (Chrome #{:?})", + process_id + ); + } + } + break; + } + Ok(event) => { + match event { + Event::TargetCreated(ev) => { + let target_info = ev.params.target_info; + trace!("Creating target: {:?}", target_info); + if target_info.Type == "page" { + match Tab::new(target_info, Arc::clone(&transport)) { + Ok(new_tab) => { + tabs.lock().unwrap().push(Arc::new(new_tab)); + } + Err(_tab_creation_err) => { + info!("Failed to create a handle to new tab"); + break; + } + } + } + } + Event::TargetInfoChanged(ev) => { + let target_info = ev.params.target_info; + trace!("Target info changed: {:?}", target_info); + if target_info.Type == "page" { + let locked_tabs = tabs.lock().unwrap(); + let updated_tab = locked_tabs + .iter() + .find(|tab| *tab.get_target_id() == target_info.target_id) + .expect("got TargetInfoChanged event about a tab not in our list"); + updated_tab.update_target_info(target_info); + } + } + Event::TargetDestroyed(ev) => { + trace!("Target destroyed: {:?}", ev.params.target_id); + let mut locked_tabs = tabs.lock().unwrap(); + let pos = locked_tabs + .iter() + .position(|tab| *tab.get_target_id() == ev.params.target_id); + + if let Some(idx) = pos { + locked_tabs.remove(idx); + } + } + _ => { + let mut raw_event = format!("{:?}", event); + raw_event.truncate(50); + trace!("Unhandled event: {}", raw_event); + } + } + } + } + } + info!("Finished browser's event handling loop"); + }); + } + + /// Call a browser method. + /// + /// See the `cdtp` module documentation for available methods. + fn call_method(&self, method: C) -> Result + where + C: Method + serde::Serialize, + { + self.transport.call_method_on_browser(method) + } + + #[allow(dead_code)] + #[cfg(test)] + pub(crate) fn process(&self) -> Option<&Process> { + #[allow(clippy::used_underscore_binding)] + self.process.as_ref() + } +} + +impl Drop for Browser { + fn drop(&mut self) { + info!("Dropping browser"); + let _ = self.loop_shutdown_tx.send(()); + self.transport.shutdown(); + } +} + +/// Returns the path to Chrome's executable. +/// +/// If the `CHROME` environment variable is set, `default_executable` will +/// use it as the default path. Otherwise, the filenames `google-chrome-stable` +/// `chromium`, `chromium-browser`, `chrome` and `chrome-browser` are +/// searched for in standard places. If that fails, +/// `/Applications/Google Chrome.app/...` (on MacOS) or the registry (on Windows) +/// is consulted. If all of the above fail, an error is returned. +pub fn default_executable() -> Result { + if let Ok(path) = std::env::var("CHROME") { + if std::path::Path::new(&path).exists() { + return Ok(path.into()); + } + } + + for app in &[ + "google-chrome-stable", + "google-chrome-beta", + "google-chrome-dev", + "google-chrome-unstable", + "chromium", + "chromium-browser", + "microsoft-edge-stable", + "microsoft-edge-beta", + "microsoft-edge-dev", + "chrome", + "chrome-browser", + "msedge" + ] { + if let Ok(path) = which(app) { + return Ok(path); + } + } + + #[cfg(target_os = "macos")] + { + for path in &[ + "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome", + "/Applications/Google Chrome Beta.app/Contents/MacOS/Google Chrome Beta", + "/Applications/Google Chrome Dev.app/Contents/MacOS/Google Chrome Dev", + "/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary", + "/Applications/Chromium.app/Contents/MacOS/Chromium", + "/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge", + "/Applications/Microsoft Edge Beta.app/Contents/MacOS/Microsoft Edge Beta", + "/Applications/Microsoft Edge Dev.app/Contents/MacOS/Microsoft Edge Dev", + "/Applications/Microsoft Edge Canary.app/Contents/MacOS/Microsoft Edge Canary" + ][..] { + if std::path::Path::new(path).exists() { + return Ok(path.into()); + } + } + } + + #[cfg(windows)] + { + use crate::browser::process::get_chrome_path_from_registry; + + if let Some(path) = get_chrome_path_from_registry() { + if path.exists() { + return Ok(path); + } else { + for path in &[ + r"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" + ][..] { + if std::path::Path::new(path).exists() { + return Ok(path.into()); + } + } + } + } + } + + Err("Could not auto detect a chrome executable".to_string()) +} diff --git a/mdbook-pdf/headless_chrome/src/browser/process.rs b/mdbook-pdf/headless_chrome/src/browser/process.rs new file mode 100644 index 00000000..abd1f925 --- /dev/null +++ b/mdbook-pdf/headless_chrome/src/browser/process.rs @@ -0,0 +1,580 @@ +use std::{ + borrow::BorrowMut, + ffi::OsStr, + io::{prelude::*, BufRead, BufReader}, + net, + process::{Child, Command, Stdio}, + time::Duration, +}; + +use anyhow::{anyhow,Result}; +use thiserror::Error; +use log::*; +use rand::seq::SliceRandom; +use rand::thread_rng; +use regex::Regex; +use websocket::url::Url; +#[cfg(windows)] +use winreg::{enums::HKEY_LOCAL_MACHINE, RegKey}; + +#[cfg(not(feature = "fetch"))] +use crate::browser::default_executable; +use crate::util; + +#[cfg(feature = "fetch")] +use super::fetcher::{Fetcher, FetcherOptions}; +use std::collections::HashMap; + +pub struct Process { + child_process: TemporaryProcess, + pub debug_ws_url: Url, +} + +#[derive(Debug, Error)] +enum ChromeLaunchError { + #[error("Chrome launched, but didn't give us a WebSocket URL before we timed out")] + PortOpenTimeout, + #[error("There are no available ports between 8000 and 9000 for debugging")] + NoAvailablePorts, + #[error("The chosen debugging port is already in use")] + DebugPortInUse, +} + +#[cfg(windows)] +pub(crate) fn get_chrome_path_from_registry() -> Option { + RegKey::predef(HKEY_LOCAL_MACHINE) + .open_subkey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\chrome.exe") + .and_then(|key| key.get_value::("")) + .map(std::path::PathBuf::from) + .ok() +} + +struct TemporaryProcess(Child); + +impl Drop for TemporaryProcess { + fn drop(&mut self) { + info!("Killing Chrome. PID: {}", self.0.id()); + self.0.kill().and_then(|_| self.0.wait()).ok(); + } +} + +/// Represents the way in which Chrome is run. By default it will search for a Chrome +/// binary on the system, use an available port for debugging, and start in headless mode. +#[derive(Builder)] +pub struct LaunchOptions<'a> { + /// Determintes whether to run headless version of the browser. Defaults to true. + #[builder(default = "true")] + pub headless: bool, + + /// Determines whether to run the browser with a sandbox. + #[builder(default = "true")] + pub sandbox: bool, + + /// Launch the browser with a specific window width and height. + #[builder(default = "None")] + pub window_size: Option<(u32, u32)>, + + /// Launch the browser with a specific debugging port. + #[builder(default = "None")] + pub port: Option, + /// Determines whether SSL certificates should be verified. + /// This is unsafe and can lead to MiTM attacks. Make sure you understand the risks + /// See https://www.owasp.org/index.php/Man-in-the-middle_attack + #[builder(default = "true")] + pub ignore_certificate_errors: bool, + + /// Path for Chrome or Chromium. + /// + /// If unspecified, the create will try to automatically detect a suitable binary. + #[builder(default = "None")] + pub path: Option, + + /// User Data (Profile) to use. + /// + /// If unspecified, a new temp directory is created and used on every launch. + #[builder(default = "None")] + pub user_data_dir: Option, + + /// A list of Chrome extensions to load. + /// + /// An extension should be a path to a folder containing the extension code. + /// CRX files cannot be used directly and must be first extracted. + /// + /// Note that Chrome does not support loading extensions in headless-mode. + /// See https://bugs.chromium.org/p/chromium/issues/detail?id=706008#c5 + #[builder(default)] + pub extensions: Vec<&'a OsStr>, + + /// Additional arguments to pass to the browser instance. The list of Chromium + /// flags can be found: http://peter.sh/experiments/chromium-command-line-switches/. + #[builder(default)] + pub args: Vec<&'a OsStr>, + + /// The options to use for fetching a version of chrome when `path` is None. + /// + /// By default, we'll use a revision guaranteed to work with our API and will + /// download and install that revision of chrome the first time a Process is created. + #[cfg(feature = "fetch")] + #[builder(default)] + fetcher_options: FetcherOptions, + + /// How long to keep the WebSocket to the browser for after not receiving any events from it + /// Defaults to 30 seconds + #[builder(default = "Duration::from_secs(30)")] + pub idle_browser_timeout: Duration, + + /// Environment variables to set for the Chromium process. + /// Passes value through to std::process::Command::envs. + #[builder(default = "None")] + pub process_envs: Option>, +} + +impl<'a> Default for LaunchOptions<'a> { + fn default() -> Self { + LaunchOptions { + headless: true, + sandbox: true, + idle_browser_timeout: Duration::from_secs(30), + window_size: None, + path: None, + user_data_dir: None, + port: None, + ignore_certificate_errors: true, + extensions: Vec::new(), + process_envs: None, + #[cfg(feature = "fetch")] + fetcher_options: Default::default(), + args: Vec::new(), + } + } +} + +impl<'a> LaunchOptions<'a> { + pub fn default_builder() -> LaunchOptionsBuilder<'a> { + LaunchOptionsBuilder::default() + } +} + +/// These are passed to the Chrome binary by default. +/// Via https://github.com/GoogleChrome/puppeteer/blob/master/lib/Launcher.js#L38 +static DEFAULT_ARGS: [&str; 23] = [ + "--disable-background-networking", + "--enable-features=NetworkService,NetworkServiceInProcess", + "--disable-background-timer-throttling", + "--disable-backgrounding-occluded-windows", + "--disable-breakpad", + "--disable-client-side-phishing-detection", + "--disable-component-extensions-with-background-pages", + "--disable-default-apps", + "--disable-dev-shm-usage", + "--disable-extensions", + // BlinkGenPropertyTrees disabled due to crbug.com/937609 + "--disable-features=TranslateUI,BlinkGenPropertyTrees", + "--disable-hang-monitor", + "--disable-ipc-flooding-protection", + "--disable-popup-blocking", + "--disable-prompt-on-repost", + "--disable-renderer-backgrounding", + "--disable-sync", + "--force-color-profile=srgb", + "--metrics-recording-only", + "--no-first-run", + "--enable-automation", + "--password-store=basic", + "--use-mock-keychain", +]; + +impl Process { + pub fn new(mut launch_options: LaunchOptions) -> Result { + if launch_options.path.is_none() { + #[cfg(feature = "fetch")] + { + let fetch = Fetcher::new(launch_options.fetcher_options.clone())?; + launch_options.path = Some(fetch.fetch()?); + } + #[cfg(not(feature = "fetch"))] + { + launch_options.path = Some(default_executable().map_err(|e| anyhow!("{}", e))?); + } + } + + let mut process = Self::start_process(&launch_options)?; + + info!("Started Chrome. PID: {}", process.0.id()); + + let url; + let mut attempts = 0; + loop { + if attempts > 10 { + return Err(ChromeLaunchError::NoAvailablePorts {}.into()); + } + + match Self::ws_url_from_output(process.0.borrow_mut()) { + Ok(debug_ws_url) => { + url = debug_ws_url; + debug!("Found debugging WS URL: {:?}", url); + break; + } + Err(error) => { + trace!("Problem getting WebSocket URL from Chrome: {}", error); + if launch_options.port.is_none() { + process = Self::start_process(&launch_options)?; + } else { + return Err(error); + } + } + } + + trace!( + "Trying again to find available debugging port. Attempts: {}", + attempts + ); + attempts += 1; + } + + let mut child = process.0.borrow_mut(); + child.stderr = None; + + Ok(Self { + child_process: process, + debug_ws_url: url, + }) + } + + fn start_process(launch_options: &LaunchOptions) -> Result { + let debug_port = if let Some(port) = launch_options.port { + port + } else { + get_available_port().ok_or(ChromeLaunchError::NoAvailablePorts {})? + }; + let port_option = format!("--remote-debugging-port={}", debug_port); + + let window_size_option = if let Some((width, height)) = launch_options.window_size { + format!("--window-size={},{}", width, height) + } else { + String::from("") + }; + + // User data directory + let user_data_dir = if let Some(dir) = &launch_options.user_data_dir { + dir.to_owned() + } else { + // picking random data dir so that each a new browser instance is launched + // (see man google-chrome) + ::tempfile::Builder::new() + .prefix("rust-headless-chrome-profile") + .tempdir()? + .path() + .to_path_buf() + }; + let data_dir_option = format!("--user-data-dir={}", &user_data_dir.to_str().unwrap()); + + trace!("Chrome will have profile: {}", data_dir_option); + + let mut args = vec![ + port_option.as_str(), + "--disable-gpu", + "--enable-logging", + "--verbose", + "--log-level=0", + "--no-first-run", + "--disable-audio-output", + data_dir_option.as_str(), + ]; + + args.extend(&DEFAULT_ARGS); + + if !launch_options.args.is_empty() { + let extra_args: Vec<&str> = launch_options + .args + .iter() + .map(|a| a.to_str().unwrap()) + .collect(); + args.extend(extra_args); + } + + if !window_size_option.is_empty() { + args.extend(&[window_size_option.as_str()]); + } + + if launch_options.headless { + args.extend(&["--headless"]); + } + + if launch_options.ignore_certificate_errors { + args.extend(&["--ignore-certificate-errors"]) + } + + if !launch_options.sandbox { + args.extend(&["--no-sandbox", "--disable-setuid-sandbox"]); + } + + let extension_args: Vec = launch_options + .extensions + .iter() + .map(|e| format!("--load-extension={}", e.to_str().unwrap())) + .collect(); + + args.extend(extension_args.iter().map(String::as_str)); + + let path = launch_options + .path + .as_ref() + .ok_or_else(|| anyhow!("Chrome path required"))?; + + info!("Launching Chrome binary at {:?}", &path); + let mut command = Command::new(&path); + + if let Some(process_envs) = launch_options.process_envs.clone() { + command.envs(process_envs); + } + + let process = TemporaryProcess(command.args(&args).stderr(Stdio::piped()).spawn()?); + Ok(process) + } + + fn ws_url_from_reader(reader: BufReader) -> Result> + where + R: Read, + { + let port_taken_re = Regex::new(r"ERROR.*bind\(\)").unwrap(); + + let re = Regex::new(r"listening on (.*/devtools/browser/.*)$").unwrap(); + + let extract = |text: &str| -> Option { + let caps = re.captures(text); + let cap = &caps?[1]; + Some(cap.into()) + }; + + for line in reader.lines() { + let chrome_output = line?; + trace!("Chrome output: {}", chrome_output); + + if port_taken_re.is_match(&chrome_output) { + return Err(ChromeLaunchError::DebugPortInUse {}.into()); + } + + if let Some(answer) = extract(&chrome_output) { + return Ok(Some(answer)); + } + } + + Ok(None) + } + + fn ws_url_from_output(child_process: &mut Child) -> Result { + let chrome_output_result = util::Wait::with_timeout(Duration::from_secs(30)).until(|| { + let my_stderr = BufReader::new(child_process.stderr.as_mut().unwrap()); + match Self::ws_url_from_reader(my_stderr) { + Ok(output_option) => { + if let Some(output) = output_option { + Some(Ok(output)) + } else { + None + } + } + Err(err) => Some(Err(err)), + } + }); + + if let Ok(output_result) = chrome_output_result { + + Ok(Url::parse(&output_result?)?) + } else { + Err(ChromeLaunchError::PortOpenTimeout {}.into()) + } + } + + pub fn get_id(&self) -> u32 { + self.child_process.0.id() + } +} + +fn get_available_port() -> Option { + let mut ports: Vec = (8000..9000).collect(); + ports.shuffle(&mut thread_rng()); + ports.iter().find(|port| port_is_available(**port)).cloned() +} + +fn port_is_available(port: u16) -> bool { + net::TcpListener::bind(("127.0.0.1", port)).is_ok() +} + +#[cfg(test)] +mod tests { + #[cfg(feature = "fetch")] + use std::fs; + #[cfg(feature = "fetch")] + use std::path::PathBuf; + + use std::sync::Once; + use std::thread; + + use crate::browser::default_executable; + + use super::*; + + static INIT: Once = Once::new(); + + fn setup() { + INIT.call_once(|| { + env_logger::try_init().unwrap_or(()); + }); + } + + #[test] + fn can_launch_chrome_and_get_ws_url() { + setup(); + let chrome = super::Process::new( + LaunchOptions::default_builder() + .path(Some(default_executable().unwrap())) + .build() + .unwrap(), + ) + .unwrap(); + info!("{:?}", chrome.debug_ws_url); + } + + #[test] + #[cfg(feature = "fetch")] + fn can_install_chrome_to_dir_and_launch() { + use crate::browser::fetcher::CUR_REV; + #[cfg(target_os = "linux")] + const PLATFORM: &str = "linux"; + #[cfg(target_os = "macos")] + const PLATFORM: &str = "mac"; + #[cfg(windows)] + const PLATFORM: &str = "win"; + + let tests_temp_dir = [env!("CARGO_MANIFEST_DIR"), "tests", "temp"] + .iter() + .collect::(); + + setup(); + + // clean up any artifacts from a previous run of this test. + // if we do this after it fails on windows because chrome can stay running + // for a bit. + let mut installed_dir = tests_temp_dir.clone(); + installed_dir.push(format!("{}-{}", PLATFORM, CUR_REV)); + + if installed_dir.exists() { + info!("Deleting pre-existing install at {:?}", &installed_dir); + fs::remove_dir_all(&installed_dir).expect("Could not delete pre-existing install"); + } + + let chrome = super::Process::new( + LaunchOptions::default_builder() + .fetcher_options(FetcherOptions::default().with_install_dir(Some(&tests_temp_dir))) + .build() + .unwrap(), + ) + .unwrap(); + info!("{:?}", chrome.debug_ws_url); + } + + #[test] + fn handle_errors_in_chrome_output() { + setup(); + let lines = "[0228/194641.093619:ERROR:socket_posix.cc(144)] bind() returned an error, errno=0: Cannot assign requested address (99)"; + let reader = BufReader::new(lines.as_bytes()); + let ws_url_result = Process::ws_url_from_reader(reader); + assert!(ws_url_result.is_err()); + } + + #[test] + fn handle_errors_in_chrome_output_gvisor_netlink() { + // see https://github.com/atroche/rust-headless-chrome/issues/261 + setup(); + let lines = "[0703/145506.975691:ERROR:address_tracker_linux.cc(214)] Could not bind NETLINK socket: Permission denied (13)"; + + let reader = BufReader::new(lines.as_bytes()); + let ws_url_result = Process::ws_url_from_reader(reader); + assert_eq!(true, ws_url_result.is_ok()); + } + + #[cfg(target_os = "linux")] + fn current_child_pids() -> Vec { + use std::fs::File; + use std::io::prelude::*; + let current_pid = std::process::id(); + let mut current_process_children_file = File::open(format!( + "/proc/{}/task/{}/children", + current_pid, current_pid + )) + .unwrap(); + let mut child_pids = String::new(); + current_process_children_file + .read_to_string(&mut child_pids) + .unwrap(); + child_pids + .split_whitespace() + .map(|pid_str| pid_str.parse::().unwrap()) + .collect() + } + + #[test] + #[cfg(target_os = "linux")] + fn kills_process_on_drop() { + setup(); + { + let _chrome = &mut super::Process::new( + LaunchOptions::default_builder() + .path(Some(default_executable().unwrap())) + .build() + .unwrap(), + ) + .unwrap(); + } + + let child_pids = current_child_pids(); + assert!(child_pids.is_empty()); + } + + #[test] + fn launch_multiple_non_headless_instances() { + setup(); + let mut handles = Vec::new(); + + for _ in 0..10 { + let handle = thread::spawn(|| { + // these sleeps are to make it more likely the chrome startups will overlap + std::thread::sleep(std::time::Duration::from_millis(10)); + let chrome = super::Process::new( + LaunchOptions::default_builder() + .path(Some(default_executable().unwrap())) + .build() + .unwrap(), + ) + .unwrap(); + std::thread::sleep(std::time::Duration::from_millis(100)); + chrome.debug_ws_url.clone() + }); + handles.push(handle); + } + + for handle in handles { + handle.join().unwrap(); + } + } + + #[test] + fn no_instance_sharing() { + setup(); + + let mut handles = Vec::new(); + + for _ in 0..10 { + let chrome = super::Process::new( + LaunchOptions::default_builder() + .path(Some(default_executable().unwrap())) + .headless(true) + .build() + .unwrap(), + ) + .unwrap(); + handles.push(chrome); + } + } +} diff --git a/mdbook-pdf/headless_chrome/src/browser/tab/element/box_model.rs b/mdbook-pdf/headless_chrome/src/browser/tab/element/box_model.rs new file mode 100644 index 00000000..92f6f4f8 --- /dev/null +++ b/mdbook-pdf/headless_chrome/src/browser/tab/element/box_model.rs @@ -0,0 +1,198 @@ +use crate::protocol::cdp::Page; + +use crate::browser::tab::point::Point; + +#[derive(Debug, Copy, Clone)] +pub struct ElementQuad { + pub top_left: Point, + pub top_right: Point, + pub bottom_left: Point, + pub bottom_right: Point, +} + +impl ElementQuad { + pub fn from_raw_points(raw_quad: &[f64]) -> Self { + Self { + top_left: Point { + x: raw_quad[0], + y: raw_quad[1], + }, + top_right: Point { + x: raw_quad[2], + y: raw_quad[3], + }, + bottom_right: Point { + x: raw_quad[4], + y: raw_quad[5], + }, + bottom_left: Point { + x: raw_quad[6], + y: raw_quad[7], + }, + } + } + + pub fn height(&self) -> f64 { + self.bottom_left.y - self.top_left.y + } + + pub fn width(&self) -> f64 { + self.top_right.x - self.top_left.x + } + + /// The width divided by the height + pub fn aspect_ratio(&self) -> f64 { + self.width() / self.height() + } + + /// The most left (smallest) x-coordinate + pub fn most_left(&self) -> f64 { + self.top_right + .x + .min(self.top_left.x) + .min(self.bottom_right.x) + .min(self.bottom_left.x) + } + + /// The most right (largest) x-coordinate + pub fn most_right(&self) -> f64 { + self.top_right + .x + .max(self.top_left.x) + .max(self.bottom_right.x) + .max(self.bottom_left.x) + } + + /// The most top (smallest) y-coordinate + pub fn most_top(&self) -> f64 { + self.top_right + .y + .min(self.top_left.y) + .min(self.bottom_right.y) + .min(self.bottom_left.y) + } + + /// The most bottom (largest) y-coordinate + fn most_bottom(&self) -> f64 { + self.top_right + .y + .max(self.top_left.y) + .max(self.bottom_right.y) + .max(self.bottom_left.y) + } + + /// If the most bottom point of `self` is above the most top point of `other` + pub fn strictly_above(&self, other: &Self) -> bool { + self.most_bottom() < other.most_top() + } + + /// If the most bottom point of `self` is above or on the same line as the + /// most top point of `other` + pub fn above(&self, other: &Self) -> bool { + self.most_bottom() <= other.most_top() + } + + /// If the most top point of `self` is below the most bottom point of `other` + pub fn strictly_below(&self, other: &Self) -> bool { + self.most_top() > other.most_bottom() + } + + /// If the most top point of `self` is below or on the same line as the + /// most bottom point of `other` + pub fn below(&self, other: &Self) -> bool { + self.most_top() >= other.most_bottom() + } + + /// If the most right point of `self` is left of the most left point of `other` + pub fn strictly_left_of(&self, other: &Self) -> bool { + self.most_right() < other.most_left() + } + + /// If the most right point of `self` is left or on the same line as the + /// most left point of `other` + pub fn left_of(&self, other: &Self) -> bool { + self.most_right() <= other.most_left() + } + + /// If the most left point of `self` is right of the most right point of `other` + pub fn strictly_right_of(&self, other: &Self) -> bool { + self.most_left() > other.most_right() + } + + /// If the most left point of `self` is right or on the same line as the + /// most right point of `other` + pub fn right_of(&self, other: &Self) -> bool { + self.most_left() >= other.most_right() + } + + /// If `self` is within the left/right boundaries defined by `other`. + pub fn within_horizontal_bounds_of(&self, other: &Self) -> bool { + self.most_left() >= other.most_left() && self.most_right() <= other.most_right() + } + + /// If `self` is within the top/bottom boundaries defined by `other`. + pub fn within_vertical_bounds_of(&self, other: &Self) -> bool { + self.most_top() >= other.most_top() && self.most_bottom() <= other.most_bottom() + } + + /// If `self` is within the boundaries defined by `other`. + pub fn within_bounds_of(&self, other: &Self) -> bool { + self.within_horizontal_bounds_of(&other) && self.within_vertical_bounds_of(&other) + } +} + +#[derive(Debug, Clone)] +pub struct BoxModel { + pub content: ElementQuad, + pub padding: ElementQuad, + pub border: ElementQuad, + pub margin: ElementQuad, + pub width: f64, + pub height: f64, +} + +impl BoxModel { + /// Create a `page::Viewport` equal to the content-box, using a scale of 1.0 + pub fn content_viewport(&self) -> Page::Viewport { + Page::Viewport { + x: self.content.top_left.x, + y: self.content.top_left.y, + width: self.content.width(), + height: self.content.height(), + scale: 1.0, + } + } + + /// Create a `page::Viewport` equal to the padding-box, using a scale of 1.0 + pub fn padding_viewport(&self) -> Page::Viewport { + Page::Viewport { + x: self.padding.top_left.x, + y: self.padding.top_left.y, + width: self.padding.width(), + height: self.padding.height(), + scale: 1.0, + } + } + + /// Create a `page::Viewport` equal to the border-box, using a scale of 1.0 + pub fn border_viewport(&self) -> Page::Viewport { + Page::Viewport { + x: self.border.top_left.x, + y: self.border.top_left.y, + width: self.border.width(), + height: self.border.height(), + scale: 1.0, + } + } + + /// Create a `page::Viewport` equal to the margin-box, using a scale of 1.0 + pub fn margin_viewport(&self) -> Page::Viewport { + Page::Viewport { + x: self.margin.top_left.x, + y: self.margin.top_left.y, + width: self.margin.width(), + height: self.margin.height(), + scale: 1.0, + } + } +} diff --git a/mdbook-pdf/headless_chrome/src/browser/tab/element/mod.rs b/mdbook-pdf/headless_chrome/src/browser/tab/element/mod.rs new file mode 100644 index 00000000..fee6291a --- /dev/null +++ b/mdbook-pdf/headless_chrome/src/browser/tab/element/mod.rs @@ -0,0 +1,556 @@ +use std::fmt::Debug; +use std::time::Duration; + +use anyhow::{Error, Result}; + +use thiserror::Error; + +use log::*; + +use crate::{browser::tab::point::Point, protocol::cdp::CSS::CSSComputedStyleProperty}; +use crate::browser::tab::NoElementFound; + +mod box_model; + +use crate::util; +pub use box_model::{BoxModel, ElementQuad}; + +use crate::protocol::cdp::{Page,CSS, Runtime, DOM}; + +#[derive(Debug, Error)] +#[error("Couldnt get element quad")] +pub struct NoQuadFound {} +/// A handle to a [DOM Element](https://developer.mozilla.org/en-US/docs/Web/API/Element). +/// +/// Typically you get access to these by passing `Tab.wait_for_element` a CSS selector. Once +/// you have a handle to an element, you can click it, type into it, inspect its +/// attributes, and more. You can even run a JavaScript function inside the tab which can reference +/// the element via `this`. +pub struct Element<'a> { + pub remote_object_id: String, + pub backend_node_id: DOM::NodeId, + pub node_id: DOM::NodeId, + pub parent: &'a super::Tab, +} + +impl<'a> Debug for Element<'a> { + fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> { + write!(f, "Element {}", self.backend_node_id)?; + Ok(()) + } +} + +impl<'a> Element<'a> { + /// Using a 'node_id', of the type returned by QuerySelector and QuerySelectorAll, this finds + /// the 'backend_node_id' and 'remote_object_id' which are stable identifiers, unlike node_id. + /// We use these two when making various calls to the API because of that. + pub fn new(parent: &'a super::Tab, node_id: DOM::NodeId) -> Result { + if node_id == 0 { + return Err(NoElementFound {}.into()); + } + + let backend_node_id = parent + .describe_node(node_id) + .map_err(NoElementFound::map)? + .backend_node_id; + + let remote_object_id = { + let object = parent + .call_method(DOM::ResolveNode { + backend_node_id: Some(backend_node_id), + node_id: None, + object_group: None, + execution_context_id: None, + })? + .object; + object.object_id.expect("couldn't find object ID") + }; + + Ok(Element { + remote_object_id, + backend_node_id, + node_id, + parent, + }) + } + + /// Returns the first element in the document which matches the given CSS selector. + /// + /// Equivalent to the following JS: + /// + /// ```js + /// document.querySelector(selector) + /// ``` + /// + /// ```rust + /// # use anyhow::Result; + /// # // Awful hack to get access to testing utils common between integration, doctest, and unit tests + /// # mod server { + /// # include!("../../../testing_utils/server.rs"); + /// # } + /// # fn main() -> Result<()> { + /// # + /// use headless_chrome::Browser; + /// + /// let browser = Browser::default()?; + /// let initial_tab = browser.wait_for_initial_tab()?; + /// + /// let file_server = server::Server::with_dumb_html(include_str!("../../../../tests/simple.html")); + /// let containing_element = initial_tab.navigate_to(&file_server.url())? + /// .wait_until_navigated()? + /// .find_element("div#position-test")?; + /// let inner_element = containing_element.find_element("#strictly-above")?; + /// let attrs = inner_element.get_attributes()?.unwrap(); + /// assert_eq!(attrs["id"], "strictly-above"); + /// # + /// # Ok(()) + /// # } + /// ``` + pub fn find_element(&self, selector: &str) -> Result { + self.parent + .run_query_selector_on_node(self.node_id, selector) + } + + pub fn find_element_by_xpath(&self, query: &str) -> Result> { + self.parent.get_document()?; + + self.parent + .call_method(DOM::PerformSearch { + query: query.to_string(), + include_user_agent_shadow_dom: Some(true), + }) + .and_then(|o| { + Ok(self + .parent + .call_method(DOM::GetSearchResults { + search_id: o.search_id, + from_index: 0, + to_index: o.result_count, + })? + .node_ids[0]) + }) + .and_then(|id| { + if id == 0 { + Err(NoElementFound {}.into()) + } else { + Ok(Element::new(self.parent, id)?) + } + }) + } + + /// Returns the first element in the document which matches the given CSS selector. + /// + /// Equivalent to the following JS: + /// + /// ```js + /// document.querySelector(selector) + /// ``` + /// + /// ```rust + /// # use anyhow::Result; + /// # // Awful hack to get access to testing utils common between integration, doctest, and unit tests + /// # mod server { + /// # include!("../../../testing_utils/server.rs"); + /// # } + /// # fn main() -> Result<()> { + /// # + /// use headless_chrome::Browser; + /// + /// let browser = Browser::default()?; + /// let initial_tab = browser.wait_for_initial_tab()?; + /// + /// let file_server = server::Server::with_dumb_html(include_str!("../../../../tests/simple.html")); + /// let containing_element = initial_tab.navigate_to(&file_server.url())? + /// .wait_until_navigated()? + /// .find_element("div#position-test")?; + /// let inner_divs = containing_element.find_elements("div")?; + /// assert_eq!(inner_divs.len(), 5); + /// # + /// # Ok(()) + /// # } + /// ``` + pub fn find_elements(&self, selector: &str) -> Result> { + self.parent + .run_query_selector_all_on_node(self.node_id, selector) + } + + pub fn find_elements_by_xpath(&self, query: &str) -> Result>> { + self.parent.get_document()?; + self.parent + .call_method(DOM::PerformSearch { + query: query.to_string(), + include_user_agent_shadow_dom: Some(true), + }) + .and_then(|o| { + Ok(self + .parent + .call_method(DOM::GetSearchResults { + search_id: o.search_id, + from_index: 0, + to_index: o.result_count, + })? + .node_ids) + }) + .and_then(|ids| { + ids.iter() + .filter(|id| **id != 0) + .map(|id| Element::new(self.parent, *id)) + .collect() + }) + } + + pub fn wait_for_element(&self, selector: &str) -> Result> { + self.wait_for_element_with_custom_timeout(selector, Duration::from_secs(3)) + } + + pub fn wait_for_xpath(&self, selector: &str) -> Result> { + self.wait_for_xpath_with_custom_timeout(selector, Duration::from_secs(3)) + } + + pub fn wait_for_element_with_custom_timeout( + &self, + selector: &str, + timeout: std::time::Duration, + ) -> Result> { + debug!("Waiting for element with selector: {:?}", selector); + util::Wait::with_timeout(timeout).strict_until( + || self.find_element(selector), + Error::downcast::, + ) + } + + pub fn wait_for_xpath_with_custom_timeout( + &self, + selector: &str, + timeout: std::time::Duration, + ) -> Result> { + debug!("Waiting for element with selector: {:?}", selector); + util::Wait::with_timeout(timeout).strict_until( + || self.find_element_by_xpath(selector), + Error::downcast::, + ) + } + + pub fn wait_for_elements(&self, selector: &str) -> Result>> { + debug!("Waiting for element with selector: {:?}", selector); + util::Wait::with_timeout(Duration::from_secs(3)).strict_until( + || self.find_elements(selector), + Error::downcast::, + ) + } + + pub fn wait_for_elements_by_xpath(&self, selector: &str) -> Result>> { + debug!("Waiting for element with selector: {:?}", selector); + util::Wait::with_timeout(Duration::from_secs(3)).strict_until( + || self.find_elements_by_xpath(selector), + Error::downcast::, + ) + } + + /// Moves the mouse to the middle of this element + pub fn move_mouse_over(&self) -> Result<&Self> { + self.scroll_into_view()?; + let midpoint = self.get_midpoint()?; + self.parent.move_mouse_to_point(midpoint)?; + Ok(self) + } + + pub fn click(&self) -> Result<&Self> { + self.scroll_into_view()?; + debug!("Clicking element {:?}", &self); + let midpoint = self.get_midpoint()?; + self.parent.click_point(midpoint)?; + Ok(self) + } + + pub fn type_into(&self, text: &str) -> Result<&Self> { + self.click()?; + + debug!("Typing into element ( {:?} ): {}", &self, text); + + self.parent.type_str(text)?; + + Ok(self) + } + + pub fn call_js_fn( + &self, + function_declaration: &str, + args: Vec, + await_promise: bool, + ) -> Result { + let mut args = args.clone(); + let result = self + .parent + .call_method(Runtime::CallFunctionOn { + object_id: Some(self.remote_object_id.clone()), + function_declaration: function_declaration.to_string(), + arguments: args + .iter_mut() + .map(|v| { + Some(Runtime::CallArgument { + value: Some(v.take()), + unserializable_value: None, + object_id: None, + }) + }) + .collect(), + return_by_value: Some(false), + generate_preview: Some(true), + silent: Some(false), + await_promise: Some(await_promise), + user_gesture: None, + execution_context_id: None, + object_group: None, + throw_on_side_effect: None, + })? + .result; + + Ok(result) + } + + pub fn focus(&self) -> Result<&Self> { + self.scroll_into_view()?; + self.parent.call_method(DOM::Focus { + backend_node_id: Some(self.backend_node_id), + node_id: None, + object_id: None, + })?; + Ok(self) + } + + /// Returns the inner text of an HTML Element. Returns an empty string on elements with no text. + /// + /// Note: .innerText and .textContent are not the same thing. See: + /// https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/innerText + /// + /// Note: if you somehow call this on a node that's not an HTML Element (e.g. `document`), this + /// will fail. + /// ```rust + /// # use anyhow::Result; + /// # fn main() -> Result<()> { + /// # + /// use headless_chrome::Browser; + /// use std::time::Duration; + /// let browser = Browser::default()?; + /// let url = "https://web.archive.org/web/20190403224553/https://en.wikipedia.org/wiki/JavaScript"; + /// let inner_text_content = browser.wait_for_initial_tab()? + /// .navigate_to(url)? + /// .wait_for_element_with_custom_timeout("#Misplaced_trust_in_developers", Duration::from_secs(10))? + /// .get_inner_text()?; + /// assert_eq!(inner_text_content, "Misplaced trust in developers"); + /// # + /// # Ok(()) + /// # } + /// ``` + pub fn get_inner_text(&self) -> Result { + let text: String = serde_json::from_value( + self.call_js_fn("function() { return this.innerText }", vec![], false)? + .value + .unwrap(), + )?; + Ok(text) + } + + pub fn get_computed_styles(&self) -> Result> { + let styles = self + .parent + .call_method(CSS::GetComputedStyleForNode { + node_id: self.node_id, + })? + .computed_style; + + Ok(styles) + } + + pub fn get_description(&self) -> Result { + let node = self + .parent + .call_method(DOM::DescribeNode { + node_id: None, + backend_node_id: Some(self.backend_node_id), + depth: Some(100), + object_id: None, + pierce: None, + })? + .node; + Ok(node) + } + + /// Capture a screenshot of this element. + /// + /// The screenshot is taken from the surface using this element's content-box. + /// + /// ```rust,no_run + /// # use anyhow::Result; + /// # fn main() -> Result<()> { + /// # + /// use headless_chrome::{protocol::page::ScreenshotFormat, Browser}; + /// let browser = Browser::default()?; + /// let png_data = browser.wait_for_initial_tab()? + /// .navigate_to("https://en.wikipedia.org/wiki/WebKit")? + /// .wait_for_element("#mw-content-text > div > table.infobox.vevent")? + /// .capture_screenshot(ScreenshotFormat::PNG)?; + /// # + /// # Ok(()) + /// # } + /// ``` + pub fn capture_screenshot( + &self, + format: Page::CaptureScreenshotFormatOption, + ) -> Result> { + self.scroll_into_view()?; + self.parent.capture_screenshot( + format, + Some(90), + Some(self.get_box_model()?.content_viewport()), + true, + ) + } + + pub fn set_input_files(&self, file_paths: &[&str]) -> Result<&Self> { + self.parent.call_method(DOM::SetFileInputFiles { + files: file_paths.to_vec().iter().map(|v| v.to_string()).collect(), + backend_node_id: Some(self.backend_node_id), + node_id: None, + object_id: None, + })?; + Ok(self) + } + + /// Scrolls the current element into view + /// + /// Used prior to any action applied to the current element to ensure action is duable. + pub fn scroll_into_view(&self) -> Result<&Self> { + let result = self.call_js_fn( + "async function() { + if (!this.isConnected) + return 'Node is detached from document'; + if (this.nodeType !== Node.ELEMENT_NODE) + return 'Node is not of type HTMLElement'; + + const visibleRatio = await new Promise(resolve => { + const observer = new IntersectionObserver(entries => { + resolve(entries[0].intersectionRatio); + observer.disconnect(); + }); + observer.observe(this); + }); + + if (visibleRatio !== 1.0) + this.scrollIntoView({ + block: 'center', + inline: 'center', + behavior: 'instant' + }); + return false; + }", + vec![], + true, + )?; + + if result.Type == Runtime::RemoteObjectType::String { + let error_text = result.value.unwrap().as_str().unwrap().to_string(); + return Err(ScrollFailed { error_text }.into()); + } + + Ok(self) + } + + pub fn get_attributes(&self) -> Result>> { + let description = self.get_description()?; + Ok(description.attributes) + } + + /// Get boxes for this element + pub fn get_box_model(&self) -> Result { + let model = self + .parent + .call_method(DOM::GetBoxModel { + node_id: None, + backend_node_id: Some(self.backend_node_id), + object_id: None, + })? + .model; + Ok(BoxModel { + content: ElementQuad::from_raw_points(&model.content), + padding: ElementQuad::from_raw_points(&model.padding), + border: ElementQuad::from_raw_points(&model.border), + margin: ElementQuad::from_raw_points(&model.margin), + width: model.width as f64, + height: model.height as f64, + }) + } + + pub fn get_midpoint(&self) -> Result { + match self + .parent + .call_method(DOM::GetContentQuads { + node_id: None, + backend_node_id: Some(self.backend_node_id), + object_id: None, + }) + .and_then(|quad| { + let raw_quad = quad.quads.first().unwrap(); + let input_quad = ElementQuad::from_raw_points(&raw_quad); + + Ok((input_quad.bottom_right + input_quad.top_left) / 2.0) + }) { + Ok(e) => return Ok(e), + Err(_) => { + let mut p = Point { x: 0.0, y: 0.0 }; + + p = util::Wait::with_timeout(Duration::from_secs(20)).until(|| { + let r = self + .call_js_fn( + r#" + function() { + let rect = this.getBoundingClientRect(); + + if(rect.x != 0) { + this.scrollIntoView(); + } + + return this.getBoundingClientRect(); + } + "#, + vec![], + false, + ) + .unwrap(); + + let res = util::extract_midpoint(r); + + match res { + Ok(v) => { + if v.x != 0.0 { + Some(v) + } else { + None + } + } + _ => None, + } + })?; + + return Ok(p); + } + } + } + + pub fn get_js_midpoint(&self) -> Result { + let result = self.call_js_fn( + "function(){return this.getBoundingClientRect(); }", + vec![], + false, + )?; + + util::extract_midpoint(result) + } +} + +#[derive(Debug, Error)] +#[error("Scrolling element into view failed: {}", error_text)] +struct ScrollFailed { + error_text: String, +} diff --git a/mdbook-pdf/headless_chrome/src/browser/tab/keys.rs b/mdbook-pdf/headless_chrome/src/browser/tab/keys.rs new file mode 100644 index 00000000..b1c09d88 --- /dev/null +++ b/mdbook-pdf/headless_chrome/src/browser/tab/keys.rs @@ -0,0 +1,1549 @@ +use crate::protocol::cdp::types::JsUInt; +use crate::protocol::cdp::Input::{DispatchKeyEvent, DispatchKeyEventTypeOption}; +use anyhow::Result; + +use thiserror::Error; + +pub struct KeyDefinition { + pub key: &'static str, + pub key_code: JsUInt, + pub code: &'static str, + pub text: Option<&'static str>, +} + +impl Into for &KeyDefinition { + fn into(self) -> DispatchKeyEvent { + let text = self + .text + .or_else(|| { + if self.key.len() == 1 { + Some(self.key) + } else { + None + } + }) + .and_then(|s| Some(s.to_string())); + + // See https://github.com/GoogleChrome/puppeteer/blob/62da2366c65b335751896afbb0206f23c61436f1/lib/Input.js#L52 + let key_down_event_type = if text.is_some() { + DispatchKeyEventTypeOption::KeyDown + } else { + DispatchKeyEventTypeOption::RawKeyDown + }; + + let key = Some(self.key.to_string()); + let code = Some(self.code.to_string()); + + DispatchKeyEvent { + Type: key_down_event_type, + key, + text, + code, + windows_virtual_key_code: Some(self.key_code), + native_virtual_key_code: Some(self.key_code), + modifiers: None, + timestamp: None, + unmodified_text: None, + key_identifier: None, + auto_repeat: None, + is_keypad: None, + is_system_key: None, + location: None, + commands: None, + } + } +} + +// Generated the following in node using Puppeteer: +// keys = require("./lib/USKeyboardLayout.js") +// toStruct = (kD) => `KeyDefinition { key: "${kD.key}", key_code: "${kD.keyCode}", code: "${kD.code}", text: kD.text }` +// output = Object.values(keys).map(toStruct).join(",\n") +// const fs = require('fs'); +// fs.writeFile("/tmp/blah1", output) + +pub const USKEYBOARD_LAYOUT: [KeyDefinition; 244] = [ + KeyDefinition { + key: "0", + key_code: 48, + code: "Digit0", + text: None, + }, + KeyDefinition { + key: "1", + key_code: 49, + code: "Digit1", + text: None, + }, + KeyDefinition { + key: "2", + key_code: 50, + code: "Digit2", + text: None, + }, + KeyDefinition { + key: "3", + key_code: 51, + code: "Digit3", + text: None, + }, + KeyDefinition { + key: "4", + key_code: 52, + code: "Digit4", + text: None, + }, + KeyDefinition { + key: "5", + key_code: 53, + code: "Digit5", + text: None, + }, + KeyDefinition { + key: "6", + key_code: 54, + code: "Digit6", + text: None, + }, + KeyDefinition { + key: "7", + key_code: 55, + code: "Digit7", + text: None, + }, + KeyDefinition { + key: "8", + key_code: 56, + code: "Digit8", + text: None, + }, + KeyDefinition { + key: "9", + key_code: 57, + code: "Digit9", + text: None, + }, + KeyDefinition { + key: "Power", + key_code: 0, + code: "Power", + text: None, + }, + KeyDefinition { + key: "Eject", + key_code: 0, + code: "Eject", + text: None, + }, + KeyDefinition { + key: "Cancel", + key_code: 3, + code: "Abort", + text: None, + }, + KeyDefinition { + key: "Help", + key_code: 6, + code: "Help", + text: None, + }, + KeyDefinition { + key: "Backspace", + key_code: 8, + code: "Backspace", + text: None, + }, + KeyDefinition { + key: "Tab", + key_code: 9, + code: "Tab", + text: None, + }, + KeyDefinition { + key: "Clear", + key_code: 12, + code: "Numpad5", + text: None, + }, + KeyDefinition { + key: "Enter", + key_code: 13, + code: "Enter", + text: Some("\r"), + }, + KeyDefinition { + key: "Shift", + key_code: 16, + code: "ShiftLeft", + text: None, + }, + KeyDefinition { + key: "Shift", + key_code: 16, + code: "ShiftRight", + text: None, + }, + KeyDefinition { + key: "Control", + key_code: 17, + code: "ControlLeft", + text: None, + }, + KeyDefinition { + key: "Control", + key_code: 17, + code: "ControlRight", + text: None, + }, + KeyDefinition { + key: "Alt", + key_code: 18, + code: "AltLeft", + text: None, + }, + KeyDefinition { + key: "Alt", + key_code: 18, + code: "AltRight", + text: None, + }, + KeyDefinition { + key: "Pause", + key_code: 19, + code: "Pause", + text: None, + }, + KeyDefinition { + key: "CapsLock", + key_code: 20, + code: "CapsLock", + text: None, + }, + KeyDefinition { + key: "Escape", + key_code: 27, + code: "Escape", + text: None, + }, + KeyDefinition { + key: "Convert", + key_code: 28, + code: "Convert", + text: None, + }, + KeyDefinition { + key: "NonConvert", + key_code: 29, + code: "NonConvert", + text: None, + }, + KeyDefinition { + key: " ", + key_code: 32, + code: "Space", + text: None, + }, + KeyDefinition { + key: "PageUp", + key_code: 33, + code: "Numpad9", + text: None, + }, + KeyDefinition { + key: "PageUp", + key_code: 33, + code: "PageUp", + text: None, + }, + KeyDefinition { + key: "PageDown", + key_code: 34, + code: "Numpad3", + text: None, + }, + KeyDefinition { + key: "PageDown", + key_code: 34, + code: "PageDown", + text: None, + }, + KeyDefinition { + key: "End", + key_code: 35, + code: "End", + text: None, + }, + KeyDefinition { + key: "End", + key_code: 35, + code: "Numpad1", + text: None, + }, + KeyDefinition { + key: "Home", + key_code: 36, + code: "Home", + text: None, + }, + KeyDefinition { + key: "Home", + key_code: 36, + code: "Numpad7", + text: None, + }, + KeyDefinition { + key: "ArrowLeft", + key_code: 37, + code: "ArrowLeft", + text: None, + }, + KeyDefinition { + key: "ArrowLeft", + key_code: 37, + code: "Numpad4", + text: None, + }, + KeyDefinition { + key: "ArrowUp", + key_code: 38, + code: "Numpad8", + text: None, + }, + KeyDefinition { + key: "ArrowUp", + key_code: 38, + code: "ArrowUp", + text: None, + }, + KeyDefinition { + key: "ArrowRight", + key_code: 39, + code: "ArrowRight", + text: None, + }, + KeyDefinition { + key: "ArrowRight", + key_code: 39, + code: "Numpad6", + text: None, + }, + KeyDefinition { + key: "ArrowDown", + key_code: 40, + code: "Numpad2", + text: None, + }, + KeyDefinition { + key: "ArrowDown", + key_code: 40, + code: "ArrowDown", + text: None, + }, + KeyDefinition { + key: "Select", + key_code: 41, + code: "Select", + text: None, + }, + KeyDefinition { + key: "Execute", + key_code: 43, + code: "Open", + text: None, + }, + KeyDefinition { + key: "PrintScreen", + key_code: 44, + code: "PrintScreen", + text: None, + }, + KeyDefinition { + key: "Insert", + key_code: 45, + code: "Insert", + text: None, + }, + KeyDefinition { + key: "Insert", + key_code: 45, + code: "Numpad0", + text: None, + }, + KeyDefinition { + key: "Delete", + key_code: 46, + code: "Delete", + text: None, + }, + KeyDefinition { + key: "", + key_code: 46, + code: "NumpadDecimal", + text: None, + }, + KeyDefinition { + key: "0", + key_code: 48, + code: "Digit0", + text: None, + }, + KeyDefinition { + key: "1", + key_code: 49, + code: "Digit1", + text: None, + }, + KeyDefinition { + key: "2", + key_code: 50, + code: "Digit2", + text: None, + }, + KeyDefinition { + key: "3", + key_code: 51, + code: "Digit3", + text: None, + }, + KeyDefinition { + key: "4", + key_code: 52, + code: "Digit4", + text: None, + }, + KeyDefinition { + key: "5", + key_code: 53, + code: "Digit5", + text: None, + }, + KeyDefinition { + key: "6", + key_code: 54, + code: "Digit6", + text: None, + }, + KeyDefinition { + key: "7", + key_code: 55, + code: "Digit7", + text: None, + }, + KeyDefinition { + key: "8", + key_code: 56, + code: "Digit8", + text: None, + }, + KeyDefinition { + key: "9", + key_code: 57, + code: "Digit9", + text: None, + }, + KeyDefinition { + key: "a", + key_code: 65, + code: "KeyA", + text: None, + }, + KeyDefinition { + key: "b", + key_code: 66, + code: "KeyB", + text: None, + }, + KeyDefinition { + key: "c", + key_code: 67, + code: "KeyC", + text: None, + }, + KeyDefinition { + key: "d", + key_code: 68, + code: "KeyD", + text: None, + }, + KeyDefinition { + key: "e", + key_code: 69, + code: "KeyE", + text: None, + }, + KeyDefinition { + key: "f", + key_code: 70, + code: "KeyF", + text: None, + }, + KeyDefinition { + key: "g", + key_code: 71, + code: "KeyG", + text: None, + }, + KeyDefinition { + key: "h", + key_code: 72, + code: "KeyH", + text: None, + }, + KeyDefinition { + key: "i", + key_code: 73, + code: "KeyI", + text: None, + }, + KeyDefinition { + key: "j", + key_code: 74, + code: "KeyJ", + text: None, + }, + KeyDefinition { + key: "k", + key_code: 75, + code: "KeyK", + text: None, + }, + KeyDefinition { + key: "l", + key_code: 76, + code: "KeyL", + text: None, + }, + KeyDefinition { + key: "m", + key_code: 77, + code: "KeyM", + text: None, + }, + KeyDefinition { + key: "n", + key_code: 78, + code: "KeyN", + text: None, + }, + KeyDefinition { + key: "o", + key_code: 79, + code: "KeyO", + text: None, + }, + KeyDefinition { + key: "p", + key_code: 80, + code: "KeyP", + text: None, + }, + KeyDefinition { + key: "q", + key_code: 81, + code: "KeyQ", + text: None, + }, + KeyDefinition { + key: "r", + key_code: 82, + code: "KeyR", + text: None, + }, + KeyDefinition { + key: "s", + key_code: 83, + code: "KeyS", + text: None, + }, + KeyDefinition { + key: "t", + key_code: 84, + code: "KeyT", + text: None, + }, + KeyDefinition { + key: "u", + key_code: 85, + code: "KeyU", + text: None, + }, + KeyDefinition { + key: "v", + key_code: 86, + code: "KeyV", + text: None, + }, + KeyDefinition { + key: "w", + key_code: 87, + code: "KeyW", + text: None, + }, + KeyDefinition { + key: "x", + key_code: 88, + code: "KeyX", + text: None, + }, + KeyDefinition { + key: "y", + key_code: 89, + code: "KeyY", + text: None, + }, + KeyDefinition { + key: "z", + key_code: 90, + code: "KeyZ", + text: None, + }, + KeyDefinition { + key: "Meta", + key_code: 91, + code: "MetaLeft", + text: None, + }, + KeyDefinition { + key: "Meta", + key_code: 92, + code: "MetaRight", + text: None, + }, + KeyDefinition { + key: "ContextMenu", + key_code: 93, + code: "ContextMenu", + text: None, + }, + KeyDefinition { + key: "*", + key_code: 106, + code: "NumpadMultiply", + text: None, + }, + KeyDefinition { + key: "+", + key_code: 107, + code: "NumpadAdd", + text: None, + }, + KeyDefinition { + key: "-", + key_code: 109, + code: "NumpadSubtract", + text: None, + }, + KeyDefinition { + key: "/", + key_code: 111, + code: "NumpadDivide", + text: None, + }, + KeyDefinition { + key: "F1", + key_code: 112, + code: "F1", + text: None, + }, + KeyDefinition { + key: "F2", + key_code: 113, + code: "F2", + text: None, + }, + KeyDefinition { + key: "F3", + key_code: 114, + code: "F3", + text: None, + }, + KeyDefinition { + key: "F4", + key_code: 115, + code: "F4", + text: None, + }, + KeyDefinition { + key: "F5", + key_code: 116, + code: "F5", + text: None, + }, + KeyDefinition { + key: "F6", + key_code: 117, + code: "F6", + text: None, + }, + KeyDefinition { + key: "F7", + key_code: 118, + code: "F7", + text: None, + }, + KeyDefinition { + key: "F8", + key_code: 119, + code: "F8", + text: None, + }, + KeyDefinition { + key: "F9", + key_code: 120, + code: "F9", + text: None, + }, + KeyDefinition { + key: "F10", + key_code: 121, + code: "F10", + text: None, + }, + KeyDefinition { + key: "F11", + key_code: 122, + code: "F11", + text: None, + }, + KeyDefinition { + key: "F12", + key_code: 123, + code: "F12", + text: None, + }, + KeyDefinition { + key: "F13", + key_code: 124, + code: "F13", + text: None, + }, + KeyDefinition { + key: "F14", + key_code: 125, + code: "F14", + text: None, + }, + KeyDefinition { + key: "F15", + key_code: 126, + code: "F15", + text: None, + }, + KeyDefinition { + key: "F16", + key_code: 127, + code: "F16", + text: None, + }, + KeyDefinition { + key: "F17", + key_code: 128, + code: "F17", + text: None, + }, + KeyDefinition { + key: "F18", + key_code: 129, + code: "F18", + text: None, + }, + KeyDefinition { + key: "F19", + key_code: 130, + code: "F19", + text: None, + }, + KeyDefinition { + key: "F20", + key_code: 131, + code: "F20", + text: None, + }, + KeyDefinition { + key: "F21", + key_code: 132, + code: "F21", + text: None, + }, + KeyDefinition { + key: "F22", + key_code: 133, + code: "F22", + text: None, + }, + KeyDefinition { + key: "F23", + key_code: 134, + code: "F23", + text: None, + }, + KeyDefinition { + key: "F24", + key_code: 135, + code: "F24", + text: None, + }, + KeyDefinition { + key: "NumLock", + key_code: 144, + code: "NumLock", + text: None, + }, + KeyDefinition { + key: "ScrollLock", + key_code: 145, + code: "ScrollLock", + text: None, + }, + KeyDefinition { + key: "AudioVolumeMute", + key_code: 173, + code: "AudioVolumeMute", + text: None, + }, + KeyDefinition { + key: "AudioVolumeDown", + key_code: 174, + code: "AudioVolumeDown", + text: None, + }, + KeyDefinition { + key: "AudioVolumeUp", + key_code: 175, + code: "AudioVolumeUp", + text: None, + }, + KeyDefinition { + key: "MediaTrackNext", + key_code: 176, + code: "MediaTrackNext", + text: None, + }, + KeyDefinition { + key: "MediaTrackPrevious", + key_code: 177, + code: "MediaTrackPrevious", + text: None, + }, + KeyDefinition { + key: "MediaStop", + key_code: 178, + code: "MediaStop", + text: None, + }, + KeyDefinition { + key: "MediaPlayPause", + key_code: 179, + code: "MediaPlayPause", + text: None, + }, + KeyDefinition { + key: ";", + key_code: 186, + code: "Semicolon", + text: None, + }, + KeyDefinition { + key: "=", + key_code: 187, + code: "Equal", + text: None, + }, + KeyDefinition { + key: "=", + key_code: 187, + code: "NumpadEqual", + text: None, + }, + KeyDefinition { + key: ",", + key_code: 188, + code: "Comma", + text: None, + }, + KeyDefinition { + key: "-", + key_code: 189, + code: "Minus", + text: None, + }, + KeyDefinition { + key: ".", + key_code: 190, + code: "Period", + text: None, + }, + KeyDefinition { + key: "/", + key_code: 191, + code: "Slash", + text: None, + }, + KeyDefinition { + key: "`", + key_code: 192, + code: "Backquote", + text: None, + }, + KeyDefinition { + key: "[", + key_code: 219, + code: "BracketLeft", + text: None, + }, + KeyDefinition { + key: "\\", + key_code: 220, + code: "Backslash", + text: None, + }, + KeyDefinition { + key: "]", + key_code: 221, + code: "BracketRight", + text: None, + }, + KeyDefinition { + key: "'", + key_code: 222, + code: "Quote", + text: None, + }, + KeyDefinition { + key: "AltGraph", + key_code: 225, + code: "AltGraph", + text: None, + }, + KeyDefinition { + key: "CrSel", + key_code: 247, + code: "Props", + text: None, + }, + KeyDefinition { + key: "Cancel", + key_code: 3, + code: "Abort", + text: None, + }, + KeyDefinition { + key: "Clear", + key_code: 12, + code: "Numpad5", + text: None, + }, + KeyDefinition { + key: "Shift", + key_code: 16, + code: "ShiftLeft", + text: None, + }, + KeyDefinition { + key: "Control", + key_code: 17, + code: "ControlLeft", + text: None, + }, + KeyDefinition { + key: "Alt", + key_code: 18, + code: "AltLeft", + text: None, + }, + KeyDefinition { + key: "Accept", + key_code: 30, + code: "undefined", + text: None, + }, + KeyDefinition { + key: "ModeChange", + key_code: 31, + code: "undefined", + text: None, + }, + KeyDefinition { + key: " ", + key_code: 32, + code: "Space", + text: None, + }, + KeyDefinition { + key: "Print", + key_code: 42, + code: "undefined", + text: None, + }, + KeyDefinition { + key: "Execute", + key_code: 43, + code: "Open", + text: None, + }, + KeyDefinition { + key: "", + key_code: 46, + code: "NumpadDecimal", + text: None, + }, + KeyDefinition { + key: "a", + key_code: 65, + code: "KeyA", + text: None, + }, + KeyDefinition { + key: "b", + key_code: 66, + code: "KeyB", + text: None, + }, + KeyDefinition { + key: "c", + key_code: 67, + code: "KeyC", + text: None, + }, + KeyDefinition { + key: "d", + key_code: 68, + code: "KeyD", + text: None, + }, + KeyDefinition { + key: "e", + key_code: 69, + code: "KeyE", + text: None, + }, + KeyDefinition { + key: "f", + key_code: 70, + code: "KeyF", + text: None, + }, + KeyDefinition { + key: "g", + key_code: 71, + code: "KeyG", + text: None, + }, + KeyDefinition { + key: "h", + key_code: 72, + code: "KeyH", + text: None, + }, + KeyDefinition { + key: "i", + key_code: 73, + code: "KeyI", + text: None, + }, + KeyDefinition { + key: "j", + key_code: 74, + code: "KeyJ", + text: None, + }, + KeyDefinition { + key: "k", + key_code: 75, + code: "KeyK", + text: None, + }, + KeyDefinition { + key: "l", + key_code: 76, + code: "KeyL", + text: None, + }, + KeyDefinition { + key: "m", + key_code: 77, + code: "KeyM", + text: None, + }, + KeyDefinition { + key: "n", + key_code: 78, + code: "KeyN", + text: None, + }, + KeyDefinition { + key: "o", + key_code: 79, + code: "KeyO", + text: None, + }, + KeyDefinition { + key: "p", + key_code: 80, + code: "KeyP", + text: None, + }, + KeyDefinition { + key: "q", + key_code: 81, + code: "KeyQ", + text: None, + }, + KeyDefinition { + key: "r", + key_code: 82, + code: "KeyR", + text: None, + }, + KeyDefinition { + key: "s", + key_code: 83, + code: "KeyS", + text: None, + }, + KeyDefinition { + key: "t", + key_code: 84, + code: "KeyT", + text: None, + }, + KeyDefinition { + key: "u", + key_code: 85, + code: "KeyU", + text: None, + }, + KeyDefinition { + key: "v", + key_code: 86, + code: "KeyV", + text: None, + }, + KeyDefinition { + key: "w", + key_code: 87, + code: "KeyW", + text: None, + }, + KeyDefinition { + key: "x", + key_code: 88, + code: "KeyX", + text: None, + }, + KeyDefinition { + key: "y", + key_code: 89, + code: "KeyY", + text: None, + }, + KeyDefinition { + key: "z", + key_code: 90, + code: "KeyZ", + text: None, + }, + KeyDefinition { + key: "Meta", + key_code: 91, + code: "MetaLeft", + text: None, + }, + KeyDefinition { + key: "*", + key_code: 106, + code: "NumpadMultiply", + text: None, + }, + KeyDefinition { + key: "+", + key_code: 107, + code: "NumpadAdd", + text: None, + }, + KeyDefinition { + key: "-", + key_code: 109, + code: "NumpadSubtract", + text: None, + }, + KeyDefinition { + key: "/", + key_code: 111, + code: "NumpadDivide", + text: None, + }, + KeyDefinition { + key: ";", + key_code: 186, + code: "Semicolon", + text: None, + }, + KeyDefinition { + key: "=", + key_code: 187, + code: "Equal", + text: None, + }, + KeyDefinition { + key: ",", + key_code: 188, + code: "Comma", + text: None, + }, + KeyDefinition { + key: ".", + key_code: 190, + code: "Period", + text: None, + }, + KeyDefinition { + key: "`", + key_code: 192, + code: "Backquote", + text: None, + }, + KeyDefinition { + key: "[", + key_code: 219, + code: "BracketLeft", + text: None, + }, + KeyDefinition { + key: "]", + key_code: 221, + code: "BracketRight", + text: None, + }, + KeyDefinition { + key: "'", + key_code: 222, + code: "Quote", + text: None, + }, + KeyDefinition { + key: "Attn", + key_code: 246, + code: "undefined", + text: None, + }, + KeyDefinition { + key: "CrSel", + key_code: 247, + code: "Props", + text: None, + }, + KeyDefinition { + key: "ExSel", + key_code: 248, + code: "undefined", + text: None, + }, + KeyDefinition { + key: "EraseEof", + key_code: 249, + code: "undefined", + text: None, + }, + KeyDefinition { + key: "Play", + key_code: 250, + code: "undefined", + text: None, + }, + KeyDefinition { + key: "ZoomOut", + key_code: 251, + code: "undefined", + text: None, + }, + KeyDefinition { + key: ")", + key_code: 48, + code: "Digit0", + text: None, + }, + KeyDefinition { + key: "!", + key_code: 49, + code: "Digit1", + text: None, + }, + KeyDefinition { + key: "@", + key_code: 50, + code: "Digit2", + text: None, + }, + KeyDefinition { + key: "#", + key_code: 51, + code: "Digit3", + text: None, + }, + KeyDefinition { + key: "$", + key_code: 52, + code: "Digit4", + text: None, + }, + KeyDefinition { + key: "%", + key_code: 53, + code: "Digit5", + text: None, + }, + KeyDefinition { + key: "^", + key_code: 54, + code: "Digit6", + text: None, + }, + KeyDefinition { + key: "&", + key_code: 55, + code: "Digit7", + text: None, + }, + KeyDefinition { + key: "(", + key_code: 57, + code: "Digit9", + text: None, + }, + KeyDefinition { + key: "A", + key_code: 65, + code: "KeyA", + text: None, + }, + KeyDefinition { + key: "B", + key_code: 66, + code: "KeyB", + text: None, + }, + KeyDefinition { + key: "C", + key_code: 67, + code: "KeyC", + text: None, + }, + KeyDefinition { + key: "D", + key_code: 68, + code: "KeyD", + text: None, + }, + KeyDefinition { + key: "E", + key_code: 69, + code: "KeyE", + text: None, + }, + KeyDefinition { + key: "F", + key_code: 70, + code: "KeyF", + text: None, + }, + KeyDefinition { + key: "G", + key_code: 71, + code: "KeyG", + text: None, + }, + KeyDefinition { + key: "H", + key_code: 72, + code: "KeyH", + text: None, + }, + KeyDefinition { + key: "I", + key_code: 73, + code: "KeyI", + text: None, + }, + KeyDefinition { + key: "J", + key_code: 74, + code: "KeyJ", + text: None, + }, + KeyDefinition { + key: "K", + key_code: 75, + code: "KeyK", + text: None, + }, + KeyDefinition { + key: "L", + key_code: 76, + code: "KeyL", + text: None, + }, + KeyDefinition { + key: "M", + key_code: 77, + code: "KeyM", + text: None, + }, + KeyDefinition { + key: "N", + key_code: 78, + code: "KeyN", + text: None, + }, + KeyDefinition { + key: "O", + key_code: 79, + code: "KeyO", + text: None, + }, + KeyDefinition { + key: "P", + key_code: 80, + code: "KeyP", + text: None, + }, + KeyDefinition { + key: "Q", + key_code: 81, + code: "KeyQ", + text: None, + }, + KeyDefinition { + key: "R", + key_code: 82, + code: "KeyR", + text: None, + }, + KeyDefinition { + key: "S", + key_code: 83, + code: "KeyS", + text: None, + }, + KeyDefinition { + key: "T", + key_code: 84, + code: "KeyT", + text: None, + }, + KeyDefinition { + key: "U", + key_code: 85, + code: "KeyU", + text: None, + }, + KeyDefinition { + key: "V", + key_code: 86, + code: "KeyV", + text: None, + }, + KeyDefinition { + key: "W", + key_code: 87, + code: "KeyW", + text: None, + }, + KeyDefinition { + key: "X", + key_code: 88, + code: "KeyX", + text: None, + }, + KeyDefinition { + key: "Y", + key_code: 89, + code: "KeyY", + text: None, + }, + KeyDefinition { + key: "Z", + key_code: 90, + code: "KeyZ", + text: None, + }, + KeyDefinition { + key: ":", + key_code: 186, + code: "Semicolon", + text: None, + }, + KeyDefinition { + key: "<", + key_code: 188, + code: "Comma", + text: None, + }, + KeyDefinition { + key: "_", + key_code: 189, + code: "Minus", + text: None, + }, + KeyDefinition { + key: ">", + key_code: 190, + code: "Period", + text: None, + }, + KeyDefinition { + key: "?", + key_code: 191, + code: "Slash", + text: None, + }, + KeyDefinition { + key: "~", + key_code: 192, + code: "Backquote", + text: None, + }, + KeyDefinition { + key: "{", + key_code: 219, + code: "BracketLeft", + text: None, + }, + KeyDefinition { + key: "|", + key_code: 220, + code: "Backslash", + text: None, + }, + KeyDefinition { + key: "}", + key_code: 221, + code: "BracketRight", + text: None, + }, + KeyDefinition { + key: "\"", + key_code: 222, + code: "Quote", + text: None, + }, +]; + +#[derive(Debug, Error)] +#[error("Key not found: {}", key)] +pub struct KeyNotFoundError { + key: String, +} + +pub fn get_key_definition(key: &str) -> Result<&KeyDefinition> { + if let Some(definition) = USKEYBOARD_LAYOUT + .iter() + .find(|key_definition| key_definition.key == key) + { + Ok(definition) + } else { + Err(KeyNotFoundError { + key: key.to_string(), + } + .into()) + } +} diff --git a/mdbook-pdf/headless_chrome/src/browser/tab/mod.rs b/mdbook-pdf/headless_chrome/src/browser/tab/mod.rs new file mode 100644 index 00000000..3beb75ac --- /dev/null +++ b/mdbook-pdf/headless_chrome/src/browser/tab/mod.rs @@ -0,0 +1,1620 @@ +use std::sync::{Arc, Mutex, RwLock, Weak}; +use std::thread; +use std::time::Duration; +use std::{ + collections::HashMap, + sync::atomic::{AtomicBool, Ordering}, +}; + +use anyhow::{Error, Result}; + +use thiserror::Error; + +use log::*; + +use serde::de::DeserializeOwned; +use serde::Serialize; +use serde_json::{json, Value as Json}; + +use element::Element; +use point::Point; + +use crate::protocol::cdp::{ + types::{Event, Method}, + Browser, Debugger, Emulation, Fetch, Input, Log, Network, Page, Profiler, Runtime, Target, DOM, +}; + +use Runtime::AddBinding; + +use Input::DispatchKeyEvent; + +use Page::{AddScriptToEvaluateOnNewDocument, Navigate, SetInterceptFileChooserDialog}; + +use Target::AttachToTarget; + +use DOM::{Node, NodeId}; + +use Target::{TargetID, TargetInfo}; + +use Log::ViolationSetting; + +use Fetch::{ + events::RequestPausedEvent, AuthChallengeResponse, ContinueRequest, ContinueWithAuth, + FailRequest, FulfillRequest, +}; + +use Network::{ + events::ResponseReceivedEventParams, Cookie, GetResponseBody, GetResponseBodyReturnObject, + SetExtraHTTPHeaders, SetUserAgentOverride, +}; + +use crate::util; + +use crate::types::{Bounds, CurrentBounds, PrintToPdfOptions, RemoteError}; + +use super::transport::SessionId; +use crate::browser::transport::Transport; +use std::thread::sleep; + +pub mod element; +mod keys; +pub mod point; + +#[derive(Debug)] +pub enum RequestPausedDecision { + Fulfill(FulfillRequest), + Fail(FailRequest), + Continue(Option), +} + +#[rustfmt::skip] +pub type ResponseHandler = Box< + dyn Fn( + ResponseReceivedEventParams, + &dyn Fn() -> Result< + GetResponseBodyReturnObject, + Error, + >, + ) + Send + + Sync, +>; + +type SyncSendEvent = dyn EventListener + Send + Sync; +pub trait RequestInterceptor { + fn intercept( + &self, + transport: Arc, + session_id: SessionId, + event: RequestPausedEvent, + ) -> RequestPausedDecision; +} + +impl RequestInterceptor for F +where + F: Fn(Arc, SessionId, RequestPausedEvent) -> RequestPausedDecision + Send + Sync, +{ + fn intercept( + &self, + transport: Arc, + session_id: SessionId, + event: RequestPausedEvent, + ) -> RequestPausedDecision { + self(transport, session_id, event) + } +} + +type RequestIntercept = dyn RequestInterceptor + Send + Sync; + +pub trait EventListener { + fn on_event(&self, event: &T); +} + +impl EventListener for F { + fn on_event(&self, event: &T) { + self(&event); + } +} + +pub trait Binding { + fn call_binding(&self, data: Json); +} + +impl Binding for T { + fn call_binding(&self, data: Json) { + self(data); + } +} + +pub type SafeBinding = dyn Binding + Send + Sync; + +pub type FunctionBinding = HashMap>; + +// type SyncSendEvent = dyn EventListener + Send + Sync; + +/// A handle to a single page. Exposes methods for simulating user actions (clicking, +/// typing), and also for getting information about the DOM and other parts of the page. +pub struct Tab { + target_id: TargetID, + transport: Arc, + session_id: SessionId, + navigating: Arc, + target_info: Arc>, + request_interceptor: Arc>>, + response_handler: Arc>>, + auth_handler: Arc>, + default_timeout: Arc>, + page_bindings: Arc>, + event_listeners: Arc>>>, + slow_motion_multiplier: Arc>, // there's no AtomicF64, otherwise would use that +} + +#[derive(Debug, Error)] +#[error("No element found")] +pub struct NoElementFound {} + +#[derive(Debug, Error)] +#[error("Navigate failed: {}", error_text)] +pub struct NavigationFailed { + error_text: String, +} + +#[derive(Debug, Error)] +#[error("No LocalStorage item was found")] +pub struct NoLocalStorageItemFound {} + +impl NoElementFound { + pub fn map(error: Error) -> Error { + match error.downcast::() { + Ok(remote_error) => { + match remote_error.message.as_ref() { + // This error is expected and occurs while the page is still loading, + // hence we shadow it and respond the element is not found + "Could not find node with given id" => Self {}.into(), + + // Any other error is unexpected and should be reported + _ => remote_error.into(), + } + } + // Return original error if downcasting to RemoteError fails + Err(original_error) => original_error, + } + } +} + +impl Tab { + pub fn new(target_info: TargetInfo, transport: Arc) -> Result { + let target_id = target_info.target_id.clone(); + + let session_id = transport + .call_method_on_browser(AttachToTarget { + target_id: target_id.clone(), + flatten: None, + })? + .session_id + .into(); + + debug!("New tab attached with session ID: {:?}", session_id); + + let target_info_mutex = Arc::new(Mutex::new(target_info)); + + let tab = Self { + target_id: target_id, + transport, + session_id, + navigating: Arc::new(AtomicBool::new(false)), + target_info: target_info_mutex, + page_bindings: Arc::new(Mutex::new(HashMap::new())), + request_interceptor: Arc::new(Mutex::new(Arc::new( + |_transport, _session_id, _interception| RequestPausedDecision::Continue(None), + ))), + response_handler: Arc::new(Mutex::new(None)), + auth_handler: Arc::new(Mutex::new(AuthChallengeResponse { + response: Fetch::AuthChallengeResponseResponse::Default, + username: None, + password: None, + })), + default_timeout: Arc::new(RwLock::new(Duration::from_secs(300))), + event_listeners: Arc::new(Mutex::new(Vec::new())), + slow_motion_multiplier: Arc::new(RwLock::new(0.0)), + }; + + tab.call_method(Page::Enable(None))?; + tab.call_method(Page::SetLifecycleEventsEnabled { enabled: true })?; + + tab.start_event_handler_thread(); + + Ok(tab) + } + + pub fn update_target_info(&self, target_info: TargetInfo) { + let mut info = self.target_info.lock().unwrap(); + *info = target_info; + } + + pub fn get_target_id(&self) -> &TargetID { + &self.target_id + } + + /// Fetches the most recent info about this target + pub fn get_target_info(&self) -> Result { + Ok(self + .call_method(Target::GetTargetInfo { + target_id: Some(self.get_target_id().to_string()), + })? + .target_info) + } + + pub fn get_browser_context_id(&self) -> Result> { + Ok(self.get_target_info()?.browser_context_id) + } + + pub fn get_url(&self) -> String { + let info = self.target_info.lock().unwrap(); + info.url.clone() + } + + /// Allows overriding user agent with the given string. + pub fn set_user_agent( + &self, + user_agent: &str, + accept_language: Option<&str>, + platform: Option<&str>, + ) -> Result<()> { + self.call_method(SetUserAgentOverride { + user_agent: user_agent.to_string(), + accept_language: accept_language.and_then(|v| Some(v.to_string())), + platform: platform.and_then(|v| Some(v.to_string())), + user_agent_metadata: None, + }) + .map(|_| ()) + } + + fn start_event_handler_thread(&self) { + let transport: Arc = Arc::clone(&self.transport); + let incoming_events_rx = self + .transport + .listen_to_target_events(self.session_id.clone()); + let navigating = Arc::clone(&self.navigating); + let interceptor_mutex = Arc::clone(&self.request_interceptor); + let response_handler_mutex = self.response_handler.clone(); + let auth_handler_mutex = self.auth_handler.clone(); + let session_id = self.session_id.clone(); + let listeners_mutex = Arc::clone(&self.event_listeners); + + let bindings_mutex = Arc::clone(&self.page_bindings); + let received_event_params = Arc::new(Mutex::new(HashMap::new())); + + thread::spawn(move || { + for event in incoming_events_rx { + let listeners = listeners_mutex.lock().unwrap(); + listeners.iter().for_each(|listener| { + listener.on_event(&event); + }); + + match event { + Event::PageLifecycleEvent(lifecycle_event) => { + let event_name = lifecycle_event.params.name.as_ref(); + trace!("Lifecycle event: {}", event_name); + match event_name { + "networkAlmostIdle" => { + navigating.store(false, Ordering::SeqCst); + } + "init" => { + navigating.store(true, Ordering::SeqCst); + } + _ => {} + } + } + Event::RuntimeBindingCalled(binding) => { + let bindings = bindings_mutex.lock().unwrap().clone(); + + let name = binding.params.name; + let payload = binding.params.payload; + + let func = &Arc::clone(bindings.get(&name).unwrap()); + + func.call_binding(json!(payload)); + } + Event::FetchRequestPaused(event) => { + let interceptor = interceptor_mutex.lock().unwrap(); + let decision = interceptor.intercept( + Arc::clone(&transport), + session_id.clone(), + event.clone(), + ); + let result = match decision { + RequestPausedDecision::Continue(continue_request) => { + if let Some(continue_request) = continue_request { + transport + .call_method_on_target(session_id.clone(), continue_request) + .map(|_| ()) + } else { + transport + .call_method_on_target( + session_id.clone(), + ContinueRequest { + request_id: event.params.request_id, + url: None, + method: None, + post_data: None, + headers: None, + intercept_response: None, + }, + ) + .map(|_| ()) + } + } + RequestPausedDecision::Fulfill(fulfill_request) => transport + .call_method_on_target(session_id.clone(), fulfill_request) + .map(|_| ()), + RequestPausedDecision::Fail(fail_request) => transport + .call_method_on_target(session_id.clone(), fail_request) + .map(|_| ()), + }; + if result.is_err() { + warn!("Tried to handle request after connection was closed"); + } + } + Event::FetchAuthRequired(event) => { + let auth_challenge_response = auth_handler_mutex.lock().unwrap().clone(); + + let request_id = event.params.request_id; + let method = ContinueWithAuth { + request_id: request_id, + auth_challenge_response, + }; + let result = transport.call_method_on_target(session_id.clone(), method); + if result.is_err() { + warn!("Tried to handle request after connection was closed"); + } + } + Event::NetworkResponseReceived(ev) => { + let request_id = ev.params.request_id.clone(); + received_event_params + .lock() + .unwrap() + .insert(request_id, ev.params); + } + Event::NetworkLoadingFinished(ev) => { + if let Some(handler) = response_handler_mutex.lock().unwrap().as_ref() { + let request_id = ev.params.request_id.clone(); + let retrieve_body = || { + let method = GetResponseBody { + request_id: request_id.clone(), + }; + transport.call_method_on_target(session_id.clone(), method) + }; + + match received_event_params.lock().unwrap().get(&request_id) { + Some(params) => handler(params.to_owned(), &retrieve_body), + _ => warn!("Request id does not exist"), + } + } + } + _ => { + let mut raw_event = format!("{:?}", event); + raw_event.truncate(50); + trace!("Unhandled event: {}", raw_event); + } + } + } + info!("finished tab's event handling loop"); + }); + } + + pub fn expose_function(&self, name: &str, func: Arc) -> Result<()> { + let bindings_mutex = Arc::clone(&self.page_bindings); + + let mut bindings = bindings_mutex.lock().unwrap(); + + bindings.insert(name.to_string(), func); + + let expression = r#" + (function addPageBinding(bindingName) { + const binding = window[bindingName]; + window[bindingName] = (...args) => { + const me = window[bindingName]; + let callbacks = me['callbacks']; + if (!callbacks) { + callbacks = new Map(); + me['callbacks'] = callbacks; + } + const seq = (me['lastSeq'] || 0) + 1; + me['lastSeq'] = seq; + const promise = new Promise((resolve, reject) => callbacks.set(seq, {resolve, reject})); + binding(JSON.stringify({name: bindingName, seq, args})); + return promise; + }; + })() + "#; // https://github.com/puppeteer/puppeteer/blob/97c9fe2520723d45a5a86da06b888ae888d400be/src/common/helper.ts#L183 + + self.call_method(AddBinding { + name: name.to_string(), + execution_context_id: None, + execution_context_name: None, + })?; + + self.call_method(AddScriptToEvaluateOnNewDocument { + source: expression.to_string(), + world_name: None, + include_command_line_api: None, + })?; + + Ok(()) + } + + pub fn remove_function(&self, name: &str) -> Result<()> { + let bindings_mutex = Arc::clone(&self.page_bindings); + + let mut bindings = bindings_mutex.lock().unwrap(); + + bindings.remove(name).unwrap(); + + Ok(()) + } + + pub fn call_method(&self, method: C) -> Result + where + C: Method + serde::Serialize + std::fmt::Debug, + { + trace!("Calling method: {:?}", method); + let result = self + .transport + .call_method_on_target(self.session_id.clone(), method); + let mut result_string = format!("{:?}", result); + result_string.truncate(70); + trace!("Got result: {:?}", result_string); + result + } + + pub fn wait_until_navigated(&self) -> Result<&Self> { + let navigating = Arc::clone(&self.navigating); + let timeout = *self.default_timeout.read().unwrap(); + + util::Wait::with_timeout(timeout).until(|| { + if navigating.load(Ordering::SeqCst) { + None + } else { + Some(true) + } + })?; + debug!("A tab finished navigating"); + + Ok(self) + } + + // Pulls focus to this tab + pub fn bring_to_front(&self) -> Result { + Ok(self.call_method(Page::BringToFront(None))?) + } + + pub fn navigate_to(&self, url: &str) -> Result<&Self> { + let return_object = self.call_method(Navigate { + url: url.to_string(), + referrer: None, + transition_Type: None, + frame_id: None, + referrer_policy: None, + })?; + if let Some(error_text) = return_object.error_text { + return Err(NavigationFailed { error_text }.into()); + } + + let navigating = Arc::clone(&self.navigating); + navigating.store(true, Ordering::SeqCst); + + info!("Navigating a tab to {}", url); + + Ok(self) + } + + /// Set default timeout for the tab + /// + /// This will be applied to all [wait_for_element](Tab::wait_for_element) and [wait_for_elements](Tab::wait_for_elements) calls for this tab + /// + /// ```rust + /// # use anyhow::Result; + /// # fn main() -> Result<()> { + /// # use headless_chrome::Browser; + /// # let browser = Browser::default()?; + /// let tab = browser.wait_for_initial_tab()?; + /// tab.set_default_timeout(std::time::Duration::from_secs(5)); + /// # + /// # Ok(()) + /// # } + + /// ``` + pub fn set_default_timeout(&self, timeout: Duration) -> &Self { + let mut current_timeout = self.default_timeout.write().unwrap(); + *current_timeout = timeout; + &self + } + + /// Analogous to Puppeteer's ['slowMo' option](https://github.com/GoogleChrome/puppeteer/blob/v1.20.0/docs/api.md#puppeteerconnectoptions), + /// but with some differences: + /// + /// * It doesn't add a delay after literally every message sent via the protocol, but instead + /// just for: + /// * clicking a specific point on the page (default: 100ms before moving the mouse, 250ms + /// before pressing and releasting mouse button) + /// * pressing a key (default: 25 ms) + /// * reloading the page (default: 100ms) + /// * closing a tab (default: 100ms) + /// * Instead of an absolute number of milliseconds, it's a multiplier, so that we can delay + /// longer on certain actions like clicking or moving the mouse, and shorter on others like + /// on pressing a key (or the individual 'mouseDown' and 'mouseUp' actions that go across the + /// wire. If the delay was always the same, filling out a form (e.g.) would take ages). + /// + /// By default the multiplier is set to zero, which effectively disables the slow motion. + /// + /// The defaults for the various actions (i.e. how long we sleep for when + /// multiplier is 1.0) are supposed to be just slow enough to help a human see what's going on + /// as a test runs. + pub fn set_slow_motion_multiplier(&self, multiplier: f64) -> &Self { + let mut slow_motion_multiplier = self.slow_motion_multiplier.write().unwrap(); + *slow_motion_multiplier = multiplier; + &self + } + + fn optional_slow_motion_sleep(&self, millis: u64) { + let multiplier = self.slow_motion_multiplier.read().unwrap(); + #[allow(clippy::cast_sign_loss, clippy::cast_possible_truncation)] + let scaled_millis = millis * *multiplier as u64; + sleep(Duration::from_millis(scaled_millis)); + } + + pub fn wait_for_element(&self, selector: &str) -> Result> { + self.wait_for_element_with_custom_timeout(selector, *self.default_timeout.read().unwrap()) + } + + pub fn wait_for_xpath(&self, selector: &str) -> Result> { + self.wait_for_xpath_with_custom_timeout(selector, *self.default_timeout.read().unwrap()) + } + + pub fn wait_for_element_with_custom_timeout( + &self, + selector: &str, + timeout: std::time::Duration, + ) -> Result> { + debug!("Waiting for element with selector: {:?}", selector); + util::Wait::with_timeout(timeout).strict_until( + || self.find_element(selector), + Error::downcast::, + ) + } + + pub fn wait_for_xpath_with_custom_timeout( + &self, + selector: &str, + timeout: std::time::Duration, + ) -> Result> { + debug!("Waiting for element with selector: {:?}", selector); + util::Wait::with_timeout(timeout).strict_until( + || self.find_element_by_xpath(selector), + Error::downcast::, + ) + } + + pub fn wait_for_elements(&self, selector: &str) -> Result>> { + debug!("Waiting for element with selector: {:?}", selector); + util::Wait::with_timeout(*self.default_timeout.read().unwrap()).strict_until( + || self.find_elements(selector), + Error::downcast::, + ) + } + + pub fn wait_for_elements_by_xpath(&self, selector: &str) -> Result>> { + debug!("Waiting for element with selector: {:?}", selector); + util::Wait::with_timeout(*self.default_timeout.read().unwrap()).strict_until( + || self.find_elements_by_xpath(selector), + Error::downcast::, + ) + } + + /// Returns the first element in the document which matches the given selector. + /// + /// Equivalent to the following JS: + /// + /// ```js + /// document.querySelector(selector) + /// ``` + /// + /// ```rust + /// # use anyhow::Result; + /// # // Awful hack to get access to testing utils common between integration, doctest, and unit tests + /// # mod server { + /// # include!("../../testing_utils/server.rs"); + /// # } + /// # fn main() -> Result<()> { + /// # + /// use headless_chrome::Browser; + /// + /// let browser = Browser::default()?; + /// let initial_tab = browser.wait_for_initial_tab()?; + /// + /// let file_server = server::Server::with_dumb_html(include_str!("../../../tests/simple.html")); + /// let element = initial_tab.navigate_to(&file_server.url())? + /// .wait_until_navigated()? + /// .find_element("div#foobar")?; + /// let attrs = element.get_attributes()?.unwrap(); + /// assert_eq!(attrs["id"], "foobar"); + /// # + /// # Ok(()) + /// # } + /// ``` + pub fn find_element(&self, selector: &str) -> Result> { + let root_node_id = self.get_document()?.node_id; + trace!("Looking up element via selector: {}", selector); + + self.run_query_selector_on_node(root_node_id, selector) + } + + pub fn find_element_by_xpath(&self, query: &str) -> Result> { + self.get_document()?; + + self.call_method(DOM::PerformSearch { + query: query.to_string(), + include_user_agent_shadow_dom: None, + }) + .and_then(|o| { + Ok(self + .call_method(DOM::GetSearchResults { + search_id: o.search_id, + from_index: 0, + to_index: o.result_count, + })? + .node_ids[0]) + }) + .and_then(|id| { + if id == 0 { + Err(NoElementFound {}.into()) + } else { + Ok(Element::new(&self, id)?) + } + }) + } + + pub fn run_query_selector_on_node( + &self, + node_id: NodeId, + selector: &str, + ) -> Result> { + let node_id = self + .call_method(DOM::QuerySelector { + node_id, + selector: selector.to_string(), + }) + .map_err(NoElementFound::map)? + .node_id; + + Element::new(&self, node_id) + } + + pub fn run_query_selector_all_on_node( + &self, + node_id: NodeId, + selector: &str, + ) -> Result>> { + let node_ids = self + .call_method(DOM::QuerySelectorAll { + node_id, + selector: selector.to_string(), + }) + .map_err(NoElementFound::map)? + .node_ids; + + node_ids + .iter() + .map(|node_id| Element::new(&self, *node_id)) + .collect() + } + + pub fn get_document(&self) -> Result { + Ok(self + .call_method(DOM::GetDocument { + depth: Some(0), + pierce: Some(false), + })? + .root) + } + + pub fn find_elements(&self, selector: &str) -> Result>> { + trace!("Looking up elements via selector: {}", selector); + + let root_node_id = self.get_document()?.node_id; + let node_ids = self + .call_method(DOM::QuerySelectorAll { + node_id: root_node_id, + selector: selector.to_string(), + }) + .map_err(NoElementFound::map)? + .node_ids; + + if node_ids.is_empty() { + return Err(NoElementFound {}.into()); + } + + node_ids + .into_iter() + .map(|node_id| Element::new(&self, node_id)) + .collect() + } + + pub fn find_elements_by_xpath(&self, query: &str) -> Result>> { + self.call_method(DOM::PerformSearch { + query: query.to_string(), + include_user_agent_shadow_dom: None, + }) + .and_then(|o| { + Ok(self + .call_method(DOM::GetSearchResults { + search_id: o.search_id, + from_index: 0, + to_index: o.result_count, + })? + .node_ids) + }) + .and_then(|ids| { + ids.iter() + .filter(|id| **id != 0) + .map(|id| Element::new(self, *id)) + .collect() + }) + } + + pub fn describe_node(&self, node_id: NodeId) -> Result { + let node = self + .call_method(DOM::DescribeNode { + node_id: Some(node_id), + backend_node_id: None, + depth: Some(100), + object_id: None, + pierce: None, + })? + .node; + Ok(node) + } + + pub fn type_str(&self, string_to_type: &str) -> Result<&Self> { + for c in string_to_type.split("") { + // split call above will have empty string at start and end which we won't type + if c == "" { + continue; + } + let definition = keys::get_key_definition(c); + // https://github.com/puppeteer/puppeteer/blob/b8806d5625ca7835abbaf2e997b0bf35a5679e29/src/common/Input.ts#L239-L245 + match definition { + Ok(key) => { + let v: DispatchKeyEvent = key.into(); + + self.call_method(v.clone())?; + self.call_method(DispatchKeyEvent { + Type: Input::DispatchKeyEventTypeOption::KeyUp, + ..v + })?; + } + Err(_) => { + self.call_method(Input::InsertText { + text: c.to_string(), + })?; + } + } + } + Ok(self) + } + + pub fn press_key(&self, key: &str) -> Result<&Self> { + // See https://github.com/GoogleChrome/puppeteer/blob/62da2366c65b335751896afbb0206f23c61436f1/lib/Input.js#L114-L115 + let definiton = keys::get_key_definition(key)?; + + let text = definiton + .text + .or_else(|| { + if definiton.key.len() == 1 { + Some(definiton.key) + } else { + None + } + }) + .and_then(|v| Some(v.to_string())); + + // See https://github.com/GoogleChrome/puppeteer/blob/62da2366c65b335751896afbb0206f23c61436f1/lib/Input.js#L52 + let key_down_event_type = if text.is_some() { + Input::DispatchKeyEventTypeOption::KeyDown + } else { + Input::DispatchKeyEventTypeOption::RawKeyDown + }; + + let key = Some(definiton.key.to_string()); + let code = Some(definiton.code.to_string()); + + self.optional_slow_motion_sleep(25); + + self.call_method(Input::DispatchKeyEvent { + Type: key_down_event_type, + key: key.clone(), + text: text.clone(), + code: code.clone(), + windows_virtual_key_code: Some(definiton.key_code), + native_virtual_key_code: Some(definiton.key_code), + modifiers: None, + timestamp: None, + unmodified_text: None, + key_identifier: None, + auto_repeat: None, + is_keypad: None, + is_system_key: None, + location: None, + commands: None, + })?; + self.call_method(Input::DispatchKeyEvent { + Type: Input::DispatchKeyEventTypeOption::KeyUp, + key, + text, + code, + windows_virtual_key_code: Some(definiton.key_code), + native_virtual_key_code: Some(definiton.key_code), + modifiers: None, + timestamp: None, + unmodified_text: None, + key_identifier: None, + auto_repeat: None, + is_keypad: None, + is_system_key: None, + location: None, + commands: None, + })?; + Ok(self) + } + + /// Moves the mouse to this point (dispatches a mouseMoved event) + pub fn move_mouse_to_point(&self, point: Point) -> Result<&Self> { + if point.x == 0.0 && point.y == 0.0 { + warn!("Midpoint of element shouldn't be 0,0. Something is probably wrong.") + } + + self.optional_slow_motion_sleep(100); + + self.call_method(Input::DispatchMouseEvent { + Type: Input::DispatchMouseEventTypeOption::MouseMoved, + x: point.x, + y: point.y, + modifiers: None, + timestamp: None, + button: None, + buttons: None, + click_count: None, + force: None, + tangential_pressure: None, + tilt_x: None, + tilt_y: None, + twist: None, + delta_x: None, + delta_y: None, + pointer_Type: None, + })?; + + Ok(self) + } + + pub fn click_point(&self, point: Point) -> Result<&Self> { + trace!("Clicking point: {:?}", point); + if point.x == 0.0 && point.y == 0.0 { + warn!("Midpoint of element shouldn't be 0,0. Something is probably wrong.") + } + + self.move_mouse_to_point(point)?; + + self.optional_slow_motion_sleep(250); + self.call_method(Input::DispatchMouseEvent { + Type: Input::DispatchMouseEventTypeOption::MousePressed, + x: point.x, + y: point.y, + button: Some(Input::MouseButton::Left), + click_count: Some(1), + modifiers: None, + timestamp: None, + buttons: None, + force: None, + tangential_pressure: None, + tilt_x: None, + tilt_y: None, + twist: None, + delta_x: None, + delta_y: None, + pointer_Type: None, + })?; + self.call_method(Input::DispatchMouseEvent { + Type: Input::DispatchMouseEventTypeOption::MouseReleased, + x: point.x, + y: point.y, + button: Some(Input::MouseButton::Left), + click_count: Some(1), + modifiers: None, + timestamp: None, + buttons: None, + force: None, + tangential_pressure: None, + tilt_x: None, + tilt_y: None, + twist: None, + delta_x: None, + delta_y: None, + pointer_Type: None, + })?; + Ok(self) + } + + /// Capture a screenshot of the current page. + /// + /// If `clip` is given, the screenshot is taken of the specified region only. + /// `Element::get_box_model()` can be used to get regions of certains elements + /// on the page; there is also `Element::capture_screenhot()` as a shorthand. + /// + /// If `from_surface` is true, the screenshot is taken from the surface rather than + /// the view. + /// + /// ```rust,no_run + /// # use anyhow::Result; + /// # fn main() -> Result<()> { + /// # + /// use headless_chrome::{protocol::page::ScreenshotFormat, Browser, LaunchOptions}; + /// let browser = Browser::new(LaunchOptions::default_builder().build().unwrap())?; + /// let tab = browser.wait_for_initial_tab()?; + /// let viewport = tab.navigate_to("https://en.wikipedia.org/wiki/WebKit")? + /// .wait_for_element("#mw-content-text > div > table.infobox.vevent")? + /// .get_box_model()? + /// .margin_viewport(); + /// let png_data = tab.capture_screenshot(ScreenshotFormat::PNG, Some(viewport), true)?; + /// # + /// # Ok(()) + /// # } + /// ``` + pub fn capture_screenshot( + &self, + format: Page::CaptureScreenshotFormatOption, + quality: Option, + clip: Option, + from_surface: bool, + ) -> Result> { + let data = self + .call_method(Page::CaptureScreenshot { + format: Some(format), + clip, + quality, + from_surface: Some(from_surface), + capture_beyond_viewport: None, + })? + .data; + base64::decode(&data).map_err(Into::into) + } + + pub fn print_to_pdf(&self, options: Option) -> Result> { + if let Some(options) = options { + let transfer_mode: Option = + options.transfer_mode.and_then(|f| f.into()); + let data = self + .call_method(Page::PrintToPDF { + landscape: options.landscape, + display_header_footer: options.display_header_footer, + print_background: options.print_background, + scale: options.scale, + paper_width: options.paper_width, + paper_height: options.paper_height, + margin_top: options.margin_top, + margin_bottom: options.margin_bottom, + margin_left: options.margin_left, + margin_right: options.margin_right, + page_ranges: options.page_ranges, + ignore_invalid_page_ranges: options.ignore_invalid_page_ranges, + header_template: options.header_template, + footer_template: options.footer_template, + prefer_css_page_size: options.prefer_css_page_size, + transfer_mode, + })? + .data; + base64::decode(&data).map_err(Into::into) + } else { + let data = self + .call_method(Page::PrintToPDF { + ..Default::default() + })? + .data; + + base64::decode(&data).map_err(Into::into) + } + } + + /// Reloads given page optionally ignoring the cache + /// + /// If `ignore_cache` is true, the browser cache is ignored (as if the user pressed Shift+F5). + /// If `script_to_evaluate` is given, the script will be injected into all frames of the + /// inspected page after reload. Argument will be ignored if reloading dataURL origin. + pub fn reload( + &self, + ignore_cache: bool, + script_to_evaluate_on_load: Option<&str>, + ) -> Result<&Self> { + self.optional_slow_motion_sleep(100); + self.call_method(Page::Reload { + ignore_cache: Some(ignore_cache), + script_to_evaluate_on_load: script_to_evaluate_on_load + .and_then(|s| Some(s.to_string())), + })?; + Ok(self) + } + + /// Set the background color of the dom to transparent. + /// + /// Useful when you want capture a .png + /// + /// ```rust,no_run + /// # use anyhow::Result; + /// # fn main() -> Result<()> { + /// # + /// use headless_chrome::{protocol::page::ScreenshotFormat, Browser, LaunchOptions}; + /// let browser = Browser::new(LaunchOptions::default_builder().build().unwrap())?; + /// let tab = browser.wait_for_initial_tab()?; + /// tab.set_transparent_background_color()?; + /// + /// # + /// # Ok(()) + /// # } + /// ``` + pub fn set_transparent_background_color(&self) -> Result<&Self> { + self.call_method(Emulation::SetDefaultBackgroundColorOverride { + color: Some(DOM::RGBA { + r: 0, + g: 0, + b: 0, + a: Some(0.0), + }), + })?; + Ok(self) + } + + /// Set the default background color of the dom. + /// + /// Pass a RGBA to override the backrgound color of the dom. + /// + /// ```rust,no_run + /// # use anyhow::Result; + /// # fn main() -> Result<()> { + /// # + /// use headless_chrome::{protocol::page::ScreenshotFormat, Browser, LaunchOptions}; + /// let browser = Browser::new(LaunchOptions::default_builder().build().unwrap())?; + /// let tab = browser.wait_for_initial_tab()?; + /// tab.set_background_color( color: RGBA { r: 255, g: 0, b: 0, a: 1.,})?; + /// + /// # + /// # Ok(()) + /// # } + /// ``` + pub fn set_background_color(&self, color: DOM::RGBA) -> Result<&Self> { + self.call_method(Emulation::SetDefaultBackgroundColorOverride { color: Some(color) })?; + Ok(self) + } + + /// Enables the profiler + pub fn enable_profiler(&self) -> Result<&Self> { + self.call_method(Profiler::Enable(None))?; + + Ok(self) + } + + /// Disables the profiler + pub fn disable_profiler(&self) -> Result<&Self> { + self.call_method(Profiler::Disable(None))?; + + Ok(self) + } + + /// Starts tracking which lines of JS have been executed + /// + /// Will return error unless `enable_profiler` has been called. + /// + /// Equivalent to hitting the record button in the "coverage" tab in Chrome DevTools. + /// See the file `tests/coverage.rs` for an example. + /// + /// By default we enable the 'detailed' flag on StartPreciseCoverage, which enables block-level + /// granularity, and also enable 'call_count' (which when disabled always sets count to 1 or 0). + /// + pub fn start_js_coverage(&self) -> Result<&Self> { + self.call_method(Profiler::StartPreciseCoverage { + call_count: Some(true), + detailed: Some(true), + allow_triggered_updates: None, + })?; + Ok(self) + } + + /// Stops tracking which lines of JS have been executed + /// If you're finished with the profiler, don't forget to call `disable_profiler`. + pub fn stop_js_coverage(&self) -> Result<&Self> { + self.call_method(Profiler::StopPreciseCoverage(None))?; + Ok(self) + } + + /// Collect coverage data for the current isolate, and resets execution counters. + /// + /// Precise code coverage needs to have started (see `start_js_coverage`). + /// + /// Will only send information about code that's been executed since this method was last + /// called, or (if this is the first time) since calling `start_js_coverage`. + /// Another way of thinking about it is: every time you call this, the call counts for + /// FunctionRanges are reset after returning. + /// + /// The format of the data is a little unintuitive, see here for details: + /// https://chromedevtools.github.io/devtools-protocol/tot/Profiler#type-ScriptCoverage + pub fn take_precise_js_coverage(&self) -> Result> { + let script_coverages = self + .call_method(Profiler::TakePreciseCoverage(None))? + .result; + Ok(script_coverages) + } + + /// Enables fetch domain. + pub fn enable_fetch( + &self, + patterns: Option<&[Fetch::RequestPattern]>, + handle_auth_requests: Option, + ) -> Result<&Self> { + self.call_method(Fetch::Enable { + patterns: patterns.and_then(|v| Some(v.to_vec())), + handle_auth_requests, + })?; + Ok(self) + } + + /// Disables fetch domain + pub fn disable_fetch(&self) -> Result<&Self> { + self.call_method(Fetch::Disable(None))?; + Ok(self) + } + + /// Allows you to inspect outgoing network requests from the tab, and optionally return + /// your own responses to them + /// + /// The `interceptor` argument is a closure which takes this tab's `Transport` and its SessionID + /// so that you can call methods from within the closure using `transport.call_method_on_target`. + /// + /// The closure needs to return a variant of `RequestPausedDecision`. + pub fn enable_request_interception(&self, interceptor: Arc) -> Result<()> { + let mut current_interceptor = self.request_interceptor.lock().unwrap(); + *current_interceptor = interceptor; + Ok(()) + } + + pub fn authenticate( + &self, + username: Option, + password: Option, + ) -> Result<&Self> { + let mut current_auth_handler = self.auth_handler.lock().unwrap(); + *current_auth_handler = AuthChallengeResponse { + response: Fetch::AuthChallengeResponseResponse::ProvideCredentials, + username, + password, + }; + Ok(self) + } + + /// Lets you listen for responses, and gives you a way to get the response body too. + /// + /// Please note that the 'response' does not include the *body* of the response -- Chrome tells + /// us about them seperately (because you might quickly get the status code and headers from a + /// server well before you receive the entire response body which could, after all, be gigabytes + /// long). + /// + /// Currently we leave it up to the caller to decide when to call `fetch_body` (the second + /// argument to the response handler), although ideally it wouldn't be possible until Chrome has + /// sent the `Network.loadingFinished` event. + /// + /// Currently you can only have one handler registered, but ideally there would be no limit and + /// we'd give you a mechanism to deregister the handler too. + pub fn enable_response_handling(&self, handler: ResponseHandler) -> Result<()> { + self.call_method(Network::Enable { + max_total_buffer_size: None, + max_resource_buffer_size: None, + max_post_data_size: None, + })?; + *(self.response_handler.lock().unwrap()) = Some(handler); + Ok(()) + } + + /// Enables runtime domain. + pub fn enable_runtime(&self) -> Result<&Self> { + self.call_method(Runtime::Enable(None))?; + Ok(self) + } + + /// Disables runtime domain + pub fn disable_runtime(&self) -> Result<&Self> { + self.call_method(Runtime::Disable(None))?; + Ok(self) + } + + /// Enables Debugger + pub fn enable_debugger(&self) -> Result<()> { + self.call_method(Debugger::Enable { + max_scripts_cache_size: None, + })?; + Ok(()) + } + + /// Disables Debugger + pub fn disable_debugger(&self) -> Result<()> { + self.call_method(Debugger::Disable(None))?; + Ok(()) + } + + /// Returns source for the script with given id. + /// + /// Debugger must be enabled. + pub fn get_script_source(&self, script_id: &str) -> Result { + Ok(self + .call_method(Debugger::GetScriptSource { + script_id: script_id.to_string(), + })? + .script_source) + } + + /// Enables log domain. + /// + /// Sends the entries collected so far to the client by means of the entryAdded notification. + /// + /// See https://chromedevtools.github.io/devtools-protocol/tot/Log#method-enable + pub fn enable_log(&self) -> Result<&Self> { + self.call_method(Log::Enable(None))?; + + Ok(self) + } + + /// Disables log domain + /// + /// Prevents further log entries from being reported to the client + /// + /// See https://chromedevtools.github.io/devtools-protocol/tot/Log#method-disable + pub fn disable_log(&self) -> Result<&Self> { + self.call_method(Log::Disable(None))?; + + Ok(self) + } + + /// Starts violation reporting + /// + /// See https://chromedevtools.github.io/devtools-protocol/tot/Log#method-startViolationsReport + pub fn start_violations_report(&self, config: Vec) -> Result<&Self> { + self.call_method(Log::StartViolationsReport { config })?; + Ok(self) + } + + /// Stop violation reporting + /// + /// See https://chromedevtools.github.io/devtools-protocol/tot/Log#method-stopViolationsReport + pub fn stop_violations_report(&self) -> Result<&Self> { + self.call_method(Log::StopViolationsReport(None))?; + Ok(self) + } + + /// Evaluates expression on global object. + pub fn evaluate(&self, expression: &str, await_promise: bool) -> Result { + let result = self + .call_method(Runtime::Evaluate { + expression: expression.to_string(), + return_by_value: Some(false), + generate_preview: Some(true), + silent: Some(false), + await_promise: Some(await_promise), + include_command_line_api: Some(false), + user_gesture: Some(false), + object_group: None, + context_id: None, + throw_on_side_effect: None, + timeout: None, + disable_breaks: None, + repl_mode: None, + allow_unsafe_eval_blocked_by_csp: None, + unique_context_id: None, + })? + .result; + Ok(result) + } + + /// Adds event listener to Event + /// + /// Make sure you are enabled domain you are listening events to. + /// + /// ## Usage example + /// + /// ```rust + /// # use anyhow::Result; + /// # use std::sync::Arc; + /// # fn main() -> Result<()> { + /// # + /// # use headless_chrome::Browser; + /// # use headless_chrome::protocol::Event; + /// # let browser = Browser::default()?; + /// # let tab = browser.wait_for_initial_tab()?; + /// tab.enable_log()?; + /// tab.add_event_listener(Arc::new(move |event: &Event| { + /// match event { + /// Event::LogEntryAdded(_) => { + /// // process event here + /// } + /// _ => {} + /// } + /// }))?; + /// # + /// # Ok(()) + /// # } + /// ``` + /// + pub fn add_event_listener(&self, listener: Arc) -> Result> { + let mut listeners = self.event_listeners.lock().unwrap(); + listeners.push(listener); + Ok(Arc::downgrade(listeners.last().unwrap())) + } + + pub fn remove_event_listener(&self, listener: &Weak) -> Result<()> { + let listener = listener.upgrade(); + if listener.is_none() { + return Ok(()); + } + let listener = listener.unwrap(); + let mut listeners = self.event_listeners.lock().unwrap(); + let pos = listeners.iter().position(|x| Arc::ptr_eq(x, &listener)); + if let Some(idx) = pos { + listeners.remove(idx); + } + + Ok(()) + } + + /// Closes the target Page + pub fn close_target(&self) -> Result { + self.call_method(Target::CloseTarget { + target_id: self.get_target_id().to_string(), + }) + .map(|r| r.success) + } + + /// Tries to close page, running its beforeunload hooks, if any + pub fn close_with_unload(&self) -> Result { + self.call_method(Page::Close(None)).map(|_| true) + } + + /// Calls one of the close_* methods depending on fire_unload option + pub fn close(&self, fire_unload: bool) -> Result { + self.optional_slow_motion_sleep(50); + + if fire_unload { + return self.close_with_unload(); + } + self.close_target() + } + + /// Activates (focuses) the target. + pub fn activate(&self) -> Result<&Self> { + self.call_method(Target::ActivateTarget { + target_id: self.get_target_id().clone(), + }) + .map(|_| self) + } + + /// Get position and size of the browser window associated with this `Tab`. + /// + /// Note that the returned bounds are always specified for normal (windowed) + /// state; they do not change when minimizing, maximizing or setting to + /// fullscreen. + pub fn get_bounds(&self) -> Result { + self.transport + .call_method_on_browser(Browser::GetWindowForTarget { + target_id: Some(self.get_target_id().to_string()), + }) + .map(|r| r.bounds.into()) + } + + /// Set position and/or size of the browser window associated with this `Tab`. + /// + /// When setting the window to normal (windowed) state, unspecified fields + /// are left unchanged. + pub fn set_bounds(&self, bounds: Bounds) -> Result<&Self, Error> { + let window_id = self + .transport + .call_method_on_browser(Browser::GetWindowForTarget { + target_id: Some(self.get_target_id().to_string()), + })? + .window_id; + // If we set Normal window state, we *have* to make two API calls + // to set the state before setting the coordinates; despite what the docs say... + if let Bounds::Normal { .. } = &bounds { + self.transport + .call_method_on_browser(Browser::SetWindowBounds { + window_id, + bounds: Browser::Bounds { + left: None, + top: None, + width: None, + height: None, + window_state: Some(Browser::WindowState::Normal), + }, + })?; + } + self.transport + .call_method_on_browser(Browser::SetWindowBounds { + window_id, + bounds: bounds.into(), + })?; + Ok(self) + } + + /// Returns all cookies that match the tab's current URL. + pub fn get_cookies(&self) -> Result> { + Ok(self + .call_method(Network::GetCookies { urls: None })? + .cookies) + } + + /// Set cookies with tab's current URL + pub fn set_cookies(&self, cs: Vec) -> Result<()> { + // puppeteer 7b24e5435b:src/common/Page.ts :1009-1028 + use Network::SetCookies; + let url = self.get_url(); + let starts_with_http = url.starts_with("http"); + let cookies: Vec = cs + .into_iter() + .map(|c| { + if c.url.is_none() && starts_with_http { + Network::CookieParam { + url: Some(url.clone()), + ..c + } + } else { + c + } + }) + .collect(); + self.delete_cookies(cookies.clone().into_iter().map(|c| c.into()).collect())?; + self.call_method(SetCookies { cookies })?; + Ok(()) + } + + /// Delete cookies with tab's current URL + pub fn delete_cookies(&self, cs: Vec) -> Result<()> { + // puppeteer 7b24e5435b:src/common/Page.ts :998-1007 + let url = self.get_url(); + let starts_with_http = url.starts_with("http"); + cs.into_iter() + .map(|c| { + // REVIEW: if c.url is blank string + if c.url.is_none() && starts_with_http { + Network::DeleteCookies { + url: Some(url.clone()), + ..c + } + } else { + c + } + }) + .try_for_each(|c| -> Result<(), anyhow::Error> { + let _ = self.call_method(c)?; + Ok(()) + })?; + Ok(()) + } + + /// Returns the title of the document. + /// + /// ```rust + /// # use anyhow::Result; + /// # use headless_chrome::Browser; + /// # fn main() -> Result<()> { + /// # + /// # let browser = Browser::default()?; + /// # let tab = browser.wait_for_initial_tab()?; + /// tab.navigate_to("https://google.com")?; + /// tab.wait_until_navigated()?; + /// let title = tab.get_title()?; + /// assert_eq!(title, "Google"); + /// # + /// # Ok(()) + /// # } + /// ``` + pub fn get_title(&self) -> Result { + let remote_object = self.evaluate("document.title", false)?; + Ok(serde_json::from_value(remote_object.value.unwrap())?) + } + + /// If enabled, instead of using the GUI to select files, the browser will + /// wait for the `Tab.handle_file_chooser` method to be called. + /// **WARNING**: Only works on Chromium / Chrome 77 and above. + pub fn set_file_chooser_dialog_interception(&self, enabled: bool) -> Result<()> { + self.call_method(SetInterceptFileChooserDialog { enabled })?; + Ok(()) + } + + /// Will have the same effect as choosing these files from the file chooser dialog that would've + /// popped up had `set_file_chooser_dialog_interception` not been called. Calls to this method + /// must be preceded by calls to that method. + /// + /// Supports selecting files or closing the file chooser dialog. + /// + /// NOTE: the filepaths listed in `files` must be absolute. + pub fn handle_file_chooser(&self, files: Vec, node_id: u32) -> Result<()> { + self.call_method(DOM::SetFileInputFiles { + files, + node_id: Some(node_id), + backend_node_id: None, + object_id: None, + })?; + Ok(()) + } + + pub fn set_extra_http_headers(&self, headers: HashMap<&str, &str>) -> Result<()> { + self.call_method(Network::Enable { + max_total_buffer_size: None, + max_resource_buffer_size: None, + max_post_data_size: None, + })?; + self.call_method(SetExtraHTTPHeaders { + headers: Network::Headers(Some(json!(headers))), + })?; + Ok(()) + } + + pub fn set_storage(&self, item_name: &str, item: T) -> Result<()> + where + T: Serialize, + { + let value = json!(item).to_string(); + + self.evaluate( + &format!( + r#"localStorage.setItem("{}",JSON.stringify({}))"#, + item_name, value + ), + false, + )?; + + Ok(()) + } + + pub fn get_storage(&self, item_name: &str) -> Result + where + T: DeserializeOwned, + { + let object = self.evaluate(&format!(r#"localStorage.getItem("{}")"#, item_name), false)?; + + let json: Option = object.value.and_then(|v| match v { + serde_json::Value::String(ref s) => { + let result = serde_json::from_str(&s); + + if result.is_err() { + Some(serde_json::from_value(v).unwrap()) + } else { + Some(result.unwrap()) + } + } + _ => None, + }); + + match json { + Some(v) => Ok(v), + None => Err(NoLocalStorageItemFound {}.into()), + } + } + + pub fn remove_storage(&self, item_name: &str) -> Result<()> { + self.evaluate( + &format!(r#"localStorage.removeItem("{}")"#, item_name), + false, + )?; + + Ok(()) + } + + pub fn stop_loading(&self) -> Result { + self.call_method(Page::StopLoading(None)).map(|_| true) + } +} diff --git a/mdbook-pdf/headless_chrome/src/browser/tab/point.rs b/mdbook-pdf/headless_chrome/src/browser/tab/point.rs new file mode 100644 index 00000000..9eb4d573 --- /dev/null +++ b/mdbook-pdf/headless_chrome/src/browser/tab/point.rs @@ -0,0 +1,38 @@ +#[derive(Debug, Copy, Clone, PartialEq)] +pub struct Point { + pub x: f64, + pub y: f64, +} + +impl std::ops::Add for Point { + type Output = Self; + + fn add(self, other: Self) -> Self { + Self { + x: self.x + other.x, + y: self.y + other.y, + } + } +} + +impl std::ops::Sub for Point { + type Output = Self; + + fn sub(self, other: Self) -> Self { + Self { + x: self.x - other.x, + y: self.y - other.y, + } + } +} + +impl std::ops::Div for Point { + type Output = Self; + + fn div(self, other: f64) -> Self { + Self { + x: self.x / other, + y: self.y / other, + } + } +} diff --git a/mdbook-pdf/headless_chrome/src/browser/transport/mod.rs b/mdbook-pdf/headless_chrome/src/browser/transport/mod.rs new file mode 100644 index 00000000..f94061ec --- /dev/null +++ b/mdbook-pdf/headless_chrome/src/browser/transport/mod.rs @@ -0,0 +1,357 @@ +use std::collections::HashMap; +use std::sync::atomic::{AtomicBool, AtomicU32, Ordering}; +use std::sync::mpsc; +use std::sync::mpsc::Sender; +use std::sync::mpsc::{Receiver, RecvTimeoutError, TryRecvError}; +use std::sync::Arc; +use std::sync::Mutex; +use std::time::Duration; + +use anyhow::{Result}; + +use thiserror::Error; + +use log::*; + +use waiting_call_registry::WaitingCallRegistry; +use web_socket_connection::WebSocketConnection; +use websocket::url::Url; + +use crate::protocol::cdp::{types::Event,types::Method, Target}; + +use crate::types::{CallId, Message, parse_raw_message, parse_response}; + +use crate::util; + +mod waiting_call_registry; +mod web_socket_connection; + +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct SessionId(String); + +pub enum MethodDestination { + Target(SessionId), + Browser, +} + +impl SessionId { + fn as_str(&self) -> &str { + &self.0 + } +} + +impl From for SessionId { + fn from(session_id: String) -> Self { + Self(session_id) + } +} + +#[derive(Debug, Eq, PartialEq, Hash)] +enum ListenerId { + SessionId(SessionId), + Browser, +} + +type Listeners = Arc>>>; + +#[derive(Debug)] +pub struct Transport { + web_socket_connection: Arc, + waiting_call_registry: Arc, + listeners: Listeners, + open: Arc, + call_id_counter: Arc, + loop_shutdown_tx: Mutex>, +} + +#[derive(Debug, Error)] +#[error("Unable to make method calls because underlying connection is closed")] +pub struct ConnectionClosed {} + +impl Transport { + pub fn new( + ws_url: Url, + process_id: Option, + idle_browser_timeout: Duration, + ) -> Result { + let (messages_tx, messages_rx) = mpsc::channel(); + let web_socket_connection = + Arc::new(WebSocketConnection::new(&ws_url, process_id, messages_tx)?); + + let waiting_call_registry = Arc::new(WaitingCallRegistry::new()); + + let listeners = Arc::new(Mutex::new(HashMap::new())); + + let open = Arc::new(AtomicBool::new(true)); + + let (shutdown_tx, shutdown_rx) = mpsc::channel(); + + let guarded_shutdown_tx = Mutex::new(shutdown_tx); + + Self::handle_incoming_messages( + messages_rx, + Arc::clone(&waiting_call_registry), + Arc::clone(&listeners), + Arc::clone(&open), + Arc::clone(&web_socket_connection), + shutdown_rx, + process_id, + idle_browser_timeout, + ); + + Ok(Self { + web_socket_connection, + waiting_call_registry, + listeners, + open, + call_id_counter: Arc::new(AtomicU32::new(0)), + loop_shutdown_tx: guarded_shutdown_tx, + }) + } + + /// Returns a number based on thread-safe unique counter, incrementing it so that the + /// next CallId is different. + pub fn unique_call_id(&self) -> CallId { + self.call_id_counter.fetch_add(1, Ordering::SeqCst) + } + + pub fn call_method( + &self, + method: C, + destination: MethodDestination, + ) -> Result + where + C: Method + serde::Serialize, + { + // TODO: use get_mut to get exclusive access for entire block... maybe. + if !self.open.load(Ordering::SeqCst) { + return Err(ConnectionClosed {}.into()); + } + let call_id = self.unique_call_id(); + let call = method.to_method_call(call_id); + + let message_text = serde_json::to_string(&call)?; + + let response_rx = self.waiting_call_registry.register_call(call.id); + + match destination { + MethodDestination::Target(session_id) => { + let message = message_text.clone(); + let target_method = Target::SendMessageToTarget { + target_id: None, + session_id: Some(session_id.0), + message: message, + }; + let mut raw = message_text.clone(); + raw.truncate(300); + trace!("Msg to tab: {}", &raw); + if let Err(e) = self.call_method_on_browser(target_method) { + warn!("Failed to call method on browser: {:?}", e); + self.waiting_call_registry.unregister_call(call.id); + trace!("Unregistered callback: {:?}", call.id); + return Err(e); + } + } + MethodDestination::Browser => { + if let Err(e) = self.web_socket_connection.send_message(&message_text) { + self.waiting_call_registry.unregister_call(call.id); + return Err(e); + } + trace!("sent method call to browser via websocket"); + } + } + + let mut params_string = format!("{:?}", call.get_params()); + params_string.truncate(400); + trace!( + "waiting for response from call registry: {} {:?}", + &call_id, + params_string + ); + + let response_result = util::Wait::new(Duration::from_secs(300), Duration::from_millis(5)) + .until(|| response_rx.try_recv().ok()); + trace!("received response for: {} {:?}", &call_id, params_string); + parse_response::((response_result?)?) + } + + pub fn call_method_on_target( + &self, + session_id: SessionId, + method: C, + ) -> Result + where + C: Method + serde::Serialize, + { + // TODO: remove clone + self.call_method(method, MethodDestination::Target(session_id)) + } + + pub fn call_method_on_browser(&self, method: C) -> Result + where + C: Method + serde::Serialize, + { + self.call_method(method, MethodDestination::Browser) + } + + pub fn listen_to_browser_events(&self) -> Receiver { + let (events_tx, events_rx) = mpsc::channel(); + + let mut listeners = self.listeners.lock().unwrap(); + listeners.insert(ListenerId::Browser, events_tx); + + events_rx + } + + pub fn listen_to_target_events(&self, session_id: SessionId) -> Receiver { + let (events_tx, events_rx) = mpsc::channel(); + + let mut listeners = self.listeners.lock().unwrap(); + listeners.insert(ListenerId::SessionId(session_id), events_tx); + + events_rx + } + + pub fn shutdown(&self) { + self.web_socket_connection.shutdown(); + let shutdown_tx = self.loop_shutdown_tx.lock().unwrap(); + let _ = shutdown_tx.send(()); + } + + #[allow(clippy::too_many_arguments)] + fn handle_incoming_messages( + messages_rx: Receiver, + waiting_call_registry: Arc, + listeners: Listeners, + open: Arc, + conn: Arc, + shutdown_rx: Receiver<()>, + process_id: Option, + idle_browser_timeout: Duration, + ) { + trace!("Starting handle_incoming_messages"); + std::thread::spawn(move || { + trace!("Inside handle_incoming_messages thread"); + // this iterator calls .recv() under the hood, so can block thread forever + // hence need for Connection Shutdown + loop { + match shutdown_rx.try_recv() { + Ok(_) | Err(TryRecvError::Disconnected) => { + info!("Transport incoming message loop loop received shutdown message"); + break; + } + Err(TryRecvError::Empty) => {} + } + match messages_rx.recv_timeout(idle_browser_timeout) { + Err(recv_timeout_error) => { + match recv_timeout_error { + RecvTimeoutError::Timeout => { + error!( + "Transport loop got a timeout while listening for messages (Chrome #{:?})", + process_id + ); + } + RecvTimeoutError::Disconnected => { + error!( + "Transport loop got disconnected from WS's sender (Chrome #{:?})", + process_id + ); + } + } + break; + } + Ok(message) => { + // trace!("{:?}", message); + match message { + Message::ConnectionShutdown => { + info!("Received shutdown message"); + break; + } + Message::Response(response_to_browser_method_call) => { + if waiting_call_registry + .resolve_call(response_to_browser_method_call) + .is_err() + { + warn!("The browser registered a call but then closed its receiving channel"); + break; + } + } + + Message::Event(browser_event) => match browser_event { + Event::ReceivedMessageFromTarget(target_message_event) => { + let session_id = target_message_event.params.session_id.into(); + let raw_message = target_message_event.params.message; + + let msg_res = parse_raw_message(&raw_message); + match msg_res { + Ok(target_message) => match target_message { + Message::Event(target_event) => { + if let Some(tx) = listeners + .lock() + .unwrap() + .get(&ListenerId::SessionId(session_id)) + { + tx.send(target_event) + .expect("Couldn't send event to listener"); + } + } + + Message::Response(resp) => { + if waiting_call_registry.resolve_call(resp).is_err() + { + warn!("The browser registered a call but then closed its receiving channel"); + break; + } + } + Message::ConnectionShutdown => {} + }, + Err(e) => { + trace!( + "Message from target isn't recognised: {:?} - {}", + &raw_message, + e, + ); + } + } + } + + _ => { + if let Some(tx) = + listeners.lock().unwrap().get(&ListenerId::Browser) + { + if let Err(err) = tx.send(browser_event.clone()) { + let mut event_string = format!("{:?}", browser_event); + event_string.truncate(400); + warn!( + "Couldn't send browser an event: {:?}\n{:?}", + event_string, err + ); + break; + } + } + } + }, + } + } + } + } + + info!("Shutting down message handling loop"); + + // Need to do this because otherwise WS thread might block forever + conn.shutdown(); + + open.store(false, Ordering::SeqCst); + waiting_call_registry.cancel_outstanding_method_calls(); + let mut listeners = listeners.lock().unwrap(); + *listeners = HashMap::new(); + info!("cleared listeners, I think"); + }); + } +} + +impl Drop for Transport { + fn drop(&mut self) { + info!("dropping transport"); + } +} diff --git a/mdbook-pdf/headless_chrome/src/browser/transport/waiting_call_registry.rs b/mdbook-pdf/headless_chrome/src/browser/transport/waiting_call_registry.rs new file mode 100644 index 00000000..5392b2db --- /dev/null +++ b/mdbook-pdf/headless_chrome/src/browser/transport/waiting_call_registry.rs @@ -0,0 +1,120 @@ +use std::collections::HashMap; +use std::sync::mpsc; +use std::sync::Mutex; + +use anyhow::Result; +use log::*; + +use crate::types::{CallId, Response}; + +use super::ConnectionClosed; + +trait IdentifiableResponse { + fn call_id(&self) -> CallId; +} + +#[derive(Debug)] +pub struct WaitingCallRegistry { + calls: Mutex>>>, +} + +impl IdentifiableResponse for Response { + fn call_id(&self) -> CallId { + self.call_id + } +} + +impl Default for WaitingCallRegistry { + fn default() -> Self { + let calls = Mutex::new(HashMap::new()); + + Self { calls } + } +} + +impl WaitingCallRegistry { + pub fn new() -> Self { + Default::default() + } + + pub fn resolve_call(&self, response: Response) -> Result<()> { + trace!("Resolving call"); + let waiting_call_tx: mpsc::Sender> = { + let mut waiting_calls = self.calls.lock().unwrap(); + waiting_calls.remove(&response.call_id()).unwrap() + }; + waiting_call_tx.send(Ok(response))?; + Ok(()) + } + + pub fn register_call(&self, call_id: CallId) -> mpsc::Receiver> { + let (tx, rx) = mpsc::channel::>(); + let mut calls = self.calls.lock().unwrap(); + calls.insert(call_id, tx); + trace!("registered {:?}", call_id); + rx + } + + pub fn unregister_call(&self, call_id: CallId) { + trace!("Deregistering call"); + let mut calls = self.calls.lock().unwrap(); + calls.remove(&call_id).unwrap(); + } + + // TODO: make it so we can pass in whatever error we want here + // to make it less dependent on browser::transport + pub fn cancel_outstanding_method_calls(&self) { + trace!("Cancelling outstanding method calls"); + let calls = self.calls.lock().unwrap(); + for (call_id, sender) in calls.iter() { + trace!( + "Telling waiting method call {:?} that the connection closed", + call_id + ); + if let Err(e) = sender.send(Err(ConnectionClosed {}.into())) { + trace!( + "Couldn't send ConnectionClosed to waiting method call: {:?} because {:?}", + call_id, + e + ); + } + } + } +} + +#[cfg(test)] +mod tests { + use serde_json::json; + + use super::*; + + #[test] + fn register_and_receive_calls() { + env_logger::try_init().unwrap_or(()); + + let waiting_calls = WaitingCallRegistry::new(); + + let call_rx = waiting_calls.register_call(431); + let resp = Response { + call_id: 431, + result: Some(json! {true}), + error: None, + }; + let resp_clone = resp.clone(); + + let call_rx2 = waiting_calls.register_call(123); + let resp2 = Response { + call_id: 123, + result: Some(json! {false}), + error: None, + }; + let cloned_resp = resp2.clone(); + + waiting_calls.resolve_call(resp).unwrap(); + waiting_calls.resolve_call(resp2).unwrap(); + + // note how they're in reverse order to that in which they were called! + assert_eq!(cloned_resp, call_rx2.recv().unwrap().unwrap()); + assert_eq!(resp_clone, call_rx.recv().unwrap().unwrap()); + } +} diff --git a/mdbook-pdf/headless_chrome/src/browser/transport/web_socket_connection.rs b/mdbook-pdf/headless_chrome/src/browser/transport/web_socket_connection.rs new file mode 100644 index 00000000..ffab40a0 --- /dev/null +++ b/mdbook-pdf/headless_chrome/src/browser/transport/web_socket_connection.rs @@ -0,0 +1,129 @@ +use std::sync::mpsc; +use std::sync::Mutex; + +use anyhow::Result; +use log::*; +use websocket::client::sync::Client; +use websocket::stream::sync::TcpStream; +use websocket::WebSocketError; +use websocket::url::Url; +use websocket::{ClientBuilder, OwnedMessage}; + +use crate::types::{parse_raw_message,Message}; + +pub struct WebSocketConnection { + sender: Mutex>, + process_id: Option, +} + +// TODO websocket::sender::Writer is not :Debug... +impl std::fmt::Debug for WebSocketConnection { + fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> { + write!(f, "WebSocketConnection {{}}") + } +} + +impl WebSocketConnection { + pub fn new( + ws_url: &Url, + process_id: Option, + messages_tx: mpsc::Sender, + ) -> Result { + let connection = Self::websocket_connection(&ws_url)?; + let (websocket_receiver, sender) = connection.split()?; + + std::thread::spawn(move || { + trace!("Starting msg dispatching loop"); + Self::dispatch_incoming_messages(websocket_receiver, messages_tx, process_id); + trace!("Quit loop msg dispatching loop"); + }); + + Ok(Self { + sender: Mutex::new(sender), + process_id, + }) + } + + pub fn shutdown(&self) { + trace!( + "Shutting down WebSocket connection for Chrome {:?}", + self.process_id + ); + if self.sender.lock().unwrap().shutdown_all().is_err() { + debug!( + "Couldn't shut down WS connection for Chrome {:?}", + self.process_id + ); + } + } + + fn dispatch_incoming_messages( + mut receiver: websocket::receiver::Reader, + messages_tx: mpsc::Sender, + process_id: Option, + ) { + for ws_message in receiver.incoming_messages() { + match ws_message { + Err(error) => match error { + WebSocketError::NoDataAvailable => { + debug!("WS Error Chrome #{:?}: {}", process_id, error); + break; + } + WebSocketError::IoError(err) => { + debug!("WS IO Error for Chrome #{:?}: {}", process_id, err); + break; + } + _ => panic!( + "Unhandled WebSocket error for Chrome #{:?}: {:?}", + process_id, error + ), + }, + Ok(message) => { + if let OwnedMessage::Text(message_string) = message { + if let Ok(message) = parse_raw_message(&message_string) { + if messages_tx.send(message).is_err() { + break; + } + } else { + trace!( + "Incoming message isn't recognised as event or method response: {}", + message_string + ); + } + } else { + panic!("Got a weird message: {:?}", message) + } + } + } + } + + info!("Sending shutdown message to message handling loop"); + if messages_tx + .send(Message::ConnectionShutdown) + .is_err() + { + warn!("Couldn't send message to transport loop telling it to shut down") + } + } + + pub fn websocket_connection(ws_url: &Url) -> Result> { + let client = ClientBuilder::from_url(ws_url).connect_insecure()?; + + debug!("Successfully connected to WebSocket: {}", ws_url); + + Ok(client) + } + + pub fn send_message(&self, message_text: &str) -> Result<()> { + let message = websocket::Message::text(message_text); + let mut sender = self.sender.lock().unwrap(); + sender.send_message(&message)?; + Ok(()) + } +} + +impl Drop for WebSocketConnection { + fn drop(&mut self) { + info!("dropping websocket connection"); + } +} diff --git a/mdbook-pdf/headless_chrome/src/lib.rs b/mdbook-pdf/headless_chrome/src/lib.rs new file mode 100644 index 00000000..2b038d97 --- /dev/null +++ b/mdbook-pdf/headless_chrome/src/lib.rs @@ -0,0 +1,91 @@ +//! A high-level API to control headless Chrome or Chromium over the DevTools Protocol. It is the +//! Rust equivalent of [Puppeteer](https://github.com/GoogleChrome/puppeteer), a Node library +//! maintained by the Chrome DevTools team. +//! +//! It is not 100% feature compatible with Puppeteer, but there's enough here to satisfy most +//! browser testing / web crawling use cases, and there are several 'advanced' features such as: +//! +//! - [network request interception](https://docs.rs/headless_chrome/latest/headless_chrome/browser/tab/struct.Tab.html#method.enable_request_interception) +//! - [JavaScript coverage monitoring](https://docs.rs/headless_chrome/latest/headless_chrome/browser/tab/struct.Tab.html#method.take_precise_js_coverage) +//! - [taking screenshots of elements or the entire page](https://docs.rs/headless_chrome/latest/headless_chrome/browser/tab/struct.Tab.html#method.capture_screenshot) +//! - [saving pages to PDF](https://docs.rs/headless_chrome/latest/headless_chrome/browser/tab/struct.Tab.html#method.print_to_pdf) +//! - ['headful' browsing](https://docs.rs/headless_chrome/latest/headless_chrome/struct.LaunchOptionsBuilder.html#method.headless) +//! - automatic downloading of 'known good' Chromium binaries for Linux / Mac / Windows +//! - [extension pre-loading](https://docs.rs/headless_chrome/latest/headless_chrome/struct.LaunchOptionsBuilder.html#method.extensions) +//! +//! # Quick Start +//! +//! ```no_run +//! use headless_chrome::{Browser, protocol::page::ScreenshotFormat}; +//! +//! fn browse_wikipedia() -> Result<(), failure::Error> { +//! let browser = Browser::default()?; +//! +//! let tab = browser.wait_for_initial_tab()?; +//! +//! /// Navigate to wikipedia +//! tab.navigate_to("https://www.wikipedia.org")?; +//! +//! /// Wait for network/javascript/dom to make the search-box available +//! /// and click it. +//! tab.wait_for_element("input#searchInput")?.click()?; +//! +//! /// Type in a query and press `Enter` +//! tab.type_str("WebKit")?.press_key("Enter")?; +//! +//! /// We should end up on the WebKit-page once navigated +//! tab.wait_for_element("#firstHeading")?; +//! assert!(tab.get_url().ends_with("WebKit")); +//! +//! /// Take a screenshot of the entire browser window +//! let _jpeg_data = tab.capture_screenshot( +//! ScreenshotFormat::JPEG(Some(75)), +//! None, +//! true)?; +//! +//! /// Take a screenshot of just the WebKit-Infobox +//! let _png_data = tab +//! .wait_for_element("#mw-content-text > div > table.infobox.vevent")? +//! .capture_screenshot(ScreenshotFormat::PNG)?; +//! Ok(()) +//! } +//! +//! assert!(browse_wikipedia().is_ok()); +//! ``` + +#![cfg_attr(feature = "nightly", feature(external_doc))] +#![deny(clippy::pedantic)] +#![warn(renamed_and_removed_lints)] +#![allow( +clippy::unknown_clippy_lints, +clippy::module_name_repetitions, +clippy::doc_markdown, // a number of false positives here +clippy::default_trait_access, // fails on output of derive_builder +clippy::needless_pass_by_value, // would stop us creating and passing in LaunchOptions to browser in one statement +clippy::unreadable_literal, // not really applicable for timestamps +clippy::too_many_lines, +clippy::type_repetition_in_bounds, +clippy::used_underscore_binding +)] + +#[macro_use] +extern crate derive_builder; +extern crate log; + +pub use browser::{ + tab::{element::Element, Tab}, + Browser, LaunchOptions, LaunchOptionsBuilder, +}; + +#[cfg(feature = "fetch")] +pub use browser::FetcherOptions; + +pub mod browser; +pub mod types; +pub mod protocol; +pub mod util; + +#[cfg(feature = "nightly")] +#[doc(include = "../README.md")] +#[allow(dead_code)] +type _READMETEST = (); diff --git a/mdbook-pdf/headless_chrome/src/protocol.rs b/mdbook-pdf/headless_chrome/src/protocol.rs new file mode 100644 index 00000000..e5bfab51 --- /dev/null +++ b/mdbook-pdf/headless_chrome/src/protocol.rs @@ -0,0 +1,16220 @@ +pub mod cdp { + pub mod types { + use serde::{Deserialize, Serialize}; + use std::fmt::Debug; + pub type JsFloat = f64; + pub type JsUInt = u32; + pub type WindowId = JsUInt; + pub type CallId = JsUInt; + #[derive(Serialize, Debug)] + pub struct MethodCall + where + T: Debug, + { + #[serde(rename = "method")] + method_name: &'static str, + pub id: CallId, + params: T, + } + impl MethodCall + where + T: Debug, + { + pub fn get_params(&self) -> &T { + &self.params + } + } + pub trait Method: Debug { + const NAME: &'static str; + type ReturnObject: serde::de::DeserializeOwned + std::fmt::Debug; + fn to_method_call(self, call_id: CallId) -> MethodCall + where + Self: std::marker::Sized, + { + MethodCall { + id: call_id, + params: self, + method_name: Self::NAME, + } + } + } + #[derive(Deserialize, Debug, Clone, PartialEq)] + #[serde(tag = "method")] + #[allow(clippy::large_enum_variant)] + pub enum Event { + #[serde(rename = "Accessibility.loadComplete")] + AccessibilityLoadComplete(super::Accessibility::events::LoadCompleteEvent), + #[serde(rename = "Accessibility.nodesUpdated")] + AccessibilityNodesUpdated(super::Accessibility::events::NodesUpdatedEvent), + #[serde(rename = "Animation.animationCanceled")] + AnimationCanceled(super::Animation::events::AnimationCanceledEvent), + #[serde(rename = "Animation.animationCreated")] + AnimationCreated(super::Animation::events::AnimationCreatedEvent), + #[serde(rename = "Animation.animationStarted")] + AnimationStarted(super::Animation::events::AnimationStartedEvent), + #[serde(rename = "Audits.issueAdded")] + AuditsIssueAdded(super::Audits::events::IssueAddedEvent), + #[serde(rename = "BackgroundService.recordingStateChanged")] + BackgroundServiceRecordingStateChanged( + super::BackgroundService::events::RecordingStateChangedEvent, + ), + #[serde(rename = "BackgroundService.backgroundServiceEventReceived")] + BackgroundServiceEventReceived( + super::BackgroundService::events::BackgroundServiceEventReceivedEvent, + ), + #[serde(rename = "Browser.downloadWillBegin")] + BrowserDownloadWillBegin(super::Browser::events::DownloadWillBeginEvent), + #[serde(rename = "Browser.downloadProgress")] + BrowserDownloadProgress(super::Browser::events::DownloadProgressEvent), + #[serde(rename = "CSS.fontsUpdated")] + CSSFontsUpdated(super::CSS::events::FontsUpdatedEvent), + #[serde(rename = "CSS.mediaQueryResultChanged")] + CSSMediaQueryResultChanged(super::CSS::events::MediaQueryResultChangedEvent), + #[serde(rename = "CSS.styleSheetAdded")] + CSSStyleSheetAdded(super::CSS::events::StyleSheetAddedEvent), + #[serde(rename = "CSS.styleSheetChanged")] + CSSStyleSheetChanged(super::CSS::events::StyleSheetChangedEvent), + #[serde(rename = "CSS.styleSheetRemoved")] + CSSStyleSheetRemoved(super::CSS::events::StyleSheetRemovedEvent), + #[serde(rename = "Cast.sinksUpdated")] + CastSinksUpdated(super::Cast::events::SinksUpdatedEvent), + #[serde(rename = "Cast.issueUpdated")] + CastIssueUpdated(super::Cast::events::IssueUpdatedEvent), + #[serde(rename = "DOM.attributeModified")] + DOMAttributeModified(super::DOM::events::AttributeModifiedEvent), + #[serde(rename = "DOM.attributeRemoved")] + DOMAttributeRemoved(super::DOM::events::AttributeRemovedEvent), + #[serde(rename = "DOM.characterDataModified")] + DOMCharacterDataModified(super::DOM::events::CharacterDataModifiedEvent), + #[serde(rename = "DOM.childNodeCountUpdated")] + DOMChildNodeCountUpdated(super::DOM::events::ChildNodeCountUpdatedEvent), + #[serde(rename = "DOM.childNodeInserted")] + DOMChildNodeInserted(super::DOM::events::ChildNodeInsertedEvent), + #[serde(rename = "DOM.childNodeRemoved")] + DOMChildNodeRemoved(super::DOM::events::ChildNodeRemovedEvent), + #[serde(rename = "DOM.distributedNodesUpdated")] + DOMDistributedNodesUpdated(super::DOM::events::DistributedNodesUpdatedEvent), + #[serde(rename = "DOM.documentUpdated")] + DOMDocumentUpdated(super::DOM::events::DocumentUpdatedEvent), + #[serde(rename = "DOM.inlineStyleInvalidated")] + DOMInlineStyleInvalidated(super::DOM::events::InlineStyleInvalidatedEvent), + #[serde(rename = "DOM.pseudoElementAdded")] + DOMPseudoElementAdded(super::DOM::events::PseudoElementAddedEvent), + #[serde(rename = "DOM.pseudoElementRemoved")] + DOMPseudoElementRemoved(super::DOM::events::PseudoElementRemovedEvent), + #[serde(rename = "DOM.setChildNodes")] + DOMSetChildNodes(super::DOM::events::SetChildNodesEvent), + #[serde(rename = "DOM.shadowRootPopped")] + DOMShadowRootPopped(super::DOM::events::ShadowRootPoppedEvent), + #[serde(rename = "DOM.shadowRootPushed")] + DOMShadowRootPushed(super::DOM::events::ShadowRootPushedEvent), + #[serde(rename = "DOMStorage.domStorageItemAdded")] + DOMStorageDomStorageItemAdded(super::DOMStorage::events::DomStorageItemAddedEvent), + #[serde(rename = "DOMStorage.domStorageItemRemoved")] + DOMStorageDomStorageItemRemoved(super::DOMStorage::events::DomStorageItemRemovedEvent), + #[serde(rename = "DOMStorage.domStorageItemUpdated")] + DOMStorageDomStorageItemUpdated(super::DOMStorage::events::DomStorageItemUpdatedEvent), + #[serde(rename = "DOMStorage.domStorageItemsCleared")] + DOMStorageDomStorageItemsCleared( + super::DOMStorage::events::DomStorageItemsClearedEvent, + ), + #[serde(rename = "Database.addDatabase")] + AddDatabase(super::Database::events::AddDatabaseEvent), + #[serde(rename = "Emulation.virtualTimeBudgetExpired")] + EmulationVirtualTimeBudgetExpired( + super::Emulation::events::VirtualTimeBudgetExpiredEvent, + ), + #[serde(rename = "HeadlessExperimental.needsBeginFramesChanged")] + HeadlessExperimentalNeedsBeginFramesChanged( + super::HeadlessExperimental::events::NeedsBeginFramesChangedEvent, + ), + #[serde(rename = "Input.dragIntercepted")] + InputDragIntercepted(super::Input::events::DragInterceptedEvent), + #[serde(rename = "Inspector.detached")] + InspectorDetached(super::Inspector::events::DetachedEvent), + #[serde(rename = "Inspector.targetCrashed")] + InspectorTargetCrashed(super::Inspector::events::TargetCrashedEvent), + #[serde(rename = "Inspector.targetReloadedAfterCrash")] + InspectorTargetReloadedAfterCrash( + super::Inspector::events::TargetReloadedAfterCrashEvent, + ), + #[serde(rename = "LayerTree.layerPainted")] + LayerTreeLayerPainted(super::LayerTree::events::LayerPaintedEvent), + #[serde(rename = "LayerTree.layerTreeDidChange")] + LayerTreeDidChange(super::LayerTree::events::LayerTreeDidChangeEvent), + #[serde(rename = "Log.entryAdded")] + LogEntryAdded(super::Log::events::EntryAddedEvent), + #[serde(rename = "Network.dataReceived")] + NetworkDataReceived(super::Network::events::DataReceivedEvent), + #[serde(rename = "Network.eventSourceMessageReceived")] + NetworkEventSourceMessageReceived( + super::Network::events::EventSourceMessageReceivedEvent, + ), + #[serde(rename = "Network.loadingFailed")] + NetworkLoadingFailed(super::Network::events::LoadingFailedEvent), + #[serde(rename = "Network.loadingFinished")] + NetworkLoadingFinished(super::Network::events::LoadingFinishedEvent), + #[serde(rename = "Network.requestIntercepted")] + NetworkRequestIntercepted(super::Network::events::RequestInterceptedEvent), + #[serde(rename = "Network.requestServedFromCache")] + NetworkRequestServedFromCache(super::Network::events::RequestServedFromCacheEvent), + #[serde(rename = "Network.requestWillBeSent")] + NetworkRequestWillBeSent(super::Network::events::RequestWillBeSentEvent), + #[serde(rename = "Network.resourceChangedPriority")] + NetworkResourceChangedPriority(super::Network::events::ResourceChangedPriorityEvent), + #[serde(rename = "Network.signedExchangeReceived")] + NetworkSignedExchangeReceived(super::Network::events::SignedExchangeReceivedEvent), + #[serde(rename = "Network.responseReceived")] + NetworkResponseReceived(super::Network::events::ResponseReceivedEvent), + #[serde(rename = "Network.webSocketClosed")] + NetworkWebSocketClosed(super::Network::events::WebSocketClosedEvent), + #[serde(rename = "Network.webSocketCreated")] + NetworkWebSocketCreated(super::Network::events::WebSocketCreatedEvent), + #[serde(rename = "Network.webSocketFrameError")] + NetworkWebSocketFrameError(super::Network::events::WebSocketFrameErrorEvent), + #[serde(rename = "Network.webSocketFrameReceived")] + NetworkWebSocketFrameReceived(super::Network::events::WebSocketFrameReceivedEvent), + #[serde(rename = "Network.webSocketFrameSent")] + NetworkWebSocketFrameSent(super::Network::events::WebSocketFrameSentEvent), + #[serde(rename = "Network.webSocketHandshakeResponseReceived")] + NetworkWebSocketHandshakeResponseReceived( + super::Network::events::WebSocketHandshakeResponseReceivedEvent, + ), + #[serde(rename = "Network.webSocketWillSendHandshakeRequest")] + NetworkWebSocketWillSendHandshakeRequest( + super::Network::events::WebSocketWillSendHandshakeRequestEvent, + ), + #[serde(rename = "Network.webTransportCreated")] + NetworkWebTransportCreated(super::Network::events::WebTransportCreatedEvent), + #[serde(rename = "Network.webTransportConnectionEstablished")] + NetworkWebTransportConnectionEstablished( + super::Network::events::WebTransportConnectionEstablishedEvent, + ), + #[serde(rename = "Network.webTransportClosed")] + NetworkWebTransportClosed(super::Network::events::WebTransportClosedEvent), + #[serde(rename = "Network.requestWillBeSentExtraInfo")] + NetworkRequestWillBeSentExtraInfo( + super::Network::events::RequestWillBeSentExtraInfoEvent, + ), + #[serde(rename = "Network.responseReceivedExtraInfo")] + NetworkResponseReceivedExtraInfo( + super::Network::events::ResponseReceivedExtraInfoEvent, + ), + #[serde(rename = "Network.trustTokenOperationDone")] + NetworkTrustTokenOperationDone(super::Network::events::TrustTokenOperationDoneEvent), + #[serde(rename = "Network.subresourceWebBundleMetadataReceived")] + NetworkSubresourceWebBundleMetadataReceived( + super::Network::events::SubresourceWebBundleMetadataReceivedEvent, + ), + #[serde(rename = "Network.subresourceWebBundleMetadataError")] + NetworkSubresourceWebBundleMetadataError( + super::Network::events::SubresourceWebBundleMetadataErrorEvent, + ), + #[serde(rename = "Network.subresourceWebBundleInnerResponseParsed")] + NetworkSubresourceWebBundleInnerResponseParsed( + super::Network::events::SubresourceWebBundleInnerResponseParsedEvent, + ), + #[serde(rename = "Network.subresourceWebBundleInnerResponseError")] + NetworkSubresourceWebBundleInnerResponseError( + super::Network::events::SubresourceWebBundleInnerResponseErrorEvent, + ), + #[serde(rename = "Network.reportingApiReportAdded")] + NetworkReportingApiReportAdded(super::Network::events::ReportingApiReportAddedEvent), + #[serde(rename = "Network.reportingApiReportUpdated")] + NetworkReportingApiReportUpdated( + super::Network::events::ReportingApiReportUpdatedEvent, + ), + #[serde(rename = "Network.reportingApiEndpointsChangedForOrigin")] + NetworkReportingApiEndpointsChangedForOrigin( + super::Network::events::ReportingApiEndpointsChangedForOriginEvent, + ), + #[serde(rename = "Overlay.inspectNodeRequested")] + OverlayInspectNodeRequested(super::Overlay::events::InspectNodeRequestedEvent), + #[serde(rename = "Overlay.nodeHighlightRequested")] + OverlayNodeHighlightRequested(super::Overlay::events::NodeHighlightRequestedEvent), + #[serde(rename = "Overlay.screenshotRequested")] + OverlayScreenshotRequested(super::Overlay::events::ScreenshotRequestedEvent), + #[serde(rename = "Overlay.inspectModeCanceled")] + OverlayInspectModeCanceled(super::Overlay::events::InspectModeCanceledEvent), + #[serde(rename = "Page.domContentEventFired")] + PageDomContentEventFired(super::Page::events::DomContentEventFiredEvent), + #[serde(rename = "Page.fileChooserOpened")] + PageFileChooserOpened(super::Page::events::FileChooserOpenedEvent), + #[serde(rename = "Page.frameAttached")] + PageFrameAttached(super::Page::events::FrameAttachedEvent), + #[serde(rename = "Page.frameClearedScheduledNavigation")] + PageFrameClearedScheduledNavigation( + super::Page::events::FrameClearedScheduledNavigationEvent, + ), + #[serde(rename = "Page.frameDetached")] + PageFrameDetached(super::Page::events::FrameDetachedEvent), + #[serde(rename = "Page.frameNavigated")] + PageFrameNavigated(super::Page::events::FrameNavigatedEvent), + #[serde(rename = "Page.documentOpened")] + PageDocumentOpened(super::Page::events::DocumentOpenedEvent), + #[serde(rename = "Page.frameResized")] + PageFrameResized(super::Page::events::FrameResizedEvent), + #[serde(rename = "Page.frameRequestedNavigation")] + PageFrameRequestedNavigation(super::Page::events::FrameRequestedNavigationEvent), + #[serde(rename = "Page.frameScheduledNavigation")] + PageFrameScheduledNavigation(super::Page::events::FrameScheduledNavigationEvent), + #[serde(rename = "Page.frameStartedLoading")] + PageFrameStartedLoading(super::Page::events::FrameStartedLoadingEvent), + #[serde(rename = "Page.frameStoppedLoading")] + PageFrameStoppedLoading(super::Page::events::FrameStoppedLoadingEvent), + #[serde(rename = "Page.downloadWillBegin")] + PageDownloadWillBegin(super::Page::events::DownloadWillBeginEvent), + #[serde(rename = "Page.downloadProgress")] + PageDownloadProgress(super::Page::events::DownloadProgressEvent), + #[serde(rename = "Page.interstitialHidden")] + PageInterstitialHidden(super::Page::events::InterstitialHiddenEvent), + #[serde(rename = "Page.interstitialShown")] + PageInterstitialShown(super::Page::events::InterstitialShownEvent), + #[serde(rename = "Page.javascriptDialogClosed")] + PageJavascriptDialogClosed(super::Page::events::JavascriptDialogClosedEvent), + #[serde(rename = "Page.javascriptDialogOpening")] + PageJavascriptDialogOpening(super::Page::events::JavascriptDialogOpeningEvent), + #[serde(rename = "Page.lifecycleEvent")] + PageLifecycleEvent(super::Page::events::LifecycleEventEvent), + #[serde(rename = "Page.backForwardCacheNotUsed")] + PageBackForwardCacheNotUsed(super::Page::events::BackForwardCacheNotUsedEvent), + #[serde(rename = "Page.loadEventFired")] + PageLoadEventFired(super::Page::events::LoadEventFiredEvent), + #[serde(rename = "Page.navigatedWithinDocument")] + PageNavigatedWithinDocument(super::Page::events::NavigatedWithinDocumentEvent), + #[serde(rename = "Page.screencastFrame")] + PageScreencastFrame(super::Page::events::ScreencastFrameEvent), + #[serde(rename = "Page.screencastVisibilityChanged")] + PageScreencastVisibilityChanged(super::Page::events::ScreencastVisibilityChangedEvent), + #[serde(rename = "Page.windowOpen")] + PageWindowOpen(super::Page::events::WindowOpenEvent), + #[serde(rename = "Page.compilationCacheProduced")] + PageCompilationCacheProduced(super::Page::events::CompilationCacheProducedEvent), + #[serde(rename = "Performance.metrics")] + PerformanceMetrics(super::Performance::events::MetricsEvent), + #[serde(rename = "PerformanceTimeline.timelineEventAdded")] + PerformanceTimelineTimelineEventAdded( + super::PerformanceTimeline::events::TimelineEventAddedEvent, + ), + #[serde(rename = "Security.certificateError")] + SecurityCertificateError(super::Security::events::CertificateErrorEvent), + #[serde(rename = "Security.visibleSecurityStateChanged")] + VisibleSecurityStateChanged(super::Security::events::VisibleSecurityStateChangedEvent), + #[serde(rename = "Security.securityStateChanged")] + SecurityStateChanged(super::Security::events::SecurityStateChangedEvent), + #[serde(rename = "ServiceWorker.workerErrorReported")] + ServiceWorkerWorkerErrorReported( + super::ServiceWorker::events::WorkerErrorReportedEvent, + ), + #[serde(rename = "ServiceWorker.workerRegistrationUpdated")] + ServiceWorkerWorkerRegistrationUpdated( + super::ServiceWorker::events::WorkerRegistrationUpdatedEvent, + ), + #[serde(rename = "ServiceWorker.workerVersionUpdated")] + ServiceWorkerWorkerVersionUpdated( + super::ServiceWorker::events::WorkerVersionUpdatedEvent, + ), + #[serde(rename = "Storage.cacheStorageContentUpdated")] + CacheStorageContentUpdated(super::Storage::events::CacheStorageContentUpdatedEvent), + #[serde(rename = "Storage.cacheStorageListUpdated")] + CacheStorageListUpdated(super::Storage::events::CacheStorageListUpdatedEvent), + #[serde(rename = "Storage.indexedDBContentUpdated")] + StorageIndexedDBContentUpdated(super::Storage::events::IndexedDBContentUpdatedEvent), + #[serde(rename = "Storage.indexedDBListUpdated")] + StorageIndexedDBListUpdated(super::Storage::events::IndexedDBListUpdatedEvent), + #[serde(rename = "Target.attachedToTarget")] + AttachedToTarget(super::Target::events::AttachedToTargetEvent), + #[serde(rename = "Target.detachedFromTarget")] + DetachedFromTarget(super::Target::events::DetachedFromTargetEvent), + #[serde(rename = "Target.receivedMessageFromTarget")] + ReceivedMessageFromTarget(super::Target::events::ReceivedMessageFromTargetEvent), + #[serde(rename = "Target.targetCreated")] + TargetCreated(super::Target::events::TargetCreatedEvent), + #[serde(rename = "Target.targetDestroyed")] + TargetDestroyed(super::Target::events::TargetDestroyedEvent), + #[serde(rename = "Target.targetCrashed")] + TargetCrashed(super::Target::events::TargetCrashedEvent), + #[serde(rename = "Target.targetInfoChanged")] + TargetInfoChanged(super::Target::events::TargetInfoChangedEvent), + #[serde(rename = "Tethering.accepted")] + TetheringAccepted(super::Tethering::events::AcceptedEvent), + #[serde(rename = "Tracing.bufferUsage")] + TracingBufferUsage(super::Tracing::events::BufferUsageEvent), + #[serde(rename = "Tracing.dataCollected")] + TracingDataCollected(super::Tracing::events::DataCollectedEvent), + #[serde(rename = "Tracing.tracingComplete")] + TracingComplete(super::Tracing::events::TracingCompleteEvent), + #[serde(rename = "Fetch.requestPaused")] + FetchRequestPaused(super::Fetch::events::RequestPausedEvent), + #[serde(rename = "Fetch.authRequired")] + FetchAuthRequired(super::Fetch::events::AuthRequiredEvent), + #[serde(rename = "WebAudio.contextCreated")] + WebAudioContextCreated(super::WebAudio::events::ContextCreatedEvent), + #[serde(rename = "WebAudio.contextWillBeDestroyed")] + WebAudioContextWillBeDestroyed(super::WebAudio::events::ContextWillBeDestroyedEvent), + #[serde(rename = "WebAudio.contextChanged")] + WebAudioContextChanged(super::WebAudio::events::ContextChangedEvent), + #[serde(rename = "WebAudio.audioListenerCreated")] + WebAudioAudioListenerCreated(super::WebAudio::events::AudioListenerCreatedEvent), + #[serde(rename = "WebAudio.audioListenerWillBeDestroyed")] + WebAudioAudioListenerWillBeDestroyed( + super::WebAudio::events::AudioListenerWillBeDestroyedEvent, + ), + #[serde(rename = "WebAudio.audioNodeCreated")] + WebAudioAudioNodeCreated(super::WebAudio::events::AudioNodeCreatedEvent), + #[serde(rename = "WebAudio.audioNodeWillBeDestroyed")] + WebAudioAudioNodeWillBeDestroyed( + super::WebAudio::events::AudioNodeWillBeDestroyedEvent, + ), + #[serde(rename = "WebAudio.audioParamCreated")] + WebAudioAudioParamCreated(super::WebAudio::events::AudioParamCreatedEvent), + #[serde(rename = "WebAudio.audioParamWillBeDestroyed")] + WebAudioAudioParamWillBeDestroyed( + super::WebAudio::events::AudioParamWillBeDestroyedEvent, + ), + #[serde(rename = "WebAudio.nodesConnected")] + WebAudioNodesConnected(super::WebAudio::events::NodesConnectedEvent), + #[serde(rename = "WebAudio.nodesDisconnected")] + WebAudioNodesDisconnected(super::WebAudio::events::NodesDisconnectedEvent), + #[serde(rename = "WebAudio.nodeParamConnected")] + WebAudioNodeParamConnected(super::WebAudio::events::NodeParamConnectedEvent), + #[serde(rename = "WebAudio.nodeParamDisconnected")] + WebAudioNodeParamDisconnected(super::WebAudio::events::NodeParamDisconnectedEvent), + #[serde(rename = "Media.playerPropertiesChanged")] + MediaPlayerPropertiesChanged(super::Media::events::PlayerPropertiesChangedEvent), + #[serde(rename = "Media.playerEventsAdded")] + MediaPlayerEventsAdded(super::Media::events::PlayerEventsAddedEvent), + #[serde(rename = "Media.playerMessagesLogged")] + MediaPlayerMessagesLogged(super::Media::events::PlayerMessagesLoggedEvent), + #[serde(rename = "Media.playerErrorsRaised")] + MediaPlayerErrorsRaised(super::Media::events::PlayerErrorsRaisedEvent), + #[serde(rename = "Media.playersCreated")] + MediaPlayersCreated(super::Media::events::PlayersCreatedEvent), + #[serde(rename = "Console.messageAdded")] + ConsoleMessageAdded(super::Console::events::MessageAddedEvent), + #[serde(rename = "Debugger.breakpointResolved")] + DebuggerBreakpointResolved(super::Debugger::events::BreakpointResolvedEvent), + #[serde(rename = "Debugger.paused")] + DebuggerPaused(super::Debugger::events::PausedEvent), + #[serde(rename = "Debugger.resumed")] + DebuggerResumed(super::Debugger::events::ResumedEvent), + #[serde(rename = "Debugger.scriptFailedToParse")] + DebuggerScriptFailedToParse(super::Debugger::events::ScriptFailedToParseEvent), + #[serde(rename = "Debugger.scriptParsed")] + DebuggerScriptParsed(super::Debugger::events::ScriptParsedEvent), + #[serde(rename = "HeapProfiler.addHeapSnapshotChunk")] + HeapProfilerAddHeapSnapshotChunk( + super::HeapProfiler::events::AddHeapSnapshotChunkEvent, + ), + #[serde(rename = "HeapProfiler.heapStatsUpdate")] + HeapProfilerHeapStatsUpdate(super::HeapProfiler::events::HeapStatsUpdateEvent), + #[serde(rename = "HeapProfiler.lastSeenObjectId")] + HeapProfilerLastSeenObjectId(super::HeapProfiler::events::LastSeenObjectIdEvent), + #[serde(rename = "HeapProfiler.reportHeapSnapshotProgress")] + HeapProfilerReportHeapSnapshotProgress( + super::HeapProfiler::events::ReportHeapSnapshotProgressEvent, + ), + #[serde(rename = "HeapProfiler.resetProfiles")] + HeapProfilerResetProfiles(super::HeapProfiler::events::ResetProfilesEvent), + #[serde(rename = "Profiler.consoleProfileFinished")] + ProfilerConsoleProfileFinished(super::Profiler::events::ConsoleProfileFinishedEvent), + #[serde(rename = "Profiler.consoleProfileStarted")] + ProfilerConsoleProfileStarted(super::Profiler::events::ConsoleProfileStartedEvent), + #[serde(rename = "Profiler.preciseCoverageDeltaUpdate")] + ProfilerPreciseCoverageDeltaUpdate( + super::Profiler::events::PreciseCoverageDeltaUpdateEvent, + ), + #[serde(rename = "Runtime.bindingCalled")] + RuntimeBindingCalled(super::Runtime::events::BindingCalledEvent), + #[serde(rename = "Runtime.consoleAPICalled")] + RuntimeConsoleAPICalled(super::Runtime::events::ConsoleAPICalledEvent), + #[serde(rename = "Runtime.exceptionRevoked")] + RuntimeExceptionRevoked(super::Runtime::events::ExceptionRevokedEvent), + #[serde(rename = "Runtime.exceptionThrown")] + RuntimeExceptionThrown(super::Runtime::events::ExceptionThrownEvent), + #[serde(rename = "Runtime.executionContextCreated")] + RuntimeExecutionContextCreated(super::Runtime::events::ExecutionContextCreatedEvent), + #[serde(rename = "Runtime.executionContextDestroyed")] + RuntimeExecutionContextDestroyed( + super::Runtime::events::ExecutionContextDestroyedEvent, + ), + #[serde(rename = "Runtime.executionContextsCleared")] + RuntimeExecutionContextsCleared(super::Runtime::events::ExecutionContextsClearedEvent), + #[serde(rename = "Runtime.inspectRequested")] + RuntimeInspectRequested(super::Runtime::events::InspectRequestedEvent), + } + } + pub mod Console { + use super::types::*; + use super::Runtime; + use serde::{Deserialize, Serialize}; + use serde_json::Value as Json; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "kebab-case")] + pub enum ConsoleMessageSource { + Xml, + Javascript, + Network, + ConsoleApi, + Storage, + Appcache, + Rendering, + Security, + Other, + Deprecation, + Worker, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum ConsoleMessageLevel { + Log, + Warning, + Error, + Debug, + Info, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ConsoleMessage { + pub source: ConsoleMessageSource, + pub level: ConsoleMessageLevel, + #[serde(default)] + pub text: String, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub url: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub line: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub column: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ClearMessages(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Disable(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Enable(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ClearMessagesReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DisableReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct EnableReturnObject {} + impl Method for ClearMessages { + const NAME: &'static str = "Console.clearMessages"; + type ReturnObject = ClearMessagesReturnObject; + } + impl Method for Disable { + const NAME: &'static str = "Console.disable"; + type ReturnObject = DisableReturnObject; + } + impl Method for Enable { + const NAME: &'static str = "Console.enable"; + type ReturnObject = EnableReturnObject; + } + pub mod events { + use super::super::types::*; + use serde::{Deserialize, Serialize}; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct MessageAddedEvent { + pub params: MessageAddedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct MessageAddedEventParams { + pub message: super::ConsoleMessage, + } + } + } + pub mod Debugger { + use super::types::*; + use super::Runtime; + use serde::{Deserialize, Serialize}; + use serde_json::Value as Json; + pub type BreakpointId = String; + pub type CallFrameId = String; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "kebab-case")] + pub enum ScopeType { + Global, + Local, + With, + Closure, + Catch, + Block, + Script, + Eval, + Module, + WasmExpressionStack, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum BreakLocationType { + DebuggerStatement, + Call, + Return, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "PascalCase")] + pub enum ScriptLanguage { + JavaScript, + WebAssembly, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "PascalCase")] + pub enum DebugSymbolsType { + None, + SourceMap, + EmbeddedDwarf, + ExternalDwarf, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum ContinueToLocationTarget_call_framesOption { + Any, + Current, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum SetInstrumentationBreakpointInstrumentationOption { + BeforeScriptExecution, + BeforeScriptWithSourceMapExecution, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum SetPauseOnExceptionsStateOption { + None, + Uncaught, + All, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "PascalCase")] + pub enum PausedEventReasonOption { + Ambiguous, + Assert, + CspViolation, + DebugCommand, + Dom, + EventListener, + Exception, + Instrumentation, + Oom, + Other, + PromiseRejection, + Xhr, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Location { + pub script_id: Runtime::ScriptId, + #[serde(default)] + pub line_number: JsUInt, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub column_number: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ScriptPosition { + #[serde(default)] + pub line_number: JsUInt, + #[serde(default)] + pub column_number: JsUInt, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct LocationRange { + pub script_id: Runtime::ScriptId, + pub start: ScriptPosition, + pub end: ScriptPosition, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CallFrame { + pub call_frame_id: CallFrameId, + #[serde(default)] + pub function_name: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub function_location: Option, + pub location: Location, + #[serde(default)] + pub url: String, + pub scope_chain: Vec, + pub this: Runtime::RemoteObject, + #[serde(skip_serializing_if = "Option::is_none")] + pub return_value: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Scope { + pub Type: ScopeType, + pub object: Runtime::RemoteObject, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub name: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub start_location: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub end_location: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SearchMatch { + #[serde(default)] + pub line_number: JsFloat, + #[serde(default)] + pub line_content: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct BreakLocation { + pub script_id: Runtime::ScriptId, + #[serde(default)] + pub line_number: JsUInt, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub column_number: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub Type: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DebugSymbols { + pub Type: DebugSymbolsType, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub external_url: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ContinueToLocation { + pub location: Location, + #[serde(skip_serializing_if = "Option::is_none")] + pub target_call_frames: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Disable(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Enable { + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub max_scripts_cache_size: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct EvaluateOnCallFrame { + pub call_frame_id: CallFrameId, + #[serde(default)] + pub expression: String, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub object_group: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub include_command_line_api: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub silent: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub return_by_value: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub generate_preview: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub throw_on_side_effect: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub timeout: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetPossibleBreakpoints { + pub start: Location, + #[serde(skip_serializing_if = "Option::is_none")] + pub end: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub restrict_to_function: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetScriptSource { + pub script_id: Runtime::ScriptId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetWasmBytecode { + pub script_id: Runtime::ScriptId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetStackTrace { + pub stack_trace_id: Runtime::StackTraceId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Pause(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct PauseOnAsyncCall { + pub parent_stack_trace_id: Runtime::StackTraceId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RemoveBreakpoint { + pub breakpoint_id: BreakpointId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RestartFrame { + pub call_frame_id: CallFrameId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Resume { + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub terminate_on_resume: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SearchInContent { + pub script_id: Runtime::ScriptId, + #[serde(default)] + pub query: String, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub case_sensitive: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub is_regex: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetAsyncCallStackDepth { + #[serde(default)] + pub max_depth: JsUInt, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetBlackboxPatterns { + #[serde(default)] + pub patterns: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetBlackboxedRanges { + pub script_id: Runtime::ScriptId, + pub positions: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetBreakpoint { + pub location: Location, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub condition: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetInstrumentationBreakpoint { + pub instrumentation: SetInstrumentationBreakpointInstrumentationOption, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetBreakpointByUrl { + #[serde(default)] + pub line_number: JsUInt, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub url: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub url_regex: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub script_hash: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub column_number: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub condition: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetBreakpointOnFunctionCall { + pub object_id: Runtime::RemoteObjectId, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub condition: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetBreakpointsActive { + #[serde(default)] + pub active: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetPauseOnExceptions { + pub state: SetPauseOnExceptionsStateOption, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetReturnValue { + pub new_value: Runtime::CallArgument, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetScriptSource { + pub script_id: Runtime::ScriptId, + #[serde(default)] + pub script_source: String, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub dry_run: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetSkipAllPauses { + #[serde(default)] + pub skip: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetVariableValue { + #[serde(default)] + pub scope_number: JsUInt, + #[serde(default)] + pub variable_name: String, + pub new_value: Runtime::CallArgument, + pub call_frame_id: CallFrameId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StepInto { + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub break_on_async_call: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub skip_list: Option>, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StepOut(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StepOver { + #[serde(skip_serializing_if = "Option::is_none")] + pub skip_list: Option>, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ContinueToLocationReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DisableReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct EnableReturnObject { + pub debugger_id: Runtime::UniqueDebuggerId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct EvaluateOnCallFrameReturnObject { + pub result: Runtime::RemoteObject, + #[serde(skip_serializing_if = "Option::is_none")] + pub exception_details: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetPossibleBreakpointsReturnObject { + pub locations: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetScriptSourceReturnObject { + #[serde(default)] + pub script_source: String, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub bytecode: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetWasmBytecodeReturnObject { + #[serde(default)] + pub bytecode: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetStackTraceReturnObject { + pub stack_trace: Runtime::StackTrace, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct PauseReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct PauseOnAsyncCallReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RemoveBreakpointReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RestartFrameReturnObject { + pub call_frames: Vec, + #[serde(skip_serializing_if = "Option::is_none")] + pub async_stack_trace: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub async_stack_trace_id: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ResumeReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SearchInContentReturnObject { + pub result: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetAsyncCallStackDepthReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetBlackboxPatternsReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetBlackboxedRangesReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetBreakpointReturnObject { + pub breakpoint_id: BreakpointId, + pub actual_location: Location, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetInstrumentationBreakpointReturnObject { + pub breakpoint_id: BreakpointId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetBreakpointByUrlReturnObject { + pub breakpoint_id: BreakpointId, + pub locations: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetBreakpointOnFunctionCallReturnObject { + pub breakpoint_id: BreakpointId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetBreakpointsActiveReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetPauseOnExceptionsReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetReturnValueReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetScriptSourceReturnObject { + #[serde(skip_serializing_if = "Option::is_none")] + pub call_frames: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub stack_changed: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub async_stack_trace: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub async_stack_trace_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub exception_details: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetSkipAllPausesReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetVariableValueReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StepIntoReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StepOutReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StepOverReturnObject {} + impl Method for ContinueToLocation { + const NAME: &'static str = "Debugger.continueToLocation"; + type ReturnObject = ContinueToLocationReturnObject; + } + impl Method for Disable { + const NAME: &'static str = "Debugger.disable"; + type ReturnObject = DisableReturnObject; + } + impl Method for Enable { + const NAME: &'static str = "Debugger.enable"; + type ReturnObject = EnableReturnObject; + } + impl Method for EvaluateOnCallFrame { + const NAME: &'static str = "Debugger.evaluateOnCallFrame"; + type ReturnObject = EvaluateOnCallFrameReturnObject; + } + impl Method for GetPossibleBreakpoints { + const NAME: &'static str = "Debugger.getPossibleBreakpoints"; + type ReturnObject = GetPossibleBreakpointsReturnObject; + } + impl Method for GetScriptSource { + const NAME: &'static str = "Debugger.getScriptSource"; + type ReturnObject = GetScriptSourceReturnObject; + } + impl Method for GetWasmBytecode { + const NAME: &'static str = "Debugger.getWasmBytecode"; + type ReturnObject = GetWasmBytecodeReturnObject; + } + impl Method for GetStackTrace { + const NAME: &'static str = "Debugger.getStackTrace"; + type ReturnObject = GetStackTraceReturnObject; + } + impl Method for Pause { + const NAME: &'static str = "Debugger.pause"; + type ReturnObject = PauseReturnObject; + } + impl Method for PauseOnAsyncCall { + const NAME: &'static str = "Debugger.pauseOnAsyncCall"; + type ReturnObject = PauseOnAsyncCallReturnObject; + } + impl Method for RemoveBreakpoint { + const NAME: &'static str = "Debugger.removeBreakpoint"; + type ReturnObject = RemoveBreakpointReturnObject; + } + impl Method for RestartFrame { + const NAME: &'static str = "Debugger.restartFrame"; + type ReturnObject = RestartFrameReturnObject; + } + impl Method for Resume { + const NAME: &'static str = "Debugger.resume"; + type ReturnObject = ResumeReturnObject; + } + impl Method for SearchInContent { + const NAME: &'static str = "Debugger.searchInContent"; + type ReturnObject = SearchInContentReturnObject; + } + impl Method for SetAsyncCallStackDepth { + const NAME: &'static str = "Debugger.setAsyncCallStackDepth"; + type ReturnObject = SetAsyncCallStackDepthReturnObject; + } + impl Method for SetBlackboxPatterns { + const NAME: &'static str = "Debugger.setBlackboxPatterns"; + type ReturnObject = SetBlackboxPatternsReturnObject; + } + impl Method for SetBlackboxedRanges { + const NAME: &'static str = "Debugger.setBlackboxedRanges"; + type ReturnObject = SetBlackboxedRangesReturnObject; + } + impl Method for SetBreakpoint { + const NAME: &'static str = "Debugger.setBreakpoint"; + type ReturnObject = SetBreakpointReturnObject; + } + impl Method for SetInstrumentationBreakpoint { + const NAME: &'static str = "Debugger.setInstrumentationBreakpoint"; + type ReturnObject = SetInstrumentationBreakpointReturnObject; + } + impl Method for SetBreakpointByUrl { + const NAME: &'static str = "Debugger.setBreakpointByUrl"; + type ReturnObject = SetBreakpointByUrlReturnObject; + } + impl Method for SetBreakpointOnFunctionCall { + const NAME: &'static str = "Debugger.setBreakpointOnFunctionCall"; + type ReturnObject = SetBreakpointOnFunctionCallReturnObject; + } + impl Method for SetBreakpointsActive { + const NAME: &'static str = "Debugger.setBreakpointsActive"; + type ReturnObject = SetBreakpointsActiveReturnObject; + } + impl Method for SetPauseOnExceptions { + const NAME: &'static str = "Debugger.setPauseOnExceptions"; + type ReturnObject = SetPauseOnExceptionsReturnObject; + } + impl Method for SetReturnValue { + const NAME: &'static str = "Debugger.setReturnValue"; + type ReturnObject = SetReturnValueReturnObject; + } + impl Method for SetScriptSource { + const NAME: &'static str = "Debugger.setScriptSource"; + type ReturnObject = SetScriptSourceReturnObject; + } + impl Method for SetSkipAllPauses { + const NAME: &'static str = "Debugger.setSkipAllPauses"; + type ReturnObject = SetSkipAllPausesReturnObject; + } + impl Method for SetVariableValue { + const NAME: &'static str = "Debugger.setVariableValue"; + type ReturnObject = SetVariableValueReturnObject; + } + impl Method for StepInto { + const NAME: &'static str = "Debugger.stepInto"; + type ReturnObject = StepIntoReturnObject; + } + impl Method for StepOut { + const NAME: &'static str = "Debugger.stepOut"; + type ReturnObject = StepOutReturnObject; + } + impl Method for StepOver { + const NAME: &'static str = "Debugger.stepOver"; + type ReturnObject = StepOverReturnObject; + } + pub mod events { + use super::super::types::*; + use serde::{Deserialize, Serialize}; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct BreakpointResolvedEvent { + pub params: BreakpointResolvedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct BreakpointResolvedEventParams { + pub breakpoint_id: super::BreakpointId, + pub location: super::Location, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct PausedEvent { + pub params: PausedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct PausedEventParams { + pub call_frames: Vec, + pub reason: super::PausedEventReasonOption, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub hit_breakpoints: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + pub async_stack_trace: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub async_stack_trace_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub async_call_stack_trace_id: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ResumedEvent(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct ScriptFailedToParseEvent { + pub params: ScriptFailedToParseEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ScriptFailedToParseEventParams { + pub script_id: super::super::Runtime::ScriptId, + #[serde(default)] + pub url: String, + #[serde(default)] + pub start_line: JsUInt, + #[serde(default)] + pub start_column: JsUInt, + #[serde(default)] + pub end_line: JsUInt, + #[serde(default)] + pub end_column: JsUInt, + pub execution_context_id: super::super::Runtime::ExecutionContextId, + #[serde(default)] + pub hash: String, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub source_map_url: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub has_source_url: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub is_module: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub length: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub stack_trace: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub code_offset: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub script_language: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub embedder_name: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct ScriptParsedEvent { + pub params: ScriptParsedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ScriptParsedEventParams { + pub script_id: super::super::Runtime::ScriptId, + #[serde(default)] + pub url: String, + #[serde(default)] + pub start_line: JsUInt, + #[serde(default)] + pub start_column: JsUInt, + #[serde(default)] + pub end_line: JsUInt, + #[serde(default)] + pub end_column: JsUInt, + pub execution_context_id: super::super::Runtime::ExecutionContextId, + #[serde(default)] + pub hash: String, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub is_live_edit: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub source_map_url: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub has_source_url: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub is_module: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub length: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub stack_trace: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub code_offset: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub script_language: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub debug_symbols: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub embedder_name: Option, + } + } + } + pub mod HeapProfiler { + use super::types::*; + use super::Runtime; + use serde::{Deserialize, Serialize}; + use serde_json::Value as Json; + pub type HeapSnapshotObjectId = String; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SamplingHeapProfileNode { + pub call_frame: Runtime::CallFrame, + #[serde(default)] + pub self_size: JsFloat, + #[serde(default)] + pub id: JsUInt, + pub children: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SamplingHeapProfileSample { + #[serde(default)] + pub size: JsFloat, + #[serde(default)] + pub node_id: JsUInt, + #[serde(default)] + pub ordinal: JsFloat, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SamplingHeapProfile { + pub head: SamplingHeapProfileNode, + pub samples: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct AddInspectedHeapObject { + pub heap_object_id: HeapSnapshotObjectId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CollectGarbage(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Disable(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Enable(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetHeapObjectId { + pub object_id: Runtime::RemoteObjectId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetObjectByHeapObjectId { + pub object_id: HeapSnapshotObjectId, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub object_group: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetSamplingProfile(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StartSampling { + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub sampling_interval: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StartTrackingHeapObjects { + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub track_allocations: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StopSampling(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StopTrackingHeapObjects { + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub report_progress: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub treat_global_objects_as_roots: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub capture_numeric_value: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct TakeHeapSnapshot { + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub report_progress: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub treat_global_objects_as_roots: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub capture_numeric_value: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct AddInspectedHeapObjectReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CollectGarbageReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DisableReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct EnableReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetHeapObjectIdReturnObject { + pub heap_snapshot_object_id: HeapSnapshotObjectId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetObjectByHeapObjectIdReturnObject { + pub result: Runtime::RemoteObject, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetSamplingProfileReturnObject { + pub profile: SamplingHeapProfile, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StartSamplingReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StartTrackingHeapObjectsReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StopSamplingReturnObject { + pub profile: SamplingHeapProfile, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StopTrackingHeapObjectsReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct TakeHeapSnapshotReturnObject {} + impl Method for AddInspectedHeapObject { + const NAME: &'static str = "HeapProfiler.addInspectedHeapObject"; + type ReturnObject = AddInspectedHeapObjectReturnObject; + } + impl Method for CollectGarbage { + const NAME: &'static str = "HeapProfiler.collectGarbage"; + type ReturnObject = CollectGarbageReturnObject; + } + impl Method for Disable { + const NAME: &'static str = "HeapProfiler.disable"; + type ReturnObject = DisableReturnObject; + } + impl Method for Enable { + const NAME: &'static str = "HeapProfiler.enable"; + type ReturnObject = EnableReturnObject; + } + impl Method for GetHeapObjectId { + const NAME: &'static str = "HeapProfiler.getHeapObjectId"; + type ReturnObject = GetHeapObjectIdReturnObject; + } + impl Method for GetObjectByHeapObjectId { + const NAME: &'static str = "HeapProfiler.getObjectByHeapObjectId"; + type ReturnObject = GetObjectByHeapObjectIdReturnObject; + } + impl Method for GetSamplingProfile { + const NAME: &'static str = "HeapProfiler.getSamplingProfile"; + type ReturnObject = GetSamplingProfileReturnObject; + } + impl Method for StartSampling { + const NAME: &'static str = "HeapProfiler.startSampling"; + type ReturnObject = StartSamplingReturnObject; + } + impl Method for StartTrackingHeapObjects { + const NAME: &'static str = "HeapProfiler.startTrackingHeapObjects"; + type ReturnObject = StartTrackingHeapObjectsReturnObject; + } + impl Method for StopSampling { + const NAME: &'static str = "HeapProfiler.stopSampling"; + type ReturnObject = StopSamplingReturnObject; + } + impl Method for StopTrackingHeapObjects { + const NAME: &'static str = "HeapProfiler.stopTrackingHeapObjects"; + type ReturnObject = StopTrackingHeapObjectsReturnObject; + } + impl Method for TakeHeapSnapshot { + const NAME: &'static str = "HeapProfiler.takeHeapSnapshot"; + type ReturnObject = TakeHeapSnapshotReturnObject; + } + pub mod events { + use super::super::types::*; + use serde::{Deserialize, Serialize}; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct AddHeapSnapshotChunkEvent { + pub params: AddHeapSnapshotChunkEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct AddHeapSnapshotChunkEventParams { + #[serde(default)] + pub chunk: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct HeapStatsUpdateEvent { + pub params: HeapStatsUpdateEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct HeapStatsUpdateEventParams { + #[serde(default)] + pub stats_update: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct LastSeenObjectIdEvent { + pub params: LastSeenObjectIdEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct LastSeenObjectIdEventParams { + #[serde(default)] + pub last_seen_object_id: JsUInt, + #[serde(default)] + pub timestamp: JsFloat, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct ReportHeapSnapshotProgressEvent { + pub params: ReportHeapSnapshotProgressEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ReportHeapSnapshotProgressEventParams { + #[serde(default)] + pub done: JsUInt, + #[serde(default)] + pub total: JsUInt, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub finished: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ResetProfilesEvent(pub Option); + } + } + pub mod Profiler { + use super::types::*; + use super::Debugger; + use super::Runtime; + use serde::{Deserialize, Serialize}; + use serde_json::Value as Json; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ProfileNode { + #[serde(default)] + pub id: JsUInt, + pub call_frame: Runtime::CallFrame, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub hit_count: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub children: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub deopt_reason: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub position_ticks: Option>, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Profile { + pub nodes: Vec, + #[serde(default)] + pub start_time: JsFloat, + #[serde(default)] + pub end_time: JsFloat, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub samples: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub time_deltas: Option>, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct PositionTickInfo { + #[serde(default)] + pub line: JsUInt, + #[serde(default)] + pub ticks: JsUInt, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CoverageRange { + #[serde(default)] + pub start_offset: JsUInt, + #[serde(default)] + pub end_offset: JsUInt, + #[serde(default)] + pub count: JsUInt, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct FunctionCoverage { + #[serde(default)] + pub function_name: String, + pub ranges: Vec, + #[serde(default)] + pub is_block_coverage: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ScriptCoverage { + pub script_id: Runtime::ScriptId, + #[serde(default)] + pub url: String, + pub functions: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct TypeObject { + #[serde(default)] + pub name: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct TypeProfileEntry { + #[serde(default)] + pub offset: JsUInt, + pub Types: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ScriptTypeProfile { + pub script_id: Runtime::ScriptId, + #[serde(default)] + pub url: String, + pub entries: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Disable(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Enable(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetBestEffortCoverage(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetSamplingInterval { + #[serde(default)] + pub interval: JsUInt, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Start(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StartPreciseCoverage { + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub call_count: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub detailed: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub allow_triggered_updates: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StartTypeProfile(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Stop(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StopPreciseCoverage(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StopTypeProfile(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct TakePreciseCoverage(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct TakeTypeProfile(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DisableReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct EnableReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetBestEffortCoverageReturnObject { + pub result: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetSamplingIntervalReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StartReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StartPreciseCoverageReturnObject { + #[serde(default)] + pub timestamp: JsFloat, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StartTypeProfileReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StopReturnObject { + pub profile: Profile, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StopPreciseCoverageReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StopTypeProfileReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct TakePreciseCoverageReturnObject { + pub result: Vec, + #[serde(default)] + pub timestamp: JsFloat, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct TakeTypeProfileReturnObject { + pub result: Vec, + } + impl Method for Disable { + const NAME: &'static str = "Profiler.disable"; + type ReturnObject = DisableReturnObject; + } + impl Method for Enable { + const NAME: &'static str = "Profiler.enable"; + type ReturnObject = EnableReturnObject; + } + impl Method for GetBestEffortCoverage { + const NAME: &'static str = "Profiler.getBestEffortCoverage"; + type ReturnObject = GetBestEffortCoverageReturnObject; + } + impl Method for SetSamplingInterval { + const NAME: &'static str = "Profiler.setSamplingInterval"; + type ReturnObject = SetSamplingIntervalReturnObject; + } + impl Method for Start { + const NAME: &'static str = "Profiler.start"; + type ReturnObject = StartReturnObject; + } + impl Method for StartPreciseCoverage { + const NAME: &'static str = "Profiler.startPreciseCoverage"; + type ReturnObject = StartPreciseCoverageReturnObject; + } + impl Method for StartTypeProfile { + const NAME: &'static str = "Profiler.startTypeProfile"; + type ReturnObject = StartTypeProfileReturnObject; + } + impl Method for Stop { + const NAME: &'static str = "Profiler.stop"; + type ReturnObject = StopReturnObject; + } + impl Method for StopPreciseCoverage { + const NAME: &'static str = "Profiler.stopPreciseCoverage"; + type ReturnObject = StopPreciseCoverageReturnObject; + } + impl Method for StopTypeProfile { + const NAME: &'static str = "Profiler.stopTypeProfile"; + type ReturnObject = StopTypeProfileReturnObject; + } + impl Method for TakePreciseCoverage { + const NAME: &'static str = "Profiler.takePreciseCoverage"; + type ReturnObject = TakePreciseCoverageReturnObject; + } + impl Method for TakeTypeProfile { + const NAME: &'static str = "Profiler.takeTypeProfile"; + type ReturnObject = TakeTypeProfileReturnObject; + } + pub mod events { + use super::super::types::*; + use serde::{Deserialize, Serialize}; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct ConsoleProfileFinishedEvent { + pub params: ConsoleProfileFinishedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ConsoleProfileFinishedEventParams { + #[serde(default)] + pub id: String, + pub location: super::super::Debugger::Location, + pub profile: super::Profile, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub title: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct ConsoleProfileStartedEvent { + pub params: ConsoleProfileStartedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ConsoleProfileStartedEventParams { + #[serde(default)] + pub id: String, + pub location: super::super::Debugger::Location, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub title: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct PreciseCoverageDeltaUpdateEvent { + pub params: PreciseCoverageDeltaUpdateEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct PreciseCoverageDeltaUpdateEventParams { + #[serde(default)] + pub timestamp: JsFloat, + #[serde(default)] + pub occasion: String, + pub result: Vec, + } + } + } + pub mod Runtime { + use super::types::*; + use serde::{Deserialize, Serialize}; + use serde_json::Value as Json; + pub type ScriptId = String; + pub type RemoteObjectId = String; + pub type UnserializableValue = String; + pub type ExecutionContextId = JsUInt; + pub type Timestamp = JsFloat; + pub type TimeDelta = JsFloat; + pub type UniqueDebuggerId = String; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum RemoteObjectType { + Object, + Function, + Undefined, + String, + Number, + Boolean, + Symbol, + Bigint, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum RemoteObjectSubtype { + Array, + Null, + Node, + Regexp, + Date, + Map, + Set, + Weakmap, + Weakset, + Iterator, + Generator, + Error, + Proxy, + Promise, + Typedarray, + Arraybuffer, + Dataview, + Webassemblymemory, + Wasmvalue, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum ObjectPreviewType { + Object, + Function, + Undefined, + String, + Number, + Boolean, + Symbol, + Bigint, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum ObjectPreviewSubtype { + Array, + Null, + Node, + Regexp, + Date, + Map, + Set, + Weakmap, + Weakset, + Iterator, + Generator, + Error, + Proxy, + Promise, + Typedarray, + Arraybuffer, + Dataview, + Webassemblymemory, + Wasmvalue, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum PropertyPreviewType { + Object, + Function, + Undefined, + String, + Number, + Boolean, + Symbol, + Accessor, + Bigint, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum PropertyPreviewSubtype { + Array, + Null, + Node, + Regexp, + Date, + Map, + Set, + Weakmap, + Weakset, + Iterator, + Generator, + Error, + Proxy, + Promise, + Typedarray, + Arraybuffer, + Dataview, + Webassemblymemory, + Wasmvalue, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum ConsoleAPICalledEventTypeOption { + Log, + Debug, + Info, + Error, + Warning, + Dir, + Dirxml, + Table, + Trace, + Clear, + StartGroup, + StartGroupCollapsed, + EndGroup, + Assert, + Profile, + ProfileEnd, + Count, + TimeEnd, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RemoteObject { + pub Type: RemoteObjectType, + #[serde(skip_serializing_if = "Option::is_none")] + pub subtype: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub class_name: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub value: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub unserializable_value: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub description: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub object_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub preview: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub custom_preview: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CustomPreview { + #[serde(default)] + pub header: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub body_getter_id: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ObjectPreview { + pub Type: ObjectPreviewType, + #[serde(skip_serializing_if = "Option::is_none")] + pub subtype: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub description: Option, + #[serde(default)] + pub overflow: bool, + pub properties: Vec, + #[serde(skip_serializing_if = "Option::is_none")] + pub entries: Option>, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct PropertyPreview { + #[serde(default)] + pub name: String, + pub Type: PropertyPreviewType, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub value: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub value_preview: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub subtype: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct EntryPreview { + #[serde(skip_serializing_if = "Option::is_none")] + pub key: Option, + pub value: ObjectPreview, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct PropertyDescriptor { + #[serde(default)] + pub name: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub value: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub writable: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub get: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub set: Option, + #[serde(default)] + pub configurable: bool, + #[serde(default)] + pub enumerable: bool, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub was_thrown: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub is_own: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub symbol: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct InternalPropertyDescriptor { + #[serde(default)] + pub name: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub value: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct PrivatePropertyDescriptor { + #[serde(default)] + pub name: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub value: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub get: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub set: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CallArgument { + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub value: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub unserializable_value: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub object_id: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ExecutionContextDescription { + pub id: ExecutionContextId, + #[serde(default)] + pub origin: String, + #[serde(default)] + pub name: String, + #[serde(default)] + pub unique_id: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ExceptionDetails { + #[serde(default)] + pub exception_id: JsUInt, + #[serde(default)] + pub text: String, + #[serde(default)] + pub line_number: JsUInt, + #[serde(default)] + pub column_number: JsUInt, + #[serde(skip_serializing_if = "Option::is_none")] + pub script_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub url: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub stack_trace: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub exception: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub execution_context_id: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CallFrame { + #[serde(default)] + pub function_name: String, + pub script_id: ScriptId, + #[serde(default)] + pub url: String, + #[serde(default)] + pub line_number: JsUInt, + #[serde(default)] + pub column_number: JsUInt, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StackTrace { + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub description: Option, + pub call_frames: Vec, + #[serde(skip_serializing_if = "Option::is_none")] + pub parent: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + pub parent_id: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StackTraceId { + #[serde(default)] + pub id: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub debugger_id: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct AwaitPromise { + pub promise_object_id: RemoteObjectId, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub return_by_value: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub generate_preview: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CallFunctionOn { + #[serde(default)] + pub function_declaration: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub object_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub arguments: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub silent: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub return_by_value: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub generate_preview: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub user_gesture: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub await_promise: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub execution_context_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub object_group: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub throw_on_side_effect: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CompileScript { + #[serde(default)] + pub expression: String, + #[serde(default)] + pub source_url: String, + #[serde(default)] + pub persist_script: bool, + #[serde(skip_serializing_if = "Option::is_none")] + pub execution_context_id: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Disable(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DiscardConsoleEntries(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Enable(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Evaluate { + #[serde(default)] + pub expression: String, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub object_group: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub include_command_line_api: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub silent: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub context_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub return_by_value: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub generate_preview: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub user_gesture: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub await_promise: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub throw_on_side_effect: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub timeout: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub disable_breaks: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub repl_mode: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub allow_unsafe_eval_blocked_by_csp: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub unique_context_id: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetIsolateId(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetHeapUsage(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetProperties { + pub object_id: RemoteObjectId, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub own_properties: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub accessor_properties_only: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub generate_preview: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub non_indexed_properties_only: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GlobalLexicalScopeNames { + #[serde(skip_serializing_if = "Option::is_none")] + pub execution_context_id: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct QueryObjects { + pub protoType_object_id: RemoteObjectId, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub object_group: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ReleaseObject { + pub object_id: RemoteObjectId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ReleaseObjectGroup { + #[serde(default)] + pub object_group: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RunIfWaitingForDebugger(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RunScript { + pub script_id: ScriptId, + #[serde(skip_serializing_if = "Option::is_none")] + pub execution_context_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub object_group: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub silent: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub include_command_line_api: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub return_by_value: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub generate_preview: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub await_promise: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetAsyncCallStackDepth { + #[serde(default)] + pub max_depth: JsUInt, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetCustomObjectFormatterEnabled { + #[serde(default)] + pub enabled: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetMaxCallStackSizeToCapture { + #[serde(default)] + pub size: JsUInt, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct TerminateExecution(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct AddBinding { + #[serde(default)] + pub name: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub execution_context_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub execution_context_name: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RemoveBinding { + #[serde(default)] + pub name: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct AwaitPromiseReturnObject { + pub result: RemoteObject, + #[serde(skip_serializing_if = "Option::is_none")] + pub exception_details: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CallFunctionOnReturnObject { + pub result: RemoteObject, + #[serde(skip_serializing_if = "Option::is_none")] + pub exception_details: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CompileScriptReturnObject { + #[serde(skip_serializing_if = "Option::is_none")] + pub script_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub exception_details: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DisableReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DiscardConsoleEntriesReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct EnableReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct EvaluateReturnObject { + pub result: RemoteObject, + #[serde(skip_serializing_if = "Option::is_none")] + pub exception_details: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetIsolateIdReturnObject { + #[serde(default)] + pub id: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetHeapUsageReturnObject { + #[serde(default)] + pub used_size: JsFloat, + #[serde(default)] + pub total_size: JsFloat, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetPropertiesReturnObject { + pub result: Vec, + #[serde(skip_serializing_if = "Option::is_none")] + pub internal_properties: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + pub private_properties: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + pub exception_details: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GlobalLexicalScopeNamesReturnObject { + pub names: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct QueryObjectsReturnObject { + pub objects: RemoteObject, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ReleaseObjectReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ReleaseObjectGroupReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RunIfWaitingForDebuggerReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RunScriptReturnObject { + pub result: RemoteObject, + #[serde(skip_serializing_if = "Option::is_none")] + pub exception_details: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetAsyncCallStackDepthReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetCustomObjectFormatterEnabledReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetMaxCallStackSizeToCaptureReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct TerminateExecutionReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct AddBindingReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RemoveBindingReturnObject {} + impl Method for AwaitPromise { + const NAME: &'static str = "Runtime.awaitPromise"; + type ReturnObject = AwaitPromiseReturnObject; + } + impl Method for CallFunctionOn { + const NAME: &'static str = "Runtime.callFunctionOn"; + type ReturnObject = CallFunctionOnReturnObject; + } + impl Method for CompileScript { + const NAME: &'static str = "Runtime.compileScript"; + type ReturnObject = CompileScriptReturnObject; + } + impl Method for Disable { + const NAME: &'static str = "Runtime.disable"; + type ReturnObject = DisableReturnObject; + } + impl Method for DiscardConsoleEntries { + const NAME: &'static str = "Runtime.discardConsoleEntries"; + type ReturnObject = DiscardConsoleEntriesReturnObject; + } + impl Method for Enable { + const NAME: &'static str = "Runtime.enable"; + type ReturnObject = EnableReturnObject; + } + impl Method for Evaluate { + const NAME: &'static str = "Runtime.evaluate"; + type ReturnObject = EvaluateReturnObject; + } + impl Method for GetIsolateId { + const NAME: &'static str = "Runtime.getIsolateId"; + type ReturnObject = GetIsolateIdReturnObject; + } + impl Method for GetHeapUsage { + const NAME: &'static str = "Runtime.getHeapUsage"; + type ReturnObject = GetHeapUsageReturnObject; + } + impl Method for GetProperties { + const NAME: &'static str = "Runtime.getProperties"; + type ReturnObject = GetPropertiesReturnObject; + } + impl Method for GlobalLexicalScopeNames { + const NAME: &'static str = "Runtime.globalLexicalScopeNames"; + type ReturnObject = GlobalLexicalScopeNamesReturnObject; + } + impl Method for QueryObjects { + const NAME: &'static str = "Runtime.queryObjects"; + type ReturnObject = QueryObjectsReturnObject; + } + impl Method for ReleaseObject { + const NAME: &'static str = "Runtime.releaseObject"; + type ReturnObject = ReleaseObjectReturnObject; + } + impl Method for ReleaseObjectGroup { + const NAME: &'static str = "Runtime.releaseObjectGroup"; + type ReturnObject = ReleaseObjectGroupReturnObject; + } + impl Method for RunIfWaitingForDebugger { + const NAME: &'static str = "Runtime.runIfWaitingForDebugger"; + type ReturnObject = RunIfWaitingForDebuggerReturnObject; + } + impl Method for RunScript { + const NAME: &'static str = "Runtime.runScript"; + type ReturnObject = RunScriptReturnObject; + } + impl Method for SetAsyncCallStackDepth { + const NAME: &'static str = "Runtime.setAsyncCallStackDepth"; + type ReturnObject = SetAsyncCallStackDepthReturnObject; + } + impl Method for SetCustomObjectFormatterEnabled { + const NAME: &'static str = "Runtime.setCustomObjectFormatterEnabled"; + type ReturnObject = SetCustomObjectFormatterEnabledReturnObject; + } + impl Method for SetMaxCallStackSizeToCapture { + const NAME: &'static str = "Runtime.setMaxCallStackSizeToCapture"; + type ReturnObject = SetMaxCallStackSizeToCaptureReturnObject; + } + impl Method for TerminateExecution { + const NAME: &'static str = "Runtime.terminateExecution"; + type ReturnObject = TerminateExecutionReturnObject; + } + impl Method for AddBinding { + const NAME: &'static str = "Runtime.addBinding"; + type ReturnObject = AddBindingReturnObject; + } + impl Method for RemoveBinding { + const NAME: &'static str = "Runtime.removeBinding"; + type ReturnObject = RemoveBindingReturnObject; + } + pub mod events { + use super::super::types::*; + use serde::{Deserialize, Serialize}; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct BindingCalledEvent { + pub params: BindingCalledEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct BindingCalledEventParams { + #[serde(default)] + pub name: String, + #[serde(default)] + pub payload: String, + pub execution_context_id: super::ExecutionContextId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct ConsoleAPICalledEvent { + pub params: ConsoleAPICalledEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ConsoleAPICalledEventParams { + pub Type: super::ConsoleAPICalledEventTypeOption, + pub args: Vec, + pub execution_context_id: super::ExecutionContextId, + pub timestamp: super::Timestamp, + #[serde(skip_serializing_if = "Option::is_none")] + pub stack_trace: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub context: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct ExceptionRevokedEvent { + pub params: ExceptionRevokedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ExceptionRevokedEventParams { + #[serde(default)] + pub reason: String, + #[serde(default)] + pub exception_id: JsUInt, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct ExceptionThrownEvent { + pub params: ExceptionThrownEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ExceptionThrownEventParams { + pub timestamp: super::Timestamp, + pub exception_details: super::ExceptionDetails, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct ExecutionContextCreatedEvent { + pub params: ExecutionContextCreatedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ExecutionContextCreatedEventParams { + pub context: super::ExecutionContextDescription, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct ExecutionContextDestroyedEvent { + pub params: ExecutionContextDestroyedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ExecutionContextDestroyedEventParams { + pub execution_context_id: super::ExecutionContextId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ExecutionContextsClearedEvent(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct InspectRequestedEvent { + pub params: InspectRequestedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct InspectRequestedEventParams { + pub object: super::RemoteObject, + #[serde(skip_serializing_if = "Option::is_none")] + pub execution_context_id: Option, + } + } + } + pub mod Schema { + use super::types::*; + use serde::{Deserialize, Serialize}; + use serde_json::Value as Json; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Domain { + #[serde(default)] + pub name: String, + #[serde(default)] + pub version: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetDomains(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetDomainsReturnObject { + pub domains: Vec, + } + impl Method for GetDomains { + const NAME: &'static str = "Schema.getDomains"; + type ReturnObject = GetDomainsReturnObject; + } + pub mod events { + use super::super::types::*; + use serde::{Deserialize, Serialize}; + } + } + pub mod Accessibility { + use super::types::*; + use super::Page; + use super::Runtime; + use super::DOM; + use serde::{Deserialize, Serialize}; + use serde_json::Value as Json; + pub type AXNodeId = String; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum AXValueType { + Boolean, + Tristate, + BooleanOrUndefined, + Idref, + IdrefList, + Integer, + Node, + NodeList, + Number, + String, + ComputedString, + Token, + TokenList, + DomRelation, + Role, + InternalRole, + ValueUndefined, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum AXValueSourceType { + Attribute, + Implicit, + Style, + Contents, + Placeholder, + RelatedElement, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum AXValueNativeSourceType { + Description, + Figcaption, + Label, + Labelfor, + Labelwrapped, + Legend, + Rubyannotation, + Tablecaption, + Title, + Other, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum AXPropertyName { + Busy, + Disabled, + Editable, + Focusable, + Focused, + Hidden, + HiddenRoot, + Invalid, + Keyshortcuts, + Settable, + Roledescription, + Live, + Atomic, + Relevant, + Root, + Autocomplete, + HasPopup, + Level, + Multiselectable, + Orientation, + Multiline, + Readonly, + Required, + Valuemin, + Valuemax, + Valuetext, + Checked, + Expanded, + Modal, + Pressed, + Selected, + Activedescendant, + Controls, + Describedby, + Details, + Errormessage, + Flowto, + Labelledby, + Owns, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct AXValueSource { + pub Type: AXValueSourceType, + #[serde(skip_serializing_if = "Option::is_none")] + pub value: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub attribute: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub attribute_value: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub superseded: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub native_source: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub native_source_value: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub invalid: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub invalid_reason: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct AXRelatedNode { + pub backend_dom_node_id: DOM::BackendNodeId, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub idref: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub text: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct AXProperty { + pub name: AXPropertyName, + pub value: AXValue, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct AXValue { + pub Type: AXValueType, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub value: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub related_nodes: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + pub sources: Option>, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct AXNode { + pub node_id: AXNodeId, + #[serde(default)] + pub ignored: bool, + #[serde(skip_serializing_if = "Option::is_none")] + pub ignored_reasons: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + pub role: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub name: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub description: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub value: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub properties: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + pub parent_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub child_ids: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + pub backend_dom_node_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub frame_id: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Disable(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Enable(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetPartialAXTree { + #[serde(skip_serializing_if = "Option::is_none")] + pub node_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub backend_node_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub object_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub fetch_relatives: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetFullAXTree { + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub depth: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub max_depth: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub frame_id: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetRootAXNode { + #[serde(skip_serializing_if = "Option::is_none")] + pub frame_id: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetAXNodeAndAncestors { + #[serde(skip_serializing_if = "Option::is_none")] + pub node_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub backend_node_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub object_id: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetChildAXNodes { + pub id: AXNodeId, + #[serde(skip_serializing_if = "Option::is_none")] + pub frame_id: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct QueryAXTree { + #[serde(skip_serializing_if = "Option::is_none")] + pub node_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub backend_node_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub object_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub accessible_name: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub role: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DisableReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct EnableReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetPartialAXTreeReturnObject { + pub nodes: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetFullAXTreeReturnObject { + pub nodes: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetRootAXNodeReturnObject { + pub node: AXNode, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetAXNodeAndAncestorsReturnObject { + pub nodes: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetChildAXNodesReturnObject { + pub nodes: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct QueryAXTreeReturnObject { + pub nodes: Vec, + } + impl Method for Disable { + const NAME: &'static str = "Accessibility.disable"; + type ReturnObject = DisableReturnObject; + } + impl Method for Enable { + const NAME: &'static str = "Accessibility.enable"; + type ReturnObject = EnableReturnObject; + } + impl Method for GetPartialAXTree { + const NAME: &'static str = "Accessibility.getPartialAXTree"; + type ReturnObject = GetPartialAXTreeReturnObject; + } + impl Method for GetFullAXTree { + const NAME: &'static str = "Accessibility.getFullAXTree"; + type ReturnObject = GetFullAXTreeReturnObject; + } + impl Method for GetRootAXNode { + const NAME: &'static str = "Accessibility.getRootAXNode"; + type ReturnObject = GetRootAXNodeReturnObject; + } + impl Method for GetAXNodeAndAncestors { + const NAME: &'static str = "Accessibility.getAXNodeAndAncestors"; + type ReturnObject = GetAXNodeAndAncestorsReturnObject; + } + impl Method for GetChildAXNodes { + const NAME: &'static str = "Accessibility.getChildAXNodes"; + type ReturnObject = GetChildAXNodesReturnObject; + } + impl Method for QueryAXTree { + const NAME: &'static str = "Accessibility.queryAXTree"; + type ReturnObject = QueryAXTreeReturnObject; + } + pub mod events { + use super::super::types::*; + use serde::{Deserialize, Serialize}; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct LoadCompleteEvent { + pub params: LoadCompleteEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct LoadCompleteEventParams { + pub root: super::AXNode, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct NodesUpdatedEvent { + pub params: NodesUpdatedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct NodesUpdatedEventParams { + pub nodes: Vec, + } + } + } + pub mod Animation { + use super::types::*; + use super::Runtime; + use super::DOM; + use serde::{Deserialize, Serialize}; + use serde_json::Value as Json; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "PascalCase")] + pub enum AnimationType { + CssTransition, + CssAnimation, + WebAnimation, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Animation { + #[serde(default)] + pub id: String, + #[serde(default)] + pub name: String, + #[serde(default)] + pub paused_state: bool, + #[serde(default)] + pub play_state: String, + #[serde(default)] + pub playback_rate: JsFloat, + #[serde(default)] + pub start_time: JsFloat, + #[serde(default)] + pub current_time: JsFloat, + pub Type: AnimationType, + #[serde(skip_serializing_if = "Option::is_none")] + pub source: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub css_id: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct AnimationEffect { + #[serde(default)] + pub delay: JsFloat, + #[serde(default)] + pub end_delay: JsFloat, + #[serde(default)] + pub iteration_start: JsFloat, + #[serde(default)] + pub iterations: JsFloat, + #[serde(default)] + pub duration: JsFloat, + #[serde(default)] + pub direction: String, + #[serde(default)] + pub fill: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub backend_node_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub keyframes_rule: Option, + #[serde(default)] + pub easing: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct KeyframesRule { + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub name: Option, + pub keyframes: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct KeyframeStyle { + #[serde(default)] + pub offset: String, + #[serde(default)] + pub easing: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Disable(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Enable(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetCurrentTime { + #[serde(default)] + pub id: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetPlaybackRate(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ReleaseAnimations { + #[serde(default)] + pub animations: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ResolveAnimation { + #[serde(default)] + pub animation_id: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SeekAnimations { + #[serde(default)] + pub animations: Vec, + #[serde(default)] + pub current_time: JsFloat, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetPaused { + #[serde(default)] + pub animations: Vec, + #[serde(default)] + pub paused: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetPlaybackRate { + #[serde(default)] + pub playback_rate: JsFloat, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetTiming { + #[serde(default)] + pub animation_id: String, + #[serde(default)] + pub duration: JsFloat, + #[serde(default)] + pub delay: JsFloat, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DisableReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct EnableReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetCurrentTimeReturnObject { + #[serde(default)] + pub current_time: JsFloat, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetPlaybackRateReturnObject { + #[serde(default)] + pub playback_rate: JsFloat, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ReleaseAnimationsReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ResolveAnimationReturnObject { + pub remote_object: Runtime::RemoteObject, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SeekAnimationsReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetPausedReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetPlaybackRateReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetTimingReturnObject {} + impl Method for Disable { + const NAME: &'static str = "Animation.disable"; + type ReturnObject = DisableReturnObject; + } + impl Method for Enable { + const NAME: &'static str = "Animation.enable"; + type ReturnObject = EnableReturnObject; + } + impl Method for GetCurrentTime { + const NAME: &'static str = "Animation.getCurrentTime"; + type ReturnObject = GetCurrentTimeReturnObject; + } + impl Method for GetPlaybackRate { + const NAME: &'static str = "Animation.getPlaybackRate"; + type ReturnObject = GetPlaybackRateReturnObject; + } + impl Method for ReleaseAnimations { + const NAME: &'static str = "Animation.releaseAnimations"; + type ReturnObject = ReleaseAnimationsReturnObject; + } + impl Method for ResolveAnimation { + const NAME: &'static str = "Animation.resolveAnimation"; + type ReturnObject = ResolveAnimationReturnObject; + } + impl Method for SeekAnimations { + const NAME: &'static str = "Animation.seekAnimations"; + type ReturnObject = SeekAnimationsReturnObject; + } + impl Method for SetPaused { + const NAME: &'static str = "Animation.setPaused"; + type ReturnObject = SetPausedReturnObject; + } + impl Method for SetPlaybackRate { + const NAME: &'static str = "Animation.setPlaybackRate"; + type ReturnObject = SetPlaybackRateReturnObject; + } + impl Method for SetTiming { + const NAME: &'static str = "Animation.setTiming"; + type ReturnObject = SetTimingReturnObject; + } + pub mod events { + use super::super::types::*; + use serde::{Deserialize, Serialize}; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct AnimationCanceledEvent { + pub params: AnimationCanceledEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct AnimationCanceledEventParams { + #[serde(default)] + pub id: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct AnimationCreatedEvent { + pub params: AnimationCreatedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct AnimationCreatedEventParams { + #[serde(default)] + pub id: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct AnimationStartedEvent { + pub params: AnimationStartedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct AnimationStartedEventParams { + pub animation: super::Animation, + } + } + } + pub mod Audits { + use super::types::*; + use super::Network; + use super::Page; + use super::Runtime; + use super::DOM; + use serde::{Deserialize, Serialize}; + use serde_json::Value as Json; + pub type IssueId = String; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "PascalCase")] + pub enum SameSiteCookieExclusionReason { + ExcludeSameSiteUnspecifiedTreatedAsLax, + ExcludeSameSiteNoneInsecure, + ExcludeSameSiteLax, + ExcludeSameSiteStrict, + ExcludeInvalidSameParty, + ExcludeSamePartyCrossPartyContext, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "PascalCase")] + pub enum SameSiteCookieWarningReason { + WarnSameSiteUnspecifiedCrossSiteContext, + WarnSameSiteNoneInsecure, + WarnSameSiteUnspecifiedLaxAllowUnsafe, + WarnSameSiteStrictLaxDowngradeStrict, + WarnSameSiteStrictCrossDowngradeStrict, + WarnSameSiteStrictCrossDowngradeLax, + WarnSameSiteLaxCrossDowngradeStrict, + WarnSameSiteLaxCrossDowngradeLax, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "PascalCase")] + pub enum SameSiteCookieOperation { + SetCookie, + ReadCookie, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "PascalCase")] + pub enum MixedContentResolutionStatus { + MixedContentBlocked, + MixedContentAutomaticallyUpgraded, + MixedContentWarning, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "PascalCase")] + pub enum MixedContentResourceType { + Audio, + Beacon, + CspReport, + Download, + EventSource, + Favicon, + Font, + Form, + Frame, + Image, + Import, + Manifest, + Ping, + PluginData, + PluginResource, + Prefetch, + Resource, + Script, + ServiceWorker, + SharedWorker, + Stylesheet, + Track, + Video, + Worker, + XmlHttpRequest, + Xslt, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "PascalCase")] + pub enum BlockedByResponseReason { + CoepFrameResourceNeedsCoepHeader, + CoopSandboxedIFrameCannotNavigateToCoopPage, + CorpNotSameOrigin, + CorpNotSameOriginAfterDefaultedToSameOriginByCoep, + CorpNotSameSite, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "PascalCase")] + pub enum HeavyAdResolutionStatus { + HeavyAdBlocked, + HeavyAdWarning, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "PascalCase")] + pub enum HeavyAdReason { + NetworkTotalLimit, + CpuTotalLimit, + CpuPeakLimit, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum ContentSecurityPolicyViolationType { + KInlineViolation, + KEvalViolation, + KUrlViolation, + KTrustedTypesSinkViolation, + KTrustedTypesPolicyViolation, + KWasmEvalViolation, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "PascalCase")] + pub enum SharedArrayBufferIssueType { + TransferIssue, + CreationIssue, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum TwaQualityEnforcementViolationType { + KHttpError, + KUnavailableOffline, + KDigitalAssetLinks, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "PascalCase")] + pub enum AttributionReportingIssueType { + PermissionPolicyDisabled, + InvalidAttributionSourceEventId, + InvalidAttributionData, + AttributionSourceUntrustworthyOrigin, + AttributionUntrustworthyOrigin, + AttributionTriggerDataTooLarge, + AttributionEventSourceTriggerDataTooLarge, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "PascalCase")] + pub enum GenericIssueErrorType { + CrossOriginPortalPostMessageError, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "PascalCase")] + pub enum InspectorIssueCode { + SameSiteCookieIssue, + MixedContentIssue, + BlockedByResponseIssue, + HeavyAdIssue, + ContentSecurityPolicyIssue, + SharedArrayBufferIssue, + TrustedWebActivityIssue, + LowTextContrastIssue, + CorsIssue, + AttributionReportingIssue, + QuirksModeIssue, + NavigatorUserAgentIssue, + WasmCrossOriginModuleSharingIssue, + GenericIssue, + DeprecationIssue, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum GetEncodedResponseEncodingOption { + Webp, + Jpeg, + Png, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct AffectedCookie { + #[serde(default)] + pub name: String, + #[serde(default)] + pub path: String, + #[serde(default)] + pub domain: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct AffectedRequest { + pub request_id: Network::RequestId, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub url: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct AffectedFrame { + pub frame_id: Page::FrameId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SameSiteCookieIssueDetails { + #[serde(skip_serializing_if = "Option::is_none")] + pub cookie: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub raw_cookie_line: Option, + pub cookie_warning_reasons: Vec, + pub cookie_exclusion_reasons: Vec, + pub operation: SameSiteCookieOperation, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub site_for_cookies: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub cookie_url: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub request: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct MixedContentIssueDetails { + #[serde(skip_serializing_if = "Option::is_none")] + pub resource_Type: Option, + pub resolution_status: MixedContentResolutionStatus, + #[serde(default)] + pub insecure_url: String, + #[serde(default)] + pub main_resource_url: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub request: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub frame: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct BlockedByResponseIssueDetails { + pub request: AffectedRequest, + #[serde(skip_serializing_if = "Option::is_none")] + pub parent_frame: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub blocked_frame: Option, + pub reason: BlockedByResponseReason, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct HeavyAdIssueDetails { + pub resolution: HeavyAdResolutionStatus, + pub reason: HeavyAdReason, + pub frame: AffectedFrame, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SourceCodeLocation { + #[serde(skip_serializing_if = "Option::is_none")] + pub script_id: Option, + #[serde(default)] + pub url: String, + #[serde(default)] + pub line_number: JsUInt, + #[serde(default)] + pub column_number: JsUInt, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ContentSecurityPolicyIssueDetails { + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub blocked_url: Option, + #[serde(default)] + pub violated_directive: String, + #[serde(default)] + pub is_report_only: bool, + pub content_security_policy_violation_Type: ContentSecurityPolicyViolationType, + #[serde(skip_serializing_if = "Option::is_none")] + pub frame_ancestor: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub source_code_location: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub violating_node_id: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SharedArrayBufferIssueDetails { + pub source_code_location: SourceCodeLocation, + #[serde(default)] + pub is_warning: bool, + pub Type: SharedArrayBufferIssueType, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct TrustedWebActivityIssueDetails { + #[serde(default)] + pub url: String, + pub violation_Type: TwaQualityEnforcementViolationType, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub http_status_code: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub package_name: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub signature: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct LowTextContrastIssueDetails { + pub violating_node_id: DOM::BackendNodeId, + #[serde(default)] + pub violating_node_selector: String, + #[serde(default)] + pub contrast_ratio: JsFloat, + #[serde(default)] + pub threshold_aa: JsFloat, + #[serde(default)] + pub threshold_aaa: JsFloat, + #[serde(default)] + pub font_size: String, + #[serde(default)] + pub font_weight: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CorsIssueDetails { + pub cors_error_status: Network::CorsErrorStatus, + #[serde(default)] + pub is_warning: bool, + pub request: AffectedRequest, + #[serde(skip_serializing_if = "Option::is_none")] + pub location: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub initiator_origin: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub resource_ip_address_space: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub client_security_state: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct AttributionReportingIssueDetails { + pub violation_Type: AttributionReportingIssueType, + #[serde(skip_serializing_if = "Option::is_none")] + pub frame: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub request: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub violating_node_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub invalid_parameter: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct QuirksModeIssueDetails { + #[serde(default)] + pub is_limited_quirks_mode: bool, + pub document_node_id: DOM::BackendNodeId, + #[serde(default)] + pub url: String, + pub frame_id: Page::FrameId, + pub loader_id: Network::LoaderId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct NavigatorUserAgentIssueDetails { + #[serde(default)] + pub url: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub location: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct WasmCrossOriginModuleSharingIssueDetails { + #[serde(default)] + pub wasm_module_url: String, + #[serde(default)] + pub source_origin: String, + #[serde(default)] + pub target_origin: String, + #[serde(default)] + pub is_warning: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GenericIssueDetails { + pub error_Type: GenericIssueErrorType, + #[serde(skip_serializing_if = "Option::is_none")] + pub frame_id: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DeprecationIssueDetails { + #[serde(skip_serializing_if = "Option::is_none")] + pub affected_frame: Option, + pub source_code_location: SourceCodeLocation, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub message: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct InspectorIssueDetails { + #[serde(skip_serializing_if = "Option::is_none")] + pub same_site_cookie_issue_details: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub mixed_content_issue_details: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub blocked_by_response_issue_details: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub heavy_ad_issue_details: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub content_security_policy_issue_details: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub shared_array_buffer_issue_details: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub twa_quality_enforcement_details: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub low_text_contrast_issue_details: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub cors_issue_details: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub attribution_reporting_issue_details: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub quirks_mode_issue_details: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub navigator_user_agent_issue_details: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub wasm_cross_origin_module_sharing_issue: + Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub generic_issue_details: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub deprecation_issue_details: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct InspectorIssue { + pub code: InspectorIssueCode, + pub details: InspectorIssueDetails, + #[serde(skip_serializing_if = "Option::is_none")] + pub issue_id: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetEncodedResponse { + pub request_id: Network::RequestId, + pub encoding: GetEncodedResponseEncodingOption, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub quality: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub size_only: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Disable(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Enable(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CheckContrast { + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub report_aaa: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetEncodedResponseReturnObject { + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub body: Option, + #[serde(default)] + pub original_size: JsUInt, + #[serde(default)] + pub encoded_size: JsUInt, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DisableReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct EnableReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CheckContrastReturnObject {} + impl Method for GetEncodedResponse { + const NAME: &'static str = "Audits.getEncodedResponse"; + type ReturnObject = GetEncodedResponseReturnObject; + } + impl Method for Disable { + const NAME: &'static str = "Audits.disable"; + type ReturnObject = DisableReturnObject; + } + impl Method for Enable { + const NAME: &'static str = "Audits.enable"; + type ReturnObject = EnableReturnObject; + } + impl Method for CheckContrast { + const NAME: &'static str = "Audits.checkContrast"; + type ReturnObject = CheckContrastReturnObject; + } + pub mod events { + use super::super::types::*; + use serde::{Deserialize, Serialize}; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct IssueAddedEvent { + pub params: IssueAddedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct IssueAddedEventParams { + pub issue: super::InspectorIssue, + } + } + } + pub mod BackgroundService { + use super::types::*; + use super::Network; + use super::ServiceWorker; + use serde::{Deserialize, Serialize}; + use serde_json::Value as Json; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum ServiceName { + BackgroundFetch, + BackgroundSync, + PushMessaging, + Notifications, + PaymentHandler, + PeriodicBackgroundSync, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct EventMetadata { + #[serde(default)] + pub key: String, + #[serde(default)] + pub value: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct BackgroundServiceEvent { + pub timestamp: Network::TimeSinceEpoch, + #[serde(default)] + pub origin: String, + pub service_worker_registration_id: ServiceWorker::RegistrationID, + pub service: ServiceName, + #[serde(default)] + pub event_name: String, + #[serde(default)] + pub instance_id: String, + pub event_metadata: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StartObserving { + pub service: ServiceName, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StopObserving { + pub service: ServiceName, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetRecording { + #[serde(default)] + pub should_record: bool, + pub service: ServiceName, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ClearEvents { + pub service: ServiceName, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StartObservingReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StopObservingReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetRecordingReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ClearEventsReturnObject {} + impl Method for StartObserving { + const NAME: &'static str = "BackgroundService.startObserving"; + type ReturnObject = StartObservingReturnObject; + } + impl Method for StopObserving { + const NAME: &'static str = "BackgroundService.stopObserving"; + type ReturnObject = StopObservingReturnObject; + } + impl Method for SetRecording { + const NAME: &'static str = "BackgroundService.setRecording"; + type ReturnObject = SetRecordingReturnObject; + } + impl Method for ClearEvents { + const NAME: &'static str = "BackgroundService.clearEvents"; + type ReturnObject = ClearEventsReturnObject; + } + pub mod events { + use super::super::types::*; + use serde::{Deserialize, Serialize}; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct RecordingStateChangedEvent { + pub params: RecordingStateChangedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RecordingStateChangedEventParams { + #[serde(default)] + pub is_recording: bool, + pub service: super::ServiceName, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct BackgroundServiceEventReceivedEvent { + pub params: BackgroundServiceEventReceivedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct BackgroundServiceEventReceivedEventParams { + pub background_service_event: super::BackgroundServiceEvent, + } + } + } + pub mod Browser { + use super::types::*; + use super::Target; + use serde::{Deserialize, Serialize}; + use serde_json::Value as Json; + pub type BrowserContextID = String; + pub type WindowID = JsUInt; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum WindowState { + Normal, + Minimized, + Maximized, + Fullscreen, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum PermissionType { + AccessibilityEvents, + AudioCapture, + BackgroundSync, + BackgroundFetch, + ClipboardReadWrite, + ClipboardSanitizedWrite, + DisplayCapture, + DurableStorage, + Flash, + Geolocation, + Midi, + MidiSysex, + Nfc, + Notifications, + PaymentHandler, + PeriodicBackgroundSync, + ProtectedMediaIdentifier, + Sensors, + VideoCapture, + VideoCapturePanTiltZoom, + IdleDetection, + WakeLockScreen, + WakeLockSystem, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum PermissionSetting { + Granted, + Denied, + Prompt, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum BrowserCommandId { + OpenTabSearch, + CloseTabSearch, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum SetDownloadBehaviorBehaviorOption { + Deny, + Allow, + AllowAndName, + Default, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum DownloadProgressEventStateOption { + InProgress, + Completed, + Canceled, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Bounds { + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub left: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub top: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub width: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub height: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub window_state: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct PermissionDescriptor { + #[serde(default)] + pub name: String, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub sysex: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub user_visible_only: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub allow_without_sanitization: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub pan_tilt_zoom: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Bucket { + #[serde(default)] + pub low: JsUInt, + #[serde(default)] + pub high: JsUInt, + #[serde(default)] + pub count: JsUInt, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Histogram { + #[serde(default)] + pub name: String, + #[serde(default)] + pub sum: JsUInt, + #[serde(default)] + pub count: JsUInt, + pub buckets: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetPermission { + pub permission: PermissionDescriptor, + pub setting: PermissionSetting, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub origin: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub browser_context_id: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GrantPermissions { + pub permissions: Vec, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub origin: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub browser_context_id: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ResetPermissions { + #[serde(skip_serializing_if = "Option::is_none")] + pub browser_context_id: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetDownloadBehavior { + pub behavior: SetDownloadBehaviorBehaviorOption, + #[serde(skip_serializing_if = "Option::is_none")] + pub browser_context_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub download_path: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub events_enabled: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CancelDownload { + #[serde(default)] + pub guid: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub browser_context_id: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Close(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Crash(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CrashGpuProcess(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetVersion(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetBrowserCommandLine(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetHistograms { + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub query: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub delta: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetHistogram { + #[serde(default)] + pub name: String, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub delta: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetWindowBounds { + pub window_id: WindowID, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetWindowForTarget { + #[serde(skip_serializing_if = "Option::is_none")] + pub target_id: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetWindowBounds { + pub window_id: WindowID, + pub bounds: Bounds, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetDockTile { + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub badge_label: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub image: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ExecuteBrowserCommand { + pub command_id: BrowserCommandId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetPermissionReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GrantPermissionsReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ResetPermissionsReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetDownloadBehaviorReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CancelDownloadReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CloseReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CrashReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CrashGpuProcessReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetVersionReturnObject { + #[serde(default)] + pub protocol_version: String, + #[serde(default)] + pub product: String, + #[serde(default)] + pub revision: String, + #[serde(default)] + pub user_agent: String, + #[serde(default)] + pub js_version: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetBrowserCommandLineReturnObject { + pub arguments: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetHistogramsReturnObject { + pub histograms: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetHistogramReturnObject { + pub histogram: Histogram, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetWindowBoundsReturnObject { + pub bounds: Bounds, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetWindowForTargetReturnObject { + pub window_id: WindowID, + pub bounds: Bounds, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetWindowBoundsReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetDockTileReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ExecuteBrowserCommandReturnObject {} + impl Method for SetPermission { + const NAME: &'static str = "Browser.setPermission"; + type ReturnObject = SetPermissionReturnObject; + } + impl Method for GrantPermissions { + const NAME: &'static str = "Browser.grantPermissions"; + type ReturnObject = GrantPermissionsReturnObject; + } + impl Method for ResetPermissions { + const NAME: &'static str = "Browser.resetPermissions"; + type ReturnObject = ResetPermissionsReturnObject; + } + impl Method for SetDownloadBehavior { + const NAME: &'static str = "Browser.setDownloadBehavior"; + type ReturnObject = SetDownloadBehaviorReturnObject; + } + impl Method for CancelDownload { + const NAME: &'static str = "Browser.cancelDownload"; + type ReturnObject = CancelDownloadReturnObject; + } + impl Method for Close { + const NAME: &'static str = "Browser.close"; + type ReturnObject = CloseReturnObject; + } + impl Method for Crash { + const NAME: &'static str = "Browser.crash"; + type ReturnObject = CrashReturnObject; + } + impl Method for CrashGpuProcess { + const NAME: &'static str = "Browser.crashGpuProcess"; + type ReturnObject = CrashGpuProcessReturnObject; + } + impl Method for GetVersion { + const NAME: &'static str = "Browser.getVersion"; + type ReturnObject = GetVersionReturnObject; + } + impl Method for GetBrowserCommandLine { + const NAME: &'static str = "Browser.getBrowserCommandLine"; + type ReturnObject = GetBrowserCommandLineReturnObject; + } + impl Method for GetHistograms { + const NAME: &'static str = "Browser.getHistograms"; + type ReturnObject = GetHistogramsReturnObject; + } + impl Method for GetHistogram { + const NAME: &'static str = "Browser.getHistogram"; + type ReturnObject = GetHistogramReturnObject; + } + impl Method for GetWindowBounds { + const NAME: &'static str = "Browser.getWindowBounds"; + type ReturnObject = GetWindowBoundsReturnObject; + } + impl Method for GetWindowForTarget { + const NAME: &'static str = "Browser.getWindowForTarget"; + type ReturnObject = GetWindowForTargetReturnObject; + } + impl Method for SetWindowBounds { + const NAME: &'static str = "Browser.setWindowBounds"; + type ReturnObject = SetWindowBoundsReturnObject; + } + impl Method for SetDockTile { + const NAME: &'static str = "Browser.setDockTile"; + type ReturnObject = SetDockTileReturnObject; + } + impl Method for ExecuteBrowserCommand { + const NAME: &'static str = "Browser.executeBrowserCommand"; + type ReturnObject = ExecuteBrowserCommandReturnObject; + } + pub mod events { + use super::super::types::*; + use serde::{Deserialize, Serialize}; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct DownloadWillBeginEvent { + pub params: DownloadWillBeginEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DownloadWillBeginEventParams { + pub frame_id: super::super::Page::FrameId, + #[serde(default)] + pub guid: String, + #[serde(default)] + pub url: String, + #[serde(default)] + pub suggested_filename: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct DownloadProgressEvent { + pub params: DownloadProgressEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DownloadProgressEventParams { + #[serde(default)] + pub guid: String, + #[serde(default)] + pub total_bytes: JsFloat, + #[serde(default)] + pub received_bytes: JsFloat, + pub state: super::DownloadProgressEventStateOption, + } + } + } + pub mod CSS { + use super::types::*; + use super::Page; + use super::DOM; + use serde::{Deserialize, Serialize}; + use serde_json::Value as Json; + pub type StyleSheetId = String; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "kebab-case")] + pub enum StyleSheetOrigin { + Injected, + UserAgent, + Inspector, + Regular, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum CssMediaSource { + MediaRule, + ImportRule, + LinkedSheet, + InlineSheet, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct PseudoElementMatches { + pub pseudo_Type: DOM::PseudoType, + pub matches: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct InheritedStyleEntry { + #[serde(skip_serializing_if = "Option::is_none")] + pub inline_style: Option, + pub matched_css_rules: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RuleMatch { + pub rule: CSSRule, + #[serde(default)] + pub matching_selectors: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Value { + #[serde(default)] + pub text: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub range: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SelectorList { + pub selectors: Vec, + #[serde(default)] + pub text: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CSSStyleSheetHeader { + pub style_sheet_id: StyleSheetId, + pub frame_id: Page::FrameId, + #[serde(default)] + pub source_url: String, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub source_map_url: Option, + pub origin: StyleSheetOrigin, + #[serde(default)] + pub title: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub owner_node: Option, + #[serde(default)] + pub disabled: bool, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub has_source_url: Option, + #[serde(default)] + pub is_inline: bool, + #[serde(default)] + pub is_mutable: bool, + #[serde(default)] + pub is_constructed: bool, + #[serde(default)] + pub start_line: JsFloat, + #[serde(default)] + pub start_column: JsFloat, + #[serde(default)] + pub length: JsFloat, + #[serde(default)] + pub end_line: JsFloat, + #[serde(default)] + pub end_column: JsFloat, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CSSRule { + #[serde(skip_serializing_if = "Option::is_none")] + pub style_sheet_id: Option, + pub selector_list: SelectorList, + pub origin: StyleSheetOrigin, + pub style: CSSStyle, + #[serde(skip_serializing_if = "Option::is_none")] + pub media: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + pub container_queries: Option>, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RuleUsage { + pub style_sheet_id: StyleSheetId, + #[serde(default)] + pub start_offset: JsFloat, + #[serde(default)] + pub end_offset: JsFloat, + #[serde(default)] + pub used: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SourceRange { + #[serde(default)] + pub start_line: JsUInt, + #[serde(default)] + pub start_column: JsUInt, + #[serde(default)] + pub end_line: JsUInt, + #[serde(default)] + pub end_column: JsUInt, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ShorthandEntry { + #[serde(default)] + pub name: String, + #[serde(default)] + pub value: String, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub important: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CSSComputedStyleProperty { + #[serde(default)] + pub name: String, + #[serde(default)] + pub value: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CSSStyle { + #[serde(skip_serializing_if = "Option::is_none")] + pub style_sheet_id: Option, + pub css_properties: Vec, + pub shorthand_entries: Vec, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub css_text: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub range: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CSSProperty { + #[serde(default)] + pub name: String, + #[serde(default)] + pub value: String, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub important: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub implicit: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub text: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub parsed_ok: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub disabled: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub range: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CSSMedia { + #[serde(default)] + pub text: String, + pub source: CssMediaSource, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub source_url: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub range: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub style_sheet_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub media_list: Option>, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct MediaQuery { + pub expressions: Vec, + #[serde(default)] + pub active: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct MediaQueryExpression { + #[serde(default)] + pub value: JsFloat, + #[serde(default)] + pub unit: String, + #[serde(default)] + pub feature: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub value_range: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub computed_length: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CSSContainerQuery { + #[serde(default)] + pub text: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub range: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub style_sheet_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub name: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct PlatformFontUsage { + #[serde(default)] + pub family_name: String, + #[serde(default)] + pub is_custom_font: bool, + #[serde(default)] + pub glyph_count: JsFloat, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct FontVariationAxis { + #[serde(default)] + pub tag: String, + #[serde(default)] + pub name: String, + #[serde(default)] + pub min_value: JsFloat, + #[serde(default)] + pub max_value: JsFloat, + #[serde(default)] + pub default_value: JsFloat, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct FontFace { + #[serde(default)] + pub font_family: String, + #[serde(default)] + pub font_style: String, + #[serde(default)] + pub font_variant: String, + #[serde(default)] + pub font_weight: String, + #[serde(default)] + pub font_stretch: String, + #[serde(default)] + pub unicode_range: String, + #[serde(default)] + pub src: String, + #[serde(default)] + pub platform_font_family: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub font_variation_axes: Option>, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CSSKeyframesRule { + pub animation_name: Value, + pub keyframes: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CSSKeyframeRule { + #[serde(skip_serializing_if = "Option::is_none")] + pub style_sheet_id: Option, + pub origin: StyleSheetOrigin, + pub key_text: Value, + pub style: CSSStyle, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StyleDeclarationEdit { + pub style_sheet_id: StyleSheetId, + pub range: SourceRange, + #[serde(default)] + pub text: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct AddRule { + pub style_sheet_id: StyleSheetId, + #[serde(default)] + pub rule_text: String, + pub location: SourceRange, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CollectClassNames { + pub style_sheet_id: StyleSheetId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CreateStyleSheet { + pub frame_id: Page::FrameId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Disable(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Enable(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ForcePseudoState { + pub node_id: DOM::NodeId, + #[serde(default)] + pub forced_pseudo_classes: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetBackgroundColors { + pub node_id: DOM::NodeId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetComputedStyleForNode { + pub node_id: DOM::NodeId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetInlineStylesForNode { + pub node_id: DOM::NodeId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetMatchedStylesForNode { + pub node_id: DOM::NodeId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetMediaQueries(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetPlatformFontsForNode { + pub node_id: DOM::NodeId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetStyleSheetText { + pub style_sheet_id: StyleSheetId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct TrackComputedStyleUpdates { + pub properties_to_track: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct TakeComputedStyleUpdates(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetEffectivePropertyValueForNode { + pub node_id: DOM::NodeId, + #[serde(default)] + pub property_name: String, + #[serde(default)] + pub value: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetKeyframeKey { + pub style_sheet_id: StyleSheetId, + pub range: SourceRange, + #[serde(default)] + pub key_text: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetMediaText { + pub style_sheet_id: StyleSheetId, + pub range: SourceRange, + #[serde(default)] + pub text: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetContainerQueryText { + pub style_sheet_id: StyleSheetId, + pub range: SourceRange, + #[serde(default)] + pub text: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetRuleSelector { + pub style_sheet_id: StyleSheetId, + pub range: SourceRange, + #[serde(default)] + pub selector: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetStyleSheetText { + pub style_sheet_id: StyleSheetId, + #[serde(default)] + pub text: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetStyleTexts { + pub edits: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StartRuleUsageTracking(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StopRuleUsageTracking(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct TakeCoverageDelta(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetLocalFontsEnabled { + #[serde(default)] + pub enabled: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct AddRuleReturnObject { + pub rule: CSSRule, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CollectClassNamesReturnObject { + pub class_names: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CreateStyleSheetReturnObject { + pub style_sheet_id: StyleSheetId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DisableReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct EnableReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ForcePseudoStateReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetBackgroundColorsReturnObject { + #[serde(skip_serializing_if = "Option::is_none")] + pub background_colors: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub computed_font_size: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub computed_font_weight: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetComputedStyleForNodeReturnObject { + pub computed_style: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetInlineStylesForNodeReturnObject { + #[serde(skip_serializing_if = "Option::is_none")] + pub inline_style: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub attributes_style: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetMatchedStylesForNodeReturnObject { + #[serde(skip_serializing_if = "Option::is_none")] + pub inline_style: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub attributes_style: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub matched_css_rules: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + pub pseudo_elements: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + pub inherited: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + pub css_keyframes_rules: Option>, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetMediaQueriesReturnObject { + pub medias: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetPlatformFontsForNodeReturnObject { + pub fonts: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetStyleSheetTextReturnObject { + #[serde(default)] + pub text: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct TrackComputedStyleUpdatesReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct TakeComputedStyleUpdatesReturnObject { + pub node_ids: DOM::NodeId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetEffectivePropertyValueForNodeReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetKeyframeKeyReturnObject { + pub key_text: Value, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetMediaTextReturnObject { + pub media: CSSMedia, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetContainerQueryTextReturnObject { + pub container_query: CSSContainerQuery, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetRuleSelectorReturnObject { + pub selector_list: SelectorList, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetStyleSheetTextReturnObject { + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub source_map_url: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetStyleTextsReturnObject { + pub styles: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StartRuleUsageTrackingReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StopRuleUsageTrackingReturnObject { + pub rule_usage: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct TakeCoverageDeltaReturnObject { + pub coverage: Vec, + #[serde(default)] + pub timestamp: JsFloat, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetLocalFontsEnabledReturnObject {} + impl Method for AddRule { + const NAME: &'static str = "CSS.addRule"; + type ReturnObject = AddRuleReturnObject; + } + impl Method for CollectClassNames { + const NAME: &'static str = "CSS.collectClassNames"; + type ReturnObject = CollectClassNamesReturnObject; + } + impl Method for CreateStyleSheet { + const NAME: &'static str = "CSS.createStyleSheet"; + type ReturnObject = CreateStyleSheetReturnObject; + } + impl Method for Disable { + const NAME: &'static str = "CSS.disable"; + type ReturnObject = DisableReturnObject; + } + impl Method for Enable { + const NAME: &'static str = "CSS.enable"; + type ReturnObject = EnableReturnObject; + } + impl Method for ForcePseudoState { + const NAME: &'static str = "CSS.forcePseudoState"; + type ReturnObject = ForcePseudoStateReturnObject; + } + impl Method for GetBackgroundColors { + const NAME: &'static str = "CSS.getBackgroundColors"; + type ReturnObject = GetBackgroundColorsReturnObject; + } + impl Method for GetComputedStyleForNode { + const NAME: &'static str = "CSS.getComputedStyleForNode"; + type ReturnObject = GetComputedStyleForNodeReturnObject; + } + impl Method for GetInlineStylesForNode { + const NAME: &'static str = "CSS.getInlineStylesForNode"; + type ReturnObject = GetInlineStylesForNodeReturnObject; + } + impl Method for GetMatchedStylesForNode { + const NAME: &'static str = "CSS.getMatchedStylesForNode"; + type ReturnObject = GetMatchedStylesForNodeReturnObject; + } + impl Method for GetMediaQueries { + const NAME: &'static str = "CSS.getMediaQueries"; + type ReturnObject = GetMediaQueriesReturnObject; + } + impl Method for GetPlatformFontsForNode { + const NAME: &'static str = "CSS.getPlatformFontsForNode"; + type ReturnObject = GetPlatformFontsForNodeReturnObject; + } + impl Method for GetStyleSheetText { + const NAME: &'static str = "CSS.getStyleSheetText"; + type ReturnObject = GetStyleSheetTextReturnObject; + } + impl Method for TrackComputedStyleUpdates { + const NAME: &'static str = "CSS.trackComputedStyleUpdates"; + type ReturnObject = TrackComputedStyleUpdatesReturnObject; + } + impl Method for TakeComputedStyleUpdates { + const NAME: &'static str = "CSS.takeComputedStyleUpdates"; + type ReturnObject = TakeComputedStyleUpdatesReturnObject; + } + impl Method for SetEffectivePropertyValueForNode { + const NAME: &'static str = "CSS.setEffectivePropertyValueForNode"; + type ReturnObject = SetEffectivePropertyValueForNodeReturnObject; + } + impl Method for SetKeyframeKey { + const NAME: &'static str = "CSS.setKeyframeKey"; + type ReturnObject = SetKeyframeKeyReturnObject; + } + impl Method for SetMediaText { + const NAME: &'static str = "CSS.setMediaText"; + type ReturnObject = SetMediaTextReturnObject; + } + impl Method for SetContainerQueryText { + const NAME: &'static str = "CSS.setContainerQueryText"; + type ReturnObject = SetContainerQueryTextReturnObject; + } + impl Method for SetRuleSelector { + const NAME: &'static str = "CSS.setRuleSelector"; + type ReturnObject = SetRuleSelectorReturnObject; + } + impl Method for SetStyleSheetText { + const NAME: &'static str = "CSS.setStyleSheetText"; + type ReturnObject = SetStyleSheetTextReturnObject; + } + impl Method for SetStyleTexts { + const NAME: &'static str = "CSS.setStyleTexts"; + type ReturnObject = SetStyleTextsReturnObject; + } + impl Method for StartRuleUsageTracking { + const NAME: &'static str = "CSS.startRuleUsageTracking"; + type ReturnObject = StartRuleUsageTrackingReturnObject; + } + impl Method for StopRuleUsageTracking { + const NAME: &'static str = "CSS.stopRuleUsageTracking"; + type ReturnObject = StopRuleUsageTrackingReturnObject; + } + impl Method for TakeCoverageDelta { + const NAME: &'static str = "CSS.takeCoverageDelta"; + type ReturnObject = TakeCoverageDeltaReturnObject; + } + impl Method for SetLocalFontsEnabled { + const NAME: &'static str = "CSS.setLocalFontsEnabled"; + type ReturnObject = SetLocalFontsEnabledReturnObject; + } + pub mod events { + use super::super::types::*; + use serde::{Deserialize, Serialize}; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct FontsUpdatedEvent { + pub params: FontsUpdatedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct FontsUpdatedEventParams { + #[serde(skip_serializing_if = "Option::is_none")] + pub font: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct MediaQueryResultChangedEvent(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct StyleSheetAddedEvent { + pub params: StyleSheetAddedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StyleSheetAddedEventParams { + pub header: super::CSSStyleSheetHeader, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct StyleSheetChangedEvent { + pub params: StyleSheetChangedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StyleSheetChangedEventParams { + pub style_sheet_id: super::StyleSheetId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct StyleSheetRemovedEvent { + pub params: StyleSheetRemovedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StyleSheetRemovedEventParams { + pub style_sheet_id: super::StyleSheetId, + } + } + } + pub mod CacheStorage { + use super::types::*; + use serde::{Deserialize, Serialize}; + use serde_json::Value as Json; + pub type CacheId = String; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum CachedResponseType { + Basic, + Cors, + Default, + Error, + OpaqueResponse, + OpaqueRedirect, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DataEntry { + #[serde(default)] + pub request_url: String, + #[serde(default)] + pub request_method: String, + pub request_headers: Vec

, + #[serde(default)] + pub response_time: JsFloat, + #[serde(default)] + pub response_status: JsUInt, + #[serde(default)] + pub response_status_text: String, + pub response_Type: CachedResponseType, + pub response_headers: Vec
, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Cache { + pub cache_id: CacheId, + #[serde(default)] + pub security_origin: String, + #[serde(default)] + pub cache_name: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Header { + #[serde(default)] + pub name: String, + #[serde(default)] + pub value: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CachedResponse { + #[serde(default)] + pub body: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DeleteCache { + pub cache_id: CacheId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DeleteEntry { + pub cache_id: CacheId, + #[serde(default)] + pub request: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RequestCacheNames { + #[serde(default)] + pub security_origin: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RequestCachedResponse { + pub cache_id: CacheId, + #[serde(default)] + pub request_url: String, + pub request_headers: Vec
, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RequestEntries { + pub cache_id: CacheId, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub skip_count: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub page_size: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub path_filter: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DeleteCacheReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DeleteEntryReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RequestCacheNamesReturnObject { + pub caches: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RequestCachedResponseReturnObject { + pub response: CachedResponse, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RequestEntriesReturnObject { + pub cache_data_entries: Vec, + #[serde(default)] + pub return_count: JsFloat, + } + impl Method for DeleteCache { + const NAME: &'static str = "CacheStorage.deleteCache"; + type ReturnObject = DeleteCacheReturnObject; + } + impl Method for DeleteEntry { + const NAME: &'static str = "CacheStorage.deleteEntry"; + type ReturnObject = DeleteEntryReturnObject; + } + impl Method for RequestCacheNames { + const NAME: &'static str = "CacheStorage.requestCacheNames"; + type ReturnObject = RequestCacheNamesReturnObject; + } + impl Method for RequestCachedResponse { + const NAME: &'static str = "CacheStorage.requestCachedResponse"; + type ReturnObject = RequestCachedResponseReturnObject; + } + impl Method for RequestEntries { + const NAME: &'static str = "CacheStorage.requestEntries"; + type ReturnObject = RequestEntriesReturnObject; + } + pub mod events { + use super::super::types::*; + use serde::{Deserialize, Serialize}; + } + } + pub mod Cast { + use super::types::*; + use serde::{Deserialize, Serialize}; + use serde_json::Value as Json; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Sink { + #[serde(default)] + pub name: String, + #[serde(default)] + pub id: String, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub session: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Enable { + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub presentation_url: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Disable(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetSinkToUse { + #[serde(default)] + pub sink_name: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StartTabMirroring { + #[serde(default)] + pub sink_name: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StopCasting { + #[serde(default)] + pub sink_name: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct EnableReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DisableReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetSinkToUseReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StartTabMirroringReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StopCastingReturnObject {} + impl Method for Enable { + const NAME: &'static str = "Cast.enable"; + type ReturnObject = EnableReturnObject; + } + impl Method for Disable { + const NAME: &'static str = "Cast.disable"; + type ReturnObject = DisableReturnObject; + } + impl Method for SetSinkToUse { + const NAME: &'static str = "Cast.setSinkToUse"; + type ReturnObject = SetSinkToUseReturnObject; + } + impl Method for StartTabMirroring { + const NAME: &'static str = "Cast.startTabMirroring"; + type ReturnObject = StartTabMirroringReturnObject; + } + impl Method for StopCasting { + const NAME: &'static str = "Cast.stopCasting"; + type ReturnObject = StopCastingReturnObject; + } + pub mod events { + use super::super::types::*; + use serde::{Deserialize, Serialize}; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct SinksUpdatedEvent { + pub params: SinksUpdatedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SinksUpdatedEventParams { + pub sinks: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct IssueUpdatedEvent { + pub params: IssueUpdatedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct IssueUpdatedEventParams { + #[serde(default)] + pub issue_message: String, + } + } + } + pub mod DOM { + use super::types::*; + use super::Page; + use super::Runtime; + use super::DOM; + use serde::{Deserialize, Serialize}; + use serde_json::Value as Json; + pub type NodeId = JsUInt; + pub type BackendNodeId = JsUInt; + pub type Quad = Vec; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "kebab-case")] + pub enum PseudoType { + FirstLine, + FirstLetter, + Before, + After, + Marker, + Backdrop, + Selection, + TargetText, + SpellingError, + GrammarError, + Highlight, + FirstLineInherited, + Scrollbar, + ScrollbarThumb, + ScrollbarButton, + ScrollbarTrack, + ScrollbarTrackPiece, + ScrollbarCorner, + Resizer, + InputListButton, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "kebab-case")] + pub enum ShadowRootType { + UserAgent, + Open, + Closed, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "PascalCase")] + pub enum CompatibilityMode { + QuirksMode, + LimitedQuirksMode, + NoQuirksMode, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct BackendNode { + #[serde(default)] + pub node_type: JsUInt, + #[serde(default)] + pub node_name: String, + pub backend_node_id: BackendNodeId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Node { + pub node_id: NodeId, + #[serde(skip_serializing_if = "Option::is_none")] + pub parent_id: Option, + pub backend_node_id: BackendNodeId, + #[serde(default)] + pub node_type: JsUInt, + #[serde(default)] + pub node_name: String, + #[serde(default)] + pub local_name: String, + #[serde(default)] + pub node_value: String, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub child_node_count: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub children: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub attributes: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub document_url: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub base_url: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub public_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub system_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub internal_subset: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub xml_version: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub name: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub value: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub pseudo_Type: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub shadow_root_Type: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub frame_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub content_document: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + pub shadow_roots: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + pub template_content: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + pub pseudo_elements: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + pub imported_document: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + pub distributed_nodes: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub is_svg: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub compatibility_mode: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RGBA { + #[serde(default)] + pub r: JsUInt, + #[serde(default)] + pub g: JsUInt, + #[serde(default)] + pub b: JsUInt, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub a: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct BoxModel { + pub content: Quad, + pub padding: Quad, + pub border: Quad, + pub margin: Quad, + #[serde(default)] + pub width: JsUInt, + #[serde(default)] + pub height: JsUInt, + #[serde(skip_serializing_if = "Option::is_none")] + pub shape_outside: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ShapeOutsideInfo { + pub bounds: Quad, + #[serde(default)] + pub shape: Vec, + #[serde(default)] + pub margin_shape: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Rect { + #[serde(default)] + pub x: JsFloat, + #[serde(default)] + pub y: JsFloat, + #[serde(default)] + pub width: JsFloat, + #[serde(default)] + pub height: JsFloat, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CSSComputedStyleProperty { + #[serde(default)] + pub name: String, + #[serde(default)] + pub value: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CollectClassNamesFromSubtree { + pub node_id: NodeId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CopyTo { + pub node_id: NodeId, + pub target_node_id: NodeId, + #[serde(skip_serializing_if = "Option::is_none")] + pub insert_before_node_id: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DescribeNode { + #[serde(skip_serializing_if = "Option::is_none")] + pub node_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub backend_node_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub object_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub depth: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub pierce: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ScrollIntoViewIfNeeded { + #[serde(skip_serializing_if = "Option::is_none")] + pub node_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub backend_node_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub object_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub rect: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Disable(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DiscardSearchResults { + #[serde(default)] + pub search_id: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Enable(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Focus { + #[serde(skip_serializing_if = "Option::is_none")] + pub node_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub backend_node_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub object_id: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetAttributes { + pub node_id: NodeId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetBoxModel { + #[serde(skip_serializing_if = "Option::is_none")] + pub node_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub backend_node_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub object_id: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetContentQuads { + #[serde(skip_serializing_if = "Option::is_none")] + pub node_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub backend_node_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub object_id: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetDocument { + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub depth: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub pierce: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetFlattenedDocument { + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub depth: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub pierce: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetNodesForSubtreeByStyle { + pub node_id: NodeId, + pub computed_styles: Vec, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub pierce: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetNodeForLocation { + #[serde(default)] + pub x: JsUInt, + #[serde(default)] + pub y: JsUInt, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub include_user_agent_shadow_dom: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub ignore_pointer_events_none: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetOuterHTML { + #[serde(skip_serializing_if = "Option::is_none")] + pub node_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub backend_node_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub object_id: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetRelayoutBoundary { + pub node_id: NodeId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetSearchResults { + #[serde(default)] + pub search_id: String, + #[serde(default)] + pub from_index: JsUInt, + #[serde(default)] + pub to_index: JsUInt, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct HideHighlight(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct HighlightNode(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct HighlightRect(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct MarkUndoableState(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct MoveTo { + pub node_id: NodeId, + pub target_node_id: NodeId, + #[serde(skip_serializing_if = "Option::is_none")] + pub insert_before_node_id: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct PerformSearch { + #[serde(default)] + pub query: String, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub include_user_agent_shadow_dom: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct PushNodeByPathToFrontend { + #[serde(default)] + pub path: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct PushNodesByBackendIdsToFrontend { + pub backend_node_ids: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct QuerySelector { + pub node_id: NodeId, + #[serde(default)] + pub selector: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct QuerySelectorAll { + pub node_id: NodeId, + #[serde(default)] + pub selector: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Redo(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RemoveAttribute { + pub node_id: NodeId, + #[serde(default)] + pub name: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RemoveNode { + pub node_id: NodeId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RequestChildNodes { + pub node_id: NodeId, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub depth: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub pierce: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RequestNode { + pub object_id: Runtime::RemoteObjectId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ResolveNode { + #[serde(skip_serializing_if = "Option::is_none")] + pub node_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub backend_node_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub object_group: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub execution_context_id: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetAttributeValue { + pub node_id: NodeId, + #[serde(default)] + pub name: String, + #[serde(default)] + pub value: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetAttributesAsText { + pub node_id: NodeId, + #[serde(default)] + pub text: String, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub name: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetFileInputFiles { + #[serde(default)] + pub files: Vec, + #[serde(skip_serializing_if = "Option::is_none")] + pub node_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub backend_node_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub object_id: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetNodeStackTracesEnabled { + #[serde(default)] + pub enable: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetNodeStackTraces { + pub node_id: NodeId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetFileInfo { + pub object_id: Runtime::RemoteObjectId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetInspectedNode { + pub node_id: NodeId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetNodeName { + pub node_id: NodeId, + #[serde(default)] + pub name: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetNodeValue { + pub node_id: NodeId, + #[serde(default)] + pub value: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetOuterHTML { + pub node_id: NodeId, + #[serde(default)] + pub outer_html: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Undo(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetFrameOwner { + pub frame_id: Page::FrameId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetContainerForNode { + pub node_id: NodeId, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub container_name: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetQueryingDescendantsForContainer { + pub node_id: NodeId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CollectClassNamesFromSubtreeReturnObject { + pub class_names: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CopyToReturnObject { + pub node_id: NodeId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DescribeNodeReturnObject { + pub node: Node, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ScrollIntoViewIfNeededReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DisableReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DiscardSearchResultsReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct EnableReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct FocusReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetAttributesReturnObject { + pub attributes: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetBoxModelReturnObject { + pub model: BoxModel, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetContentQuadsReturnObject { + pub quads: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetDocumentReturnObject { + pub root: Node, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetFlattenedDocumentReturnObject { + pub nodes: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetNodesForSubtreeByStyleReturnObject { + pub node_ids: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetNodeForLocationReturnObject { + pub backend_node_id: BackendNodeId, + pub frame_id: Page::FrameId, + #[serde(skip_serializing_if = "Option::is_none")] + pub node_id: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetOuterHTMLReturnObject { + #[serde(default)] + pub outer_html: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetRelayoutBoundaryReturnObject { + pub node_id: NodeId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetSearchResultsReturnObject { + pub node_ids: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct HideHighlightReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct HighlightNodeReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct HighlightRectReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct MarkUndoableStateReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct MoveToReturnObject { + pub node_id: NodeId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct PerformSearchReturnObject { + #[serde(default)] + pub search_id: String, + #[serde(default)] + pub result_count: JsUInt, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct PushNodeByPathToFrontendReturnObject { + pub node_id: NodeId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct PushNodesByBackendIdsToFrontendReturnObject { + pub node_ids: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct QuerySelectorReturnObject { + pub node_id: NodeId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct QuerySelectorAllReturnObject { + pub node_ids: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RedoReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RemoveAttributeReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RemoveNodeReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RequestChildNodesReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RequestNodeReturnObject { + pub node_id: NodeId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ResolveNodeReturnObject { + pub object: Runtime::RemoteObject, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetAttributeValueReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetAttributesAsTextReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetFileInputFilesReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetNodeStackTracesEnabledReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetNodeStackTracesReturnObject { + #[serde(skip_serializing_if = "Option::is_none")] + pub creation: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetFileInfoReturnObject { + #[serde(default)] + pub path: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetInspectedNodeReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetNodeNameReturnObject { + pub node_id: NodeId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetNodeValueReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetOuterHTMLReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct UndoReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetFrameOwnerReturnObject { + pub backend_node_id: BackendNodeId, + #[serde(skip_serializing_if = "Option::is_none")] + pub node_id: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetContainerForNodeReturnObject { + #[serde(skip_serializing_if = "Option::is_none")] + pub node_id: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetQueryingDescendantsForContainerReturnObject { + pub node_ids: Vec, + } + impl Method for CollectClassNamesFromSubtree { + const NAME: &'static str = "DOM.collectClassNamesFromSubtree"; + type ReturnObject = CollectClassNamesFromSubtreeReturnObject; + } + impl Method for CopyTo { + const NAME: &'static str = "DOM.copyTo"; + type ReturnObject = CopyToReturnObject; + } + impl Method for DescribeNode { + const NAME: &'static str = "DOM.describeNode"; + type ReturnObject = DescribeNodeReturnObject; + } + impl Method for ScrollIntoViewIfNeeded { + const NAME: &'static str = "DOM.scrollIntoViewIfNeeded"; + type ReturnObject = ScrollIntoViewIfNeededReturnObject; + } + impl Method for Disable { + const NAME: &'static str = "DOM.disable"; + type ReturnObject = DisableReturnObject; + } + impl Method for DiscardSearchResults { + const NAME: &'static str = "DOM.discardSearchResults"; + type ReturnObject = DiscardSearchResultsReturnObject; + } + impl Method for Enable { + const NAME: &'static str = "DOM.enable"; + type ReturnObject = EnableReturnObject; + } + impl Method for Focus { + const NAME: &'static str = "DOM.focus"; + type ReturnObject = FocusReturnObject; + } + impl Method for GetAttributes { + const NAME: &'static str = "DOM.getAttributes"; + type ReturnObject = GetAttributesReturnObject; + } + impl Method for GetBoxModel { + const NAME: &'static str = "DOM.getBoxModel"; + type ReturnObject = GetBoxModelReturnObject; + } + impl Method for GetContentQuads { + const NAME: &'static str = "DOM.getContentQuads"; + type ReturnObject = GetContentQuadsReturnObject; + } + impl Method for GetDocument { + const NAME: &'static str = "DOM.getDocument"; + type ReturnObject = GetDocumentReturnObject; + } + impl Method for GetFlattenedDocument { + const NAME: &'static str = "DOM.getFlattenedDocument"; + type ReturnObject = GetFlattenedDocumentReturnObject; + } + impl Method for GetNodesForSubtreeByStyle { + const NAME: &'static str = "DOM.getNodesForSubtreeByStyle"; + type ReturnObject = GetNodesForSubtreeByStyleReturnObject; + } + impl Method for GetNodeForLocation { + const NAME: &'static str = "DOM.getNodeForLocation"; + type ReturnObject = GetNodeForLocationReturnObject; + } + impl Method for GetOuterHTML { + const NAME: &'static str = "DOM.getOuterHTML"; + type ReturnObject = GetOuterHTMLReturnObject; + } + impl Method for GetRelayoutBoundary { + const NAME: &'static str = "DOM.getRelayoutBoundary"; + type ReturnObject = GetRelayoutBoundaryReturnObject; + } + impl Method for GetSearchResults { + const NAME: &'static str = "DOM.getSearchResults"; + type ReturnObject = GetSearchResultsReturnObject; + } + impl Method for HideHighlight { + const NAME: &'static str = "DOM.hideHighlight"; + type ReturnObject = HideHighlightReturnObject; + } + impl Method for HighlightNode { + const NAME: &'static str = "DOM.highlightNode"; + type ReturnObject = HighlightNodeReturnObject; + } + impl Method for HighlightRect { + const NAME: &'static str = "DOM.highlightRect"; + type ReturnObject = HighlightRectReturnObject; + } + impl Method for MarkUndoableState { + const NAME: &'static str = "DOM.markUndoableState"; + type ReturnObject = MarkUndoableStateReturnObject; + } + impl Method for MoveTo { + const NAME: &'static str = "DOM.moveTo"; + type ReturnObject = MoveToReturnObject; + } + impl Method for PerformSearch { + const NAME: &'static str = "DOM.performSearch"; + type ReturnObject = PerformSearchReturnObject; + } + impl Method for PushNodeByPathToFrontend { + const NAME: &'static str = "DOM.pushNodeByPathToFrontend"; + type ReturnObject = PushNodeByPathToFrontendReturnObject; + } + impl Method for PushNodesByBackendIdsToFrontend { + const NAME: &'static str = "DOM.pushNodesByBackendIdsToFrontend"; + type ReturnObject = PushNodesByBackendIdsToFrontendReturnObject; + } + impl Method for QuerySelector { + const NAME: &'static str = "DOM.querySelector"; + type ReturnObject = QuerySelectorReturnObject; + } + impl Method for QuerySelectorAll { + const NAME: &'static str = "DOM.querySelectorAll"; + type ReturnObject = QuerySelectorAllReturnObject; + } + impl Method for Redo { + const NAME: &'static str = "DOM.redo"; + type ReturnObject = RedoReturnObject; + } + impl Method for RemoveAttribute { + const NAME: &'static str = "DOM.removeAttribute"; + type ReturnObject = RemoveAttributeReturnObject; + } + impl Method for RemoveNode { + const NAME: &'static str = "DOM.removeNode"; + type ReturnObject = RemoveNodeReturnObject; + } + impl Method for RequestChildNodes { + const NAME: &'static str = "DOM.requestChildNodes"; + type ReturnObject = RequestChildNodesReturnObject; + } + impl Method for RequestNode { + const NAME: &'static str = "DOM.requestNode"; + type ReturnObject = RequestNodeReturnObject; + } + impl Method for ResolveNode { + const NAME: &'static str = "DOM.resolveNode"; + type ReturnObject = ResolveNodeReturnObject; + } + impl Method for SetAttributeValue { + const NAME: &'static str = "DOM.setAttributeValue"; + type ReturnObject = SetAttributeValueReturnObject; + } + impl Method for SetAttributesAsText { + const NAME: &'static str = "DOM.setAttributesAsText"; + type ReturnObject = SetAttributesAsTextReturnObject; + } + impl Method for SetFileInputFiles { + const NAME: &'static str = "DOM.setFileInputFiles"; + type ReturnObject = SetFileInputFilesReturnObject; + } + impl Method for SetNodeStackTracesEnabled { + const NAME: &'static str = "DOM.setNodeStackTracesEnabled"; + type ReturnObject = SetNodeStackTracesEnabledReturnObject; + } + impl Method for GetNodeStackTraces { + const NAME: &'static str = "DOM.getNodeStackTraces"; + type ReturnObject = GetNodeStackTracesReturnObject; + } + impl Method for GetFileInfo { + const NAME: &'static str = "DOM.getFileInfo"; + type ReturnObject = GetFileInfoReturnObject; + } + impl Method for SetInspectedNode { + const NAME: &'static str = "DOM.setInspectedNode"; + type ReturnObject = SetInspectedNodeReturnObject; + } + impl Method for SetNodeName { + const NAME: &'static str = "DOM.setNodeName"; + type ReturnObject = SetNodeNameReturnObject; + } + impl Method for SetNodeValue { + const NAME: &'static str = "DOM.setNodeValue"; + type ReturnObject = SetNodeValueReturnObject; + } + impl Method for SetOuterHTML { + const NAME: &'static str = "DOM.setOuterHTML"; + type ReturnObject = SetOuterHTMLReturnObject; + } + impl Method for Undo { + const NAME: &'static str = "DOM.undo"; + type ReturnObject = UndoReturnObject; + } + impl Method for GetFrameOwner { + const NAME: &'static str = "DOM.getFrameOwner"; + type ReturnObject = GetFrameOwnerReturnObject; + } + impl Method for GetContainerForNode { + const NAME: &'static str = "DOM.getContainerForNode"; + type ReturnObject = GetContainerForNodeReturnObject; + } + impl Method for GetQueryingDescendantsForContainer { + const NAME: &'static str = "DOM.getQueryingDescendantsForContainer"; + type ReturnObject = GetQueryingDescendantsForContainerReturnObject; + } + pub mod events { + use super::super::types::*; + use serde::{Deserialize, Serialize}; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct AttributeModifiedEvent { + pub params: AttributeModifiedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct AttributeModifiedEventParams { + pub node_id: super::NodeId, + #[serde(default)] + pub name: String, + #[serde(default)] + pub value: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct AttributeRemovedEvent { + pub params: AttributeRemovedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct AttributeRemovedEventParams { + pub node_id: super::NodeId, + #[serde(default)] + pub name: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct CharacterDataModifiedEvent { + pub params: CharacterDataModifiedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CharacterDataModifiedEventParams { + pub node_id: super::NodeId, + #[serde(default)] + pub character_data: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct ChildNodeCountUpdatedEvent { + pub params: ChildNodeCountUpdatedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ChildNodeCountUpdatedEventParams { + pub node_id: super::NodeId, + #[serde(default)] + pub child_node_count: JsUInt, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct ChildNodeInsertedEvent { + pub params: ChildNodeInsertedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ChildNodeInsertedEventParams { + pub parent_node_id: super::NodeId, + pub previous_node_id: super::NodeId, + pub node: super::Node, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct ChildNodeRemovedEvent { + pub params: ChildNodeRemovedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ChildNodeRemovedEventParams { + pub parent_node_id: super::NodeId, + pub node_id: super::NodeId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct DistributedNodesUpdatedEvent { + pub params: DistributedNodesUpdatedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DistributedNodesUpdatedEventParams { + pub insertion_point_id: super::NodeId, + pub distributed_nodes: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DocumentUpdatedEvent(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct InlineStyleInvalidatedEvent { + pub params: InlineStyleInvalidatedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct InlineStyleInvalidatedEventParams { + pub node_ids: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct PseudoElementAddedEvent { + pub params: PseudoElementAddedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct PseudoElementAddedEventParams { + pub parent_id: super::NodeId, + pub pseudo_element: super::Node, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct PseudoElementRemovedEvent { + pub params: PseudoElementRemovedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct PseudoElementRemovedEventParams { + pub parent_id: super::NodeId, + pub pseudo_element_id: super::NodeId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct SetChildNodesEvent { + pub params: SetChildNodesEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetChildNodesEventParams { + pub parent_id: super::NodeId, + pub nodes: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct ShadowRootPoppedEvent { + pub params: ShadowRootPoppedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ShadowRootPoppedEventParams { + pub host_id: super::NodeId, + pub root_id: super::NodeId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct ShadowRootPushedEvent { + pub params: ShadowRootPushedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ShadowRootPushedEventParams { + pub host_id: super::NodeId, + pub root: super::Node, + } + } + } + pub mod DOMDebugger { + use super::types::*; + use super::Debugger; + use super::Runtime; + use super::DOM; + use serde::{Deserialize, Serialize}; + use serde_json::Value as Json; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "kebab-case")] + pub enum DOMBreakpointType { + SubtreeModified, + AttributeModified, + NodeRemoved, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "kebab-case")] + pub enum CSPViolationType { + TrustedtypeSinkViolation, + TrustedtypePolicyViolation, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct EventListener { + #[serde(default)] + pub Type: String, + #[serde(default)] + pub use_capture: bool, + #[serde(default)] + pub passive: bool, + #[serde(default)] + pub once: bool, + pub script_id: Runtime::ScriptId, + #[serde(default)] + pub line_number: JsUInt, + #[serde(default)] + pub column_number: JsUInt, + #[serde(skip_serializing_if = "Option::is_none")] + pub handler: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub original_handler: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub backend_node_id: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetEventListeners { + pub object_id: Runtime::RemoteObjectId, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub depth: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub pierce: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RemoveDOMBreakpoint { + pub node_id: DOM::NodeId, + pub Type: DOMBreakpointType, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RemoveEventListenerBreakpoint { + #[serde(default)] + pub event_name: String, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub target_name: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RemoveInstrumentationBreakpoint { + #[serde(default)] + pub event_name: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RemoveXHRBreakpoint { + #[serde(default)] + pub url: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetBreakOnCSPViolation { + pub violation_Types: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetDOMBreakpoint { + pub node_id: DOM::NodeId, + pub Type: DOMBreakpointType, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetEventListenerBreakpoint { + #[serde(default)] + pub event_name: String, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub target_name: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetInstrumentationBreakpoint { + #[serde(default)] + pub event_name: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetXHRBreakpoint { + #[serde(default)] + pub url: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetEventListenersReturnObject { + pub listeners: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RemoveDOMBreakpointReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RemoveEventListenerBreakpointReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RemoveInstrumentationBreakpointReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RemoveXHRBreakpointReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetBreakOnCSPViolationReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetDOMBreakpointReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetEventListenerBreakpointReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetInstrumentationBreakpointReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetXHRBreakpointReturnObject {} + impl Method for GetEventListeners { + const NAME: &'static str = "DOMDebugger.getEventListeners"; + type ReturnObject = GetEventListenersReturnObject; + } + impl Method for RemoveDOMBreakpoint { + const NAME: &'static str = "DOMDebugger.removeDOMBreakpoint"; + type ReturnObject = RemoveDOMBreakpointReturnObject; + } + impl Method for RemoveEventListenerBreakpoint { + const NAME: &'static str = "DOMDebugger.removeEventListenerBreakpoint"; + type ReturnObject = RemoveEventListenerBreakpointReturnObject; + } + impl Method for RemoveInstrumentationBreakpoint { + const NAME: &'static str = "DOMDebugger.removeInstrumentationBreakpoint"; + type ReturnObject = RemoveInstrumentationBreakpointReturnObject; + } + impl Method for RemoveXHRBreakpoint { + const NAME: &'static str = "DOMDebugger.removeXHRBreakpoint"; + type ReturnObject = RemoveXHRBreakpointReturnObject; + } + impl Method for SetBreakOnCSPViolation { + const NAME: &'static str = "DOMDebugger.setBreakOnCSPViolation"; + type ReturnObject = SetBreakOnCSPViolationReturnObject; + } + impl Method for SetDOMBreakpoint { + const NAME: &'static str = "DOMDebugger.setDOMBreakpoint"; + type ReturnObject = SetDOMBreakpointReturnObject; + } + impl Method for SetEventListenerBreakpoint { + const NAME: &'static str = "DOMDebugger.setEventListenerBreakpoint"; + type ReturnObject = SetEventListenerBreakpointReturnObject; + } + impl Method for SetInstrumentationBreakpoint { + const NAME: &'static str = "DOMDebugger.setInstrumentationBreakpoint"; + type ReturnObject = SetInstrumentationBreakpointReturnObject; + } + impl Method for SetXHRBreakpoint { + const NAME: &'static str = "DOMDebugger.setXHRBreakpoint"; + type ReturnObject = SetXHRBreakpointReturnObject; + } + pub mod events { + use super::super::types::*; + use serde::{Deserialize, Serialize}; + } + } + pub mod EventBreakpoints { + use super::types::*; + use serde::{Deserialize, Serialize}; + use serde_json::Value as Json; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetInstrumentationBreakpoint { + #[serde(default)] + pub event_name: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RemoveInstrumentationBreakpoint { + #[serde(default)] + pub event_name: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetInstrumentationBreakpointReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RemoveInstrumentationBreakpointReturnObject {} + impl Method for SetInstrumentationBreakpoint { + const NAME: &'static str = "EventBreakpoints.setInstrumentationBreakpoint"; + type ReturnObject = SetInstrumentationBreakpointReturnObject; + } + impl Method for RemoveInstrumentationBreakpoint { + const NAME: &'static str = "EventBreakpoints.removeInstrumentationBreakpoint"; + type ReturnObject = RemoveInstrumentationBreakpointReturnObject; + } + pub mod events { + use super::super::types::*; + use serde::{Deserialize, Serialize}; + } + } + pub mod DOMSnapshot { + use super::types::*; + use super::DOMDebugger; + use super::Page; + use super::CSS; + use super::DOM; + use serde::{Deserialize, Serialize}; + use serde_json::Value as Json; + pub type StringIndex = JsUInt; + pub type ArrayOfStrings = Vec; + pub type Rectangle = Vec; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DOMNode { + #[serde(default)] + pub node_type: JsUInt, + #[serde(default)] + pub node_name: String, + #[serde(default)] + pub node_value: String, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub text_value: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub input_value: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub input_checked: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub option_selected: Option, + pub backend_node_id: DOM::BackendNodeId, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub child_node_indexes: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + pub attributes: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub pseudo_element_indexes: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub layout_node_index: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub document_url: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub base_url: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub content_language: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub document_encoding: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub public_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub system_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub frame_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub content_document_index: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub pseudo_Type: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub shadow_root_Type: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub is_clickable: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub event_listeners: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub current_source_url: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub origin_url: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub scroll_offset_x: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub scroll_offset_y: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct InlineTextBox { + pub bounding_box: DOM::Rect, + #[serde(default)] + pub start_character_index: JsUInt, + #[serde(default)] + pub num_characters: JsUInt, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct LayoutTreeNode { + #[serde(default)] + pub dom_node_index: JsUInt, + pub bounding_box: DOM::Rect, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub layout_text: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub inline_text_nodes: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub style_index: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub paint_order: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub is_stacking_context: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ComputedStyle { + pub properties: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct NameValue { + #[serde(default)] + pub name: String, + #[serde(default)] + pub value: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RareStringData { + #[serde(default)] + pub index: Vec, + pub value: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RareBooleanData { + #[serde(default)] + pub index: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RareIntegerData { + #[serde(default)] + pub index: Vec, + #[serde(default)] + pub value: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DocumentSnapshot { + pub document_url: StringIndex, + pub title: StringIndex, + pub base_url: StringIndex, + pub content_language: StringIndex, + pub encoding_name: StringIndex, + pub public_id: StringIndex, + pub system_id: StringIndex, + pub frame_id: StringIndex, + pub nodes: NodeTreeSnapshot, + pub layout: LayoutTreeSnapshot, + pub text_boxes: TextBoxSnapshot, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub scroll_offset_x: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub scroll_offset_y: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub content_width: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub content_height: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct NodeTreeSnapshot { + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub parent_index: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub node_type: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + pub shadow_root_Type: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub node_name: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + pub node_value: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + pub backend_node_id: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + pub attributes: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + pub text_value: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub input_value: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub input_checked: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub option_selected: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub content_document_index: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub pseudo_Type: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub is_clickable: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub current_source_url: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub origin_url: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct LayoutTreeSnapshot { + #[serde(default)] + pub node_index: Vec, + pub styles: Vec, + pub bounds: Vec, + pub text: Vec, + pub stacking_contexts: RareBooleanData, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub paint_orders: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + pub offset_rects: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + pub scroll_rects: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + pub client_rects: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + pub blended_background_colors: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub text_color_opacities: Option>, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct TextBoxSnapshot { + #[serde(default)] + pub layout_index: Vec, + pub bounds: Vec, + #[serde(default)] + pub start: Vec, + #[serde(default)] + pub length: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Disable(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Enable(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetSnapshot { + #[serde(default)] + pub computed_style_whitelist: Vec, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub include_event_listeners: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub include_paint_order: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub include_user_agent_shadow_tree: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CaptureSnapshot { + #[serde(default)] + pub computed_styles: Vec, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub include_paint_order: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub include_dom_rects: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub include_blended_background_colors: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub include_text_color_opacities: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DisableReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct EnableReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetSnapshotReturnObject { + pub dom_nodes: Vec, + pub layout_tree_nodes: Vec, + pub computed_styles: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CaptureSnapshotReturnObject { + pub documents: Vec, + pub strings: Vec, + } + impl Method for Disable { + const NAME: &'static str = "DOMSnapshot.disable"; + type ReturnObject = DisableReturnObject; + } + impl Method for Enable { + const NAME: &'static str = "DOMSnapshot.enable"; + type ReturnObject = EnableReturnObject; + } + impl Method for GetSnapshot { + const NAME: &'static str = "DOMSnapshot.getSnapshot"; + type ReturnObject = GetSnapshotReturnObject; + } + impl Method for CaptureSnapshot { + const NAME: &'static str = "DOMSnapshot.captureSnapshot"; + type ReturnObject = CaptureSnapshotReturnObject; + } + pub mod events { + use super::super::types::*; + use serde::{Deserialize, Serialize}; + } + } + pub mod DOMStorage { + use super::types::*; + use serde::{Deserialize, Serialize}; + use serde_json::Value as Json; + pub type Item = Vec; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StorageId { + #[serde(default)] + pub security_origin: String, + #[serde(default)] + pub is_local_storage: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Clear { + pub storage_id: StorageId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Disable(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Enable(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetDOMStorageItems { + pub storage_id: StorageId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RemoveDOMStorageItem { + pub storage_id: StorageId, + #[serde(default)] + pub key: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetDOMStorageItem { + pub storage_id: StorageId, + #[serde(default)] + pub key: String, + #[serde(default)] + pub value: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ClearReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DisableReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct EnableReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetDOMStorageItemsReturnObject { + pub entries: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RemoveDOMStorageItemReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetDOMStorageItemReturnObject {} + impl Method for Clear { + const NAME: &'static str = "DOMStorage.clear"; + type ReturnObject = ClearReturnObject; + } + impl Method for Disable { + const NAME: &'static str = "DOMStorage.disable"; + type ReturnObject = DisableReturnObject; + } + impl Method for Enable { + const NAME: &'static str = "DOMStorage.enable"; + type ReturnObject = EnableReturnObject; + } + impl Method for GetDOMStorageItems { + const NAME: &'static str = "DOMStorage.getDOMStorageItems"; + type ReturnObject = GetDOMStorageItemsReturnObject; + } + impl Method for RemoveDOMStorageItem { + const NAME: &'static str = "DOMStorage.removeDOMStorageItem"; + type ReturnObject = RemoveDOMStorageItemReturnObject; + } + impl Method for SetDOMStorageItem { + const NAME: &'static str = "DOMStorage.setDOMStorageItem"; + type ReturnObject = SetDOMStorageItemReturnObject; + } + pub mod events { + use super::super::types::*; + use serde::{Deserialize, Serialize}; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct DomStorageItemAddedEvent { + pub params: DomStorageItemAddedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DomStorageItemAddedEventParams { + pub storage_id: super::StorageId, + #[serde(default)] + pub key: String, + #[serde(default)] + pub new_value: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct DomStorageItemRemovedEvent { + pub params: DomStorageItemRemovedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DomStorageItemRemovedEventParams { + pub storage_id: super::StorageId, + #[serde(default)] + pub key: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct DomStorageItemUpdatedEvent { + pub params: DomStorageItemUpdatedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DomStorageItemUpdatedEventParams { + pub storage_id: super::StorageId, + #[serde(default)] + pub key: String, + #[serde(default)] + pub old_value: String, + #[serde(default)] + pub new_value: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct DomStorageItemsClearedEvent { + pub params: DomStorageItemsClearedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DomStorageItemsClearedEventParams { + pub storage_id: super::StorageId, + } + } + } + pub mod Database { + use super::types::*; + use serde::{Deserialize, Serialize}; + use serde_json::Value as Json; + pub type DatabaseId = String; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Database { + pub id: DatabaseId, + #[serde(default)] + pub domain: String, + #[serde(default)] + pub name: String, + #[serde(default)] + pub version: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Error { + #[serde(default)] + pub message: String, + #[serde(default)] + pub code: JsUInt, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Disable(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Enable(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ExecuteSQL { + pub database_id: DatabaseId, + #[serde(default)] + pub query: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetDatabaseTableNames { + pub database_id: DatabaseId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DisableReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct EnableReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ExecuteSQLReturnObject { + #[serde(skip_serializing_if = "Option::is_none")] + pub column_names: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + pub values: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + pub sql_error: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetDatabaseTableNamesReturnObject { + pub table_names: Vec, + } + impl Method for Disable { + const NAME: &'static str = "Database.disable"; + type ReturnObject = DisableReturnObject; + } + impl Method for Enable { + const NAME: &'static str = "Database.enable"; + type ReturnObject = EnableReturnObject; + } + impl Method for ExecuteSQL { + const NAME: &'static str = "Database.executeSQL"; + type ReturnObject = ExecuteSQLReturnObject; + } + impl Method for GetDatabaseTableNames { + const NAME: &'static str = "Database.getDatabaseTableNames"; + type ReturnObject = GetDatabaseTableNamesReturnObject; + } + pub mod events { + use super::super::types::*; + use serde::{Deserialize, Serialize}; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct AddDatabaseEvent { + pub params: AddDatabaseEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct AddDatabaseEventParams { + pub database: super::Database, + } + } + } + pub mod DeviceOrientation { + use super::types::*; + use serde::{Deserialize, Serialize}; + use serde_json::Value as Json; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ClearDeviceOrientationOverride(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetDeviceOrientationOverride { + #[serde(default)] + pub alpha: JsFloat, + #[serde(default)] + pub beta: JsFloat, + #[serde(default)] + pub gamma: JsFloat, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ClearDeviceOrientationOverrideReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetDeviceOrientationOverrideReturnObject {} + impl Method for ClearDeviceOrientationOverride { + const NAME: &'static str = "DeviceOrientation.clearDeviceOrientationOverride"; + type ReturnObject = ClearDeviceOrientationOverrideReturnObject; + } + impl Method for SetDeviceOrientationOverride { + const NAME: &'static str = "DeviceOrientation.setDeviceOrientationOverride"; + type ReturnObject = SetDeviceOrientationOverrideReturnObject; + } + pub mod events { + use super::super::types::*; + use serde::{Deserialize, Serialize}; + } + } + pub mod Emulation { + use super::types::*; + use super::Network; + use super::Page; + use super::Runtime; + use super::DOM; + use serde::{Deserialize, Serialize}; + use serde_json::Value as Json; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum ScreenOrientationType { + PortraitPrimary, + PortraitSecondary, + LandscapePrimary, + LandscapeSecondary, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum DisplayFeatureOrientation { + Vertical, + Horizontal, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum VirtualTimePolicy { + Advance, + Pause, + PauseIfNetworkFetchesPending, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum DisabledImageType { + Avif, + Jxl, + Webp, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum SetEmitTouchEventsForMouseConfigurationOption { + Mobile, + Desktop, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum SetEmulatedVisionDeficiencyTypeOption { + None, + Achromatopsia, + BlurredVision, + Deuteranopia, + Protanopia, + Tritanopia, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ScreenOrientation { + pub Type: ScreenOrientationType, + #[serde(default)] + pub angle: JsUInt, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DisplayFeature { + pub orientation: DisplayFeatureOrientation, + #[serde(default)] + pub offset: JsUInt, + #[serde(default)] + pub mask_length: JsUInt, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct MediaFeature { + #[serde(default)] + pub name: String, + #[serde(default)] + pub value: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct UserAgentBrandVersion { + #[serde(default)] + pub brand: String, + #[serde(default)] + pub version: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct UserAgentMetadata { + #[serde(skip_serializing_if = "Option::is_none")] + pub brands: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + pub full_version_list: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub full_version: Option, + #[serde(default)] + pub platform: String, + #[serde(default)] + pub platform_version: String, + #[serde(default)] + pub architecture: String, + #[serde(default)] + pub model: String, + #[serde(default)] + pub mobile: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CanEmulate(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ClearDeviceMetricsOverride(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ClearGeolocationOverride(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ResetPageScaleFactor(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetFocusEmulationEnabled { + #[serde(default)] + pub enabled: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetAutoDarkModeOverride { + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub enabled: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetCPUThrottlingRate { + #[serde(default)] + pub rate: JsFloat, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetDefaultBackgroundColorOverride { + #[serde(skip_serializing_if = "Option::is_none")] + pub color: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetDeviceMetricsOverride { + #[serde(default)] + pub width: JsUInt, + #[serde(default)] + pub height: JsUInt, + #[serde(default)] + pub device_scale_factor: JsFloat, + #[serde(default)] + pub mobile: bool, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub scale: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub screen_width: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub screen_height: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub position_x: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub position_y: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub dont_set_visible_size: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub screen_orientation: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub viewport: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub display_feature: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetScrollbarsHidden { + #[serde(default)] + pub hidden: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetDocumentCookieDisabled { + #[serde(default)] + pub disabled: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetEmitTouchEventsForMouse { + #[serde(default)] + pub enabled: bool, + #[serde(skip_serializing_if = "Option::is_none")] + pub configuration: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetEmulatedMedia { + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub media: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub features: Option>, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetEmulatedVisionDeficiency { + pub Type: SetEmulatedVisionDeficiencyTypeOption, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetGeolocationOverride { + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub latitude: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub longitude: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub accuracy: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetIdleOverride { + #[serde(default)] + pub is_user_active: bool, + #[serde(default)] + pub is_screen_unlocked: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ClearIdleOverride(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetNavigatorOverrides { + #[serde(default)] + pub platform: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetPageScaleFactor { + #[serde(default)] + pub page_scale_factor: JsFloat, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetScriptExecutionDisabled { + #[serde(default)] + pub value: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetTouchEmulationEnabled { + #[serde(default)] + pub enabled: bool, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub max_touch_points: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetVirtualTimePolicy { + pub policy: VirtualTimePolicy, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub budget: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub max_virtual_time_task_starvation_count: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub wait_for_navigation: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub initial_virtual_time: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetLocaleOverride { + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub locale: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetTimezoneOverride { + #[serde(default)] + pub timezone_id: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetVisibleSize { + #[serde(default)] + pub width: JsUInt, + #[serde(default)] + pub height: JsUInt, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetDisabledImageTypes { + pub image_Types: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetUserAgentOverride { + #[serde(default)] + pub user_agent: String, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub accept_language: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub platform: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub user_agent_metadata: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CanEmulateReturnObject { + #[serde(default)] + pub result: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ClearDeviceMetricsOverrideReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ClearGeolocationOverrideReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ResetPageScaleFactorReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetFocusEmulationEnabledReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetAutoDarkModeOverrideReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetCPUThrottlingRateReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetDefaultBackgroundColorOverrideReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetDeviceMetricsOverrideReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetScrollbarsHiddenReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetDocumentCookieDisabledReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetEmitTouchEventsForMouseReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetEmulatedMediaReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetEmulatedVisionDeficiencyReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetGeolocationOverrideReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetIdleOverrideReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ClearIdleOverrideReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetNavigatorOverridesReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetPageScaleFactorReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetScriptExecutionDisabledReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetTouchEmulationEnabledReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetVirtualTimePolicyReturnObject { + #[serde(default)] + pub virtual_time_ticks_base: JsFloat, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetLocaleOverrideReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetTimezoneOverrideReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetVisibleSizeReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetDisabledImageTypesReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetUserAgentOverrideReturnObject {} + impl Method for CanEmulate { + const NAME: &'static str = "Emulation.canEmulate"; + type ReturnObject = CanEmulateReturnObject; + } + impl Method for ClearDeviceMetricsOverride { + const NAME: &'static str = "Emulation.clearDeviceMetricsOverride"; + type ReturnObject = ClearDeviceMetricsOverrideReturnObject; + } + impl Method for ClearGeolocationOverride { + const NAME: &'static str = "Emulation.clearGeolocationOverride"; + type ReturnObject = ClearGeolocationOverrideReturnObject; + } + impl Method for ResetPageScaleFactor { + const NAME: &'static str = "Emulation.resetPageScaleFactor"; + type ReturnObject = ResetPageScaleFactorReturnObject; + } + impl Method for SetFocusEmulationEnabled { + const NAME: &'static str = "Emulation.setFocusEmulationEnabled"; + type ReturnObject = SetFocusEmulationEnabledReturnObject; + } + impl Method for SetAutoDarkModeOverride { + const NAME: &'static str = "Emulation.setAutoDarkModeOverride"; + type ReturnObject = SetAutoDarkModeOverrideReturnObject; + } + impl Method for SetCPUThrottlingRate { + const NAME: &'static str = "Emulation.setCPUThrottlingRate"; + type ReturnObject = SetCPUThrottlingRateReturnObject; + } + impl Method for SetDefaultBackgroundColorOverride { + const NAME: &'static str = "Emulation.setDefaultBackgroundColorOverride"; + type ReturnObject = SetDefaultBackgroundColorOverrideReturnObject; + } + impl Method for SetDeviceMetricsOverride { + const NAME: &'static str = "Emulation.setDeviceMetricsOverride"; + type ReturnObject = SetDeviceMetricsOverrideReturnObject; + } + impl Method for SetScrollbarsHidden { + const NAME: &'static str = "Emulation.setScrollbarsHidden"; + type ReturnObject = SetScrollbarsHiddenReturnObject; + } + impl Method for SetDocumentCookieDisabled { + const NAME: &'static str = "Emulation.setDocumentCookieDisabled"; + type ReturnObject = SetDocumentCookieDisabledReturnObject; + } + impl Method for SetEmitTouchEventsForMouse { + const NAME: &'static str = "Emulation.setEmitTouchEventsForMouse"; + type ReturnObject = SetEmitTouchEventsForMouseReturnObject; + } + impl Method for SetEmulatedMedia { + const NAME: &'static str = "Emulation.setEmulatedMedia"; + type ReturnObject = SetEmulatedMediaReturnObject; + } + impl Method for SetEmulatedVisionDeficiency { + const NAME: &'static str = "Emulation.setEmulatedVisionDeficiency"; + type ReturnObject = SetEmulatedVisionDeficiencyReturnObject; + } + impl Method for SetGeolocationOverride { + const NAME: &'static str = "Emulation.setGeolocationOverride"; + type ReturnObject = SetGeolocationOverrideReturnObject; + } + impl Method for SetIdleOverride { + const NAME: &'static str = "Emulation.setIdleOverride"; + type ReturnObject = SetIdleOverrideReturnObject; + } + impl Method for ClearIdleOverride { + const NAME: &'static str = "Emulation.clearIdleOverride"; + type ReturnObject = ClearIdleOverrideReturnObject; + } + impl Method for SetNavigatorOverrides { + const NAME: &'static str = "Emulation.setNavigatorOverrides"; + type ReturnObject = SetNavigatorOverridesReturnObject; + } + impl Method for SetPageScaleFactor { + const NAME: &'static str = "Emulation.setPageScaleFactor"; + type ReturnObject = SetPageScaleFactorReturnObject; + } + impl Method for SetScriptExecutionDisabled { + const NAME: &'static str = "Emulation.setScriptExecutionDisabled"; + type ReturnObject = SetScriptExecutionDisabledReturnObject; + } + impl Method for SetTouchEmulationEnabled { + const NAME: &'static str = "Emulation.setTouchEmulationEnabled"; + type ReturnObject = SetTouchEmulationEnabledReturnObject; + } + impl Method for SetVirtualTimePolicy { + const NAME: &'static str = "Emulation.setVirtualTimePolicy"; + type ReturnObject = SetVirtualTimePolicyReturnObject; + } + impl Method for SetLocaleOverride { + const NAME: &'static str = "Emulation.setLocaleOverride"; + type ReturnObject = SetLocaleOverrideReturnObject; + } + impl Method for SetTimezoneOverride { + const NAME: &'static str = "Emulation.setTimezoneOverride"; + type ReturnObject = SetTimezoneOverrideReturnObject; + } + impl Method for SetVisibleSize { + const NAME: &'static str = "Emulation.setVisibleSize"; + type ReturnObject = SetVisibleSizeReturnObject; + } + impl Method for SetDisabledImageTypes { + const NAME: &'static str = "Emulation.setDisabledImageTypes"; + type ReturnObject = SetDisabledImageTypesReturnObject; + } + impl Method for SetUserAgentOverride { + const NAME: &'static str = "Emulation.setUserAgentOverride"; + type ReturnObject = SetUserAgentOverrideReturnObject; + } + pub mod events { + use super::super::types::*; + use serde::{Deserialize, Serialize}; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct VirtualTimeBudgetExpiredEvent(pub Option); + } + } + pub mod HeadlessExperimental { + use super::types::*; + use super::Page; + use super::Runtime; + use serde::{Deserialize, Serialize}; + use serde_json::Value as Json; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum ScreenshotParamsFormat { + Jpeg, + Png, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ScreenshotParams { + #[serde(skip_serializing_if = "Option::is_none")] + pub format: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub quality: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct BeginFrame { + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub frame_time_ticks: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub interval: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub no_display_updates: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub screenshot: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Disable(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Enable(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct BeginFrameReturnObject { + #[serde(default)] + pub has_damage: bool, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub screenshot_data: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DisableReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct EnableReturnObject {} + impl Method for BeginFrame { + const NAME: &'static str = "HeadlessExperimental.beginFrame"; + type ReturnObject = BeginFrameReturnObject; + } + impl Method for Disable { + const NAME: &'static str = "HeadlessExperimental.disable"; + type ReturnObject = DisableReturnObject; + } + impl Method for Enable { + const NAME: &'static str = "HeadlessExperimental.enable"; + type ReturnObject = EnableReturnObject; + } + pub mod events { + use super::super::types::*; + use serde::{Deserialize, Serialize}; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct NeedsBeginFramesChangedEvent { + pub params: NeedsBeginFramesChangedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct NeedsBeginFramesChangedEventParams { + #[serde(default)] + pub needs_begin_frames: bool, + } + } + } + pub mod IO { + use super::types::*; + use super::Runtime; + use serde::{Deserialize, Serialize}; + use serde_json::Value as Json; + pub type StreamHandle = String; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Close { + pub handle: StreamHandle, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Read { + pub handle: StreamHandle, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub offset: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub size: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ResolveBlob { + pub object_id: Runtime::RemoteObjectId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CloseReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ReadReturnObject { + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub base_64_encoded: Option, + #[serde(default)] + pub data: String, + #[serde(default)] + pub eof: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ResolveBlobReturnObject { + #[serde(default)] + pub uuid: String, + } + impl Method for Close { + const NAME: &'static str = "IO.close"; + type ReturnObject = CloseReturnObject; + } + impl Method for Read { + const NAME: &'static str = "IO.read"; + type ReturnObject = ReadReturnObject; + } + impl Method for ResolveBlob { + const NAME: &'static str = "IO.resolveBlob"; + type ReturnObject = ResolveBlobReturnObject; + } + pub mod events { + use super::super::types::*; + use serde::{Deserialize, Serialize}; + } + } + pub mod IndexedDB { + use super::types::*; + use super::Runtime; + use serde::{Deserialize, Serialize}; + use serde_json::Value as Json; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum KeyType { + Number, + String, + Date, + Array, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum KeyPathType { + Null, + String, + Array, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DatabaseWithObjectStores { + #[serde(default)] + pub name: String, + #[serde(default)] + pub version: JsFloat, + pub object_stores: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ObjectStore { + #[serde(default)] + pub name: String, + pub key_path: KeyPath, + #[serde(default)] + pub auto_increment: bool, + pub indexes: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ObjectStoreIndex { + #[serde(default)] + pub name: String, + pub key_path: KeyPath, + #[serde(default)] + pub unique: bool, + #[serde(default)] + pub multi_entry: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Key { + pub Type: KeyType, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub number: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub string: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub date: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub array: Option>, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct KeyRange { + #[serde(skip_serializing_if = "Option::is_none")] + pub lower: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub upper: Option, + #[serde(default)] + pub lower_open: bool, + #[serde(default)] + pub upper_open: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DataEntry { + pub key: Runtime::RemoteObject, + pub primary_key: Runtime::RemoteObject, + pub value: Runtime::RemoteObject, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct KeyPath { + pub Type: KeyPathType, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub string: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub array: Option>, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ClearObjectStore { + #[serde(default)] + pub security_origin: String, + #[serde(default)] + pub database_name: String, + #[serde(default)] + pub object_store_name: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DeleteDatabase { + #[serde(default)] + pub security_origin: String, + #[serde(default)] + pub database_name: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DeleteObjectStoreEntries { + #[serde(default)] + pub security_origin: String, + #[serde(default)] + pub database_name: String, + #[serde(default)] + pub object_store_name: String, + pub key_range: KeyRange, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Disable(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Enable(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RequestData { + #[serde(default)] + pub security_origin: String, + #[serde(default)] + pub database_name: String, + #[serde(default)] + pub object_store_name: String, + #[serde(default)] + pub index_name: String, + #[serde(default)] + pub skip_count: JsUInt, + #[serde(default)] + pub page_size: JsUInt, + #[serde(skip_serializing_if = "Option::is_none")] + pub key_range: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetMetadata { + #[serde(default)] + pub security_origin: String, + #[serde(default)] + pub database_name: String, + #[serde(default)] + pub object_store_name: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RequestDatabase { + #[serde(default)] + pub security_origin: String, + #[serde(default)] + pub database_name: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RequestDatabaseNames { + #[serde(default)] + pub security_origin: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ClearObjectStoreReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DeleteDatabaseReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DeleteObjectStoreEntriesReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DisableReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct EnableReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RequestDataReturnObject { + pub object_store_data_entries: Vec, + #[serde(default)] + pub has_more: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetMetadataReturnObject { + #[serde(default)] + pub entries_count: JsFloat, + #[serde(default)] + pub key_generator_value: JsFloat, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RequestDatabaseReturnObject { + pub database_with_object_stores: DatabaseWithObjectStores, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RequestDatabaseNamesReturnObject { + pub database_names: Vec, + } + impl Method for ClearObjectStore { + const NAME: &'static str = "IndexedDB.clearObjectStore"; + type ReturnObject = ClearObjectStoreReturnObject; + } + impl Method for DeleteDatabase { + const NAME: &'static str = "IndexedDB.deleteDatabase"; + type ReturnObject = DeleteDatabaseReturnObject; + } + impl Method for DeleteObjectStoreEntries { + const NAME: &'static str = "IndexedDB.deleteObjectStoreEntries"; + type ReturnObject = DeleteObjectStoreEntriesReturnObject; + } + impl Method for Disable { + const NAME: &'static str = "IndexedDB.disable"; + type ReturnObject = DisableReturnObject; + } + impl Method for Enable { + const NAME: &'static str = "IndexedDB.enable"; + type ReturnObject = EnableReturnObject; + } + impl Method for RequestData { + const NAME: &'static str = "IndexedDB.requestData"; + type ReturnObject = RequestDataReturnObject; + } + impl Method for GetMetadata { + const NAME: &'static str = "IndexedDB.getMetadata"; + type ReturnObject = GetMetadataReturnObject; + } + impl Method for RequestDatabase { + const NAME: &'static str = "IndexedDB.requestDatabase"; + type ReturnObject = RequestDatabaseReturnObject; + } + impl Method for RequestDatabaseNames { + const NAME: &'static str = "IndexedDB.requestDatabaseNames"; + type ReturnObject = RequestDatabaseNamesReturnObject; + } + pub mod events { + use super::super::types::*; + use serde::{Deserialize, Serialize}; + } + } + pub mod Input { + use super::types::*; + use serde::{Deserialize, Serialize}; + use serde_json::Value as Json; + pub type TimeSinceEpoch = JsFloat; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum GestureSourceType { + Default, + Touch, + Mouse, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum MouseButton { + None, + Left, + Middle, + Right, + Back, + Forward, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum DispatchDragEventTypeOption { + DragEnter, + DragOver, + Drop, + DragCancel, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum DispatchKeyEventTypeOption { + KeyDown, + KeyUp, + RawKeyDown, + Char, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum DispatchMouseEventTypeOption { + MousePressed, + MouseReleased, + MouseMoved, + MouseWheel, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum DispatchMouseEventPointer_TypeOption { + Mouse, + Pen, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum DispatchTouchEventTypeOption { + TouchStart, + TouchEnd, + TouchMove, + TouchCancel, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum EmulateTouchFromMouseEventTypeOption { + MousePressed, + MouseReleased, + MouseMoved, + MouseWheel, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct TouchPoint { + #[serde(default)] + pub x: JsFloat, + #[serde(default)] + pub y: JsFloat, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub radius_x: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub radius_y: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub rotation_angle: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub force: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub tangential_pressure: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub tilt_x: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub tilt_y: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub twist: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub id: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DragDataItem { + #[serde(default)] + pub mime_type: String, + #[serde(default)] + pub data: String, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub title: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub base_url: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DragData { + pub items: Vec, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub files: Option>, + #[serde(default)] + pub drag_operations_mask: JsUInt, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DispatchDragEvent { + pub Type: DispatchDragEventTypeOption, + #[serde(default)] + pub x: JsFloat, + #[serde(default)] + pub y: JsFloat, + pub data: DragData, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub modifiers: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DispatchKeyEvent { + pub Type: DispatchKeyEventTypeOption, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub modifiers: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub timestamp: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub text: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub unmodified_text: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub key_identifier: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub code: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub key: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub windows_virtual_key_code: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub native_virtual_key_code: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub auto_repeat: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub is_keypad: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub is_system_key: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub location: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub commands: Option>, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct InsertText { + #[serde(default)] + pub text: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ImeSetComposition { + #[serde(default)] + pub text: String, + #[serde(default)] + pub selection_start: JsUInt, + #[serde(default)] + pub selection_end: JsUInt, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub replacement_start: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub replacement_end: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DispatchMouseEvent { + pub Type: DispatchMouseEventTypeOption, + #[serde(default)] + pub x: JsFloat, + #[serde(default)] + pub y: JsFloat, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub modifiers: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub timestamp: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub button: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub buttons: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub click_count: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub force: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub tangential_pressure: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub tilt_x: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub tilt_y: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub twist: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub delta_x: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub delta_y: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub pointer_Type: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DispatchTouchEvent { + pub Type: DispatchTouchEventTypeOption, + pub touch_points: Vec, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub modifiers: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub timestamp: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct EmulateTouchFromMouseEvent { + pub Type: EmulateTouchFromMouseEventTypeOption, + #[serde(default)] + pub x: JsUInt, + #[serde(default)] + pub y: JsUInt, + pub button: MouseButton, + #[serde(skip_serializing_if = "Option::is_none")] + pub timestamp: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub delta_x: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub delta_y: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub modifiers: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub click_count: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetIgnoreInputEvents { + #[serde(default)] + pub ignore: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetInterceptDrags { + #[serde(default)] + pub enabled: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SynthesizePinchGesture { + #[serde(default)] + pub x: JsFloat, + #[serde(default)] + pub y: JsFloat, + #[serde(default)] + pub scale_factor: JsFloat, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub relative_speed: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub gesture_source_Type: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SynthesizeScrollGesture { + #[serde(default)] + pub x: JsFloat, + #[serde(default)] + pub y: JsFloat, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub x_distance: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub y_distance: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub x_overscroll: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub y_overscroll: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub prevent_fling: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub speed: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub gesture_source_Type: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub repeat_count: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub repeat_delay_ms: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub interaction_marker_name: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SynthesizeTapGesture { + #[serde(default)] + pub x: JsFloat, + #[serde(default)] + pub y: JsFloat, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub duration: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub tap_count: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub gesture_source_Type: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DispatchDragEventReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DispatchKeyEventReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct InsertTextReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ImeSetCompositionReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DispatchMouseEventReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DispatchTouchEventReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct EmulateTouchFromMouseEventReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetIgnoreInputEventsReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetInterceptDragsReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SynthesizePinchGestureReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SynthesizeScrollGestureReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SynthesizeTapGestureReturnObject {} + impl Method for DispatchDragEvent { + const NAME: &'static str = "Input.dispatchDragEvent"; + type ReturnObject = DispatchDragEventReturnObject; + } + impl Method for DispatchKeyEvent { + const NAME: &'static str = "Input.dispatchKeyEvent"; + type ReturnObject = DispatchKeyEventReturnObject; + } + impl Method for InsertText { + const NAME: &'static str = "Input.insertText"; + type ReturnObject = InsertTextReturnObject; + } + impl Method for ImeSetComposition { + const NAME: &'static str = "Input.imeSetComposition"; + type ReturnObject = ImeSetCompositionReturnObject; + } + impl Method for DispatchMouseEvent { + const NAME: &'static str = "Input.dispatchMouseEvent"; + type ReturnObject = DispatchMouseEventReturnObject; + } + impl Method for DispatchTouchEvent { + const NAME: &'static str = "Input.dispatchTouchEvent"; + type ReturnObject = DispatchTouchEventReturnObject; + } + impl Method for EmulateTouchFromMouseEvent { + const NAME: &'static str = "Input.emulateTouchFromMouseEvent"; + type ReturnObject = EmulateTouchFromMouseEventReturnObject; + } + impl Method for SetIgnoreInputEvents { + const NAME: &'static str = "Input.setIgnoreInputEvents"; + type ReturnObject = SetIgnoreInputEventsReturnObject; + } + impl Method for SetInterceptDrags { + const NAME: &'static str = "Input.setInterceptDrags"; + type ReturnObject = SetInterceptDragsReturnObject; + } + impl Method for SynthesizePinchGesture { + const NAME: &'static str = "Input.synthesizePinchGesture"; + type ReturnObject = SynthesizePinchGestureReturnObject; + } + impl Method for SynthesizeScrollGesture { + const NAME: &'static str = "Input.synthesizeScrollGesture"; + type ReturnObject = SynthesizeScrollGestureReturnObject; + } + impl Method for SynthesizeTapGesture { + const NAME: &'static str = "Input.synthesizeTapGesture"; + type ReturnObject = SynthesizeTapGestureReturnObject; + } + pub mod events { + use super::super::types::*; + use serde::{Deserialize, Serialize}; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct DragInterceptedEvent { + pub params: DragInterceptedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DragInterceptedEventParams { + pub data: super::DragData, + } + } + } + pub mod Inspector { + use super::types::*; + use serde::{Deserialize, Serialize}; + use serde_json::Value as Json; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Disable(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Enable(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DisableReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct EnableReturnObject {} + impl Method for Disable { + const NAME: &'static str = "Inspector.disable"; + type ReturnObject = DisableReturnObject; + } + impl Method for Enable { + const NAME: &'static str = "Inspector.enable"; + type ReturnObject = EnableReturnObject; + } + pub mod events { + use super::super::types::*; + use serde::{Deserialize, Serialize}; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct DetachedEvent { + pub params: DetachedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DetachedEventParams { + #[serde(default)] + pub reason: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct TargetCrashedEvent(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct TargetReloadedAfterCrashEvent(pub Option); + } + } + pub mod LayerTree { + use super::types::*; + use super::DOM; + use serde::{Deserialize, Serialize}; + use serde_json::Value as Json; + pub type LayerId = String; + pub type SnapshotId = String; + pub type PaintProfile = Vec; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "PascalCase")] + pub enum ScrollRectType { + RepaintsOnScroll, + TouchEventHandler, + WheelEventHandler, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ScrollRect { + pub rect: DOM::Rect, + pub Type: ScrollRectType, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StickyPositionConstraint { + pub sticky_box_rect: DOM::Rect, + pub containing_block_rect: DOM::Rect, + #[serde(skip_serializing_if = "Option::is_none")] + pub nearest_layer_shifting_sticky_box: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub nearest_layer_shifting_containing_block: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct PictureTile { + #[serde(default)] + pub x: JsFloat, + #[serde(default)] + pub y: JsFloat, + #[serde(default)] + pub picture: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Layer { + pub layer_id: LayerId, + #[serde(skip_serializing_if = "Option::is_none")] + pub parent_layer_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub backend_node_id: Option, + #[serde(default)] + pub offset_x: JsFloat, + #[serde(default)] + pub offset_y: JsFloat, + #[serde(default)] + pub width: JsFloat, + #[serde(default)] + pub height: JsFloat, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub transform: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub anchor_x: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub anchor_y: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub anchor_z: Option, + #[serde(default)] + pub paint_count: JsUInt, + #[serde(default)] + pub draws_content: bool, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub invisible: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub scroll_rects: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + pub sticky_position_constraint: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CompositingReasons { + pub layer_id: LayerId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Disable(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Enable(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct LoadSnapshot { + pub tiles: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct MakeSnapshot { + pub layer_id: LayerId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ProfileSnapshot { + pub snapshot_id: SnapshotId, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub min_repeat_count: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub min_duration: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub clip_rect: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ReleaseSnapshot { + pub snapshot_id: SnapshotId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ReplaySnapshot { + pub snapshot_id: SnapshotId, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub from_step: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub to_step: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub scale: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SnapshotCommandLog { + pub snapshot_id: SnapshotId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CompositingReasonsReturnObject { + pub compositing_reasons: Vec, + pub compositing_reason_ids: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DisableReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct EnableReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct LoadSnapshotReturnObject { + pub snapshot_id: SnapshotId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct MakeSnapshotReturnObject { + pub snapshot_id: SnapshotId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ProfileSnapshotReturnObject { + pub timings: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ReleaseSnapshotReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ReplaySnapshotReturnObject { + #[serde(default)] + pub data_url: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SnapshotCommandLogReturnObject {} + impl Method for CompositingReasons { + const NAME: &'static str = "LayerTree.compositingReasons"; + type ReturnObject = CompositingReasonsReturnObject; + } + impl Method for Disable { + const NAME: &'static str = "LayerTree.disable"; + type ReturnObject = DisableReturnObject; + } + impl Method for Enable { + const NAME: &'static str = "LayerTree.enable"; + type ReturnObject = EnableReturnObject; + } + impl Method for LoadSnapshot { + const NAME: &'static str = "LayerTree.loadSnapshot"; + type ReturnObject = LoadSnapshotReturnObject; + } + impl Method for MakeSnapshot { + const NAME: &'static str = "LayerTree.makeSnapshot"; + type ReturnObject = MakeSnapshotReturnObject; + } + impl Method for ProfileSnapshot { + const NAME: &'static str = "LayerTree.profileSnapshot"; + type ReturnObject = ProfileSnapshotReturnObject; + } + impl Method for ReleaseSnapshot { + const NAME: &'static str = "LayerTree.releaseSnapshot"; + type ReturnObject = ReleaseSnapshotReturnObject; + } + impl Method for ReplaySnapshot { + const NAME: &'static str = "LayerTree.replaySnapshot"; + type ReturnObject = ReplaySnapshotReturnObject; + } + impl Method for SnapshotCommandLog { + const NAME: &'static str = "LayerTree.snapshotCommandLog"; + type ReturnObject = SnapshotCommandLogReturnObject; + } + pub mod events { + use super::super::types::*; + use serde::{Deserialize, Serialize}; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct LayerPaintedEvent { + pub params: LayerPaintedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct LayerPaintedEventParams { + pub layer_id: super::LayerId, + pub clip: super::super::DOM::Rect, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct LayerTreeDidChangeEvent { + pub params: LayerTreeDidChangeEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct LayerTreeDidChangeEventParams { + #[serde(skip_serializing_if = "Option::is_none")] + pub layers: Option>, + } + } + } + pub mod Log { + use super::types::*; + use super::Network; + use super::Runtime; + use serde::{Deserialize, Serialize}; + use serde_json::Value as Json; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum LogEntrySource { + Xml, + Javascript, + Network, + Storage, + Appcache, + Rendering, + Security, + Deprecation, + Worker, + Violation, + Intervention, + Recommendation, + Other, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum LogEntryLevel { + Verbose, + Info, + Warning, + Error, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum LogEntryCategory { + Cors, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum ViolationSettingName { + LongTask, + LongLayout, + BlockedEvent, + BlockedParser, + DiscouragedApiUse, + Handler, + RecurringHandler, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct LogEntry { + pub source: LogEntrySource, + pub level: LogEntryLevel, + #[serde(default)] + pub text: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub category: Option, + pub timestamp: Runtime::Timestamp, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub url: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub line_number: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub stack_trace: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub network_request_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub worker_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub args: Option>, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ViolationSetting { + pub name: ViolationSettingName, + #[serde(default)] + pub threshold: JsFloat, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Clear(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Disable(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Enable(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StartViolationsReport { + pub config: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StopViolationsReport(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ClearReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DisableReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct EnableReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StartViolationsReportReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StopViolationsReportReturnObject {} + impl Method for Clear { + const NAME: &'static str = "Log.clear"; + type ReturnObject = ClearReturnObject; + } + impl Method for Disable { + const NAME: &'static str = "Log.disable"; + type ReturnObject = DisableReturnObject; + } + impl Method for Enable { + const NAME: &'static str = "Log.enable"; + type ReturnObject = EnableReturnObject; + } + impl Method for StartViolationsReport { + const NAME: &'static str = "Log.startViolationsReport"; + type ReturnObject = StartViolationsReportReturnObject; + } + impl Method for StopViolationsReport { + const NAME: &'static str = "Log.stopViolationsReport"; + type ReturnObject = StopViolationsReportReturnObject; + } + pub mod events { + use super::super::types::*; + use serde::{Deserialize, Serialize}; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct EntryAddedEvent { + pub params: EntryAddedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct EntryAddedEventParams { + pub entry: super::LogEntry, + } + } + } + pub mod Memory { + use super::types::*; + use serde::{Deserialize, Serialize}; + use serde_json::Value as Json; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum PressureLevel { + Moderate, + Critical, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SamplingProfileNode { + #[serde(default)] + pub size: JsFloat, + #[serde(default)] + pub total: JsFloat, + #[serde(default)] + pub stack: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SamplingProfile { + pub samples: Vec, + pub modules: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Module { + #[serde(default)] + pub name: String, + #[serde(default)] + pub uuid: String, + #[serde(default)] + pub base_address: String, + #[serde(default)] + pub size: JsFloat, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetDOMCounters(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct PrepareForLeakDetection(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ForciblyPurgeJavaScriptMemory(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetPressureNotificationsSuppressed { + #[serde(default)] + pub suppressed: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SimulatePressureNotification { + pub level: PressureLevel, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StartSampling { + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub sampling_interval: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub suppress_randomness: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StopSampling(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetAllTimeSamplingProfile(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetBrowserSamplingProfile(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetSamplingProfile(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetDOMCountersReturnObject { + #[serde(default)] + pub documents: JsUInt, + #[serde(default)] + pub nodes: JsUInt, + #[serde(default)] + pub js_event_listeners: JsUInt, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct PrepareForLeakDetectionReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ForciblyPurgeJavaScriptMemoryReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetPressureNotificationsSuppressedReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SimulatePressureNotificationReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StartSamplingReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StopSamplingReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetAllTimeSamplingProfileReturnObject { + pub profile: SamplingProfile, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetBrowserSamplingProfileReturnObject { + pub profile: SamplingProfile, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetSamplingProfileReturnObject { + pub profile: SamplingProfile, + } + impl Method for GetDOMCounters { + const NAME: &'static str = "Memory.getDOMCounters"; + type ReturnObject = GetDOMCountersReturnObject; + } + impl Method for PrepareForLeakDetection { + const NAME: &'static str = "Memory.prepareForLeakDetection"; + type ReturnObject = PrepareForLeakDetectionReturnObject; + } + impl Method for ForciblyPurgeJavaScriptMemory { + const NAME: &'static str = "Memory.forciblyPurgeJavaScriptMemory"; + type ReturnObject = ForciblyPurgeJavaScriptMemoryReturnObject; + } + impl Method for SetPressureNotificationsSuppressed { + const NAME: &'static str = "Memory.setPressureNotificationsSuppressed"; + type ReturnObject = SetPressureNotificationsSuppressedReturnObject; + } + impl Method for SimulatePressureNotification { + const NAME: &'static str = "Memory.simulatePressureNotification"; + type ReturnObject = SimulatePressureNotificationReturnObject; + } + impl Method for StartSampling { + const NAME: &'static str = "Memory.startSampling"; + type ReturnObject = StartSamplingReturnObject; + } + impl Method for StopSampling { + const NAME: &'static str = "Memory.stopSampling"; + type ReturnObject = StopSamplingReturnObject; + } + impl Method for GetAllTimeSamplingProfile { + const NAME: &'static str = "Memory.getAllTimeSamplingProfile"; + type ReturnObject = GetAllTimeSamplingProfileReturnObject; + } + impl Method for GetBrowserSamplingProfile { + const NAME: &'static str = "Memory.getBrowserSamplingProfile"; + type ReturnObject = GetBrowserSamplingProfileReturnObject; + } + impl Method for GetSamplingProfile { + const NAME: &'static str = "Memory.getSamplingProfile"; + type ReturnObject = GetSamplingProfileReturnObject; + } + pub mod events { + use super::super::types::*; + use serde::{Deserialize, Serialize}; + } + } + pub mod Network { + use super::types::*; + use super::Debugger; + use super::Emulation; + use super::Network; + use super::Page; + use super::Runtime; + use super::Security; + use super::IO; + use serde::{Deserialize, Serialize}; + use serde_json::Value as Json; + pub type LoaderId = String; + pub type RequestId = String; + pub type InterceptionId = String; + pub type TimeSinceEpoch = JsFloat; + pub type MonotonicTime = JsFloat; + pub type ReportId = String; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "PascalCase")] + pub enum ResourceType { + Document, + Stylesheet, + Image, + Media, + Font, + Script, + TextTrack, + Xhr, + Fetch, + EventSource, + WebSocket, + Manifest, + SignedExchange, + Ping, + CspViolationReport, + Preflight, + Other, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "PascalCase")] + pub enum ErrorReason { + Failed, + Aborted, + TimedOut, + AccessDenied, + ConnectionClosed, + ConnectionReset, + ConnectionRefused, + ConnectionAborted, + ConnectionFailed, + NameNotResolved, + InternetDisconnected, + AddressUnreachable, + BlockedByClient, + BlockedByResponse, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum ConnectionType { + None, + Cellular2G, + Cellular3G, + Cellular4G, + Bluetooth, + Ethernet, + Wifi, + Wimax, + Other, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "PascalCase")] + pub enum CookieSameSite { + Strict, + Lax, + None, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "PascalCase")] + pub enum CookiePriority { + Low, + Medium, + High, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "PascalCase")] + pub enum CookieSourceScheme { + Unset, + NonSecure, + Secure, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "PascalCase")] + pub enum ResourcePriority { + VeryLow, + Low, + Medium, + High, + VeryHigh, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "kebab-case")] + pub enum RequestReferrerPolicy { + UnsafeUrl, + NoReferrerWhenDowngrade, + NoReferrer, + Origin, + OriginWhenCrossOrigin, + SameOrigin, + StrictOrigin, + StrictOriginWhenCrossOrigin, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "kebab-case")] + pub enum CertificateTransparencyCompliance { + Unknown, + NotCompliant, + Compliant, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "kebab-case")] + pub enum BlockedReason { + Other, + Csp, + MixedContent, + Origin, + Inspector, + SubresourceFilter, + ContentType, + CoepFrameResourceNeedsCoepHeader, + CoopSandboxedIframeCannotNavigateToCoopPage, + CorpNotSameOrigin, + CorpNotSameOriginAfterDefaultedToSameOriginByCoep, + CorpNotSameSite, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "PascalCase")] + pub enum CorsError { + DisallowedByMode, + InvalidResponse, + WildcardOriginNotAllowed, + MissingAllowOriginHeader, + MultipleAllowOriginValues, + InvalidAllowOriginValue, + AllowOriginMismatch, + InvalidAllowCredentials, + CorsDisabledScheme, + PreflightInvalidStatus, + PreflightDisallowedRedirect, + PreflightWildcardOriginNotAllowed, + PreflightMissingAllowOriginHeader, + PreflightMultipleAllowOriginValues, + PreflightInvalidAllowOriginValue, + PreflightAllowOriginMismatch, + PreflightInvalidAllowCredentials, + PreflightMissingAllowExternal, + PreflightInvalidAllowExternal, + InvalidAllowMethodsPreflightResponse, + InvalidAllowHeadersPreflightResponse, + MethodDisallowedByPreflightResponse, + HeaderDisallowedByPreflightResponse, + RedirectContainsCredentials, + InsecurePrivateNetwork, + InvalidPrivateNetworkAccess, + UnexpectedPrivateNetworkAccess, + NoCorsRedirectModeNotFollow, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "kebab-case")] + pub enum ServiceWorkerResponseSource { + CacheStorage, + HttpCache, + FallbackCode, + Network, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "PascalCase")] + pub enum TrustTokenParamsRefreshPolicy { + UseCached, + Refresh, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "PascalCase")] + pub enum TrustTokenOperationType { + Issuance, + Redemption, + Signing, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "PascalCase")] + pub enum InitiatorType { + Parser, + Script, + Preload, + SignedExchange, + Preflight, + Other, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "PascalCase")] + pub enum SetCookieBlockedReason { + SecureOnly, + SameSiteStrict, + SameSiteLax, + SameSiteUnspecifiedTreatedAsLax, + SameSiteNoneInsecure, + UserPreferences, + SyntaxError, + SchemeNotSupported, + OverwriteSecure, + InvalidDomain, + InvalidPrefix, + UnknownError, + SchemefulSameSiteStrict, + SchemefulSameSiteLax, + SchemefulSameSiteUnspecifiedTreatedAsLax, + SamePartyFromCrossPartyContext, + SamePartyConflictsWithOtherAttributes, + NameValuePairExceedsMaxSize, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "PascalCase")] + pub enum CookieBlockedReason { + SecureOnly, + NotOnPath, + DomainMismatch, + SameSiteStrict, + SameSiteLax, + SameSiteUnspecifiedTreatedAsLax, + SameSiteNoneInsecure, + UserPreferences, + UnknownError, + SchemefulSameSiteStrict, + SchemefulSameSiteLax, + SchemefulSameSiteUnspecifiedTreatedAsLax, + SamePartyFromCrossPartyContext, + NameValuePairExceedsMaxSize, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "PascalCase")] + pub enum AuthChallengeSource { + Server, + Proxy, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "PascalCase")] + pub enum AuthChallengeResponseResponse { + Default, + CancelAuth, + ProvideCredentials, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "PascalCase")] + pub enum InterceptionStage { + Request, + HeadersReceived, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum SignedExchangeErrorField { + SignatureSig, + SignatureIntegrity, + SignatureCertUrl, + SignatureCertSha256, + SignatureValidityUrl, + SignatureTimestamps, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum ContentEncoding { + Deflate, + Gzip, + Br, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "PascalCase")] + pub enum PrivateNetworkRequestPolicy { + Allow, + BlockFromInsecureToMorePrivate, + WarnFromInsecureToMorePrivate, + PreflightBlock, + PreflightWarn, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "PascalCase")] + pub enum IPAddressSpace { + Local, + Private, + Public, + Unknown, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "PascalCase")] + pub enum CrossOriginOpenerPolicyValue { + SameOrigin, + SameOriginAllowPopups, + UnsafeNone, + SameOriginPlusCoep, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "PascalCase")] + pub enum CrossOriginEmbedderPolicyValue { + None, + Credentialless, + RequireCorp, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "PascalCase")] + pub enum ReportStatus { + Queued, + Pending, + MarkedForRemoval, + Success, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "PascalCase")] + pub enum TrustTokenOperationDoneEventStatusOption { + Ok, + InvalidArgument, + FailedPrecondition, + ResourceExhausted, + AlreadyExists, + Unavailable, + BadResponse, + InternalError, + UnknownError, + FulfilledLocally, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Headers(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ResourceTiming { + #[serde(default)] + pub request_time: JsFloat, + #[serde(default)] + pub proxy_start: JsFloat, + #[serde(default)] + pub proxy_end: JsFloat, + #[serde(default)] + pub dns_start: JsFloat, + #[serde(default)] + pub dns_end: JsFloat, + #[serde(default)] + pub connect_start: JsFloat, + #[serde(default)] + pub connect_end: JsFloat, + #[serde(default)] + pub ssl_start: JsFloat, + #[serde(default)] + pub ssl_end: JsFloat, + #[serde(default)] + pub worker_start: JsFloat, + #[serde(default)] + pub worker_ready: JsFloat, + #[serde(default)] + pub worker_fetch_start: JsFloat, + #[serde(default)] + pub worker_respond_with_settled: JsFloat, + #[serde(default)] + pub send_start: JsFloat, + #[serde(default)] + pub send_end: JsFloat, + #[serde(default)] + pub push_start: JsFloat, + #[serde(default)] + pub push_end: JsFloat, + #[serde(default)] + pub receive_headers_end: JsFloat, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct PostDataEntry { + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub bytes: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Request { + #[serde(default)] + pub url: String, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub url_fragment: Option, + #[serde(default)] + pub method: String, + pub headers: Headers, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub post_data: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub has_post_data: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub post_data_entries: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + pub mixed_content_Type: Option, + pub initial_priority: ResourcePriority, + pub referrer_policy: RequestReferrerPolicy, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub is_link_preload: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub trust_token_params: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub is_same_site: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SignedCertificateTimestamp { + #[serde(default)] + pub status: String, + #[serde(default)] + pub origin: String, + #[serde(default)] + pub log_description: String, + #[serde(default)] + pub log_id: String, + #[serde(default)] + pub timestamp: JsFloat, + #[serde(default)] + pub hash_algorithm: String, + #[serde(default)] + pub signature_algorithm: String, + #[serde(default)] + pub signature_data: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SecurityDetails { + #[serde(default)] + pub protocol: String, + #[serde(default)] + pub key_exchange: String, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub key_exchange_group: Option, + #[serde(default)] + pub cipher: String, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub mac: Option, + pub certificate_id: Security::CertificateId, + #[serde(default)] + pub subject_name: String, + #[serde(default)] + pub san_list: Vec, + #[serde(default)] + pub issuer: String, + pub valid_from: TimeSinceEpoch, + pub valid_to: TimeSinceEpoch, + pub signed_certificate_timestamp_list: Vec, + pub certificate_transparency_compliance: CertificateTransparencyCompliance, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CorsErrorStatus { + pub cors_error: CorsError, + #[serde(default)] + pub failed_parameter: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct TrustTokenParams { + pub Type: TrustTokenOperationType, + pub refresh_policy: TrustTokenParamsRefreshPolicy, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub issuers: Option>, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Response { + #[serde(default)] + pub url: String, + #[serde(default)] + pub status: JsUInt, + #[serde(default)] + pub status_text: String, + pub headers: Headers, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub headers_text: Option, + #[serde(default)] + pub mime_type: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub request_headers: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub request_headers_text: Option, + #[serde(default)] + pub connection_reused: bool, + #[serde(default)] + pub connection_id: JsFloat, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub remote_ip_address: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub remote_port: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub from_disk_cache: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub from_service_worker: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub from_prefetch_cache: Option, + #[serde(default)] + pub encoded_data_length: JsFloat, + #[serde(skip_serializing_if = "Option::is_none")] + pub timing: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub service_worker_response_source: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub response_time: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub cache_storage_cache_name: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub protocol: Option, + pub security_state: Security::SecurityState, + #[serde(skip_serializing_if = "Option::is_none")] + pub security_details: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct WebSocketRequest { + pub headers: Headers, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct WebSocketResponse { + #[serde(default)] + pub status: JsUInt, + #[serde(default)] + pub status_text: String, + pub headers: Headers, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub headers_text: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub request_headers: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub request_headers_text: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct WebSocketFrame { + #[serde(default)] + pub opcode: JsFloat, + #[serde(default)] + pub mask: bool, + #[serde(default)] + pub payload_data: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CachedResource { + #[serde(default)] + pub url: String, + pub Type: ResourceType, + #[serde(skip_serializing_if = "Option::is_none")] + pub response: Option, + #[serde(default)] + pub body_size: JsFloat, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Initiator { + pub Type: InitiatorType, + #[serde(skip_serializing_if = "Option::is_none")] + pub stack: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub url: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub line_number: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub column_number: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub request_id: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Cookie { + #[serde(default)] + pub name: String, + #[serde(default)] + pub value: String, + #[serde(default)] + pub domain: String, + #[serde(default)] + pub path: String, + #[serde(default)] + pub expires: JsFloat, + #[serde(default)] + pub size: JsUInt, + #[serde(default)] + pub http_only: bool, + #[serde(default)] + pub secure: bool, + #[serde(default)] + pub session: bool, + #[serde(skip_serializing_if = "Option::is_none")] + pub same_site: Option, + pub priority: CookiePriority, + #[serde(default)] + pub same_party: bool, + pub source_scheme: CookieSourceScheme, + #[serde(default)] + pub source_port: JsUInt, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub partition_key: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub partition_key_opaque: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct BlockedSetCookieWithReason { + pub blocked_reasons: Vec, + #[serde(default)] + pub cookie_line: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub cookie: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct BlockedCookieWithReason { + pub blocked_reasons: Vec, + pub cookie: Cookie, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CookieParam { + #[serde(default)] + pub name: String, + #[serde(default)] + pub value: String, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub url: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub domain: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub path: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub secure: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub http_only: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub same_site: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub expires: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub priority: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub same_party: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub source_scheme: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub source_port: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub partition_key: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct AuthChallenge { + #[serde(skip_serializing_if = "Option::is_none")] + pub source: Option, + #[serde(default)] + pub origin: String, + #[serde(default)] + pub scheme: String, + #[serde(default)] + pub realm: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct AuthChallengeResponse { + pub response: AuthChallengeResponseResponse, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub username: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub password: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RequestPattern { + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub url_pattern: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub resource_Type: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub interception_stage: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SignedExchangeSignature { + #[serde(default)] + pub label: String, + #[serde(default)] + pub signature: String, + #[serde(default)] + pub integrity: String, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub cert_url: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub cert_sha_256: Option, + #[serde(default)] + pub validity_url: String, + #[serde(default)] + pub date: JsUInt, + #[serde(default)] + pub expires: JsUInt, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub certificates: Option>, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SignedExchangeHeader { + #[serde(default)] + pub request_url: String, + #[serde(default)] + pub response_code: JsUInt, + pub response_headers: Headers, + pub signatures: Vec, + #[serde(default)] + pub header_integrity: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SignedExchangeError { + #[serde(default)] + pub message: String, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub signature_index: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub error_field: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SignedExchangeInfo { + pub outer_response: Response, + #[serde(skip_serializing_if = "Option::is_none")] + pub header: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub security_details: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub errors: Option>, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ConnectTiming { + #[serde(default)] + pub request_time: JsFloat, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ClientSecurityState { + #[serde(default)] + pub initiator_is_secure_context: bool, + pub initiator_ip_address_space: IPAddressSpace, + pub private_network_request_policy: PrivateNetworkRequestPolicy, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CrossOriginOpenerPolicyStatus { + pub value: CrossOriginOpenerPolicyValue, + pub report_only_value: CrossOriginOpenerPolicyValue, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub reporting_endpoint: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub report_only_reporting_endpoint: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CrossOriginEmbedderPolicyStatus { + pub value: CrossOriginEmbedderPolicyValue, + pub report_only_value: CrossOriginEmbedderPolicyValue, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub reporting_endpoint: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub report_only_reporting_endpoint: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SecurityIsolationStatus { + #[serde(skip_serializing_if = "Option::is_none")] + pub coop: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub coep: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ReportingApiReport { + pub id: ReportId, + #[serde(default)] + pub initiator_url: String, + #[serde(default)] + pub destination: String, + #[serde(default)] + pub Type: String, + pub timestamp: Network::TimeSinceEpoch, + #[serde(default)] + pub depth: JsUInt, + #[serde(default)] + pub completed_attempts: JsUInt, + pub status: ReportStatus, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ReportingApiEndpoint { + #[serde(default)] + pub url: String, + #[serde(default)] + pub group_name: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct LoadNetworkResourcePageResult { + #[serde(default)] + pub success: bool, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub net_error: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub net_error_name: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub http_status_code: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub stream: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub headers: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct LoadNetworkResourceOptions { + #[serde(default)] + pub disable_cache: bool, + #[serde(default)] + pub include_credentials: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetAcceptedEncodings { + pub encodings: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ClearAcceptedEncodingsOverride(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CanClearBrowserCache(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CanClearBrowserCookies(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CanEmulateNetworkConditions(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ClearBrowserCache(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ClearBrowserCookies(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ContinueInterceptedRequest { + pub interception_id: InterceptionId, + #[serde(skip_serializing_if = "Option::is_none")] + pub error_reason: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub raw_response: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub url: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub method: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub post_data: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub headers: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub auth_challenge_response: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DeleteCookies { + #[serde(default)] + pub name: String, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub url: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub domain: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub path: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Disable(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct EmulateNetworkConditions { + #[serde(default)] + pub offline: bool, + #[serde(default)] + pub latency: JsFloat, + #[serde(default)] + pub download_throughput: JsFloat, + #[serde(default)] + pub upload_throughput: JsFloat, + #[serde(skip_serializing_if = "Option::is_none")] + pub connection_Type: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Enable { + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub max_total_buffer_size: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub max_resource_buffer_size: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub max_post_data_size: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetAllCookies(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetCertificate { + #[serde(default)] + pub origin: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetCookies { + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub urls: Option>, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetResponseBody { + pub request_id: RequestId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetRequestPostData { + pub request_id: RequestId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetResponseBodyForInterception { + pub interception_id: InterceptionId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct TakeResponseBodyForInterceptionAsStream { + pub interception_id: InterceptionId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ReplayXHR { + pub request_id: RequestId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SearchInResponseBody { + pub request_id: RequestId, + #[serde(default)] + pub query: String, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub case_sensitive: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub is_regex: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetBlockedURLs { + #[serde(default)] + pub urls: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetBypassServiceWorker { + #[serde(default)] + pub bypass: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetCacheDisabled { + #[serde(default)] + pub cache_disabled: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetCookie { + #[serde(default)] + pub name: String, + #[serde(default)] + pub value: String, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub url: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub domain: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub path: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub secure: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub http_only: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub same_site: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub expires: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub priority: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub same_party: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub source_scheme: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub source_port: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub partition_key: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetCookies { + pub cookies: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetExtraHTTPHeaders { + pub headers: Headers, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetAttachDebugStack { + #[serde(default)] + pub enabled: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetRequestInterception { + pub patterns: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetUserAgentOverride { + #[serde(default)] + pub user_agent: String, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub accept_language: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub platform: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub user_agent_metadata: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetSecurityIsolationStatus { + #[serde(skip_serializing_if = "Option::is_none")] + pub frame_id: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct EnableReportingApi { + #[serde(default)] + pub enable: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct LoadNetworkResource { + #[serde(skip_serializing_if = "Option::is_none")] + pub frame_id: Option, + #[serde(default)] + pub url: String, + pub options: LoadNetworkResourceOptions, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetAcceptedEncodingsReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ClearAcceptedEncodingsOverrideReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CanClearBrowserCacheReturnObject { + #[serde(default)] + pub result: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CanClearBrowserCookiesReturnObject { + #[serde(default)] + pub result: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CanEmulateNetworkConditionsReturnObject { + #[serde(default)] + pub result: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ClearBrowserCacheReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ClearBrowserCookiesReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ContinueInterceptedRequestReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DeleteCookiesReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DisableReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct EmulateNetworkConditionsReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct EnableReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetAllCookiesReturnObject { + pub cookies: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetCertificateReturnObject { + pub table_names: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetCookiesReturnObject { + pub cookies: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetResponseBodyReturnObject { + #[serde(default)] + pub body: String, + #[serde(default)] + pub base_64_encoded: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetRequestPostDataReturnObject { + #[serde(default)] + pub post_data: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetResponseBodyForInterceptionReturnObject { + #[serde(default)] + pub body: String, + #[serde(default)] + pub base_64_encoded: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct TakeResponseBodyForInterceptionAsStreamReturnObject { + pub stream: IO::StreamHandle, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ReplayXHRReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SearchInResponseBodyReturnObject { + pub result: Debugger::SearchMatch, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetBlockedURLsReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetBypassServiceWorkerReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetCacheDisabledReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetCookieReturnObject { + #[serde(default)] + pub success: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetCookiesReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetExtraHTTPHeadersReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetAttachDebugStackReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetRequestInterceptionReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetUserAgentOverrideReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetSecurityIsolationStatusReturnObject { + pub status: SecurityIsolationStatus, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct EnableReportingApiReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct LoadNetworkResourceReturnObject { + pub resource: LoadNetworkResourcePageResult, + } + impl Method for SetAcceptedEncodings { + const NAME: &'static str = "Network.setAcceptedEncodings"; + type ReturnObject = SetAcceptedEncodingsReturnObject; + } + impl Method for ClearAcceptedEncodingsOverride { + const NAME: &'static str = "Network.clearAcceptedEncodingsOverride"; + type ReturnObject = ClearAcceptedEncodingsOverrideReturnObject; + } + impl Method for CanClearBrowserCache { + const NAME: &'static str = "Network.canClearBrowserCache"; + type ReturnObject = CanClearBrowserCacheReturnObject; + } + impl Method for CanClearBrowserCookies { + const NAME: &'static str = "Network.canClearBrowserCookies"; + type ReturnObject = CanClearBrowserCookiesReturnObject; + } + impl Method for CanEmulateNetworkConditions { + const NAME: &'static str = "Network.canEmulateNetworkConditions"; + type ReturnObject = CanEmulateNetworkConditionsReturnObject; + } + impl Method for ClearBrowserCache { + const NAME: &'static str = "Network.clearBrowserCache"; + type ReturnObject = ClearBrowserCacheReturnObject; + } + impl Method for ClearBrowserCookies { + const NAME: &'static str = "Network.clearBrowserCookies"; + type ReturnObject = ClearBrowserCookiesReturnObject; + } + impl Method for ContinueInterceptedRequest { + const NAME: &'static str = "Network.continueInterceptedRequest"; + type ReturnObject = ContinueInterceptedRequestReturnObject; + } + impl Method for DeleteCookies { + const NAME: &'static str = "Network.deleteCookies"; + type ReturnObject = DeleteCookiesReturnObject; + } + impl Method for Disable { + const NAME: &'static str = "Network.disable"; + type ReturnObject = DisableReturnObject; + } + impl Method for EmulateNetworkConditions { + const NAME: &'static str = "Network.emulateNetworkConditions"; + type ReturnObject = EmulateNetworkConditionsReturnObject; + } + impl Method for Enable { + const NAME: &'static str = "Network.enable"; + type ReturnObject = EnableReturnObject; + } + impl Method for GetAllCookies { + const NAME: &'static str = "Network.getAllCookies"; + type ReturnObject = GetAllCookiesReturnObject; + } + impl Method for GetCertificate { + const NAME: &'static str = "Network.getCertificate"; + type ReturnObject = GetCertificateReturnObject; + } + impl Method for GetCookies { + const NAME: &'static str = "Network.getCookies"; + type ReturnObject = GetCookiesReturnObject; + } + impl Method for GetResponseBody { + const NAME: &'static str = "Network.getResponseBody"; + type ReturnObject = GetResponseBodyReturnObject; + } + impl Method for GetRequestPostData { + const NAME: &'static str = "Network.getRequestPostData"; + type ReturnObject = GetRequestPostDataReturnObject; + } + impl Method for GetResponseBodyForInterception { + const NAME: &'static str = "Network.getResponseBodyForInterception"; + type ReturnObject = GetResponseBodyForInterceptionReturnObject; + } + impl Method for TakeResponseBodyForInterceptionAsStream { + const NAME: &'static str = "Network.takeResponseBodyForInterceptionAsStream"; + type ReturnObject = TakeResponseBodyForInterceptionAsStreamReturnObject; + } + impl Method for ReplayXHR { + const NAME: &'static str = "Network.replayXHR"; + type ReturnObject = ReplayXHRReturnObject; + } + impl Method for SearchInResponseBody { + const NAME: &'static str = "Network.searchInResponseBody"; + type ReturnObject = SearchInResponseBodyReturnObject; + } + impl Method for SetBlockedURLs { + const NAME: &'static str = "Network.setBlockedURLs"; + type ReturnObject = SetBlockedURLsReturnObject; + } + impl Method for SetBypassServiceWorker { + const NAME: &'static str = "Network.setBypassServiceWorker"; + type ReturnObject = SetBypassServiceWorkerReturnObject; + } + impl Method for SetCacheDisabled { + const NAME: &'static str = "Network.setCacheDisabled"; + type ReturnObject = SetCacheDisabledReturnObject; + } + impl Method for SetCookie { + const NAME: &'static str = "Network.setCookie"; + type ReturnObject = SetCookieReturnObject; + } + impl Method for SetCookies { + const NAME: &'static str = "Network.setCookies"; + type ReturnObject = SetCookiesReturnObject; + } + impl Method for SetExtraHTTPHeaders { + const NAME: &'static str = "Network.setExtraHTTPHeaders"; + type ReturnObject = SetExtraHTTPHeadersReturnObject; + } + impl Method for SetAttachDebugStack { + const NAME: &'static str = "Network.setAttachDebugStack"; + type ReturnObject = SetAttachDebugStackReturnObject; + } + impl Method for SetRequestInterception { + const NAME: &'static str = "Network.setRequestInterception"; + type ReturnObject = SetRequestInterceptionReturnObject; + } + impl Method for SetUserAgentOverride { + const NAME: &'static str = "Network.setUserAgentOverride"; + type ReturnObject = SetUserAgentOverrideReturnObject; + } + impl Method for GetSecurityIsolationStatus { + const NAME: &'static str = "Network.getSecurityIsolationStatus"; + type ReturnObject = GetSecurityIsolationStatusReturnObject; + } + impl Method for EnableReportingApi { + const NAME: &'static str = "Network.enableReportingApi"; + type ReturnObject = EnableReportingApiReturnObject; + } + impl Method for LoadNetworkResource { + const NAME: &'static str = "Network.loadNetworkResource"; + type ReturnObject = LoadNetworkResourceReturnObject; + } + pub mod events { + use super::super::types::*; + use serde::{Deserialize, Serialize}; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct DataReceivedEvent { + pub params: DataReceivedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DataReceivedEventParams { + pub request_id: super::RequestId, + pub timestamp: super::MonotonicTime, + #[serde(default)] + pub data_length: JsUInt, + #[serde(default)] + pub encoded_data_length: JsUInt, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct EventSourceMessageReceivedEvent { + pub params: EventSourceMessageReceivedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct EventSourceMessageReceivedEventParams { + pub request_id: super::RequestId, + pub timestamp: super::MonotonicTime, + #[serde(default)] + pub event_name: String, + #[serde(default)] + pub event_id: String, + #[serde(default)] + pub data: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct LoadingFailedEvent { + pub params: LoadingFailedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct LoadingFailedEventParams { + pub request_id: super::RequestId, + pub timestamp: super::MonotonicTime, + pub Type: super::ResourceType, + #[serde(default)] + pub error_text: String, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub canceled: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub blocked_reason: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub cors_error_status: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct LoadingFinishedEvent { + pub params: LoadingFinishedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct LoadingFinishedEventParams { + pub request_id: super::RequestId, + pub timestamp: super::MonotonicTime, + #[serde(default)] + pub encoded_data_length: JsFloat, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub should_report_corb_blocking: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct RequestInterceptedEvent { + pub params: RequestInterceptedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RequestInterceptedEventParams { + pub interception_id: super::InterceptionId, + pub request: super::Request, + pub frame_id: super::super::Page::FrameId, + pub resource_Type: super::ResourceType, + #[serde(default)] + pub is_navigation_request: bool, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub is_download: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub redirect_url: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub auth_challenge: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub response_error_reason: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub response_status_code: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub response_headers: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub request_id: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct RequestServedFromCacheEvent { + pub params: RequestServedFromCacheEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RequestServedFromCacheEventParams { + pub request_id: super::RequestId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct RequestWillBeSentEvent { + pub params: RequestWillBeSentEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RequestWillBeSentEventParams { + pub request_id: super::RequestId, + pub loader_id: super::LoaderId, + #[serde(default)] + pub document_url: String, + pub request: super::Request, + pub timestamp: super::MonotonicTime, + pub wall_time: super::TimeSinceEpoch, + pub initiator: super::Initiator, + #[serde(default)] + pub redirect_has_extra_info: bool, + #[serde(skip_serializing_if = "Option::is_none")] + pub redirect_response: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub Type: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub frame_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub has_user_gesture: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct ResourceChangedPriorityEvent { + pub params: ResourceChangedPriorityEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ResourceChangedPriorityEventParams { + pub request_id: super::RequestId, + pub new_priority: super::ResourcePriority, + pub timestamp: super::MonotonicTime, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct SignedExchangeReceivedEvent { + pub params: SignedExchangeReceivedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SignedExchangeReceivedEventParams { + pub request_id: super::RequestId, + pub info: super::SignedExchangeInfo, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct ResponseReceivedEvent { + pub params: ResponseReceivedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ResponseReceivedEventParams { + pub request_id: super::RequestId, + pub loader_id: super::LoaderId, + pub timestamp: super::MonotonicTime, + pub Type: super::ResourceType, + pub response: super::Response, + #[serde(default)] + pub has_extra_info: bool, + #[serde(skip_serializing_if = "Option::is_none")] + pub frame_id: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct WebSocketClosedEvent { + pub params: WebSocketClosedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct WebSocketClosedEventParams { + pub request_id: super::RequestId, + pub timestamp: super::MonotonicTime, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct WebSocketCreatedEvent { + pub params: WebSocketCreatedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct WebSocketCreatedEventParams { + pub request_id: super::RequestId, + #[serde(default)] + pub url: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub initiator: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct WebSocketFrameErrorEvent { + pub params: WebSocketFrameErrorEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct WebSocketFrameErrorEventParams { + pub request_id: super::RequestId, + pub timestamp: super::MonotonicTime, + #[serde(default)] + pub error_message: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct WebSocketFrameReceivedEvent { + pub params: WebSocketFrameReceivedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct WebSocketFrameReceivedEventParams { + pub request_id: super::RequestId, + pub timestamp: super::MonotonicTime, + pub response: super::WebSocketFrame, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct WebSocketFrameSentEvent { + pub params: WebSocketFrameSentEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct WebSocketFrameSentEventParams { + pub request_id: super::RequestId, + pub timestamp: super::MonotonicTime, + pub response: super::WebSocketFrame, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct WebSocketHandshakeResponseReceivedEvent { + pub params: WebSocketHandshakeResponseReceivedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct WebSocketHandshakeResponseReceivedEventParams { + pub request_id: super::RequestId, + pub timestamp: super::MonotonicTime, + pub response: super::WebSocketResponse, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct WebSocketWillSendHandshakeRequestEvent { + pub params: WebSocketWillSendHandshakeRequestEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct WebSocketWillSendHandshakeRequestEventParams { + pub request_id: super::RequestId, + pub timestamp: super::MonotonicTime, + pub wall_time: super::TimeSinceEpoch, + pub request: super::WebSocketRequest, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct WebTransportCreatedEvent { + pub params: WebTransportCreatedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct WebTransportCreatedEventParams { + pub transport_id: super::RequestId, + #[serde(default)] + pub url: String, + pub timestamp: super::MonotonicTime, + #[serde(skip_serializing_if = "Option::is_none")] + pub initiator: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct WebTransportConnectionEstablishedEvent { + pub params: WebTransportConnectionEstablishedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct WebTransportConnectionEstablishedEventParams { + pub transport_id: super::RequestId, + pub timestamp: super::MonotonicTime, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct WebTransportClosedEvent { + pub params: WebTransportClosedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct WebTransportClosedEventParams { + pub transport_id: super::RequestId, + pub timestamp: super::MonotonicTime, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct RequestWillBeSentExtraInfoEvent { + pub params: RequestWillBeSentExtraInfoEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RequestWillBeSentExtraInfoEventParams { + pub request_id: super::RequestId, + pub associated_cookies: Vec, + pub headers: super::Headers, + pub connect_timing: super::ConnectTiming, + #[serde(skip_serializing_if = "Option::is_none")] + pub client_security_state: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct ResponseReceivedExtraInfoEvent { + pub params: ResponseReceivedExtraInfoEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ResponseReceivedExtraInfoEventParams { + pub request_id: super::RequestId, + pub blocked_cookies: Vec, + pub headers: super::Headers, + pub resource_ip_address_space: super::IPAddressSpace, + #[serde(default)] + pub status_code: JsUInt, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub headers_text: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct TrustTokenOperationDoneEvent { + pub params: TrustTokenOperationDoneEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct TrustTokenOperationDoneEventParams { + pub status: super::TrustTokenOperationDoneEventStatusOption, + pub Type: super::TrustTokenOperationType, + pub request_id: super::RequestId, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub top_level_origin: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub issuer_origin: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub issued_token_count: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct SubresourceWebBundleMetadataReceivedEvent { + pub params: SubresourceWebBundleMetadataReceivedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SubresourceWebBundleMetadataReceivedEventParams { + pub request_id: super::RequestId, + #[serde(default)] + pub urls: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct SubresourceWebBundleMetadataErrorEvent { + pub params: SubresourceWebBundleMetadataErrorEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SubresourceWebBundleMetadataErrorEventParams { + pub request_id: super::RequestId, + #[serde(default)] + pub error_message: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct SubresourceWebBundleInnerResponseParsedEvent { + pub params: SubresourceWebBundleInnerResponseParsedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SubresourceWebBundleInnerResponseParsedEventParams { + pub inner_request_id: super::RequestId, + #[serde(default)] + pub inner_request_url: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub bundle_request_id: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct SubresourceWebBundleInnerResponseErrorEvent { + pub params: SubresourceWebBundleInnerResponseErrorEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SubresourceWebBundleInnerResponseErrorEventParams { + pub inner_request_id: super::RequestId, + #[serde(default)] + pub inner_request_url: String, + #[serde(default)] + pub error_message: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub bundle_request_id: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct ReportingApiReportAddedEvent { + pub params: ReportingApiReportAddedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ReportingApiReportAddedEventParams { + pub report: super::ReportingApiReport, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct ReportingApiReportUpdatedEvent { + pub params: ReportingApiReportUpdatedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ReportingApiReportUpdatedEventParams { + pub report: super::ReportingApiReport, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct ReportingApiEndpointsChangedForOriginEvent { + pub params: ReportingApiEndpointsChangedForOriginEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ReportingApiEndpointsChangedForOriginEventParams { + #[serde(default)] + pub origin: String, + pub endpoints: Vec, + } + } + } + pub mod Overlay { + use super::types::*; + use super::Page; + use super::Runtime; + use super::DOM; + use serde::{Deserialize, Serialize}; + use serde_json::Value as Json; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum LineStylePattern { + Dashed, + Dotted, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum ContrastAlgorithm { + Aa, + Aaa, + Apca, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum ColorFormat { + Rgb, + Hsl, + Hex, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum InspectMode { + SearchForNode, + SearchForUaShadowDom, + CaptureAreaScreenshot, + ShowDistances, + None, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SourceOrderConfig { + pub parent_outline_color: DOM::RGBA, + pub child_outline_color: DOM::RGBA, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GridHighlightConfig { + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub show_grid_extension_lines: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub show_positive_line_numbers: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub show_negative_line_numbers: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub show_area_names: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub show_line_names: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub show_track_sizes: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub grid_border_color: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub cell_border_color: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub row_line_color: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub column_line_color: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub grid_border_dash: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub cell_border_dash: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub row_line_dash: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub column_line_dash: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub row_gap_color: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub row_hatch_color: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub column_gap_color: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub column_hatch_color: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub area_border_color: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub grid_background_color: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct FlexContainerHighlightConfig { + #[serde(skip_serializing_if = "Option::is_none")] + pub container_border: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub line_separator: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub item_separator: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub main_distributed_space: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub cross_distributed_space: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub row_gap_space: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub column_gap_space: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub cross_alignment: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct FlexItemHighlightConfig { + #[serde(skip_serializing_if = "Option::is_none")] + pub base_size_box: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub base_size_border: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub flexibility_arrow: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct LineStyle { + #[serde(skip_serializing_if = "Option::is_none")] + pub color: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub pattern: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct BoxStyle { + #[serde(skip_serializing_if = "Option::is_none")] + pub fill_color: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub hatch_color: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct HighlightConfig { + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub show_info: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub show_styles: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub show_rulers: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub show_accessibility_info: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub show_extension_lines: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub content_color: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub padding_color: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub border_color: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub margin_color: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub event_target_color: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub shape_color: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub shape_margin_color: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub css_grid_color: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub color_format: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub grid_highlight_config: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub flex_container_highlight_config: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub flex_item_highlight_config: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub contrast_algorithm: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub container_query_container_highlight_config: + Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GridNodeHighlightConfig { + pub grid_highlight_config: GridHighlightConfig, + pub node_id: DOM::NodeId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct FlexNodeHighlightConfig { + pub flex_container_highlight_config: FlexContainerHighlightConfig, + pub node_id: DOM::NodeId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ScrollSnapContainerHighlightConfig { + #[serde(skip_serializing_if = "Option::is_none")] + pub snapport_border: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub snap_area_border: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub scroll_margin_color: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub scroll_padding_color: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ScrollSnapHighlightConfig { + pub scroll_snap_container_highlight_config: ScrollSnapContainerHighlightConfig, + pub node_id: DOM::NodeId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct HingeConfig { + pub rect: DOM::Rect, + #[serde(skip_serializing_if = "Option::is_none")] + pub content_color: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub outline_color: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ContainerQueryHighlightConfig { + pub container_query_container_highlight_config: ContainerQueryContainerHighlightConfig, + pub node_id: DOM::NodeId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ContainerQueryContainerHighlightConfig { + #[serde(skip_serializing_if = "Option::is_none")] + pub container_border: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub descendant_border: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct IsolatedElementHighlightConfig { + pub isolation_mode_highlight_config: IsolationModeHighlightConfig, + pub node_id: DOM::NodeId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct IsolationModeHighlightConfig { + #[serde(skip_serializing_if = "Option::is_none")] + pub resizer_color: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub resizer_handle_color: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub mask_color: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Disable(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Enable(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetHighlightObjectForTest { + pub node_id: DOM::NodeId, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub include_distance: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub include_style: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub color_format: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub show_accessibility_info: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetGridHighlightObjectsForTest { + pub node_ids: DOM::NodeId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetSourceOrderHighlightObjectForTest { + pub node_id: DOM::NodeId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct HideHighlight(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct HighlightFrame { + pub frame_id: Page::FrameId, + #[serde(skip_serializing_if = "Option::is_none")] + pub content_color: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub content_outline_color: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct HighlightNode { + pub highlight_config: HighlightConfig, + #[serde(skip_serializing_if = "Option::is_none")] + pub node_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub backend_node_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub object_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub selector: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct HighlightQuad { + pub quad: DOM::Quad, + #[serde(skip_serializing_if = "Option::is_none")] + pub color: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub outline_color: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct HighlightRect { + #[serde(default)] + pub x: JsUInt, + #[serde(default)] + pub y: JsUInt, + #[serde(default)] + pub width: JsUInt, + #[serde(default)] + pub height: JsUInt, + #[serde(skip_serializing_if = "Option::is_none")] + pub color: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub outline_color: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct HighlightSourceOrder { + pub source_order_config: SourceOrderConfig, + #[serde(skip_serializing_if = "Option::is_none")] + pub node_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub backend_node_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub object_id: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetInspectMode { + pub mode: InspectMode, + #[serde(skip_serializing_if = "Option::is_none")] + pub highlight_config: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetShowAdHighlights { + #[serde(default)] + pub show: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetPausedInDebuggerMessage { + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub message: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetShowDebugBorders { + #[serde(default)] + pub show: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetShowFPSCounter { + #[serde(default)] + pub show: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetShowGridOverlays { + pub grid_node_highlight_configs: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetShowFlexOverlays { + pub flex_node_highlight_configs: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetShowScrollSnapOverlays { + pub scroll_snap_highlight_configs: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetShowContainerQueryOverlays { + pub container_query_highlight_configs: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetShowPaintRects { + #[serde(default)] + pub result: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetShowLayoutShiftRegions { + #[serde(default)] + pub result: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetShowScrollBottleneckRects { + #[serde(default)] + pub show: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetShowHitTestBorders { + #[serde(default)] + pub show: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetShowWebVitals { + #[serde(default)] + pub show: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetShowViewportSizeOnResize { + #[serde(default)] + pub show: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetShowHinge { + #[serde(skip_serializing_if = "Option::is_none")] + pub hinge_config: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetShowIsolatedElements { + pub isolated_element_highlight_configs: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DisableReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct EnableReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetHighlightObjectForTestReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetGridHighlightObjectsForTestReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetSourceOrderHighlightObjectForTestReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct HideHighlightReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct HighlightFrameReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct HighlightNodeReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct HighlightQuadReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct HighlightRectReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct HighlightSourceOrderReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetInspectModeReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetShowAdHighlightsReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetPausedInDebuggerMessageReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetShowDebugBordersReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetShowFPSCounterReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetShowGridOverlaysReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetShowFlexOverlaysReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetShowScrollSnapOverlaysReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetShowContainerQueryOverlaysReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetShowPaintRectsReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetShowLayoutShiftRegionsReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetShowScrollBottleneckRectsReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetShowHitTestBordersReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetShowWebVitalsReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetShowViewportSizeOnResizeReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetShowHingeReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetShowIsolatedElementsReturnObject {} + impl Method for Disable { + const NAME: &'static str = "Overlay.disable"; + type ReturnObject = DisableReturnObject; + } + impl Method for Enable { + const NAME: &'static str = "Overlay.enable"; + type ReturnObject = EnableReturnObject; + } + impl Method for GetHighlightObjectForTest { + const NAME: &'static str = "Overlay.getHighlightObjectForTest"; + type ReturnObject = GetHighlightObjectForTestReturnObject; + } + impl Method for GetGridHighlightObjectsForTest { + const NAME: &'static str = "Overlay.getGridHighlightObjectsForTest"; + type ReturnObject = GetGridHighlightObjectsForTestReturnObject; + } + impl Method for GetSourceOrderHighlightObjectForTest { + const NAME: &'static str = "Overlay.getSourceOrderHighlightObjectForTest"; + type ReturnObject = GetSourceOrderHighlightObjectForTestReturnObject; + } + impl Method for HideHighlight { + const NAME: &'static str = "Overlay.hideHighlight"; + type ReturnObject = HideHighlightReturnObject; + } + impl Method for HighlightFrame { + const NAME: &'static str = "Overlay.highlightFrame"; + type ReturnObject = HighlightFrameReturnObject; + } + impl Method for HighlightNode { + const NAME: &'static str = "Overlay.highlightNode"; + type ReturnObject = HighlightNodeReturnObject; + } + impl Method for HighlightQuad { + const NAME: &'static str = "Overlay.highlightQuad"; + type ReturnObject = HighlightQuadReturnObject; + } + impl Method for HighlightRect { + const NAME: &'static str = "Overlay.highlightRect"; + type ReturnObject = HighlightRectReturnObject; + } + impl Method for HighlightSourceOrder { + const NAME: &'static str = "Overlay.highlightSourceOrder"; + type ReturnObject = HighlightSourceOrderReturnObject; + } + impl Method for SetInspectMode { + const NAME: &'static str = "Overlay.setInspectMode"; + type ReturnObject = SetInspectModeReturnObject; + } + impl Method for SetShowAdHighlights { + const NAME: &'static str = "Overlay.setShowAdHighlights"; + type ReturnObject = SetShowAdHighlightsReturnObject; + } + impl Method for SetPausedInDebuggerMessage { + const NAME: &'static str = "Overlay.setPausedInDebuggerMessage"; + type ReturnObject = SetPausedInDebuggerMessageReturnObject; + } + impl Method for SetShowDebugBorders { + const NAME: &'static str = "Overlay.setShowDebugBorders"; + type ReturnObject = SetShowDebugBordersReturnObject; + } + impl Method for SetShowFPSCounter { + const NAME: &'static str = "Overlay.setShowFPSCounter"; + type ReturnObject = SetShowFPSCounterReturnObject; + } + impl Method for SetShowGridOverlays { + const NAME: &'static str = "Overlay.setShowGridOverlays"; + type ReturnObject = SetShowGridOverlaysReturnObject; + } + impl Method for SetShowFlexOverlays { + const NAME: &'static str = "Overlay.setShowFlexOverlays"; + type ReturnObject = SetShowFlexOverlaysReturnObject; + } + impl Method for SetShowScrollSnapOverlays { + const NAME: &'static str = "Overlay.setShowScrollSnapOverlays"; + type ReturnObject = SetShowScrollSnapOverlaysReturnObject; + } + impl Method for SetShowContainerQueryOverlays { + const NAME: &'static str = "Overlay.setShowContainerQueryOverlays"; + type ReturnObject = SetShowContainerQueryOverlaysReturnObject; + } + impl Method for SetShowPaintRects { + const NAME: &'static str = "Overlay.setShowPaintRects"; + type ReturnObject = SetShowPaintRectsReturnObject; + } + impl Method for SetShowLayoutShiftRegions { + const NAME: &'static str = "Overlay.setShowLayoutShiftRegions"; + type ReturnObject = SetShowLayoutShiftRegionsReturnObject; + } + impl Method for SetShowScrollBottleneckRects { + const NAME: &'static str = "Overlay.setShowScrollBottleneckRects"; + type ReturnObject = SetShowScrollBottleneckRectsReturnObject; + } + impl Method for SetShowHitTestBorders { + const NAME: &'static str = "Overlay.setShowHitTestBorders"; + type ReturnObject = SetShowHitTestBordersReturnObject; + } + impl Method for SetShowWebVitals { + const NAME: &'static str = "Overlay.setShowWebVitals"; + type ReturnObject = SetShowWebVitalsReturnObject; + } + impl Method for SetShowViewportSizeOnResize { + const NAME: &'static str = "Overlay.setShowViewportSizeOnResize"; + type ReturnObject = SetShowViewportSizeOnResizeReturnObject; + } + impl Method for SetShowHinge { + const NAME: &'static str = "Overlay.setShowHinge"; + type ReturnObject = SetShowHingeReturnObject; + } + impl Method for SetShowIsolatedElements { + const NAME: &'static str = "Overlay.setShowIsolatedElements"; + type ReturnObject = SetShowIsolatedElementsReturnObject; + } + pub mod events { + use super::super::types::*; + use serde::{Deserialize, Serialize}; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct InspectNodeRequestedEvent { + pub params: InspectNodeRequestedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct InspectNodeRequestedEventParams { + pub backend_node_id: super::super::DOM::BackendNodeId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct NodeHighlightRequestedEvent { + pub params: NodeHighlightRequestedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct NodeHighlightRequestedEventParams { + pub node_id: super::super::DOM::NodeId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct ScreenshotRequestedEvent { + pub params: ScreenshotRequestedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ScreenshotRequestedEventParams { + pub viewport: super::super::Page::Viewport, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct InspectModeCanceledEvent(pub Option); + } + } + pub mod Page { + use super::types::*; + use super::Debugger; + use super::Emulation; + use super::Network; + use super::Runtime; + use super::DOM; + use super::IO; + use serde::{Deserialize, Serialize}; + use serde_json::Value as Json; + pub type FrameId = String; + pub type ScriptIdentifier = String; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum AdFrameType { + None, + Child, + Root, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "PascalCase")] + pub enum AdFrameExplanation { + ParentIsAd, + CreatedByAdScript, + MatchedBlockingRule, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "PascalCase")] + pub enum SecureContextType { + Secure, + SecureLocalhost, + InsecureScheme, + InsecureAncestor, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "PascalCase")] + pub enum CrossOriginIsolatedContextType { + Isolated, + NotIsolated, + NotIsolatedFeatureDisabled, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "PascalCase")] + pub enum GatedAPIFeatures { + SharedArrayBuffers, + SharedArrayBuffersTransferAllowed, + PerformanceMeasureMemory, + PerformanceProfile, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "kebab-case")] + pub enum PermissionsPolicyFeature { + Accelerometer, + AmbientLightSensor, + AttributionReporting, + Autoplay, + Camera, + ChDpr, + ChDeviceMemory, + ChDownlink, + ChEct, + ChPrefersColorScheme, + ChRtt, + ChUa, + ChUaArch, + ChUaBitness, + ChUaPlatform, + ChUaModel, + ChUaMobile, + ChUaFullVersion, + ChUaFullVersionList, + ChUaPlatformVersion, + ChUaReduced, + ChViewportHeight, + ChViewportWidth, + ChWidth, + ClipboardRead, + ClipboardWrite, + CrossOriginIsolated, + DirectSockets, + DisplayCapture, + DocumentDomain, + EncryptedMedia, + ExecutionWhileOutOfViewport, + ExecutionWhileNotRendered, + FocusWithoutUserActivation, + Fullscreen, + Frobulate, + Gamepad, + Geolocation, + Gyroscope, + Hid, + IdleDetection, + InterestCohort, + JoinAdInterestGroup, + KeyboardMap, + Magnetometer, + Microphone, + Midi, + OtpCredentials, + Payment, + PictureInPicture, + PublickeyCredentialsGet, + RunAdAuction, + ScreenWakeLock, + Serial, + SharedAutofill, + StorageAccessApi, + SyncXhr, + TrustTokenRedemption, + Usb, + VerticalScroll, + WebShare, + WindowPlacement, + XrSpatialTracking, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "PascalCase")] + pub enum PermissionsPolicyBlockReason { + Header, + IframeAttribute, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "PascalCase")] + pub enum OriginTrialTokenStatus { + Success, + NotSupported, + Insecure, + Expired, + WrongOrigin, + InvalidSignature, + Malformed, + WrongVersion, + FeatureDisabled, + TokenDisabled, + FeatureDisabledForUser, + UnknownTrial, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "PascalCase")] + pub enum OriginTrialStatus { + Enabled, + ValidTokenNotProvided, + OsNotSupported, + TrialNotAllowed, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "PascalCase")] + pub enum OriginTrialUsageRestriction { + None, + Subset, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum TransitionType { + Link, + Typed, + AddressBar, + AutoBookmark, + AutoSubframe, + ManualSubframe, + Generated, + AutoToplevel, + FormSubmit, + Reload, + Keyword, + KeywordGenerated, + Other, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum DialogType { + Alert, + Confirm, + Prompt, + Beforeunload, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum ClientNavigationReason { + FormSubmissionGet, + FormSubmissionPost, + HttpHeaderRefresh, + ScriptInitiated, + MetaTagRefresh, + PageBlockInterstitial, + Reload, + AnchorClick, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum ClientNavigationDisposition { + CurrentTab, + NewTab, + NewWindow, + Download, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum ReferrerPolicy { + NoReferrer, + NoReferrerWhenDowngrade, + Origin, + OriginWhenCrossOrigin, + SameOrigin, + StrictOrigin, + StrictOriginWhenCrossOrigin, + UnsafeUrl, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "PascalCase")] + pub enum NavigationType { + Navigation, + BackForwardCacheRestore, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "PascalCase")] + pub enum BackForwardCacheNotRestoredReason { + NotMainFrame, + BackForwardCacheDisabled, + RelatedActiveContentsExist, + HttpStatusNotOk, + SchemeNotHttpOrHttps, + Loading, + WasGrantedMediaAccess, + DisableForRenderFrameHostCalled, + DomainNotAllowed, + HttpMethodNotGet, + SubframeIsNavigating, + Timeout, + CacheLimit, + JavaScriptExecution, + RendererProcessKilled, + RendererProcessCrashed, + GrantedMediaStreamAccess, + SchedulerTrackedFeatureUsed, + ConflictingBrowsingInstance, + CacheFlushed, + ServiceWorkerVersionActivation, + SessionRestored, + ServiceWorkerPostMessage, + EnteredBackForwardCacheBeforeServiceWorkerHostAdded, + RenderFrameHostReusedSameSite, + RenderFrameHostReusedCrossSite, + ServiceWorkerClaim, + IgnoreEventAndEvict, + HaveInnerContents, + TimeoutPuttingInCache, + BackForwardCacheDisabledByLowMemory, + BackForwardCacheDisabledByCommandLine, + NetworkRequestDatapipeDrainedAsBytesConsumer, + NetworkRequestRedirected, + NetworkRequestTimeout, + NetworkExceedsBufferLimit, + NavigationCancelledWhileRestoring, + NotMostRecentNavigationEntry, + BackForwardCacheDisabledForPrerender, + UserAgentOverrideDiffers, + ForegroundCacheLimit, + BrowsingInstanceNotSwapped, + BackForwardCacheDisabledForDelegate, + OptInUnloadHeaderNotPresent, + UnloadHandlerExistsInMainFrame, + UnloadHandlerExistsInSubFrame, + ServiceWorkerUnregistration, + CacheControlNoStore, + CacheControlNoStoreCookieModified, + CacheControlNoStoreHttpOnlyCookieModified, + NoResponseHead, + Unknown, + ActivationNavigationsDisallowedForBug1234857, + WebSocket, + WebTransport, + WebRtc, + MainResourceHasCacheControlNoStore, + MainResourceHasCacheControlNoCache, + SubresourceHasCacheControlNoStore, + SubresourceHasCacheControlNoCache, + ContainsPlugins, + DocumentLoaded, + DedicatedWorkerOrWorklet, + OutstandingNetworkRequestOthers, + OutstandingIndexedDbTransaction, + RequestedNotificationsPermission, + RequestedMidiPermission, + RequestedAudioCapturePermission, + RequestedVideoCapturePermission, + RequestedBackForwardCacheBlockedSensors, + RequestedBackgroundWorkPermission, + BroadcastChannel, + IndexedDbConnection, + WebXr, + SharedWorker, + WebLocks, + WebHid, + WebShare, + RequestedStorageAccessGrant, + WebNfc, + OutstandingNetworkRequestFetch, + OutstandingNetworkRequestXhr, + AppBanner, + Printing, + WebDatabase, + PictureInPicture, + Portal, + SpeechRecognizer, + IdleManager, + PaymentManager, + SpeechSynthesis, + KeyboardLock, + WebOtpService, + OutstandingNetworkRequestDirectSocket, + InjectedJavascript, + InjectedStyleSheet, + Dummy, + ContentSecurityHandler, + ContentWebAuthenticationApi, + ContentFileChooser, + ContentSerial, + ContentFileSystemAccess, + ContentMediaDevicesDispatcherHost, + ContentWebBluetooth, + ContentWebUsb, + ContentMediaSession, + ContentMediaSessionService, + EmbedderPopupBlockerTabHelper, + EmbedderSafeBrowsingTriggeredPopupBlocker, + EmbedderSafeBrowsingThreatDetails, + EmbedderAppBannerManager, + EmbedderDomDistillerViewerSource, + EmbedderDomDistillerSelfDeletingRequestDelegate, + EmbedderOomInterventionTabHelper, + EmbedderOfflinePage, + EmbedderChromePasswordManagerClientBindCredentialManager, + EmbedderPermissionRequestManager, + EmbedderModalDialog, + EmbedderExtensions, + EmbedderExtensionMessaging, + EmbedderExtensionMessagingForOpenPort, + EmbedderExtensionSentMessageToCachedFrame, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "PascalCase")] + pub enum BackForwardCacheNotRestoredReasonType { + SupportPending, + PageSupportNeeded, + Circumstantial, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum CaptureScreenshotFormatOption { + Jpeg, + Png, + Webp, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum CaptureSnapshotFormatOption { + Mhtml, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "PascalCase")] + pub enum PrintToPDFTransfer_modeOption { + ReturnAsBase64, + ReturnAsStream, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum SetDownloadBehaviorBehaviorOption { + Deny, + Allow, + Default, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum SetTouchEmulationEnabledConfigurationOption { + Mobile, + Desktop, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum StartScreencastFormatOption { + Jpeg, + Png, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum SetWebLifecycleStateStateOption { + Frozen, + Active, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum SetSPCTransactionModeModeOption { + None, + Autoaccept, + Autoreject, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum FileChooserOpenedEventModeOption { + SelectSingle, + SelectMultiple, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum FrameDetachedEventReasonOption { + Remove, + Swap, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum DownloadProgressEventStateOption { + InProgress, + Completed, + Canceled, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct AdFrameStatus { + pub ad_frame_Type: AdFrameType, + #[serde(skip_serializing_if = "Option::is_none")] + pub explanations: Option>, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct PermissionsPolicyBlockLocator { + pub frame_id: FrameId, + pub block_reason: PermissionsPolicyBlockReason, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct PermissionsPolicyFeatureState { + pub feature: PermissionsPolicyFeature, + #[serde(default)] + pub allowed: bool, + #[serde(skip_serializing_if = "Option::is_none")] + pub locator: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct OriginTrialToken { + #[serde(default)] + pub origin: String, + #[serde(default)] + pub match_sub_domains: bool, + #[serde(default)] + pub trial_name: String, + pub expiry_time: Network::TimeSinceEpoch, + #[serde(default)] + pub is_third_party: bool, + pub usage_restriction: OriginTrialUsageRestriction, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct OriginTrialTokenWithStatus { + #[serde(default)] + pub raw_token_text: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub parsed_token: Option, + pub status: OriginTrialTokenStatus, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct OriginTrial { + #[serde(default)] + pub trial_name: String, + pub status: OriginTrialStatus, + pub tokens_with_status: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Frame { + pub id: FrameId, + #[serde(skip_serializing_if = "Option::is_none")] + pub parent_id: Option, + pub loader_id: Network::LoaderId, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub name: Option, + #[serde(default)] + pub url: String, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub url_fragment: Option, + #[serde(default)] + pub domain_and_registry: String, + #[serde(default)] + pub security_origin: String, + #[serde(default)] + pub mime_type: String, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub unreachable_url: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub ad_frame_status: Option, + pub secure_context_Type: SecureContextType, + pub cross_origin_isolated_context_Type: CrossOriginIsolatedContextType, + pub gated_api_features: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct FrameResource { + #[serde(default)] + pub url: String, + pub Type: Network::ResourceType, + #[serde(default)] + pub mime_type: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub last_modified: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub content_size: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub failed: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub canceled: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct FrameResourceTree { + pub frame: Frame, + #[serde(skip_serializing_if = "Option::is_none")] + pub child_frames: Option>, + pub resources: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct FrameTree { + pub frame: Frame, + #[serde(skip_serializing_if = "Option::is_none")] + pub child_frames: Option>, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct NavigationEntry { + #[serde(default)] + pub id: JsUInt, + #[serde(default)] + pub url: String, + #[serde(default)] + pub user_typed_url: String, + #[serde(default)] + pub title: String, + pub transition_Type: TransitionType, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ScreencastFrameMetadata { + #[serde(default)] + pub offset_top: JsFloat, + #[serde(default)] + pub page_scale_factor: JsFloat, + #[serde(default)] + pub device_width: JsFloat, + #[serde(default)] + pub device_height: JsFloat, + #[serde(default)] + pub scroll_offset_x: JsFloat, + #[serde(default)] + pub scroll_offset_y: JsFloat, + #[serde(skip_serializing_if = "Option::is_none")] + pub timestamp: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct AppManifestError { + #[serde(default)] + pub message: String, + #[serde(default)] + pub critical: JsUInt, + #[serde(default)] + pub line: JsUInt, + #[serde(default)] + pub column: JsUInt, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct AppManifestParsedProperties { + #[serde(default)] + pub scope: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct LayoutViewport { + #[serde(default)] + pub page_x: JsUInt, + #[serde(default)] + pub page_y: JsUInt, + #[serde(default)] + pub client_width: JsUInt, + #[serde(default)] + pub client_height: JsUInt, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct VisualViewport { + #[serde(default)] + pub offset_x: JsFloat, + #[serde(default)] + pub offset_y: JsFloat, + #[serde(default)] + pub page_x: JsFloat, + #[serde(default)] + pub page_y: JsFloat, + #[serde(default)] + pub client_width: JsFloat, + #[serde(default)] + pub client_height: JsFloat, + #[serde(default)] + pub scale: JsFloat, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub zoom: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Viewport { + #[serde(default)] + pub x: JsFloat, + #[serde(default)] + pub y: JsFloat, + #[serde(default)] + pub width: JsFloat, + #[serde(default)] + pub height: JsFloat, + #[serde(default)] + pub scale: JsFloat, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct FontFamilies { + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub standard: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub fixed: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub serif: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub sans_serif: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub cursive: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub fantasy: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub pictograph: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct FontSizes { + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub standard: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub fixed: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct InstallabilityErrorArgument { + #[serde(default)] + pub name: String, + #[serde(default)] + pub value: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct InstallabilityError { + #[serde(default)] + pub error_id: String, + pub error_arguments: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CompilationCacheParams { + #[serde(default)] + pub url: String, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub eager: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct BackForwardCacheNotRestoredExplanation { + pub Type: BackForwardCacheNotRestoredReasonType, + pub reason: BackForwardCacheNotRestoredReason, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct AddScriptToEvaluateOnLoad { + #[serde(default)] + pub script_source: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct AddScriptToEvaluateOnNewDocument { + #[serde(default)] + pub source: String, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub world_name: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub include_command_line_api: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct BringToFront(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CaptureScreenshot { + #[serde(skip_serializing_if = "Option::is_none")] + pub format: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub quality: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub clip: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub from_surface: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub capture_beyond_viewport: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CaptureSnapshot { + #[serde(skip_serializing_if = "Option::is_none")] + pub format: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ClearDeviceMetricsOverride(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ClearDeviceOrientationOverride(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ClearGeolocationOverride(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CreateIsolatedWorld { + pub frame_id: FrameId, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub world_name: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub grant_univeral_access: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DeleteCookie { + #[serde(default)] + pub cookie_name: String, + #[serde(default)] + pub url: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Disable(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Enable(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetAppManifest(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetInstallabilityErrors(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetManifestIcons(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetAppId(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetCookies(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetFrameTree(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetLayoutMetrics(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetNavigationHistory(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ResetNavigationHistory(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetResourceContent { + pub frame_id: FrameId, + #[serde(default)] + pub url: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetResourceTree(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct HandleJavaScriptDialog { + #[serde(default)] + pub accept: bool, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub prompt_text: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Navigate { + #[serde(default)] + pub url: String, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub referrer: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub transition_Type: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub frame_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub referrer_policy: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct NavigateToHistoryEntry { + #[serde(default)] + pub entry_id: JsUInt, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct PrintToPDF { + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub landscape: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub display_header_footer: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub print_background: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub scale: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub paper_width: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub paper_height: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub margin_top: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub margin_bottom: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub margin_left: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub margin_right: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub page_ranges: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub ignore_invalid_page_ranges: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub header_template: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub footer_template: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub prefer_css_page_size: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub transfer_mode: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Reload { + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub ignore_cache: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub script_to_evaluate_on_load: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RemoveScriptToEvaluateOnLoad { + pub identifier: ScriptIdentifier, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RemoveScriptToEvaluateOnNewDocument { + pub identifier: ScriptIdentifier, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ScreencastFrameAck { + #[serde(default)] + pub session_id: JsUInt, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SearchInResource { + pub frame_id: FrameId, + #[serde(default)] + pub url: String, + #[serde(default)] + pub query: String, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub case_sensitive: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub is_regex: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetAdBlockingEnabled { + #[serde(default)] + pub enabled: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetBypassCSP { + #[serde(default)] + pub enabled: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetPermissionsPolicyState { + pub frame_id: FrameId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetOriginTrials { + pub frame_id: FrameId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetDeviceMetricsOverride { + #[serde(default)] + pub width: JsUInt, + #[serde(default)] + pub height: JsUInt, + #[serde(default)] + pub device_scale_factor: JsFloat, + #[serde(default)] + pub mobile: bool, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub scale: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub screen_width: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub screen_height: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub position_x: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub position_y: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub dont_set_visible_size: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub screen_orientation: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub viewport: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetDeviceOrientationOverride { + #[serde(default)] + pub alpha: JsFloat, + #[serde(default)] + pub beta: JsFloat, + #[serde(default)] + pub gamma: JsFloat, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetFontFamilies { + pub font_families: FontFamilies, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetFontSizes { + pub font_sizes: FontSizes, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetDocumentContent { + pub frame_id: FrameId, + #[serde(default)] + pub html: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetDownloadBehavior { + pub behavior: SetDownloadBehaviorBehaviorOption, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub download_path: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetGeolocationOverride { + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub latitude: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub longitude: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub accuracy: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetLifecycleEventsEnabled { + #[serde(default)] + pub enabled: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetTouchEmulationEnabled { + #[serde(default)] + pub enabled: bool, + #[serde(skip_serializing_if = "Option::is_none")] + pub configuration: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StartScreencast { + #[serde(skip_serializing_if = "Option::is_none")] + pub format: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub quality: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub max_width: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub max_height: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub every_nth_frame: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StopLoading(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Crash(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Close(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetWebLifecycleState { + pub state: SetWebLifecycleStateStateOption, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StopScreencast(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ProduceCompilationCache { + pub scripts: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct AddCompilationCache { + #[serde(default)] + pub url: String, + #[serde(default)] + pub data: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ClearCompilationCache(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetSPCTransactionMode { + pub mode: SetSPCTransactionModeModeOption, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GenerateTestReport { + #[serde(default)] + pub message: String, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub group: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct WaitForDebugger(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetInterceptFileChooserDialog { + #[serde(default)] + pub enabled: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct AddScriptToEvaluateOnLoadReturnObject { + pub identifier: ScriptIdentifier, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct AddScriptToEvaluateOnNewDocumentReturnObject { + pub identifier: ScriptIdentifier, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct BringToFrontReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CaptureScreenshotReturnObject { + #[serde(default)] + pub data: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CaptureSnapshotReturnObject { + #[serde(default)] + pub data: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ClearDeviceMetricsOverrideReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ClearDeviceOrientationOverrideReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ClearGeolocationOverrideReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CreateIsolatedWorldReturnObject { + pub execution_context_id: Runtime::ExecutionContextId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DeleteCookieReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DisableReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct EnableReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetAppManifestReturnObject { + #[serde(default)] + pub url: String, + pub errors: Vec, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub data: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub parsed: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetInstallabilityErrorsReturnObject { + pub installability_errors: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetManifestIconsReturnObject { + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub primary_icon: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetAppIdReturnObject { + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub app_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub recommended_id: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetCookiesReturnObject { + pub cookies: Network::Cookie, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetFrameTreeReturnObject { + pub frame_tree: FrameTree, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetLayoutMetricsReturnObject { + pub layout_viewport: LayoutViewport, + pub visual_viewport: VisualViewport, + pub content_size: DOM::Rect, + pub css_layout_viewport: LayoutViewport, + pub css_visual_viewport: VisualViewport, + pub css_content_size: DOM::Rect, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetNavigationHistoryReturnObject { + #[serde(default)] + pub current_index: JsUInt, + pub entries: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ResetNavigationHistoryReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetResourceContentReturnObject { + #[serde(default)] + pub content: String, + #[serde(default)] + pub base_64_encoded: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetResourceTreeReturnObject { + pub frame_tree: FrameResourceTree, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct HandleJavaScriptDialogReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct NavigateReturnObject { + pub frame_id: FrameId, + #[serde(skip_serializing_if = "Option::is_none")] + pub loader_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub error_text: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct NavigateToHistoryEntryReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct PrintToPDFReturnObject { + #[serde(default)] + pub data: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub stream: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ReloadReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RemoveScriptToEvaluateOnLoadReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RemoveScriptToEvaluateOnNewDocumentReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ScreencastFrameAckReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SearchInResourceReturnObject { + pub result: Debugger::SearchMatch, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetAdBlockingEnabledReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetBypassCSPReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetPermissionsPolicyStateReturnObject { + pub states: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetOriginTrialsReturnObject { + pub origin_trials: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetDeviceMetricsOverrideReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetDeviceOrientationOverrideReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetFontFamiliesReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetFontSizesReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetDocumentContentReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetDownloadBehaviorReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetGeolocationOverrideReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetLifecycleEventsEnabledReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetTouchEmulationEnabledReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StartScreencastReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StopLoadingReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CrashReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CloseReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetWebLifecycleStateReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StopScreencastReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ProduceCompilationCacheReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct AddCompilationCacheReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ClearCompilationCacheReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetSPCTransactionModeReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GenerateTestReportReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct WaitForDebuggerReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetInterceptFileChooserDialogReturnObject {} + impl Method for AddScriptToEvaluateOnLoad { + const NAME: &'static str = "Page.addScriptToEvaluateOnLoad"; + type ReturnObject = AddScriptToEvaluateOnLoadReturnObject; + } + impl Method for AddScriptToEvaluateOnNewDocument { + const NAME: &'static str = "Page.addScriptToEvaluateOnNewDocument"; + type ReturnObject = AddScriptToEvaluateOnNewDocumentReturnObject; + } + impl Method for BringToFront { + const NAME: &'static str = "Page.bringToFront"; + type ReturnObject = BringToFrontReturnObject; + } + impl Method for CaptureScreenshot { + const NAME: &'static str = "Page.captureScreenshot"; + type ReturnObject = CaptureScreenshotReturnObject; + } + impl Method for CaptureSnapshot { + const NAME: &'static str = "Page.captureSnapshot"; + type ReturnObject = CaptureSnapshotReturnObject; + } + impl Method for ClearDeviceMetricsOverride { + const NAME: &'static str = "Page.clearDeviceMetricsOverride"; + type ReturnObject = ClearDeviceMetricsOverrideReturnObject; + } + impl Method for ClearDeviceOrientationOverride { + const NAME: &'static str = "Page.clearDeviceOrientationOverride"; + type ReturnObject = ClearDeviceOrientationOverrideReturnObject; + } + impl Method for ClearGeolocationOverride { + const NAME: &'static str = "Page.clearGeolocationOverride"; + type ReturnObject = ClearGeolocationOverrideReturnObject; + } + impl Method for CreateIsolatedWorld { + const NAME: &'static str = "Page.createIsolatedWorld"; + type ReturnObject = CreateIsolatedWorldReturnObject; + } + impl Method for DeleteCookie { + const NAME: &'static str = "Page.deleteCookie"; + type ReturnObject = DeleteCookieReturnObject; + } + impl Method for Disable { + const NAME: &'static str = "Page.disable"; + type ReturnObject = DisableReturnObject; + } + impl Method for Enable { + const NAME: &'static str = "Page.enable"; + type ReturnObject = EnableReturnObject; + } + impl Method for GetAppManifest { + const NAME: &'static str = "Page.getAppManifest"; + type ReturnObject = GetAppManifestReturnObject; + } + impl Method for GetInstallabilityErrors { + const NAME: &'static str = "Page.getInstallabilityErrors"; + type ReturnObject = GetInstallabilityErrorsReturnObject; + } + impl Method for GetManifestIcons { + const NAME: &'static str = "Page.getManifestIcons"; + type ReturnObject = GetManifestIconsReturnObject; + } + impl Method for GetAppId { + const NAME: &'static str = "Page.getAppId"; + type ReturnObject = GetAppIdReturnObject; + } + impl Method for GetCookies { + const NAME: &'static str = "Page.getCookies"; + type ReturnObject = GetCookiesReturnObject; + } + impl Method for GetFrameTree { + const NAME: &'static str = "Page.getFrameTree"; + type ReturnObject = GetFrameTreeReturnObject; + } + impl Method for GetLayoutMetrics { + const NAME: &'static str = "Page.getLayoutMetrics"; + type ReturnObject = GetLayoutMetricsReturnObject; + } + impl Method for GetNavigationHistory { + const NAME: &'static str = "Page.getNavigationHistory"; + type ReturnObject = GetNavigationHistoryReturnObject; + } + impl Method for ResetNavigationHistory { + const NAME: &'static str = "Page.resetNavigationHistory"; + type ReturnObject = ResetNavigationHistoryReturnObject; + } + impl Method for GetResourceContent { + const NAME: &'static str = "Page.getResourceContent"; + type ReturnObject = GetResourceContentReturnObject; + } + impl Method for GetResourceTree { + const NAME: &'static str = "Page.getResourceTree"; + type ReturnObject = GetResourceTreeReturnObject; + } + impl Method for HandleJavaScriptDialog { + const NAME: &'static str = "Page.handleJavaScriptDialog"; + type ReturnObject = HandleJavaScriptDialogReturnObject; + } + impl Method for Navigate { + const NAME: &'static str = "Page.navigate"; + type ReturnObject = NavigateReturnObject; + } + impl Method for NavigateToHistoryEntry { + const NAME: &'static str = "Page.navigateToHistoryEntry"; + type ReturnObject = NavigateToHistoryEntryReturnObject; + } + impl Method for PrintToPDF { + const NAME: &'static str = "Page.printToPDF"; + type ReturnObject = PrintToPDFReturnObject; + } + impl Method for Reload { + const NAME: &'static str = "Page.reload"; + type ReturnObject = ReloadReturnObject; + } + impl Method for RemoveScriptToEvaluateOnLoad { + const NAME: &'static str = "Page.removeScriptToEvaluateOnLoad"; + type ReturnObject = RemoveScriptToEvaluateOnLoadReturnObject; + } + impl Method for RemoveScriptToEvaluateOnNewDocument { + const NAME: &'static str = "Page.removeScriptToEvaluateOnNewDocument"; + type ReturnObject = RemoveScriptToEvaluateOnNewDocumentReturnObject; + } + impl Method for ScreencastFrameAck { + const NAME: &'static str = "Page.screencastFrameAck"; + type ReturnObject = ScreencastFrameAckReturnObject; + } + impl Method for SearchInResource { + const NAME: &'static str = "Page.searchInResource"; + type ReturnObject = SearchInResourceReturnObject; + } + impl Method for SetAdBlockingEnabled { + const NAME: &'static str = "Page.setAdBlockingEnabled"; + type ReturnObject = SetAdBlockingEnabledReturnObject; + } + impl Method for SetBypassCSP { + const NAME: &'static str = "Page.setBypassCSP"; + type ReturnObject = SetBypassCSPReturnObject; + } + impl Method for GetPermissionsPolicyState { + const NAME: &'static str = "Page.getPermissionsPolicyState"; + type ReturnObject = GetPermissionsPolicyStateReturnObject; + } + impl Method for GetOriginTrials { + const NAME: &'static str = "Page.getOriginTrials"; + type ReturnObject = GetOriginTrialsReturnObject; + } + impl Method for SetDeviceMetricsOverride { + const NAME: &'static str = "Page.setDeviceMetricsOverride"; + type ReturnObject = SetDeviceMetricsOverrideReturnObject; + } + impl Method for SetDeviceOrientationOverride { + const NAME: &'static str = "Page.setDeviceOrientationOverride"; + type ReturnObject = SetDeviceOrientationOverrideReturnObject; + } + impl Method for SetFontFamilies { + const NAME: &'static str = "Page.setFontFamilies"; + type ReturnObject = SetFontFamiliesReturnObject; + } + impl Method for SetFontSizes { + const NAME: &'static str = "Page.setFontSizes"; + type ReturnObject = SetFontSizesReturnObject; + } + impl Method for SetDocumentContent { + const NAME: &'static str = "Page.setDocumentContent"; + type ReturnObject = SetDocumentContentReturnObject; + } + impl Method for SetDownloadBehavior { + const NAME: &'static str = "Page.setDownloadBehavior"; + type ReturnObject = SetDownloadBehaviorReturnObject; + } + impl Method for SetGeolocationOverride { + const NAME: &'static str = "Page.setGeolocationOverride"; + type ReturnObject = SetGeolocationOverrideReturnObject; + } + impl Method for SetLifecycleEventsEnabled { + const NAME: &'static str = "Page.setLifecycleEventsEnabled"; + type ReturnObject = SetLifecycleEventsEnabledReturnObject; + } + impl Method for SetTouchEmulationEnabled { + const NAME: &'static str = "Page.setTouchEmulationEnabled"; + type ReturnObject = SetTouchEmulationEnabledReturnObject; + } + impl Method for StartScreencast { + const NAME: &'static str = "Page.startScreencast"; + type ReturnObject = StartScreencastReturnObject; + } + impl Method for StopLoading { + const NAME: &'static str = "Page.stopLoading"; + type ReturnObject = StopLoadingReturnObject; + } + impl Method for Crash { + const NAME: &'static str = "Page.crash"; + type ReturnObject = CrashReturnObject; + } + impl Method for Close { + const NAME: &'static str = "Page.close"; + type ReturnObject = CloseReturnObject; + } + impl Method for SetWebLifecycleState { + const NAME: &'static str = "Page.setWebLifecycleState"; + type ReturnObject = SetWebLifecycleStateReturnObject; + } + impl Method for StopScreencast { + const NAME: &'static str = "Page.stopScreencast"; + type ReturnObject = StopScreencastReturnObject; + } + impl Method for ProduceCompilationCache { + const NAME: &'static str = "Page.produceCompilationCache"; + type ReturnObject = ProduceCompilationCacheReturnObject; + } + impl Method for AddCompilationCache { + const NAME: &'static str = "Page.addCompilationCache"; + type ReturnObject = AddCompilationCacheReturnObject; + } + impl Method for ClearCompilationCache { + const NAME: &'static str = "Page.clearCompilationCache"; + type ReturnObject = ClearCompilationCacheReturnObject; + } + impl Method for SetSPCTransactionMode { + const NAME: &'static str = "Page.setSPCTransactionMode"; + type ReturnObject = SetSPCTransactionModeReturnObject; + } + impl Method for GenerateTestReport { + const NAME: &'static str = "Page.generateTestReport"; + type ReturnObject = GenerateTestReportReturnObject; + } + impl Method for WaitForDebugger { + const NAME: &'static str = "Page.waitForDebugger"; + type ReturnObject = WaitForDebuggerReturnObject; + } + impl Method for SetInterceptFileChooserDialog { + const NAME: &'static str = "Page.setInterceptFileChooserDialog"; + type ReturnObject = SetInterceptFileChooserDialogReturnObject; + } + pub mod events { + use super::super::types::*; + use serde::{Deserialize, Serialize}; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct DomContentEventFiredEvent { + pub params: DomContentEventFiredEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DomContentEventFiredEventParams { + pub timestamp: super::super::Network::MonotonicTime, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct FileChooserOpenedEvent { + pub params: FileChooserOpenedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct FileChooserOpenedEventParams { + pub frame_id: super::FrameId, + pub backend_node_id: super::super::DOM::BackendNodeId, + pub mode: super::FileChooserOpenedEventModeOption, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct FrameAttachedEvent { + pub params: FrameAttachedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct FrameAttachedEventParams { + pub frame_id: super::FrameId, + pub parent_frame_id: super::FrameId, + #[serde(skip_serializing_if = "Option::is_none")] + pub stack: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct FrameClearedScheduledNavigationEvent { + pub params: FrameClearedScheduledNavigationEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct FrameClearedScheduledNavigationEventParams { + pub frame_id: super::FrameId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct FrameDetachedEvent { + pub params: FrameDetachedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct FrameDetachedEventParams { + pub frame_id: super::FrameId, + pub reason: super::FrameDetachedEventReasonOption, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct FrameNavigatedEvent { + pub params: FrameNavigatedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct FrameNavigatedEventParams { + pub frame: super::Frame, + pub Type: super::NavigationType, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct DocumentOpenedEvent { + pub params: DocumentOpenedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DocumentOpenedEventParams { + pub frame: super::Frame, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct FrameResizedEvent(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct FrameRequestedNavigationEvent { + pub params: FrameRequestedNavigationEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct FrameRequestedNavigationEventParams { + pub frame_id: super::FrameId, + pub reason: super::ClientNavigationReason, + #[serde(default)] + pub url: String, + pub disposition: super::ClientNavigationDisposition, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct FrameScheduledNavigationEvent { + pub params: FrameScheduledNavigationEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct FrameScheduledNavigationEventParams { + pub frame_id: super::FrameId, + #[serde(default)] + pub delay: JsFloat, + pub reason: super::ClientNavigationReason, + #[serde(default)] + pub url: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct FrameStartedLoadingEvent { + pub params: FrameStartedLoadingEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct FrameStartedLoadingEventParams { + pub frame_id: super::FrameId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct FrameStoppedLoadingEvent { + pub params: FrameStoppedLoadingEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct FrameStoppedLoadingEventParams { + pub frame_id: super::FrameId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct DownloadWillBeginEvent { + pub params: DownloadWillBeginEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DownloadWillBeginEventParams { + pub frame_id: super::FrameId, + #[serde(default)] + pub guid: String, + #[serde(default)] + pub url: String, + #[serde(default)] + pub suggested_filename: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct DownloadProgressEvent { + pub params: DownloadProgressEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DownloadProgressEventParams { + #[serde(default)] + pub guid: String, + #[serde(default)] + pub total_bytes: JsFloat, + #[serde(default)] + pub received_bytes: JsFloat, + pub state: super::DownloadProgressEventStateOption, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct InterstitialHiddenEvent(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct InterstitialShownEvent(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct JavascriptDialogClosedEvent { + pub params: JavascriptDialogClosedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct JavascriptDialogClosedEventParams { + #[serde(default)] + pub result: bool, + #[serde(default)] + pub user_input: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct JavascriptDialogOpeningEvent { + pub params: JavascriptDialogOpeningEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct JavascriptDialogOpeningEventParams { + #[serde(default)] + pub url: String, + #[serde(default)] + pub message: String, + pub Type: super::DialogType, + #[serde(default)] + pub has_browser_handler: bool, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub default_prompt: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct LifecycleEventEvent { + pub params: LifecycleEventEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct LifecycleEventEventParams { + pub frame_id: super::FrameId, + pub loader_id: super::super::Network::LoaderId, + #[serde(default)] + pub name: String, + pub timestamp: super::super::Network::MonotonicTime, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct BackForwardCacheNotUsedEvent { + pub params: BackForwardCacheNotUsedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct BackForwardCacheNotUsedEventParams { + pub loader_id: super::super::Network::LoaderId, + pub frame_id: super::FrameId, + pub not_restored_explanations: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct LoadEventFiredEvent { + pub params: LoadEventFiredEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct LoadEventFiredEventParams { + pub timestamp: super::super::Network::MonotonicTime, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct NavigatedWithinDocumentEvent { + pub params: NavigatedWithinDocumentEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct NavigatedWithinDocumentEventParams { + pub frame_id: super::FrameId, + #[serde(default)] + pub url: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct ScreencastFrameEvent { + pub params: ScreencastFrameEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ScreencastFrameEventParams { + #[serde(default)] + pub data: String, + pub metadata: super::ScreencastFrameMetadata, + #[serde(default)] + pub session_id: JsUInt, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct ScreencastVisibilityChangedEvent { + pub params: ScreencastVisibilityChangedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ScreencastVisibilityChangedEventParams { + #[serde(default)] + pub visible: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct WindowOpenEvent { + pub params: WindowOpenEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct WindowOpenEventParams { + #[serde(default)] + pub url: String, + #[serde(default)] + pub window_name: String, + #[serde(default)] + pub window_features: Vec, + #[serde(default)] + pub user_gesture: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct CompilationCacheProducedEvent { + pub params: CompilationCacheProducedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CompilationCacheProducedEventParams { + #[serde(default)] + pub url: String, + #[serde(default)] + pub data: String, + } + } + } + pub mod Performance { + use super::types::*; + use serde::{Deserialize, Serialize}; + use serde_json::Value as Json; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum EnableTime_domainOption { + TimeTicks, + ThreadTicks, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum SetTimeDomainTime_domainOption { + TimeTicks, + ThreadTicks, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Metric { + #[serde(default)] + pub name: String, + #[serde(default)] + pub value: JsFloat, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Disable(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Enable { + #[serde(skip_serializing_if = "Option::is_none")] + pub time_domain: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetTimeDomain { + pub time_domain: SetTimeDomainTime_domainOption, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetMetrics(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DisableReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct EnableReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetTimeDomainReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetMetricsReturnObject { + pub metrics: Vec, + } + impl Method for Disable { + const NAME: &'static str = "Performance.disable"; + type ReturnObject = DisableReturnObject; + } + impl Method for Enable { + const NAME: &'static str = "Performance.enable"; + type ReturnObject = EnableReturnObject; + } + impl Method for SetTimeDomain { + const NAME: &'static str = "Performance.setTimeDomain"; + type ReturnObject = SetTimeDomainReturnObject; + } + impl Method for GetMetrics { + const NAME: &'static str = "Performance.getMetrics"; + type ReturnObject = GetMetricsReturnObject; + } + pub mod events { + use super::super::types::*; + use serde::{Deserialize, Serialize}; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct MetricsEvent { + pub params: MetricsEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct MetricsEventParams { + pub metrics: Vec, + #[serde(default)] + pub title: String, + } + } + } + pub mod PerformanceTimeline { + use super::types::*; + use super::Network; + use super::Page; + use super::DOM; + use serde::{Deserialize, Serialize}; + use serde_json::Value as Json; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct LargestContentfulPaint { + pub render_time: Network::TimeSinceEpoch, + pub load_time: Network::TimeSinceEpoch, + #[serde(default)] + pub size: JsFloat, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub element_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub url: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub node_id: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct LayoutShiftAttribution { + pub previous_rect: DOM::Rect, + pub current_rect: DOM::Rect, + #[serde(skip_serializing_if = "Option::is_none")] + pub node_id: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct LayoutShift { + #[serde(default)] + pub value: JsFloat, + #[serde(default)] + pub had_recent_input: bool, + pub last_input_time: Network::TimeSinceEpoch, + pub sources: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct TimelineEvent { + pub frame_id: Page::FrameId, + #[serde(default)] + pub Type: String, + #[serde(default)] + pub name: String, + pub time: Network::TimeSinceEpoch, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub duration: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub lcp_details: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub layout_shift_details: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Enable { + #[serde(default)] + pub event_Types: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct EnableReturnObject {} + impl Method for Enable { + const NAME: &'static str = "PerformanceTimeline.enable"; + type ReturnObject = EnableReturnObject; + } + pub mod events { + use super::super::types::*; + use serde::{Deserialize, Serialize}; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct TimelineEventAddedEvent { + pub params: TimelineEventAddedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct TimelineEventAddedEventParams { + pub event: super::TimelineEvent, + } + } + } + pub mod Security { + use super::types::*; + use super::Network; + use serde::{Deserialize, Serialize}; + use serde_json::Value as Json; + pub type CertificateId = JsUInt; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "kebab-case")] + pub enum MixedContentType { + Blockable, + OptionallyBlockable, + None, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "kebab-case")] + pub enum SecurityState { + Unknown, + Neutral, + Insecure, + Secure, + Info, + InsecureBroken, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum SafetyTipStatus { + BadReputation, + Lookalike, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum CertificateErrorAction { + Continue, + Cancel, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CertificateSecurityState { + #[serde(default)] + pub protocol: String, + #[serde(default)] + pub key_exchange: String, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub key_exchange_group: Option, + #[serde(default)] + pub cipher: String, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub mac: Option, + #[serde(default)] + pub certificate: Vec, + #[serde(default)] + pub subject_name: String, + #[serde(default)] + pub issuer: String, + pub valid_from: Network::TimeSinceEpoch, + pub valid_to: Network::TimeSinceEpoch, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub certificate_network_error: Option, + #[serde(default)] + pub certificate_has_weak_signature: bool, + #[serde(default)] + pub certificate_has_sha_1_signature: bool, + #[serde(default)] + pub modern_ssl: bool, + #[serde(default)] + pub obsolete_ssl_protocol: bool, + #[serde(default)] + pub obsolete_ssl_key_exchange: bool, + #[serde(default)] + pub obsolete_ssl_cipher: bool, + #[serde(default)] + pub obsolete_ssl_signature: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SafetyTipInfo { + pub safety_tip_status: SafetyTipStatus, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub safe_url: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct VisibleSecurityState { + pub security_state: SecurityState, + #[serde(skip_serializing_if = "Option::is_none")] + pub certificate_security_state: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub safety_tip_info: Option, + #[serde(default)] + pub security_state_issue_ids: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SecurityStateExplanation { + pub security_state: SecurityState, + #[serde(default)] + pub title: String, + #[serde(default)] + pub summary: String, + #[serde(default)] + pub description: String, + pub mixed_content_Type: MixedContentType, + #[serde(default)] + pub certificate: Vec, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub recommendations: Option>, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct InsecureContentStatus { + #[serde(default)] + pub ran_mixed_content: bool, + #[serde(default)] + pub displayed_mixed_content: bool, + #[serde(default)] + pub contained_mixed_form: bool, + #[serde(default)] + pub ran_content_with_cert_errors: bool, + #[serde(default)] + pub displayed_content_with_cert_errors: bool, + pub ran_insecure_content_style: SecurityState, + pub displayed_insecure_content_style: SecurityState, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Disable(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Enable(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetIgnoreCertificateErrors { + #[serde(default)] + pub ignore: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct HandleCertificateError { + #[serde(default)] + pub event_id: JsUInt, + pub action: CertificateErrorAction, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetOverrideCertificateErrors { + #[serde(default)] + pub Override: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DisableReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct EnableReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetIgnoreCertificateErrorsReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct HandleCertificateErrorReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetOverrideCertificateErrorsReturnObject {} + impl Method for Disable { + const NAME: &'static str = "Security.disable"; + type ReturnObject = DisableReturnObject; + } + impl Method for Enable { + const NAME: &'static str = "Security.enable"; + type ReturnObject = EnableReturnObject; + } + impl Method for SetIgnoreCertificateErrors { + const NAME: &'static str = "Security.setIgnoreCertificateErrors"; + type ReturnObject = SetIgnoreCertificateErrorsReturnObject; + } + impl Method for HandleCertificateError { + const NAME: &'static str = "Security.handleCertificateError"; + type ReturnObject = HandleCertificateErrorReturnObject; + } + impl Method for SetOverrideCertificateErrors { + const NAME: &'static str = "Security.setOverrideCertificateErrors"; + type ReturnObject = SetOverrideCertificateErrorsReturnObject; + } + pub mod events { + use super::super::types::*; + use serde::{Deserialize, Serialize}; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct CertificateErrorEvent { + pub params: CertificateErrorEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CertificateErrorEventParams { + #[serde(default)] + pub event_id: JsUInt, + #[serde(default)] + pub error_Type: String, + #[serde(default)] + pub request_url: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct VisibleSecurityStateChangedEvent { + pub params: VisibleSecurityStateChangedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct VisibleSecurityStateChangedEventParams { + pub visible_security_state: super::VisibleSecurityState, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct SecurityStateChangedEvent { + pub params: SecurityStateChangedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SecurityStateChangedEventParams { + pub security_state: super::SecurityState, + #[serde(default)] + pub scheme_is_cryptographic: bool, + pub explanations: Vec, + pub insecure_content_status: super::InsecureContentStatus, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub summary: Option, + } + } + } + pub mod ServiceWorker { + use super::types::*; + use super::Target; + use serde::{Deserialize, Serialize}; + use serde_json::Value as Json; + pub type RegistrationID = String; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum ServiceWorkerVersionRunningStatus { + Stopped, + Starting, + Running, + Stopping, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum ServiceWorkerVersionStatus { + New, + Installing, + Installed, + Activating, + Activated, + Redundant, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ServiceWorkerRegistration { + pub registration_id: RegistrationID, + #[serde(default)] + pub scope_url: String, + #[serde(default)] + pub is_deleted: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ServiceWorkerVersion { + #[serde(default)] + pub version_id: String, + pub registration_id: RegistrationID, + #[serde(default)] + pub script_url: String, + pub running_status: ServiceWorkerVersionRunningStatus, + pub status: ServiceWorkerVersionStatus, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub script_last_modified: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub script_response_time: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub controlled_clients: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + pub target_id: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ServiceWorkerErrorMessage { + #[serde(default)] + pub error_message: String, + pub registration_id: RegistrationID, + #[serde(default)] + pub version_id: String, + #[serde(default)] + pub source_url: String, + #[serde(default)] + pub line_number: JsUInt, + #[serde(default)] + pub column_number: JsUInt, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DeliverPushMessage { + #[serde(default)] + pub origin: String, + pub registration_id: RegistrationID, + #[serde(default)] + pub data: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Disable(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DispatchSyncEvent { + #[serde(default)] + pub origin: String, + pub registration_id: RegistrationID, + #[serde(default)] + pub tag: String, + #[serde(default)] + pub last_chance: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DispatchPeriodicSyncEvent { + #[serde(default)] + pub origin: String, + pub registration_id: RegistrationID, + #[serde(default)] + pub tag: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Enable(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct InspectWorker { + #[serde(default)] + pub version_id: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetForceUpdateOnPageLoad { + #[serde(default)] + pub force_update_on_page_load: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SkipWaiting { + #[serde(default)] + pub scope_url: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StartWorker { + #[serde(default)] + pub scope_url: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StopAllWorkers(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StopWorker { + #[serde(default)] + pub version_id: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Unregister { + #[serde(default)] + pub scope_url: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct UpdateRegistration { + #[serde(default)] + pub scope_url: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DeliverPushMessageReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DisableReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DispatchSyncEventReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DispatchPeriodicSyncEventReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct EnableReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct InspectWorkerReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetForceUpdateOnPageLoadReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SkipWaitingReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StartWorkerReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StopAllWorkersReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StopWorkerReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct UnregisterReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct UpdateRegistrationReturnObject {} + impl Method for DeliverPushMessage { + const NAME: &'static str = "ServiceWorker.deliverPushMessage"; + type ReturnObject = DeliverPushMessageReturnObject; + } + impl Method for Disable { + const NAME: &'static str = "ServiceWorker.disable"; + type ReturnObject = DisableReturnObject; + } + impl Method for DispatchSyncEvent { + const NAME: &'static str = "ServiceWorker.dispatchSyncEvent"; + type ReturnObject = DispatchSyncEventReturnObject; + } + impl Method for DispatchPeriodicSyncEvent { + const NAME: &'static str = "ServiceWorker.dispatchPeriodicSyncEvent"; + type ReturnObject = DispatchPeriodicSyncEventReturnObject; + } + impl Method for Enable { + const NAME: &'static str = "ServiceWorker.enable"; + type ReturnObject = EnableReturnObject; + } + impl Method for InspectWorker { + const NAME: &'static str = "ServiceWorker.inspectWorker"; + type ReturnObject = InspectWorkerReturnObject; + } + impl Method for SetForceUpdateOnPageLoad { + const NAME: &'static str = "ServiceWorker.setForceUpdateOnPageLoad"; + type ReturnObject = SetForceUpdateOnPageLoadReturnObject; + } + impl Method for SkipWaiting { + const NAME: &'static str = "ServiceWorker.skipWaiting"; + type ReturnObject = SkipWaitingReturnObject; + } + impl Method for StartWorker { + const NAME: &'static str = "ServiceWorker.startWorker"; + type ReturnObject = StartWorkerReturnObject; + } + impl Method for StopAllWorkers { + const NAME: &'static str = "ServiceWorker.stopAllWorkers"; + type ReturnObject = StopAllWorkersReturnObject; + } + impl Method for StopWorker { + const NAME: &'static str = "ServiceWorker.stopWorker"; + type ReturnObject = StopWorkerReturnObject; + } + impl Method for Unregister { + const NAME: &'static str = "ServiceWorker.unregister"; + type ReturnObject = UnregisterReturnObject; + } + impl Method for UpdateRegistration { + const NAME: &'static str = "ServiceWorker.updateRegistration"; + type ReturnObject = UpdateRegistrationReturnObject; + } + pub mod events { + use super::super::types::*; + use serde::{Deserialize, Serialize}; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct WorkerErrorReportedEvent { + pub params: WorkerErrorReportedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct WorkerErrorReportedEventParams { + pub error_message: super::ServiceWorkerErrorMessage, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct WorkerRegistrationUpdatedEvent { + pub params: WorkerRegistrationUpdatedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct WorkerRegistrationUpdatedEventParams { + pub registrations: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct WorkerVersionUpdatedEvent { + pub params: WorkerVersionUpdatedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct WorkerVersionUpdatedEventParams { + pub versions: Vec, + } + } + } + pub mod Storage { + use super::types::*; + use super::Browser; + use super::Network; + use serde::{Deserialize, Serialize}; + use serde_json::Value as Json; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum StorageType { + Appcache, + Cookies, + FileSystems, + Indexeddb, + LocalStorage, + ShaderCache, + Websql, + ServiceWorkers, + CacheStorage, + All, + Other, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct UsageForType { + pub storage_Type: StorageType, + #[serde(default)] + pub usage: JsFloat, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct TrustTokens { + #[serde(default)] + pub issuer_origin: String, + #[serde(default)] + pub count: JsFloat, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ClearDataForOrigin { + #[serde(default)] + pub origin: String, + #[serde(default)] + pub storage_Types: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetCookies { + #[serde(skip_serializing_if = "Option::is_none")] + pub browser_context_id: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetCookies { + pub cookies: Network::CookieParam, + #[serde(skip_serializing_if = "Option::is_none")] + pub browser_context_id: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ClearCookies { + #[serde(skip_serializing_if = "Option::is_none")] + pub browser_context_id: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetUsageAndQuota { + #[serde(default)] + pub origin: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct OverrideQuotaForOrigin { + #[serde(default)] + pub origin: String, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub quota_size: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct TrackCacheStorageForOrigin { + #[serde(default)] + pub origin: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct TrackIndexedDBForOrigin { + #[serde(default)] + pub origin: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct UntrackCacheStorageForOrigin { + #[serde(default)] + pub origin: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct UntrackIndexedDBForOrigin { + #[serde(default)] + pub origin: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetTrustTokens(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ClearTrustTokens { + #[serde(default)] + pub issuer_origin: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ClearDataForOriginReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetCookiesReturnObject { + pub cookies: Network::Cookie, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetCookiesReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ClearCookiesReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetUsageAndQuotaReturnObject { + #[serde(default)] + pub usage: JsFloat, + #[serde(default)] + pub quota: JsFloat, + #[serde(default)] + pub override_active: bool, + pub usage_breakdown: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct OverrideQuotaForOriginReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct TrackCacheStorageForOriginReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct TrackIndexedDBForOriginReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct UntrackCacheStorageForOriginReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct UntrackIndexedDBForOriginReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetTrustTokensReturnObject { + pub tokens: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ClearTrustTokensReturnObject { + #[serde(default)] + pub did_delete_tokens: bool, + } + impl Method for ClearDataForOrigin { + const NAME: &'static str = "Storage.clearDataForOrigin"; + type ReturnObject = ClearDataForOriginReturnObject; + } + impl Method for GetCookies { + const NAME: &'static str = "Storage.getCookies"; + type ReturnObject = GetCookiesReturnObject; + } + impl Method for SetCookies { + const NAME: &'static str = "Storage.setCookies"; + type ReturnObject = SetCookiesReturnObject; + } + impl Method for ClearCookies { + const NAME: &'static str = "Storage.clearCookies"; + type ReturnObject = ClearCookiesReturnObject; + } + impl Method for GetUsageAndQuota { + const NAME: &'static str = "Storage.getUsageAndQuota"; + type ReturnObject = GetUsageAndQuotaReturnObject; + } + impl Method for OverrideQuotaForOrigin { + const NAME: &'static str = "Storage.overrideQuotaForOrigin"; + type ReturnObject = OverrideQuotaForOriginReturnObject; + } + impl Method for TrackCacheStorageForOrigin { + const NAME: &'static str = "Storage.trackCacheStorageForOrigin"; + type ReturnObject = TrackCacheStorageForOriginReturnObject; + } + impl Method for TrackIndexedDBForOrigin { + const NAME: &'static str = "Storage.trackIndexedDBForOrigin"; + type ReturnObject = TrackIndexedDBForOriginReturnObject; + } + impl Method for UntrackCacheStorageForOrigin { + const NAME: &'static str = "Storage.untrackCacheStorageForOrigin"; + type ReturnObject = UntrackCacheStorageForOriginReturnObject; + } + impl Method for UntrackIndexedDBForOrigin { + const NAME: &'static str = "Storage.untrackIndexedDBForOrigin"; + type ReturnObject = UntrackIndexedDBForOriginReturnObject; + } + impl Method for GetTrustTokens { + const NAME: &'static str = "Storage.getTrustTokens"; + type ReturnObject = GetTrustTokensReturnObject; + } + impl Method for ClearTrustTokens { + const NAME: &'static str = "Storage.clearTrustTokens"; + type ReturnObject = ClearTrustTokensReturnObject; + } + pub mod events { + use super::super::types::*; + use serde::{Deserialize, Serialize}; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct CacheStorageContentUpdatedEvent { + pub params: CacheStorageContentUpdatedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CacheStorageContentUpdatedEventParams { + #[serde(default)] + pub origin: String, + #[serde(default)] + pub cache_name: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct CacheStorageListUpdatedEvent { + pub params: CacheStorageListUpdatedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CacheStorageListUpdatedEventParams { + #[serde(default)] + pub origin: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct IndexedDBContentUpdatedEvent { + pub params: IndexedDBContentUpdatedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct IndexedDBContentUpdatedEventParams { + #[serde(default)] + pub origin: String, + #[serde(default)] + pub database_name: String, + #[serde(default)] + pub object_store_name: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct IndexedDBListUpdatedEvent { + pub params: IndexedDBListUpdatedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct IndexedDBListUpdatedEventParams { + #[serde(default)] + pub origin: String, + } + } + } + pub mod SystemInfo { + use super::types::*; + use serde::{Deserialize, Serialize}; + use serde_json::Value as Json; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum SubsamplingFormat { + Yuv420, + Yuv422, + Yuv444, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum ImageType { + Jpeg, + Webp, + Unknown, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GPUDevice { + #[serde(default)] + pub vendor_id: JsFloat, + #[serde(default)] + pub device_id: JsFloat, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub sub_sys_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub revision: Option, + #[serde(default)] + pub vendor_string: String, + #[serde(default)] + pub device_string: String, + #[serde(default)] + pub driver_vendor: String, + #[serde(default)] + pub driver_version: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Size { + #[serde(default)] + pub width: JsUInt, + #[serde(default)] + pub height: JsUInt, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct VideoDecodeAcceleratorCapability { + #[serde(default)] + pub profile: String, + pub max_resolution: Size, + pub min_resolution: Size, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct VideoEncodeAcceleratorCapability { + #[serde(default)] + pub profile: String, + pub max_resolution: Size, + #[serde(default)] + pub max_framerate_numerator: JsUInt, + #[serde(default)] + pub max_framerate_denominator: JsUInt, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ImageDecodeAcceleratorCapability { + pub image_Type: ImageType, + pub max_dimensions: Size, + pub min_dimensions: Size, + pub subsamplings: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GPUInfo { + pub devices: Vec, + #[serde(default)] + pub driver_bug_workarounds: Vec, + pub video_decoding: Vec, + pub video_encoding: Vec, + pub image_decoding: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ProcessInfo { + #[serde(default)] + pub Type: String, + #[serde(default)] + pub id: JsUInt, + #[serde(default)] + pub cpu_time: JsFloat, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetInfo(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetProcessInfo(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetInfoReturnObject { + pub gpu: GPUInfo, + #[serde(default)] + pub model_name: String, + #[serde(default)] + pub model_version: String, + #[serde(default)] + pub command_line: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetProcessInfoReturnObject { + pub process_info: Vec, + } + impl Method for GetInfo { + const NAME: &'static str = "SystemInfo.getInfo"; + type ReturnObject = GetInfoReturnObject; + } + impl Method for GetProcessInfo { + const NAME: &'static str = "SystemInfo.getProcessInfo"; + type ReturnObject = GetProcessInfoReturnObject; + } + pub mod events { + use super::super::types::*; + use serde::{Deserialize, Serialize}; + } + } + pub mod Target { + use super::types::*; + use super::Browser; + use super::Page; + use serde::{Deserialize, Serialize}; + use serde_json::Value as Json; + pub type TargetID = String; + pub type SessionID = String; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct TargetInfo { + pub target_id: TargetID, + #[serde(default)] + pub Type: String, + #[serde(default)] + pub title: String, + #[serde(default)] + pub url: String, + #[serde(default)] + pub attached: bool, + #[serde(skip_serializing_if = "Option::is_none")] + pub opener_id: Option, + #[serde(default)] + pub can_access_opener: bool, + #[serde(skip_serializing_if = "Option::is_none")] + pub opener_frame_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub browser_context_id: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RemoteLocation { + #[serde(default)] + pub host: String, + #[serde(default)] + pub port: JsUInt, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ActivateTarget { + pub target_id: TargetID, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct AttachToTarget { + pub target_id: TargetID, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub flatten: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct AttachToBrowserTarget(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CloseTarget { + pub target_id: TargetID, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ExposeDevToolsProtocol { + pub target_id: TargetID, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub binding_name: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CreateBrowserContext { + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub dispose_on_detach: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub proxy_server: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub proxy_bypass_list: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub origins_with_universal_network_access: Option>, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetBrowserContexts(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CreateTarget { + #[serde(default)] + pub url: String, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub width: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub height: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub browser_context_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub enable_begin_frame_control: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub new_window: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub background: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DetachFromTarget { + #[serde(skip_serializing_if = "Option::is_none")] + pub session_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub target_id: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DisposeBrowserContext { + pub browser_context_id: Browser::BrowserContextID, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetTargetInfo { + #[serde(skip_serializing_if = "Option::is_none")] + pub target_id: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetTargets(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SendMessageToTarget { + #[serde(default)] + pub message: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub session_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub target_id: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetAutoAttach { + #[serde(default)] + pub auto_attach: bool, + #[serde(default)] + pub wait_for_debugger_on_start: bool, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub flatten: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct AutoAttachRelated { + pub target_id: TargetID, + #[serde(default)] + pub wait_for_debugger_on_start: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetDiscoverTargets { + #[serde(default)] + pub discover: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetRemoteLocations { + pub locations: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ActivateTargetReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct AttachToTargetReturnObject { + pub session_id: SessionID, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct AttachToBrowserTargetReturnObject { + pub session_id: SessionID, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CloseTargetReturnObject { + #[serde(default)] + pub success: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ExposeDevToolsProtocolReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CreateBrowserContextReturnObject { + pub browser_context_id: Browser::BrowserContextID, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetBrowserContextsReturnObject { + pub browser_context_ids: Browser::BrowserContextID, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct CreateTargetReturnObject { + pub target_id: TargetID, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DetachFromTargetReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DisposeBrowserContextReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetTargetInfoReturnObject { + pub target_info: TargetInfo, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetTargetsReturnObject { + pub target_infos: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SendMessageToTargetReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetAutoAttachReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct AutoAttachRelatedReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetDiscoverTargetsReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetRemoteLocationsReturnObject {} + impl Method for ActivateTarget { + const NAME: &'static str = "Target.activateTarget"; + type ReturnObject = ActivateTargetReturnObject; + } + impl Method for AttachToTarget { + const NAME: &'static str = "Target.attachToTarget"; + type ReturnObject = AttachToTargetReturnObject; + } + impl Method for AttachToBrowserTarget { + const NAME: &'static str = "Target.attachToBrowserTarget"; + type ReturnObject = AttachToBrowserTargetReturnObject; + } + impl Method for CloseTarget { + const NAME: &'static str = "Target.closeTarget"; + type ReturnObject = CloseTargetReturnObject; + } + impl Method for ExposeDevToolsProtocol { + const NAME: &'static str = "Target.exposeDevToolsProtocol"; + type ReturnObject = ExposeDevToolsProtocolReturnObject; + } + impl Method for CreateBrowserContext { + const NAME: &'static str = "Target.createBrowserContext"; + type ReturnObject = CreateBrowserContextReturnObject; + } + impl Method for GetBrowserContexts { + const NAME: &'static str = "Target.getBrowserContexts"; + type ReturnObject = GetBrowserContextsReturnObject; + } + impl Method for CreateTarget { + const NAME: &'static str = "Target.createTarget"; + type ReturnObject = CreateTargetReturnObject; + } + impl Method for DetachFromTarget { + const NAME: &'static str = "Target.detachFromTarget"; + type ReturnObject = DetachFromTargetReturnObject; + } + impl Method for DisposeBrowserContext { + const NAME: &'static str = "Target.disposeBrowserContext"; + type ReturnObject = DisposeBrowserContextReturnObject; + } + impl Method for GetTargetInfo { + const NAME: &'static str = "Target.getTargetInfo"; + type ReturnObject = GetTargetInfoReturnObject; + } + impl Method for GetTargets { + const NAME: &'static str = "Target.getTargets"; + type ReturnObject = GetTargetsReturnObject; + } + impl Method for SendMessageToTarget { + const NAME: &'static str = "Target.sendMessageToTarget"; + type ReturnObject = SendMessageToTargetReturnObject; + } + impl Method for SetAutoAttach { + const NAME: &'static str = "Target.setAutoAttach"; + type ReturnObject = SetAutoAttachReturnObject; + } + impl Method for AutoAttachRelated { + const NAME: &'static str = "Target.autoAttachRelated"; + type ReturnObject = AutoAttachRelatedReturnObject; + } + impl Method for SetDiscoverTargets { + const NAME: &'static str = "Target.setDiscoverTargets"; + type ReturnObject = SetDiscoverTargetsReturnObject; + } + impl Method for SetRemoteLocations { + const NAME: &'static str = "Target.setRemoteLocations"; + type ReturnObject = SetRemoteLocationsReturnObject; + } + pub mod events { + use super::super::types::*; + use serde::{Deserialize, Serialize}; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct AttachedToTargetEvent { + pub params: AttachedToTargetEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct AttachedToTargetEventParams { + pub session_id: super::SessionID, + pub target_info: super::TargetInfo, + #[serde(default)] + pub waiting_for_debugger: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct DetachedFromTargetEvent { + pub params: DetachedFromTargetEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DetachedFromTargetEventParams { + pub session_id: super::SessionID, + #[serde(skip_serializing_if = "Option::is_none")] + pub target_id: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct ReceivedMessageFromTargetEvent { + pub params: ReceivedMessageFromTargetEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ReceivedMessageFromTargetEventParams { + pub session_id: super::SessionID, + #[serde(default)] + pub message: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub target_id: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct TargetCreatedEvent { + pub params: TargetCreatedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct TargetCreatedEventParams { + pub target_info: super::TargetInfo, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct TargetDestroyedEvent { + pub params: TargetDestroyedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct TargetDestroyedEventParams { + pub target_id: super::TargetID, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct TargetCrashedEvent { + pub params: TargetCrashedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct TargetCrashedEventParams { + pub target_id: super::TargetID, + #[serde(default)] + pub status: String, + #[serde(default)] + pub error_code: JsUInt, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct TargetInfoChangedEvent { + pub params: TargetInfoChangedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct TargetInfoChangedEventParams { + pub target_info: super::TargetInfo, + } + } + } + pub mod Tethering { + use super::types::*; + use serde::{Deserialize, Serialize}; + use serde_json::Value as Json; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Bind { + #[serde(default)] + pub port: JsUInt, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Unbind { + #[serde(default)] + pub port: JsUInt, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct BindReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct UnbindReturnObject {} + impl Method for Bind { + const NAME: &'static str = "Tethering.bind"; + type ReturnObject = BindReturnObject; + } + impl Method for Unbind { + const NAME: &'static str = "Tethering.unbind"; + type ReturnObject = UnbindReturnObject; + } + pub mod events { + use super::super::types::*; + use serde::{Deserialize, Serialize}; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct AcceptedEvent { + pub params: AcceptedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct AcceptedEventParams { + #[serde(default)] + pub port: JsUInt, + #[serde(default)] + pub connection_id: String, + } + } + } + pub mod Tracing { + use super::types::*; + use super::IO; + use serde::{Deserialize, Serialize}; + use serde_json::Value as Json; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum TraceConfigRecordMode { + RecordUntilFull, + RecordContinuously, + RecordAsMuchAsPossible, + EchoToConsole, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum StreamFormat { + Json, + Proto, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum StreamCompression { + None, + Gzip, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum MemoryDumpLevelOfDetail { + Background, + Light, + Detailed, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum TracingBackend { + Auto, + Chrome, + System, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "PascalCase")] + pub enum StartTransfer_modeOption { + ReportEvents, + ReturnAsStream, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct MemoryDumpConfig(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct TraceConfig { + #[serde(skip_serializing_if = "Option::is_none")] + pub record_mode: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub enable_sampling: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub enable_systrace: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub enable_argument_filter: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub included_categories: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub excluded_categories: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub synthetic_delays: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + pub memory_dump_config: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct End(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetCategories(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RecordClockSyncMarker { + #[serde(default)] + pub sync_id: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RequestMemoryDump { + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub deterministic: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub level_of_detail: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Start { + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub categories: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub options: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub buffer_usage_reporting_interval: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub transfer_mode: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub stream_format: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub stream_compression: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub trace_config: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub perfetto_config: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub tracing_backend: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct EndReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetCategoriesReturnObject { + pub categories: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RecordClockSyncMarkerReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RequestMemoryDumpReturnObject { + #[serde(default)] + pub dump_guid: String, + #[serde(default)] + pub success: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct StartReturnObject {} + impl Method for End { + const NAME: &'static str = "Tracing.end"; + type ReturnObject = EndReturnObject; + } + impl Method for GetCategories { + const NAME: &'static str = "Tracing.getCategories"; + type ReturnObject = GetCategoriesReturnObject; + } + impl Method for RecordClockSyncMarker { + const NAME: &'static str = "Tracing.recordClockSyncMarker"; + type ReturnObject = RecordClockSyncMarkerReturnObject; + } + impl Method for RequestMemoryDump { + const NAME: &'static str = "Tracing.requestMemoryDump"; + type ReturnObject = RequestMemoryDumpReturnObject; + } + impl Method for Start { + const NAME: &'static str = "Tracing.start"; + type ReturnObject = StartReturnObject; + } + pub mod events { + use super::super::types::*; + use serde::{Deserialize, Serialize}; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct BufferUsageEvent { + pub params: BufferUsageEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct BufferUsageEventParams { + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub percent_full: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub event_count: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub value: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct DataCollectedEvent { + pub params: DataCollectedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DataCollectedEventParams {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct TracingCompleteEvent { + pub params: TracingCompleteEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct TracingCompleteEventParams { + #[serde(default)] + pub data_loss_occurred: bool, + #[serde(skip_serializing_if = "Option::is_none")] + pub stream: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub trace_format: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub stream_compression: Option, + } + } + } + pub mod Fetch { + use super::types::*; + use super::Network; + use super::Page; + use super::IO; + use serde::{Deserialize, Serialize}; + use serde_json::Value as Json; + pub type RequestId = String; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "PascalCase")] + pub enum RequestStage { + Request, + Response, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "PascalCase")] + pub enum AuthChallengeSource { + Server, + Proxy, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "PascalCase")] + pub enum AuthChallengeResponseResponse { + Default, + CancelAuth, + ProvideCredentials, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RequestPattern { + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub url_pattern: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub resource_Type: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub request_stage: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct HeaderEntry { + #[serde(default)] + pub name: String, + #[serde(default)] + pub value: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct AuthChallenge { + #[serde(skip_serializing_if = "Option::is_none")] + pub source: Option, + #[serde(default)] + pub origin: String, + #[serde(default)] + pub scheme: String, + #[serde(default)] + pub realm: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct AuthChallengeResponse { + pub response: AuthChallengeResponseResponse, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub username: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub password: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Disable(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Enable { + #[serde(skip_serializing_if = "Option::is_none")] + pub patterns: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub handle_auth_requests: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct FailRequest { + pub request_id: RequestId, + pub error_reason: Network::ErrorReason, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct FulfillRequest { + pub request_id: RequestId, + #[serde(default)] + pub response_code: JsUInt, + #[serde(skip_serializing_if = "Option::is_none")] + pub response_headers: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub binary_response_headers: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub body: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub response_phrase: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ContinueRequest { + pub request_id: RequestId, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub url: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub method: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub post_data: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub headers: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub intercept_response: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ContinueWithAuth { + pub request_id: RequestId, + pub auth_challenge_response: AuthChallengeResponse, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ContinueResponse { + pub request_id: RequestId, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub response_code: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub response_phrase: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub response_headers: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub binary_response_headers: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetResponseBody { + pub request_id: RequestId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct TakeResponseBodyAsStream { + pub request_id: RequestId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DisableReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct EnableReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct FailRequestReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct FulfillRequestReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ContinueRequestReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ContinueWithAuthReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ContinueResponseReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetResponseBodyReturnObject { + #[serde(default)] + pub body: String, + #[serde(default)] + pub base_64_encoded: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct TakeResponseBodyAsStreamReturnObject { + pub stream: IO::StreamHandle, + } + impl Method for Disable { + const NAME: &'static str = "Fetch.disable"; + type ReturnObject = DisableReturnObject; + } + impl Method for Enable { + const NAME: &'static str = "Fetch.enable"; + type ReturnObject = EnableReturnObject; + } + impl Method for FailRequest { + const NAME: &'static str = "Fetch.failRequest"; + type ReturnObject = FailRequestReturnObject; + } + impl Method for FulfillRequest { + const NAME: &'static str = "Fetch.fulfillRequest"; + type ReturnObject = FulfillRequestReturnObject; + } + impl Method for ContinueRequest { + const NAME: &'static str = "Fetch.continueRequest"; + type ReturnObject = ContinueRequestReturnObject; + } + impl Method for ContinueWithAuth { + const NAME: &'static str = "Fetch.continueWithAuth"; + type ReturnObject = ContinueWithAuthReturnObject; + } + impl Method for ContinueResponse { + const NAME: &'static str = "Fetch.continueResponse"; + type ReturnObject = ContinueResponseReturnObject; + } + impl Method for GetResponseBody { + const NAME: &'static str = "Fetch.getResponseBody"; + type ReturnObject = GetResponseBodyReturnObject; + } + impl Method for TakeResponseBodyAsStream { + const NAME: &'static str = "Fetch.takeResponseBodyAsStream"; + type ReturnObject = TakeResponseBodyAsStreamReturnObject; + } + pub mod events { + use super::super::types::*; + use serde::{Deserialize, Serialize}; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct RequestPausedEvent { + pub params: RequestPausedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RequestPausedEventParams { + pub request_id: super::RequestId, + pub request: super::super::Network::Request, + pub frame_id: super::super::Page::FrameId, + pub resource_Type: super::super::Network::ResourceType, + #[serde(skip_serializing_if = "Option::is_none")] + pub response_error_reason: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub response_status_code: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub response_status_text: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub response_headers: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + pub network_id: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct AuthRequiredEvent { + pub params: AuthRequiredEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct AuthRequiredEventParams { + pub request_id: super::RequestId, + pub request: super::super::Network::Request, + pub frame_id: super::super::Page::FrameId, + pub resource_Type: super::super::Network::ResourceType, + pub auth_challenge: super::AuthChallenge, + } + } + } + pub mod WebAudio { + use super::types::*; + use serde::{Deserialize, Serialize}; + use serde_json::Value as Json; + pub type GraphObjectId = String; + pub type NodeType = String; + pub type ParamType = String; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum ContextType { + Realtime, + Offline, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum ContextState { + Suspended, + Running, + Closed, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "kebab-case")] + pub enum ChannelCountMode { + ClampedMax, + Explicit, + Max, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum ChannelInterpretation { + Discrete, + Speakers, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "kebab-case")] + pub enum AutomationRate { + ARate, + KRate, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ContextRealtimeData { + #[serde(default)] + pub current_time: JsFloat, + #[serde(default)] + pub render_capacity: JsFloat, + #[serde(default)] + pub callback_interval_mean: JsFloat, + #[serde(default)] + pub callback_interval_variance: JsFloat, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct BaseAudioContext { + pub context_id: GraphObjectId, + pub context_Type: ContextType, + pub context_state: ContextState, + #[serde(skip_serializing_if = "Option::is_none")] + pub realtime_data: Option, + #[serde(default)] + pub callback_buffer_size: JsFloat, + #[serde(default)] + pub max_output_channel_count: JsFloat, + #[serde(default)] + pub sample_rate: JsFloat, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct AudioListener { + pub listener_id: GraphObjectId, + pub context_id: GraphObjectId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct AudioNode { + pub node_id: GraphObjectId, + pub context_id: GraphObjectId, + pub node_Type: NodeType, + #[serde(default)] + pub number_of_inputs: JsFloat, + #[serde(default)] + pub number_of_outputs: JsFloat, + #[serde(default)] + pub channel_count: JsFloat, + pub channel_count_mode: ChannelCountMode, + pub channel_interpretation: ChannelInterpretation, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct AudioParam { + pub param_id: GraphObjectId, + pub node_id: GraphObjectId, + pub context_id: GraphObjectId, + pub param_Type: ParamType, + pub rate: AutomationRate, + #[serde(default)] + pub default_value: JsFloat, + #[serde(default)] + pub min_value: JsFloat, + #[serde(default)] + pub max_value: JsFloat, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Enable(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Disable(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetRealtimeData { + pub context_id: GraphObjectId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct EnableReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DisableReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetRealtimeDataReturnObject { + pub realtime_data: ContextRealtimeData, + } + impl Method for Enable { + const NAME: &'static str = "WebAudio.enable"; + type ReturnObject = EnableReturnObject; + } + impl Method for Disable { + const NAME: &'static str = "WebAudio.disable"; + type ReturnObject = DisableReturnObject; + } + impl Method for GetRealtimeData { + const NAME: &'static str = "WebAudio.getRealtimeData"; + type ReturnObject = GetRealtimeDataReturnObject; + } + pub mod events { + use super::super::types::*; + use serde::{Deserialize, Serialize}; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct ContextCreatedEvent { + pub params: ContextCreatedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ContextCreatedEventParams { + pub context: super::BaseAudioContext, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct ContextWillBeDestroyedEvent { + pub params: ContextWillBeDestroyedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ContextWillBeDestroyedEventParams { + pub context_id: super::GraphObjectId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct ContextChangedEvent { + pub params: ContextChangedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ContextChangedEventParams { + pub context: super::BaseAudioContext, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct AudioListenerCreatedEvent { + pub params: AudioListenerCreatedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct AudioListenerCreatedEventParams { + pub listener: super::AudioListener, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct AudioListenerWillBeDestroyedEvent { + pub params: AudioListenerWillBeDestroyedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct AudioListenerWillBeDestroyedEventParams { + pub context_id: super::GraphObjectId, + pub listener_id: super::GraphObjectId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct AudioNodeCreatedEvent { + pub params: AudioNodeCreatedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct AudioNodeCreatedEventParams { + pub node: super::AudioNode, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct AudioNodeWillBeDestroyedEvent { + pub params: AudioNodeWillBeDestroyedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct AudioNodeWillBeDestroyedEventParams { + pub context_id: super::GraphObjectId, + pub node_id: super::GraphObjectId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct AudioParamCreatedEvent { + pub params: AudioParamCreatedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct AudioParamCreatedEventParams { + pub param: super::AudioParam, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct AudioParamWillBeDestroyedEvent { + pub params: AudioParamWillBeDestroyedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct AudioParamWillBeDestroyedEventParams { + pub context_id: super::GraphObjectId, + pub node_id: super::GraphObjectId, + pub param_id: super::GraphObjectId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct NodesConnectedEvent { + pub params: NodesConnectedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct NodesConnectedEventParams { + pub context_id: super::GraphObjectId, + pub source_id: super::GraphObjectId, + pub destination_id: super::GraphObjectId, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub source_output_index: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub destination_input_index: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct NodesDisconnectedEvent { + pub params: NodesDisconnectedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct NodesDisconnectedEventParams { + pub context_id: super::GraphObjectId, + pub source_id: super::GraphObjectId, + pub destination_id: super::GraphObjectId, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub source_output_index: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub destination_input_index: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct NodeParamConnectedEvent { + pub params: NodeParamConnectedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct NodeParamConnectedEventParams { + pub context_id: super::GraphObjectId, + pub source_id: super::GraphObjectId, + pub destination_id: super::GraphObjectId, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub source_output_index: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct NodeParamDisconnectedEvent { + pub params: NodeParamDisconnectedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct NodeParamDisconnectedEventParams { + pub context_id: super::GraphObjectId, + pub source_id: super::GraphObjectId, + pub destination_id: super::GraphObjectId, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub source_output_index: Option, + } + } + } + pub mod WebAuthn { + use super::types::*; + use serde::{Deserialize, Serialize}; + use serde_json::Value as Json; + pub type AuthenticatorId = String; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum AuthenticatorProtocol { + U2F, + Ctap2, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum Ctap2Version { + Ctap20, + Ctap21, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum AuthenticatorTransport { + Usb, + Nfc, + Ble, + Cable, + Internal, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct VirtualAuthenticatorOptions { + pub protocol: AuthenticatorProtocol, + #[serde(skip_serializing_if = "Option::is_none")] + pub ctap_2_version: Option, + pub transport: AuthenticatorTransport, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub has_resident_key: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub has_user_verification: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub has_large_blob: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub has_cred_blob: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub automatic_presence_simulation: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub is_user_verified: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Credential { + #[serde(default)] + pub credential_id: String, + #[serde(default)] + pub is_resident_credential: bool, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub rp_id: Option, + #[serde(default)] + pub private_key: String, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub user_handle: Option, + #[serde(default)] + pub sign_count: JsUInt, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub large_blob: Option, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Enable(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Disable(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct AddVirtualAuthenticator { + pub options: VirtualAuthenticatorOptions, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RemoveVirtualAuthenticator { + pub authenticator_id: AuthenticatorId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct AddCredential { + pub authenticator_id: AuthenticatorId, + pub credential: Credential, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetCredential { + pub authenticator_id: AuthenticatorId, + #[serde(default)] + pub credential_id: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetCredentials { + pub authenticator_id: AuthenticatorId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RemoveCredential { + pub authenticator_id: AuthenticatorId, + #[serde(default)] + pub credential_id: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ClearCredentials { + pub authenticator_id: AuthenticatorId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetUserVerified { + pub authenticator_id: AuthenticatorId, + #[serde(default)] + pub is_user_verified: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetAutomaticPresenceSimulation { + pub authenticator_id: AuthenticatorId, + #[serde(default)] + pub enabled: bool, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct EnableReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DisableReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct AddVirtualAuthenticatorReturnObject { + pub authenticator_id: AuthenticatorId, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RemoveVirtualAuthenticatorReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct AddCredentialReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetCredentialReturnObject { + pub credential: Credential, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct GetCredentialsReturnObject { + pub credentials: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct RemoveCredentialReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct ClearCredentialsReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetUserVerifiedReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct SetAutomaticPresenceSimulationReturnObject {} + impl Method for Enable { + const NAME: &'static str = "WebAuthn.enable"; + type ReturnObject = EnableReturnObject; + } + impl Method for Disable { + const NAME: &'static str = "WebAuthn.disable"; + type ReturnObject = DisableReturnObject; + } + impl Method for AddVirtualAuthenticator { + const NAME: &'static str = "WebAuthn.addVirtualAuthenticator"; + type ReturnObject = AddVirtualAuthenticatorReturnObject; + } + impl Method for RemoveVirtualAuthenticator { + const NAME: &'static str = "WebAuthn.removeVirtualAuthenticator"; + type ReturnObject = RemoveVirtualAuthenticatorReturnObject; + } + impl Method for AddCredential { + const NAME: &'static str = "WebAuthn.addCredential"; + type ReturnObject = AddCredentialReturnObject; + } + impl Method for GetCredential { + const NAME: &'static str = "WebAuthn.getCredential"; + type ReturnObject = GetCredentialReturnObject; + } + impl Method for GetCredentials { + const NAME: &'static str = "WebAuthn.getCredentials"; + type ReturnObject = GetCredentialsReturnObject; + } + impl Method for RemoveCredential { + const NAME: &'static str = "WebAuthn.removeCredential"; + type ReturnObject = RemoveCredentialReturnObject; + } + impl Method for ClearCredentials { + const NAME: &'static str = "WebAuthn.clearCredentials"; + type ReturnObject = ClearCredentialsReturnObject; + } + impl Method for SetUserVerified { + const NAME: &'static str = "WebAuthn.setUserVerified"; + type ReturnObject = SetUserVerifiedReturnObject; + } + impl Method for SetAutomaticPresenceSimulation { + const NAME: &'static str = "WebAuthn.setAutomaticPresenceSimulation"; + type ReturnObject = SetAutomaticPresenceSimulationReturnObject; + } + pub mod events { + use super::super::types::*; + use serde::{Deserialize, Serialize}; + } + } + pub mod Media { + use super::types::*; + use serde::{Deserialize, Serialize}; + use serde_json::Value as Json; + pub type PlayerId = String; + pub type Timestamp = JsFloat; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum PlayerMessageLevel { + Error, + Warning, + Info, + Debug, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub enum PlayerErrorType { + PipelineError, + MediaError, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct PlayerMessage { + pub level: PlayerMessageLevel, + #[serde(default)] + pub message: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct PlayerProperty { + #[serde(default)] + pub name: String, + #[serde(default)] + pub value: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct PlayerEvent { + pub timestamp: Timestamp, + #[serde(default)] + pub value: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct PlayerError { + pub Type: PlayerErrorType, + #[serde(default)] + pub error_code: String, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Enable(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct Disable(pub Option); + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct EnableReturnObject {} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct DisableReturnObject {} + impl Method for Enable { + const NAME: &'static str = "Media.enable"; + type ReturnObject = EnableReturnObject; + } + impl Method for Disable { + const NAME: &'static str = "Media.disable"; + type ReturnObject = DisableReturnObject; + } + pub mod events { + use super::super::types::*; + use serde::{Deserialize, Serialize}; + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct PlayerPropertiesChangedEvent { + pub params: PlayerPropertiesChangedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct PlayerPropertiesChangedEventParams { + pub player_id: super::PlayerId, + pub properties: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct PlayerEventsAddedEvent { + pub params: PlayerEventsAddedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct PlayerEventsAddedEventParams { + pub player_id: super::PlayerId, + pub events: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct PlayerMessagesLoggedEvent { + pub params: PlayerMessagesLoggedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct PlayerMessagesLoggedEventParams { + pub player_id: super::PlayerId, + pub messages: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct PlayerErrorsRaisedEvent { + pub params: PlayerErrorsRaisedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct PlayerErrorsRaisedEventParams { + pub player_id: super::PlayerId, + pub errors: Vec, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + pub struct PlayersCreatedEvent { + pub params: PlayersCreatedEventParams, + } + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] + #[serde(rename_all = "camelCase")] + pub struct PlayersCreatedEventParams { + pub players: Vec, + } + } + } +} diff --git a/mdbook-pdf/headless_chrome/src/testing_utils/logging.rs b/mdbook-pdf/headless_chrome/src/testing_utils/logging.rs new file mode 100644 index 00000000..a8cb087a --- /dev/null +++ b/mdbook-pdf/headless_chrome/src/testing_utils/logging.rs @@ -0,0 +1,60 @@ +use std::io::Write; + +use chrono; +use env_logger; +use env_logger::fmt; +use log::*; + +pub fn enable_logging() { + let mut builder = env_logger::Builder::from_default_env(); + + // NOTE: can infer types here, but I find them a useful reminder. + let _result = builder + .format(move |buf: &mut fmt::Formatter, record: &log::Record| { + let date = chrono::Local::now(); + + let level_str = level_to_emoji(record.level()); + let mut style = buf.style(); + let hours_minutes = date.format("%H:%M").to_string(); + let seconds_millis = date.format("%S%.3f").to_string(); + let fmt_seconds = style.set_bold(true).value(seconds_millis); + + let truncated_module_path = &record.module_path().unwrap()[5..]; + + writeln!( + buf, + "{:<2} [{}:{}] - {:<12} - {}", + level_str, + hours_minutes, + fmt_seconds, + truncated_module_path, + record.args() + ) + }) + .try_init(); +} + +// damn, looks like it's harder than I thought it would be to change the datetime format! + +fn level_to_emoji(level: log::Level) -> &'static str { + use Level::*; + + match level { + Error => "❌", + Warn => "☢️ ", + Info => "📝", + Debug => "🐛", // NOTE: there's emoji here! + Trace => "🏹", + } +} + +#[test] +fn start_the_logs() { + enable_logging(); + + error!("error message"); + warn!("warn message"); + info!("info message"); + debug!("debug message"); + trace!("trace message"); +} diff --git a/mdbook-pdf/headless_chrome/src/testing_utils/mod.rs b/mdbook-pdf/headless_chrome/src/testing_utils/mod.rs new file mode 100644 index 00000000..c2e3e92c --- /dev/null +++ b/mdbook-pdf/headless_chrome/src/testing_utils/mod.rs @@ -0,0 +1,2 @@ +pub mod logging; +pub mod server; diff --git a/mdbook-pdf/headless_chrome/src/testing_utils/server.rs b/mdbook-pdf/headless_chrome/src/testing_utils/server.rs new file mode 100644 index 00000000..e13fe8f1 --- /dev/null +++ b/mdbook-pdf/headless_chrome/src/testing_utils/server.rs @@ -0,0 +1,124 @@ +use std::sync::{atomic, Arc}; +use std::thread::JoinHandle; +use std::time::Duration; +use std::{fs, io}; + +pub struct Server { + server: Arc, + handler: Option>>, + shall_exit: Arc, +} + +impl Server { + pub fn new( + mut responder: impl FnMut(tiny_http::Request) -> Result<(), io::Error> + Send + 'static, + ) -> Self { + let server = Arc::new(tiny_http::Server::http("127.0.0.1:0").unwrap()); + let shall_exit = Arc::new(atomic::AtomicBool::new(false)); + let srv = server.clone(); + let exit = shall_exit.clone(); + let handler = std::thread::spawn(move || { + loop { + if let Some(r) = srv.recv_timeout(Duration::from_millis(1000))? { + responder(r)?; + } + if exit.load(atomic::Ordering::Relaxed) { + break; + } + } + Ok(()) + }); + Server { + server, + handler: Some(handler), + shall_exit, + } + } + + #[allow(dead_code)] + pub fn with_dumb_html(data: &'static str) -> Self { + let responder = move |r: tiny_http::Request| { + let response = tiny_http::Response::new( + 200.into(), + vec![ + tiny_http::Header::from_bytes(&b"Content-Type"[..], &b"text/html"[..]).unwrap(), + ], + io::Cursor::new(data), + Some(data.len()), + None, + ); + r.respond(response) + }; + Self::new(responder) + } + + #[allow(dead_code)] + pub fn url(&self) -> String { + format!("http://127.0.0.1:{}", self.port()) + } + + pub fn port(&self) -> u16 { + self.server.server_addr().port() + } + + pub fn exit(&mut self) -> Result<(), io::Error> { + self.shall_exit.store(true, atomic::Ordering::Relaxed); + match self.handler.take() { + Some(h) => h.join().unwrap(), + None => Ok(()), + } + } +} + +impl Drop for Server { + fn drop(&mut self) { + self.exit().unwrap() + } +} + +fn basic_http_response<'a>( + body: &'a str, + content_type: &'static str, +) -> tiny_http::Response<&'a [u8]> { + tiny_http::Response::new( + 200.into(), + vec![tiny_http::Header::from_bytes(&b"Content-Type"[..], content_type.as_bytes()).unwrap()], + body.as_bytes(), + Some(body.len()), + None, + ) +} + +#[allow(dead_code)] +fn not_found_response() -> tiny_http::Response { + tiny_http::Response::new_empty(404.into()) +} + +#[allow(dead_code)] +pub fn file_server(path: &'static str) -> Server { + Server::new(move |request: tiny_http::Request| { + let url = if request.url() == "/" { + "/index.html" + } else { + request.url() + }; + + let file_path = format!("{}{}", path, url); + + if let Ok(file_contents) = fs::read_to_string(file_path) { + let content_type = if url.ends_with(".js") { + "application/javascript" + } else if url.ends_with(".css") { + "text/css" + } else { + "text/html" + }; + + let response = basic_http_response(&file_contents, content_type); + request.respond(response) + } else { + let response = not_found_response(); + request.respond(response) + } + }) +} diff --git a/mdbook-pdf/headless_chrome/src/types.rs b/mdbook-pdf/headless_chrome/src/types.rs new file mode 100644 index 00000000..4373bfe1 --- /dev/null +++ b/mdbook-pdf/headless_chrome/src/types.rs @@ -0,0 +1,367 @@ +use crate::protocol::cdp::{ + types::{Event, JsUInt}, + Browser, + Page, + DOM::Node, + Network::{CookieParam,DeleteCookies}, + Page::PrintToPDF +}; + +use serde::{Deserialize, Serialize}; + +use serde_json::Value; + +pub type CallId = JsUInt; + +use thiserror::Error; + +use anyhow::Result; + +type JsInt = i32; + +#[derive(Deserialize, Debug, PartialEq, Clone, Error)] +#[error("Method call error {}: {}", code, message)] +pub struct RemoteError { + pub code: JsInt, + pub message: String, +} + +#[derive(Deserialize, Debug, PartialEq, Clone)] +pub struct Response { + #[serde(rename(deserialize = "id"))] + pub call_id: CallId, + pub result: Option, + pub error: Option, +} + +pub fn parse_response(response: Response) -> Result +where + T: serde::de::DeserializeOwned + std::fmt::Debug, +{ + if let Some(error) = response.error { + return Err(error.into()); + } + + let result: T = serde_json::from_value(response.result.unwrap()).unwrap(); + + Ok(result) +} + +#[derive(Deserialize, Debug, Clone)] +#[serde(untagged)] +#[allow(clippy::large_enum_variant)] +pub enum Message { + Event(Event), + Response(Response), + ConnectionShutdown, +} + +#[derive(Serialize, Debug)] +pub struct TransferMode { + mode: String, +} + +impl Into> for TransferMode { + fn into(self) -> Option { + if self.mode == "base64" { + Some(Page::PrintToPDFTransfer_modeOption::ReturnAsBase64) + } else if self.mode == "stream" { + Some(Page::PrintToPDFTransfer_modeOption::ReturnAsStream) + } else { + None + } + } +} + +#[derive(Serialize, Debug)] +#[serde(rename_all = "camelCase")] +pub struct PrintToPdfOptions { + #[serde(skip_serializing_if = "Option::is_none")] + pub landscape: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub display_header_footer: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub print_background: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub scale: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub paper_width: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub paper_height: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub margin_top: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub margin_bottom: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub margin_left: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub margin_right: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub page_ranges: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub ignore_invalid_page_ranges: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub header_template: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub footer_template: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub prefer_css_page_size: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub transfer_mode: Option +} + +pub fn parse_raw_message(raw_message: &str) -> Result { + Ok(serde_json::from_str::(raw_message)?) +} + +#[derive(Clone, Debug)] +pub enum Bounds { + Minimized, + Maximized, + Fullscreen, + Normal { + /// The offset from the left edge of the screen to the window in pixels. + left: Option, + /// The offset from the top edge of the screen to the window in pixels. + top: Option, + /// The window width in pixels. + width: Option, + /// THe window height in pixels. + height: Option, + }, +} + +impl Bounds { + /// Set normal window state without setting any coordinates + pub fn normal() -> Self { + Self::Normal { + left: None, + top: None, + width: None, + height: None, + } + } +} + +impl From for DeleteCookies { + fn from(v: CookieParam) -> Self { + Self { + name: v.name, + url: v.url, + domain: v.domain, + path: v.path, + } + } +} + +impl Into for Bounds { + fn into(self) -> Browser::Bounds { + match self { + Self::Minimized => Browser::Bounds { + left: None, + top: None, + width: None, + height: None, + window_state: Some(Browser::WindowState::Minimized), + }, + Self::Maximized => Browser::Bounds { + left: None, + top: None, + width: None, + height: None, + window_state: Some(Browser::WindowState::Maximized), + }, + Self::Fullscreen => Browser::Bounds { + left: None, + top: None, + width: None, + height: None, + window_state: Some(Browser::WindowState::Fullscreen), + }, + Self::Normal { + left, + top, + width, + height, + } => Browser::Bounds { + left, + top, + width: width.and_then(|f| Some(f as u32)), + height: height.and_then(|f| Some(f as u32)), + window_state: Some(Browser::WindowState::Normal), + }, + } + } +} + +#[derive(Clone, Debug)] +pub struct CurrentBounds { + pub left: JsUInt, + pub top: JsUInt, + pub width: f64, + pub height: f64, + pub state: Browser::WindowState, +} + +impl From for CurrentBounds { + fn from(bounds: Browser::Bounds) -> Self { + Self { + left: bounds.left.unwrap(), + top: bounds.top.unwrap(), + width: bounds.width.unwrap() as f64, + height: bounds.height.unwrap() as f64, + state: bounds.window_state.unwrap(), + } + } +} + +impl Default for PrintToPDF { + fn default() -> Self { + PrintToPDF { + display_header_footer: None, + footer_template: None, + header_template: None, + ignore_invalid_page_ranges: None, + landscape: None, + margin_bottom: None, + margin_left: None, + margin_right: None, + margin_top: None, + page_ranges: None, + paper_height: None, + paper_width: None, + prefer_css_page_size: None, + print_background: None, + scale: None, + transfer_mode: None + } + } +} + +struct SearchVisitor<'a, F> { + predicate: F, + item: Option<&'a Node>, +} + +impl<'a, F: FnMut(&Node) -> bool> SearchVisitor<'a, F> { + fn new(predicate: F) -> Self { + SearchVisitor { + predicate, + item: None, + } + } + + fn visit(&mut self, n: &'a Node) { + if (self.predicate)(n) { + self.item = Some(n); + } else if self.item.is_none() { + if let Some(c) = &n.children { + c.iter().for_each(|n| self.visit(n)) + } + } + } +} + +impl Node { + /// Returns the first node for which the given closure returns true. + /// + /// Nodes are inspected breadth-first down their children. + pub fn find bool>(&self, predicate: F) -> Option<&Self> { + let mut s = SearchVisitor::new(predicate); + s.visit(self); + s.item + } +} + +#[cfg(test)] +mod tests { + use log::*; + use serde_json::json; + + use super::*; + + #[test] + fn pass_through_channel() { + env_logger::try_init().unwrap_or(()); + + let attached_to_target_json = json!({ + "method": "Target.attachedToTarget", + "params": { + "sessionId": "8BEF122ABAB0C43B5729585A537F424A", + "targetInfo": { + "targetId": "26DEBCB2A45BEFC67A84012AC32C8B2A", + "type": "page", + "title": "", + "url": "about:blank", + "attached": true, + "browserContextId": "946423F3D201EFA1A5FCF3462E340C15" + }, + "waitingForDebugger": false + } + }); + + let _event: Message = serde_json::from_value(attached_to_target_json).unwrap(); + } + + #[test] + fn parse_event_fully() { + env_logger::try_init().unwrap_or(()); + + let attached_to_target_json = json!({ + "method": "Target.attachedToTarget", + "params": { + "sessionId": "8BEF122ABAB0C43B5729585A537F424A", + "targetInfo": { + "targetId": "26DEBCB2A45BEFC67A84012AC32C8B2A", + "type": "page", + "title": "", + "url": "about:blank", + "attached": true, + "browserContextId": "946423F3D201EFA1A5FCF3462E340C15" + }, + "waitingForDebugger": false + } + }); + + if let Ok(Event::AttachedToTarget(_)) = serde_json::from_value(attached_to_target_json) { + } else { + panic!("Failed to parse event properly"); + } + + let received_target_msg_event = json!({ + "method": "Target.receivedMessageFromTarget", + "params": { + "sessionId": "8BEF122ABAB0C43B5729585A537F424A", + "message": "{\"id\":43473,\"result\":{\"data\":\"kDEgAABII=\"}}", + "targetId": "26DEBCB2A45BEFC67A84012AC32C8B2A" + } + }); + let event: Event = serde_json::from_value(received_target_msg_event).unwrap(); + match event { + Event::ReceivedMessageFromTarget(ev) => { + trace!("{:?}", ev); + } + _ => panic!("bad news"), + } + } + + #[test] + fn easy_parse_messages() { + env_logger::try_init().unwrap_or(()); + + let example_message_strings = [ + // browser method response: + "{\"id\":1,\"result\":{\"browserContextIds\":[\"C2652EACAAA12B41038F1F2137C57A6E\"]}}", + "{\"id\":2,\"result\":{\"targetInfos\":[{\"targetId\":\"225A1B90036320AB4DB2E28F04AA6EE0\",\"type\":\"page\",\"title\":\"\",\"url\":\"about:blank\",\"attached\":false,\"browserContextId\":\"04FB807A65CFCA420C03E1134EB9214E\"}]}}", + "{\"id\":3,\"result\":{}}", + // browser event: + "{\"method\":\"Target.attachedToTarget\",\"params\":{\"sessionId\":\"8BEF122ABAB0C43B5729585A537F424A\",\"targetInfo\":{\"targetId\":\"26DEBCB2A45BEFC67A84012AC32C8B2A\",\"type\":\"page\",\"title\":\"\",\"url\":\"about:blank\",\"attached\":true,\"browserContextId\":\"946423F3D201EFA1A5FCF3462E340C15\"},\"waitingForDebugger\":false}}", + // browser event which indicates target method response: + "{\"method\":\"Target.receivedMessageFromTarget\",\"params\":{\"sessionId\":\"8BEF122ABAB0C43B5729585A537F424A\",\"message\":\"{\\\"id\\\":43473,\\\"result\\\":{\\\"data\\\":\\\"iVBORw0KGgoAAAANSUhEUgAAAyAAAAJYCAYAAACadoJwAAAMa0lEQVR4nO3XMQEAIAzAMMC/5+GiHCQK+nbPzCwAAIDAeR0AAAD8w4AAAAAZAwIAAGQMCAAAkDEgAABAxoAAAAAZAwIAAGQMCAAAkDEgAABAxoAAAAAZAwIAAGQMCAAAkDEgAABAxoAAAAAZAwIAAGQMCAAAkDEgAABAxoAAAAAZAwIAAGQMCAAAkDEgAABAxoAAAAAZAwIAAGQMCAAAkDEgAABAxoAAAAAZAwIAAGQMCAAAkDEgAABAxoAAAAAZAwIAAGQMCAAAkDEgAABAxoAAAAAZAwIAAGQMCAAAkDEgAABAxoAAAAAZAwIAAGQMCAAAkDEgAABAxoAAAAAZAwIAAGQMCAAAkDEgAABAxoAAAAAZAwIAAGQMCAAAkDEgAABAxoAAAAAZAwIAAGQMCAAAkDEgAABAxoAAAAAZAwIAAGQMCAAAkDEgAABII=\\\"}}\",\"targetId\":\"26DEBCB2A45BEFC67A84012AC32C8B2A\"}}" + ]; + + for msg_string in &example_message_strings { + let _message: super::Message = parse_raw_message(msg_string).unwrap(); + } + } +} diff --git a/mdbook-pdf/headless_chrome/src/util.rs b/mdbook-pdf/headless_chrome/src/util.rs new file mode 100644 index 00000000..abbbe344 --- /dev/null +++ b/mdbook-pdf/headless_chrome/src/util.rs @@ -0,0 +1,127 @@ +use std::time::{Duration, Instant}; +use std::{collections::HashMap, thread::sleep}; + +use anyhow::{Error,Result}; + +use thiserror::Error; + +use crate::protocol::cdp::Runtime::RemoteObject; + +use crate::browser::tab::point::Point; + +#[derive(Debug, Error)] +#[error("The event waited for never came")] +pub struct Timeout; + +/// A helper to wait until some event has passed. +#[derive(Debug)] +pub struct Wait { + timeout: Duration, + sleep: Duration, +} + +impl Default for Wait { + fn default() -> Self { + Self { + timeout: Duration::from_secs(10), + sleep: Duration::from_millis(100), + } + } +} + +pub fn extract_midpoint(remote_obj: RemoteObject) -> Result { + let mut prop_map = HashMap::new(); + + match remote_obj.preview.and_then(|v| { + for prop in v.properties { + prop_map.insert(prop.name, prop.value.unwrap().parse::().unwrap()); + } + let midpoint = Point { + x: prop_map["x"] + (prop_map["width"] / 2.0), + y: prop_map["y"] + (prop_map["height"] / 2.0), + }; + + Some(midpoint) + }) { + Some(v) => return Ok(v), + None => return Ok(Point { x: 0.0, y: 0.0 }), + } +} + +impl Wait { + pub fn new(timeout: Duration, sleep: Duration) -> Self { + Self { timeout, sleep } + } + + pub fn with_timeout(timeout: Duration) -> Self { + Self { + timeout, + ..Self::default() + } + } + + pub fn with_sleep(sleep: Duration) -> Self { + Self { + sleep, + ..Self::default() + } + } + + pub fn forever() -> Self { + Self { + timeout: Duration::from_secs(u64::max_value()), + ..Self::default() + } + } + + /// Wait until the given predicate returns `Some(G)` or timeout arrives. + /// + /// Note: If your predicate function shadows potential unexpected + /// errors you should consider using `#strict_until`. + pub fn until(&self, predicate: F) -> Result + where + F: FnMut() -> Option, + { + let mut predicate = predicate; + let start = Instant::now(); + loop { + if let Some(v) = predicate() { + return Ok(v); + } + if start.elapsed() > self.timeout { + return Err(Timeout); + } + sleep(self.sleep); + } + } + + /// Wait until the given predicate returns `Ok(G)`, an unexpected error occurs or timeout arrives. + /// + /// Errors produced by the predicate are downcasted by the additional provided closure. + /// If the downcast is successful - the error is ignored, otherwise the wait is terminated + /// and `Err(error)` containing the unexpected failure is returned to the caller. + /// + /// You can use `failure::Error::downcast::` out-of-the-box, + /// if you need to ignore one expected error, or you can implement a matching closure + /// that responds to multiple error types. + pub fn strict_until(&self, predicate: F, downcast: D) -> Result + where + F: FnMut() -> Result, + D: FnMut(Error) -> Result, + { + let mut predicate = predicate; + let mut downcast = downcast; + let start = Instant::now(); + loop { + match predicate() { + Ok(value) => return Ok(value), + Err(error) => downcast(error)?, + }; + + if start.elapsed() > self.timeout { + return Err(Timeout.into()); + } + sleep(self.sleep); + } + } +} diff --git a/mdbook-pdf/headless_chrome/tests/connect_to_url.rs b/mdbook-pdf/headless_chrome/tests/connect_to_url.rs new file mode 100644 index 00000000..1f158f00 --- /dev/null +++ b/mdbook-pdf/headless_chrome/tests/connect_to_url.rs @@ -0,0 +1,17 @@ +use std::env; + +use headless_chrome::Browser; + +use anyhow::Result; + +#[test] +fn connect_to_url() -> Result<()> { + + let debug_ws_url = env::args().nth(1).expect("Must provide debug_ws_url"); + + let browser = Browser::connect(debug_ws_url.to_string()); + + assert!(browser.is_ok()); + + Ok(()) +} diff --git a/mdbook-pdf/headless_chrome/tests/coverage.rs b/mdbook-pdf/headless_chrome/tests/coverage.rs new file mode 100644 index 00000000..f6ce13bc --- /dev/null +++ b/mdbook-pdf/headless_chrome/tests/coverage.rs @@ -0,0 +1,128 @@ +use std::sync::Arc; + +use anyhow::Result; + +use headless_chrome::browser::tab::Tab; +use headless_chrome::Browser; +use server::Server; + +mod logging; +pub mod server; + +fn basic_http_response( + body: &'static str, + content_type: &'static str, +) -> tiny_http::Response<&'static [u8]> { + tiny_http::Response::new( + 200.into(), + vec![tiny_http::Header::from_bytes(&b"Content-Type"[..], content_type.as_bytes()).unwrap()], + body.as_bytes(), + Some(body.len()), + None, + ) +} + +fn server_with_html_and_js() -> Server { + Server::new(|request: tiny_http::Request| { + let url = request.url(); + + let content_type = if url.ends_with(".js") { + "application/javascript" + } else { + "text/html" + }; + + let body = if url.ends_with("coverage_fixture1.js") { + include_str!("coverage_fixtures/coverage_fixture1.js") + } else if url.ends_with("coverage_fixture2.js") { + include_str!("coverage_fixtures/coverage_fixture2.js") + } else { + include_str!("coverage_fixtures/basic_page_with_js_scripts.html") + }; + + let response = basic_http_response(body, content_type); + request.respond(response) + }) +} + +#[test] +fn returns_actual_coverage() -> Result<()> { + logging::enable_logging(); + let server = server_with_html_and_js(); + let browser = Browser::default()?; + let tab: Arc = browser.wait_for_initial_tab()?; + + tab.enable_profiler()?; + tab.start_js_coverage()?; + + let url = format!("http://127.0.0.1:{}", server.port()); + tab.navigate_to(&url)?; + + tab.wait_until_navigated()?; + + let script_coverages = tab.take_precise_js_coverage()?; + + dbg!(&script_coverages); + + // our fixtures HTML file (basic_page_with_js_scripts.html) includes two external scripts + assert_eq!(2, script_coverages.len()); + + let first_script = script_coverages + .iter() + .find(|script_coverage| script_coverage.url.ends_with("coverage_fixture1.js")) + .unwrap(); + + // in coverage_fixture1.js, there are two anonymous functions and one nameless "function" that + // you can imagine as being the global scope (i.e. the top level scope of the script) + assert_eq!(3, first_script.functions.len()); + + // this one should not have been executed yet: + + let on_click_function_coverage = first_script + .functions + .iter() + .find(|function_coverage| function_coverage.function_name == "button.onclick") + .unwrap(); + + let fn_range = on_click_function_coverage.ranges.first().unwrap(); + assert_eq!(fn_range.count, 0); + + let button = tab.wait_for_element("#incrementor")?; + button.click()?; + + let result = tab.take_precise_js_coverage()?; + + let updated_script_coverages: Vec<_> = result + .iter() + // discludes 'anonymous' scripts we inject into the page + .filter(|script_cov| script_cov.url.starts_with("http://")) + .collect(); + + dbg!(&updated_script_coverages); + + // when we clicked the button, code in only one of the scripts was executed, and Chrome + // only sends back info about code that's been executed since you last "took" the coverage: + assert_eq!(1, updated_script_coverages.len()); + + let updated_on_click_function_coverage = updated_script_coverages + .first() + .unwrap() + .functions + .first() + .unwrap(); + + assert_eq!( + "button.onclick", + updated_on_click_function_coverage.function_name + ); + assert_eq!( + 1, + updated_on_click_function_coverage + .ranges + .first() + .unwrap() + .count + ); + + Ok(()) +} diff --git a/mdbook-pdf/headless_chrome/tests/coverage_fixtures/basic_page_with_js_scripts.html b/mdbook-pdf/headless_chrome/tests/coverage_fixtures/basic_page_with_js_scripts.html new file mode 100644 index 00000000..13546836 --- /dev/null +++ b/mdbook-pdf/headless_chrome/tests/coverage_fixtures/basic_page_with_js_scripts.html @@ -0,0 +1,13 @@ + + + + + + + + + \ No newline at end of file diff --git a/mdbook-pdf/headless_chrome/tests/coverage_fixtures/coverage_fixture1.js b/mdbook-pdf/headless_chrome/tests/coverage_fixtures/coverage_fixture1.js new file mode 100644 index 00000000..8252ecb4 --- /dev/null +++ b/mdbook-pdf/headless_chrome/tests/coverage_fixtures/coverage_fixture1.js @@ -0,0 +1,8 @@ +window.onload = function() { + var loaded = true; +}; +var button = document.getElementById("incrementor"); +button.onclick = function() { + var clicked = true; +}; + diff --git a/mdbook-pdf/headless_chrome/tests/coverage_fixtures/coverage_fixture2.js b/mdbook-pdf/headless_chrome/tests/coverage_fixtures/coverage_fixture2.js new file mode 100644 index 00000000..d00e9d09 --- /dev/null +++ b/mdbook-pdf/headless_chrome/tests/coverage_fixtures/coverage_fixture2.js @@ -0,0 +1,3 @@ +function thisIsNeverExecuted() { + +} \ No newline at end of file diff --git a/mdbook-pdf/headless_chrome/tests/events_fixtures/events_page.html b/mdbook-pdf/headless_chrome/tests/events_fixtures/events_page.html new file mode 100644 index 00000000..5b661ed3 --- /dev/null +++ b/mdbook-pdf/headless_chrome/tests/events_fixtures/events_page.html @@ -0,0 +1,18 @@ + + + + + + + diff --git a/mdbook-pdf/headless_chrome/tests/events_listeners.rs b/mdbook-pdf/headless_chrome/tests/events_listeners.rs new file mode 100644 index 00000000..2148a7b7 --- /dev/null +++ b/mdbook-pdf/headless_chrome/tests/events_listeners.rs @@ -0,0 +1,85 @@ +use std::sync::{Arc, Mutex}; + +use anyhow::Result; + +use headless_chrome::browser::tab::Tab; +use headless_chrome::Browser; +use headless_chrome::protocol::cdp::types::Event; + +mod server; + +#[test] +fn listen_to_events() -> Result<()> { + let server = server::Server::with_dumb_html(include_str!("events_fixtures/events_page.html")); + + let counter_log_entries = Arc::new(Mutex::new(0)); + let counter_exception_thrown = Arc::new(Mutex::new(0)); + + let browser = Browser::default()?; + let tab: Arc = browser.wait_for_initial_tab()?; + + tab.enable_log()?.enable_runtime()?; + + let counter_log_entries_clone = Arc::clone(&counter_log_entries); + let counter_exception_thrown_clone = Arc::clone(&counter_exception_thrown); + + let sync_event = move |event: &Event| match event { + Event::LogEntryAdded(_) => { + *counter_log_entries_clone.lock().unwrap() += 1; + } + Event::RuntimeExceptionThrown(_) => { + *counter_exception_thrown_clone.lock().unwrap() += 1; + } + _ => {} + }; + + tab.add_event_listener(Arc::new(sync_event))?; + + let url = format!("http://127.0.0.1:{}", server.port()); + tab.navigate_to(&url)?.wait_until_navigated()?; + + assert_eq!(*counter_log_entries.lock().unwrap(), 1); + assert_eq!(*counter_exception_thrown.lock().unwrap(), 1); + Ok(()) +} + +#[test] +fn remove_event_listener() -> Result<()> { + let server = server::Server::with_dumb_html(include_str!("events_fixtures/events_page.html")); + + let counter_log_entries = Arc::new(Mutex::new(0)); + let counter_exception_thrown = Arc::new(Mutex::new(0)); + + let browser = Browser::default()?; + let tab: Arc = browser.wait_for_initial_tab()?; + + tab.enable_log()?.enable_runtime()?; + + let counter_log_entries_clone = Arc::clone(&counter_log_entries); + let counter_exception_thrown_clone = Arc::clone(&counter_exception_thrown); + + let sync_event = move |event: &Event| { + if let Event::LogEntryAdded(_) = event { + *counter_log_entries_clone.lock().unwrap() += 1; + } + }; + + let runtime_event = move |event: &Event| { + if let Event::RuntimeExceptionThrown(_) = event { + *counter_exception_thrown_clone.lock().unwrap() += 1; + } + }; + + tab.add_event_listener(Arc::new(sync_event))?; + + let runtime_listener = tab.add_event_listener(Arc::new(runtime_event))?; + + tab.remove_event_listener(&runtime_listener)?; + + let url = format!("http://127.0.0.1:{}", server.port()); + tab.navigate_to(&url)?.wait_until_navigated()?; + + assert_eq!(*counter_log_entries.lock().unwrap(), 1); + assert_eq!(*counter_exception_thrown.lock().unwrap(), 0); + Ok(()) +} diff --git a/mdbook-pdf/headless_chrome/tests/expose_function.rs b/mdbook-pdf/headless_chrome/tests/expose_function.rs new file mode 100644 index 00000000..1189eb60 --- /dev/null +++ b/mdbook-pdf/headless_chrome/tests/expose_function.rs @@ -0,0 +1,36 @@ +use std::sync::{Arc, Mutex}; + +use headless_chrome::browser::tab::Tab; +use headless_chrome::Browser; + +mod server; + +use anyhow::Result; + +#[test] +fn expose_function() -> Result<()> { + let server = server::Server::with_dumb_html(include_str!("simple.html")); + + let function_called_entries = Arc::new(Mutex::new(0)); + + let browser = Browser::default()?; + let tab: Arc = browser.wait_for_initial_tab()?; + + let function_called_entries_clone = Arc::clone(&function_called_entries); + + let url = format!("http://127.0.0.1:{}", server.port()); + tab.navigate_to(&url)?.wait_until_navigated()?; + + tab.expose_function( + "simple", + Arc::new(move |_value| { + *function_called_entries_clone.lock().unwrap() += 1; + }), + )?; + + tab.evaluate("window.simple('100')", false)?; + + assert_eq!(*function_called_entries.lock().unwrap(), 1); + + Ok(()) +} diff --git a/mdbook-pdf/headless_chrome/tests/extension.rs b/mdbook-pdf/headless_chrome/tests/extension.rs new file mode 100644 index 00000000..ba64ea6a --- /dev/null +++ b/mdbook-pdf/headless_chrome/tests/extension.rs @@ -0,0 +1,20 @@ +use std::ffi::OsStr; + +use anyhow::Result; + +use headless_chrome::{browser::default_executable, Browser, LaunchOptions}; + +#[test] +fn test_extension() -> Result<()> { + Browser::new( + LaunchOptions::default_builder() + .path(Some(default_executable().unwrap())) + .extensions(vec![OsStr::new("tests/extension_sampl")]) + .build() + .unwrap(), + ) + .unwrap(); + // if there is popup like missing manifest.json + // that could probably mean that extension didn't load successfully + Ok(()) +} diff --git a/mdbook-pdf/headless_chrome/tests/extension_sample/background.js b/mdbook-pdf/headless_chrome/tests/extension_sample/background.js new file mode 100644 index 00000000..8e32a39d --- /dev/null +++ b/mdbook-pdf/headless_chrome/tests/extension_sample/background.js @@ -0,0 +1,5 @@ +chrome.runtime.onInstalled.addListener(function() { + chrome.storage.sync.set({color: '#3aa757'}, function() { + console.log("The color is green."); + }); + }); \ No newline at end of file diff --git a/mdbook-pdf/headless_chrome/tests/extension_sample/manifest.json b/mdbook-pdf/headless_chrome/tests/extension_sample/manifest.json new file mode 100644 index 00000000..4a4da011 --- /dev/null +++ b/mdbook-pdf/headless_chrome/tests/extension_sample/manifest.json @@ -0,0 +1,11 @@ +{ + "name": "Getting Started Example", + "version": "1.0", + "description": "Build an Extension!", + "permissions": ["storage"], + "background": { + "scripts": ["background.js"], + "persistent": false + }, + "manifest_version": 2 +} \ No newline at end of file diff --git a/mdbook-pdf/headless_chrome/tests/file_chooser.rs b/mdbook-pdf/headless_chrome/tests/file_chooser.rs new file mode 100644 index 00000000..af301b23 --- /dev/null +++ b/mdbook-pdf/headless_chrome/tests/file_chooser.rs @@ -0,0 +1,67 @@ +use std::fs::File; + +use anyhow::{Context, Result}; +use filepath::FilePath; +use regex::Regex; + +use headless_chrome::{Browser, LaunchOptionsBuilder}; + +pub mod logging; +mod server; + +#[test] +fn file_chooser_works() -> Result<()> { + logging::enable_logging(); + let browser = Browser::new(LaunchOptionsBuilder::default().headless(false).build().unwrap())?; + // let version = browser.get_version()?; + // let version_number_re: Regex = Regex::new(r"HeadlessChrome/(\d+)\.").unwrap(); + // let version_number: u8 = version_number_re.captures(&version.product).unwrap()[1] + // .parse() + // .unwrap(); + + // if version_number > 76 { + let tab = browser.wait_for_initial_tab()?; + let server = + server::Server::with_dumb_html(include_str!("file_chooser_fixtures/chooser.html")); + + tab.navigate_to(&server.url())?; + + tab.set_file_chooser_dialog_interception(true)?; + + let file_upload_button = tab.wait_for_element("input[type='file']")?; + // file_upload_button.click()?; + + // uses 'filepath' crate to get absolute path + let test_file = File::open("tests/file_chooser_fixtures/file_to_upload.txt")?; + let path = test_file.path()?; + + tab.handle_file_chooser( + vec![path.to_string_lossy().into_owned()], + file_upload_button.node_id + )?; + + let eval_result = + file_upload_button.call_js_fn("function() { return this.files[0]; }", vec![],false)?; + + let size_from_js: u64 = eval_result + .preview + .context("Object preview is not available. the object is empty") + .unwrap() + .properties + .iter() + .find_map(|property_preview| { + if property_preview.name == "size" { + Some(property_preview.value.as_ref().context("Object value is unavailable").unwrap()) + } else { + None + } + }) + .context("Returned value is empty") + .unwrap() + .parse()?; + + assert_eq!(size_from_js, test_file.metadata()?.len()); + // } + + Ok(()) +} diff --git a/mdbook-pdf/headless_chrome/tests/file_chooser_fixtures/chooser.html b/mdbook-pdf/headless_chrome/tests/file_chooser_fixtures/chooser.html new file mode 100644 index 00000000..793ebc67 --- /dev/null +++ b/mdbook-pdf/headless_chrome/tests/file_chooser_fixtures/chooser.html @@ -0,0 +1,9 @@ + + + +
+ + +
+ + \ No newline at end of file diff --git a/mdbook-pdf/headless_chrome/tests/file_chooser_fixtures/file_to_upload.txt b/mdbook-pdf/headless_chrome/tests/file_chooser_fixtures/file_to_upload.txt new file mode 100644 index 00000000..b6fc4c62 --- /dev/null +++ b/mdbook-pdf/headless_chrome/tests/file_chooser_fixtures/file_to_upload.txt @@ -0,0 +1 @@ +hello \ No newline at end of file diff --git a/mdbook-pdf/headless_chrome/tests/form.html b/mdbook-pdf/headless_chrome/tests/form.html new file mode 100644 index 00000000..b4d6cebb --- /dev/null +++ b/mdbook-pdf/headless_chrome/tests/form.html @@ -0,0 +1,23 @@ + + + +
+ + + +
+
+ + diff --git a/mdbook-pdf/headless_chrome/tests/local_storage.rs b/mdbook-pdf/headless_chrome/tests/local_storage.rs new file mode 100644 index 00000000..cc74d630 --- /dev/null +++ b/mdbook-pdf/headless_chrome/tests/local_storage.rs @@ -0,0 +1,50 @@ +use anyhow::Result; +use headless_chrome::{Browser, LaunchOptionsBuilder}; +use serde::{Deserialize, Serialize}; + +mod server; + +#[derive(Serialize, Deserialize, Debug)] +struct Item { + pub value: i32, +} + +#[test] +fn read_write_local_storage() -> Result<()> { + let server = server::Server::with_dumb_html(include_str!("simple.html")); + + let browser = Browser::new( + LaunchOptionsBuilder::default() + .headless(true) + .build() + .unwrap(), + ) + .unwrap(); + + let tab = browser.wait_for_initial_tab()?; + + let item_value = "cb2a8cd9"; + + let url = format!("http://127.0.0.1:{}", server.port()); + tab.navigate_to(&url)?.wait_until_navigated()?; + + let value: String = tab.get_storage("translationHash")?; + + assert_ne!("", &value); + + tab.set_storage("translationHash", item_value)?; + + let new_value: String = tab.get_storage("translationHash")?; + + assert_eq!(item_value, new_value); + + tab.remove_storage("translationHash")?; + + assert_eq!(true, tab.get_storage::("translationHash").is_err()); + + let item: Item = tab.get_storage("testItem")?; + + assert_eq!(300,item.value); + + Ok(()) +} diff --git a/mdbook-pdf/headless_chrome/tests/logging.rs b/mdbook-pdf/headless_chrome/tests/logging.rs new file mode 100644 index 00000000..e5a58aaa --- /dev/null +++ b/mdbook-pdf/headless_chrome/tests/logging.rs @@ -0,0 +1 @@ +include!("../src/testing_utils/logging.rs"); diff --git a/mdbook-pdf/headless_chrome/tests/logs.rs b/mdbook-pdf/headless_chrome/tests/logs.rs new file mode 100644 index 00000000..becfa958 --- /dev/null +++ b/mdbook-pdf/headless_chrome/tests/logs.rs @@ -0,0 +1,30 @@ +use std::sync::Arc; + +use anyhow::Result; + +use headless_chrome::browser::tab::Tab; +use headless_chrome::Browser; + +pub mod logging; +mod server; + +#[test] +fn enable_and_disable_logs() -> Result<()> { + logging::enable_logging(); + let server = server::Server::with_dumb_html(include_str!( + "logs_fixtures/basic_page_with_console_messages.html" + )); + let browser = Browser::default()?; + let tab: Arc = browser.wait_for_initial_tab()?; + + tab.enable_log()?; + + let url = format!("http://127.0.0.1:{}", server.port()); + tab.navigate_to(&url)?; + + tab.wait_until_navigated()?; + + tab.disable_log()?; + + Ok(()) +} diff --git a/mdbook-pdf/headless_chrome/tests/logs_fixtures/basic_page_with_console_messages.html b/mdbook-pdf/headless_chrome/tests/logs_fixtures/basic_page_with_console_messages.html new file mode 100644 index 00000000..37fa005c --- /dev/null +++ b/mdbook-pdf/headless_chrome/tests/logs_fixtures/basic_page_with_console_messages.html @@ -0,0 +1,15 @@ + + + + + + + + diff --git a/mdbook-pdf/headless_chrome/tests/pdfassets/index.html b/mdbook-pdf/headless_chrome/tests/pdfassets/index.html new file mode 100644 index 00000000..1d2e1b7a --- /dev/null +++ b/mdbook-pdf/headless_chrome/tests/pdfassets/index.html @@ -0,0 +1,17 @@ + + + + + +The Rust Programming Language + + + +
+ +

Empowering everyone to build reliable and efficient software.

+
+ + + + diff --git a/mdbook-pdf/headless_chrome/tests/pdfassets/rust-logo.svg b/mdbook-pdf/headless_chrome/tests/pdfassets/rust-logo.svg new file mode 100644 index 00000000..65ac6b1e --- /dev/null +++ b/mdbook-pdf/headless_chrome/tests/pdfassets/rust-logo.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/mdbook-pdf/headless_chrome/tests/pdfassets/style.css b/mdbook-pdf/headless_chrome/tests/pdfassets/style.css new file mode 100644 index 00000000..b3a7e926 --- /dev/null +++ b/mdbook-pdf/headless_chrome/tests/pdfassets/style.css @@ -0,0 +1,7 @@ +@page { + margin: 10px 10px 10px 10px; +} + +h1 { + font-size: 50px; +} diff --git a/mdbook-pdf/headless_chrome/tests/server.rs b/mdbook-pdf/headless_chrome/tests/server.rs new file mode 100644 index 00000000..cf8203d3 --- /dev/null +++ b/mdbook-pdf/headless_chrome/tests/server.rs @@ -0,0 +1 @@ +include!("../src/testing_utils/server.rs"); diff --git a/mdbook-pdf/headless_chrome/tests/shadow-dom.html b/mdbook-pdf/headless_chrome/tests/shadow-dom.html new file mode 100644 index 00000000..2eb159a9 --- /dev/null +++ b/mdbook-pdf/headless_chrome/tests/shadow-dom.html @@ -0,0 +1,24 @@ + + +
some text
+
+
+
+ + + + diff --git a/mdbook-pdf/headless_chrome/tests/simple.html b/mdbook-pdf/headless_chrome/tests/simple.html new file mode 100644 index 00000000..a76e786a --- /dev/null +++ b/mdbook-pdf/headless_chrome/tests/simple.html @@ -0,0 +1,91 @@ + + + + + + + + +
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/mdbook-pdf/headless_chrome/tests/simple.rs b/mdbook-pdf/headless_chrome/tests/simple.rs new file mode 100644 index 00000000..6badf082 --- /dev/null +++ b/mdbook-pdf/headless_chrome/tests/simple.rs @@ -0,0 +1,890 @@ +#![allow(unused_variables)] + +use std::sync::{Arc, Mutex}; +use std::thread::sleep; +use std::time::{Duration, Instant}; + +use anyhow::Result; +use headless_chrome::protocol::cdp::Browser::WindowState; +use headless_chrome::protocol::cdp::DOM::RGBA; +use headless_chrome::protocol::cdp::Fetch::events::RequestPausedEvent; +use headless_chrome::protocol::cdp::Fetch::{ + FulfillRequest, HeaderEntry, RequestPattern, RequestStage, +}; +use headless_chrome::protocol::cdp::Network::{Cookie, CookieParam, InterceptionStage}; +use headless_chrome::protocol::cdp::Page::CaptureScreenshotFormatOption; +use headless_chrome::protocol::cdp::Runtime::{RemoteObjectSubtype, RemoteObjectType}; +use headless_chrome::types::{RemoteError, Bounds}; +use headless_chrome::LaunchOptionsBuilder; +use log::*; +use rand::prelude::*; + +use headless_chrome::browser::tab::RequestPausedDecision; +use headless_chrome::browser::transport::{SessionId, Transport}; +use headless_chrome::util::Wait; +use headless_chrome::{Browser, Tab}; +use std::collections::HashMap; + +pub mod logging; +pub mod server; + +/// Launches a dumb server that unconditionally serves the given data as a +/// successful html response; launches a new browser and navigates to the +/// server. +/// +/// Users must hold on to the server, which stops when dropped. +fn dumb_server(data: &'static str) -> (server::Server, Browser, Arc) { + let server = server::Server::with_dumb_html(data); + let (browser, tab) = dumb_client(&server); + (server, browser, tab) +} + +fn browser() -> Browser { + Browser::new( + LaunchOptionsBuilder::default() + .headless(true) + .build() + .unwrap(), + ) + .unwrap() +} + +fn dumb_client(server: &server::Server) -> (Browser, Arc) { + let browser = browser(); + let tab = browser.wait_for_initial_tab().unwrap(); + tab.navigate_to(&format!("http://127.0.0.1:{}", server.port())) + .unwrap(); + (browser, tab) +} + +#[test] +fn simple() -> Result<()> { + logging::enable_logging(); + let (server, browser, tab) = dumb_server(include_str!("simple.html")); + tab.wait_for_element("div#foobar")?; + Ok(()) +} + +// NOTE: we disable this test for Mac, because Travis doesn't support xvfb as a 'service' +#[cfg(target_os = "linux")] +#[test] +fn bounds_changed() -> Result<(), anyhow::Error> { + logging::enable_logging(); + let browser = browser(); + let tab = browser.wait_for_initial_tab().unwrap(); + + // New browser windows start in normal (windowed) state + let bounds = tab.get_bounds()?; + assert_eq!(bounds.state, WindowState::Normal); + + // Return to normal window size, setting only the coordinates + tab.set_bounds(Bounds::Normal { + left: Some(5), + top: Some(5), + width: None, + height: None, + })?; + let new_bounds = tab.get_bounds()?; + assert_eq!(new_bounds.state, WindowState::Normal); + assert_eq!(new_bounds.left, 5); + assert_eq!(new_bounds.top, 5); + assert_eq!(new_bounds.width, bounds.width); + assert_eq!(new_bounds.height, bounds.height); + + tab.set_bounds(Bounds::Normal { + left: None, + top: None, + width: Some(200.0), + height: Some(100.0), + })?; + let new_bounds = tab.get_bounds()?; + assert_eq!(new_bounds.state, WindowState::Normal); + assert_eq!(new_bounds.left, 5); + assert_eq!(new_bounds.top, 5); + assert_eq!(new_bounds.width, 200.0); + assert_eq!(new_bounds.height, 100.0); + Ok(()) +} + +#[test] +fn bounds_unchanged() -> Result<(), anyhow::Error> { + logging::enable_logging(); + let browser = browser(); + let tab = browser.wait_for_initial_tab().unwrap(); + let bounds = tab.get_bounds()?; + + // Minimizing a window does *not* change it's bounds + tab.set_bounds(Bounds::Minimized)?; + let min_bounds = tab.get_bounds()?; + assert_eq!(min_bounds.state, WindowState::Minimized); + assert_eq!(min_bounds.left, bounds.left); + assert_eq!(min_bounds.top, bounds.top); + assert_eq!(min_bounds.width, bounds.width); + assert_eq!(min_bounds.height, bounds.height); + + // Maximizing a window does *not* change it's bounds + tab.set_bounds(Bounds::Maximized)?; + let max_bounds = tab.get_bounds()?; + assert_eq!(max_bounds.state, WindowState::Maximized); + assert_eq!(max_bounds.left, bounds.left); + assert_eq!(max_bounds.top, bounds.top); + assert!(max_bounds.width >= bounds.width); + assert!(max_bounds.height >= bounds.height); + + // Setting a window to fullscreen does *not* change it's bounds + tab.set_bounds(Bounds::Fullscreen)?; + let fs_bounds = tab.get_bounds()?; + assert_eq!(fs_bounds.state, WindowState::Fullscreen); + assert_eq!(fs_bounds.left, bounds.left); + assert_eq!(fs_bounds.top, bounds.top); + assert!(fs_bounds.width >= bounds.width); + assert!(fs_bounds.height >= bounds.height); + + Ok(()) +} + +#[test] +fn actions_on_tab_wont_hang_after_browser_drops() -> Result<()> { + logging::enable_logging(); + for _ in 0..20 { + let (_, browser, tab) = dumb_server(include_str!("simple.html")); + std::thread::spawn(move || { + let mut rng = rand::thread_rng(); + let millis: u64 = rng.gen_range(0, 5000); + std::thread::sleep(std::time::Duration::from_millis(millis)); + trace!("dropping browser"); + drop(browser); + }); + let _element = tab.find_element("div#foobar"); + } + Ok(()) +} + +#[test] +fn form_interaction() -> Result<()> { + logging::enable_logging(); + let (_, browser, tab) = dumb_server(include_str!("form.html")); + tab.wait_for_element("input#target")? + .type_into("mothership")?; + tab.wait_for_element("button")?.click()?; + let d = tab.wait_for_element("div#protocol")?.get_description()?; + assert!(d + .find(|n| n.node_value == "Missiles launched against mothership") + .is_some()); + tab.wait_for_element("input#sneakattack")?.click()?; + tab.wait_for_element("button")?.click()?; + let d = tab.wait_for_element("div#protocol")?.get_description()?; + assert!(d + .find(|n| n.node_value == "Comrades, have a nice day!") + .is_some()); + Ok(()) +} + +fn decode_png(i: &[u8]) -> Result> { + let decoder = png::Decoder::new(&i[..]); + let (info, mut reader) = decoder.read_info()?; + let mut buf = vec![0; info.buffer_size()]; + reader.next_frame(&mut buf)?; + Ok(buf) +} + +fn sum_of_errors(inp: &[u8], fixture: &[u8]) -> u32 { + inp.chunks_exact(fixture.len()) + .map(|c| { + c.iter() + .zip(fixture) + .map(|(b, e)| (i32::from(*b) - i32::from(*e)).pow(2) as u32) + .sum::() + }) + .sum() +} + +#[test] +fn set_background_color() -> Result<()> { + logging::enable_logging(); + let (_, browser, tab) = dumb_server(include_str!("transparent.html")); + tab.wait_for_element("body")?; + // Check that the top-left pixel on the page has the background color set in transparent.html + tab.set_background_color(RGBA { + r: 255, + g: 0, + b: 0, + a: Some(1.), + })?; + let png_data = tab.capture_screenshot(CaptureScreenshotFormatOption::Png, None, None,true)?; + let buf = decode_png(&png_data[..])?; + assert!(sum_of_errors(&buf[0..4], &[0xff, 0x00, 0x00, 0xff]) < 5); + Ok(()) +} + +#[test] +fn set_transparent_background_color() -> Result<()> { + logging::enable_logging(); + let (_, browser, tab) = dumb_server(include_str!("transparent.html")); + tab.wait_for_element("body")?; + // Check that the top-left pixel on the page has the background color set in transparent.html + tab.set_transparent_background_color()?; + let png_data = tab.capture_screenshot(CaptureScreenshotFormatOption::Png, None,None, true)?; + let buf = decode_png(&png_data[..])?; + assert!(sum_of_errors(&buf[0..4], &[0x00, 0x00, 0x00, 0x00]) < 5); + Ok(()) +} + + +#[test] +fn capture_screenshot_png() -> Result<()> { + logging::enable_logging(); + let (_, browser, tab) = dumb_server(include_str!("simple.html")); + tab.wait_for_element("div#foobar")?; + // Check that the top-left pixel on the page has the background color set in simple.html + let png_data = + tab.capture_screenshot(CaptureScreenshotFormatOption::Png, None, None, true)?; + let buf = decode_png(&png_data[..])?; + assert!(sum_of_errors(&buf[0..4], &[0x11, 0x22, 0x33, 0xff]) < 5); + Ok(()) +} + +#[test] +fn capture_screenshot_element() -> Result<()> { + logging::enable_logging(); + let (_, browser, tab) = dumb_server(include_str!("simple.html")); + // Check that the screenshot of the div's content-box has no other color than the one set in simple.html + let png_data = tab + .wait_for_element("div#foobar")? + .capture_screenshot(CaptureScreenshotFormatOption::Png)?; + let buf = decode_png(&png_data[..])?; + for i in 0..buf.len() / 4 { + assert!(sum_of_errors(&buf[i * 4..(i + 1) * 4], &[0x33, 0x22, 0x11, 0xff]) < 5); + } + Ok(()) +} + +#[test] +fn capture_screenshot_element_box() -> Result<()> { + logging::enable_logging(); + let (_, browser, tab) = dumb_server(include_str!("simple.html")); + // Check that the top-left pixel of the div's border-box has the border's color set in simple.html + let pox = tab.wait_for_element("div#foobar")?.get_box_model()?; + let png_data = tab.capture_screenshot( + CaptureScreenshotFormatOption::Png, + None, + Some(pox.border_viewport()), + true, + )?; + let buf = decode_png(&png_data[..])?; + assert!(dbg!(sum_of_errors(&buf[0..4], &[0x22, 0x11, 0x33, 0xff])) < 15); + Ok(()) +} + +#[test] +fn capture_screenshot_jpeg() -> Result<()> { + logging::enable_logging(); + let (_, browser, tab) = dumb_server(include_str!("simple.html")); + tab.wait_for_element("div#foobar")?; + let jpg_data = + tab.capture_screenshot(CaptureScreenshotFormatOption::Jpeg, Some(100), None, true)?; + let mut decoder = jpeg_decoder::Decoder::new(&jpg_data[..]); + let buf = decoder.decode().unwrap(); + assert!(sum_of_errors(&buf[0..4], &[0x11, 0x22, 0x33]) < 5); + Ok(()) +} + +#[test] +fn test_print_file_to_pdf() -> Result<()> { + logging::enable_logging(); + let (_, browser, tab) = dumb_server(include_str!("./pdfassets/index.html")); + let local_pdf = tab.wait_until_navigated()?.print_to_pdf(None)?; + assert_eq!(true, local_pdf.len() > 1000); // an arbitrary size + assert!(local_pdf.starts_with(b"%PDF")); + Ok(()) +} + +#[test] +fn get_box_model() -> Result<()> { + logging::enable_logging(); + let (_, browser, tab) = dumb_server(include_str!("simple.html")); + let pox = tab.wait_for_element("div#foobar")?.get_box_model()?; + // Check that the div has exactly the dimensions we set in simple.html + assert_eq!(pox.width as i32, 3 + 100 + 3); + assert_eq!(pox.height as i32, 3 + 20 + 3); + Ok(()) +} + +#[test] +fn box_model_geometry() -> Result<()> { + logging::enable_logging(); + let (_, browser, tab) = dumb_server(include_str!("simple.html")); + let center = tab.wait_for_element("div#position-test")?.get_box_model()?; + let within = tab.wait_for_element("div#within")?.get_box_model()?; + let above = tab + .wait_for_element("div#strictly-above")? + .get_box_model()?; + let below = tab + .wait_for_element("div#strictly-below")? + .get_box_model()?; + let left = tab.wait_for_element("div#strictly-left")?.get_box_model()?; + let right = tab + .wait_for_element("div#strictly-right")? + .get_box_model()?; + + assert!(above.content.strictly_above(¢er.content)); + assert!(above.content.above(¢er.content)); + assert!(above.margin.above(¢er.content)); + assert!(!above.margin.strictly_above(¢er.content)); + assert!(above.content.within_horizontal_bounds_of(¢er.content)); + assert!(!above.content.within_vertical_bounds_of(¢er.content)); + + assert!(below.content.strictly_below(¢er.content)); + assert!(below.content.below(¢er.content)); + assert!(below.margin.below(¢er.content)); + assert!(!below.margin.strictly_below(¢er.content)); + + assert!(left.content.strictly_left_of(¢er.content)); + assert!(left.content.left_of(¢er.content)); + assert!(left.margin.left_of(¢er.content)); + assert!(!left.margin.strictly_left_of(¢er.content)); + assert!(!left.content.within_horizontal_bounds_of(¢er.content)); + assert!(left.content.within_vertical_bounds_of(¢er.content)); + + assert!(right.content.strictly_right_of(¢er.content)); + assert!(right.content.right_of(¢er.content)); + assert!(right.margin.right_of(¢er.content)); + assert!(!right.margin.strictly_right_of(¢er.content)); + + assert!(within.content.within_bounds_of(¢er.content)); + assert!(!center.content.within_bounds_of(&within.content)); + + Ok(()) +} + +#[test] +fn reload() -> Result<()> { + logging::enable_logging(); + let mut counter = 0; + let responder = move |r: tiny_http::Request| { + let response = tiny_http::Response::new( + 200.into(), + vec![tiny_http::Header::from_bytes(&b"Content-Type"[..], &b"text/html"[..]).unwrap()], + std::io::Cursor::new(format!(r#"
{}
"#, counter)), + None, + None, + ); + trace!("{}", counter); + counter += 1; + r.respond(response) + }; + let server = server::Server::new(responder); + let (browser, tab) = dumb_client(&server); + assert!(tab + .wait_for_element("div#counter")? + .get_description()? + .find(|n| n.node_value == "0") + .is_some()); + assert!(tab + .reload(false, None)? + .wait_for_element("div#counter")? + .get_description()? + .find(|n| n.node_value == "1") + .is_some()); + // TODO test effect of scriptEvaluateOnLoad + Ok(()) +} + +#[test] +fn find_elements() -> Result<()> { + logging::enable_logging(); + let (server, browser, tab) = dumb_server(include_str!("simple.html")); + let divs = tab.wait_for_elements("div")?; + let divs_xpath = tab.wait_for_elements_by_xpath("//*[@id]")?; + assert_eq!(8, divs.len()); + assert_eq!(7, divs_xpath.len()); + Ok(()) +} + +/* +#[test] +fn find_element_on_tab_and_other_elements() -> Result<()> { + logging::enable_logging(); + let (server, browser, tab) = dumb_server(include_str!("simple.html")); + let containing_element = tab.find_element("div#position-test")?; + let inner_element = containing_element.find_element("#strictly-above")?; + dbg!(&inner_element); + let attrs = inner_element.get_attributes()?.unwrap(); + assert_eq!(attrs["id"], "strictly-above"); + Ok(()) +} +*/ + +#[test] +fn find_element_on_tab_by_xpath() -> Result<()> { + logging::enable_logging(); + let (server, browser, tab) = dumb_server(include_str!("simple.html")); + let containing_element_xpath = tab.wait_for_xpath("/html/body/div[2]")?; + let inner_element_xpath = + containing_element_xpath.wait_for_xpath(r#"//*[@id="strictly-above"]"#)?; + dbg!(&inner_element_xpath); + let attrs = inner_element_xpath.get_attributes()?.unwrap(); + let id: Vec<&String> = attrs.iter().filter(|v| v.as_str() == "id").collect(); + assert_eq!(id[0].as_str(), "strictly-above"); + + Ok(()) +} + +#[test] +fn set_user_agent() -> Result<()> { + logging::enable_logging(); + let (server, browser, tab) = dumb_server( + r#" + + + + + +"#, + ); + tab.set_user_agent("UnitTestClient", Some("de-DE-1996"), Some("UnitTest"))?; + // The test-tab has already navigated once, so reload to ensure that js + // environment is using the correct values. + tab.reload(true, None)?; + assert!(tab + .wait_for_element("body")? + .get_description()? + .find(|n| n + .node_value + .starts_with("UnitTestClient;UnitTest;de-DE-1996")) + .is_some()); + Ok(()) +} + +#[test] +fn wait_for_element_returns_unexpected_errors_early() -> Result<()> { + logging::enable_logging(); + let (server, browser, tab) = dumb_server(include_str!("simple.html")); + let start = Instant::now(); + let remote_error = tab + .wait_for_element("") // pass an invalid selector + .unwrap_err() + .downcast::()?; + assert_eq!(remote_error.message, "DOM Error while querying"); + assert!(start.elapsed() < Duration::from_secs(1)); + Ok(()) +} + +#[test] +fn call_js_fn_sync() -> Result<()> { + logging::enable_logging(); + let (server, browser, tab) = dumb_server(include_str!("simple.html")); + let element = tab.wait_for_element("#foobar")?; + let result = element.call_js_fn("function() { return 42 }", vec![], false)?; + assert_eq!(result.Type, RemoteObjectType::Number); + assert_eq!(result.description, Some("42".to_owned())); + assert_eq!(result.value, Some((42).into())); + Ok(()) +} + +#[test] +fn call_js_fn_async_unresolved() -> Result<()> { + logging::enable_logging(); + let (server, browser, tab) = dumb_server(include_str!("simple.html")); + let element = tab.wait_for_element("#foobar")?; + let result = element.call_js_fn("async function() { return 42 }", vec![], false)?; + assert_eq!(result.Type, RemoteObjectType::Object); + assert_eq!(result.subtype, Some(RemoteObjectSubtype::Promise)); + assert_eq!(result.description, Some("Promise".to_owned())); + assert_eq!(result.value, None); + Ok(()) +} + +#[test] +fn call_js_fn_async_resolved() -> Result<()> { + logging::enable_logging(); + let (server, browser, tab) = dumb_server(include_str!("simple.html")); + let element = tab.wait_for_element("#foobar")?; + let result = element.call_js_fn("async function() { return 42 }", vec![], true)?; + assert_eq!(result.Type, RemoteObjectType::Number); + assert_eq!(result.subtype, None); + assert_eq!(result.description, Some("42".to_owned())); + assert_eq!(result.value, Some((42).into())); + Ok(()) +} + +#[test] +fn evaluate_sync() -> Result<()> { + logging::enable_logging(); + let (server, browser, tab) = dumb_server(include_str!("simple.html")); + let result = tab.evaluate("(function () { return 42 })();", false)?; + assert_eq!(result.Type, RemoteObjectType::Number); + assert_eq!(result.description, Some("42".to_owned())); + assert_eq!(result.value, Some((42).into())); + Ok(()) +} + +#[test] +fn evaluate_async_unresolved() -> Result<()> { + logging::enable_logging(); + let (server, browser, tab) = dumb_server(include_str!("simple.html")); + let result = tab.evaluate("(async function () { return 42 })();", false)?; + assert_eq!(result.Type, RemoteObjectType::Object); + assert_eq!(result.description, Some("Promise".to_owned())); + assert_eq!(result.subtype, Some(RemoteObjectSubtype::Promise)); + assert_eq!(result.value, None); + Ok(()) +} + +#[test] +fn evaluate_async_resolved() -> Result<()> { + logging::enable_logging(); + let (server, browser, tab) = dumb_server(include_str!("simple.html")); + let result = tab.evaluate("(async function () { return 42 })();", true)?; + assert_eq!(result.Type, RemoteObjectType::Number); + assert_eq!(result.subtype, None); + assert_eq!(result.description, Some("42".to_owned())); + assert_eq!(result.value, Some((42).into())); + Ok(()) +} + +#[test] +fn set_request_interception() -> Result<()> { + logging::enable_logging(); + let (server, browser, tab) = dumb_server(include_str!( + "coverage_fixtures/basic_page_with_js_scripts.html" + )); + + let patterns = vec![ + RequestPattern { + url_pattern: None, + resource_Type: None, + request_stage: Some(RequestStage::Response), + }, + RequestPattern { + url_pattern: None, + resource_Type: None, + request_stage: Some(RequestStage::Request), + }, + ]; + tab.enable_fetch(Some(&patterns), None)?; + + tab.enable_request_interception(Arc::new( + move |transport: Arc, session_id: SessionId, intercepted: RequestPausedEvent| { + if intercepted.params.request.url.ends_with(".js") { + let js_body = r#"document.body.appendChild(document.createElement("hr"));"#; + + let headers = vec![HeaderEntry { + name: "Content-Type".to_string(), + value: "application/javascript".to_string(), + }]; + + let fulfill_request = FulfillRequest { + request_id: intercepted.params.request_id, + response_code: 200, + response_headers: Some(headers), + binary_response_headers: None, + body: Some(base64::encode(js_body)), + response_phrase: None, + }; + + RequestPausedDecision::Fulfill(fulfill_request) + } else { + RequestPausedDecision::Continue(None) + } + }, + ))?; + + // ignore cache: + + tab.navigate_to(&format!("http://127.0.0.1:{}", server.port())) + .unwrap(); + tab.wait_until_navigated()?; + // There are two JS scripts that get loaded via network, they both append an element like this: + assert_eq!(2, tab.wait_for_elements("hr")?.len()); + + Ok(()) +} + +#[test] +fn authentication() -> Result<()> { + logging::enable_logging(); + let browser = Browser::default()?; + let tab = browser.wait_for_initial_tab()?; + tab.authenticate(Some("login".to_string()), Some("password".to_string()))?; + tab.enable_fetch(None, Some(true))?; + tab.navigate_to("http://httpbin.org/basic-auth/login/password")?; + tab.wait_until_navigated()?; + + Ok(()) +} + +#[test] +fn response_handler() -> Result<()> { + logging::enable_logging(); + let server = server::Server::with_dumb_html(include_str!( + "coverage_fixtures/basic_page_with_js_scripts.html" + )); + + let browser = Browser::default()?; + + let tab = browser.wait_for_initial_tab().unwrap(); + + let responses = Arc::new(Mutex::new(Vec::new())); + + let responses2 = responses.clone(); + tab.enable_response_handling(Box::new(move |response, fetch_body| { + // NOTE: you can only fetch the body after it's been downloaded, which might be some time + // after the initial 'response' (with status code, headers, etc.) has come back. hence this + // sleep: + sleep(Duration::from_millis(500)); + let body = fetch_body().unwrap(); + responses2.lock().unwrap().push((response, body)); + }))?; + + tab.navigate_to(&format!("http://127.0.0.1:{}", server.port())) + .unwrap(); + + tab.wait_until_navigated()?; + + let final_responses: Vec<_> = responses.lock().unwrap().clone(); + assert_eq!(final_responses.len(), 3); + assert_eq!(final_responses[0].0.response.mime_type, "text/html"); + assert!(final_responses[0].1.body.contains("Click me")); + + Ok(()) +} + +#[test] +fn incognito_contexts() -> Result<()> { + logging::enable_logging(); + let (server, browser, tab) = dumb_server(include_str!("simple.html")); + + let incognito_context = browser.new_context()?; + let incognito_tab: Arc = incognito_context.new_tab()?; + let tab_context_id = incognito_tab.get_target_info()?.browser_context_id.unwrap(); + + assert_eq!(incognito_context.get_id(), tab_context_id); + assert_eq!( + incognito_context.get_tabs()?[0].get_target_id(), + incognito_tab.get_target_id() + ); + Ok(()) +} + +#[test] +fn get_script_source() -> Result<()> { + logging::enable_logging(); + let server = server::file_server("tests/coverage_fixtures"); + let browser = Browser::default()?; + + let tab: Arc = browser.wait_for_initial_tab()?; + + tab.enable_profiler()?; + tab.start_js_coverage()?; + + tab.navigate_to(&format!( + "{}/basic_page_with_js_scripts.html", + &server.url() + ))?; + + tab.wait_until_navigated()?; + + sleep(Duration::from_millis(500)); + + let script_coverages = tab.take_precise_js_coverage()?; + + tab.enable_debugger()?; + + let contents = tab.get_script_source(&script_coverages[0].script_id)?; + assert_eq!( + include_str!("coverage_fixtures/coverage_fixture1.js"), + contents + ); + + let contents = tab.get_script_source(&script_coverages[1].script_id)?; + assert_eq!( + include_str!("coverage_fixtures/coverage_fixture2.js"), + contents + ); + + Ok(()) +} + +#[test] +fn read_write_cookies() -> Result<()> { + logging::enable_logging(); + let responder = move |r: tiny_http::Request| { + let response = tiny_http::Response::new( + 200.into(), + vec![ + tiny_http::Header::from_bytes(&b"Content-Type"[..], &b"text/html"[..]).unwrap(), + tiny_http::Header::from_bytes(&b"Set-Cookie"[..], &b"testing=1; Max-Age=100;"[..]) + .unwrap(), + ], + std::io::Cursor::new("
"), + None, + None, + ); + r.respond(response) + }; + let server = server::Server::new(responder); + let (browser, tab) = dumb_client(&server); + + // can read cookies + { + tab.navigate_to(&server.url())?; + + tab.wait_until_navigated()?; + + let cookies = tab.get_cookies()?; + + assert_eq!(cookies.len(), 1); + + let Cookie { name, value, .. } = cookies.first().unwrap(); + + assert_eq!(name, "testing"); + assert_eq!(value, "1"); + + let t: Result<()> = Ok(()); // type hint for error + t + }?; + + // can change (delete and set) value for current url + { + tab.set_cookies(vec![CookieParam { + name: "testing".to_string(), + value: "2".to_string(), + url: None, + domain: None, + path: None, + secure: None, + http_only: None, + same_site: None, + expires: None, + priority: None, + same_party: None, + source_scheme: None, + source_port: None, + partition_key: None, + }])?; + + let cookies = tab.get_cookies()?; + assert_eq!(cookies.len(), 1); + let cf = cookies.first().unwrap(); + assert_eq!(cf.name, "testing"); + assert_eq!(cf.value, "2"); + + let t: Result<()> = Ok(()); // type hint for error + t + }?; + + Ok(()) +} + +#[test] +fn close_tabs() -> Result<()> { + let (server, browser, tab) = dumb_server(include_str!("simple.html")); + let tabs = browser.get_tabs(); + + let wait = Wait::with_timeout(Duration::from_secs(30)); + + let check_tabs = |num: usize| { + let num_tabs = tabs.lock().unwrap().len(); + assert_eq!(num, num_tabs); + }; + let wait_tabs = |num: usize| { + let num_tabs = tabs.lock().unwrap().len(); + if num_tabs == num { + Some(true) + } else { + None + } + }; + + check_tabs(1); + + let new_tab1 = browser.new_tab()?; + new_tab1 + .navigate_to(&format!("http://127.0.0.1:{}", server.port()))? + .wait_until_navigated()?; + check_tabs(2); + + let new_tab2 = browser.new_tab()?; + new_tab2 + .navigate_to(&format!("http://127.0.0.1:{}", server.port()))? + .wait_until_navigated()?; + + check_tabs(3); + + let closed = new_tab1.close(true)?; + + assert_eq!(closed, true); + + wait.until(|| wait_tabs(2))?; + check_tabs(2); + + new_tab2.close_with_unload()?; + wait.until(|| wait_tabs(1))?; + check_tabs(1); + + Ok(()) +} + +#[test] +fn parses_shadow_doms() -> Result<()> { + logging::enable_logging(); + let (_, browser, tab) = dumb_server(include_str!("shadow-dom.html")); + tab.wait_for_element("html")?; + Ok(()) +} + +#[test] +fn set_extra_http_headers() -> Result<()> { + let (server, browser, tab) = dumb_server(include_str!("simple.html")); + let mut headers = HashMap::new(); + headers.insert("test", "header"); + tab.set_extra_http_headers(headers)?; + tab.enable_fetch(None, None)?; + + tab.enable_request_interception(Arc::new( + |transport: Arc, session_id: SessionId, intercepted: RequestPausedEvent| { + println!("{:?}", intercepted.params.request.headers); + // assert_eq!( + // intercepted.params.request.headers.get("test"), + // Some(&"header".to_string()) + // ); + RequestPausedDecision::Continue(None) + }, + ))?; + + tab.navigate_to(&format!("http://127.0.0.1:{}", server.port()))? + .wait_until_navigated()?; + Ok(()) +} + +#[test] +fn get_css_styles() -> Result<()> { + let (server, browser, tab) = dumb_server(include_str!("simple.html")); + + tab.navigate_to(&format!("http://127.0.0.1:{}", server.port()))? + .wait_until_navigated()?; + + let element = tab.wait_for_element("#within")?; + + let styles = element.get_computed_styles()?; + + let v = styles + .iter() + .filter_map(|p| { + if p.name == "top" || p.name == "background-color" || p.name == "position" { + Some(p.value.as_str()) + } else { + None + } + }) + .collect::>(); + + assert!(v.len() > 0); + + assert_eq!(["rgb(255, 255, 0)", "absolute", "5px"], v.as_slice()); + + Ok(()) +} diff --git a/mdbook-pdf/headless_chrome/tests/temp/.gitkeep b/mdbook-pdf/headless_chrome/tests/temp/.gitkeep new file mode 100644 index 00000000..1e469b7e --- /dev/null +++ b/mdbook-pdf/headless_chrome/tests/temp/.gitkeep @@ -0,0 +1 @@ +This file prevents git from not tracking an empty directory \ No newline at end of file diff --git a/mdbook-pdf/headless_chrome/tests/transparent.html b/mdbook-pdf/headless_chrome/tests/transparent.html new file mode 100644 index 00000000..645214de --- /dev/null +++ b/mdbook-pdf/headless_chrome/tests/transparent.html @@ -0,0 +1,17 @@ + + + + + + + + + + + \ No newline at end of file -- Gitee