OLD | NEW |
1 <html> | 1 <html> |
2 <head> | 2 <head> |
| 3 <!-- TODO(philipj): Convert test to testharness.js. crbug.com/588956 |
| 4 (Please avoid writing new tests using video-test.js) --> |
3 <script src=video-test.js></script> | 5 <script src=video-test.js></script> |
4 <script src=media-file.js></script> | 6 <script src=media-file.js></script> |
5 <script> | 7 <script> |
6 var mediaFile; | 8 var mediaFile; |
7 var loadedCount = 0; | 9 var loadedCount = 0; |
8 var errorCount = 0; | 10 var errorCount = 0; |
9 | 11 |
10 function errorEvent() | 12 function errorEvent() |
11 { | 13 { |
12 testExpected("relativeURL(video.currentSrc)", "bogus"); | 14 testExpected("relativeURL(video.currentSrc)", "bogus"); |
13 testExpected("video.networkState", HTMLMediaElement.NETWORK_NO_S
OURCE); | 15 testExpected("video.networkState", HTMLMediaElement.NETWORK_NO_S
OURCE); |
14 testExpected("video.error.code", MediaError.MEDIA_ERR_SRC_NOT_SU
PPORTED); | 16 testExpected("video.error.code", MediaError.MEDIA_ERR_SRC_NOT_SU
PPORTED); |
15 consoleWrite(""); | 17 consoleWrite(""); |
16 | 18 |
17 // Prevent runaway tests when unexpected errors happen. | 19 // Prevent runaway tests when unexpected errors happen. |
18 if (++errorCount > 1) | 20 if (++errorCount > 1) |
19 endTest(); | 21 endTest(); |
20 | 22 |
21 setSrcAttribure(findMediaFile("video", "content/test")); | 23 setSrcAttribure(findMediaFile("video", "content/test")); |
22 consoleWrite(""); | 24 consoleWrite(""); |
23 } | 25 } |
24 | 26 |
25 function loadedmetadata() | 27 function loadedmetadata() |
26 { | 28 { |
27 testExpected("stripExtension(relativeURL(video.currentSrc))", st
ripExtension(mediaFile)); | 29 testExpected("stripExtension(relativeURL(video.currentSrc))", st
ripExtension(mediaFile)); |
28 testExpected("isNaN(video.duration)", false); | 30 testExpected("isNaN(video.duration)", false); |
29 consoleWrite(""); | 31 consoleWrite(""); |
30 | 32 |
31 if (++loadedCount >= 2) { | 33 if (++loadedCount >= 2) { |
32 mediaElement.removeEventListener('loadedmetadata', loadedmet
adata); | 34 mediaElement.removeEventListener('loadedmetadata', loadedmet
adata); |
33 endTest(); | 35 endTest(); |
34 return; | 36 return; |
35 } | 37 } |
36 | 38 |
37 setSrcAttribure(findMediaFile("video", "content/counting")); | 39 setSrcAttribure(findMediaFile("video", "content/counting")); |
38 consoleWrite(""); | 40 consoleWrite(""); |
39 } | 41 } |
40 | 42 |
41 function setSrcAttribure(src) | 43 function setSrcAttribure(src) |
42 { | 44 { |
43 mediaFile = src; | 45 mediaFile = src; |
44 video.setAttribute('src', src); | 46 video.setAttribute('src', src); |
45 } | 47 } |
46 | 48 |
47 function setup() | 49 function setup() |
48 { | 50 { |
49 findMediaElement(); | 51 findMediaElement(); |
50 waitForEvent('loadedmetadata', loadedmetadata); | 52 waitForEvent('loadedmetadata', loadedmetadata); |
51 waitForEvent('error', errorEvent); | 53 waitForEvent('error', errorEvent); |
52 setSrcAttribure("bogus"); | 54 setSrcAttribure("bogus"); |
53 consoleWrite(""); | 55 consoleWrite(""); |
54 } | 56 } |
55 </script> | 57 </script> |
56 </head> | 58 </head> |
57 | 59 |
58 <body onload="setup()"> | 60 <body onload="setup()"> |
59 | 61 |
60 <video controls" ></video> | 62 <video controls" ></video> |
61 | 63 |
62 <p> | 64 <p> |
63 1. Test that an invalid src attribute fires an error when the file fails to
load.<br> | 65 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> | 66 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. | 67 3. Test that changing src triggers load once a file is known to be valid. |
66 </p> | 68 </p> |
67 | 69 |
68 </body> | 70 </body> |
69 </html> | 71 </html> |
OLD | NEW |