summaryrefslogtreecommitdiffstats
path: root/LayoutTests/fast/dom/beforeload/remove-video-in-beforeload-listener.html
blob: add0e135a7d9e3ff7c6ff79f5e15837a9930edad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<html>
<head>
    <script src="resources/print.js"></script>
    <script>
        if (window.layoutTestController) {
            layoutTestController.dumpAsText();
            layoutTestController.waitUntilDone();
        }
        
        var count = 0;
        var maxCount = 10;
        var timeout = 100;

        document.addEventListener("beforeload", function(event) {
            if (event.target && event.target.parentElement)
                event.target.parentElement.removeChild(event.target);
        }, true);
    </script>
</head>
<body>
    <p>This page tests that you can correctly remove a video object in a beforeload listener without causing a crash.</p>
    <video src="../../../media/content/test.mp4"></video>
    <div id="console"></div>
    <script>
        function checkObjectRemoval()
        {
            if (!document.getElementsByTagName("video").length) {
                print("PASS", "green");
                if (window.layoutTestController)
                    layoutTestController.notifyDone();
                return;
            }
            
            if (++count > maxCount) {
                print("FAIL", "red");
                if (window.layoutTestController)
                    layoutTestController.notifyDone();
                return;
            }
            
            setTimeout("checkObjectRemoval()", timeout);
        }
        
        setTimeout("checkObjectRemoval()", timeout);
    </script>
</body>
</html>