[Webkit-unassigned] [Bug 44575] beforeload event fired twice on <object>s

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Sep 7 16:03:14 PDT 2011


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





--- Comment #11 from Marc Hoyois <marc.hoyois at gmail.com>  2011-09-07 16:03:13 PST ---
This may be related to comment #8: trying to get computed styles of event.target within the handler can cause the handler to pause while a new beforeload event is fired and handled. This seems to happen consistently if plugins are disabled. I'd like to point out that it's essential for several content-blocking extensions out there that computed styles be accessible within the beforeload handler, so please don't remove this possibility. The 2nd beforeload shouldn't be there, though (but it's easy to ignore in Javascript: just set a property on event.target before getting styles and remove it after).

Another completely different cause of duplicate beforeload events concerns native image types in <object> elements. For example if the specified type is image/jpeg, Safari tries to load the resource directly, but if that fails it checks the actual Content-Type and fires a beforeload again. In this case the second event is fired some time after the first has been handled, and so it's impossible to tell for sure that the second event is a duplicate. Instead of reusing the same <object> after checking the Content-Type, it would be more consistent if WebKit created a new subframe like it does in the case when type is not set and extension does not match a plugin, and fire the 2nd beforeload there.

These two phenomena can even combine so that <object> elements can fire up to 3 beforeload events.

It seems to me the main problem is that the beforeload event is not fired in the correct place: updateWidget is called in cases where no beforeload should be fired. Conceptually the algorithm should be

1. Gather parameters from the DOM. If no source and no type, abort and use fallback. (Only source and type are needed here, but since we must look for them in <params> for legacy reasons, we might as well gather all parameters now. It would even be useful to set them as a DOMStringMap property of the beforeload event.)
2. Fire beforeload. If defaultPrevented, abort and use fallback.
3. Run the loading procedures.

Start again whenever the data/src or type attributes are changed. Currently beforeload is fired in the middle of 3...

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list