# Ad removal animation (S058, port of the original Nacre's zapper): visible ads matching a cosmetic rule get the
# cookie shield overlay, squish away, and their slots close up; an ad inside a player and the box holding a <video>
# are left to the player; tiny and off-screen ads are hidden without animation; Motion off = plain hide, no overlay.
# Dark and light. Offline (own rules only, no lists). Never Tor or proxies.
#   SMOKE_SIZE=1280x900 tools/smoke.sh tests/smoke/zap.txt
wait 3
set /adblock/update_days 0
set /adblock/lists []
set /adblock/own_rules "##.zap-ad"
set /theme/mode "dark"
set /ui/motion "slow"
wait 5
status rules
expect /adblock/ready true
open @PAGES@/ads.html
waitfor 20 document.title === "Zap"
waitfor 10 [...document.querySelectorAll(".__nz_ov")].some(o => getComputedStyle(o).opacity === "1") && getComputedStyle(document.getElementById("ad-wide")).opacity === "0"
shot zap-mid-dark
assert document.querySelectorAll(".__nz_ov").length === 3
waitfor 10 !shown("ad-wide") && !shown("ad-left") && !shown("ad-right")
wait 1
shot zap-after-dark
assert document.querySelectorAll(".__nz_ov").length === 0
assert !shown("ad-tiny") && !shown("ad-offscreen") && !shown("ad-in-player")
assert shown("player") && shown("ad-with-video") && document.getElementById("vid").isConnected
assert document.getElementById("p2").getBoundingClientRect().top < window.p2Top - 200
status dark
expect /active/hidden_elements 6
# Light theme: the overlay follows the theme's colours.
set /theme/mode "light"
wait 2
cmd reload
waitfor 20 document.title === "Zap"
waitfor 10 [...document.querySelectorAll(".__nz_ov")].some(o => getComputedStyle(o).opacity === "1") && getComputedStyle(document.getElementById("ad-wide")).opacity === "0"
shot zap-mid-light
waitfor 10 !shown("ad-wide")
wait 1
shot zap-after-light
# Motion off: hidden at once, no overlay ever.
set /ui/motion "off"
wait 2
cmd reload
waitfor 20 document.title === "Zap"
waitfor 10 !shown("ad-wide") && !shown("ad-left") && !shown("ad-right") && !shown("ad-in-player")
wait 2
shot zap-off
assert window.ovSeen === false
assert shown("player") && shown("ad-with-video")
status off
expect /active/hidden_elements > 4
status done
quit
