From 63706325221f6072b18024fe1b857a697de48d6b Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Wed, 25 Nov 2026 18:27:12 -0800 Subject: [PATCH] Scripts: the blendingMode test catches each refused value in the script Each invalid assignment is now caught inside the script, and the mode is read right after it, so a setter that changed the mode before throwing fails the test instead of being hidden by the run's rollback. --- crates/engine/src/tests/script_dom.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/crates/engine/src/tests/script_dom.rs b/crates/engine/src/tests/script_dom.rs index 07131a18e9..ae7faace45 100644 --- a/crates/engine/src/tests/script_dom.rs +++ b/crates/engine/src/tests/script_dom.rs @@ -306,8 +306,19 @@ fn blending_mode_reads_and_sets_the_objects_blend_mode() { for value in ["'BlendModes.SCREEN '", "'MULTIPLY'", "'Multiply'", "'BlendModes.multiply'", "'BlendModes.NOPE'", "5", "null", "ZOrderMethod.BRINGTOFRONT"] { - let e = failure(&mut s, &format!("app.activeDocument.pageItems[1].blendingMode = {value};")); + // The error is caught in the script, so the run does not roll back and the mode read right + // after it is the one the setter left. + let out = log( + &mut s, + &format!( + "var i = app.activeDocument.pageItems[1], e = '';\ + try {{ i.blendingMode = {value}; }} catch (x) {{ e = String(x); }}\ + vc.log(e); vc.log(i.blendingMode);" + ), + ); + let e = out[0].as_str().unwrap_or_default(); assert!(e.contains("blendingMode needs a BlendModes value"), "{value}: {e}"); + assert_eq!(out[1], json!("BlendModes.COLORBLEND"), "{value}"); assert_eq!((blend(&s, a), undo_steps(&s)), (before, steps), "{value}"); } }