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