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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/media/media-source/mediasource-preload.html

Issue 1920383002: MSE: Clean up the mediasource-preload layout test (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addresses all remaining comments Created 4 years, 7 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 | no next file » | 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 <html>
3 <head> 3 <head>
4 <script src="/w3c/resources/testharness.js"></script> 4 <script src="/w3c/resources/testharness.js"></script>
5 <script src="/w3c/resources/testharnessreport.js"></script> 5 <script src="/w3c/resources/testharnessreport.js"></script>
6 <script src="mediasource-util.js"></script>
7 <link rel="stylesheet" href="/w3c/resources/testharness.css">
8 </head> 6 </head>
9 <body> 7 <body>
10 <script> 8 <script>
11 function attachWithPreloadTest(preload) 9 function attachWithPreloadTest(preload)
12 { 10 {
13 async_test(function(test) 11 async_test(function(test)
14 { 12 {
15 var video = document.createElement("video"); 13 var video = document.createElement("video");
16 var mediaSource = new MediaSource(); 14 var mediaSource = new MediaSource();
17 var mediaSourceURL = URL.createObjectURL(mediaSource); 15 var mediaSourceURL = URL.createObjectURL(mediaSource);
18 16
19 video.preload = preload; 17 video.preload = preload;
20 document.body.appendChild(video); 18 document.body.appendChild(video);
21 test.add_cleanup(function() { 19 test.add_cleanup(function() {
22 document.body.removeChild(video); 20 document.body.removeChild(video);
23 URL.revokeObjectURL(mediaSourceURL); 21 URL.revokeObjectURL(mediaSourceURL);
24 }); 22 });
25 23
26 var listener = test.step_func(function(event) { test.done(); }); 24 mediaSource.addEventListener("sourceopen", test.step_func_do ne());
27 mediaSource.addEventListener("sourceopen", listener);
28 video.src = mediaSourceURL; 25 video.src = mediaSourceURL;
29 }, "sourceopen occurs with element preload=" + preload); 26 }, "sourceopen occurs with element preload=" + preload);
30 } 27 }
31 28
32 attachWithPreloadTest("auto"); 29 attachWithPreloadTest("auto");
33 attachWithPreloadTest("metadata"); 30 attachWithPreloadTest("metadata");
34 attachWithPreloadTest("none"); 31 attachWithPreloadTest("none");
35 32
36 function errorWithPreloadTest(preload, bogusURLStyle) 33 function errorWithPreloadTest(preload, bogusURLStyle)
37 { 34 {
38 var testURLdescription;
39 var mediaSource = new MediaSource();
40 var bogusURL;
41
42 if (bogusURLStyle == "revoked") {
43 testURLdescription = "revoked MediaSource object URL";
44 bogusURL = URL.createObjectURL(mediaSource);
45 URL.revokeObjectURL(bogusURL);
46 } else if (bogusURLStyle == "corrupted") {
47 testURLdescription = "corrupted MediaSource object URL";
48 bogusURL = URL.createObjectURL(mediaSource);
49 bogusURL += "0";
50 } else {
51 testURLdescription = bogusURL = bogusURLStyle;
52 }
53
54 async_test(function(test) 35 async_test(function(test)
55 { 36 {
37 var mediaSource = new MediaSource();
38 var bogusURL = URL.createObjectURL(mediaSource);
39
40 if (bogusURLStyle == "corrupted") {
41 var goodURL = bogusURL;
42 test.add_cleanup(function() { URL.revokeObjectURL(goodUR L); });
43 bogusURL += "0";
44 } else if (bogusURLStyle == "revoked") {
45 URL.revokeObjectURL(bogusURL);
46 } else {
47 assert_unreached("invalid case");
48 }
49
56 var video = document.createElement("video"); 50 var video = document.createElement("video");
57
58 video.preload = preload; 51 video.preload = preload;
59 document.body.appendChild(video); 52 document.body.appendChild(video);
60 test.add_cleanup(function() { document.body.removeChild(vide o); }); 53 test.add_cleanup(function() { document.body.removeChild(vide o); });
61 54
62 var listener = test.step_func(function(event) { test.fail(); }); 55 mediaSource.addEventListener("sourceopen", test.unreached_fu nc("'sourceopen' should not be fired"));
63 mediaSource.addEventListener("sourceopen", listener);
64 56
65 video.onerror = test.step_func(function(event) { test.done() ; }); 57 video.onerror = test.step_func_done();
66 video.src = bogusURL; 58 video.src = bogusURL;
67 }, "error occurs with bogus blob URL (" + testURLdescription + " ) and element preload=" + preload); 59 }, "error occurs with bogus blob URL (" + bogusURLStyle + " Medi aSource object URL) and element preload=" + preload);
68 } 60 }
69 61
70 errorWithPreloadTest("auto", "revoked"); 62 errorWithPreloadTest("auto", "revoked");
71 errorWithPreloadTest("metadata", "revoked"); 63 errorWithPreloadTest("metadata", "revoked");
72 errorWithPreloadTest("none", "revoked"); 64 errorWithPreloadTest("none", "revoked");
73 65
74 errorWithPreloadTest("auto", "blob:a");
75 errorWithPreloadTest("metadata", "blob:a");
76 errorWithPreloadTest("none", "blob:a");
77
78 errorWithPreloadTest("auto", "corrupted"); 66 errorWithPreloadTest("auto", "corrupted");
79 errorWithPreloadTest("metadata", "corrupted"); 67 errorWithPreloadTest("metadata", "corrupted");
80 errorWithPreloadTest("none", "corrupted"); 68 errorWithPreloadTest("none", "corrupted");
81 </script> 69 </script>
82 </body> 70 </body>
83 </html> 71 </html>
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698