4 <script src=
"../../media-resources/video-test.js"></script>
7 <p>Verifies that a MediaSource decode error followed by a gc() and page reload does not trigger a crash.
</p>
10 function onSourceOpen(e
)
12 consoleWrite("onSourceOpen");
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);
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().");
44 if (document
.location
.href
.indexOf(suffix
) != -1) {
49 document
.location
.href
+= suffix
;
54 var ms
= new MediaSource();
55 ms
.addEventListener("sourceopen", onSourceOpen
);
56 document
.querySelector("video").src
= URL
.createObjectURL(ms
);