# R5-01 regression, kept as a blocking stress test: blocked script loads must not crash the browser. crash-adblock.html inserts 20 blocked
# loads per round (classic, async, defer, module, dynamic import, fetch, image) from the local server, whose
# /ads/banner.js is on its filter list, and reloads or navigates itself mid-load; 3 passes of 20 rounds plus tabs
# opened and closed while loading, about 1300 blocked loads. Offline. Start the server first:
# crash-timers.html lets 40 timers fall due together, each allocating enough to start a GC; every callback must run.
#   python3 tests/smoke/net/server.py &   then   tools/smoke.sh tests/smoke/crash-adblock.txt
wait 3
set /adblock/lists []
set /adblock/custom ["http://127.0.0.1:8766/list.txt"]
wait 5
expect /adblock/rules 4
# WebKit compiles the content filter (queued behind the seed lists' first compile, S049).
waitstatus 90 /adblock/filters_ready true
open @PAGES@/crash-adblock.html?rounds=20
waitfor 120 window.crash && window.crash.done && document.readyState === "complete"
status pass1
expect /active/blocked > 10
open @PAGES@/crash-adblock.html?rounds=20
waitfor 120 window.crash && window.crash.done && document.readyState === "complete"
newtab @PAGES@/crash-adblock.html?rounds=20
wait 1
cmd close_tab
newtab @PAGES@/crash-adblock.html?rounds=20
waitfor 120 window.crash && window.crash.done && document.readyState === "complete"
assert window.crash.errors > 0
shot crash-adblock
open @PAGES@/crash-timers.html?rounds=40&batch=40&pass=1
waitfor 150 location.search.endsWith("pass=1") && window.crash && window.crash.done
assert window.crash.fired === 1600
open @PAGES@/crash-timers.html?rounds=40&batch=40&pass=2
waitfor 150 location.search.endsWith("pass=2") && window.crash && window.crash.done
assert window.crash.fired === 1600
status done
quit
