# Site pass (S054, D-030/D-031): every daily site at 1280x800, one shot each, for the side-by-side read against
# the Chromium reference (docs/engine/site-pass-webkit.md). Each site also saves `<name>.json` with what the page
# has (title, address, size, counts), so a blank shot can be told from a page that never loaded.
# Hidden runs paint slowly (llvmpipe, more so with other work on the machine): each page gets 15 s after it is ready.
# NEEDS INTERNET. Direct connections only: never a VPN, Tor or proxy. Nothing is signed in or submitted.
# Run with SMOKE_SIZE=1280x800 SMOKE_TIMEOUT=900 tools/smoke.sh tests/smoke/site-pass.txt; read the PNGs.
wait 3
open https://www.youtube.com/
waitfor 120 [...document.querySelectorAll("input[name=search_query]")].some(e => e.getBoundingClientRect().width > 0)
wait 15
shot yt-home
save yt-home JSON.stringify({ url: location.href, title: document.title, items: document.querySelectorAll("ytd-rich-item-renderer").length, thumbs: [...document.querySelectorAll("ytd-rich-item-renderer img")].filter(i => i.complete && i.naturalWidth > 0).length })
open https://www.youtube.com/watch?v=jNQXAC9IVRw
waitfor 120 location.pathname === "/watch" && !!document.querySelector("video")
wait 15
shot yt-watch
# Media may start with sound by itself (autoplay allowed, as in Chromium).
assert document.querySelector("video").currentTime > 0
save yt-watch JSON.stringify({ url: location.href, title: document.title, src: document.querySelector("video").currentSrc.slice(0, 40), t: document.querySelector("video").currentTime, paused: document.querySelector("video").paused, w: document.querySelector("video").videoWidth, err: document.querySelector("#movie_player .ytp-error") ? document.querySelector("#movie_player .ytp-error").innerText.slice(0, 80) : null, related: document.querySelectorAll("ytd-compact-video-renderer, yt-lockup-view-model").length })
open https://www.youtube.com/results?search_query=webkit
waitfor 120 !!document.querySelector("ytd-video-renderer")
wait 15
shot yt-search
save yt-search JSON.stringify({ url: location.href, results: document.querySelectorAll("ytd-video-renderer").length, h: document.querySelector("ytd-video-renderer").getBoundingClientRect().height })
open https://www.youtube.com/shorts
waitfor 120 location.pathname.startsWith("/shorts/") && !!document.querySelector("video")
wait 15
shot yt-shorts
save yt-shorts JSON.stringify({ url: location.href, t: document.querySelector("video").currentTime, paused: document.querySelector("video").paused, w: document.querySelector("video").videoWidth })
open https://www.reddit.com/r/rust/
waitfor 90 document.readyState === "complete"
wait 15
shot reddit
save reddit JSON.stringify({ url: location.href, title: document.title, posts: document.querySelectorAll("shreddit-post, article").length, blocked: /blocked|whoa there/i.test(document.body.innerText.slice(0, 2000)) })
open https://discord.com/login
waitfor 90 document.readyState === "complete"
wait 15
shot discord
save discord JSON.stringify({ url: location.href, title: document.title, email: !!document.querySelector("input[name=email]"), qr: !!document.querySelector("[class*=qrCode]"), text: document.body.innerText.slice(0, 200) })
open https://github.com/WebKit/WebKit
waitfor 90 document.readyState === "complete"
wait 15
shot github
save github JSON.stringify({ url: location.href, title: document.title, readme: !!document.querySelector("article.markdown-body, [data-testid=readme], #readme"), rows: document.querySelectorAll("table tr, [role=row]").length })
open https://en.wikipedia.org/wiki/Web_browser
waitfor 60 document.readyState === "complete"
wait 15
shot wikipedia
save wikipedia JSON.stringify({ url: location.href, title: document.title, imgs: [...document.images].filter(i => i.complete && i.naturalWidth > 0).length })
open https://duckduckgo.com/?q=webkit+browser+engine
waitfor 60 document.querySelectorAll("a[data-testid=result-title-a]").length > 0
wait 15
shot ddg
save ddg JSON.stringify({ url: location.href, results: document.querySelectorAll("a[data-testid=result-title-a]").length, oops: document.body.innerText.includes("Oops") })
open https://www.google.com/search?q=webkit
waitfor 60 document.readyState === "complete"
wait 15
shot google-search
save google-search JSON.stringify({ url: location.href.slice(0, 80), title: document.title, results: document.querySelectorAll("#search a h3").length, text: document.body.innerText.slice(0, 200) })
open https://accounts.google.com/
waitfor 60 !!document.querySelector("#identifierId")
wait 15
shot google-signin
save google-signin JSON.stringify({ url: location.href.slice(0, 80), text: document.body.innerText.slice(0, 200) })
open https://www.theguardian.com/international
waitfor 90 document.readyState === "complete"
wait 15
shot news
save news JSON.stringify({ url: location.href, title: document.title, imgs: [...document.images].filter(i => i.complete && i.naturalWidth > 0).length, text: document.body.innerText.slice(0, 200) })
open https://www.twitch.tv/directory
waitfor 90 document.readyState === "complete"
wait 15
shot twitch
save twitch JSON.stringify({ url: location.href, title: document.title, cards: document.querySelectorAll("[data-a-target^=card], article").length, imgs: [...document.images].filter(i => i.complete && i.naturalWidth > 0).length })
open https://www.openstreetmap.org/#map=12/51.5074/-0.1278
waitfor 90 document.readyState === "complete" && document.querySelectorAll(".leaflet-tile-loaded").length > 4
wait 15
shot maps
save maps JSON.stringify({ url: location.href, tiles: document.querySelectorAll(".leaflet-tile-loaded").length, canvas: document.querySelectorAll("canvas").length })
status done
quit
