# Site interactions (S054): what people do on the daily sites, with real compositor input (hidden only: rclick and
# the pop-up need tools/wl-input). YouTube: autoplay, seek by key and by script, page full screen and back; Google
# sign-in: the email field takes typing (nothing sent); Reddit: infinite scroll, Nacre's context menu on a link, the
# "Continue with Google" button opens a sign-in pop-up (closed, nothing signed in); Discord: the login form.
# NEEDS INTERNET. Direct connections only: never a VPN, Tor or proxy.
# Run with SMOKE_SIZE=1280x800 SMOKE_TIMEOUT=900 tools/smoke.sh tests/smoke/site-interact.txt; read the PNGs.
wait 3
open https://www.youtube.com/watch?v=aqz-KE-bpKQ
waitfor 120 location.pathname === "/watch" && !!document.querySelector("video")
waitfor 60 document.querySelector("video").currentTime > 0 && !document.querySelector("video").paused
js (() => { const v = document.querySelector("video"); window.__t0 = v.currentTime; v.currentTime = 120; return "seek"; })()
waitfor 60 document.querySelector("video").currentTime > 120 && !document.querySelector("video").seeking
shot yt-seeked
locate #movie_player video
wait 1
click @
wait 1
pagetype l
wait 2
save yt-keys JSON.stringify({ t: document.querySelector("video").currentTime, paused: document.querySelector("video").paused })
assert document.querySelector("video").paused && document.querySelector("video").currentTime > 129
pagetype f
waitfor 20 !!document.fullscreenElement
wait 3
expect /fullscreen true
shot yt-fullscreen
pagetype {escape}
waitfor 20 !document.fullscreenElement
wait 2
expect /fullscreen false
shot yt-fullscreen-back
open https://accounts.google.com/
waitfor 60 !!document.querySelector("#identifierId")
wait 5
locate #identifierId
wait 1
click @
wait 1
pagetype nacre.smoke.test
wait 2
assert document.querySelector("#identifierId").value === "nacre.smoke.test"
shot google-typed
open https://www.reddit.com/r/rust/
waitfor 90 document.readyState === "complete" && document.querySelectorAll("shreddit-post").length > 0
wait 15
save reddit-before JSON.stringify({ posts: document.querySelectorAll("shreddit-post").length })
pagescroll 640 400 4000
wait 4
pagescroll 640 400 4000
wait 4
pagescroll 640 400 4000
wait 8
save reddit-after JSON.stringify({ posts: document.querySelectorAll("shreddit-post").length, y: scrollY })
shot reddit-scrolled
js (() => { window.scrollTo(0, 0); return "top"; })()
wait 3
locate shreddit-post a[slot=full-post-link], shreddit-post a[href*="/comments/"]
wait 1
rclick @
wait 2
shot reddit-ctxmenu
expect /active/dialog true
key escape
wait 1
locate iframe[src*="gsi/button"]
wait 1
click @
wait 10
# Pop-ups open as tabs (as in the original Nacre; Chromium gives them a window).
expect /tab_count 2
shot reddit-popup
cmd close_tab
waitstatus 10 /tab_count 1
open https://discord.com/login
waitfor 90 document.readyState === "complete"
wait 40
# The login form shows (it stayed blank with WebKit's own "Version/60.5" Safari agent).
assert !!document.querySelector("input[name=email]")
save discord JSON.stringify({ email: !!document.querySelector("input[name=email]"), text: document.body.innerText.slice(0, 200), scripts: document.scripts.length, root: (document.querySelector("#app-mount") || {}).childElementCount })
shot discord
status done
quit
