mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-10-24 10:08:00 -06:00
Integration: execMenuItem requests go through the request cap (#3580)
A script looping on app.execMenuItem could queue unlimited requests; they now follow the same count and byte limits as other requests.
This commit is contained in:
@@ -704,7 +704,7 @@ pub(crate) fn menu_item(name: &str) -> Option<Request> {
|
||||
fn exec_menu_item(_: &JsValue, args: &[JsValue], ctx: &mut Context) -> JsResult<JsValue> {
|
||||
let item = text(&arg(args, 0), ctx)?;
|
||||
if let Some(r) = menu_item(&item) {
|
||||
host(ctx)?.borrow_mut().requests.push(r);
|
||||
host(ctx)?.borrow_mut().request(r);
|
||||
}
|
||||
Ok(JsValue::undefined())
|
||||
}
|
||||
|
||||
@@ -254,6 +254,13 @@ fn kept_bytes(o: &Outcome) -> usize {
|
||||
o.console.iter().chain(&o.alerts).map(String::len).sum::<usize>() + o.requests.iter().map(req).sum::<usize>()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn exec_menu_item_requests_are_capped_like_other_requests() {
|
||||
let o = go("for (var i = 0; i < 12000; i++) app.execMenuItem('Print');", &Event::field("Mouse Up", "agree", ""));
|
||||
assert_eq!(o.error, None);
|
||||
assert_eq!(o.requests.len(), crate::xfa::MAX_EFFECTS);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn console_alerts_and_requests_are_capped_in_count_and_bytes() {
|
||||
let o = go(
|
||||
|
||||
Reference in New Issue
Block a user