# Per-site memory and permissions (S008, R1-20), part 1: set values, then quit.
# Part 2 (site-memory-restart.txt) runs on the same home and checks they came back and still apply. Offline.
#   python3 -m http.server 8768 --bind 127.0.0.1 --directory tests/smoke/pages &
#   tools/smoke.sh tests/smoke/site-memory.txt            (hidden)
#   SMOKE_HOME=<that outdir>/home tools/smoke.sh tests/smoke/site-memory-restart.txt
wait 3
open http://127.0.0.1:8768/site.html
waitfor 20 window.res && window.res.img !== undefined
assert res.img === 'loaded'
# Notifications: asks first; deny + remember; the next ask is refused without a prompt.
js notif()
wait 3
status ask
expect /active/prompts 1
prompt deny remember
waitfor 10 res.notif === 'denied'
js notif()
waitfor 10 res.notif === 'denied'
status notif
expect /active/prompts 0
expect /permissions/127.0.0.1/notifications block
# Pop-ups: a new tab by default, none once blocked.
js pop()
wait 2
status popup-default
expect /tab_count 2
cmd close_tab
cmd select 0
perm 127.0.0.1 popups block
js pop()
wait 2
status popup
expect /tab_count 1
# Images blocked for the site: the picture doesn't load after a reload.
perm 127.0.0.1 images block
cmd reload
waitload
waitfor 20 window.res && window.res.img !== undefined
assert res.img === 'blocked'
shot images-blocked
# Sound blocked: the tab is muted on load.
perm 127.0.0.1 sound block
cmd reload
waitload
wait 2
status sound
expect /active/muted true
# Other per-site choices: zoom, ad blocker off, keep active, mute, HTTPS exception.
cmd zoom 1
cmd zoom 1
set /adblock/allow ["127.0.0.1"]
set /perf/keep_active ["127.0.0.1"]
set /media/muted_sites ["127.0.0.1"]
set /privacy/https_exceptions ["127.0.0.1"]
wait 1
status set
expect /active/zoom > 1
expect /site_state/adblock_allow/0 "127.0.0.1"
expect /permissions/127.0.0.1/images block
expect /permissions/127.0.0.1/popups block
status done
quit
