fix(js): an XFA value past the effect cap leaves the field unchanged

This commit is contained in:
aiongg
2026-10-22 21:41:50 +00:00
parent e541151389
commit d67c4b3059
2 changed files with 17 additions and 2 deletions
+15
View File
@@ -723,6 +723,21 @@ mod xfa_model {
assert!(!o.effects.iter().any(|e| matches!(e, XfaEffect::SetPresence { som, .. } | XfaEffect::SetAccess { som, .. } if som.contains("qty"))));
}
/// Past the effect cap, a value written to a field with no effect yet is left out of reads as
/// well as the effects; a field written again before the cap still takes its new value.
#[test]
fn a_value_past_the_effect_cap_is_left_out_of_reads_and_effects_alike() {
let o = go(
"price.rawValue = 1; for (var i = 0; i < 20000; i++) xfa.host.beep(); qty.rawValue = 9; price.rawValue = 3; qty.rawValue + ':' + price.rawValue",
"form1[0].page1[0]",
"click",
);
assert_eq!(o.error, None, "{o:?}");
assert_eq!(o.effects.len(), MAX_EFFECTS);
assert_eq!(o.result.as_deref(), Some("4:3"));
assert!(!o.effects.iter().any(|e| matches!(e, XfaEffect::SetValue { som, .. } if som.contains("qty"))));
}
#[test]
fn urls_and_reset_lists_are_clipped_and_deduplicated() {
let o = go(
+2 -2
View File
@@ -459,9 +459,9 @@ impl XHost {
self.clipped_values += 1;
}
// The snapshot's copy and the effect's are charged together, before either is kept:
// past the byte budget the write is left out of both.
// past the byte budget or the effect cap the write is left out of both.
let effect = XfaEffect::SetValue { som, value: text.clone() };
if !self.room(text.len().saturating_add(payload(&effect))) {
if !self.reserve(&effect, text.len().saturating_add(payload(&effect))) {
return true;
}
if let Some(n) = self.nodes.get_mut(i) {