# Context menus (S056, S061): a site that cancels `contextmenu` shows only its own menu, on every right click;
# elsewhere Nacre's menu, which takes the keyboard (arrows, Enter, Escape) and gives it back to the page. Hidden only
# (rclick and realkey need real input). Offline. Run with tools/smoke.sh.
wait 3
open @PAGES@/ctxmenu.html
waitload
rclick 200 100
wait 1.5
shot ctx-site
assert window.siteMenus === 1
expect /active/dialog false
key escape
click 600 600
wait 0.5
rclick 200 300
wait 1.5
shot ctx-plain
expect /active/dialog true
key escape
wait 0.5
# S061: pages/site-menu.html, each area right-clicked three times (in a new tab: no Back in its menu).
do new_tab
wait 1
open @PAGES@/site-menu.html
waitload
# Like YouTube's player: its menu, then the browser's (a right click while its menu is open), then its menu again.
rclick 200 100
wait 1
expect /active/dialog false
assert window.toggleOwn === 1
rclick 220 110
wait 1
shot toggle-native
expect /active/dialog true
assert window.toggleNative === 1
realkey Escape
wait 1
expect /active/dialog false
expect /page_focused true
rclick 200 100
wait 1
expect /active/dialog false
assert window.toggleOwn === 2
click 600 600
wait 0.5
# Like Discord: its own menu every time, never Nacre's.
rclick 200 260
wait 1
expect /active/dialog false
rclick 210 270
wait 1
expect /active/dialog false
rclick 220 280
wait 1
shot always
expect /active/dialog false
assert window.alwaysOwn === 3
click 600 600
wait 0.5
# No menu of its own: Nacre's every time; Escape closes it, the page has the keyboard again.
rclick 200 440
wait 1
expect /active/dialog true
realkey Escape
wait 1
expect /active/dialog false
expect /page_focused true
rclick 210 450
wait 1
shot plain-menu
expect /active/dialog true
realkey Escape
wait 1
expect /active/dialog false
# Keys: Down picks the first row that can be chosen (Reload: no Back or Forward in this tab), Enter runs it.
assert sessionStorage.loads === "1"
rclick 220 460
wait 1
expect /active/dialog true
realkey Down
wait 0.5
shot plain-key
realkey Return
wait 2
waitload
expect /active/dialog false
assert sessionStorage.loads === "2"
status done
quit
