# Dialogs (S020, S048 on WebKit): alert, confirm, prompt (and their answers), select, colour, file chooser request, # context menu, leave page, find bar, permission bars. Offline. # Run with SMOKE_VISIBLE=1 SMOKE_SIZE=1280x900 tools/smoke.sh tests/smoke/dialogs.txt; read the PNGs. wait 3 resize 1280 900 set /theme/mode "dark" open @PAGES@/dialogs.html waitload js setTimeout(() => alert("Your session is about to expire. Save your work before it ends."), 50) wait 1.2 shot alert-dark key Return wait 0.5 js setTimeout(() => confirm("Delete this draft? This cannot be undone."), 50) wait 1.2 shot confirm-dark key Escape wait 0.5 js setTimeout(() => prompt("What should the file be called?", "notes.txt"), 50) wait 1.2 shot prompt-dark key Escape wait 0.5 # The answers reach the page. js setTimeout(() => { window.r1 = confirm("Keep this?"); }, 50) wait 1.2 expect /active/dialog true key Return wait 0.5 assert window.r1 === true js setTimeout(() => { window.r2 = confirm("Drop this?"); }, 50) wait 1.2 key Escape wait 0.5 assert window.r2 === false js setTimeout(() => { window.r3 = prompt("Name?", "abc"); }, 50) wait 1.2 key Return wait 0.5 assert window.r3 === "abc" js setTimeout(() => { window.r4 = prompt("Name?", "abc"); }, 50) wait 1.2 key Escape wait 0.5 assert window.r4 === null expect /active/dialog false locate #s wait 0.5 click @ wait 1 shot select-dark key Escape wait 0.5 locate #c wait 0.5 click @ wait 1 shot color-dark key Escape wait 0.5 # Nacre's own context menu, from WebKit's hit test: plain page, then a link. locate #t wait 0.5 rclick @ wait 1 expect /active/dialog true shot ctxmenu-dark key Escape wait 0.5 locate #l wait 0.5 rclick @ wait 1 shot ctxmenu-link-dark key Escape wait 0.5 expect /active/dialog false # File chooser: the request goes to the portal (none on the hidden session's bus: it is cancelled, the page lives). locate #f wait 0.5 click @ wait 2 assert document.getElementById('f').files.length === 0 # Permissions: notifications allowed, location denied, through the permission bar. js Notification.requestPermission().then(p => { window.np = p; }) wait 1 expect /active/prompts 1 shot permission-dark prompt allow wait 0.5 assert window.np === "granted" js new Notification("Smoke", { body: "From the dialogs page" }), 1 wait 1 expect /notifications 1 js navigator.geolocation.getCurrentPosition(() => { window.geo = 0; }, e => { window.geo = e.code; }) wait 1 expect /active/prompts 1 prompt deny wait 0.5 assert window.geo === 1 do find wait 0.5 shot find-dark set /theme/mode "light" js setTimeout(() => alert("Light mode alert."), 50) wait 1.2 shot alert-light key Return wait 0.5 # Leave page: the page asks before it closes (WebKit asks only after a click in the page); stay, the tab is still there. locate #t wait 0.5 click @ wait 0.5 cmd close_tab wait 1.2 shot leave-light expect /active/dialog true key Escape wait 0.5 expect /tab_count 1 status done quit