mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Auto merge of #23947 - georgeroman:finish_json_clone_functionality, r=jdm
Finish the JSON clone algorithm for WebDriver <!-- 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/23947) <!-- Reviewable:end -->
This commit is contained in:
commit
2a9b2fe027
6 changed files with 137 additions and 56 deletions
|
@ -252,11 +252,18 @@ impl Serialize for SendableWebDriverJSValue {
|
|||
WebDriverJSValue::Number(x) => serializer.serialize_f64(x),
|
||||
WebDriverJSValue::String(ref x) => serializer.serialize_str(&x),
|
||||
WebDriverJSValue::Element(ref x) => x.serialize(serializer),
|
||||
WebDriverJSValue::Frame(ref x) => x.serialize(serializer),
|
||||
WebDriverJSValue::Window(ref x) => x.serialize(serializer),
|
||||
WebDriverJSValue::ArrayLike(ref x) => x
|
||||
.iter()
|
||||
.map(|element| SendableWebDriverJSValue(element.clone()))
|
||||
.collect::<Vec<SendableWebDriverJSValue>>()
|
||||
.serialize(serializer),
|
||||
WebDriverJSValue::Object(ref x) => x
|
||||
.iter()
|
||||
.map(|(k, v)| (k.clone(), SendableWebDriverJSValue(v.clone())))
|
||||
.collect::<HashMap<String, SendableWebDriverJSValue>>()
|
||||
.serialize(serializer),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1409,18 +1416,22 @@ impl Handler {
|
|||
Ok(value) => Ok(WebDriverResponse::Generic(ValueResponse(
|
||||
serde_json::to_value(SendableWebDriverJSValue(value))?,
|
||||
))),
|
||||
Err(WebDriverJSError::Timeout) => Err(WebDriverError::new(ErrorStatus::Timeout, "")),
|
||||
Err(WebDriverJSError::UnknownType) => Err(WebDriverError::new(
|
||||
ErrorStatus::UnsupportedOperation,
|
||||
"Unsupported return type",
|
||||
Err(WebDriverJSError::BrowsingContextNotFound) => Err(WebDriverError::new(
|
||||
ErrorStatus::JavascriptError,
|
||||
"Pipeline id not found in browsing context",
|
||||
)),
|
||||
Err(WebDriverJSError::JSError) => Err(WebDriverError::new(
|
||||
ErrorStatus::JavascriptError,
|
||||
"JS evaluation raised an exception",
|
||||
)),
|
||||
Err(WebDriverJSError::BrowsingContextNotFound) => Err(WebDriverError::new(
|
||||
ErrorStatus::JavascriptError,
|
||||
"Pipeline id not found in browsing context",
|
||||
Err(WebDriverJSError::StaleElementReference) => Err(WebDriverError::new(
|
||||
ErrorStatus::StaleElementReference,
|
||||
"Stale element",
|
||||
)),
|
||||
Err(WebDriverJSError::Timeout) => Err(WebDriverError::new(ErrorStatus::Timeout, "")),
|
||||
Err(WebDriverJSError::UnknownType) => Err(WebDriverError::new(
|
||||
ErrorStatus::UnsupportedOperation,
|
||||
"Unsupported return type",
|
||||
)),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue