Skip to content

Lazy loading video & audio: test load method precedence over loading attribute in media elements - #58455

Open
scottjehl wants to merge 4 commits into
web-platform-tests:masterfrom
Squarespace:media-element-loading-method-tests
Open

scottjehl wants to merge 4 commits into
web-platform-tests:masterfrom
Squarespace:media-element-loading-method-tests

Conversation

@scottjehl

Copy link
Copy Markdown
Contributor

These tests are meant to support recent revisions to whatwg/html#11980 that specify the precedence of explicit calls to the load() method over the loading attribute.

@scottjehl

Copy link
Copy Markdown
Contributor Author

@zcorpan also rebased.

@zcorpan zcorpan left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rename tests (remove .tentative)

Edit: you beat me to it

@scottjehl
scottjehl force-pushed the media-element-loading-method-tests branch from ca53d6e to 9e5190a Compare April 23, 2026 02:37
@scottjehl
scottjehl requested a review from zcorpan April 23, 2026 02:40
Comment on lines +25 to +27
audio.addEventListener("loadstart", t.step_func(() => {
loadstartFired = true;
assert_true(loadCalled, "load should have been called");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not correct per the current spec, but I filed whatwg/html#12973

Comment on lines +33 to +37
const nonLazyAudio = document.createElement("audio");
nonLazyAudio.addEventListener("loadstart", t.step_func(() => {
assert_false(loadstartFired, "loadstart should not have fired initially");
loadCalled = true;
audio.load();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each media element has its own media element event task source, so there's no guarantee about relative order of the two loadstart events. Better to drop this and instead wait for load on window and assert readyState is HAVE_NOTHING.


let loadstartFired = false;
let loadCalled = false;
audio.addEventListener("loadstart", t.step_func(() => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait for loadedmetadata instead to determine that some data was actually loaded.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants