layout-in-beforeload-listener-affects-plugin-loading.html 1.44 KB
Newer Older
1 2 3 4
<!DOCTYPE html>
<html>
<head>
    <script>
5 6 7
        if (window.testRunner) {
            testRunner.dumpAsText();
            testRunner.waitUntilDone();
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
        }
        
        window._beforeloadReceivedForEmbed = false;
        
        document.addEventListener("beforeload", function(event) {
            if (document.getElementsByTagName("object")[0] == event.target) {
                // trigger a layout
                event.target.offsetWidth;
                return;
            }
            
            _beforeloadReceivedForEmbed = document.getElementsByTagName("embed")[0] == event.target;
        }, true);
        
        function test() {
            // The <embed> should load as a post-layout task that executes in
            // the current run loop iteration. Queue a task to check if the
            // <embed>'s beforeload event fired.
            window.setTimeout(function() {
                console.log(_beforeloadReceivedForEmbed ? "PASS" : "FAIL");
28 29
                if (window.testRunner)
                    testRunner.notifyDone();
30 31 32 33 34 35 36 37 38 39 40 41 42
            }, 0);
        }
    </script>
</head>
<body onload="test();">
    <!-- Test that performing layout in a beforeload listener does not affect
         plug-in loading. See http://webkit.org/b/77167 for details. This test
         requires TestNetscapePlugIn so it must be run in DumpRenderTree. -->
    <object>
        <embed type="application/x-webkit-test-netscape">
    </object>
</body>
</html>