Bug 127644 - onload event is never fired if script element was added from readystatechange listener
Summary: onload event is never fired if script element was added from readystatechange...
Status: RESOLVED CONFIGURATION CHANGED
Alias: None
Product: WebKit
Classification: Unclassified
Component: UI Events (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC Linux
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-01-25 22:31 PST by sanachan.y
Modified: 2022-07-23 14:35 PDT (History)
11 users (show)

See Also:


Attachments
Test case for this bug to reproduce (913 bytes, text/html)
2014-01-25 22:42 PST, sanachan.y
no flags Details
Patch (1.38 KB, patch)
2014-01-25 23:01 PST, sanachan.y
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description sanachan.y 2014-01-25 22:31:21 PST
If the functions with the below ordering were called, I think 'onload' event is never fired.

1. FrameLoader::checkCompleted()
2. Document::setReadyState(Document::Complete); -- from checkCompleted()
3. HTMLScriptElement::HTMLScriptElement -- from listener of onreadystatechange
4. ScriptRunner::queueScriptForExecution()
5. Document::incrementLoadEventDelayCount() -- from queueScriptForExecution()
6. Document::checkCallImplicitClose() -- from checkCompleted()
---> But it will return immediately because of Document::isDelayingLoadEvent()==true
7. Document::decrementLoadEventDelayCount() is called and timer fired,
FrameLoader::checkCompleted() will be called. However, m_isComplete is already set to 'true' then
we cannot reach to DOMWindow::dispatchLoadEvent();

I think isDelayingLoadEvent() is necessary to be checked after onreadystatechange to be fired.
Firefox, Chrome v30 (not WebKit) on PC are OK.
Comment 1 Benjamin Poulain 2014-01-25 22:35:15 PST
For reference: https://lists.webkit.org/pipermail/webkit-help/2014-January/003723.html
Comment 2 sanachan.y 2014-01-25 22:42:11 PST
Created attachment 222255 [details]
Test case for this bug to reproduce
Comment 3 sanachan.y 2014-01-25 23:01:28 PST
Created attachment 222258 [details]
Patch

I'm not an expert of WebKit. Maybe this is incomplete and will make any side-effects.
Comment 4 Deepak Mittal 2014-01-28 02:44:26 PST
When isDelayingLoadEvent() is pending then m_complete should be fale.

Changes appears ok to me,

I have verified these changes also, It is working fine..
Comment 5 Ahmad Saleem 2022-07-23 03:25:57 PDT
I am not clear on Expected result of test case but all browsers show following output (in Private / Incognito tab or window):

interactive
complete
Recived onload event

Browsers tested - Safari 15.6 on macOS 12.5 , Chrome Canary 105 and Firefox Nightly 104

If it is expected result, I think it can be marked as "RESOLVED CONFIGURATION CHANGED" or else test case can be updated etc. Just wanted to share updated results. Thanks!
Comment 6 Ryosuke Niwa 2022-07-23 14:35:54 PDT
Yeah, this appears to be fixed now.