1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
<!doctype html>
<html>
<head>
<title>load() and the <source> element</title>
<!-- TODO(philipj): Convert test to testharness.js. crbug.com/588956
(Please avoid writing new tests using video-test.js) -->
<script src=video-test.js></script>
<script src=media-file.js></script>
<script>
var sources = [];
var count = 0;
function canplaythrough()
{
testExpected("stripExtension(relativeURL(video.currentSrc))", relativeURL(stripExtension(sources[1])));
++count;
switch (count)
{
case 1:
consoleWrite("<br>+++ Calling load().");
video.load();
break;
case 2:
endTest();
return;
}
}
function addSource(type, name)
{
var source = document.createElement('source');
source.src = findMediaFile(type, name);
sources.push(source.src);
source.type = mimeTypeForExtension(source.src.split('.').pop());
video.appendChild(source);
}
function setup()
{
video = mediaElement = document.getElementsByTagName('video')[0];
consoleWrite("+++ Test initial networkState.");
testExpected("video.networkState", HTMLMediaElement.prototype.NETWORK_EMPTY, "==");
// Add an invalid url to the first source so we test getting an error event
// each time resource selection runs.
addSource("video", "content/bogus");
addSource("video", "content/test");
addSource("audio", "content/test");
consoleWrite("<br>+++ Add <source> elements to trigger loading, test networkState.");
testExpected("video.networkState", HTMLMediaElement.prototype.NETWORK_NO_SOURCE, "==");
waitForEvent("canplaythrough", canplaythrough);
waitForEvent("error");
}
</script>
</head>
<body onload="setup()">
<video controls width=300 ></video>
<p>Test that the resource selection algorithm is restarted when load() is called, and that all <source> elements are reconsidered.</p>
</body>
</html>
|