mirror of
https://github.com/servo/servo.git
synced 2025-06-14 11:24:33 +00:00
Implement GetElementProperty wd command <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors <!-- Either: --> - [X] There are tests for these changes <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23745) <!-- Reviewable:end -->
94 lines
3.6 KiB
Rust
94 lines
3.6 KiB
Rust
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
|
|
#![allow(missing_docs)]
|
|
|
|
use cookie::Cookie;
|
|
use euclid::default::Rect;
|
|
use hyper_serde::Serde;
|
|
use ipc_channel::ipc::IpcSender;
|
|
use msg::constellation_msg::BrowsingContextId;
|
|
use servo_url::ServoUrl;
|
|
|
|
#[derive(Debug, Deserialize, Serialize)]
|
|
pub enum WebDriverScriptCommand {
|
|
AddCookie(
|
|
#[serde(
|
|
deserialize_with = "::hyper_serde::deserialize",
|
|
serialize_with = "::hyper_serde::serialize"
|
|
)]
|
|
Cookie<'static>,
|
|
IpcSender<Result<(), WebDriverCookieError>>,
|
|
),
|
|
DeleteCookies(IpcSender<Result<(), ()>>),
|
|
ExecuteScript(String, IpcSender<WebDriverJSResult>),
|
|
ExecuteAsyncScript(String, IpcSender<WebDriverJSResult>),
|
|
FindElementCSS(String, IpcSender<Result<Option<String>, ()>>),
|
|
FindElementLinkText(String, bool, IpcSender<Result<Option<String>, ()>>),
|
|
FindElementTagName(String, IpcSender<Result<Option<String>, ()>>),
|
|
FindElementsCSS(String, IpcSender<Result<Vec<String>, ()>>),
|
|
FindElementsLinkText(String, bool, IpcSender<Result<Vec<String>, ()>>),
|
|
FindElementsTagName(String, IpcSender<Result<Vec<String>, ()>>),
|
|
FindElementElementCSS(String, String, IpcSender<Result<Option<String>, ()>>),
|
|
FindElementElementLinkText(String, String, bool, IpcSender<Result<Option<String>, ()>>),
|
|
FindElementElementTagName(String, String, IpcSender<Result<Option<String>, ()>>),
|
|
FindElementElementsCSS(String, String, IpcSender<Result<Vec<String>, ()>>),
|
|
FindElementElementsLinkText(String, String, bool, IpcSender<Result<Vec<String>, ()>>),
|
|
FindElementElementsTagName(String, String, IpcSender<Result<Vec<String>, ()>>),
|
|
FocusElement(String, IpcSender<Result<(), ()>>),
|
|
GetActiveElement(IpcSender<Option<String>>),
|
|
GetCookie(String, IpcSender<Vec<Serde<Cookie<'static>>>>),
|
|
GetCookies(IpcSender<Vec<Serde<Cookie<'static>>>>),
|
|
GetElementAttribute(String, String, IpcSender<Result<Option<String>, ()>>),
|
|
GetElementProperty(String, String, IpcSender<Result<WebDriverJSValue, ()>>),
|
|
GetElementCSS(String, String, IpcSender<Result<String, ()>>),
|
|
GetElementRect(String, IpcSender<Result<Rect<f64>, ()>>),
|
|
GetElementTagName(String, IpcSender<Result<String, ()>>),
|
|
GetElementText(String, IpcSender<Result<String, ()>>),
|
|
GetBrowsingContextId(WebDriverFrameId, IpcSender<Result<BrowsingContextId, ()>>),
|
|
GetUrl(IpcSender<ServoUrl>),
|
|
GetPageSource(IpcSender<Result<String, ()>>),
|
|
IsEnabled(String, IpcSender<Result<bool, ()>>),
|
|
IsSelected(String, IpcSender<Result<bool, ()>>),
|
|
GetTitle(IpcSender<String>),
|
|
}
|
|
|
|
#[derive(Debug, Deserialize, Serialize)]
|
|
pub enum WebDriverCookieError {
|
|
InvalidDomain,
|
|
UnableToSetCookie,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
|
pub enum WebDriverJSValue {
|
|
Undefined,
|
|
Null,
|
|
Boolean(bool),
|
|
Number(f64),
|
|
String(String), // TODO: Object and WebElement
|
|
}
|
|
|
|
#[derive(Debug, Deserialize, Serialize)]
|
|
pub enum WebDriverJSError {
|
|
Timeout,
|
|
UnknownType,
|
|
/// Occurs when handler received an event message for a layout channel that is not
|
|
/// associated with the current script thread
|
|
BrowsingContextNotFound,
|
|
}
|
|
|
|
pub type WebDriverJSResult = Result<WebDriverJSValue, WebDriverJSError>;
|
|
|
|
#[derive(Debug, Deserialize, Serialize)]
|
|
pub enum WebDriverFrameId {
|
|
Short(u16),
|
|
Element(String),
|
|
Parent,
|
|
}
|
|
|
|
#[derive(Debug, Deserialize, Serialize)]
|
|
pub enum LoadStatus {
|
|
LoadComplete,
|
|
LoadTimeout,
|
|
}
|