Deal with DOM modifications when evaluating source elements.
[WebKit-https.git] / LayoutTests / media / video-beforeload-remove-source.html
1 <!DOCTYPE html>
2 <html>
3     <head>
4         <script src=../resources/gc.js></script>
5     </head>
6     <body>
7     <video controls autoplay>
8         <b id="start"></b>
9         <source src="content/test.mp4" type="video/mp4">
10         <source src="content/test.ogv" type="video/ogg">
11         <b id="end"></b>
12     </video> 
13     <div>Test passes if it does not crash.</div>
14     </body>
15     <script>
16         if (window.layoutTestController) {
17             layoutTestController.dumpAsText();
18             layoutTestController.waitUntilDone();
19         }
20         
21         function removeNodes(start, end) {
22             var range = document.createRange();
23             range.setStart(start, 0);
24             range.setEnd(end, 0);
25             range.deleteContents();
26         }
27         
28         function beforeLoadFunc()
29         {
30             document.removeEventListener("beforeload", beforeLoadFunc, true);
31             var start = document.getElementById("start");
32             var end = document.getElementById("end");
33             removeNodes(start, end);
34         
35             gc();
36             if (window.layoutTestController)
37                 setTimeout("layoutTestController.notifyDone()", 0);
38         }
39         
40         document.addEventListener("beforeload", beforeLoadFunc, true);
41     </script>
42 </html>