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

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

Issue 2116293004: Convert video-source-[load|moved|removed].html tests to testharness.js (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 <!doctype html> 1 <!DOCTYPE html>
2 <html> 2 <title>Test that the resource selection algorithm is restarted when load() is ca lled, and that all "source" elements are reconsidered.</title>
3 <head> 3 <script src="../resources/testharness.js"></script>
4 <title>load() and the &lt;source&gt; element</title> 4 <script src="../resources/testharnessreport.js"></script>
5 <!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956 5 <script src="media-file.js"></script>
6 (Please avoid writing new tests using video-test.js) --> 6 <video></video>
7 <script src=video-test.js></script> 7 <script>
8 <script src=media-file.js></script> 8 async_test(function(t) {
9 <script> 9 var sourceUrls = [];
10 var sources = []; 10 var errorCount = 0;
11 var count = 0; 11 var video = document.querySelector("video");
12 12
13 function canplaythrough() 13 // Test initial networkState.
14 { 14 assert_equals(video.networkState, HTMLMediaElement.NETWORK_EMPTY);
15 testExpected("stripExtension(relativeURL(video.currentSrc))", re lativeURL(stripExtension(sources[1])));
16 ++count;
17 switch (count)
18 {
19 case 1:
20 consoleWrite("<br>+++ Calling load().");
21 video.load();
22 break;
23 case 2:
24 endTest();
25 return;
26 }
27 }
28 15
29 function addSource(type, name) 16 video.oncanplaythrough = t.step_func(function() {
30 { 17 var url = video.currentSrc;
31 var source = document.createElement('source'); 18 assert_equals(url.substr(url.lastIndexOf("/media/") + 7),
32 source.src = findMediaFile(type, name); 19 sourceUrls[1].substr(sourceUrls[1].lastIndexOf("/media/") + 7));
33 sources.push(source.src); 20 switch (errorCount) {
34 source.type = mimeTypeForExtension(source.src.split('.').pop()); 21 case 1:
35 video.appendChild(source); 22 // Calling load() to invoke resource selection again.
36 } 23 video.load();
24 break;
25 case 2:
26 t.done();
27 return;
fs 2016/07/05 13:33:04 Nit: indentation (or, remove since it's redundant)
Srirama 2016/07/05 14:55:28 Done.
28 }
29 });
37 30
38 function setup() 31 video.addEventListener("error", function() {
39 { 32 errorCount++;
40 video = mediaElement = document.getElementsByTagName('video')[0] ; 33 }, true);
41 34
42 consoleWrite("+++ Test initial networkState."); 35 // Add an invalid url to the first source so we test getting
43 testExpected("video.networkState", HTMLMediaElement.prototype.NE TWORK_EMPTY, "=="); 36 // an error event each time resource selection runs.
37 addSource("video", "content/bogus");
38 addSource("video", "content/test");
39 addSource("audio", "content/test");
44 40
45 // Add an invalid url to the first source so we test getting an error event 41 // test networkState.
46 // each time resource selection runs. 42 assert_equals(video.networkState, HTMLMediaElement.NETWORK_NO_SOURCE);
47 addSource("video", "content/bogus");
48 addSource("video", "content/test");
49 addSource("audio", "content/test");
50 43
51 consoleWrite("<br>+++ Add &lt;source&gt; elements to trigger loa ding, test networkState."); 44 function addSource(type, name) {
52 testExpected("video.networkState", HTMLMediaElement.prototype.NE TWORK_NO_SOURCE, "=="); 45 var source = document.createElement("source");
53 46 source.src = findMediaFile(type, name);
54 waitForEvent("canplaythrough", canplaythrough); 47 sourceUrls.push(source.src);
55 waitForEvent("error"); 48 source.type = mimeTypeForExtension(source.src.split(".").pop());
56 } 49 video.appendChild(source);
57 </script> 50 }
58 </head> 51 });
59 <body onload="setup()"> 52 </script>
60 <video controls width=300 ></video>
61 <p>Test that the resource selection algorithm is restarted when load() i s called, and that all &lt;source&gt; elements are reconsidered.</p>
62 </body>
63 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698