Skip to content

Commit

Permalink
HTML: Add <source media> to media elements
Browse files Browse the repository at this point in the history
  • Loading branch information
zcorpan committed Jun 12, 2023
1 parent d8a00c2 commit 0f4b390
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 51 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!doctype html>
<title>the &lt;source> media attribute: no reaction to environment change</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<iframe src="resources/media-min-width.html" width="300"></iframe>
<script>
const t = promise_test(async () => {
await new Promise(resolve => window.onload = resolve);
assert_equals(window[0].beforeEnvChange, '#a', 'beforeEnvChange');
assert_equals(window[0].afterEnvChange, '#a', 'afterEnvChange');
assert_equals(window[0].afterLoadCalled, '#b', 'afterLoadCalled');
});
</script>
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<!doctype html>
<title>the &lt;source> media attribute has no effect</title>
<title>the &lt;source> media attribute</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<video><source src="resources/delayed-broken-video.py" media="none"></video>
<video><source src="resources/delayed-broken-video.py" media="not all"></video>
<script>
test(function() {
var v = document.querySelector('video');
var s = document.querySelector('source');
assert_equals(v.networkState, v.NETWORK_LOADING);
assert_equals(v.currentSrc, s.src);
assert_equals(v.networkState, v.NETWORK_NO_SOURCE);
assert_equals(v.currentSrc, '');
});
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!DOCTYPE html>
<video></video>
<script>
function createSource(src, media) {
var source = document.createElement('source');
source.src = src;
if (media) {
source.media = media;
}
return source;
}
const rAF = () => new Promise(resolve => requestAnimationFrame(resolve));
const hash = str => str.substr(str.lastIndexOf('#'));
(async () => {
const v = document.querySelector('video');
v.append(createSource('delayed-broken-video.py#a', '(min-width: 200px)'));
v.append(createSource('delayed-broken-video.py#b'));
await rAF();
await rAF();
window.beforeEnvChange = hash(v.currentSrc);
window.frameElement.width = '150';
await rAF();
await rAF();
window.afterEnvChange = hash(v.currentSrc);
v.load()
await rAF();
await rAF();
window.afterLoadCalled = hash(v.currentSrc);
})();
</script>
47 changes: 0 additions & 47 deletions html/semantics/embedded-content/media-elements/video_008.htm

This file was deleted.

0 comments on commit 0f4b390

Please sign in to comment.