# S045 hidden check (needs internet): Wikipedia under the chrome, YouTube plays after a real click (driver
# tests/hidden/web-driver.sh clicks with wl-input when the log says "click-video"), tabs open/switch/close.
wait 3
set /theme/mode "dark"
open https://en.wikipedia.org/wiki/Web_browser
waitload 60
wait 3
shot wiki-dark
assert document.querySelector('#firstHeading').textContent.includes('Web browser')
set /theme/mode "light"
wait 2
shot wiki-light
newtab https://www.youtube.com/watch?v=jNQXAC9IVRw
waitload 60
wait 8
shot yt-loaded
save yt-before JSON.stringify((()=>{const v=document.querySelector('video');return v&&{t:v.currentTime,p:v.paused,rs:v.readyState}})())
js window.__ev = []; for (const t of ['pointerdown', 'pointerup', 'click']) addEventListener(t, e => window.__ev.push(t + ':' + e.clientX + ',' + e.clientY + ':' + (e.target.className || e.target.tagName).toString().slice(0, 30)), true); true
# YouTube keeps the page's main thread busy for several seconds after load (software GL, ~7 s here) and swaps its
# skeleton for the real player meanwhile; a click in that window lands on <html>. Click once the player is hit.
waitfor 60 (()=>{const e=document.elementFromPoint(402,354);return !!e && !!e.closest('#movie_player')})()
log click-video
wait 4
waitfor 60 (()=>{const v=document.querySelector('video');return !!v && v.currentTime > 2})()
save yt-after JSON.stringify((()=>{const v=document.querySelector('video');return v&&{t:v.currentTime,p:v.paused,rs:v.readyState}})())
save clicks JSON.stringify([window.__ev, (()=>{const v=document.querySelector('video');return v&&[v.error&&v.error.code,v.networkState,v.src.slice(0,30)]})()])
shot yt-playing
status tabs
assert location.href.includes('jNQXAC9IVRw')
cmd select 0
wait 1
assert location.host.endsWith('wikipedia.org')
cmd close_tab
wait 1
status closed
quit
