Nacre/tests/smoke/pages/previews.html

44 lines
1.4 KiB
HTML

<!doctype html>
<html>
<head><meta charset="utf-8"><title>Previews</title>
<style>
body { margin: 0; background: #222; display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
video { width: 100%; aspect-ratio: 16 / 9; background: #000; }
</style></head>
<body>
<!-- Hover previews (S068): many short muted videos that play, pause and swap sources fast, as video list sites do
when the pointer moves over thumbnails. A WebKitGTK 2.54 / GStreamer 1.28 lock-order deadlock froze such a page
in a background tab. `window.ops` counts the changes made. -->
<script>
const clips = ['clip.mp4', 'clip.webm'];
const videos = [];
for (let i = 0; i < 24; i++) {
const v = document.createElement('video');
v.muted = true;
v.loop = true;
v.playsInline = true;
v.preload = 'auto';
document.body.appendChild(v);
videos.push(v);
}
window.ops = 0;
function step() {
const v = videos[Math.floor(Math.random() * videos.length)];
const r = Math.random();
if (r < 0.35) {
v.src = clips[Math.floor(Math.random() * clips.length)] + '?' + Math.floor(Math.random() * 4);
v.play().catch(() => {});
} else if (r < 0.6) {
v.play().catch(() => {});
} else if (r < 0.85) {
v.pause();
} else {
v.removeAttribute('src');
v.load();
}
window.ops++;
}
setInterval(() => { for (let i = 0; i < 4; i++) step(); }, 30);
</script>
</body>
</html>