Skip to content

Commit dba3823

Browse files
authored
fix(test): tolerate stale screencast frames in viewport e2e test (#1245)
Chrome's `Page.startScreencast` `maxWidth`/`maxHeight` are upper bounds, and early frames can arrive before the viewport resize fully takes effect. Instead of asserting exact JPEG dimensions on the first frame, skip frames with stale dimensions and wait for one that matches.
1 parent 2e99293 commit dba3823

1 file changed

Lines changed: 12 additions & 20 deletions

File tree

cli/src/native/e2e_tests.rs

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3950,7 +3950,9 @@ async fn e2e_stream_frame_metadata_respects_custom_viewport() {
39503950
.await;
39513951
assert_success(&resp);
39523952

3953-
// Wait for a frame message and verify both metadata and actual image dimensions
3953+
// Wait for a frame whose JPEG dimensions match the custom viewport.
3954+
// Early frames may arrive before Chrome fully applies the viewport resize,
3955+
// so skip frames with stale dimensions rather than failing immediately.
39543956
let mut found_frame = false;
39553957
let deadline = tokio::time::Instant::now() + tokio::time::Duration::from_secs(15);
39563958
while tokio::time::Instant::now() < deadline {
@@ -3977,28 +3979,18 @@ async fn e2e_stream_frame_metadata_respects_custom_viewport() {
39773979
meta
39783980
);
39793981

3980-
// Verify the actual JPEG image dimensions match the custom viewport.
39813982
let data_str = parsed
39823983
.get("data")
39833984
.and_then(|v| v.as_str())
39843985
.expect("frame message should include base64-encoded 'data' field");
3985-
{
3986-
use base64::Engine;
3987-
let bytes = base64::engine::general_purpose::STANDARD
3988-
.decode(data_str)
3989-
.expect("frame data should be valid base64");
3990-
let (img_w, img_h) = jpeg_dimensions(&bytes)
3991-
.expect("frame data should be a valid JPEG with SOF marker");
3992-
assert_eq!(
3993-
img_w, 800,
3994-
"JPEG image width should match custom viewport, got: {}",
3995-
img_w
3996-
);
3997-
assert_eq!(
3998-
img_h, 600,
3999-
"JPEG image height should match custom viewport, got: {}",
4000-
img_h
4001-
);
3986+
use base64::Engine;
3987+
let bytes = base64::engine::general_purpose::STANDARD
3988+
.decode(data_str)
3989+
.expect("frame data should be valid base64");
3990+
let (img_w, img_h) =
3991+
jpeg_dimensions(&bytes).expect("frame data should be a valid JPEG with SOF marker");
3992+
if img_w != 800 || img_h != 600 {
3993+
continue;
40023994
}
40033995

40043996
found_frame = true;
@@ -4007,7 +3999,7 @@ async fn e2e_stream_frame_metadata_respects_custom_viewport() {
40073999
}
40084000
assert!(
40094001
found_frame,
4010-
"should have received at least one frame message with correct viewport metadata"
4002+
"should have received a frame with JPEG dimensions 800x600 within the deadline"
40114003
);
40124004

40134005
// Cleanup

0 commit comments

Comments
 (0)