Skip to content

js: implement HTMLMediaElement.currentTime/play/pause/paused - #240

Merged
tannevaled merged 1 commit into
mainfrom
js-html-media-element-basics
Sep 28, 2026
Merged

tannevaled merged 1 commit into
mainfrom
js-html-media-element-basics

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

Summary

  • This engine has no <video>/<audio> support at all — no entry anywhere in isReplacedTag or any binder file.
  • Implemented the storage-only subset a script needs to stay internally consistent: currentTime (read/write), play()/pause() (methods toggling paused), the same "storage without real playback effect" shape as scrollTop/scrollLeft — no real media decoding/playback, since a static renderer has no timeline to advance.
  • Found by sweeping a third, freshly-fetched corpus page (archive.org's own item-detail viewer) after both prior corpora (this session's ten-page bench set, then github.com's own bundles) were exhausted.
  • Most of the initial grep hits (duration, volume, muted, .paused) turned out to be jQuery's own $.fx.speeds animation internals and Bootstrap's carousel widget — unrelated to media elements at all. Traced each hit back to its actual surrounding code before trusting it. The one confirmed real trigger: clicking a transcript entry finds the real <video> element (shadowRoot.querySelector("video")) and does videoEl.currentTime = ...; videoEl.play() to seek and resume playback.
  • play() returns a real Promise, matching the spec's own return type. duration/volume/muted/readyState/playbackRate deliberately left out — no confirmed real trigger for any of them survived closer inspection.

Test plan

  • New TestMediaElementCurrentTimeAndPlayPause, git-stash-confirmed: reverting turns currentTime/paused into undefined and makes .play() throw TypeError: Object has no member 'play'.
  • go build ./... && go vet ./... && go test ./... clean.
  • Coverage floors held (css 99.5%, layout 100%, paint 100%, dom 98.4%, paginate 100%).
  • Bench vs. real headless Chrome: exactly flat on pkg.go.dev (0.716, unchanged) as expected, no visual effect by design. caniuse.com showed unusually slow fetch times across three runs — investigated rather than assumed: an isolated re-run showed real Chrome taking even longer on the same fetch, confirming a real but purely environmental/network condition, not a code regression; SSIM stayed within its own established noise band throughout.

🤖 Generated with Claude Code

This engine has no <video>/<audio> support at all -- no entry
anywhere in isReplacedTag or any binder file. Implemented the
storage-only subset a script needs to stay internally consistent
(currentTime read/write, play()/pause() toggling paused, the same
"storage without real playback effect" shape as scrollTop/scrollLeft)
-- no real media decoding/playback, since a static renderer has no
timeline to advance.

Found sweeping a third, freshly-fetched corpus page (archive.org's
own item-detail viewer) after both prior corpora were exhausted. Most
of the initial grep hits (duration, volume, muted, paused) turned out
to be jQuery/Bootstrap internals unrelated to media elements --
traced each one back to its actual surrounding code before trusting
it. The one confirmed real trigger: clicking a transcript entry finds
the real <video> element and does videoEl.currentTime = ...;
videoEl.play() to seek and resume playback.

play() returns a real Promise, matching the spec's own return type.
duration/volume/muted/readyState/playbackRate deliberately left out:
no confirmed real trigger for any of them survived closer inspection.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@tannevaled
tannevaled merged commit 1f45666 into main Sep 28, 2026
7 checks passed
@tannevaled
tannevaled deleted the js-html-media-element-basics branch September 28, 2026 11:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant