[Webkit-unassigned] [Bug 177043] New: innerWidth and innerHeight return 0 inside iframe created with document.write

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Sat Sep 16 18:48:59 PDT 2017


https://bugs.webkit.org/show_bug.cgi?id=177043

            Bug ID: 177043
           Summary: innerWidth and innerHeight return 0 inside iframe
                    created with document.write
           Product: WebKit
           Version: WebKit Nightly Build
          Hardware: Unspecified
                OS: Unspecified
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: Frames
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: MatthiasSaihttam1 at gmail.com

Created attachment 321021

  --> https://bugs.webkit.org/attachment.cgi?id=321021&action=review

A HTML file showing the bug.

If you write to an iframe, innerWidth and innerHeight are 0 inside the iframe, even after the window "load" event fires. However, even 50ms later the dimensions are correct. This may be because the load event is fired too early, or because these properties are not set correctly. This behavior works as expected on other browsers (the width and height represent the dimensions of the iframe from the outset).
Rather than try to explain the exact circumstances required to reproduce this, I'm going to include the following example which I used to confirm this issue (also attached).

<!DOCTYPE HTML>
<html>
<body>
    <iframe src="about:blank" id="frame"></iframe>
    <script>
        var doc = document.getElementById("frame").contentDocument;
        doc.open();
        doc.write(`<script>
            console.log("start", innerWidth);
            window.addEventListener("load", function () {
                console.log("onload", innerWidth); //Doesn't work. Prints 0
            });
            window.setTimeout(function () {
                console.log("50ms", innerWidth); //Works
            }, 50);
        </scr` + "ipt>");
        doc.close();
    </script>
</body>
</html>

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20170917/d079ba0b/attachment.html>


More information about the webkit-unassigned mailing list