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

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

Issue 2092373002: Convert video-src* tests to testharness.js (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 <head> 2 <title>Test that an invalid "src" fires an error event and changing "src" to a v alid one triggers media load.</title>
3 <!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956 3 <script src="../resources/testharness.js"></script>
4 (Please avoid writing new tests using video-test.js) --> 4 <script src="../resources/testharnessreport.js"></script>
5 <script src=video-test.js></script> 5 <script src="media-file.js"></script>
6 <script src=media-file.js></script> 6 <video></video>
7 <script> 7 <script>
8 var mediaFile; 8 // 1. Test that an invalid src attribute fires an error when the file fails to l oad.
9 var loadedCount = 0; 9 // 2. Test that changing src attribute triggers load after a load fails.
10 var errorCount = 0; 10 // 3. Test that changing src triggers load once a file is known to be valid.
11 async_test(function(t) {
12 var mediaFile;
13 var loadedCount = 0;
14 var video = document.querySelector("video");
11 15
12 function errorEvent() 16 video.onloadedmetadata = t.step_func(function() {
13 { 17 var url = video.currentSrc;
14 testExpected("relativeURL(video.currentSrc)", "bogus"); 18 assert_equals(url.substr(url.lastIndexOf("/media/")+7), mediaFile);
15 testExpected("video.networkState", HTMLMediaElement.NETWORK_NO_S OURCE); 19 assert_false(isNaN(video.duration));
16 testExpected("video.error.code", MediaError.MEDIA_ERR_SRC_NOT_SU PPORTED);
17 consoleWrite("");
18 20
19 // Prevent runaway tests when unexpected errors happen. 21 if (++loadedCount >= 2) {
fs 2016/06/25 17:12:03 Should never be > 2, right?
Srirama 2016/06/26 05:41:54 Done.
20 if (++errorCount > 1) 22 t.done();
21 endTest(); 23 return;
24 }
22 25
23 setSrcAttribure(findMediaFile("video", "content/test")); 26 setSrcAttribure(findMediaFile("video", "content/counting"));
24 consoleWrite(""); 27 });
25 }
26 28
27 function loadedmetadata() 29 video.onerror = t.step_func(function() {
28 { 30 var url = video.currentSrc;
fs 2016/06/25 17:12:03 Assert loadedCount == 0 too?
Srirama 2016/06/26 05:41:55 Done.
29 testExpected("stripExtension(relativeURL(video.currentSrc))", st ripExtension(mediaFile)); 31 assert_equals(url.substr(url.lastIndexOf("/media/")+7), "bogus");
30 testExpected("isNaN(video.duration)", false); 32 assert_equals(video.networkState, HTMLMediaElement.NETWORK_NO_SOURCE);
31 consoleWrite(""); 33 assert_equals(video.error.code, MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED);
34 setSrcAttribure(findMediaFile("video", "content/test"));
35 });
32 36
33 if (++loadedCount >= 2) { 37 setSrcAttribure("bogus");
34 mediaElement.removeEventListener('loadedmetadata', loadedmet adata);
35 endTest();
36 return;
37 }
38 38
39 setSrcAttribure(findMediaFile("video", "content/counting")); 39 function setSrcAttribure(src) {
fs 2016/06/25 17:12:03 Let's fix this typo while we're at it (...bure ->
Srirama 2016/06/26 05:41:55 Done.
40 consoleWrite(""); 40 mediaFile = src;
41 } 41 video.src = src;
42 42 }
43 function setSrcAttribure(src) 43 });
44 { 44 </script>
45 mediaFile = src;
46 video.setAttribute('src', src);
47 }
48
49 function setup()
50 {
51 findMediaElement();
52 waitForEvent('loadedmetadata', loadedmetadata);
53 waitForEvent('error', errorEvent);
54 setSrcAttribure("bogus");
55 consoleWrite("");
56 }
57 </script>
58 </head>
59
60 <body onload="setup()">
61
62 <video controls" ></video>
63
64 <p>
65 1. Test that an invalid src attribute fires an error when the file fails to load.<br>
66 2. Test that changing src attribute triggers load after a load fails.<br>
67 3. Test that changing src triggers load once a file is known to be valid.
68 </p>
69
70 </body>
71 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698