Update web-platform-tests to revision 0d318188757a9c996e20b82db201fd04de5aa255

This commit is contained in:
James Graham 2015-03-27 09:15:38 +00:00
parent b2a5225831
commit 1a81b18b9f
12321 changed files with 544385 additions and 6 deletions

View file

@ -0,0 +1,10 @@
[
{
"id": "authoring",
"original_id": "authoring"
},
{
"id": "processing-model-0",
"original_id": "processing-model-0"
}
]

View file

@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<title>Audio Test: audio_controls_present.html</title>
<link rel="author" title="Intel" href="http://www.intel.com" />
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-media-controls" />
<meta name="flags" content="" />
<meta name="assert" content="Check if the controls attribute is present in the audio element that expecting the user agent exposes a controller user interface" />
</head>
<body>
<p>Test passes if a controller user interface appears below and the text 'The user agent doesn't support media element.' does not appear anywhere on this page</p>
<audio id="m" controls>The user agent doesn't support media element.</audio>
</body>
</html>

View file

@ -0,0 +1,42 @@
<!DOCTYPE html>
<html>
<head>
<title>Audio Test: audio_loop_base</title>
<link rel="author" title="Intel" href="http://www.intel.com" />
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-media-loop" />
<meta name="flags" content="" />
<meta name="assert" content="Check if audio.loop is set to true that expecting the seeking event is fired more than once" />
<meta name=timeout content=long>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/media.js"></script>
</head>
<body>
<div id="log"></div>
<audio id="m" controls>The user agent doesn't support media element.</audio>
<script type="text/javascript">
var media = document.getElementById("m");
var name = document.getElementsByName("assert")[0].content;
var t = async_test(name);
var looped = false;
function startTest() {
if (looped) {
t.step(function() {
assert_true(true, "looped");
});
t.done();
media.pause();
}
looped = true;
}
media.addEventListener("seeking", startTest, false);
media.loop = true;
media.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random();
media.play();
</script>
</body>
</html>

View file

@ -0,0 +1,23 @@
<!DOCTYPE html>
<html>
<head>
<title>Audio Test: audio_loop_current_media_controller</title>
<link rel="author" title="Intel" href="http://www.intel.com" />
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-media-loop" />
<meta name="flags" content="" />
<meta name="assert" content="Check if the audio element has a current media controller that expecting the loop attribute has no effect" />
<script src="/common/media.js"></script>
</head>
<body>
<p>Test passes if the audio doesn't repeatly play and the text 'The user agent doesn't support media element.' does not appear anywhere on this page</p>
<audio id="m" controls loop mediagroup="movie">The user agent doesn't support media element.</audio>
<script type="text/javascript">
var media = document.getElementById("m");
var controller = new MediaController();
media.controller = controller;
media.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random();
media.play();
</script>
</body>
</html>

View file

@ -0,0 +1,21 @@
<!DOCTYPE html>
<html>
<head>
<title>Audio Test: audio_muted_overriding_volume</title>
<link rel="author" title="Intel" href="http://www.intel.com" />
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-media-muted" />
<meta name="flags" content="" />
<meta name="assert" content="Check if the muted attribute is present in the audio element with volume is set to loudest that expecting the user hears no sound" />
<script src="/common/media.js"></script>
</head>
<body>
<p>Test passes if the audio is playing without sound output and the text 'The user agent doesn't support media element.' does not appear anywhere on this page</p>
<audio id="m" controls muted>The user agent doesn't support media element.</audio>
<script type="text/javascript">
var media = document.getElementById("m");
media.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random();
media.volume = 1.0;
media.play();
</script>
</body>
</html>

View file

@ -0,0 +1,20 @@
<!DOCTYPE html>
<html>
<head>
<title>Audio Test: audio_muted_present</title>
<link rel="author" title="Intel" href="http://www.intel.com" />
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-media-muted" />
<meta name="flags" content="" />
<meta name="assert" content="Check if the muted attribute is present in the audio element that expecting the user hears no sound" />
<script src="/common/media.js"></script>
</head>
<body>
<p>Test passes if the audio is playing without sound output and the text 'The user agent doesn't support media element.' does not appear anywhere on this page</p>
<audio id="m" controls muted>The user agent doesn't support media element.</audio>
<script type="text/javascript">
var media = document.getElementById("m");
media.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random();
media.play();
</script>
</body>
</html>

View file

@ -0,0 +1,58 @@
<!DOCTYPE html>
<html>
<head>
<title>Audio Test: audio_volume_check</title>
<link rel="author" title="Intel" href="http://www.intel.com" />
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-media-volume" />
<meta name="flags" content="" />
<meta name="assert" content="Check that audio.volume returns the value of the muted content attribute" />
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id="log"></div>
<audio id="m">The user agent doesn't support media element.</audio>
<script type="text/javascript">
var media = document.getElementById("m");
var VOLUME = {
'SILENT' : 0.0,
'NORMAL' : 0.5,
'LOUDEST' : 1.0,
'LOWER' : -1.1,
'UPPER' : 1.1,
};
test(function() {
assert_false(media.volume < VOLUME.SILENT || media.volume > VOLUME.LOUDEST, "media.volume outside the range 0.0 to 1.0 inclusive");
}, "Check if the intial value of the audio.volume is in the range 0.0 to 1.0 inclusive");
function volume_setting(vol, name)
{
if (vol < VOLUME.SILENT || vol > VOLUME.LOUDEST) {
try {
media.volume = vol;
test(function() {
assert_true(false, "media.volume setting exception");
}, name);
} catch(e) {
test(function() {
// 1 should be e.IndexSizeError or e.INDEX_SIZE_ERR in previous spec
assert_equals(e.code, 1, "media.volume setting exception");
}, name);
}
} else {
media.volume = vol;
test(function() {
assert_equals(media.volume, vol, "media.volume new value");
}, name);
}
}
volume_setting(VOLUME.NORMAL, "Check if audio.volume is able to set to new value in the range 0.0 to 1.0");
volume_setting(VOLUME.SILENT, "Check if media.volume is able to set to new value 0.0 as silent");
volume_setting(VOLUME.LOUDEST, "Check if media.volume is able to set to new value 1.0 as loudest");
volume_setting(VOLUME.LOWER, "Check if media.volume is set to new value less than 0.0 that expecting an IndexSizeError exception is to be thrown");
volume_setting(VOLUME.UPPER, "Check if audio.volume is set to new value greater than 1.0 that expecting an IndexSizeError exception is to be thrown");
</script>
</body>
</html>

View file

@ -0,0 +1,21 @@
<!DOCTYPE html>
<html>
<head>
<title>Audio Test: audio_volume_loudest</title>
<link rel="author" title="Intel" href="http://www.intel.com" />
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-media-volume" />
<meta name="flags" content="" />
<meta name="assert" content="Check if the volume attribute is set to 1.0 as loudest in the audio element that expecting the user hears sound loudly" />
<script src="/common/media.js"></script>
</head>
<body>
<p>Test passes if the audio is playing with sound heard and the text 'The user agent doesn't support media element.' does not appear anywhere on this page</p>
<audio id="m" controls>The user agent doesn't support media element.</audio>
<script type="text/javascript">
var media = document.getElementById("m");
media.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random();
media.volume = 1.0;
media.play();
</script>
</body>
</html>

View file

@ -0,0 +1,21 @@
<!DOCTYPE html>
<html>
<head>
<title>Audio Test: audio_volume_silent</title>
<link rel="author" title="Intel" href="http://www.intel.com" />
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-media-volume" />
<meta name="flags" content="" />
<meta name="assert" content="Check if the volume attribute is set to 0.0 as silent in the audio element that expecting the user hears no sound" />
<script src="/common/media.js"></script>
</head>
<body>
<p>Test passes if the audio is playing without sound heard and the text 'The user agent doesn't support media element.' does not appear anywhere on this page</p>
<audio id="m" controls volume=0.0>The user agent doesn't support media element.</audio>
<script type="text/javascript">
var media = document.getElementById("m");
media.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random();
media.volume = 0.0;
media.play();
</script>
</body>
</html>

View file

@ -0,0 +1,132 @@
[
{
"id": "error-codes",
"original_id": "error-codes"
},
{
"id": "location-of-the-media-resource",
"original_id": "location-of-the-media-resource"
},
{
"id": "mime-types",
"original_id": "mime-types"
},
{
"id": "network-states",
"original_id": "network-states"
},
{
"id": "loading-the-media-resource",
"original_id": "loading-the-media-resource"
},
{
"id": "offsets-into-the-media-resource",
"original_id": "offsets-into-the-media-resource"
},
{
"id": "ready-states",
"original_id": "ready-states"
},
{
"id": "playing-the-media-resource",
"original_id": "playing-the-media-resource"
},
{
"id": "seeking",
"original_id": "seeking"
},
{
"id": "media-resources-with-multiple-media-tracks",
"original_id": "media-resources-with-multiple-media-tracks",
"children": [
{
"id": "audiotracklist-and-videotracklist-objects",
"original_id": "audiotracklist-and-videotracklist-objects"
},
{
"id": "selecting-specific-audio-and-video-tracks-declaratively",
"original_id": "selecting-specific-audio-and-video-tracks-declaratively"
}
]
},
{
"id": "synchronising-multiple-media-elements",
"original_id": "synchronising-multiple-media-elements",
"children": [
{
"id": "introduction-0",
"original_id": "introduction-0"
},
{
"id": "media-controllers",
"original_id": "media-controllers"
},
{
"id": "assigning-a-media-controller-declaratively",
"original_id": "assigning-a-media-controller-declaratively"
}
]
},
{
"id": "timed-text-tracks",
"original_id": "timed-text-tracks",
"children": [
{
"id": "text-track-model",
"original_id": "text-track-model"
},
{
"id": "sourcing-in-band-text-tracks",
"original_id": "sourcing-in-band-text-tracks"
},
{
"id": "sourcing-out-of-band-text-tracks",
"original_id": "sourcing-out-of-band-text-tracks"
},
{
"id": "guidelines-for-exposing-cues-in-various-formats-as-text-track-cues",
"original_id": "guidelines-for-exposing-cues-in-various-formats-as-text-track-cues"
},
{
"id": "text-track-api",
"original_id": "text-track-api"
},
{
"id": "text-tracks-describing-chapters",
"original_id": "text-tracks-describing-chapters"
},
{
"id": "cue-events",
"original_id": "cue-events"
}
]
},
{
"id": "user-interface",
"original_id": "user-interface"
},
{
"id": "time-ranges",
"original_id": "time-ranges"
},
{
"id": "event-definitions",
"original_id": "event-definitions"
},
{
"id": "mediaevents",
"original_id": "mediaevents"
},
{
"id": "security-and-privacy-considerations",
"original_id": "security-and-privacy-considerations"
},
{
"id": "best-practices-for-authors-using-media-elements",
"original_id": "best-practices-for-authors-using-media-elements"
},
{
"id": "best-practices-for-implementors-of-media-elements",
"original_id": "best-practices-for-implementors-of-media-elements"
}
]

View file

@ -0,0 +1,38 @@
<!doctype html>
<title>error</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/media.js"></script>
<div id="log"></div>
<script>
function error_test(tagName, src) {
test(function() {
assert_equals(document.createElement(tagName).error, null);
}, tagName + '.error initial value');
async_test(function(t) {
var e = document.createElement(tagName);
e.src = src;
e.onloadeddata = t.step_func(function() {
assert_equals(e.error, null);
t.done();
});
}, tagName + '.error after successful load');
// TODO: MEDIA_ERR_ABORTED, MEDIA_ERR_NETWORK, MEDIA_ERR_DECODE
async_test(function(t) {
var e = document.createElement(tagName);
e.src = '';
e.onerror = t.step_func(function() {
assert_true(e.error instanceof MediaError);
assert_equals(e.error.code, 4);
assert_equals(e.error.code, e.error.MEDIA_ERR_SRC_NOT_SUPPORTED);
t.done();
});
}, tagName + '.error after setting src to the empty string');
}
error_test('audio', getAudioURI('/media/sound_5'));
error_test('video', getVideoURI('/media/movie_5'));
</script>

View file

@ -0,0 +1,38 @@
<!doctype html>
<html>
<head>
<title>{audio,video} events - canplay</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/media.js"></script>
</head>
<body>
<p><a href="https://html.spec.whatwg.org/multipage/#mediaevents">spec reference</a></p>
<audio id="a" autoplay controls>
</audio>
<video id="v" autoplay controls>
</video>
<div id="log"></div>
<script>
test(function() {
var t = async_test("setting src attribute on autoplay audio should trigger canplay event", {timeout:5000});
var a = document.getElementById("a");
a.addEventListener("canplay", function() {
t.done();
a.pause();
}, false);
a.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random();
}, "audio events - canplay");
test(function() {
var t = async_test("setting src attribute on autoplay video should trigger canplay event", {timeout:5000});
var v = document.getElementById("v");
v.addEventListener("canplay", function() {
t.done();
v.pause();
}, false);
v.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random();
}, "video events - canplay");
</script>
</body>
</html>

View file

@ -0,0 +1,36 @@
<!doctype html>
<html>
<head>
<title>{audio,video} events - canplay</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/media.js"></script>
</head>
<body>
<p><a href="https://html.spec.whatwg.org/multipage/#mediaevents">spec reference</a></p>
<audio id="a" controls>
</audio>
<video id="v" controls>
</video>
<div id="log"></div>
<script>
test(function () {
var t = async_test("setting src attribute on non-autoplay audio should trigger canplay event", {timeout:5000});
var a = document.getElementById("a");
a.addEventListener("canplay", function() {
t.done();
}, false);
a.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random();
}, "audio events - canplay");
test(function () {
var t = async_test("setting src attribute on non-autoplay video should trigger canplay event", {timeout:5000});
var v = document.getElementById("v");
v.addEventListener("canplay", function() {
t.done();
}, false);
v.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random();
}, "video events - canplay");
</script>
</body>
</html>

View file

@ -0,0 +1,38 @@
<!doctype html>
<html>
<head>
<title>{audio,video} events - canplaythrough</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/media.js"></script>
</head>
<body>
<p><a href="https://html.spec.whatwg.org/multipage/#mediaevents">spec reference</a></p>
<audio id="a" autoplay controls>
</audio>
<video id="v" autoplay controls>
</video>
<div id="log"></div>
<script>
test(function() {
var t = async_test("setting src attribute on autoplay audio should trigger canplaythrough event", {timeout:5000});
var a = document.getElementById("a");
a.addEventListener("canplaythrough", function() {
t.done();
a.pause();
}, false);
a.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random();
}, "audio events - canplaythrough");
test(function() {
var t = async_test("setting src attribute on autoplay video should trigger canplaythrough event", {timeout:5000});
var v = document.getElementById("v");
v.addEventListener("canplaythrough", function() {
t.done();
v.pause();
}, false);
v.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random();
}, "video events - canplaythrough");
</script>
</body>
</html>

View file

@ -0,0 +1,36 @@
<!doctype html>
<html>
<head>
<title>{audio,video} events - canplaythrough</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/media.js"></script>
</head>
<body>
<p><a href="https://html.spec.whatwg.org/multipage/#mediaevents">spec reference</a></p>
<audio id="a" controls>
</audio>
<video id="v" controls>
</video>
<div id="log"></div>
<script>
test(function() {
var t = async_test("setting src attribute on non-autoplay audio should trigger canplaythrough event", {timeout:5000});
var a = document.getElementById("a");
a.addEventListener("canplaythrough", function() {
t.done();
}, false);
a.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random();
}, "audio events - canplaythrough");
test(function() {
var t = async_test("setting src attribute on non-autoplay video should trigger canplaythrough event", {timeout:5000});
var v = document.getElementById("v");
v.addEventListener("canplaythrough", function() {
t.done();
}, false);
v.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random();
}, "video events - canplaythrough");
</script>
</body>
</html>

View file

@ -0,0 +1,38 @@
<!doctype html>
<html>
<head>
<title>{audio,video} events - loadeddata</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/media.js"></script>
</head>
<body>
<p><a href="https://html.spec.whatwg.org/multipage/#mediaevents">spec reference</a></p>
<audio id="a" autoplay controls>
</audio>
<video id="v" autoplay controls>
</video>
<div id="log"></div>
<script>
test(function() {
var t = async_test("setting src attribute on autoplay audio should trigger loadeddata event", {timeout:5000});
var a = document.getElementById("a");
a.addEventListener("loadeddata", function() {
t.done();
a.pause();
}, false);
a.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random();
}, "audio events - loadeddata");
test(function() {
var t = async_test("setting src attribute on autoplay video should trigger loadeddata event", {timeout:5000});
var a = document.getElementById("v");
v.addEventListener("loadeddata", function() {
t.done();
v.pause();
}, false);
v.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random();
}, "video events - loadeddata");
</script>
</body>
</html>

View file

@ -0,0 +1,36 @@
<!doctype html>
<html>
<head>
<title>{audio,video} events - loadeddata</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/media.js"></script>
</head>
<body>
<p><a href="https://html.spec.whatwg.org/multipage/#mediaevents">spec reference</a></p>
<audio id="a" controls>
</audio>
<video id="v" controls>
</video>
<div id="log"></div>
<script>
test(function() {
var t = async_test("setting src attribute on non-autoplay audio should trigger loadeddata event", {timeout:5000});
var a = document.getElementById("a");
a.addEventListener("loadeddata", function() {
t.done();
}, false);
a.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random();
}, "audio events - loadeddata");
test(function() {
var t = async_test("setting src attribute on non-autoplay video should trigger loadeddata event", {timeout:5000});
var v = document.getElementById("v");
v.addEventListener("loadeddata", function() {
t.done();
}, false);
v.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random();
}, "video events - loadeddata");
</script>
</body>
</html>

View file

@ -0,0 +1,38 @@
<!doctype html>
<html>
<head>
<title>{audio,video} events - loadedmetadata</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/media.js"></script>
</head>
<body>
<p><a href="https://html.spec.whatwg.org/multipage/#mediaevents">spec reference</a></p>
<audio id="a" autoplay controls>
</audio>
<video id="v" autoplay controls>
</video>
<div id="log"></div>
<script>
test(function() {
var t = async_test("setting src attribute on autoplay audio should trigger loadedmetadata event", {timeout:5000});
var a = document.getElementById("a");
a.addEventListener("loadedmetadata", function() {
t.done();
a.pause();
});
a.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random();
}, "audio events - loadedmetadata");
test(function() {
var t = async_test("setting src attribute on autoplay video should trigger loadedmetadata event", {timeout:5000});
var v = document.getElementById("v");
v.addEventListener("loadedmetadata", function() {
t.done();
v.pause();
});
v.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random();
}, "video events - loadedmetadata");
</script>
</body>
</html>

View file

@ -0,0 +1,36 @@
<!doctype html>
<html>
<head>
<title>{audio,video} events - loadedmetadata</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/media.js"></script>
</head>
<body>
<p><a href="https://html.spec.whatwg.org/multipage/#mediaevents">spec reference</a></p>
<audio id="a" controls>
</audio>
<video id="v" controls>
</video>
<div id="log"></div>
<script>
test(function() {
var t = async_test("setting src attribute on non-autoplay audio should trigger loadedmetadata event", {timeout:5000});
var a = document.getElementById("a");
a.addEventListener("loadedmetadata", function() {
t.done();
}, false);
a.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random();
}, "audio events - loadedmetadata");
test(function() {
var t = async_test("setting src attribute on non-autoplay video should trigger loadedmetadata event", {timeout:5000});
var v = document.getElementById("v");
v.addEventListener("loadedmetadata", function() {
t.done();
}, false);
v.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random();
}, "video events, loadedmetadata");
</script>
</body>
</html>

View file

@ -0,0 +1,38 @@
<!doctype html>
<html>
<head>
<title>{audio,video} events - loadstart</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/media.js"></script>
</head>
<body>
<p><a href="https://html.spec.whatwg.org/multipage/#mediaevents">spec reference</a></p>
<audio id="a" autoplay controls>
</audio>
<video id="v" autoplay controls>
</video>
<div id="log"></div>
<script>
test(function() {
var t = async_test("setting src attribute on autoplay audio should trigger loadstart event", {timeout:5000});
var a = document.getElementById("a");
a.addEventListener("loadstart", function() {
t.done();
a.pause();
}, false);
a.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random();
}, "audio events - loadstart");
test(function() {
var t = async_test("setting src attribute on autoplay video should trigger loadstart event", {timeout:5000});
var v = document.getElementById("v");
v.addEventListener("loadstart", function() {
t.done();
v.pause();
}, false);
v.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random();
}, "video events - loadstart");
</script>
</body>
</html>

View file

@ -0,0 +1,36 @@
<!doctype html>
<html>
<head>
<title>{audio,video} events - loadstart</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/media.js"></script>
</head>
<body>
<p><a href="https://html.spec.whatwg.org/multipage/#mediaevents">spec reference</a></p>
<audio id="a" controls>
</audio>
<video id="v" controls>
</video>
<div id="log"></div>
<script>
test(function() {
var t = async_test("setting src attribute on non-autoplay audio should trigger loadstart event", {timeout:5000});
var a = document.getElementById("a");
a.addEventListener("loadstart", function() {
t.done();
}, false);
a.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random();
}, "audio events - loadstart");
test(function() {
var t = async_test("setting src attribute on non-autoplay video should trigger loadstart event", {timeout:5000});
var v = document.getElementById("v");
v.addEventListener("loadstart", function() {
t.done();
}, false);
v.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random();
}, "video events - loadstart");
</script>
</body>
</html>

View file

@ -0,0 +1,52 @@
<!doctype html>
<html>
<head>
<title>{audio,video} events - canplay, then canplaythrough</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/media.js"></script>
</head>
<body>
<p><a href="https://html.spec.whatwg.org/multipage/#mediaevents">spec reference</a></p>
<audio id="a" autoplay controls>
</audio>
<video id="v" autoplay controls>
</video>
<div id="log"></div>
<script>
test(function() {
var t = async_test("setting src attribute on autoplay audio should trigger canplay then canplaythrough event", {timeout:5000});
var a = document.getElementById("a");
var found_canplay = false;
a.addEventListener("canplay", function() {
found_canplay = true;
});
a.addEventListener("canplaythrough", function() {
t.step(function() {
assert_true(found_canplay);
});
t.done();
a.pause();
}, false);
a.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random();
}, "audio events - canplay, then canplaythrough");
test(function() {
var t = async_test("setting src attribute on autoplay video should trigger canplay then canplaythrough event", {timeout:5000});
var v = document.getElementById("v");
var found_canplay = false;
v.addEventListener("canplay", function() {
found_canplay = true;
});
v.addEventListener("canplaythrough", function() {
t.step(function() {
assert_true(found_canplay);
});
t.done();
v.pause();
}, false);
v.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random();
}, "video events - canplay, then canplaythrough");
</script>
</body>
</html>

View file

@ -0,0 +1,52 @@
<!doctype html>
<html>
<head>
<title>{audio,video} events - canplay, then playing</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/media.js"></script>
</head>
<body>
<p><a href="https://html.spec.whatwg.org/multipage/#mediaevents">spec reference</a></p>
<audio id="a" autoplay controls>
</audio>
<video id="v" autoplay controls>
</video>
<div id="log"></div>
<script>
test(function() {
var t = async_test("setting src attribute on autoplay audio should trigger canplay then playing event", {timeout:5000});
var a = document.getElementById("a");
var found_canplay = false;
a.addEventListener("canplay", function() {
found_canplay = true;
});
a.addEventListener("playing", function() {
t.step(function() {
assert_true(found_canplay);
});
t.done();
a.pause();
}, false);
a.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random();
}, "audio events - canplay, then playing");
test(function() {
var t = async_test("setting src attribute on autoplay video should trigger canplay then playing event", {timeout:5000});
var v = document.getElementById("v");
var found_canplay = false;
v.addEventListener("canplay", function() {
found_canplay = true;
});
v.addEventListener("playing", function() {
t.step(function() {
assert_true(found_canplay);
});
t.done();
v.pause();
}, false);
v.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random();
}, "video events - canplay, then playing");
</script>
</body>
</html>

View file

@ -0,0 +1,52 @@
<!doctype html>
<html>
<head>
<title>{audio,video} events - loadedmetadata, then loadeddata</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/media.js"></script>
</head>
<body>
<p><a href="https://html.spec.whatwg.org/multipage/#mediaevents">spec reference</a></p>
<audio id="a" autoplay controls>
</audio>
<video id="v" autoplay controls>
</video>
<div id="log"></div>
<script>
test(function() {
var t = async_test("setting src attribute on autoplay audio should trigger loadedmetadata then loadeddata event", {timeout:5000});
var a = document.getElementById("a");
var found_loadedmetadata = false;
a.addEventListener("loadedmetadata", function() {
found_loadedmetadata = true;
});
a.addEventListener("loadeddata", function() {
t.step(function() {
assert_true(found_loadedmetadata);
});
t.done();
a.pause();
}, false);
a.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random();
}, "audio events - loadedmetadata, then loadeddata");
test(function() {
var t = async_test("setting src attribute on autoplay video should trigger loadedmetadata then loadeddata event", {timeout:5000});
var v = document.getElementById("v");
var found_loadedmetadata = false;
v.addEventListener("loadedmetadata", function() {
found_loadedmetadata = true;
});
v.addEventListener("loadeddata", function() {
t.step(function() {
assert_true(found_loadedmetadata);
});
t.done();
v.pause();
}, false);
v.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random();
}, "video events - loadedmetadata, then loadeddata");
</script>
</body>
</html>

View file

@ -0,0 +1,52 @@
<!doctype html>
<html>
<head>
<title>{audio,video} events - loadstart, then progress</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/media.js"></script>
</head>
<body>
<p><a href="https://html.spec.whatwg.org/multipage/#mediaevents">spec reference</a></p>
<audio id="a" autoplay controls>
</audio>
<video id="v" autoplay controls>
</video>
<div id="log"></div>
<script>
test(function() {
var t = async_test("setting src attribute on autoplay audio should trigger loadstart then progress event", {timeout:5000});
var a = document.getElementById("a");
var found_loadstart = false;
a.addEventListener("loadstart", function() {
found_loadstart = true;
});
a.addEventListener("progress", function() {
t.step(function() {
assert_true(found_loadstart);
});
t.done();
a.pause();
}, false);
a.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random();
}, "audio events - loadstart, then progress");
test(function() {
var t = async_test("setting src attribute on autoplay video should trigger loadstart then progress event", {timeout:5000});
var v = document.getElementById("v");
var found_loadstart = false;
v.addEventListener("loadstart", function() {
found_loadstart = true;
});
v.addEventListener("progress", function() {
t.step(function() {
assert_true(found_loadstart);
});
t.done();
v.pause();
}, false);
v.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random();
}, "video events - loadstart, then progress");
</script>
</body>
</html>

View file

@ -0,0 +1,48 @@
<!doctype html>
<html>
<head>
<title>{audio,video} events - pause</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/media.js"></script>
</head>
<body>
<p><a href="https://html.spec.whatwg.org/multipage/#mediaevents">spec reference</a></p>
<audio id="a" autoplay controls>
</audio>
<video id="v" autoplay controls>
</video>
<div id="log"></div>
<script>
test(function() {
var t = async_test("calling pause() on autoplay audio should trigger pause event", {timeout:5000});
var a = document.getElementById("a");
a.addEventListener("pause", function() {
t.step(function() {
assert_true(true);
});
t.done();
}, false);
a.addEventListener("play", function() {
a.pause(); // pause right after play
});
a.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random();
}, "audio events - pause");
test(function() {
var t = async_test("calling pause() on autoplay video should trigger pause event", {timeout:5000});
var v = document.getElementById("v");
v.addEventListener("pause", function() {
t.step(function() {
assert_true(true);
});
t.done();
}, false);
v.addEventListener("play", function() {
v.pause(); // pause right after play
});
v.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random();
}, "video events - pause");
</script>
</body>
</html>

View file

@ -0,0 +1,40 @@
<!doctype html>
<html>
<head>
<title>{audio,video} events - pause</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/media.js"></script>
</head>
<body>
<p><a href="https://html.spec.whatwg.org/multipage/#mediaevents">spec reference</a></p>
<audio id="a" controls>
</audio>
<video id="v" controls>
</video>
<div id="log"></div>
<script>
test(function() {
var t = async_test("calling play() then pause() on non-autoplay audio should trigger pause event", {timeout:5000});
var a = document.getElementById("a");
a.addEventListener("pause", function() {
t.done();
}, false);
a.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random();
a.play();
a.pause();
}, "audio events - pause");
test(function() {
var t = async_test("calling play() then pause() on non-autoplay video should trigger pause event", {timeout:5000});
var v = document.getElementById("v");
v.addEventListener("pause", function() {
t.done();
}, false);
v.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random();
v.play();
v.pause();
}, "video events - pause");
</script>
</body>
</html>

View file

@ -0,0 +1,38 @@
<!doctype html>
<html>
<head>
<title>{audio,video} events - play</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/media.js"></script>
</head>
<body>
<p><a href="https://html.spec.whatwg.org/multipage/#mediaevents">spec reference</a></p>
<audio id="a" autoplay controls>
</audio>
<video id="v" autoplay controls>
</video>
<div id="log"></div>
<script>
test(function() {
var t = async_test("setting src attribute on autoplay audio should trigger play event", {timeout:5000});
var a = document.getElementById("a");
a.addEventListener("play", function() {
t.done();
a.pause();
}, false);
a.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random();
}, "audio events - play");
test(function() {
var t = async_test("setting src attribute on autoplay video should trigger play event", {timeout:5000});
var v = document.getElementById("v");
v.addEventListener("play", function() {
t.done();
v.pause();
}, false);
v.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random();
}, "video events - play");
</script>
</body>
</html>

View file

@ -0,0 +1,40 @@
<!doctype html>
<html>
<head>
<title>{audio,video} events - play</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/media.js"></script>
</head>
<body>
<p><a href="https://html.spec.whatwg.org/multipage/#mediaevents">spec reference</a></p>
<audio id="a" controls>
</audio>
<video id="v" controls>
</video>
<div id="log"></div>
<script>
test(function() {
var t = async_test("calling play() on audio should trigger play event", {timeout:5000});
var a = document.getElementById("a");
a.addEventListener("play", function() {
t.done();
a.pause();
}, false);
a.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random();
a.play();
}, "audio events - play");
test(function() {
var t = async_test("calling play() on video should trigger play event", {timeout:5000});
var v = document.getElementById("v");
v.addEventListener("play", function() {
t.done();
v.pause();
}, false);
v.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random();
v.play();
}, "video events - play");
</script>
</body>
</html>

View file

@ -0,0 +1,38 @@
<!doctype html>
<html>
<head>
<title>{audio,video} events - playing</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/media.js"></script>
</head>
<body>
<p><a href="https://html.spec.whatwg.org/multipage/#mediaevents">spec reference</a></p>
<audio id="a" autoplay controls>
</audio>
<video id="v" autoplay controls>
</video>
<div id="log"></div>
<script>
test(function() {
var t = async_test("setting src attribute on autoplay audio should trigger playing event", {timeout:5000});
var a = document.getElementById("a");
a.addEventListener("playing", function() {
t.done();
a.pause();
}, false);
a.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random();
}, "audio events - playing");
test(function() {
var t = async_test("setting src attribute on autoplay video should trigger playing event", {timeout:5000});
var v = document.getElementById("v");
v.addEventListener("playing", function() {
t.done();
v.pause();
}, false);
v.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random();
}, "video events - playing");
</script>
</body>
</html>

View file

@ -0,0 +1,40 @@
<!doctype html>
<html>
<head>
<title>{audio,video} events - playing</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/media.js"></script>
</head>
<body>
<p><a href="https://html.spec.whatwg.org/multipage/#mediaevents">spec reference</a></p>
<audio id="a" controls>
</audio>
<video id="v" controls>
</video>
<div id="log"></div>
<script>
test(function() {
var t = async_test("calling play() on audio should trigger playing event", {timeout:5000});
var a = document.getElementById("a");
a.addEventListener("playing", function() {
t.done();
a.pause();
});
a.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random();
a.play();
}, "audio events - playing");
test(function() {
var t = async_test("calling play() on video should trigger playing event", {timeout:5000});
var v = document.getElementById("v");
v.addEventListener("playing", function() {
t.done();
v.pause();
});
v.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random();
v.play();
}, "video events - playing");
</script>
</body>
</html>

View file

@ -0,0 +1,38 @@
<!doctype html>
<html>
<head>
<title>{audio,video} events - progress</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/media.js"></script>
</head>
<body>
<p><a href="https://html.spec.whatwg.org/multipage/#mediaevents">spec reference</a></p>
<audio id="a" autoplay controls>
</audio>
<video id="v" autoplay controls>
</video>
<div id="log"></div>
<script>
test(function() {
var t = async_test("setting src attribute on autoplay audio should trigger progress event", {timeout:5000});
var a = document.getElementById("a");
a.addEventListener("progress", function() {
t.done();
a.pause();
}, false);
a.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random();
}, "audio events - progress");
test(function() {
var t = async_test("setting src attribute on autoplay video should trigger progress event", {timeout:5000});
var v = document.getElementById("v");
v.addEventListener("progress", function() {
t.done();
v.pause();
}, false);
v.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random();
}, "video events - progress");
</script>
</body>
</html>

View file

@ -0,0 +1,36 @@
<!doctype html>
<html>
<head>
<title>{audio,video} events - progress</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/media.js"></script>
</head>
<body>
<p><a href="https://html.spec.whatwg.org/multipage/#mediaevents">spec reference</a></p>
<audio id="a" controls>
</audio>
<video id="v" controls>
</video>
<div id="log"></div>
<script>
test(function() {
var t = async_test("setting src attribute on non-autoplay audio should trigger progress event", {timeout:5000});
var a = document.getElementById("a");
a.addEventListener("progress", function() {
t.done();
}, false);
a.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random();
}, "audio events - progress");
test(function() {
var t = async_test("setting src attribute on non-autoplay video should trigger progress event", {timeout:5000});
var v = document.getElementById("v");
v.addEventListener("progress", function() {
t.done();
}, false);
v.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random();
}, "video events - progress");
</script>
</body>
</html>

View file

@ -0,0 +1,34 @@
<!doctype html>
<html>
<head>
<title>{audio,video} events - timeupdate</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/media.js"></script>
</head>
<body>
<p><a href="https://html.spec.whatwg.org/multipage/#mediaevents">spec reference</a></p>
<audio id="a" autoplay controls>
</audio>
<video id="v" autoplay controls>
</video>
<div id="log"></div>
<script>
var ta = async_test("setting src attribute on a sufficiently long autoplay audio should trigger timeupdate event", {timeout:5000});
var a = document.getElementById("a");
a.addEventListener("timeupdate", function() {
ta.done();
a.pause();
}, false);
a.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random();
var tv = async_test("setting src attribute on a sufficiently long autoplay video should trigger timeupdate event", {timeout:5000});
var v = document.getElementById("v");
v.addEventListener("timeupdate", function() {
tv.done();
v.pause();
}, false);
v.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random();
</script>
</body>
</html>

View file

@ -0,0 +1,40 @@
<!doctype html>
<html>
<head>
<title>{audio,video} events - timeupdate</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/media.js"></script>
</head>
<body>
<p><a href="https://html.spec.whatwg.org/multipage/#mediaevents">spec reference</a></p>
<audio id="a" controls>
</audio>
<video id="v" controls>
</video>
<div id="log"></div>
<script>
test(function() {
var t = async_test("calling play() on a sufficiently long audio should trigger timeupdate event", {timeout:5000});
var a = document.getElementById("a");
a.addEventListener("timeupdate", function() {
t.done();
a.pause();
}, false);
a.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random();
a.play();
}, "audio events - timeupdate");
test(function() {
var t = async_test("calling play() on a sufficiently long video should trigger timeupdate event", {timeout:5000});
var v = document.getElementById("v");
v.addEventListener("timeupdate", function() {
t.done();
v.pause();
}, false);
v.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random();
v.play();
}, "video events - timeupdate");
</script>
</body>
</html>

View file

@ -0,0 +1,72 @@
<!doctype html>
<title>volumechange event</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
function volumechange_test(tagName) {
async_test(function(t) {
var e = document.createElement(tagName);
assert_equals(e.volume, 1);
e.volume = 0.5;
assert_equals(e.volume, 0.5);
e.onvolumechange = t.step_func(function() {
assert_equals(e.volume, 0.5);
e.volume = 1;
assert_equals(e.volume, 1);
e.onvolumechange = t.step_func(function() {
assert_equals(e.volume, 1);
t.done();
});
});
}, "setting " + tagName + ".volume fires volumechange");
async_test(function(t) {
var e = document.createElement(tagName);
assert_false(e.muted);
e.muted = true;
assert_true(e.muted);
e.onvolumechange = t.step_func(function() {
assert_true(e.muted);
e.muted = false;
assert_false(e.muted);
e.onvolumechange = t.step_func(function() {
assert_false(e.muted);
t.done();
});
});
}, "setting " + tagName + ".muted fires volumechange");
async_test(function(t) {
var e = document.createElement(tagName);
e.volume = e.volume;
e.muted = e.muted;
e.onvolumechange = t.step_func(function() {
assert_unreached();
});
var e2 = document.createElement(tagName);
e2.muted = !e2.muted;
e2.onvolumechange = t.step_func(function() {
t.done();
});
}, "setting " + tagName + ".volume/muted to the same value does not fire volumechange");
async_test(function(t) {
var e = document.createElement(tagName);
e.muted = !e.muted;
e.volume = 1 - e.volume;
e.muted = !e.muted;
e.volume = 1 - e.volume;
var volumechange_count = 0;
e.onvolumechange = t.step_func(function() {
volumechange_count++;
if (volumechange_count == 4) {
t.done();
}
});
}, "setting " + tagName + ".volume/muted repeatedly fires volumechange repeatedly");
}
volumechange_test("audio");
volumechange_test("video");
</script>

View file

@ -0,0 +1,46 @@
<!doctype html>
<title>Historical media element features should not be supported</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<script>
function t(property, tagName) {
var tagNames = tagName ? [tagName] : ['audio', 'video'];
tagNames.forEach(function(tagName) {
test(function() {
assert_false(property in document.createElement(tagName));
}, tagName + '.' + property + ' should not be supported');
});
}
t('bufferingRate'); // added in r678, removed in r2872.
t('start'); // added in r692, removed in r2401.
t('end'); // added in r692, removed in r2401.
t('loopStart'); // added in r692, removed in r2401.
t('loopEnd'); // added in r692, removed in r2401.
t('loopCount'); // added in r692, replaced with playCount in r1105.
t('currentLoop'); // added in r692, removed in r2401.
t('addCuePoint'); // added in r721, replaced with addCueRange in r1106.
t('removeCuePoint'); // added in r721, replaced with removeCueRanges in r1106.
t('media', 'source'); // added in r724, removed in r8472.
t('playCount'); // added in r1105, removed in r2401.
t('addCueRange'); // added in r1106, removed in r5070.
t('removeCueRanges'); // added in r1106, removed in r5070.
t('pixelratio', 'source'); // added in r1629, removed in r2493.
t('bufferedBytes'); // added in r1630, removed in r2405.
t('totalBytes'); // added in r1630, removed in r2405.
t('bufferingThrottled'); // added in r1632, removed in r2872.
t('autobuffer'); // added in r2855, replaced with preload in r4811.
t('startTime'); // added in r3035, replaced with initialTime in r5310.
t('startOffsetTime'); // added in r5310, replaced with startDate in r7045.
t('initialTime'); // added in r5310, removed in r7046.
t('audio', 'video'); // added in r5636, replaced with muted in r5991.
t('startDate'); // added in r7045, replaced with getStartDate() in r8113.
// TextTrackCue constructor: added in r5723, removed in r7742.
test(function() {
assert_throws(new TypeError(), function() {
new TextTrackCue(0, 0, '');
});
}, 'TextTrackCue constructor should not be supported');
</script>

View file

@ -0,0 +1,116 @@
<!doctype html>
<title>HTMLMediaElement.addTextTrack</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
var video = document.createElement('video');
test(function(){
assert_throws(new TypeError(), function(){
video.addTextTrack('foo');
});
assert_throws(new TypeError(), function(){
video.addTextTrack(undefined);
});
assert_throws(new TypeError(), function(){
video.addTextTrack(null);
});
}, document.title + ' bogus first arg');
test(function(){
assert_throws(new TypeError(), function(){
video.addTextTrack('SUBTITLES');
});
}, document.title + ' uppercase first arg');
test(function(){
var t = video.addTextTrack('subtitles');
assert_equals(t.kind, 'subtitles');
assert_equals(t.label, '');
assert_equals(t.language, '');
assert_equals(t.mode, 'hidden');
assert_true(t.cues instanceof TextTrackCueList);
assert_equals(t.cues.length, 0);
}, document.title + ' subtitles first arg');
test(function(){
var t = video.addTextTrack('captions');
assert_equals(t.kind, 'captions');
assert_equals(t.label, '');
assert_equals(t.language, '');
assert_equals(t.mode, 'hidden');
assert_true(t.cues instanceof TextTrackCueList);
assert_equals(t.cues.length, 0);
}, document.title + ' captions first arg');
test(function(){
var t = video.addTextTrack('descriptions');
assert_equals(t.kind, 'descriptions');
assert_equals(t.label, '');
assert_equals(t.language, '');
assert_equals(t.mode, 'hidden');
assert_true(t.cues instanceof TextTrackCueList);
assert_equals(t.cues.length, 0);
}, document.title + ' descriptions first arg');
test(function(){
var t = video.addTextTrack('chapters');
assert_equals(t.kind, 'chapters');
assert_equals(t.label, '');
assert_equals(t.language, '');
assert_equals(t.mode, 'hidden');
assert_true(t.cues instanceof TextTrackCueList);
assert_equals(t.cues.length, 0);
}, document.title + ' chapters first arg');
test(function(){
var t = video.addTextTrack('metadata');
assert_equals(t.kind, 'metadata');
assert_equals(t.label, '');
assert_equals(t.language, '');
assert_equals(t.mode, 'hidden');
assert_true(t.cues instanceof TextTrackCueList);
assert_equals(t.cues.length, 0);
}, document.title + ' metadata first arg');
test(function(){
var t = video.addTextTrack('subtitles', undefined, undefined);
assert_equals(t.kind, 'subtitles');
assert_equals(t.label, '');
assert_equals(t.language, '');
assert_equals(t.mode, 'hidden');
assert_true(t.cues instanceof TextTrackCueList);
assert_equals(t.cues.length, 0);
}, document.title + ' undefined second and third arg');
test(function(){
var t = video.addTextTrack('subtitles', null, null);
assert_equals(t.kind, 'subtitles');
assert_equals(t.label, 'null');
assert_equals(t.language, 'null');
assert_equals(t.mode, 'hidden');
assert_true(t.cues instanceof TextTrackCueList);
assert_equals(t.cues.length, 0);
}, document.title + ' null second and third arg');
test(function(){
var t = video.addTextTrack('subtitles', 'foo', 'bar');
assert_equals(t.kind, 'subtitles');
assert_equals(t.label, 'foo');
assert_equals(t.language, 'bar');
assert_equals(t.mode, 'hidden');
assert_true(t.cues instanceof TextTrackCueList);
assert_equals(t.cues.length, 0);
}, document.title + ' foo and bar second and third arg');
test(function(){
var t = video.addTextTrack('subtitles', 'foo');
assert_equals(t.kind, 'subtitles');
assert_equals(t.label, 'foo');
assert_equals(t.language, '');
assert_equals(t.mode, 'hidden');
assert_true(t.cues instanceof TextTrackCueList);
assert_equals(t.cues.length, 0);
}, document.title + ' foo second arg, third arg omitted');
</script>

View file

@ -0,0 +1,13 @@
<!doctype html>
<title>HTMLMediaElement.textTracks</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
var video = document.createElement('video');
test(function(){
assert_equals(video.textTracks, video.textTracks);
assert_equals(video.textTracks.length, 0);
});
</script>

View file

@ -0,0 +1,55 @@
<!doctype html>
<title>HTMLTrackElement.default</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
test(function(){
var track = document.createElement('track');
assert_equals(track['default'], false);
assert_equals(track.getAttribute('default'), null);
}, document.title + ' missing value');
test(function(){
var track = document.createElement('track');
track.setAttribute('default', '');
assert_equals(track['default'], true);
assert_equals(track.getAttribute('default'), '');
}, document.title + ' empty string content attribute');
test(function(){
var track = document.createElement('track');
track['default'] = '';
assert_equals(track['default'], false);
assert_equals(track.getAttribute('default'), null);
}, document.title + ' empty string IDL attribute');
test(function(){
var track = document.createElement('track');
track.setAttribute('default', 'foo');
assert_equals(track['default'], true);
assert_equals(track.getAttribute('default'), 'foo');
}, document.title + ' foo in content attribute');
test(function(){
var track = document.createElement('track');
track['default'] = 'foo';
assert_equals(track['default'], true);
assert_equals(track.getAttribute('default'), '');
}, document.title + ' foo in IDL attribute');
test(function(){
var track = document.createElement('track');
track['default'] = true;
assert_equals(track['default'], true);
assert_equals(track.getAttribute('default'), '');
}, document.title + ' true in IDL attribute');
test(function(){
var track = document.createElement('track');
track.setAttribute('default', '');
track['default'] = false;
assert_equals(track['default'], false);
assert_equals(track.getAttribute('default'), null);
}, document.title + ' false in IDL attribute');
</script>

View file

@ -0,0 +1,146 @@
<!doctype html>
<title>HTMLTrackElement.kind</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
test(function(){
var track = document.createElement('track');
assert_equals(track.kind, 'subtitles');
assert_equals(track.getAttribute('kind'), null);
}, document.title + ' missing value');
test(function(){
var track = document.createElement('track');
track.setAttribute('kind', 'invalid');
assert_equals(track.kind, 'subtitles');
assert_equals(track.getAttribute('kind'), 'invalid');
}, document.title + ' invalid value in content attribute');
test(function(){
var track = document.createElement('track');
track.setAttribute('kind', 'CAPTIONS');
assert_equals(track.kind, 'captions');
assert_equals(track.getAttribute('kind'), 'CAPTIONS');
}, document.title + ' content attribute uppercase');
test(function(){
var track = document.createElement('track');
track.setAttribute('kind', 'CAPT\u0130ONS');
assert_equals(track.kind, 'subtitles');
assert_equals(track.getAttribute('kind'), 'CAPT\u0130ONS');
}, document.title + ' content attribute with uppercase turkish I (with dot)');
test(function(){
var track = document.createElement('track');
track.setAttribute('kind', 'capt\u0131ons');
assert_equals(track.kind, 'subtitles');
assert_equals(track.getAttribute('kind'), 'capt\u0131ons');
}, document.title + ' content attribute with lowercase turkish i (dotless)');
test(function(){
var track = document.createElement('track');
track.setAttribute('kind', 'subtitles');
assert_equals(track.kind, 'subtitles');
assert_equals(track.getAttribute('kind'), 'subtitles');
}, document.title + ' content attribute "subtitles"');
test(function(){
var track = document.createElement('track');
track.setAttribute('kind', 'captions');
assert_equals(track.kind, 'captions');
assert_equals(track.getAttribute('kind'), 'captions');
}, document.title + ' content attribute "captions"');
test(function(){
var track = document.createElement('track');
track.setAttribute('kind', 'descriptions');
assert_equals(track.kind, 'descriptions');
assert_equals(track.getAttribute('kind'), 'descriptions');
}, document.title + ' content attribute "descriptions"');
test(function(){
var track = document.createElement('track');
track.setAttribute('kind', 'chapters');
assert_equals(track.kind, 'chapters');
assert_equals(track.getAttribute('kind'), 'chapters');
}, document.title + ' content attribute "chapters"');
test(function(){
var track = document.createElement('track');
track.setAttribute('kind', 'metadata');
assert_equals(track.kind, 'metadata');
assert_equals(track.getAttribute('kind'), 'metadata');
}, document.title + ' content attribute "metadata"');
test(function(){
var track = document.createElement('track');
track.setAttribute('kind', 'captions\u0000');
assert_equals(track.kind, 'subtitles');
assert_equals(track.getAttribute('kind'), 'captions\u0000');
}, document.title + ' content attribute "captions\\u0000"');
test(function(){
var track = document.createElement('track');
track.kind = 'subtitles';
assert_equals(track.getAttribute('kind'), 'subtitles');
assert_equals(track.kind, 'subtitles');
}, document.title + ' setting IDL attribute to "subtitles"');
test(function(){
var track = document.createElement('track');
track.kind = 'captions';
assert_equals(track.getAttribute('kind'), 'captions');
assert_equals(track.kind, 'captions');
}, document.title + ' setting IDL attribute to "captions"');
test(function(){
var track = document.createElement('track');
track.kind = 'descriptions';
assert_equals(track.getAttribute('kind'), 'descriptions');
assert_equals(track.kind, 'descriptions');
}, document.title + ' setting IDL attribute to "descriptions"');
test(function(){
var track = document.createElement('track');
track.kind = 'chapters';
assert_equals(track.getAttribute('kind'), 'chapters');
assert_equals(track.kind, 'chapters');
}, document.title + ' setting IDL attribute to "chapters"');
test(function(){
var track = document.createElement('track');
track.kind = 'metadata';
assert_equals(track.getAttribute('kind'), 'metadata');
assert_equals(track.kind, 'metadata');
}, document.title + ' setting IDL attribute to "metadata"');
test(function(){
var track = document.createElement('track');
track.kind = 'CAPTIONS';
assert_equals(track.getAttribute('kind'), 'CAPTIONS');
assert_equals(track.kind, 'captions');
}, document.title + ' setting IDL attribute to "CAPTIONS"');
test(function(){
var track = document.createElement('track');
track.kind = 'CAPT\u0130ONS';
assert_equals(track.getAttribute('kind'), 'CAPT\u0130ONS');
assert_equals(track.kind, 'subtitles');
}, document.title + ' setting IDL attribute with uppercase turkish I (with dot)');
test(function(){
var track = document.createElement('track');
track.kind = 'capt\u0131ons';
assert_equals(track.getAttribute('kind'), 'capt\u0131ons');
assert_equals(track.kind, 'subtitles');
}, document.title + ' setting IDL attribute with lowercase turkish I (dotless)');
test(function(){
var track = document.createElement('track');
track.kind = 'captions\u0000';
assert_equals(track.getAttribute('kind'), 'captions\u0000');
assert_equals(track.kind, 'subtitles');
}, document.title + ' setting IDL attribute with \\u0000');
</script>

View file

@ -0,0 +1,83 @@
<!doctype html>
<title>HTMLTrackElement.label</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
test(function(){
var track = document.createElement('track');
assert_equals(track.label, '');
assert_equals(track.getAttribute('label'), null);
}, document.title + ' missing value');
test(function(){
var track = document.createElement('track');
track.setAttribute('label', '');
assert_equals(track.label, '');
assert_equals(track.getAttribute('label'), '');
}, document.title + ' empty string content attribute');
test(function(){
var track = document.createElement('track');
track.label = '';
assert_equals(track.label, '');
assert_equals(track.getAttribute('label'), '');
}, document.title + ' empty string IDL attribute');
test(function(){
var track = document.createElement('track');
track.setAttribute('label', 'foo');
assert_equals(track.label, 'foo');
assert_equals(track.getAttribute('label'), 'foo');
}, document.title + ' lowercase content attribute');
test(function(){
var track = document.createElement('track');
track.setAttribute('label', 'FOO');
assert_equals(track.label, 'FOO');
assert_equals(track.getAttribute('label'), 'FOO');
}, document.title + ' uppercase content attribute');
test(function(){
var track = document.createElement('track');
track.setAttribute('label', '\u0000');
assert_equals(track.label, '\u0000');
assert_equals(track.getAttribute('label'), '\u0000');
}, document.title + '\\u0000 in content attribute');
test(function(){
var track = document.createElement('track');
track.label = 'foo';
assert_equals(track.label, 'foo');
assert_equals(track.getAttribute('label'), 'foo');
}, document.title + ' lowercase IDL attribute');
test(function(){
var track = document.createElement('track');
track.label = 'FOO';
assert_equals(track.label, 'FOO');
assert_equals(track.getAttribute('label'), 'FOO');
}, document.title + ' uppercase IDL attribute');
test(function(){
var track = document.createElement('track');
track.setAttribute('label', ' foo \n');
assert_equals(track.label, ' foo \n');
assert_equals(track.getAttribute('label'), ' foo \n');
}, document.title + ' whitespace in content attribute');
test(function(){
var track = document.createElement('track');
track.label = ' foo \n';
assert_equals(track.label, ' foo \n');
assert_equals(track.getAttribute('label'), ' foo \n');
}, document.title + ' whitespace in IDL attribute');
test(function(){
var track = document.createElement('track');
track.label = '\u0000';
assert_equals(track.label, '\u0000');
assert_equals(track.getAttribute('label'), '\u0000');
}, document.title + ' \\u0000 in IDL attribute');
</script>

View file

@ -0,0 +1,11 @@
<!doctype html>
<title>HTMLTrackElement.readyState</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
test(function(){
var track = document.createElement('track');
assert_equals(track.readyState, 0);
}, document.title + ' default value');
</script>

View file

@ -0,0 +1,77 @@
<!doctype html>
<title>HTMLTrackElement.src</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
test(function(){
var track = document.createElement('track');
assert_equals(track.src, '');
assert_equals(track.getAttribute('src'), null);
}, document.title + ' missing value');
test(function(){
var track = document.createElement('track');
track.setAttribute('src', '');
assert_equals(track.src, '');
assert_equals(track.getAttribute('src'), '');
}, document.title + ' empty string in content attribute');
test(function(){
var track = document.createElement('track');
track.src = '';
assert_equals(track.src, '');
assert_equals(track.getAttribute('src'), '');
}, document.title + ' empty string in IDL attribute');
test(function(){
var track = document.createElement('track');
track.setAttribute('src', 'http://foo bar');
assert_equals(track.src, 'http://foo bar');
assert_equals(track.getAttribute('src'), 'http://foo bar');
}, document.title + ' unresolvable value in content attribute');
test(function(){
var track = document.createElement('track');
track.setAttribute('src', 'test');
var link = document.createElement('a');
link.setAttribute('href', 'test');
assert_equals(track.src, link.href);
assert_equals(track.getAttribute('src'), 'test');
}, document.title + ' resolvable value in content attribute');
test(function(){
var track = document.createElement('track');
track.setAttribute('src', '\u0000');
var link = document.createElement('a');
link.setAttribute('href', '%00');
assert_equals(track.src, link.href);
assert_equals(track.getAttribute('src'), '\u0000');
}, document.title + ' \\u0000 in content attribute');
test(function(){
var track = document.createElement('track');
track.src = 'http://foo bar';
assert_equals(track.src, 'http://foo bar');
assert_equals(track.getAttribute('src'), 'http://foo bar');
}, document.title + ' assigning unresolvable value to IDL attribute');
test(function(){
var track = document.createElement('track');
track.src = 'test';
var link = document.createElement('a');
link.setAttribute('href', 'test');
assert_equals(track.src, link.href);
assert_equals(track.getAttribute('src'), 'test');
}, document.title + ' assigning resolvable value to IDL attribute');
test(function(){
var track = document.createElement('track');
track.src = '\u0000';
var link = document.createElement('a');
link.setAttribute('href', '%00');
assert_equals(track.src, link.href);
assert_equals(track.getAttribute('src'), '\u0000');
}, document.title + ' assigning \\u0000 to IDL attribute');
</script>

View file

@ -0,0 +1,82 @@
<!doctype html>
<title>HTMLTrackElement.srclang</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
test(function(){
var track = document.createElement('track');
assert_equals(track.srclang, '');
assert_equals(track.getAttribute('srclang'), null);
}, document.title + ' missing value');
test(function(){
var track = document.createElement('track');
track.setAttribute('srclang', '');
assert_equals(track.srclang, '');
assert_equals(track.getAttribute('srclang'), '');
}, document.title + ' empty string content attribute');
test(function(){
var track = document.createElement('track');
track.srclang = '';
assert_equals(track.srclang, '');
assert_equals(track.getAttribute('srclang'), '');
}, document.title + ' empty string IDL attribute');
test(function(){
var track = document.createElement('track');
track.setAttribute('srclang', 'foo');
assert_equals(track.srclang, 'foo');
assert_equals(track.getAttribute('srclang'), 'foo');
}, document.title + ' lowercase content attribute');
test(function(){
var track = document.createElement('track');
track.setAttribute('srclang', 'FOO');
assert_equals(track.srclang, 'FOO');
assert_equals(track.getAttribute('srclang'), 'FOO');
}, document.title + ' uppercase content attribute');
test(function(){
var track = document.createElement('track');
track.setAttribute('srclang', '\u0000');
assert_equals(track.srclang, '\u0000');
assert_equals(track.getAttribute('srclang'), '\u0000');
}, document.title + ' \\u0000 content attribute');
test(function(){
var track = document.createElement('track');
track.srclang = 'foo';
assert_equals(track.srclang, 'foo');
assert_equals(track.getAttribute('srclang'), 'foo');
}, document.title + ' lowercase IDL attribute');
test(function(){
var track = document.createElement('track');
track.srclang = 'FOO';
assert_equals(track.srclang, 'FOO');
assert_equals(track.getAttribute('srclang'), 'FOO');
}, document.title + ' uppercase IDL attribute');
test(function(){
var track = document.createElement('track');
track.setAttribute('srclang', ' foo \n');
assert_equals(track.srclang, ' foo \n');
assert_equals(track.getAttribute('srclang'), ' foo \n');
}, document.title + ' whitespace in content attribute');
test(function(){
var track = document.createElement('track');
track.srclang = ' foo \n';
assert_equals(track.srclang, ' foo \n');
assert_equals(track.getAttribute('srclang'), ' foo \n');
}, document.title + ' whitespace in IDL attribute');
test(function(){
var track = document.createElement('track');
track.srclang = '\u0000';
assert_equals(track.srclang, '\u0000');
assert_equals(track.getAttribute('srclang'), '\u0000');
}, document.title + ' \\u0000 in IDL attribute');
</script>

View file

@ -0,0 +1,12 @@
<!doctype html>
<title>HTMLTrackElement.track</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
test(function(){
var track = document.createElement('track');
assert_equals(track.track, track.track, 'same object should be returned');
assert_true(track.track instanceof TextTrack, 'returned object should be a TextTrack');
});
</script>

View file

@ -0,0 +1,104 @@
<!doctype html>
<title>TextTrack.activeCues</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=/common/media.js></script>
<div id=log></div>
<script>
setup(function(){
window.video = document.createElement('video');
window.t1 = video.addTextTrack('subtitles');
window.track = document.createElement('track');
track['default'] = true;
video.appendChild(track);
window.t2 = track.track;
t2.mode = 'showing';
window.t1_cues = t1.activeCues;
window.t2_cues = t2.activeCues;
document.body.appendChild(video);
if (!t1)
throw new Error('t1 was undefined')
}, {timeout:25000});
function smoke_test() {
assert_true('HTMLTrackElement' in window, 'track not supported');
}
test(function(){
smoke_test();
assert_equals(t1.activeCues, t1_cues, 't1.activeCues should return same object');
assert_equals(t2.activeCues, t2_cues, 't2.activeCues should return same object');
assert_not_equals(t1.activeCues, t2.activeCues, 't1.activeCues and t2.activeCues should be different objects');
assert_not_equals(t1.activeCues, null, 't1.activeCues should not be null');
assert_not_equals(t2.activeCues, null, 't2.activeCues should not be null');
assert_equals(t1.activeCues.length, 0, 't1.activeCues should have length 0');
assert_equals(t2.activeCues.length, 0, 't2.activeCues should have length 0');
}, document.title+', empty list');
test(function(){
smoke_test();
var c = new VTTCue(0, 1, "text");
t1.addCue(c);
assert_equals(t1.activeCues, t1_cues, "t1.activeCues should return same object");
assert_equals(t1.activeCues.length, 0, "t1.activeCues.length");
var c2 = new VTTCue(1, 2, "text2");
t1.addCue(c2);
assert_equals(t1.activeCues, t1_cues, "t1.activeCues should return the same object after adding a second cue");
assert_equals(t1.activeCues.length, 0, "t1.activeCues.length after adding a second cue");
}, document.title+', after addCue()');
test(function(){
smoke_test();
t1.mode = 'showing';
assert_equals(t1.activeCues, t1_cues, "t1.activeCues should return the same object after setting mode to showing");
t1.mode = 'hidden';
assert_equals(t1.activeCues, t1_cues, "t1.activeCues should return the same object after setting mode to hidden");
t1.mode = 'disabled';
assert_equals(t1.activeCues, null, "t1.activeCues should be null when mode is disabled");
assert_equals(t1_cues.length, 0, "t1_cues should still be intact after setting mode to disabled");
}, document.title+', different modes');
// ok now let's load in a video
var test1 = async_test(document.title+', video loading', {timeout:20000});
var test2 = async_test(document.title+', video playing', {timeout:20000});
var test3 = async_test(document.title+', adding cue during playback', {timeout:20000});
test1.step(smoke_test);
test2.step(smoke_test);
test3.step(smoke_test);
test1.step(function(){
t1.mode = 'showing';
video.onloadeddata = test1.step_func(function(e) {
video.onplaying = test2.step_func(function(e) {
try {
assert_equals(t1.activeCues, t1_cues, "t1.activeCues should return the same object after playing a video");
assert_equals(t1.activeCues.length, 1, "t1.activeCues.length after the video has started playing");
} catch(ex) {
test2.step(function() { throw ex; });
test3.step(function() { assert_unreached(); });
return;
}
test3.step(function(){
var c3 = new VTTCue(0, 2, "text3");
t1.addCue(c3);
assert_equals(t1.activeCues.length, 1, "t1.activeCues.length after adding a cue in the same script");
setTimeout(test3.step_func(function(){
assert_equals(t1.activeCues.length, 2, "t1.activeCues.length after the event loop has spun");
test3.done();
}, 0));
});
test2.done();
});
try {
assert_equals(t1.activeCues, t1_cues, "t1.activeCues should return the same object after loading a video");
assert_equals(t2.activeCues, t2_cues, "t2.activeCues should return the same object after loading a video");
assert_equals(t1.activeCues.length, 0, "t1.activeCues.length before the video has started playing");
assert_equals(t2.activeCues.length, 0, "t1.activeCues.length before the video has started playing");
} catch(ex) {
test1.step(function() { throw ex; });
test2.step(function() { assert_unreached(); });
test3.step(function() { assert_unreached(); });
return;
}
video.play();
test1.done();
});
video.src = getVideoURI("/media/movie_5");
});
</script>

View file

@ -0,0 +1,68 @@
<!doctype html>
<title>TextTrack.addCue()</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
setup(function(){
window.video = document.createElement('video');
document.body.appendChild(video);
}, {timeout:5000});
test(function() {
var t1 = video.addTextTrack('subtitles');
var t2 = video.addTextTrack('subtitles');
var c1 = new VTTCue(0, 1, 'text1');
t1.addCue(c1);
t2.addCue(c1);
assert_equals(c1.track, t2);
}, document.title+', adding a cue to two different tracks');
test(function() {
var t1 = video.addTextTrack('subtitles');
var c1 = new VTTCue(0, 1, 'text1');
t1.addCue(c1);
assert_equals(c1.track, t1);
t1.addCue(c1);
assert_equals(c1.track, t1);
}, document.title+', adding a cue to a track twice');
test(function() {
var t1 = video.addTextTrack('subtitles');
var t2 = video.addTextTrack('subtitles');
var c1 = new VTTCue(0, 1, 'text1');
t1.addCue(c1);
assert_equals(c1.track, t1);
t1.removeCue(c1);
assert_equals(c1.track, null);
t2.addCue(c1);
assert_equals(c1.track, t2);
}, document.title+', adding a removed cue to a different track');
test(function() {
var t1 = video.addTextTrack('subtitles');
var c1 = new VTTCue(0, 1, 'text1');
t1.addCue(c1);
assert_equals(t1.cues.length, 1, 't1.cues.length after first addition');
t1.removeCue(c1);
assert_equals(t1.cues.length, 0, 't1.cues.length after removal');
t1.addCue(c1);
assert_equals(t1.cues.length, 1, 't1.cues.length after second addition');
}, document.title+', adding an associated but removed cue to the same track');
var t = async_test(document.title+', adding a cue associated with a track element to other track');
t.step(function(){
var t1 = video.addTextTrack('subtitles');
var track = document.createElement('track');
track.onload = t.step_func(function(){
var cue = track.track.cues[0];
track.track.removeCue(cue);
t1.addCue(cue);
assert_equals(cue.track, t1);
t.done();
});
track.onerror = t.step_func(function() {
assert_unreached('got error event');
});
track.src= 'data:text/vtt,'+encodeURIComponent('WEBVTT\n\n00:00:00.000 --> 00:00:01.000\ntest\n');
track.kind = 'subtitles';
track.track.mode = 'hidden';
video.appendChild(track);
});
</script>

View file

@ -0,0 +1,23 @@
<!doctype html>
<title>TextTrack constants</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
setup(function(){
window.video = document.createElement('video');
window.t1 = video.addTextTrack('subtitles');
});
test(function(){
assert_equals(t1.DISABLED, undefined, "t1.DISABLED");
assert_equals(t1.HIDDEN, undefined, "t1.HIDDEN");
assert_equals(t1.SHOWING, undefined, "t1.SHOWING");
assert_equals(TextTrack.prototype.DISABLED, undefined, "TextTrack.prototype.DISABLED");
assert_equals(TextTrack.prototype.HIDDEN, undefined, "TextTrack.prototype.HIDDEN");
assert_equals(TextTrack.prototype.SHOWING, undefined, "TextTrack.prototype.SHOWING");
assert_equals(TextTrack.DISABLED, undefined, "TextTrack.DISABLED");
assert_equals(TextTrack.HIDDEN, undefined, "TextTrack.HIDDEN");
assert_equals(TextTrack.SHOWING, undefined, "TextTrack.SHOWING");
});
</script>

View file

@ -0,0 +1,100 @@
<!doctype html>
<title>TextTrack.cues</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
test(function(){
var video = document.createElement('video');
var t1 = video.addTextTrack('subtitles');
assert_equals(t1.cues, t1.cues, 't1.cues should return same object');
assert_not_equals(t1.cues, null, 't1.cues should not be null');
assert_true(t1.cues instanceof TextTrackCueList, 't1.cues instanceof TextTrackCueList');
assert_equals(t1.cues.length, 0, 't1.cues.length');
}, document.title+', empty list');
function addCue(texttrack, start, end, text, id) {
var c = new VTTCue(start, end, text);
c.id = id;
texttrack.addCue(c);
return c;
}
test(function(){
var video = document.createElement('video');
var t1 = video.addTextTrack('subtitles');
var t1_cues = t1.cues;
var c = addCue(t1, 0, 1, 'text', 'id');
assert_equals(t1.cues, t1_cues, "t1.cues should return same object");
assert_equals(t1.cues.length, 1, "t1.cues.length");
var c2 = addCue(t1, 1, 2, 'text2', 'id2');
assert_equals(t1.cues, t1_cues, "t1.cues should return the same object after adding a second cue");
assert_equals(t1.cues.length, 2, "t1.cues.length after adding a second cue");
assert_equals(t1.cues[0].id, "id");
assert_equals(t1.cues[1].id, "id2");
}, document.title+', after addCue()');
test(function(){
var video = document.createElement('video');
var t1 = video.addTextTrack('subtitles');
var t1_cues = t1.cues;
var c = addCue(t1, 0, 1, 'text', 'id');
var c2 = addCue(t1, 1, 2, 'text2', 'id2');
t1.mode = 'showing';
assert_equals(t1.cues, t1_cues, "t1.cues should return the same object after setting mode to 'showing'");
t1.mode = 'hidden';
assert_equals(t1.cues, t1_cues, "t1.cues should return the same object after setting mode to 'hidden'");
t1.mode = 'disabled';
assert_equals(t1.cues, null, "t1.cues should be null when mode is 'disabled'");
assert_equals(t1_cues.length, 2, "t1_cues should still be intact after setting mode to 'disabled'");
assert_equals(t1_cues[0].id, "id", "t1_cues first cue should still be intact after setting mode to 'disabled'");
assert_equals(t1_cues[1].id, "id2", "t1_cues second cue should still be intact after setting mode to 'disabled'");
t1.mode = 'hidden';
assert_equals(t1.cues, t1_cues, "t1.cues should return the same object after setting mode to 'disabled' and then 'hidden'");
t1.mode = 'disabled';
assert_equals(t1.cues, null, "t1.cues should be null when mode is set to 'disabled' again");
assert_equals(t1_cues.length, 2, "t1_cues should still be intact after setting mode to 'disabled' again");
assert_equals(t1_cues[0].id, "id", "t1_cues first cue should still be intact after setting mode to 'disabled' again");
assert_equals(t1_cues[1].id, "id2", "t1_cues second cue should still be intact after setting mode to 'disabled' again");
t1.mode = 'showing';
assert_equals(t1.cues, t1_cues, "t1.cues should return the same object after setting mode to 'disabled' and then 'showing'");
}, document.title+', different modes');
test(function(){
var video = document.createElement('video');
var t1 = video.addTextTrack('subtitles');
var t1_cues = t1.cues;
var c = addCue(t1, 0, 1, 'text', 'id');
var c2 = addCue(t1, 1, 2, 'text2', 'id2');
t1.mode = 'showing';
t1.cues[1].startTime = 0; // this should change the text track cue order
assert_equals(t1.cues[0].id, 'id2');
assert_equals(t1.cues[1].id, 'id');
t1.cues[0].startTime = 0.5; // this should change it back
assert_equals(t1.cues[0].id, 'id');
assert_equals(t1.cues[1].id, 'id2');
}, document.title+', changing order');
async_test(function(){
var video = document.createElement('video');
var t1 = video.addTextTrack('subtitles');
var t1_cues = t1.cues;
t1.mode = 'showing';
var track = document.createElement('track');
track['default'] = true;
video.appendChild(track); // queues a task to "honor user preferences...", media element event task source
var t2 = track.track;
assert_equals(t2.cues, null, 't2.cues should be null');
// We need to wait until the "honor user preferences..." steps have run so we invoke play()
// which queues an event with the same task source.
video.onplay = this.step_func(function(){
assert_equals(t2.cues, t2.cues, 't2.cues should return same object');
assert_not_equals(t1.cues, t2.cues, 't1.cues and t2.cues should be different objects');
assert_not_equals(t2.cues, null, 't2.cues should not be null');
assert_true(t2.cues instanceof TextTrackCueList, 't2.cues instanceof TextTrackCueList');
assert_equals(t2.cues.length, 0, 't2.cues should have length 0');
this.done();
});
video.play(); // queues a task to fire 'play', media element event task source
}, document.title+', default attribute');
</script>

View file

@ -0,0 +1,31 @@
<!doctype html>
<title>TextTrack.kind</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
test(function(){
var video = document.createElement('video');
var t1 = video.addTextTrack('subtitles');
var t2 = video.addTextTrack('captions');
var t3 = video.addTextTrack('descriptions');
var t4 = video.addTextTrack('chapters');
var t5 = video.addTextTrack('metadata');
assert_equals(t1.kind, 'subtitles');
assert_equals(t2.kind, 'captions');
assert_equals(t3.kind, 'descriptions');
assert_equals(t4.kind, 'chapters');
assert_equals(t5.kind, 'metadata');
}, document.title+', addTextTrack');
test(function(){
var track = document.createElement('track');
track.setAttribute('kind', 'CAPTIONS');
var t = track.track;
assert_equals(t.kind, 'captions');
}, document.title+', track element');
test(function(){
var track = document.createElement('track');
track.kind = 'captions\u0000';
assert_equals(track.track.kind, 'subtitles');
}, document.title+', \\u0000');
</script>

View file

@ -0,0 +1,29 @@
<!doctype html>
<title>TextTrack.label</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
setup(function(){
window.video = document.createElement('video');
window.t1 = video.addTextTrack('subtitles', 'foo');
window.track = document.createElement('track');
track.setAttribute('label', 'bar');
video.appendChild(track);
window.t2 = track.track;
});
test(function(){
assert_equals(t1.label, 'foo');
assert_equals(t2.label, 'bar');
track.label = 'baz';
assert_equals(t2.label, 'baz');
track.removeAttribute('label');
assert_equals(t2.label, '');
});
test(function(){
track.label = '\u0000a';
assert_equals(t2.label, '\u0000a');
track.setAttribute('label', '\u0000b', 'IDL attribute');
assert_equals(t2.label, '\u0000b', 'content attribute');
}, document.title+', \\u0000');
</script>

View file

@ -0,0 +1,29 @@
<!doctype html>
<title>TextTrack.language</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
setup(function(){
window.video = document.createElement('video');
window.t1 = video.addTextTrack('subtitles', 'foo', 'foo');
window.track = document.createElement('track');
track.setAttribute('srclang', 'bar');
video.appendChild(track);
window.t2 = track.track;
});
test(function(){
assert_equals(t1.language, 'foo');
assert_equals(t2.language, 'bar');
track.srclang = 'baz';
assert_equals(t2.language, 'baz');
track.removeAttribute('srclang');
assert_equals(t2.language, '');
});
test(function(){
track.srclang = '\u0000a';
assert_equals(t2.language, '\u0000a', 'IDL attribute');
track.setAttribute('srclang', '\u0000b');
assert_equals(t2.language, '\u0000b', 'content attribute');
}, document.title+', \\u0000');
</script>

View file

@ -0,0 +1,55 @@
<!doctype html>
<title>TextTrack.mode</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
test(function(){
var track = document.createElement('track');
assert_equals(track.track.mode, 'disabled', 'initial');
track.track.mode = 1;
assert_equals(track.track.mode, 'disabled', '1');
track.track.mode = '';
assert_equals(track.track.mode, 'disabled', '""');
track.track.mode = null;
assert_equals(track.track.mode, 'disabled', 'null');
track.track.mode = undefined;
assert_equals(track.track.mode, 'disabled', 'undefined');
track.track.mode = 'showing';
assert_equals(track.track.mode, 'showing', 'showing (correct value)');
track.track.mode = 'DISABLED';
assert_equals(track.track.mode, 'showing', '"DISABLED"');
track.track.mode = 'd\u0130sabled'; // dotted uppercase i
assert_equals(track.track.mode, 'showing', '"d\u0130sabled" (dotted uppercase i)');
track.track.mode = 'd\u0131sabled'; // dotless lowercase i
assert_equals(track.track.mode, 'showing', '"d\u0131sabled" (dotless lowercase i)');
track.track.mode = 'disabled ';
assert_equals(track.track.mode, 'showing', '"disabled "');
track.track.mode = ' disabled';
assert_equals(track.track.mode, 'showing', '" disabled"');
track.track.mode = {};
assert_equals(track.track.mode, 'showing', '{}');
track.track.mode = 'HIDDEN';
assert_equals(track.track.mode, 'showing', '"HIDDEN"');
track.track.mode = 'h\u0130dden'; // dotted uppercase i
assert_equals(track.track.mode, 'showing', '"h\u0130dden" (dotted uppercase i)');
track.track.mode = 'h\u0131dden'; // dotless lowercase i
assert_equals(track.track.mode, 'showing', '"h\u0131dden" (dotless lowercase i)');
}, document.title+', wrong value');
test(function() {
var track = document.createElement('track');
assert_equals(track.track.mode, 'disabled', 'initial');
track.track.mode = 'disabled'; // no-op
assert_equals(track.track.mode, 'disabled', 'disabled (1)');
track.track.mode = 'hidden';
assert_equals(track.track.mode, 'hidden', 'hidden (1)');
track.track.mode = 'hidden'; // no-op
assert_equals(track.track.mode, 'hidden', 'hidden (2)');
track.track.mode = 'showing';
assert_equals(track.track.mode, 'showing', 'showing (1)');
track.track.mode = 'showing'; // no-op
assert_equals(track.track.mode, 'showing', 'showing (2)');
track.track.mode = {toString:function() { return 'disabled'; }};
assert_equals(track.track.mode, 'disabled', '{toString:...}');
}, document.title+', correct value');
</script>

View file

@ -0,0 +1,33 @@
<!doctype html>
<title>TextTrack.oncuechange</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
setup(function(){
window.video = document.createElement('video');
window.t1 = video.addTextTrack('subtitles');
window.ev = new Event('cuechange');
window.ran = false;
window.cb = function() { ran = true; };
});
test(function(){
assert_equals(t1.oncuechange, null);
t1.oncuechange = cb;
t1.dispatchEvent(ev);
assert_true(ran);
t1.oncuechange = null;
ran = false;
t1.dispatchEvent(ev);
assert_false(ran);
});
test(function(){
t1.addEventListener('cuechange', cb, false);
t1.dispatchEvent(ev);
assert_true(ran);
t1.removeEventListener('cuechange', cb, false);
ran = false;
t1.dispatchEvent(ev);
assert_false(ran);
}, 'TextTrack.addEventListener/removeEventListener');
</script>

View file

@ -0,0 +1,50 @@
<!doctype html>
<title>TextTrack.removeCue()</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
setup(function(){
window.video = document.createElement('video');
document.body.appendChild(video);
}, {timeout:5000});
test(function() {
var t1 = video.addTextTrack('subtitles');
var t2 = video.addTextTrack('subtitles');
var c1 = new VTTCue(0, 1, 'text1');
assert_throws("NOT_FOUND_ERR", function() {
t1.removeCue(c1);
}, 'standalone');
t1.addCue(c1);
assert_throws("NOT_FOUND_ERR", function() {
t2.removeCue(c1);
}, 'listed in t1, remove from t2');
t1.removeCue(c1);
assert_throws("NOT_FOUND_ERR", function() {
t1.removeCue(c1);
}, 'standalone, remove from t1');
assert_throws("NOT_FOUND_ERR", function() {
t2.removeCue(c1);
}, 'standalone, remove from t2');
}, document.title+', two elementless tracks');
var t = async_test(document.title+', cue from track element');
t.step(function(){
var t1 = video.addTextTrack('subtitles');
var track = document.createElement('track');
track.onload = t.step_func(function(){
var cue = track.track.cues[0];
assert_throws('NOT_FOUND_ERR', function() { t1.removeCue(cue); }, 'listed in track.track, remove from t1');
track.track.removeCue(cue);
assert_throws('NOT_FOUND_ERR', function() { track.track.removeCue(cue); }, 'standalone, remove from track.track');
assert_throws('NOT_FOUND_ERR', function() { t1.removeCue(cue); }, 'standalone, remove from t1');
t.done();
});
track.onerror = t.step_func(function() {
assert_unreached('got error event');
});
track.src= 'data:text/vtt,'+encodeURIComponent('WEBVTT\n\n00:00:00.000 --> 00:00:01.000\ntest\n');
track.kind = 'subtitles';
track.track.mode = 'hidden';
video.appendChild(track);
});
</script>

View file

@ -0,0 +1,39 @@
<!doctype html>
<title>TextTrackCue.endTime</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
setup(function(){
window.video = document.createElement('video');
window.t1 = video.addTextTrack('subtitles');
document.body.appendChild(video);
});
test(function(){
var c1 = new VTTCue(-2, -1, 'text1');
assert_equals(c1.endTime, -1);
c1.endTime = c1.endTime;
assert_equals(c1.endTime, -1);
assert_throws(new TypeError(), function(){ c1.endTime = NaN; });
assert_throws(new TypeError(), function(){ c1.endTime = +Infinity; });
assert_throws(new TypeError(), function(){ c1.endTime = -Infinity; });
}, document.title+', script-created cue');
var t_parsed = async_test(document.title+', parsed cue');
t_parsed.step(function(){
var t = document.createElement('track');
t.onload = this.step_func(function(){
var c = t.track.cues;
assert_equals(c[0].endTime, 0.001);
assert_equals(c[1].endTime, 3600.001);
this.done();
});
t.onerror = this.step_func(function() {
assert_unreached('got error event');
});
t.src = 'data:text/vtt,'+encodeURIComponent('WEBVTT\n\n00:00:00.000 --> 00:00:00.001\ntest'+
'\n\nfoobar\n01:00:00.000 --> 01:00:00.001\ntest');
t.track.mode = 'showing';
video.appendChild(t);
});
</script>

View file

@ -0,0 +1,39 @@
<!doctype html>
<title>TextTrackCue.id</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
setup(function(){
window.video = document.createElement('video');
window.t1 = video.addTextTrack('subtitles');
document.body.appendChild(video);
});
test(function(){
var c1 = new VTTCue(0, 1, 'text1');
c1.id = 'id1\r\n\u0000';
assert_equals(c1.id, 'id1\r\n\u0000');
c1.id = c1.id;
assert_equals(c1.id, 'id1\r\n\u0000');
c1.id = null;
assert_equals(c1.id, 'null');
}, document.title+', script-created cue');
var t_parsed = async_test(document.title+', parsed cue');
t_parsed.step(function(){
var t = document.createElement('track');
t.onload = this.step_func(function(){
var c = t.track.cues;
assert_equals(c[0].id, '');
assert_equals(c[1].id, 'foobar');
this.done();
});
t.onerror = this.step_func(function() {
assert_unreached('got error event');
});
t.src = 'data:text/vtt,'+encodeURIComponent('WEBVTT\n\n00:00:00.000 --> 00:00:00.001\ntest'+
'\n\nfoobar\n00:00:00.000 --> 00:00:00.001\ntest');
t.track.mode = 'showing';
video.appendChild(t);
});
</script>

View file

@ -0,0 +1,36 @@
<!doctype html>
<title>TextTrackCue.onenter</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
setup(function(){
window.c1 = new VTTCue(0, 1, 'text1');
window.ev = new Event('enter');
window.ran = false;
window.cb = function() { ran = true; };
});
test(function(){
assert_equals(c1.onenter, null, 'initial value');
c1.onenter = undefined;
assert_equals(c1.onenter, null, 'assigning undefined');
c1.onenter = cb;
assert_equals(c1.onenter, cb, 'assigning onenter');
c1.dispatchEvent(ev);
assert_true(ran, 'dispatching event');
c1.onenter = null;
assert_equals(c1.onenter, null, 'assigning null');
ran = false;
c1.dispatchEvent(ev);
assert_false(ran, 'dispatching event after nulling onenter');
});
test(function(){
c1.addEventListener('enter', cb, false);
c1.dispatchEvent(ev);
assert_true(ran);
c1.removeEventListener('enter', cb, false);
ran = false;
c1.dispatchEvent(ev);
assert_false(ran);
}, 'TextTrackCue.addEventListener/removeEventListener');
</script>

View file

@ -0,0 +1,36 @@
<!doctype html>
<title>TextTrackCue.onexit</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
setup(function(){
window.c1 = new VTTCue(0, 1, 'text1');
window.ev = new Event('exit');
window.ran = false;
window.cb = function() { ran = true; };
});
test(function(){
assert_equals(c1.onexit, null, 'initial value');
c1.onexit = undefined;
assert_equals(c1.onexit, null, 'assigning undefined');
c1.onexit = cb;
assert_equals(c1.onexit, cb, 'assigning onexit');
c1.dispatchEvent(ev);
assert_true(ran, 'dispatching event');
c1.onexit = null;
assert_equals(c1.onexit, null, 'assigning null');
ran = false;
c1.dispatchEvent(ev);
assert_false(ran, 'dispatching event after nulling onexit');
});
test(function(){
c1.addEventListener('exit', cb, false);
c1.dispatchEvent(ev);
assert_true(ran);
c1.removeEventListener('exit', cb, false);
ran = false;
c1.dispatchEvent(ev);
assert_false(ran);
}, 'TextTrackCue.addEventListener/removeEventListener');
</script>

View file

@ -0,0 +1,40 @@
<!doctype html>
<title>TextTrackCue.pauseOnExit</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
setup(function(){
window.video = document.createElement('video');
window.t1 = video.addTextTrack('subtitles');
document.body.appendChild(video);
});
test(function(){
var c1 = new VTTCue(0, 1, 'text1');
assert_equals(c1.pauseOnExit, false);
c1.pauseOnExit = null;
assert_equals(c1.pauseOnExit, false);
c1.pauseOnExit = 'foo';
assert_equals(c1.pauseOnExit, true);
}, document.title+', script-created cue');
var t_parsed = async_test(document.title+', parsed cue');
t_parsed.step(function(){
var t = document.createElement('track');
t.onload = this.step_func(function(){
var c1 = t.track.cues[0];
assert_equals(c1.pauseOnExit, false);
c1.pauseOnExit = null;
assert_equals(c1.pauseOnExit, false);
c1.pauseOnExit = 'foo';
assert_equals(c1.pauseOnExit, true);
this.done();
});
t.onerror = this.step_func(function() {
assert_unreached('got error event');
});
t.src = 'data:text/vtt,'+encodeURIComponent('WEBVTT\n\n00:00:00.000 --> 00:00:00.001\ntest');
t.track.mode = 'showing';
video.appendChild(t);
});
</script>

View file

@ -0,0 +1,39 @@
<!doctype html>
<title>TextTrackCue.startTime</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
setup(function(){
window.video = document.createElement('video');
window.t1 = video.addTextTrack('subtitles');
document.body.appendChild(video);
});
test(function(){
var c1 = new VTTCue(-1, 1, 'text1');
assert_equals(c1.startTime, -1);
c1.startTime = c1.startTime;
assert_equals(c1.startTime, -1);
assert_throws(new TypeError(), function(){ c1.startTime = NaN; });
assert_throws(new TypeError(), function(){ c1.startTime = +Infinity; });
assert_throws(new TypeError(), function(){ c1.startTime = -Infinity; });
}, document.title+', script-created cue');
var t_parsed = async_test(document.title+', parsed cue');
t_parsed.step(function(){
var t = document.createElement('track');
t.onload = this.step_func(function(){
var c = t.track.cues;
assert_equals(c[0].startTime, 0);
assert_equals(c[1].startTime, 3600);
this.done();
});
t.onerror = this.step_func(function() {
assert_unreached('got error event');
});
t.src = 'data:text/vtt,'+encodeURIComponent('WEBVTT\n\n00:00:00.000 --> 00:00:00.001\ntest'+
'\n\nfoobar\n01:00:00.000 --> 01:00:00.001\ntest');
t.track.mode = 'showing';
video.appendChild(t);
});
</script>

View file

@ -0,0 +1,38 @@
<!doctype html>
<title>TextTrackCue.track</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
setup(function(){
window.video = document.createElement('video');
window.t1 = video.addTextTrack('subtitles');
document.body.appendChild(video);
});
test(function(){
var c1 = new VTTCue(0, 1, 'text1');
assert_equals(c1.track, null);
t1.addCue(c1);
assert_equals(c1.track, t1);
t1.removeCue(c1);
assert_equals(c1.track, null);
}, document.title+', script-created cue');
var t_parsed = async_test(document.title+', parsed cue');
t_parsed.step(function(){
var t = document.createElement('track');
t.onload = this.step_func(function(){
var c = t.track.cues[0];
assert_equals(c.track, t.track);
t.track.removeCue(c);
assert_equals(c.track, null);
this.done();
});
t.onerror = this.step_func(function() {
assert_unreached('got error event');
});
t.src = 'data:text/vtt,'+encodeURIComponent('WEBVTT\n\n00:00:00.000 --> 00:00:00.001\ntest');
t.track.mode = 'showing';
video.appendChild(t);
});
</script>

View file

@ -0,0 +1,53 @@
<!doctype html>
<title>TextTrackCueList.getCueById</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
test(function(){
var video = document.createElement('video');
var t = video.addTextTrack('subtitles');
document.body.appendChild(video);
var cues = t.cues;
var c = new VTTCue(0, 1, 'text1');
t.addCue(c);
assert_equals(cues.getCueById(""), null, '""');
assert_equals(cues.getCueById(null), null, 'null');
assert_equals(cues.getCueById(undefined), null, 'undefined');
}, document.title+ ', no id');
test(function(){
var video = document.createElement('video');
var t = video.addTextTrack('subtitles');
document.body.appendChild(video);
var cues = t.cues;
var c = new VTTCue(0, 1, 'text1');
c.id = 'foo';
t.addCue(c);
assert_equals(cues.getCueById(""), null, '""');
assert_equals(cues.getCueById("foo"), c, '"foo"');
assert_equals(cues.getCueById({toString:function(){return "foo"}}), c, 'object');
}, document.title+ ', id foo');
test(function(){
var video = document.createElement('video');
var t = video.addTextTrack('subtitles');
document.body.appendChild(video);
var cues = t.cues;
var c = new VTTCue(0, 1, 'text1');
c.id = '1';
t.addCue(c);
assert_equals(cues.getCueById(""), null, '""');
assert_equals(cues.getCueById("1"), c, '"1"');
assert_equals(cues.getCueById(1), c, '1');
}, document.title+ ', no 1');
test(function(){
var video = document.createElement('video');
var t = video.addTextTrack('subtitles');
document.body.appendChild(video);
var cues = t.cues;
var c = new VTTCue(0, 1, 'text1');
c.id = 'a\u0000b';
t.addCue(c);
assert_equals(cues.getCueById("a\u0000b"), c, '"a\\u0000b"');
assert_equals(cues.getCueById("a"), null, '"a"');
}, document.title+ ', id a\\u0000b');
</script>

View file

@ -0,0 +1,49 @@
<!doctype html>
<title>TextTrackCueList getter</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
setup(function(){
window.video = document.createElement('video');
window.t1 = video.addTextTrack('subtitles');
document.body.appendChild(video);
});
test(function(){
var cues = t1.cues;
assert_equals(cues[0], undefined, 'cues[0] before');
var c1 = new VTTCue(0, 1, 'text1');
t1.addCue(c1);
assert_equals(cues[0], c1, 'cues[0]');
assert_equals(cues[1], undefined, 'cues[1]');
assert_equals(cues[-1], undefined, 'cues[-1]');
t1.removeCue(c1);
assert_equals(cues[0], undefined, 'cues[0] after');
});
test(function(){
var cues = t1.cues;
assert_equals(cues[0], undefined);
cues[0] = 'foo';
assert_equals(cues[0], undefined);
var c1 = new VTTCue(0, 1, 'text1');
t1.addCue(c1);
assert_equals(cues[0], c1);
cues[0] = 'foo';
assert_equals(cues[0], c1);
t1.removeCue(c1);
}, document.title+', no indexed set/create');
test(function(){
'use strict';
var cues = t1.cues;
assert_equals(cues[0], undefined);
assert_throws(new TypeError(), function() { cues[0] = 'foo'; });
assert_equals(cues[0], undefined);
var c1 = new VTTCue(0, 1, 'text1');
t1.addCue(c1);
assert_equals(cues[0], c1);
assert_throws(new TypeError(), function() { cues[0] = 'foo'; });
assert_equals(cues[0], c1);
t1.removeCue(c1);
}, document.title+', no indexed set/create (strict)');
</script>

View file

@ -0,0 +1,22 @@
<!doctype html>
<title>TextTrackCueList.length</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
setup(function(){
window.video = document.createElement('video');
window.t1 = video.addTextTrack('subtitles');
document.body.appendChild(video);
});
test(function(){
var cues = t1.cues;
assert_equals(cues.length, 0);
var c1 = new VTTCue(0, 1, 'text1');
t1.addCue(c1);
assert_equals(cues.length, 1);
t1.removeCue(c1);
assert_equals(cues.length, 0);
});
</script>

View file

@ -0,0 +1,16 @@
<!doctype html>
<title>TextTrackList.getTrackById</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
test(function(){
var video = document.createElement('video');
var track1 = video.addTextTrack('subtitles');
var track2 = video.addTextTrack('subtitles');
assert_equals(track1.id, '');
assert_equals(track2.id, '');
assert_equals(video.textTracks.getTrackById(''), track1);
assert_equals(video.textTracks.getTrackById('fake-id'), null);
});
</script>

View file

@ -0,0 +1,32 @@
<!doctype html>
<title>TextTrackList getter</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
setup(function(){
window.video = document.createElement('video');
video.addTextTrack('subtitles', 'b');
window.track = document.createElement('track');
track.label = 'a';
video.appendChild(track);
video.addTextTrack('subtitles', 'c');
});
test(function(){
assert_equals(video.textTracks[0].label, 'a');
assert_equals(video.textTracks[1].label, 'b');
assert_equals(video.textTracks[2].label, 'c');
});
test(function(){
var track_before = video.textTracks[0];
video.textTracks[0] = 'foo';
assert_equals(video.textTracks[0], track_before);
}, document.title+', no indexed set/create');
test(function(){
'use strict';
var track_before = video.textTracks[0];
assert_throws(new TypeError(), function(){ video.textTracks[0] = 'foo'; });
assert_equals(video.textTracks[0], track_before);
}, document.title+', no indexed set/create (strict)');
</script>

View file

@ -0,0 +1,18 @@
<!doctype html>
<title>TextTrackList.length</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
setup(function(){
window.video = document.createElement('video');
video.addTextTrack('subtitles');
window.track = document.createElement('track');
video.appendChild(track);
video.addTextTrack('subtitles');
});
test(function(){
assert_equals(video.textTracks.length, 3);
});
</script>

View file

@ -0,0 +1,33 @@
<!doctype html>
<title>TextTrackList.onaddtrack</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
setup(function(){
window.tracks = document.createElement('video').textTracks;
window.ev = new Event('addtrack');
window.ran = false;
window.cb = function() { ran = true; };
});
test(function(){
assert_equals(tracks.onaddtrack, null);
tracks.onaddtrack = cb;
assert_equals(tracks.onaddtrack, cb);
tracks.dispatchEvent(ev);
assert_true(ran);
tracks.onaddtrack = null;
ran = false;
tracks.dispatchEvent(ev);
assert_false(ran);
});
test(function(){
tracks.addEventListener('addtrack', cb, false);
tracks.dispatchEvent(ev);
assert_true(ran);
tracks.removeEventListener('addtrack', cb, false);
ran = false;
tracks.dispatchEvent(ev);
assert_false(ran);
}, 'TextTrackList.addEventListener/removeEventListener');
</script>

View file

@ -0,0 +1,33 @@
<!doctype html>
<title>TextTrackList.onremovetrack</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
setup(function(){
window.tracks = document.createElement('video').textTracks;
window.ev = new Event('removetrack');
window.ran = false;
window.cb = function() { ran = true; };
});
test(function(){
assert_equals(tracks.onremovetrack, null);
tracks.onremovetrack = cb;
assert_equals(tracks.onremovetrack, cb);
tracks.dispatchEvent(ev);
assert_true(ran);
tracks.onremovetrack = null;
ran = false;
tracks.dispatchEvent(ev);
assert_false(ran);
});
test(function(){
tracks.addEventListener('removetrack', cb, false);
tracks.dispatchEvent(ev);
assert_true(ran);
tracks.removeEventListener('removetrack', cb, false);
ran = false;
tracks.dispatchEvent(ev);
assert_false(ran);
}, 'TextTrackList.addEventListener/removeEventListener');
</script>

View file

@ -0,0 +1,24 @@
<!doctype html>
<title>TrackEvent constructor</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
test(function(){
var ev = new TrackEvent('foo');
assert_true(ev instanceof TrackEvent, 'ev instanceof TrackEvent');
assert_true(ev instanceof Event, 'ev instanceof Event');
assert_equals(ev.track, null, 'ev.track');
ev.track = {};
assert_equals(ev.track, null, 'ev.track after assignment');
}, document.title+', one arg');
test(function(){
var obj = {};
var ev = new TrackEvent('foo', {track:obj});
assert_true(ev instanceof TrackEvent, 'ev instanceof TrackEvent');
assert_true(ev instanceof Event, 'ev instanceof Event');
assert_equals(ev.track, obj, 'ev.track');
ev.track = {};
assert_equals(ev.track, obj, 'ev.track after assignment');
}, document.title+', two args');
</script>

View file

@ -0,0 +1,15 @@
<!doctype html>
<title>TrackEvent created with createEvent</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
test(function(){
// https://www.w3.org/Bugs/Public/show_bug.cgi?id=17268
assert_throws('NOT_SUPPORTED_ERR', function() {
var ev = document.createEvent('TrackEvent');
});
var ev = new TrackEvent('foo');
assert_false('initTrackEvent' in ev, 'initTrackEvent');
});
</script>

View file

@ -0,0 +1,28 @@
<!DOCTYPE HTML>
<title>autoplay overrides preload</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/media.js"></script>
<div id=log></div>
<script>
['none', 'metadata'].forEach(function(preload) {
['first', 'last'].forEach(function(order) {
async_test(function(t) {
var a = document.createElement('audio');
a.src = getAudioURI('/media/sound_5');
if (order == 'first') {
a.autoplay = true;
a.preload = preload;
} else {
a.preload = preload;
a.autoplay = true;
}
a.addEventListener('playing', t.step_func(function() {
assert_equals(a.readyState, a.HAVE_ENOUGH_DATA);
assert_false(a.paused);
t.done();
}));
}, 'autoplay (set ' + order + ') overrides preload "' + preload + '"');
});
});
</script>

View file

@ -0,0 +1,67 @@
<!doctype html>
<title>load() fires abort/emptied events when networkState is not NETWORK_EMPTY</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/media.js"></script>
<div id=log></div>
<script>
function load_test(t, v) {
assert_not_equals(v.networkState, v.NETWORK_EMPTY);
var expected_events = [];
if (v.networkState == v.NETWORK_LOADING || v.networkState == v.NETWORK_IDLE) {
expected_events.push('abort');
}
if (v.networkState != v.NETWORK_EMPTY) {
expected_events.push('emptied');
}
var actual_events = [];
v.onabort = v.onemptied = t.step_func(function(e) {
actual_events.push(e.type);
});
v.onloadstart = t.step_func(function() {
assert_array_equals(actual_events, expected_events);
t.done();
});
v.load();
assert_array_equals(actual_events, [], 'events should be fired in queued tasks');
}
async_test(function(t) {
var v = document.createElement('video');
// suspend is fired optionally "if the user agent intends to not attempt to
// fetch the resource" or "once the entire media resource has been fetched"
v.preload = 'none';
v.src = getAudioURI('/media/sound_5');
v.onsuspend = t.step_func(function() {
v.onsuspend = null;
assert_equals(v.networkState, v.NETWORK_IDLE);
load_test(t, v);
});
}, 'NETWORK_IDLE');
async_test(function(t) {
var v = document.createElement('video');
v.src = 'resources/delayed-broken-video.py';
v.onloadstart = t.step_func(function() {
v.onloadstart = null;
assert_equals(v.networkState, v.NETWORK_LOADING);
load_test(t, v);
});
}, 'NETWORK_LOADING');
async_test(function(t) {
var v = document.createElement('video');
v.src = 'data:,';
v.onerror = t.step_func(function() {
v.onerror = null;
assert_equals(v.networkState, v.NETWORK_NO_SOURCE);
load_test(t, v);
});
assert_equals(v.networkState, v.NETWORK_NO_SOURCE);
}, 'NETWORK_NO_SOURCE');
</script>

View file

@ -0,0 +1,44 @@
<!doctype html>
<title>load() removes queued error event</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<script>
// The loadstart and error event firing tasks are queued in the synchronous
// section of the resource selection algorithm, so no tasks can come between
// them. Calling load() in the loadstart event handler removes the queued error
// event task at very latest opportunity, failing any implementation that fires
// the events in the same task.
async_test(function(t) {
var v = document.createElement('video');
var events = [];
v.onloadstart = v.onerror = t.step_func(function(e) {
events.push(e.type);
if (events.length == 1) {
v.load();
} else if (events.length == 3) {
assert_array_equals(events, ['loadstart', 'loadstart', 'error']);
t.done();
}
});
v.src = '';
}, 'video error event');
async_test(function(t) {
var v = document.createElement('video');
var s = document.createElement('source');
var events = [];
v.onloadstart = s.onerror = t.step_func(function(e) {
events.push(e.type);
if (events.length == 1) {
v.load();
} else if (events.length == 3) {
assert_array_equals(events, ['loadstart', 'loadstart', 'error']);
t.done();
}
});
v.onerror = t.step_func(function() { assert_unreached(); });
v.appendChild(s);
}, 'source error event');
</script>

View file

@ -0,0 +1,29 @@
<!doctype html>
<title>inserting another source before the candidate</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<script>
var v;
function createSource(src) {
var source = document.createElement('source');
source.src = src;
return source;
}
var t = async_test(function(t) {
v = document.createElement('video');
v.addEventListener('loadstart', t.step_func(function() {
assert_equals(v.currentSrc.substr(v.currentSrc.lastIndexOf('#')), '#a');
t.done();
}), false);
v.appendChild(createSource('#a')); // invokes resource selection
});
</script>
<!-- now resource selection algorithm will continue its sync section (the </script> tag below provides a stable state) -->
<!-- #a is candidate -->
<!-- pointer is between #a and the end of the list -->
<script>
t.step(function() {
v.insertBefore(createSource('#b'), v.firstChild); // pointer is unchanged, #a is still candidate
});
</script>

View file

@ -0,0 +1,21 @@
<!doctype html>
<title>moving the candidate source</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<script>
var s;
var t = async_test(function(t) {
var v = document.createElement('video');
s = document.createElement('source');
s.src = 'resources/delayed-broken-video.py';
s.onerror = t.step_func(function() { t.done(); });
v.appendChild(s); // invokes resource selection
onload = t.step_func(function() { assert_unreached(); });
});
</script>
<script>
t.step(function() {
document.body.appendChild(s);
});
</script>

View file

@ -0,0 +1,26 @@
<!doctype html>
<title>removing the candidate source, addEventListener</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<script>
var v;
function createSource(src) {
var source = document.createElement('source');
source.src = src;
return source;
}
var t = async_test(function(t) {
v = document.createElement('video');
v.appendChild(createSource('resources/delayed-broken-video.py')); // invokes resource selection
v.firstChild.addEventListener('error', t.step_func(function() { t.done(); }), false);
});
</script>
<!-- now resource selection algorithm will continue its sync section (the </script> tag below provides a stable state) -->
<!-- the <source> is candidate -->
<!-- pointer is between the <source> and the end of the list -->
<script>
t.step(function() {
v.removeChild(v.firstChild); // tests that we fire 'error' on it despite being removed
});
</script>

View file

@ -0,0 +1,26 @@
<!doctype html>
<title>removing the candidate source, no listener</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<script>
var v;
function createSource(src) {
var source = document.createElement('source');
source.src = src;
return source;
}
var t = async_test(function(t) {
v = document.createElement('video');
v.appendChild(createSource('resources/delayed-broken-video.py')); // invokes resource selection
});
</script>
<!-- now resource selection algorithm will continue its sync section (the </script> tag below provides a stable state) -->
<!-- the <source> is candidate -->
<!-- pointer is between the <source> and the end of the list -->
<script>
t.step(function() {
v.removeChild(v.firstChild); // just tests that we don't crash
onload = t.step_func(function() { t.done(); });
});
</script>

View file

@ -0,0 +1,26 @@
<!doctype html>
<title>removing the candidate source, onerror</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<script>
var v;
function createSource(src) {
var source = document.createElement('source');
source.src = src;
return source;
}
var t = async_test(function(t) {
v = document.createElement('video');
v.appendChild(createSource('resources/delayed-broken-video.py')); // invokes resource selection
v.firstChild.onerror = t.step_func(function() { t.done(); });
});
</script>
<!-- now resource selection algorithm will continue its sync section (the </script> tag below provides a stable state) -->
<!-- the <source> is candidate -->
<!-- pointer is between the <source> and the end of the list -->
<script>
t.step(function() {
v.removeChild(v.firstChild); // tests that we fire 'error' on it despite being removed
});
</script>

View file

@ -0,0 +1,13 @@
<!doctype html>
<title>NOT invoking resource selection with new Audio() sans src</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<script>
async_test(function(t) {
var a = new Audio();
assert_equals(a.networkState, a.NETWORK_EMPTY);
a.onloadstart = t.step_func(function() { assert_unreached(); });
window.onload = t.step_func(function() { t.done(); });
});
</script>

View file

@ -0,0 +1,12 @@
<!doctype html>
<title>invoking resource selection with new Audio(src)</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<script>
async_test(function(t) {
var a = new Audio('');
a.onloadstart = t.step_func(function() { t.done(); });
window.onload = t.step_func(function() { assert_unreached(); });
});
</script>

View file

@ -0,0 +1,32 @@
<!doctype html>
<title>await a stable state and sync event handlers</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<video></video>
<script>
var v;
var t = async_test(function(t) {
v = document.querySelector('video');
var a = document.createElement('a');
a.onclick = t.step_func(function() {
v.setAttribute('src', '#'); // invokes media load which invokes resource selection
assert_equals(v.networkState, v.NETWORK_NO_SOURCE, 'networkState in onclick handler');
});
a.click(); // sync fires click, so sets src
// now we should still await a stable state because the script hasn't
// finished, the event handler has just returned
assert_equals(v.networkState, v.NETWORK_NO_SOURCE, 'networkState after click()');
v.removeAttribute('src');
});
</script>
<script>
t.step(function() {
// now the sync section of resource selection should have run and should
// have found no src="" or <source> thus networkState being set to NETWORK_EMPTY.
// if the sync section was run when onclick returned, then networkState
// would be either NETWORK_LOADING or NETWORK_NO_SOURCE.
assert_equals(v.networkState, v.NETWORK_EMPTY, 'networkState in separate script');
t.done();
});
</script>

View file

@ -0,0 +1,22 @@
<!doctype html>
<title>NOT invoking resource selection by inserting document fragment into a document</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<script>
var v;
var t = async_test(function(t) {
v = document.createElement('video');
var fragment = document.createDocumentFragment();
fragment.appendChild(v);
assert_equals(v.networkState, v.NETWORK_EMPTY, 'networkState after fragment.appendChild(v)');
document.body.appendChild(fragment);
assert_equals(v.networkState, v.NETWORK_EMPTY, 'networkState after document.body.appendChild(fragment)');
});
</script>
<script>
t.step(function() {
assert_equals(v.networkState, v.NETWORK_EMPTY, 'networkState in separate script');
t.done();
});
</script>

View file

@ -0,0 +1,12 @@
<!doctype html>
<title>NOT invoking resource selection by inserting into a document</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<script>
test(function(t) {
var v = document.createElement('video');
document.body.appendChild(v);
assert_equals(v.networkState, v.NETWORK_EMPTY);
});
</script>

View file

@ -0,0 +1,23 @@
<!doctype html>
<title>NOT invoking resource selection by inserting into other document with src set</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<iframe hidden></iframe>
<script>
async_test(function(t) {
var v = document.createElement('video');
v.src = 'data:,';
v.onerror = t.step_func(function() {
assert_equals(v.readyState, v.HAVE_NOTHING);
assert_equals(v.networkState, v.NETWORK_NO_SOURCE);
var iframe = document.querySelector('iframe');
iframe.contentDocument.body.appendChild(v);
v.onloadstart = t.step_func(function() { assert_unreached(); });
// wait for an event after the above
var v2 = document.createElement('video');
v2.src = 'data:,';
v2.onloadstart = t.step_func(function() { t.done(); });
});
});
</script>

View file

@ -0,0 +1,19 @@
<!doctype html>
<title>NOT invoking resource selection by inserting parent into a document</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<script>
async_test(function(t) {
var v = document.createElement('video');
var div = document.createElement('div');
div.appendChild(v);
assert_equals(v.networkState, v.NETWORK_EMPTY, 'networkState after div.appendChild(v)');
document.body.appendChild(div);
assert_equals(v.networkState, v.NETWORK_EMPTY, 'networkState after document.body.appendChild(div)');
window.onload = t.step_func(function() {
assert_equals(v.networkState, v.NETWORK_EMPTY, 'networkState in window.onload');
t.done();
});
});
</script>

View file

@ -0,0 +1,14 @@
<!doctype html>
<title>NOT invoking resource selection by inserting &lt;source> in &lt;div> in &lt;video></title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<video><div></div></video>
<script>
async_test(function(t) {
var v = document.querySelector('video');
v.onloadstart = t.step_func(function() { assert_unreached(); });
v.firstChild.appendChild(document.createElement('source'));
window.onload = t.step_func(function() { t.done(); });
});
</script>

View file

@ -0,0 +1,14 @@
<!doctype html>
<title>NOT invoking resource selection by inserting &lt;source> in the wrong namespace</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<video></video>
<script>
async_test(function(t) {
var v = document.querySelector('video');
v.onloadstart = t.step_func(function() { assert_unreached(); });
v.appendChild(document.createElementNS('bogus','source'));
window.onload = t.step_func(function() { t.done(); });
});
</script>

View file

@ -0,0 +1,38 @@
<!doctype html>
<title>NOT invoking resource selection by inserting &lt;source> when networkState is not NETWORK_EMPTY</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<script>
var loadstartCount = 0;
var s1ErrorCount = 0;
var s2ErrorCount = 0;
var v;
var t = async_test(function(t) {
v = document.createElement('video');
v.onloadstart = function() { loadstartCount++; };
var s1 = document.createElement('source');
s1.src = 'resources/delayed-broken-video.py';
s1.onerror = function() { s1ErrorCount++; };
v.appendChild(s1); // invokes resource selection
assert_equals(v.networkState, v.NETWORK_NO_SOURCE, 'networkState in first script');
});
</script>
<script>
t.step(function() {
assert_equals(v.networkState, v.NETWORK_LOADING, 'networkState in second script');
assert_equals(s1ErrorCount, 0, 's1ErrorCount in second script');
var s2 = document.createElement('source');
s2.onerror = t.step_func(function() {
s2ErrorCount++;
assert_equals(s1ErrorCount, 1, 's1ErrorCount in s2.onerror');
});
v.appendChild(s2);
onload = t.step_func(function() {
assert_equals(s2ErrorCount, 1, 's2ErrorCount in window.onload');
assert_equals(loadstartCount, 1, 'loadstartCount in window.onload'); // reliable if https://www.w3.org/Bugs/Public/show_bug.cgi?id=24353 is fixed
assert_equals(v.networkState, v.NETWORK_NO_SOURCE, 'networkState in window.onload'); // See Waiting step
t.done();
});
});
</script>

View file

@ -0,0 +1,13 @@
<!doctype html>
<title>invoking resource selection by inserting &lt;source> in video not in a document</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<script>
async_test(function(t) {
var v = document.createElement('video');
v.onloadstart = t.step_func(function() { t.done(); });
v.appendChild(document.createElement('source'));
window.onload = t.step_func(function() { assert_unreached(); });
});
</script>

View file

@ -0,0 +1,14 @@
<!doctype html>
<title>invoking resource selection by inserting &lt;source></title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<video></video>
<script>
async_test(function(t) {
var v = document.querySelector('video');
v.onloadstart = t.step_func(function() { t.done(); });
v.appendChild(document.createElement('source'));
window.onload = t.step_func(function() { assert_unreached(); });
});
</script>

View file

@ -0,0 +1,20 @@
<!doctype html>
<title>invoking resource selection with load()</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<script>
var v;
var t = async_test(function(t) {
v = document.createElement('video');
assert_equals(v.networkState, v.NETWORK_EMPTY, 'networkState after creating v');
v.load();
assert_equals(v.networkState, v.NETWORK_NO_SOURCE, 'networkState after v.load()');
});
</script>
<script>
t.step(function() {
assert_equals(v.networkState, v.NETWORK_EMPTY, 'networkState in separate script');
t.done();
});
</script>

View file

@ -0,0 +1,28 @@
<!doctype html>
<title>NOT invoking resource selection with pause() when networkState is not NETWORK_EMPTY</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<video></video>
<script>
var v;
var t = async_test(function(t) {
v = document.querySelector('video');
v.src = 'data:,';
assert_equals(v.networkState, v.NETWORK_NO_SOURCE, 'networkState after setting src');
var errorCount = 0;
v.onerror = t.step_func(function() {
errorCount++;
if (errorCount == 1) {
assert_equals(v.networkState, v.NETWORK_NO_SOURCE, 'networkState in onerror');
v.pause(); // should not invoke RSA. if it does, error will be fired again.
} else {
assert_unreached();
}
});
onload = t.step_func(function() {
assert_equals(errorCount, 1, 'errorCount');
t.done();
});
});
</script>

Some files were not shown because too many files have changed in this diff Show more