Closed Bug 380417 Opened 17 years ago Closed 17 years ago

[FIX]SVG Load Event Doesn't Always Fire, Recent Regression

Categories

(Core :: SVG, defect, P1)

defect

Tracking

()

RESOLVED FIXED
mozilla1.9alpha5

People

(Reporter: duncan.loveday, Assigned: bzbarsky)

References

Details

(Keywords: regression)

Attachments

(5 files, 2 obsolete files)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a5pre) Gecko/20070510 Minefield/3.0a5pre
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a5pre) Gecko/20070510 Minefield/3.0a5pre

In the attached test case, most of the time the SVG load event doesn't fire. The SVG is imported into the HTML by means of an EMBED written using javascript document.write(). The problem may be timing dependent since removing the alert message from the test case makes it work correctly.

Reproducible: Sometimes

Steps to Reproduce:
1. Open the attached test.html
2. Click the reload button and/or click in the location field and hit enter.
3.
Actual Results:  
In most cases, the following alerts are displayed:
    Loading doc
    HTML load handler
Occasionally, the following alerts are displayed:
    Loading doc
    SVG load handler
    HTML load handler

Expected Results:  
The correct behaviour is to consistently display
    Loading doc
    SVG load handler
    HTML load handler

This works correctly on FF2 and on recent trunk builds, no more than a couple of weeks old.
Attached image test SVG source
Attached file test Javascript source (obsolete) —
Attached file test HTML source (obsolete) —
Attached file test Javascript source
Unfortunately, I can't recreate the fault with files that work live in the bug, possibly because of time dependency. Reattaching files with relative URLs.

Save the three files test.html, test.js, test.svg in a directory and open test.html.
Attachment #264488 - Attachment is obsolete: true
Attached file test HTML source
Attachment #264489 - Attachment is obsolete: true
The latest three attachments recreate the bug consistently for me when saved in a directory. Comment out the "loading doc" alert from test.html and it starts working.
Keywords: regression
Ah, yes.  So SVG fires onload events for its elements only if there is already a presentation set up for the document by the time the close tag for the element is parsed.  

Bug 379485 changed things so that in fact there is no presshell in this case, because the frame for the <embed> hasn't been created yet.

The question I have is whether SVG should fire the events independently of presentation existence...
Blocks: 379485
Status: UNCONFIRMED → NEW
Ever confirmed: true
Attached patch Proposed fixSplinter Review
I assume that SVG frames do not listen for SVG load events, right?
Attachment #264524 - Flags: superreview?(tor)
Attachment #264524 - Flags: review?(jwatt)
Attachment #264524 - Flags: review?(Olli.Pettay)
Assignee: general → bzbarsky
OS: Windows XP → All
Priority: -- → P1
Hardware: PC → All
Summary: SVG Load Event Doesn't Always Fire, Recent Regression → [FIX]SVG Load Event Doesn't Always Fire, Recent Regression
Target Milestone: --- → mozilla1.9alpha5
I *think* SVGLoad doesn't need prescontext at all.
Flags: in-testsuite?
Comment on attachment 264524 [details] [diff] [review]
Proposed fix

Though, this is ok too, works like normal DOM event dispatching where context is used if there is one.
Attachment #264524 - Flags: review?(Olli.Pettay) → review+
If we're using the event dispatcher, do we want to set the NS_EVENT_FLAG_CANT_BUBBLE flag?

http://www.w3.org/2003/01/REC-SVG11-20030114-errata.html#SVGLoad%20does%20not%20bubble
Oh, that is just proposed errata. Does that mean that we should wait until it has been somehow accepted or ?
It seems the errata is just to simplify the language, not to change the actual behavior.
I can add that, sure.  Do you want to see an updated patch?
Comment on attachment 264524 [details] [diff] [review]
Proposed fix

sr=tor with bubble flag added.
Attachment #264524 - Flags: superreview?(tor) → superreview+
Comment on attachment 264524 [details] [diff] [review]
Proposed fix

Sorry for the delayed review! r=jwatt, but please do add the NS_EVENT_FLAG_CANT_BUBBLE flag.
Attachment #264524 - Flags: review?(jwatt) → review+
Checked in.
Status: NEW → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
Depends on: 431703
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: