vomebook commited on
Commit
c6dfdc2
·
1 Parent(s): 8f78cde

Remove unconsumed Reader mini-player resume event fallback

Browse files
static/search/reader-host/application/navigation.js CHANGED
@@ -166,8 +166,7 @@
166
  url.hash = "";
167
  url.searchParams.delete("bookmark");
168
  url.searchParams.delete("bookmark_source");
169
- if (typeof options.resume === "function") options.resume(url.href);
170
- else root.dispatchEvent(new CustomEvent("voice-reader-resume", { detail: url.href }));
171
  });
172
  back.className = "reader-speech-mini-back";
173
  const play = button("暂停", () => /** @type {HTMLElement | null} */ (inFrame(target, "#speech-play"))?.click());
 
166
  url.hash = "";
167
  url.searchParams.delete("bookmark");
168
  url.searchParams.delete("bookmark_source");
169
+ options.resume?.(url.href);
 
170
  });
171
  back.className = "reader-speech-mini-back";
172
  const play = button("暂停", () => /** @type {HTMLElement | null} */ (inFrame(target, "#speech-play"))?.click());
tests/search/reader-navigation/test_reader_navigation_baseline.mjs CHANGED
@@ -183,27 +183,24 @@ test('explicit fragment and bookmark opens bypass parked reuse without stopping
183
  });
184
 
185
  test('mini-player resumes the live Reader even when its iframe src contains opening targets', () => {
186
- for (const viaEvent of [false, true]) {
187
- let resumed;
188
- const resume = raw => {
189
- const url = nav.prepare(raw, '/search/#/?q=book');
190
- resumed = nav.mount(url, true);
191
- nav.remember(url, {});
192
- };
193
- const {nav, mini, calls, context} = shellFixture(readerPath, viaEvent ? undefined : {resume});
194
- if (viaEvent) context.window.addEventListener('voice-reader-resume', event => resume(event.detail));
195
- const ordinary = nav.parse(readerPath + '?id=book&ext=md&title=Book');
196
- const url = nav.parse(ordinary.href + '&bookmark=saved&bookmark_source=source#opening');
197
- const parked = parkSpeakingReader(nav, url);
198
- mini().children.find(child => child.className === 'reader-speech-mini-back').dispatchEvent(new Event('click'));
199
- assert.equal(resumed, parked.frame);
200
- assert.equal(parked.reveals(), 1);
201
- assert.equal(parked.frame.src, url.href, 'resuming must not reload the live iframe');
202
- assert.equal(calls[0][3], ordinary.href, 'mini-player history must not carry stale position requests');
203
- assert.equal(nav.backgroundReader, null);
204
- assert.equal(mini(), undefined);
205
- nav.unmount(false);
206
- }
207
  });
208
 
209
  test('pending background handoff survives opening another book and reopening the same frame', () => {
 
183
  });
184
 
185
  test('mini-player resumes the live Reader even when its iframe src contains opening targets', () => {
186
+ let resumed;
187
+ const resume = raw => {
188
+ const url = nav.prepare(raw, '/search/#/?q=book');
189
+ resumed = nav.mount(url, true);
190
+ nav.remember(url, {});
191
+ };
192
+ const {nav, mini, calls} = shellFixture(readerPath, {resume});
193
+ const ordinary = nav.parse(readerPath + '?id=book&ext=md&title=Book');
194
+ const url = nav.parse(ordinary.href + '&bookmark=saved&bookmark_source=source#opening');
195
+ const parked = parkSpeakingReader(nav, url);
196
+ mini().children.find(child => child.className === 'reader-speech-mini-back').dispatchEvent(new Event('click'));
197
+ assert.equal(resumed, parked.frame);
198
+ assert.equal(parked.reveals(), 1);
199
+ assert.equal(parked.frame.src, url.href, 'resuming must not reload the live iframe');
200
+ assert.equal(calls[0][3], ordinary.href, 'mini-player history must not carry stale position requests');
201
+ assert.equal(nav.backgroundReader, null);
202
+ assert.equal(mini(), undefined);
203
+ nav.unmount(false);
 
 
 
204
  });
205
 
206
  test('pending background handoff survives opening another book and reopening the same frame', () => {