Changeset 84357 in webkit


Ignore:
Timestamp:
Apr 20, 2011 4:52:04 AM (13 years ago)
Author:
yurys@chromium.org
Message:

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:
Location:
trunk
Files:
2 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r84356 r84357  
     12011-04-20  Yury Semikhatsky  <yurys@chromium.org>
     2
     3        Reviewed by Tony Gentilcore.
     4
     5        Error event in <script> element shouldn't bubble
     6        https://bugs.webkit.org/show_bug.cgi?id=51040
     7
     8        * fast/events/onerror-bubbling-expected.txt:
     9        * fast/events/onerror-bubbling.html:
     10        * svg/dom/SVGScriptElement/script-load-and-error-events.svg: error event is dispatched on the
     11        corresponding SVGScriptElement and shouldn't bubble, so the global error handler should
     12        never be invoked for script load errors. This behaviour is consistent with HTMLScriptElement element.
     13        * svg/dom/SVGScriptElement/script-onerror-bubbling-expected.txt: Added.
     14        * svg/dom/SVGScriptElement/script-onerror-bubbling.svg: Added.
     15
    1162011-04-20  John Knottenbelt  <jknotten@chromium.org>
    217
  • trunk/LayoutTests/fast/events/onerror-bubbling-expected.txt

    r25617 r84357  
    1 PASS: inline script load error bubbled
    2 PASS: dynamic script load error bubbled
     1PASS: script error handler invoked
    32
  • trunk/LayoutTests/fast/events/onerror-bubbling.html

    r14007 r84357  
    2121       
    2222    var div = document.createElement("div");
    23     div.setAttribute("onerror", "print('PASS: dynamic script load error bubbled'); \
     23    div.setAttribute("onerror", "print('FAILED: dynamic script load error bubbled'); \
    2424                                 if (window.layoutTestController) \
    2525                                    layoutTestController.notifyDone();");
     
    3232    document.body.appendChild(div);
    3333}
     34
     35function scriptOnerror()
     36{
     37    print('PASS: script error handler invoked');
     38
     39    // Allow event bubbling phase to complete.
     40    setTimeout(function() {
     41        if (window.layoutTestController)
     42            layoutTestController.notifyDone();
     43    }, 0);
     44}
     45
     46window.onerror = function() {
     47    print('FAILED: window.onerror handler invoked');
     48}
    3449</script>
    3550</head>
     
    3752<hr>
    3853<div id='console'></div>
    39 <div onerror="print('PASS: inline script load error bubbled')">
    40     <script src="file:///GregTheBunny.js"></script>
     54<div onerror="print('FAILED: inline script load error bubbled')">
     55    <script src="file:///GregTheBunny.js" onerror="scriptOnerror()"></script>
    4156</div>
    4257
  • trunk/LayoutTests/svg/dom/SVGScriptElement/script-load-and-error-events.svg

    r36699 r84357  
    11<?xml version="1.0"?>
    2 <svg width="100%" height="100%" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xhtml="http://www.w3.org/1999/xhtml" onerror="errorEventHandler(evt)" onload="testLoadEventNotFired()">
     2<svg width="100%" height="100%" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xhtml="http://www.w3.org/1999/xhtml" onerror="testGlobalErrorHandlerNotFired(evt)" onload="testLoadEventNotFired()">
    33<defs>
    44<title>&lt;SCRIPT&gt; load and error events</title>
     
    1414    layoutTestController.dumpAsText();
    1515    layoutTestController.waitUntilDone();
     16}
     17
     18function testGlobalErrorHandlerNotFired(evt) {
     19    status_[evt.target.id] += "G";
    1620}
    1721
     
    97101        window.setTimeout('continueDynamicTest2()', 0);
    98102    };
     103    scriptElement.onerror = errorEventHandler;
    99104
    100105    document.getElementsByTagName("defs")[0].appendChild(scriptElement); 
     
    107112    scriptElement.href.baseVal = "resources/not-existant.js";
    108113    scriptElement.externalResourcesRequired.baseVal = true;
     114    scriptElement.onerror = errorEventHandler;
    109115
    110116    lastTest = 1;
     
    112118}
    113119</script>
    114 <script id="0" type="text/javascript" onload="loadEventHandler(evt)" xlink:href="resources/certainlydoesnotexist.js"></script>
    115 <script id="1" type="text/javascript" externalResourcesRequired="true" onload="loadEventHandler(evt)" xlink:href="resources/certainlydoesnotexisttoo.js"/>
    116 <script id="2" type="text/javascript" onload="loadEventHandler(evt)" xlink:href="resources/script-load.js"></script>
    117 <script id="3" type="text/javascript" externalResourcesRequired="true" onload="loadEventHandler(evt); lastTestBeforeRootElementLoaded();" xlink:href="resources/script-load.js"/>
     120<script id="0" type="text/javascript" onerror="errorEventHandler(evt)" onload="loadEventHandler(evt)" xlink:href="resources/certainlydoesnotexist.js"></script>
     121<script id="1" type="text/javascript" onerror="errorEventHandler(evt)" externalResourcesRequired="true" onload="loadEventHandler(evt)" xlink:href="resources/certainlydoesnotexisttoo.js"/>
     122<script id="2" type="text/javascript" onerror="errorEventHandler(evt)" onload="loadEventHandler(evt)" xlink:href="resources/script-load.js"></script>
     123<script id="3" type="text/javascript" onerror="errorEventHandler(evt)" externalResourcesRequired="true" onload="loadEventHandler(evt); lastTestBeforeRootElementLoaded();" xlink:href="resources/script-load.js"/>
    118124</defs>
    119125<foreignObject>
  • trunk/Source/WebCore/ChangeLog

    r84351 r84357  
     12011-04-20  Yury Semikhatsky  <yurys@chromium.org>
     2
     3        Reviewed by Tony Gentilcore.
     4
     5        Error event in <script> element shouldn't bubble
     6        https://bugs.webkit.org/show_bug.cgi?id=51040
     7
     8        Test: svg/dom/SVGScriptElement/script-onerror-bubbling.svg
     9
     10        * dom/ScriptElement.cpp:
     11        (WebCore::ScriptElement::dispatchErrorEvent): the method now has same implementation for all script
     12        elements, script load error event doesn' bubble.
     13        * dom/ScriptElement.h:
     14        * html/HTMLScriptElement.cpp:
     15        * html/HTMLScriptElement.h:
     16        * html/parser/HTMLScriptRunner.cpp:
     17        (WebCore::HTMLScriptRunner::executePendingScriptAndDispatchEvent):
     18        * svg/SVGScriptElement.cpp:
     19        (WebCore::SVGScriptElement::parseMappedAttribute): SVG script element now supports onerror
     20        hanlder which behaves the same way as onerror in HTML script element: it's invoked when
     21        script loading fails and the event doesn't bubble.
     22        * svg/SVGScriptElement.h:
     23
    1242011-04-20  Pavel Feldman  <pfeldman@google.com>
    225
  • trunk/Source/WebCore/dom/ScriptElement.cpp

    r83159 r84357  
    136136}
    137137
     138void ScriptElement::dispatchErrorEvent()
     139{
     140    m_element->dispatchEvent(Event::create(eventNames().errorEvent, false, false));
     141}
     142
    138143bool ScriptElement::isScriptTypeSupported(LegacyTypeSupport supportLegacyTypes) const
    139144{
  • trunk/Source/WebCore/dom/ScriptElement.h

    r81198 r84357  
    5151    // XML parser calls these
    5252    virtual void dispatchLoadEvent() = 0;
    53     virtual void dispatchErrorEvent() = 0;
     53    void dispatchErrorEvent();
    5454    bool isScriptTypeSupported(LegacyTypeSupport) const;
    5555
  • trunk/Source/WebCore/html/HTMLScriptElement.cpp

    r81198 r84357  
    186186}
    187187
    188 void HTMLScriptElement::dispatchErrorEvent()
    189 {
    190     dispatchEvent(Event::create(eventNames().errorEvent, true, false));
    191 }
    192 
    193188PassRefPtr<Element> HTMLScriptElement::cloneElementWithoutAttributesAndChildren() const
    194189{
  • trunk/Source/WebCore/html/HTMLScriptElement.h

    r81198 r84357  
    6666
    6767    virtual void dispatchLoadEvent();
    68     virtual void dispatchErrorEvent();
    6968
    7069    PassRefPtr<Element> cloneElementWithoutAttributesAndChildren() const;
  • trunk/Source/WebCore/html/parser/HTMLScriptRunner.cpp

    r82631 r84357  
    8787}
    8888
    89 inline PassRefPtr<Event> createScriptErrorEvent()
    90 {
    91     return Event::create(eventNames().errorEvent, true, false);
    92 }
    93 
    9489ScriptSourceCode HTMLScriptRunner::sourceFromPendingScript(const PendingScript& script, bool& errorOccurred) const
    9590{
     
    139134        IgnoreDestructiveWriteCountIncrementer ignoreDestructiveWriteCountIncrementer(m_document);
    140135        if (errorOccurred)
    141             element->dispatchEvent(createScriptErrorEvent());
     136            scriptElement->dispatchErrorEvent();
    142137        else {
    143138            ASSERT(isExecutingScript());
  • trunk/Source/WebCore/svg/SVGScriptElement.cpp

    r79114 r84357  
    2828#include "Event.h"
    2929#include "EventNames.h"
     30#include "HTMLNames.h"
    3031#include "SVGNames.h"
     32#include "ScriptEventListener.h"
    3133
    3234namespace WebCore {
     
    5355    if (attrName == SVGNames::typeAttr)
    5456        setType(attr->value());
     57    else if (attr->name() == HTMLNames::onerrorAttr)
     58        setAttributeEventListener(eventNames().errorEvent, createAttributeEventListener(this, attr));
    5559    else {
    5660        if (SVGURIReference::parseMappedAttribute(attr))
     
    245249}
    246250
    247 void SVGScriptElement::dispatchErrorEvent()
    248 {
    249     dispatchEvent(Event::create(eventNames().errorEvent, true, false));
    250 }
    251 
    252251PassRefPtr<Element> SVGScriptElement::cloneElementWithoutAttributesAndChildren() const
    253252{
  • trunk/Source/WebCore/svg/SVGScriptElement.h

    r79114 r84357  
    7272
    7373    virtual void dispatchLoadEvent();
    74     virtual void dispatchErrorEvent();
    7574
    7675    PassRefPtr<Element> cloneElementWithoutAttributesAndChildren() const;
Note: See TracChangeset for help on using the changeset viewer.