Bug 500261 - svg images do not fire error events on any error. r=cam,sr=smaug
authorRobert Longson <longsonr@gmail.com>
Tue, 18 Feb 2014 19:57:42 +0000
changeset 169682 e3a09f5cec6b11fdaa4632ce05313d7746ed5896
parent 169681 2a34429afff1b8192378a5427e2d118d44d00622
child 169742 1b45269a2fd9ce27c202d9c81e03c51458d01dcb
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewerscam, smaug
bugs500261
milestone30.0a1
Bug 500261 - svg images do not fire error events on any error. r=cam,sr=smaug
content/base/src/nsGkAtomList.h
content/svg/content/src/nsSVGElement.cpp
content/svg/content/test/mochitest.ini
content/svg/content/test/test_onerror.xhtml
dom/events/nsEventListenerManager.cpp
dom/events/nsEventNameList.h
--- a/content/base/src/nsGkAtomList.h
+++ b/content/base/src/nsGkAtomList.h
@@ -1342,18 +1342,16 @@ GK_ATOM(metadata, "metadata")
 GK_ATOM(missingGlyph, "missing-glyph")
 GK_ATOM(mm, "mm")
 GK_ATOM(mpath, "mpath")
 GK_ATOM(noStitch, "noStitch")
 GK_ATOM(numOctaves, "numOctaves")
 GK_ATOM(multiply, "multiply")
 GK_ATOM(objectBoundingBox, "objectBoundingBox")
 GK_ATOM(offset, "offset")
-GK_ATOM(onSVGAbort, "onSVGAbort")
-GK_ATOM(onSVGError, "onSVGError")
 GK_ATOM(onSVGLoad, "onSVGLoad")
 GK_ATOM(onSVGResize, "onSVGResize")
 GK_ATOM(onSVGScroll, "onSVGScroll")
 GK_ATOM(onSVGUnload, "onSVGUnload")
 GK_ATOM(onSVGZoom, "onSVGZoom")
 GK_ATOM(onzoom, "onzoom")
 GK_ATOM(opacity, "opacity")
 GK_ATOM(_operator, "operator")
--- a/content/svg/content/src/nsSVGElement.cpp
+++ b/content/svg/content/src/nsSVGElement.cpp
@@ -1515,20 +1515,16 @@ nsSVGElement::MaybeSerializeAttrBeforeRe
 
 /* static */
 nsIAtom* nsSVGElement::GetEventNameForAttr(nsIAtom* aAttr)
 {
   if (aAttr == nsGkAtoms::onload)
     return nsGkAtoms::onSVGLoad;
   if (aAttr == nsGkAtoms::onunload)
     return nsGkAtoms::onSVGUnload;
-  if (aAttr == nsGkAtoms::onabort)
-    return nsGkAtoms::onSVGAbort;
-  if (aAttr == nsGkAtoms::onerror)
-    return nsGkAtoms::onSVGError;
   if (aAttr == nsGkAtoms::onresize)
     return nsGkAtoms::onSVGResize;
   if (aAttr == nsGkAtoms::onscroll)
     return nsGkAtoms::onSVGScroll;
   if (aAttr == nsGkAtoms::onzoom)
     return nsGkAtoms::onSVGZoom;
   if (aAttr == nsGkAtoms::onbegin)
     return nsGkAtoms::onbeginEvent;
--- a/content/svg/content/test/mochitest.ini
+++ b/content/svg/content/test/mochitest.ini
@@ -43,16 +43,17 @@ support-files =
 [test_hasFeature.xhtml]
 [test_lang.xhtml]
 skip-if = true # disabled-for-intermittent-failures--bug-701060
 [test_length.xhtml]
 skip-if = true
 [test_lengthParsing.html]
 [test_nonAnimStrings.xhtml]
 [test_non-scaling-stroke.html]
+[test_onerror.xhtml]
 [test_pathAnimInterpolation.xhtml]
 [test_pathSeg.xhtml]
 [test_pointAtLength.xhtml]
 [test_pointer-events-1a.xhtml]
 [test_pointer-events-1b.xhtml]
 [test_pointer-events-2.xhtml]
 [test_pointer-events-3.xhtml]
 [test_pointer-events-4.xhtml]
new file mode 100644
--- /dev/null
+++ b/content/svg/content/test/test_onerror.xhtml
@@ -0,0 +1,36 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=500261
+-->
+<head>
+  <title>Test onerror behaviour</title>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=500261">Mozilla Bug 500261</a>
+<p id="display"></p>
+<div id="content">
+
+  <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="100%" height="1" id="svg">
+    <image width="1" height="1" xlink:href="http://localhost/serverGone.gif" onerror="run()"/>
+  </svg>
+
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+<![CDATA[
+
+SimpleTest.waitForExplicitFinish();
+
+function run()
+{
+  ok(true, 'onerror method called');
+  SimpleTest.finish();
+}
+
+]]>
+</script>
+</pre>
+</body>
+</html>
--- a/dom/events/nsEventListenerManager.cpp
+++ b/dom/events/nsEventListenerManager.cpp
@@ -828,20 +828,16 @@ nsEventListenerManager::CompileEventHand
     MOZ_ASSERT(element || aBody, "Where will we get our body?");
     nsAutoString handlerBody;
     const nsAString* body = aBody;
     if (!aBody) {
       if (aListenerStruct->mTypeAtom == nsGkAtoms::onSVGLoad)
         attrName = nsGkAtoms::onload;
       else if (aListenerStruct->mTypeAtom == nsGkAtoms::onSVGUnload)
         attrName = nsGkAtoms::onunload;
-      else if (aListenerStruct->mTypeAtom == nsGkAtoms::onSVGAbort)
-        attrName = nsGkAtoms::onabort;
-      else if (aListenerStruct->mTypeAtom == nsGkAtoms::onSVGError)
-        attrName = nsGkAtoms::onerror;
       else if (aListenerStruct->mTypeAtom == nsGkAtoms::onSVGResize)
         attrName = nsGkAtoms::onresize;
       else if (aListenerStruct->mTypeAtom == nsGkAtoms::onSVGScroll)
         attrName = nsGkAtoms::onscroll;
       else if (aListenerStruct->mTypeAtom == nsGkAtoms::onSVGZoom)
         attrName = nsGkAtoms::onzoom;
       else if (aListenerStruct->mTypeAtom == nsGkAtoms::onbeginEvent)
         attrName = nsGkAtoms::onbegin;
--- a/dom/events/nsEventNameList.h
+++ b/dom/events/nsEventNameList.h
@@ -144,17 +144,17 @@
 
 #ifndef BEFOREUNLOAD_EVENT
 #define BEFOREUNLOAD_EVENT WINDOW_EVENT
 #define DEFINED_BEFOREUNLOAD_EVENT
 #endif /* BEFOREUNLOAD_EVENT */
 
 EVENT(abort,
       NS_IMAGE_ABORT,
-      (EventNameType_HTMLXUL | EventNameType_SVGSVG),
+      EventNameType_All,
       NS_EVENT)
 EVENT(canplay,
       NS_CANPLAY,
       EventNameType_HTML,
       NS_EVENT)
 EVENT(canplaythrough,
       NS_CANPLAYTHROUGH,
       EventNameType_HTML,
@@ -428,17 +428,17 @@ EVENT(afterscriptexecute,
       NS_EVENT)
 
 FORWARDED_EVENT(blur,
                 NS_BLUR_CONTENT,
                 EventNameType_HTMLXUL,
                 NS_FOCUS_EVENT)
 ERROR_EVENT(error,
             NS_LOAD_ERROR,
-            (EventNameType_HTMLXUL | EventNameType_SVGSVG),
+            EventNameType_All,
             NS_EVENT)
 FORWARDED_EVENT(focus,
                 NS_FOCUS_CONTENT,
                 EventNameType_HTMLXUL,
                 NS_FOCUS_EVENT)
 FORWARDED_EVENT(load,
                 NS_LOAD,
                 EventNameType_All,
@@ -729,24 +729,16 @@ NON_IDL_EVENT(underflow,
 NON_IDL_EVENT(SVGLoad,
               NS_SVG_LOAD,
               EventNameType_None,
               NS_EVENT)
 NON_IDL_EVENT(SVGUnload,
               NS_SVG_UNLOAD,
               EventNameType_None,
               NS_EVENT)
-NON_IDL_EVENT(SVGAbort,
-              NS_SVG_ABORT,
-              EventNameType_None,
-              NS_EVENT)
-NON_IDL_EVENT(SVGError,
-              NS_SVG_ERROR,
-              EventNameType_None,
-              NS_EVENT)
 NON_IDL_EVENT(SVGResize,
               NS_SVG_RESIZE,
               EventNameType_None,
               NS_EVENT)
 NON_IDL_EVENT(SVGScroll,
               NS_SVG_SCROLL,
               EventNameType_None,
               NS_EVENT)