OLD | NEW |
1 <!doctype html> | 1 <!DOCTYPE html> |
2 <html> | 2 <title>Verifies that a MediaSource decode error followed by a gc() and page relo
ad does not trigger a crash.</title> |
3 <head> | 3 <script src="/w3c/resources/testharness.js"></script> |
4 <!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956 | 4 <script src="/w3c/resources/testharnessreport.js"></script> |
5 (Please avoid writing new tests using video-test.js) --> | 5 <video></video> |
6 <script src="../../media-resources/video-test.js"></script> | 6 <script> |
7 </head> | 7 async_test(function(t) { |
8 <body> | 8 var video = document.querySelector('video'); |
9 <p>Verifies that a MediaSource decode error followed by a gc() and page
reload does not trigger a crash.</p> | 9 var mediaSource = new MediaSource(); |
10 <video></video> | |
11 <script> | |
12 function onSourceOpen(e) | |
13 { | |
14 consoleWrite("onSourceOpen"); | |
15 var ms = e.target; | |
16 ms.removeEventListener("sourceopen", onSourceOpen); | |
17 | 10 |
18 var v = document.querySelector("video"); | 11 mediaSource.onsourceopen = t.step_func(function() { |
19 URL.revokeObjectURL(v.src); | 12 mediaSource.onsourceopen = null; |
| 13 URL.revokeObjectURL(video.src); |
20 | 14 |
21 // Create a SourceBuffer and append garbage so a decode error will
occur | 15 // Create a SourceBuffer and append garbage so a decode error will occur |
22 // and the MediaSource will get closed. | 16 // and the MediaSource will get closed. |
23 ms.addEventListener("sourceclose", onSourceClose); | 17 mediaSource.onsourceclose = t.step_func(function() { |
24 var sb = ms.addSourceBuffer("video/webm;codecs=\"vp8\""); | 18 mediaSource.onsourceclose = null; |
25 var buf = new Uint8Array(10); | |
26 sb.appendBuffer(buf); | |
27 } | |
28 | |
29 function onSourceClose(e) | |
30 { | |
31 consoleWrite("onSourceClose"); | |
32 e.target.removeEventListener("sourceclose", onSourceClose); | |
33 | 19 |
34 // Schedule a GC and page reload. We need a timeout here so that | 20 // Schedule a GC and page reload. We need a timeout here so that |
35 // the MediaSource reference used by this event is cleared before | 21 // the MediaSource reference used by this event is cleared before |
36 // we try to GC & reload. | 22 // we try to GC & reload. |
37 setTimeout(gcAndReloadPage, 0); | 23 setTimeout(t.step_func(function() { |
38 } | 24 gc(); |
39 | 25 |
40 function gcAndReloadPage() | 26 var suffix = "?2"; |
41 { | 27 if (document.location.href.indexOf(suffix) != -1) { |
42 consoleWrite("Running gc()."); | 28 t.done(); |
43 gc(); | 29 return; |
| 30 } |
44 | 31 |
45 var suffix = "?2"; | 32 document.location.href += suffix; |
46 if (document.location.href.indexOf(suffix) != -1) { | 33 }), 0); |
47 endTest(); | 34 }); |
48 return; | 35 var sourceBuffer = mediaSource.addSourceBuffer("video/webm;codecs=\"vp8\
""); |
49 } | 36 var buffer = new Uint8Array(10); |
| 37 sourceBuffer.appendBuffer(buffer); |
| 38 }); |
50 | 39 |
51 document.location.href += suffix; | 40 video.src = URL.createObjectURL(mediaSource); |
52 } | 41 }); |
53 | 42 </script> |
54 (function() | |
55 { | |
56 var ms = new MediaSource(); | |
57 ms.addEventListener("sourceopen", onSourceOpen); | |
58 document.querySelector("video").src = URL.createObjectURL(ms); | |
59 })(); | |
60 </script> | |
61 </body> | |
62 </html> | |
OLD | NEW |