mirror of
https://github.com/servo/servo.git
synced 2025-09-27 15:20:09 +01:00
webdriver: Wait animation frame callbacks before taking (element) screenshot (#39539)
According to spec, we should wait animation frame callbacks before taking (element) screenshot. As "element screenshot" would automatically scroll into view, this solves intermittency. Testing: Manually tested on pages, and `take_element_screenshot/scroll_into_view.py` passes stably now. Fixes: #39306 --------- Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
This commit is contained in:
parent
5f5f2abc0f
commit
6aa82309c3
4 changed files with 7 additions and 4 deletions
|
@ -1223,7 +1223,7 @@ impl IOCompositor {
|
|||
}
|
||||
|
||||
/// Render the WebRender scene to the active `RenderingContext`. If successful, trigger
|
||||
/// the next round of animations.
|
||||
/// the next round of animations. Return false if unable to render.
|
||||
pub fn render(&mut self) -> bool {
|
||||
self.global
|
||||
.borrow()
|
||||
|
|
|
@ -1065,6 +1065,7 @@ impl Servo {
|
|||
if let Err(e) = response_sender.send(Err(())) {
|
||||
error!("Sending reply to create png failed {e:?}");
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2312,6 +2312,11 @@ impl Handler {
|
|||
}
|
||||
|
||||
fn take_screenshot(&self, rect: Option<Rect<f32, CSSPixel>>) -> WebDriverResult<String> {
|
||||
// Spec: Take screenshot after running the animation frame callbacks.
|
||||
let _ = self.handle_execute_async_script(JavascriptCommandParameters {
|
||||
script: "requestAnimationFrame(() => arguments[0]());".to_string(),
|
||||
args: None,
|
||||
});
|
||||
let webview_id = self.webview_id()?;
|
||||
let mut img = None;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue