summaryrefslogtreecommitdiffstats
path: root/LayoutTests/fast/dom/beforeload/remove-flash-in-beforeload-listener.html
blob: 1c8c021b350c46d3256798a7e9e1e771cd3dc230 (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
48
<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 flash object in a beforeload listener without causing a crash.</p>
    <object type="application/x-shockwave-flash" data="../../../plugins/resources/simple_blank.swf"></object>
    <div id="console"></div>
    <script>
        function checkObjectRemoval()
        {
            if (!document.getElementsByTagName("object").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>