Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: third_party/WebKit/LayoutTests/media/video-delay-load-event.html

Issue 2096413003: Convert video-delay* and video-display* tests to testharness.js (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: modify as per suggestion Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/media/video-delay-load-event-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <video id="video1"></video>
7 (Please avoid writing new tests using video-test.js) --> 7 <video id="video2"></video>
8 <script src=video-test.js></script> 8 <video id="video3"><source></source></video>
9 <script src=media-file.js></script> 9 <script>
10 <script> 10 async_test(function(t) {
11 var video; 11 assertVideoNoSrcNoLoad(document.getElementById("video1"));
12 12
13 function testMovieWithNoSource(elem) 13 var video = document.getElementById("video2");
14 { 14 video.src = findMediaFile("video", "content/test");
15 video = elem; // Need it in a global for testExpected() to see it. 15 assertVideoSrcNoLoad(video);
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 16
21 function testMovieWithSource(elem, hasLoaded, msg) 17 var source = document.querySelector("source");
22 { 18 source.src = findMediaFile("video", "content/test");
23 video = elem; // Need it in a global for testExpected() to see it. 19 assertVideoSrcNoLoad(document.getElementById("video3"));
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 20
36 function loaded() 21 window.onload = t.step_func_done(function() {
37 { 22 assertVideoNoSrcNoLoad(document.getElementById("video1"));
38 consoleWrite("<br><b>document <em>'load'<" + "/em> event handler </b>"); 23 assertVideoSrcLoad(document.getElementById("video2"));
24 assertVideoSrcLoad(document.getElementById("video3"));
25 });
39 26
40 testMovieWithNoSource(document.getElementById('video-1')); 27 function assertVideoNoSrcNoLoad(video) {
41 testMovieWithSource(document.getElementById('video-2'), true, "< br><em>with 'src' attribute.</em>"); 28 // Video should not load as there is no "src".
42 testMovieWithSource(document.getElementById('video-3'), true, "< br><em>with &lt;source&gt; element.</em>"); 29 assert_equals(video.networkState, HTMLMediaElement.NETWORK_EMPTY);
30 assert_equals(video.readyState, HTMLMediaElement.HAVE_NOTHING);
31 }
43 32
44 if (window.testRunner) 33 function assertVideoSrcNoLoad(video) {
45 testRunner.notifyDone(); 34 // Video loading has just triggered.
46 } 35 assert_equals(video.networkState, HTMLMediaElement.NETWORK_NO_SOURCE);
47 </script> 36 assert_equals(video.readyState, HTMLMediaElement.HAVE_NOTHING);
48 </head> 37 }
49 <body onload="loaded()">
50 <video id="video-1"></video>
51 <video id="video-2"></video>
52 <video id="video-3"><source id="source-1"></video>
53 38
54 <p>Test the document's load event is delayed until a movie's meta data i s available.</p> 39 function assertVideoSrcLoad(video) {
55 40 // The Video should have loaded at least to HAVE_CURRENT_DATA
56 <script> 41 assert_not_equals(video.networkState, HTMLMediaElement.NETWORK_NO_SOURCE );
57 consoleWrite("<br><b>inline script</b>"); 42 assert_greater_than_equal(video.networkState, HTMLMediaElement.NETWORK_I DLE);
58 43 assert_greater_than_equal(video.readyState, HTMLMediaElement.HAVE_CURREN T_DATA);
59 testMovieWithNoSource(document.getElementById('video-1')); 44 }
60 45 });
61 video = document.getElementById('video-2'); 46 </script>
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 &lt;source&gt; element.</em>");
68 document.getElementById('video-3').load();
69 </script>
70
71 </body>
72 </html>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/media/video-delay-load-event-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698