Skip to content

test(browser): cover the load-delaying pump's page-error path - #744

Merged
SGavrl merged 1 commit into
h4ckf0r0day:mainfrom
ntdatt812:fix/699-pump-contains-script-errors
Sep 4, 2026
Merged

SGavrl merged 1 commit into
h4ckf0r0day:mainfrom
ntdatt812:fix/699-pump-contains-script-errors

Conversation

@ntdatt812

@ntdatt812 ntdatt812 commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

Rescoped. ad29745 fixed #699 upstream while this was open, and your fix is broader than mine was — it covers all four pumps rather than only the load-delaying one, and is_fatal_event_loop_error is a better seam than the local error counter I had. I have dropped my implementation entirely and reduced this PR to the one piece your commit did not carry: a test at the layer where the bug was reported.

Why this layer

ad29745 changes Page::drive_load_delaying_scripts in obscura-browser and adds no test there. The tests that exist do not reach the new branch:

Test Layer Covers the error path?
unhandled_rejection_does_not_starve_later_tasks (yours, ad29745) obscura-js, run_event_loop_bounded yes, but not this pump
load_delaying_script_driver_respects_absolute_deadline (existing) obscura-browser, this pump no — deadline path only

So the is_fatal_event_loop_error branch in page.rs is currently unguarded, and #699 was reported as load-delaying scripts going missing, which is this function.

Mutation-checked

Reverting your branch to the unconditional bail it replaced:

Ok(Err(error)) => {
    tracing::warn!("load-delaying dynamic script event loop failed: {error}");
    return false;
}
FAIL  load_delaying_script_driver_survives_a_page_script_exception
      the throw must not end the pump while a script is still pending
PASS  load_delaying_script_driver_respects_absolute_deadline

The deadline test passing under the same mutation is the point: the existing suite does not notice the regression, and this test does. Restored, both pass:

2 tests run: 2 passed, 65 skipped

cargo nextest run --release --features render -p obscura-browser load_delaying_script_driver, Linux container, rustc 1.98.

The test

A load-delaying classic script is left pending against a 150 ms server while a page callback throws. The throw is deferred through a timer so it lands on a pump tick — thrown during the installing script's own microtask drain it would clear the pending-script bookkeeping before the fetch starts, which is a different path. The assertions are that the pump reports completion, that the pending script was still fetched, and that the pending set drained.

No production code in this PR. rustfmt --check is clean across the inserted range (the file carries unrelated pre-existing diffs elsewhere).

Closes nothing on its own — #699 is already fixed by ad29745.

@yinnho

yinnho commented Aug 29, 2026

Copy link
Copy Markdown

Reviewed the patch — the shape is right.

The deadline-as-only-bound tradeoff is the correct call: on a page that throws every tick, the pump now burns its remaining budget instead of abandoning still-pending work over an error that a fresh tick would clear, and that is bounded (the absolute deadline) rather than unbounded. yield_now() in the error arm keeps a pathological page from spinning the loop hot between polls, and warn-once/debug-after keeps a noisy page from flooding the log. The regression test matches the measurement table from #699 (throw deferred through a timer so it lands on a pump tick).

One question, from the test comment: "Thrown during the installing script's own microtask drain it would clear the pending-script bookkeeping before the fetch even starts, which is a different bug from the one under test here." Is that second failure mode tracked anywhere? We would like to check our tree for it — if it turns out to be real on our side too, it deserves its own issue rather than riding on this PR.

@ntdatt812

Copy link
Copy Markdown
Contributor Author

Obstacle course, for the CONTRIBUTING pre-PR item I could not tick from a unit test. Companion repo at the ref your CI pins (6ebac82), same host, same invocation, base and candidate back to back:

revision correctness median latency
main (c138019) 32/33 3016.7ms
this branch 32/33 3016.0ms

No delta. The single failure is the same stage on both, and it fails on untouched main:

observer-intersection   modern-web   FAIL   expected 'io:50', got ''

So it is a property of this host rather than of the change, and I have not chased it further since it is outside the diff. It is deterministic rather than flaky here: re-running just that stage with --runs 3 --warmup 1 reproduces it exactly. Mentioning it only in case a 32/33 on a plain rust:latest Debian container is news to you; on your ubuntu-22.04 runner it may well be 33/33.

Everything else in this PR is unchanged.

@yinnho

yinnho commented Aug 29, 2026

Copy link
Copy Markdown

That stage is #671, and the back-to-back table here (no delta between main and this branch) is the expected shape of it — nothing in this PR touches the observer path. Two notes that might save the next person the chase:

  • The failure is spec-correct withholding, not a missing computation step. The fixture observes the sentinel exactly once (its comment claims a fresh observation per batch, but io.observe() runs once), and nothing flips isIntersecting or the threshold index after the appends — so an engine following the spec delivers one entry and stops. Headless Chromium 151 produces the identical expected 'io:50', got '' through the same runner; measurement tables and the aff0172 → 10b8492 history are in Obstacle course stage observer-intersection fails on main, headless Chrome fails it identically, and CI does not catch it #671.
  • For completeness: our obscura-lineage engine (diting) never returns empty on this stage either, because its IO is still the pre-10b8492 geometry-naive emulation (always-intersecting, mutation re-fire, burst schedule) — which is what the fixture was originally written against. So the stage currently measures engine history rather than browser behavior from both directions: spec-following engines (including Chrome) fail on the missing re-observation, and the fixture's comment describes an emulation that no longer matches main.

Until the fixture re-observes or toggles the sentinel, I'd treat the stage as known-fail per #671 rather than a regression signal for PRs like this one.

ad29745 made the load-delaying script pump continue past a page-local
event-loop error instead of abandoning every still-pending script, but
the change landed without a test at this layer: the runtime-level test
exercises run_event_loop_bounded, and the only page-level test for this
pump measures the absolute deadline.

Reverting the is_fatal_event_loop_error branch to the unconditional bail
leaves the deadline test passing and fails this one, so the new branch is
now guarded where the reported symptom lived.
@ntdatt812
ntdatt812 force-pushed the fix/699-pump-contains-script-errors branch from f52b971 to 6a089af Compare August 31, 2026 00:35
@ntdatt812 ntdatt812 changed the title fix(browser): keep draining load-delaying scripts after a page exception test(browser): cover the load-delaying pump's page-error path Aug 31, 2026
@SGavrl
SGavrl merged commit 9d47aab into h4ckf0r0day:main Sep 4, 2026
markjacksoncerberus added a commit to markjacksoncerberus/obscura that referenced this pull request Sep 11, 2026
…ng): the reflected verdict — A PAGE THAT TOOK FIVE SECONDS WAS NOT SLOWED DOWN, IT WAS EXECUTED (a 5s watchdog terminated the V8 isolate and never cancelled the termination, so every later script, handler and CDP evaluate died with it), and then the browser learned to keep the promise `img.alt` makes — Quests h4ckf0r0day#731–h4ckf0r0day#752 (reflection suite 10,065 scoreable → 56,591/56,660; 0 regressions over 392 ritual rows)

The region was chosen by measuring, and the measurement was the finding. A
26-file sample of the platform's biggest files came back 40,500/42,147 — the
campaign is in good health — with three rows reading `testharness did not load`
whose denominators were 10,202, 8,922 and 8,271. 27,395 subtests were not
failing. They were invisible.

h4ckf0r0day#731 ⭐⭐⭐ V8 termination is STICKY. `terminate_execution()` does not unwind a
script, it puts the isolate into a state where every later entry into JS bails
out until `cancel_terminate_execution()` clears it — and that call was never
made, so the `<reset>` script meant to recover was itself terminated on arrival.
The watchdog did not kill a script; it killed the page, and from a driver's side
that is a browser that silently stopped answering.

h4ckf0r0day#732 The budget had both halves backwards: no timeout at all under 10 kB (a
fifty-byte `while(1){}` hung the engine forever) and five seconds above it (the
heaviest real pages need 10-25s, measured). Now every script is guarded at 60s,
`OBSCURA_SCRIPT_TIMEOUT_MS` overrides, `0` disables. That one fix was +28,036
subtests before a line of reflection was written.

h4ckf0r0day#733-h4ckf0r0day#744 Then the suite could be read: 183 reflected members across 33
interfaces were simply absent — `a.ping`, `q.cite`, `td.colSpan`, `th.scope`,
`img.srcset`, `track.kind`, the whole `<frame>`/`<marquee>` family. Rebuilt keyed
by INTERFACE, because `Element.prototype` cannot express that `a.type` is a
DOMString while `input.type` is a 22-keyword enum, or that `value` is a DOMString
on `<data>` and a double on `<meter>`. The clamped types clamp in the GETTER
only; `progress.max = 0` is ignored; `<meter>`'s six numbers are a system; and
`nonce` writes an internal slot and touches the attribute only when connected,
because the attack it defends against is a page that can be made to READ it.

h4ckf0r0day#745-h4ckf0r0day#752, five more root causes from re-reading the same sample:
- `'zIndex' in el.style` was FALSE. A trap answers `get` but not `in`, so
  `'gridTemplateAreas' in body.style` reported we support nothing.
- The browser gave TWO answers to "do you support this?" — `CSS.supports()`'s
  validator chain and the property registry were different lists. Underneath:
  a CSS-wide keyword is valid in EVERY declaration, and a dozen branches forgot.
- `font-family: simple default` is a font called "simple default" — the CSS-wide
  exclusion belongs to the `<family-name>`, not to each `<custom-ident>` in it.
- An unknown media query is not a broken one. MQ4 has three truth values;
  collapsing `<general-enclosed>` to `not all` made `@media not (future-thing)`
  come out TRUE.
- `<img width=200>` was 200 of nothing — the dimension attributes never reached
  the cascade, so on the old web this browser exists for, every image, cell and
  frame laid out at `auto`.
- The URL parser said no and four APIs did not listen (`xhr.open`, `sendBeacon`,
  `location.href`, and `window.location =`, which was replacing the Location
  object with a string).

⚠️ The ritual caught THREE regressions in my own work, which is why it exists:
the computed-style proxy's `if (prop in target)` delegation began answering from
the INLINE declaration once every property had an IDL attribute; a condvar wait
with NO predicate check lost the `notify_one()` of a script that finished before
its watchdog was scheduled, so `join()` froze the ENGINE THREAD for the whole
budget (a hung browser, not a hung script, with nothing in the log); and a
generated table must not assume a reflector is ONLY a reflector — `iframe.src`
navigates the frame. Keeping the existing setters costs 69 subtests, and a
browser that scores 56,660 and cannot load an iframe is not a better browser.

Results: reflection suite 10,065 scoreable → 56,591/56,660 · dimension-attributes
952 → 1720/1720 · CSS-supports-CSSStyleDeclaration 869 → 1495/1495 · url/failure
604 → 1174/1175 · test_font_family_parsing 1768 → 2217/2232 · idlharness?include=HTML
2299 → 2773 · three dead files worth +5,245 more.

Zero regressions: 392 ritual rows, 55,689 → 55,707, two rows moved — one an
improvement (scroll-behavior-main-frame-root 1/40 → 40/40) and one the documented
flaky img file, re-proven solo at 205/228/228 on the pre-arc binary and
207/228/205 on the final one.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01EiXpEBV3Kfpy9zWXHqAhRU
whyparv pushed a commit to whyparv/obscura that referenced this pull request Nov 17, 2026
…ns-script-errors

test(browser): cover the load-delaying pump's page-error path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants