mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-11-10 14:41:51 +00:00
M6: app.runtimeHighlight asks once, for the setting a script ends with, under the request cap
This commit is contained in:
@@ -690,7 +690,10 @@ fn set_runtime_highlight(_: &JsValue, args: &[JsValue], ctx: &mut Context) -> Js
|
||||
let mut h = host(ctx)?.borrow_mut();
|
||||
if h.doc.highlight != on {
|
||||
h.doc.highlight = on;
|
||||
h.requests.push(Request::Highlight(on));
|
||||
// Only the setting the script ends with matters: one request, the latest, under the
|
||||
// host's request cap like any other.
|
||||
h.requests.retain(|r| !matches!(r, Request::Highlight(_)));
|
||||
h.request(Request::Highlight(on));
|
||||
}
|
||||
Ok(JsValue::undefined())
|
||||
}
|
||||
|
||||
@@ -1560,6 +1560,10 @@ mod runtime_highlight {
|
||||
assert_eq!(o.error, None);
|
||||
assert_eq!(o.value, "false,true", "the script reads back what it set");
|
||||
assert_eq!(o.requests, vec![Request::Highlight(true)]);
|
||||
// A script that toggles it over and over asks once, for where it ended.
|
||||
let o = go("for (var i = 0; i < 5001; i++) { app.runtimeHighlight = !app.runtimeHighlight; }", &ev);
|
||||
assert_eq!(o.error, None);
|
||||
assert_eq!(o.requests, vec![Request::Highlight(true)], "one request, the last setting");
|
||||
}
|
||||
|
||||
/// The same in XFA scripts, where the change is an effect; nothing is asked for when the
|
||||
|
||||
Reference in New Issue
Block a user