# Slow connection (S052): a paced local server (tests/smoke/slow/server.py, ~1 Mbit/s, 250 ms per request; never a
# proxy) serves a page with a 400 KB image, a stylesheet, two scripts. Phases: first visit, revisit, reload,
# back/forward. Each `save` has the navigation time (ms to load) and every resource's transferSize (0 = from cache);
# the server's /log (saved to log.json) counts requests per phase. Offline.
#   python3 tests/smoke/slow/server.py &   then  tools/smoke.sh tests/smoke/slow.txt
# Cache variants: NACRE_WK_CACHE_MODEL=viewer, NACRE_WK_PAGE_CACHE=1 in the environment.
wait 3
open http://127.0.0.1:8771/mark?p=first
wait 2
open http://127.0.0.1:8771/
waitfor 60 window.done === true
save first JSON.stringify({load: Math.round(performance.getEntriesByType("navigation")[0].duration), res: performance.getEntriesByType("resource").map(r => [r.name.split("/").pop(), r.transferSize])})
js fetch("http://127.0.0.1:8771/mark?p=second-page")
wait 1
open http://127.0.0.1:8771/two.html
waitfor 60 window.done === true
js fetch("http://127.0.0.1:8771/mark?p=revisit")
wait 1
open http://127.0.0.1:8771/
waitfor 60 window.done === true
save revisit JSON.stringify({load: Math.round(performance.getEntriesByType("navigation")[0].duration), res: performance.getEntriesByType("resource").map(r => [r.name.split("/").pop(), r.transferSize])})
js fetch("http://127.0.0.1:8771/mark?p=reload")
wait 1
cmd reload
waitload
waitfor 60 window.done === true
save reload JSON.stringify({load: Math.round(performance.getEntriesByType("navigation")[0].duration), res: performance.getEntriesByType("resource").map(r => [r.name.split("/").pop(), r.transferSize])})
js fetch("http://127.0.0.1:8771/mark?p=back")
wait 1
open http://127.0.0.1:8771/two.html
waitfor 60 window.done === true
js fetch("http://127.0.0.1:8771/mark?p=back2")
wait 1
cmd back
waitfor 60 document.title === "one" && window.done === true
save back JSON.stringify({load: Math.round(performance.getEntriesByType("navigation")[0].duration), res: performance.getEntriesByType("resource").map(r => [r.name.split("/").pop(), r.transferSize])})
js fetch("http://127.0.0.1:8771/log").then(r => r.text()).then(t => { window.srvlog = t; })
waitfor 5 window.srvlog !== undefined
save log window.srvlog
status done
quit
