diff --git a/crates/io/src/svg/tests.rs b/crates/io/src/svg/tests.rs index d8a60194b3..2fe64fbd87 100644 --- a/crates/io/src/svg/tests.rs +++ b/crates/io/src/svg/tests.rs @@ -1045,7 +1045,14 @@ fn the_deepest_chain_of_embedded_svg_images_fits_a_small_stack() { for levels in 1..=MAX_EMBEDDED_SVG_DEPTH + 1 { match rasterize_bounded(chain(levels).as_bytes(), 1.0, MAX_RASTER_PIXELS) { Ok(buf) => { - assert!(buf.px[4 * 8 + 4][3] > 0.99, "{levels} levels: the innermost rect draws through every level"); + let drawn = buf.px[4 * 8 + 4][3] > 0.99; + if levels > MAX_EMBEDDED_SVG_DEPTH { + // A chain past the limit is left out rather than rejected; it must not + // still draw its innermost image through the exhausted depth budget. + assert!(!drawn, "{levels} levels: the too-deep image is left out"); + break; + } + assert!(drawn, "{levels} levels: the innermost rect draws through every level"); accepted = levels; } Err(_) => assert!(accepted > 0, "a one-level chain renders"),