OLD | NEW |
1 <html> | 1 <!DOCTYPE html> |
2 <body> | 2 <title>Tests that invalid media src url does not result in crash.</title> |
3 <p>Tests that invalid media src url does not result in crash.</p> | 3 <script src="../resources/testharness.js"></script> |
4 <!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956 | 4 <script src="../resources/testharnessreport.js"></script> |
5 (Please avoid writing new tests using video-test.js) --> | 5 <script> |
6 <script src=video-test.js></script> | 6 function check_invalid_media_src(elementName) { |
7 <script> | 7 async_test(function(t) { |
8 var invalid_url = "!:/" + String.fromCharCode(0) + "%aa#aa"; | 8 var mediaElement = document.createElement(elementName); |
9 var error_count = 0; | 9 mediaElement.src = "!:/" + String.fromCharCode(0) + "%aa#aa"; |
10 | 10 |
11 function errorEvent() | 11 mediaElement.onerror = t.step_func_done(function() { |
12 { | 12 assert_equals(mediaElement.error.code, MediaError.MEDIA_ERR_SRC_NOT_
SUPPORTED); |
13 error_count++; | 13 assert_equals(mediaElement.networkState, HTMLMediaElement.NETWORK_NO
_SOURCE); |
14 if (error_count == 2) | 14 }); |
15 { | 15 }); |
16 testExpected("audio.error.code", MediaError.MEDIA_ERR_SRC_NO
T_SUPPORTED); | 16 } |
17 testExpected("video.error.code", MediaError.MEDIA_ERR_SRC_NO
T_SUPPORTED); | |
18 testExpected("audio.networkState", HTMLMediaElement.NETWORK_
NO_SOURCE); | |
19 testExpected("video.networkState", HTMLMediaElement.NETWORK_
NO_SOURCE); | |
20 endTest(); | |
21 } | |
22 } | |
23 | 17 |
24 var audio = document.createElement('audio'); | 18 check_invalid_media_src("audio"); |
25 var video = document.createElement('video'); | 19 check_invalid_media_src("video"); |
26 audio.src = invalid_url; | 20 </script> |
27 video.src = invalid_url; | |
28 audio.onerror = errorEvent; | |
29 video.onerror = errorEvent; | |
30 document.body.appendChild(audio); | |
31 document.body.appendChild(video); | |
32 </script> | |
33 </body> | |
34 </html> | |
OLD | NEW |