2009-09-18 Alpha Lam <hclam@chromium.org>
[WebKit-https.git] / LayoutTests / media / video-src-remove.html
index 5ce1dfd..341020d 100644 (file)
@@ -1,15 +1,56 @@
+<html>
 <body>
-<div>
-Test that removing src attribute triggers load
-</div>
-<script src=video-test.js></script>
-<video src=bogus controls>
-    <source src=content/test.mp4></source>
-</video>
-<script>
-video = media = document.getElementsByTagName('video')[0];
-waitForEvent('emptied', function () {
-    video.removeAttribute('src')
-    waitForEventTestAndEnd('begin', "relativeURL(video.currentSrc) == 'content/test.mp4'");
-});
-</script>
+    <script src=media-file.js></script>
+    <script src=video-test.js></script>
+    <div id=panel></div>
+    <script>
+        var panel = document.getElementById("panel");
+        var mediaFile = findMediaFile("video", "content/test");
+        panel.innerHTML = "<video src=" + mediaFile + " controls onloadedmetadata='loadedmetadata()'><source src=content/counting.mp4></video>";
+    </script>
+
+    <p>Test that removing valid 'src' attribute DOES NOT trigger load of &lt;source&gt; elements</p>
+
+    <script>
+        findMediaElement();
+
+        var loadCount = 0;
+        
+        function testSrc()
+        {
+            testExpected("relativeURL(video.currentSrc)", mediaFile);
+            testExpected("isNaN(video.duration)", false);
+            consoleWrite("");
+        }
+
+        function loadedmetadata()
+        {
+            consoleWrite("EVENT(loadedmetadata)");
+
+            ++loadCount;
+            if (loadCount == 1)
+            {
+                testSrc();
+                run("video.removeAttribute('src')");
+            }
+            else
+            {
+                consoleWrite("<span style='color:red'>FAIL</span> : 'loadCount' fired " + loadCount + "times" );
+                endTest();
+            }
+            consoleWrite("");
+            setTimeout(someTimeLater, 100) ;
+        }
+        
+        function someTimeLater()
+        {
+            testSrc();
+            endTest();
+            consoleWrite("");
+        }
+
+        consoleWrite("");
+    </script>
+
+</body>
+</html>