Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / media / video-src-change.html
blob7ad40bec30c0f98734f9945ca2c0a2aa01918991
1 <html>
2 <head>
3 <script src=video-test.js></script>
4 <script src=media-file.js></script>
5 <script>
6 var mediaFile;
7 var loadedCount = 0;
8 var errorCount = 0;
10 function errorEvent()
12 testExpected("relativeURL(video.currentSrc)", "bogus");
13 testExpected("video.networkState", HTMLMediaElement.NETWORK_NO_SOURCE);
14 testExpected("video.error.code", MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED);
15 consoleWrite("");
17 // Prevent runaway tests when unexpected errors happen.
18 if (++errorCount > 1)
19 endTest();
21 setSrcAttribure(findMediaFile("video", "content/test"));
22 consoleWrite("");
25 function loadedmetadata()
27 testExpected("stripExtension(relativeURL(video.currentSrc))", stripExtension(mediaFile));
28 testExpected("isNaN(video.duration)", false);
29 consoleWrite("");
31 if (++loadedCount >= 2) {
32 mediaElement.removeEventListener('loadedmetadata', loadedmetadata);
33 endTest();
34 return;
37 setSrcAttribure(findMediaFile("video", "content/counting"));
38 consoleWrite("");
41 function setSrcAttribure(src)
43 mediaFile = src;
44 video.setAttribute('src', src);
47 function setup()
49 findMediaElement();
50 waitForEvent('loadedmetadata', loadedmetadata);
51 waitForEvent('error', errorEvent);
52 setSrcAttribure("bogus");
53 consoleWrite("");
55 </script>
56 </head>
58 <body onload="setup()">
60 <video controls" ></video>
62 <p>
63 1. Test that an invalid src attribute fires an error when the file fails to load.<br>
64 2. Test that changing src attribute triggers load after a load fails.<br>
65 3. Test that changing src triggers load once a file is known to be valid.
66 </p>
68 </body>
69 </html>