OLD | NEW |
1 <html> | 1 <!DOCTYPE html> |
2 <head> | 2 <title>Test that removing "src" attribute does not trigger load of "source" elem
ents.</title> |
3 <script src=media-file.js></script> | 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 src="media-file.js"></script> |
6 <script src=video-test.js></script> | 6 <video></video> |
| 7 <script> |
| 8 async_test(function(t) { |
| 9 var video = document.querySelector("video"); |
7 | 10 |
| 11 video.onloadedmetadata = t.unreached_func(); |
| 12 video.onerror = t.step_func(function() { |
| 13 assert_equals(video.error.code, MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED); |
8 | 14 |
9 <script> | 15 setTimeout(t.step_func_done(), 200); |
10 function loadedmetadata() | 16 video.removeAttribute("src"); |
11 { | 17 }); |
12 failTest(relativeURL(video.currentSrc) + "loaded but should not"
); | |
13 consoleWrite(""); | |
14 } | |
15 | 18 |
16 function errorEvent() | 19 video.src = "bogus.mov"; |
17 { | 20 var source = document.createElement("source"); |
18 testExpected("video.error.code", MediaError.MEDIA_ERR_SRC_NOT_SU
PPORTED); | 21 source.src = findMediaFile("video", "content/test"); |
19 | 22 video.appendChild(source); |
20 // "setTimeout()" is generally bad form in a layout test, but we
need to verify | 23 }); |
21 // that changing the 'src' attribute does not do something that
happens | 24 </script> |
22 // asynchronously so we don't have a lot of options. | |
23 setTimeout(function () { endTest(); }, 200) ; | |
24 run("video.removeAttribute('src')"); | |
25 consoleWrite(""); | |
26 } | |
27 | |
28 function setup() | |
29 { | |
30 findMediaElement(); | |
31 | |
32 video.src = "bogus.mov"; | |
33 | |
34 var source = document.createElement("source"); | |
35 source.setAttribute("src", findMediaFile("video", "content/test"
)); | |
36 video.appendChild(source); | |
37 | |
38 waitForEvent('loadedmetadata', loadedmetadata); | |
39 waitForEvent('error', errorEvent); | |
40 consoleWrite(""); | |
41 } | |
42 | |
43 </script> | |
44 </head> | |
45 <body onload="setup()"> | |
46 | |
47 <video controls></video> | |
48 | |
49 <p>Test that removing 'src' attribute does NOT trigger load of <source>
; elements</p> | |
50 | |
51 <script> | |
52 | |
53 </script> | |
54 | |
55 </body> | |
56 </html> | |
OLD | NEW |