# Per-site memory and permissions (S008, R1-20), part 2: run on part 1's home (SMOKE_HOME=<outdir>/home).
# Everything set in part 1 is still stored, and applies again when the site is opened.
wait 3
status stored
expect /permissions/127.0.0.1/notifications block
expect /permissions/127.0.0.1/popups block
expect /permissions/127.0.0.1/images block
expect /permissions/127.0.0.1/sound block
expect /site_state/adblock_allow/0 "127.0.0.1"
expect /site_state/keep_active/0 "127.0.0.1"
expect /site_state/muted_sites/0 "127.0.0.1"
expect /site_state/https_exceptions/0 "127.0.0.1"
expect /site_state/zoom_sites/127.0.0.1 > 1
# Open the site fresh: zoom, mute, images and permissions apply again; a blocked pop-up stays blocked.
newtab http://127.0.0.1:8768/site.html
waitfor 20 window.res && window.res.img !== undefined
assert res.img === 'blocked'
wait 2
status opened
expect /active/zoom > 1
expect /active/muted true
js notif()
waitfor 10 res.notif === 'denied'
js pop()
wait 2
status checked
expect /tab_count 2
expect /active/prompts 1
# That one prompt is the 'pop-up blocked' notice; dismiss it.
prompt deny
# Prompt answers: allow + remember is stored; deny without remember is not (it asks again after a reload).
perm 127.0.0.1 notifications default
cmd reload
waitload
waitfor 20 window.res && window.res.img !== undefined
js notif()
wait 3
status ask-again
expect /active/prompts 1
prompt allow remember
waitfor 10 res.notif === 'granted'
status allowed
expect /permissions/127.0.0.1/notifications allow
perm 127.0.0.1 notifications default
cmd reload
waitload
waitfor 20 window.res && window.res.img !== undefined
js notif()
wait 3
prompt deny
waitfor 10 res.notif === 'denied'
cmd reload
waitload
waitfor 20 window.res && window.res.img !== undefined
js notif()
wait 3
status asked-third
expect /active/prompts 1
prompt deny remember
# Reset the images answer: the picture loads again, and the change is stored.
perm 127.0.0.1 images default
cmd reload
waitload
waitfor 20 window.res && window.res.img !== undefined
assert res.img === 'loaded'
shot images-back
status done
quit
