Last Comment Bug 500261 - svg image onerror fails to fire on any error
: svg image onerror fails to fire on any error
Status: RESOLVED FIXED
:
Product: Core
Classification: Components
Component: SVG (show other bugs)
: unspecified
: x86 Windows XP
: -- normal (vote)
: mozilla30
Assigned To: Robert Longson
:
Mentors:
Depends on: 620002
Blocks:
  Show dependency treegraph
 
Reported: 2009-06-24 12:39 PDT by Bill Wallace
Modified: 2014-02-18 18:52 PST (History)
5 users (show)
longsonr: in‑testsuite+
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
patch (6.15 KB, patch)
2009-06-24 17:29 PDT, Robert Longson
no flags Details | Diff | Review
HTML passing testcase (for comparison with SVG testcase) (202 bytes, application/xhtml+xml)
2009-06-25 05:45 PDT, Bill Wallace
no flags Details
This is the SVG testcase that fails. (537 bytes, application/xhtml+xml)
2009-06-25 05:45 PDT, Bill Wallace
no flags Details
better patch (3.16 KB, patch)
2009-10-04 06:34 PDT, Robert Longson
no flags Details | Diff | Review
reftest (1.79 KB, patch)
2009-10-04 11:29 PDT, Robert Longson
no flags Details | Diff | Review
The SVG 2 way (6.61 KB, patch)
2014-02-13 02:10 PST, Robert Longson
cam: review+
bugs: superreview+
Details | Diff | Review

Description Bill Wallace 2009-06-24 12:39:11 PDT
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.11) Gecko/2009060215 Firefox/3.0.11
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.11) Gecko/2009060215 Firefox/3.0.11

If there is an onerror method attached to either an svg:image or xhtml:img tag, they will fail to fire if either the server is missing or a 404 is returned.  I didn't have any easy way to test other error codes, but I expect this is generally true.  Note that this is a super-set of the bug reported in 299138, where that issue is only about 404 errors returning an image.  In this case, any 404 returned, even html, or a 0 (server gone) is silently ignored, and no image is displayed, nor is the callback called.

Reproducible: Always

Steps to Reproduce:
Try loading the following file as XHTML.  It should give you 2 error alerts, but instead gives you none.

<html  xmlns="http://www.w3.org/1999/xhtml" xmlns:xlink="http://www.w3.org/1999/xlink" >
<body>

<p>This is an HTML paragraph</p>

<div style="width:300px; height:100px; background:cyan; position: relative;">

<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300" height="100"
viewBox="0 0 100 100" preserveAspectRatio="xMidYMid slice"
style="width:300px; height:100px; ">
<image width="300" height="100" xlink:href="http://localhost/noServer.gif" preserveAspectRatio="none" onerror="alert(1)" /> 
</svg>
</div>

Done.
<img src="http://localhost/noServer.gif" onerror="alert(2)" /> 

</body>
</html> 


Actual Results:  
onerror is ignored every time.  I was unable to find any case where onerror was successfully called.

Expected Results:  
alert 1 and 2 are both shown (unless you happen to have the gif I reference which seems unlikely)
Comment 1 Bill Wallace 2009-06-24 12:42:56 PDT
I had noscript for files on - the svg image onerror still fails, but the second alert(2) displays just fine.
Also, for the svg reference about having onerror, I'm using:
http://www.w3.org/TR/SVG11/interact.html#SVGEvents
Comment 2 Robert Longson 2009-06-24 15:27:32 PDT
Can you add the testcase as an attachment please? Ideally as two separate attachments (one for html only and another containing only as the svg example)
Comment 3 Robert Longson 2009-06-24 17:29:16 PDT
Created attachment 385018 [details] [diff] [review]
patch
Comment 4 Bill Wallace 2009-06-25 05:45:21 PDT
Created attachment 385087 [details]
HTML passing testcase (for comparison with SVG testcase)

This is the html test case that already passes.
Comment 5 Bill Wallace 2009-06-25 05:45:50 PDT
Created attachment 385088 [details]
This is the SVG testcase that fails.
Comment 6 Jonathan Watt [:jwatt] (Away Jun. 27 - Jul. 13) 2009-07-21 14:08:58 PDT
Comment on attachment 385018 [details] [diff] [review]
patch

This seems wrong to me. The spec says that the 'onerror' attribute on SVG content triggers for the 'SVGError' event, not the 'error' event. Hence what nsSVGElement::GetEventNameForAttr is for.
Comment 7 Jonathan Watt [:jwatt] (Away Jun. 27 - Jul. 13) 2009-09-18 08:01:40 PDT
Any thoughts on that Robert?
Comment 8 Robert Longson 2009-09-18 08:03:20 PDT
I think you're right. Unfortunately I'm not sure what to do about it :-( You know the events code better than me I think.
Comment 9 Robert Longson 2009-10-04 06:34:44 PDT
Created attachment 404500 [details] [diff] [review]
better patch
Comment 10 Olli Pettay [:smaug] (high review load, please consider other reviewers) 2009-10-04 10:52:18 PDT
Comment on attachment 404500 [details] [diff] [review]
better patch

Could you add some simple testcase for this.

I'm not sure we actually fire abort, but dispatching abort manually should be handle by onabort listener.
Comment 11 Robert Longson 2009-10-04 11:29:46 PDT
Created attachment 404522 [details] [diff] [review]
reftest
Comment 12 Robert Longson 2009-10-04 11:31:15 PDT
(In reply to comment #10)
> (From update of attachment 404500 [details] [diff] [review])
> Could you add some simple testcase for this.

Done.

> 
> I'm not sure we actually fire abort, but dispatching abort manually should be
> handle by onabort listener.

I don't fire abort internally either.
Comment 13 Robert Longson 2010-12-19 02:33:02 PST
Comment on attachment 404500 [details] [diff] [review]
better patch

bitrotted now
Comment 14 Robert Longson 2014-02-13 02:10:30 PST
Created attachment 8375406 [details] [diff] [review]
The SVG 2 way

Seems that SVG 2 will use the standard CSS error and abort events per http://www.w3.org/TR/SVG2/interact.html#SVGEvents

We never fired the SVG 1.1 SVGError event so we've no backwards compatibility worries.
Comment 15 Cameron McCormack (:heycam) (away Jun 25 – Jul 10) 2014-02-17 16:54:18 PST
Comment on attachment 8375406 [details] [diff] [review]
The SVG 2 way

Review of attachment 8375406 [details] [diff] [review]:
-----------------------------------------------------------------

r=me for the SVG bits but can you get smaug or masayuki to review the dom/events/ bits?
Comment 18 Wes Kocher (:KWierso) 2014-02-18 18:52:06 PST
https://hg.mozilla.org/mozilla-central/rev/e3a09f5cec6b

Note You need to log in before you can comment on or make changes to this bug.