# Caching on a real site (R1-04, S007). NEEDS INTERNET. Direct connection only: the VPN stays off, never Tor or a
# proxy. Two Wikipedia articles share their stylesheets, scripts and logo, so the second one and a revisit of the
# first must come mostly from the HTTP cache: compare `bridge_bytes` (bytes through the network bridge) in
# first.json, second.json and revisit.json, and the resource entries the `js` lines log (transferSize 0 = cache).
# Run it twice, the second time with SMOKE_HOME=<first outdir>/home: start.json -> revisit.json is the disk cache.
#   tools/smoke.sh tests/smoke/net-real.txt target/smoke/net-real-a
#   SMOKE_HOME=target/smoke/net-real-a/home tools/smoke.sh tests/smoke/net-real.txt target/smoke/net-real-b
wait 3
set /vpn/enabled false
expect /vpn "Off"
status start
open https://en.wikipedia.org/wiki/Web_browser
waitload 60
wait 4
status first
js JSON.stringify(performance.getEntriesByType("resource").map(e => [e.name.split("?")[0].slice(-40), e.transferSize, e.decodedBodySize]))
open https://en.wikipedia.org/wiki/Rust_(programming_language)
waitload 60
wait 4
status second
js JSON.stringify(performance.getEntriesByType("resource").map(e => [e.name.split("?")[0].slice(-40), e.transferSize, e.decodedBodySize]))
open https://en.wikipedia.org/wiki/Web_browser
waitload 60
wait 4
status revisit
js JSON.stringify(performance.getEntriesByType("resource").map(e => [e.name.split("?")[0].slice(-40), e.transferSize, e.decodedBodySize]))
shot revisit
status done
quit
