Use testRunner instead of layoutTestController in fast/doctypes, dom, dynamic, encodi...
[WebKit-https.git] / LayoutTests / fast / dom / beforeload / remove-video-in-beforeload-listener.html
1 <html>
2 <head>
3     <script src="resources/print.js"></script>
4     <script>
5         if (window.testRunner) {
6             testRunner.dumpAsText();
7             testRunner.waitUntilDone();
8         }
9         
10         var count = 0;
11         var maxCount = 10;
12         var timeout = 100;
13
14         document.addEventListener("beforeload", function(event) {
15             if (event.target && event.target.parentElement)
16                 event.target.parentElement.removeChild(event.target);
17         }, true);
18     </script>
19 </head>
20 <body>
21     <p>This page tests that you can correctly remove a video object in a beforeload listener without causing a crash.</p>
22     <video src="../../../media/content/test.mp4"></video>
23     <div id="console"></div>
24     <script>
25         function checkObjectRemoval()
26         {
27             if (!document.getElementsByTagName("video").length) {
28                 print("PASS", "green");
29                 if (window.testRunner)
30                     testRunner.notifyDone();
31                 return;
32             }
33             
34             if (++count > maxCount) {
35                 print("FAIL", "red");
36                 if (window.testRunner)
37                     testRunner.notifyDone();
38                 return;
39             }
40             
41             setTimeout("checkObjectRemoval()", timeout);
42         }
43         
44         setTimeout("checkObjectRemoval()", timeout);
45     </script>
46 </body>
47 </html>