mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +01:00
servoshell: Fall back to PNG format when outputting an image (#35648)
A recent change, #35538 added the ability to dump different output image formats. Unfortunately, this necessitated adding a file extension to the output image for WPT tests. This had two problems: 1. The original change never landed properly in WPT for unknown reasons. 2. It interfered with the way that temporary files were cleaned up during WPT runs. This change modifies the image dumping code to fall back to PNG format when there is no valid file extension on the output image and reverts the change made to the WPT runner. Fixes #35635. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
864a5edb0b
commit
c844ed232a
3 changed files with 6 additions and 4 deletions
|
@ -8,7 +8,7 @@ use std::path::PathBuf;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
use euclid::Vector2D;
|
use euclid::Vector2D;
|
||||||
use image::DynamicImage;
|
use image::{DynamicImage, ImageFormat};
|
||||||
use keyboard_types::{Key, KeyboardEvent, Modifiers, ShortcutMatcher};
|
use keyboard_types::{Key, KeyboardEvent, Modifiers, ShortcutMatcher};
|
||||||
use log::{error, info};
|
use log::{error, info};
|
||||||
use servo::base::id::WebViewId;
|
use servo::base::id::WebViewId;
|
||||||
|
@ -146,7 +146,10 @@ impl RunningAppState {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Err(error) = DynamicImage::ImageRgba8(image).save(output_path) {
|
let image_format = ImageFormat::from_path(output_path).unwrap_or(ImageFormat::Png);
|
||||||
|
if let Err(error) =
|
||||||
|
DynamicImage::ImageRgba8(image).save_with_format(output_path, image_format)
|
||||||
|
{
|
||||||
error!("Failed to save {output_path}: {error}.");
|
error!("Failed to save {output_path}: {error}.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
2
tests/wpt/meta/MANIFEST.json
vendored
2
tests/wpt/meta/MANIFEST.json
vendored
|
@ -506162,7 +506162,7 @@
|
||||||
[]
|
[]
|
||||||
],
|
],
|
||||||
"executorservo.py": [
|
"executorservo.py": [
|
||||||
"2710b1b844c8e93c251c91c8809697d357bd4f06",
|
"e3369d24ebc6d6aac1b4632ef673a36602417745",
|
||||||
[]
|
[]
|
||||||
],
|
],
|
||||||
"executorservodriver.py": [
|
"executorservodriver.py": [
|
||||||
|
|
|
@ -226,7 +226,6 @@ class ServoRefTestExecutor(ServoExecutor):
|
||||||
|
|
||||||
def screenshot(self, test, viewport_size, dpi, page_ranges):
|
def screenshot(self, test, viewport_size, dpi, page_ranges):
|
||||||
with TempFilename(self.tempdir) as output_path:
|
with TempFilename(self.tempdir) as output_path:
|
||||||
output_path = f"{output_path}.png"
|
|
||||||
extra_args = ["--exit",
|
extra_args = ["--exit",
|
||||||
"--output=%s" % output_path,
|
"--output=%s" % output_path,
|
||||||
"--window-size", viewport_size or "800x600"]
|
"--window-size", viewport_size or "800x600"]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue