Skip to content

armgit / moli

Public Imported from GitHub
0

Best headless browser for AI agents. Lite, Fast, High-Compatibility. Built in Rust

Stabilize large NodeList regression test

ldm0edd2c2df15dd
diff --git a/moli-core/tests/fetch_behaviors.rs b/moli-core/tests/fetch_behaviors.rs
index a04be34e1..4126f1a64 100644
--- a/moli-core/tests/fetch_behaviors.rs
+++ b/moli-core/tests/fetch_behaviors.rs
@@ -261,11 +261,10 @@ async fn large_static_query_selector_all_subset_does_not_eagerly_wrap_every_node
assert!(html.contains("data-done=\"true\""), "html={html}");
assert!(html.contains("data-node-count=\"12000\""), "html={html}");
- assert!(html.contains("data-checksum=\""), "html={html}");
+ assert!(html.contains("data-checksum=\"60\""), "html={html}");
// Keep page-visible timing fields as diagnostics, but do not make this
// correctness gate depend on full-workspace nextest scheduling load.
let _script_elapsed = extract_data_attr_u64(&html, "data-elapsed-ms")?;
- let _names_elapsed = extract_data_attr_u64(&html, "data-names-elapsed-ms")?;
let _checks_elapsed = extract_data_attr_u64(&html, "data-checks-elapsed-ms")?;
server.shutdown().await;
diff --git a/moli-test-support/src/routes_core.rs b/moli-test-support/src/routes_core.rs
index 317fce736..70c3eac29 100644
--- a/moli-test-support/src/routes_core.rs
+++ b/moli-test-support/src/routes_core.rs
@@ -279,23 +279,16 @@ pub(super) async fn encoding_large_static_nodelist_subset_page() -> Html<String>
body.push_str(&format!("{index:X}"));
body.push_str("\" data-bytes=\"A1 A1\">x</span>");
}
+ // Keep the DOM large so eager wrapper creation remains expensive, while the
+ // script reads only a small prefix. Traversing every entry would test full
+ // iteration instead and make the watchdog outcome depend on host load.
body.push_str(
r#"<script>
try {
const started = Date.now();
const nodes = document.querySelectorAll("span");
- const namesStarted = Date.now();
- let names = 0;
let checksum = 0;
function simpleDecoder(bytes) { return bytes; }
- for (let i = 0; i < nodes.length; i++) {
- const name = "U+" + nodes[i].dataset.cp + " " +
- String.fromCodePoint(parseInt(nodes[i].dataset.cp, 16)) + " " +
- simpleDecoder(nodes[i].dataset.bytes) + " " +
- nodes[i].dataset.bytes;
- names += name.length;
- }
- const namesElapsed = Date.now() - namesStarted;
const checksStarted = Date.now();
for (let i = 0; i < 10; i++) {
checksum += nodes[i].textContent.length;
@@ -304,8 +297,6 @@ pub(super) async fn encoding_large_static_nodelist_subset_page() -> Html<String>
const checksElapsed = Date.now() - checksStarted;
document.body.setAttribute("data-node-count", String(nodes.length));
document.body.setAttribute("data-checksum", String(checksum));
- document.body.setAttribute("data-name-bytes", String(names));
- document.body.setAttribute("data-names-elapsed-ms", String(namesElapsed));
document.body.setAttribute("data-checks-elapsed-ms", String(checksElapsed));
document.body.setAttribute("data-done", "true");
document.body.setAttribute("data-elapsed-ms", String(Date.now() - started));