feat(slides): add timed playback and looping controls

This commit is contained in:
Anya Tokugawa committed 2026-11-30 23:14:09 +09:00
1 parent fdf6dffc84
commit 1fd2de4c6b
7 files changed
+94 -8

No files matched your search

+14
View File
@@ -12,8 +12,22 @@
let isolated=false;try{isolated=!frame.contentDocument}catch{isolated=true}assert(isolated,'Frame can access parent origin');
assert(frame.getBoundingClientRect().height>=240,'Slide frame collapsed');
assert(frame.getBoundingClientRect().width<=innerWidth,'Mobile slide overflow');
const playback=frame.parentElement.querySelector('.slides-playback'),play=playback.querySelector('button'),seconds=playback.querySelector('input[type=number]'),loop=playback.querySelector('input[type=checkbox]');
assert(play.disabled===false&&play.getAttribute('aria-pressed')==='false','Slideshow should start paused');
seconds.value='0';seconds.dispatchEvent(new Event('change'));assert(frame.parentElement.dataset.slidePlaying!=='true','Invalid interval started slideshow');
seconds.value='1';seconds.dispatchEvent(new Event('change'));play.click();
await wait(()=>frame.parentElement.dataset.slideIndex==='1');
await wait(()=>play.getAttribute('aria-pressed')==='false');
assert(frame.parentElement.dataset.slideIndex==='1','Non-loop slideshow did not stop at final slide');
loop.checked=true;loop.dispatchEvent(new Event('change'));play.click();
await wait(()=>frame.parentElement.dataset.slideIndex==='0');
await wait(()=>frame.parentElement.dataset.slideIndex==='1');
play.click();await wait(()=>play.getAttribute('aria-pressed')==='false');
const stoppedIndex=frame.parentElement.dataset.slideIndex;await delay(1150);assert(frame.parentElement.dataset.slideIndex===stoppedIndex,'Paused slideshow advanced');
window.postMessage({type:'slides-playback',playing:true,token:'invalid'},'*');await delay(30);assert(play.getAttribute('aria-pressed')==='false','Untrusted playback message accepted');
if(e&&innerWidth<=700){assert(getComputedStyle(document.querySelector('.editor-pane')).display==='none','Mobile preview not full width');setEditorPreviewVisible(false);assert(getComputedStyle(document.querySelector('.editor-pane')).display!=='none','Mobile source inaccessible');setEditorPreviewVisible(true);}
const host=frame.parentElement;
host.dataset.slideIndex='0';
// Verify the defensive DOM boundary independently of server sanitization.
PagesSlides.render(host,'<h1 onclick="alert(1)" data-background-iframe="https://evil.invalid">Safe</h1><script>alert(1)</scr'+'ipt><iframe src="https://evil.invalid"></iframe><img src="https://evil.invalid/x"><hr><p>Next</p>','/deck');
await wait(ready);