# Picture in picture three times in a row (S060): enter -> exit -> enter ... must work every round, the PiP window
# floating and focused each time, the page keeping its state. Round 1 ends with `cmd exitpip`, round 2 with a real
# Escape in the PiP window, round 3 with niri closing the PiP window. Offline, hidden only:
#   tools/hidden.sh tests/smoke/pip-loop.txt <out> -- tests/smoke/pip-loop-driver.sh
# then <out>/windows-<n>.json (n = 1..3) has the PiP window (app id dev.nacre.Nacre.Pip) floating and focused.
wait 3
open @PAGES@/video.html
waitload
waitfor 10 document.getElementById('v').currentTime > 0.5
js window.marker = 42
cmd pip
wait 2
expect /windows 2
expect /active/pip true
assert window.marker === 42 && !document.getElementById('v').paused && document.fullscreenElement === document.getElementById('v').parentElement
log round-1
wait 2
cmd exitpip
wait 1.5
expect /windows 1
expect /active/pip false
cmd pip
wait 2
expect /windows 2
expect /active/pip true
assert window.marker === 42 && !document.getElementById('v').paused && document.fullscreenElement === document.getElementById('v').parentElement
log round-2
waitfor 15 !document.fullscreenElement
wait 1.5
expect /windows 1
expect /active/pip false
cmd pip
wait 2
expect /windows 2
expect /active/pip true
assert window.marker === 42 && !document.getElementById('v').paused && document.fullscreenElement === document.getElementById('v').parentElement
shot pip-3 pip
log round-3
waitfor 15 !document.fullscreenElement
wait 1.5
expect /windows 1
expect /active/pip false
assert window.marker === 42 && !document.getElementById('v').paused && !document.fullscreenElement
shot pip-back
status done
quit
