Add overall progress and completion estimates with autoplay recovery

This commit is contained in:
2026-10-06 03:01:32 +08:00
parent d80c490f48
commit 8023a802f1
8 changed files with 493 additions and 78 deletions
+2 -2
View File
@@ -3,7 +3,7 @@ const assert=require('node:assert/strict');
const {harness,ID,RID}=require('./study-helper.test.cjs');
let passed=0;
async function test(name,fn){await fn();passed++;console.log(`PASS ${name}`);}
async function start(h){h.api.begin();await h.api.tickCourse(ID);h.advance(1000);await h.api.tickCourse(ID);await Promise.resolve();}
async function start(h){h.api.begin();await h.api.tickCourse(ID);h.advance(1000);await h.api.tickCourse(ID);await Promise.resolve();await Promise.resolve();}
function mountPanel(h){
const elements=new Map();
const panel={querySelector(s){if(!elements.has(s))elements.set(s,{textContent:'',value:'all',checked:true});return elements.get(s);}};
@@ -41,7 +41,7 @@ function mountPanel(h){
await start(h);assert.equal(h.api.state.running,true);h.advance(2000);h.api.monitor();await Promise.resolve();
h.video.currentTime+=2;h.api.monitor();assert.equal(calls,2);assert.equal(h.api.state.active.phase,'playing');
});
await test('real autoplay permission rejection asks for a click without reloading',async()=>{
await test('autoplay rejection including muted fallback asks for a click without reloading',async()=>{
const h=harness();h.video.play=()=>Promise.reject(Object.assign(new Error('blocked'),{name:'NotAllowedError'}));
await start(h);assert.equal(h.api.state.running,false);assert.match(h.api.state.status,/浏览器阻止/);assert.equal(h.context.location.reloadCount,undefined);
});