2011-04-20  Yury Semikhatsky  <yurys@chromium.org>

        Reviewed by Tony Gentilcore.

        Error event in <script> element shouldn't bubble
        https://bugs.webkit.org/show_bug.cgi?id=51040

        * fast/events/onerror-bubbling-expected.txt:
        * fast/events/onerror-bubbling.html:
        * svg/dom/SVGScriptElement/script-load-and-error-events.svg: error event is dispatched on the
        corresponding SVGScriptElement and shouldn't bubble, so the global error handler should
        never be invoked for script load errors. This behaviour is consistent with HTMLScriptElement element.
        * svg/dom/SVGScriptElement/script-onerror-bubbling-expected.txt: Added.
        * svg/dom/SVGScriptElement/script-onerror-bubbling.svg: Added.
2011-04-20  Yury Semikhatsky  <yurys@chromium.org>

        Reviewed by Tony Gentilcore.

        Error event in <script> element shouldn't bubble
        https://bugs.webkit.org/show_bug.cgi?id=51040

        Test: svg/dom/SVGScriptElement/script-onerror-bubbling.svg

        * dom/ScriptElement.cpp:
        (WebCore::ScriptElement::dispatchErrorEvent): the method now has same implementation for all script
        elements, script load error event doesn' bubble.
        * dom/ScriptElement.h:
        * html/HTMLScriptElement.cpp:
        * html/HTMLScriptElement.h:
        * html/parser/HTMLScriptRunner.cpp:
        (WebCore::HTMLScriptRunner::executePendingScriptAndDispatchEvent):
        * svg/SVGScriptElement.cpp:
        (WebCore::SVGScriptElement::parseMappedAttribute): SVG script element now supports onerror
        hanlder which behaves the same way as onerror in HTML script element: it's invoked when
        script loading fails and the event doesn't bubble.
        * svg/SVGScriptElement.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@84357 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/dom/ScriptElement.cpp b/Source/WebCore/dom/ScriptElement.cpp
index 5dd6b7d..1660868 100644
--- a/Source/WebCore/dom/ScriptElement.cpp
+++ b/Source/WebCore/dom/ScriptElement.cpp
@@ -135,6 +135,11 @@
     return languages.contains(language);
 }
 
+void ScriptElement::dispatchErrorEvent()
+{
+    m_element->dispatchEvent(Event::create(eventNames().errorEvent, false, false));
+}
+
 bool ScriptElement::isScriptTypeSupported(LegacyTypeSupport supportLegacyTypes) const
 {
     // FIXME: isLegacySupportedJavaScriptLanguage() is not valid HTML5. It is used here to maintain backwards compatibility with existing layout tests. The specific violations are: