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

Side by Side Diff: third_party/WebKit/LayoutTests/media/video-src-remove.html

Issue 2098213002: Convert video-src-[plus-source, remove, set, source].html tests to testharness.js (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address nits 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
OLDNEW
1 <html> 1 <!DOCTYPE html>
2 <body> 2 <title>Test that removing valid "src" attribute doesn't trigger load of "source" elements.</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>
7 <div id=panel></div> 7 <source></source>
8 <script> 8 </video>
9 var panel = document.getElementById("panel"); 9 <script>
10 var mediaFile = findMediaFile("video", "content/test"); 10 async_test(function(t) {
11 panel.innerHTML = "<video src=" + mediaFile + " controls onloadedmetadat a='loadedmetadata()'><source src=content/counting.mp4></video>"; 11 var video = document.querySelector("video");
12 </script>
13 12
14 <p>Test that removing valid 'src' attribute DOES NOT trigger load of &lt;sou rce&gt; elements</p> 13 video.onloadedmetadata = t.step_func(function() {
14 testSrc();
15 video.removeAttribute("src");
16 video.onloadedmetadata = t.unreached_func();
15 17
16 <script> 18 setTimeout(t.step_func_done(function() {
17 findMediaElement(); 19 testSrc();
20 }), 100) ;
21 });
18 22
19 var loadCount = 0; 23 function testSrc() {
24 var url = video.currentSrc;
25 assert_equals(url.substr(url.lastIndexOf("/media/")+7), mediaFile);
26 assert_false(isNaN(video.duration));
27 }
20 28
21 function testSrc() 29 document.querySelector("source").src = findMediaFile("video", "content/count ing");
22 { 30 var mediaFile = findMediaFile("video", "content/test");
23 testExpected("stripExtension(relativeURL(video.currentSrc))", stripE xtension(mediaFile)); 31 video.src = mediaFile;
24 testExpected("isNaN(video.duration)", false); 32 });
25 consoleWrite(""); 33 </script>
26 }
27
28 function loadedmetadata()
29 {
30 consoleWrite("EVENT(loadedmetadata)");
31
32 ++loadCount;
33 if (loadCount == 1)
34 {
35 testSrc();
36 run("video.removeAttribute('src')");
37 }
38 else
39 {
40 consoleWrite("<span style='color:red'>FAIL</span> : 'loadCount' fired " + loadCount + "times" );
41 endTest();
42 }
43 consoleWrite("");
44 setTimeout(someTimeLater, 100) ;
45 }
46
47 function someTimeLater()
48 {
49 testSrc();
50 endTest();
51 consoleWrite("");
52 }
53
54 consoleWrite("");
55 </script>
56
57 </body>
58 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698