[Webkit-unassigned] [Bug 188499] New: Setting a frame src before appending it to the DOM makes the frame's load event be fired twice

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Sun Aug 12 23:53:24 PDT 2018


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

            Bug ID: 188499
           Summary: Setting a frame src before appending it to the DOM
                    makes the frame's load event be fired twice
           Product: WebKit
           Version: Safari 11
          Hardware: Macintosh
                OS: Unspecified
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: Frames
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: tpillardpro at gmail.com

Hello,

I am creating this bug in follow-up to https://twitter.com/tpillard/status/1028663435524009984

The following JavaScript code will log the "Loaded" message twice.


```
const root = document.body;
const frame = document.createElement('iframe');
const href = 'https://bugs.webkit.org';

frame.onload = (evt) => console.log('Loaded', evt);
root.appendChild(frame);
frame.src = href;
```

Inverting the last two lines (setting the frame's src before appending it to the DOM) fixes the problem.

Tested and fixed with the following UA string:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.1.1 Safari/605.1.15

I've originally had some customer complaints on this behavior, one includes the following UA string:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.1 Safari/605.1.15

While debugging, I noticed similar issues have been reported by users on StackOverflow over the years:
https://stackoverflow.com/questions/10781880/dynamically-created-iframe-triggers-onload-event-twice
https://stackoverflow.com/questions/22722046/onload-bug-in-google-chrome-safari
https://stackoverflow.com/questions/25066052/window-onload-called-twice-inside-an-iframe

I could not reproduce this behavior on other browsers I had at my disposal.

Thank you for any response,

--
Tim

-- 
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/20180813/5fd7b608/attachment-0001.html>


More information about the webkit-unassigned mailing list