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

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: address comments 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 <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) {
20 if (++errorCount > 1) 22 t.done();
21 endTest(); 23 return;
24 }
22 25
23 setSrcAttribure(findMediaFile("video", "content/test")); 26 mediaFile = findMediaFile("video", "content/counting");
24 consoleWrite(""); 27 video.src = mediaFile;
25 } 28 });
26 29
27 function loadedmetadata() 30 video.onerror = t.step_func(function() {
28 { 31 assert_equals(loadedCount, 0);
29 testExpected("stripExtension(relativeURL(video.currentSrc))", st ripExtension(mediaFile)); 32 var url = video.currentSrc;
30 testExpected("isNaN(video.duration)", false); 33 assert_equals(url.substr(url.lastIndexOf("/media/")+7), "bogus");
31 consoleWrite(""); 34 assert_equals(video.networkState, HTMLMediaElement.NETWORK_NO_SOURCE);
35 assert_equals(video.error.code, MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED);
36 mediaFile = findMediaFile("video", "content/test");
37 video.src = mediaFile;
38 });
32 39
33 if (++loadedCount >= 2) { 40 mediaFile = "bogus";
34 mediaElement.removeEventListener('loadedmetadata', loadedmet adata); 41 video.src = mediaFile;
35 endTest(); 42 });
36 return; 43 </script>
37 }
38
39 setSrcAttribure(findMediaFile("video", "content/counting"));
40 consoleWrite("");
41 }
42
43 function setSrcAttribure(src)
44 {
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