vomebook commited on
Commit ·
c6dfdc2
1
Parent(s): 8f78cde
Remove unconsumed Reader mini-player resume event fallback
Browse filesFiles changed (2)
165 unmodified lines166167168169170171172173165 unmodified linesurl.hash = "";url.searchParams.delete("bookmark");url.searchParams.delete("bookmark_source");if (typeof options.resume === "function") options.resume(url.href);else root.dispatchEvent(new CustomEvent("voice-reader-resume", { detail: url.href }));});back.className = "reader-speech-mini-back";const play = button("暂停", () => /** @type {HTMLElement | null} */ (inFrame(target, "#speech-play"))?.click());165 unmodified lines166167168169170171172165 unmodified linesurl.hash = "";url.searchParams.delete("bookmark");url.searchParams.delete("bookmark_source");options.resume?.(url.href);});back.className = "reader-speech-mini-back";const play = button("暂停", () => /** @type {HTMLElement | null} */ (inFrame(target, "#speech-play"))?.click());
182 unmodified lines183184185186187188189190191192193194195196197198199200201202203204205206207208209182 unmodified lines});test('mini-player resumes the live Reader even when its iframe src contains opening targets', () => {for (const viaEvent of [false, true]) {let resumed;const resume = raw => {const url = nav.prepare(raw, '/search/#/?q=book');resumed = nav.mount(url, true);nav.remember(url, {});};const {nav, mini, calls, context} = shellFixture(readerPath, viaEvent ? undefined : {resume});if (viaEvent) context.window.addEventListener('voice-reader-resume', event => resume(event.detail));const ordinary = nav.parse(readerPath + '?id=book&ext=md&title=Book');const url = nav.parse(ordinary.href + '&bookmark=saved&bookmark_source=source#opening');const parked = parkSpeakingReader(nav, url);mini().children.find(child => child.className === 'reader-speech-mini-back').dispatchEvent(new Event('click'));assert.equal(resumed, parked.frame);assert.equal(parked.reveals(), 1);assert.equal(parked.frame.src, url.href, 'resuming must not reload the live iframe');assert.equal(calls[0][3], ordinary.href, 'mini-player history must not carry stale position requests');assert.equal(nav.backgroundReader, null);assert.equal(mini(), undefined);nav.unmount(false);}});test('pending background handoff survives opening another book and reopening the same frame', () => {182 unmodified lines183184185186187188189190191192193194195196197198199200201202203204205206182 unmodified lines});test('mini-player resumes the live Reader even when its iframe src contains opening targets', () => {let resumed;const resume = raw => {const url = nav.prepare(raw, '/search/#/?q=book');resumed = nav.mount(url, true);nav.remember(url, {});};const {nav, mini, calls} = shellFixture(readerPath, {resume});const ordinary = nav.parse(readerPath + '?id=book&ext=md&title=Book');const url = nav.parse(ordinary.href + '&bookmark=saved&bookmark_source=source#opening');const parked = parkSpeakingReader(nav, url);mini().children.find(child => child.className === 'reader-speech-mini-back').dispatchEvent(new Event('click'));assert.equal(resumed, parked.frame);assert.equal(parked.reveals(), 1);assert.equal(parked.frame.src, url.href, 'resuming must not reload the live iframe');assert.equal(calls[0][3], ordinary.href, 'mini-player history must not carry stale position requests');assert.equal(nav.backgroundReader, null);assert.equal(mini(), undefined);nav.unmount(false);});test('pending background handoff survives opening another book and reopening the same frame', () => {
static/search/reader-host/application/navigation.js+1-2
tests/search/reader-navigation/test_reader_navigation_baseline.mjs+18-21