Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / media / media-source / mediasource-gc-after-decode-error-crash.html
blobdb130cdfbf48cc564752f58bd728ff78d02f2880
1 <!doctype html>
2 <html>
3 <head>
4 <script src="../../media-resources/video-test.js"></script>
5 </head>
6 <body>
7 <p>Verifies that a MediaSource decode error followed by a gc() and page reload does not trigger a crash.</p>
8 <video></video>
9 <script>
10 function onSourceOpen(e)
12 consoleWrite("onSourceOpen");
13 var ms = e.target;
14 ms.removeEventListener("sourceopen", onSourceOpen);
16 var v = document.querySelector("video");
17 URL.revokeObjectURL(v.src);
19 // Create a SourceBuffer and append garbage so a decode error will occur
20 // and the MediaSource will get closed.
21 ms.addEventListener("sourceclose", onSourceClose);
22 var sb = ms.addSourceBuffer("video/webm;codecs=\"vp8\"");
23 var buf = new Uint8Array(10);
24 sb.appendBuffer(buf);
27 function onSourceClose(e)
29 consoleWrite("onSourceClose");
30 e.target.removeEventListener("sourceclose", onSourceClose);
32 // Schedule a GC and page reload. We need a timeout here so that
33 // the MediaSource reference used by this event is cleared before
34 // we try to GC & reload.
35 setTimeout(gcAndReloadPage, 0);
38 function gcAndReloadPage()
40 consoleWrite("Running gc().");
41 gc();
43 var suffix = "?2";
44 if (document.location.href.indexOf(suffix) != -1) {
45 endTest();
46 return;
49 document.location.href += suffix;
52 (function()
54 var ms = new MediaSource();
55 ms.addEventListener("sourceopen", onSourceOpen);
56 document.querySelector("video").src = URL.createObjectURL(ms);
57 })();
58 </script>
59 </body>
60 </html>