Open Bug 2020973 Opened 4 months ago Updated 2 months ago

Add a console warning if a load listener is added after sync-about-blank load completed

Categories

(Core :: DOM: Navigation, enhancement)

enhancement

Tracking

()

ASSIGNED

People

(Reporter: vhilla, Assigned: vhilla)

References

Details

Attachments

(1 obsolete file)

Bug 543435 made Gecko's initial about:blank load Blink / WebKit compatible by changing it to complete synchronous. This timing change has broken a few web pages and libraries, like CKEditor 4 or bug 2020285 and bug 2020668.

The issue is code like

ifr = document.createElement("iframe")
document.body.append(ifr)
ifr.onload = ...

where onload won't be called anymore and we should prototype a console warning for it as indicated by bug 2020668 c7.

As DOMContentLoaded fires on the document and previously that first synchronously available document got replaced, that event should not be of concern. It would be possible to listen for load on ifr.contentWindow though.


I guess it wouldn't have been straightforward to add a deprecation warning / have a warning now, as above code isn't necessarily wrong. I.e. a page might check in onload for the right URI and afterwards set src to some non-blank URI. And the document/window doesn't know much about when listeners are added. It also seems unclean to have such specific code in the generic EventTarget::AddEventListener, with potential performance costs. But it's a bad developer experience if pages randomly break without any indication.

Let's first evaluate the performance impact of: Check for load on an iframe or window element in EventTarget::AddEventListener using MOZ_UNLIKELY. If the document is already loaded and src is such that about:blank would not be replaced, then log a console warning.

If that doesn't work, alternatively nsDocShell::CompleteInitialAboutBlankLoad could determine the number of listeners on the iframe, dispatch a runnable to wait a tick, and if more listeners are added while src still causes about:blank, log a warning.

I guess for this to be useful, the change should be simple enough to be uplifted to release soon. I'm unsure if this is still worth the risk / effort.

See Also: → sync-about-blank
Assignee: nobody → vhilla
Status: NEW → ASSIGNED
Attachment #9550324 - Attachment is obsolete: true
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: