OLD | NEW |
---|---|
1 <!doctype html> | 1 <!DOCTYPE html> |
2 <html> | 2 <title>Test that the document's load event is delayed until a video's meta data is available.</title> |
3 <head> | 3 <script src="../resources/testharness.js"></script> |
4 <title>delay document 'load' event test</title> | 4 <script src="../resources/testharnessreport.js"></script> |
5 <style> video { border: 3px solid red; } </style> | 5 <script src="media-file.js"></script> |
6 <!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956 | 6 <body> |
fs
2016/06/27 18:46:38
Is this needed?
Srirama
2016/06/28 17:42:00
Done.
| |
7 (Please avoid writing new tests using video-test.js) --> | 7 <video id="video1"></video> |
8 <script src=video-test.js></script> | 8 <video id="video2"></video> |
9 <script src=media-file.js></script> | 9 <video id="video3"><source></source></video> |
10 <script> | 10 <script> |
11 var video; | 11 async_test(function(t) { |
12 testVideoWithNoSource(document.getElementById("video1")); | |
12 | 13 |
13 function testMovieWithNoSource(elem) | 14 var video = document.getElementById("video2"); |
14 { | 15 video.src = findMediaFile("video", "content/test"); |
15 video = elem; // Need it in a global for testExpected() to see it. | 16 testVideoWithSource(video, false); |
16 consoleWrite("<em>no 'src'.</em>"); | |
17 testExpected("video.networkState", HTMLMediaElement.prototype.NE TWORK_EMPTY, "=="); | |
18 testExpected("video.readyState", HTMLMediaElement.prototype.HAVE _NOTHING, "=="); | |
19 } | |
20 | 17 |
21 function testMovieWithSource(elem, hasLoaded, msg) | 18 var source = document.querySelector("source"); |
22 { | 19 source.src = findMediaFile("video", "content/test"); |
23 video = elem; // Need it in a global for testExpected() to see it. | 20 testVideoWithSource(document.getElementById("video3"), false); |
24 consoleWrite(msg); | |
25 if (hasLoaded) { | |
26 // The movie should have loaded at least to HAVE_CURRENT_DAT A | |
27 testExpected("video.networkState", HTMLMediaElement.prototyp e.NETWORK_NO_SOURCE, "!="); | |
28 testExpected("video.networkState", HTMLMediaElement.prototyp e.NETWORK_IDLE, ">="); | |
29 testExpected("video.readyState", HTMLMediaElement.prototype. HAVE_CURRENT_DATA, ">="); | |
30 } else { | |
31 testExpected("video.networkState", HTMLMediaElement.prototyp e.NETWORK_NO_SOURCE, "=="); | |
32 testExpected("video.readyState", HTMLMediaElement.prototype. HAVE_NOTHING, "=="); | |
33 } | |
34 } | |
35 | 21 |
36 function loaded() | 22 window.onload = t.step_func_done(function() { |
37 { | 23 testVideoWithNoSource(document.getElementById("video1")); |
38 consoleWrite("<br><b>document <em>'load'<" + "/em> event handler </b>"); | 24 testVideoWithSource(document.getElementById("video2"), true); |
25 testVideoWithSource(document.getElementById("video3"), true); | |
26 }); | |
39 | 27 |
40 testMovieWithNoSource(document.getElementById('video-1')); | 28 function testVideoWithNoSource(video) { |
41 testMovieWithSource(document.getElementById('video-2'), true, "< br><em>with 'src' attribute.</em>"); | 29 assert_equals(video.networkState, HTMLMediaElement.NETWORK_EMPTY); |
42 testMovieWithSource(document.getElementById('video-3'), true, "< br><em>with <source> element.</em>"); | 30 assert_equals(video.readyState, HTMLMediaElement.HAVE_NOTHING); |
31 } | |
43 | 32 |
44 if (window.testRunner) | 33 function testVideoWithSource(video, hasLoaded) { |
fs
2016/06/27 18:46:38
Since this only consists of two very distinct code
Srirama
2016/06/28 17:42:00
Done.
| |
45 testRunner.notifyDone(); | 34 if (hasLoaded) { |
46 } | 35 // The Video should have loaded at least to HAVE_CURRENT_DATA |
47 </script> | 36 assert_not_equals(video.networkState, HTMLMediaElement.NETWORK_NO_SO URCE); |
48 </head> | 37 assert_greater_than_equal(video.networkState, HTMLMediaElement.NETWO RK_IDLE); |
49 <body onload="loaded()"> | 38 assert_greater_than_equal(video.readyState, HTMLMediaElement.HAVE_CU RRENT_DATA); |
50 <video id="video-1"></video> | 39 } else { |
51 <video id="video-2"></video> | 40 assert_equals(video.networkState, HTMLMediaElement.NETWORK_NO_SOURCE ); |
52 <video id="video-3"><source id="source-1"></video> | 41 assert_equals(video.readyState, HTMLMediaElement.HAVE_NOTHING); |
53 | 42 } |
54 <p>Test the document's load event is delayed until a movie's meta data i s available.</p> | 43 } |
55 | 44 }); |
56 <script> | 45 </script> |
57 consoleWrite("<br><b>inline script</b>"); | 46 </body> |
58 | |
59 testMovieWithNoSource(document.getElementById('video-1')); | |
60 | |
61 video = document.getElementById('video-2'); | |
62 video.src = findMediaFile("video", "content/test"); | |
63 testMovieWithSource(video, false, "<br><em>with 'src' attribute.</em >"); | |
64 | |
65 source = document.getElementById('source-1'); | |
66 source.src = findMediaFile("video", "content/test"); | |
67 testMovieWithSource(document.getElementById('video-3'), false, "<br> <em>with <source> element.</em>"); | |
68 document.getElementById('video-3').load(); | |
69 </script> | |
70 | |
71 </body> | |
72 </html> | |
OLD | NEW |