# beforeunload handler test (#1436)

Mode:
—

Pick a strategy, then try to navigate away using the link at the bottom, closing the tab, or pressing F5.

Navigate away (example.com) →

Strategy | Expected | What it tests
--- | --- | ---
1: block navigation | Dialog | handler + Js._false: preventDefault + returnValue + non-undefined return
2: allow navigation | No dialog | handler + Js._true: detects beforeunload, returns undefined to JS
3: conditional | Depends on toggle | Same handler, runtime decision — use toggle button to switch
4: clear handler | No dialog | no_handler: sets onbeforeunload to null

`Dom.handler` detects `beforeunload` events at runtime and adjusts the return value: `Js._true` returns `undefined` (allowing navigation) and `Js._false` also sets `event.returnValue` for legacy browser compatibility.