2009-09-18 Alpha Lam <hclam@chromium.org>
[WebKit-https.git] / LayoutTests / media / video-src-remove.html
1 <html>
2 <body>
3     <script src=media-file.js></script>
4     <script src=video-test.js></script>
5     <div id=panel></div>
6     <script>
7         var panel = document.getElementById("panel");
8         var mediaFile = findMediaFile("video", "content/test");
9         panel.innerHTML = "<video src=" + mediaFile + " controls onloadedmetadata='loadedmetadata()'><source src=content/counting.mp4></video>";
10     </script>
11
12     <p>Test that removing valid 'src' attribute DOES NOT trigger load of &lt;source&gt; elements</p>
13
14     <script>
15         findMediaElement();
16
17         var loadCount = 0;
18         
19         function testSrc()
20         {
21             testExpected("relativeURL(video.currentSrc)", mediaFile);
22             testExpected("isNaN(video.duration)", false);
23             consoleWrite("");
24         }
25
26         function loadedmetadata()
27         {
28             consoleWrite("EVENT(loadedmetadata)");
29
30             ++loadCount;
31             if (loadCount == 1)
32             {
33                 testSrc();
34                 run("video.removeAttribute('src')");
35             }
36             else
37             {
38                 consoleWrite("<span style='color:red'>FAIL</span> : 'loadCount' fired " + loadCount + "times" );
39                 endTest();
40             }
41             consoleWrite("");
42             setTimeout(someTimeLater, 100) ;
43         }
44         
45         function someTimeLater()
46         {
47             testSrc();
48             endTest();
49             consoleWrite("");
50         }
51
52         consoleWrite("");
53     </script>
54
55 </body>
56 </html>