Changeset 90972 in webkit


Ignore:
Timestamp:
Jul 13, 2011 7:25:55 PM (13 years ago)
Author:
dominicc@chromium.org
Message:

Raise if dispatchEvent dispatches an event that is being dispatched
https://bugs.webkit.org/show_bug.cgi?id=64150

Reviewed by Dimitri Glazkov.

Source/WebCore:

Spec: http://www.w3.org/TR/DOM-Level-3-Events/#events-EventTarget-dispatchEvent

Test: fast/events/dispatch-event-being-dispatched.html

  • dom/Event.h:

(WebCore::Event::isBeingDispatched): Added.

  • dom/EventException.h:
  • dom/EventException.idl: Add DISPATCH_REQUEST_ERR.
  • dom/EventTarget.cpp:

(WebCore::EventTarget::dispatchEvent): Raise if being dispatched.

  • dom/ExceptionCode.cpp: Add gunk for DISPATCH_REQUEST_ERR.

LayoutTests:

  • fast/dom/Window/window-properties-expected.txt: Added DISPATCH_REQUEST_ERR.
  • fast/events/dispatch-event-being-dispatched-expected.txt: Added.
  • fast/events/dispatch-event-being-dispatched.html: Added.
  • fast/workers/resources/worker-event-listener.js:

(onmessage): Redispatching the MessageEvent throws an exception now.

  • platform/gtk/fast/dom/Window/window-properties-expected.txt:
  • platform/qt-wk2/fast/dom/Window/window-properties-expected.txt:
  • platform/qt/fast/dom/Window/window-properties-expected.txt:
Location:
trunk
Files:
2 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r90971 r90972  
     12011-07-12  Dominic Cooney  <dominicc@chromium.org>
     2
     3        Raise if dispatchEvent dispatches an event that is being dispatched
     4        https://bugs.webkit.org/show_bug.cgi?id=64150
     5
     6        Reviewed by Dimitri Glazkov.
     7
     8        * fast/dom/Window/window-properties-expected.txt: Added DISPATCH_REQUEST_ERR.
     9        * fast/events/dispatch-event-being-dispatched-expected.txt: Added.
     10        * fast/events/dispatch-event-being-dispatched.html: Added.
     11        * fast/workers/resources/worker-event-listener.js:
     12        (onmessage): Redispatching the MessageEvent throws an exception now.
     13        * platform/gtk/fast/dom/Window/window-properties-expected.txt:
     14        * platform/qt-wk2/fast/dom/Window/window-properties-expected.txt:
     15        * platform/qt/fast/dom/Window/window-properties-expected.txt:
     16
    1172011-07-13  Kent Tamura  <tkent@chromium.org>
    218
  • trunk/LayoutTests/fast/dom/Window/window-properties-expected.txt

    r88020 r90972  
    936936window.Event.prototype.stopPropagation [function]
    937937window.EventException [object EventExceptionConstructor]
     938window.EventException.DISPATCH_REQUEST_ERR [number]
    938939window.EventException.UNSPECIFIED_EVENT_TYPE_ERR [number]
    939940window.EventException.prototype [object EventExceptionPrototype]
     941window.EventException.prototype.DISPATCH_REQUEST_ERR [number]
    940942window.EventException.prototype.UNSPECIFIED_EVENT_TYPE_ERR [number]
    941943window.EventException.prototype.toString [function]
  • trunk/LayoutTests/fast/workers/resources/worker-event-listener.js

    r38567 r90972  
    88function onmessage(evt)
    99{
    10     try {
    11         removeEventListener("message", onmessage, true);
    12         addEventListener("message", function(e) { e.foo = "bar" }, true);
    13         dispatchEvent(evt);
    14         postMessage((evt.foo == "bar") ? "SUCCESS" : "FAIL");
    15     } catch (ex) {
    16         postMessage(ex);
    17     }
     10    postMessage("SUCCESS");
    1811}
    1912
  • trunk/LayoutTests/platform/gtk/fast/dom/Window/window-properties-expected.txt

    r89294 r90972  
    936936window.Event.prototype.stopPropagation [function]
    937937window.EventException [object EventExceptionConstructor]
     938window.EventException.DISPATCH_REQUEST_ERR [number]
    938939window.EventException.UNSPECIFIED_EVENT_TYPE_ERR [number]
    939940window.EventException.prototype [object EventExceptionPrototype]
     941window.EventException.prototype.DISPATCH_REQUEST_ERR [number]
    940942window.EventException.prototype.UNSPECIFIED_EVENT_TYPE_ERR [number]
    941943window.EventException.prototype.toString [function]
  • trunk/LayoutTests/platform/qt-wk2/fast/dom/Window/window-properties-expected.txt

    r89732 r90972  
    932932window.Event.prototype.stopPropagation [function]
    933933window.EventException [object EventExceptionConstructor]
     934window.EventException.DISPATCH_REQUEST_ERR [number]
    934935window.EventException.UNSPECIFIED_EVENT_TYPE_ERR [number]
    935936window.EventException.prototype [object EventExceptionPrototype]
     937window.EventException.prototype.DISPATCH_REQUEST_ERR [number]
    936938window.EventException.prototype.UNSPECIFIED_EVENT_TYPE_ERR [number]
    937939window.EventException.prototype.toString [function]
  • trunk/LayoutTests/platform/qt/fast/dom/Window/window-properties-expected.txt

    r89732 r90972  
    932932window.Event.prototype.stopPropagation [function]
    933933window.EventException [object EventExceptionConstructor]
     934window.EventException.DISPATCH_REQUEST_ERR [number]
    934935window.EventException.UNSPECIFIED_EVENT_TYPE_ERR [number]
    935936window.EventException.prototype [object EventExceptionPrototype]
     937window.EventException.prototype.DISPATCH_REQUEST_ERR [number]
    936938window.EventException.prototype.UNSPECIFIED_EVENT_TYPE_ERR [number]
    937939window.EventException.prototype.toString [function]
  • trunk/Source/WebCore/ChangeLog

    r90971 r90972  
     12011-07-12  Dominic Cooney  <dominicc@chromium.org>
     2
     3        Raise if dispatchEvent dispatches an event that is being dispatched
     4        https://bugs.webkit.org/show_bug.cgi?id=64150
     5
     6        Reviewed by Dimitri Glazkov.
     7
     8        Spec: http://www.w3.org/TR/DOM-Level-3-Events/#events-EventTarget-dispatchEvent
     9
     10        Test: fast/events/dispatch-event-being-dispatched.html
     11
     12        * dom/Event.h:
     13        (WebCore::Event::isBeingDispatched): Added.
     14        * dom/EventException.h:
     15        * dom/EventException.idl: Add DISPATCH_REQUEST_ERR.
     16        * dom/EventTarget.cpp:
     17        (WebCore::EventTarget::dispatchEvent): Raise if being dispatched.
     18        * dom/ExceptionCode.cpp: Add gunk for DISPATCH_REQUEST_ERR.
     19
    1202011-07-13  Kent Tamura  <tkent@chromium.org>
    221
  • trunk/Source/WebCore/dom/Event.h

    r89044 r90972  
    172172        virtual Clipboard* clipboard() const { return 0; }
    173173
     174        bool isBeingDispatched() const { return eventPhase(); }
    174175
    175176    protected:
  • trunk/Source/WebCore/dom/EventException.h

    r34432 r90972  
    4545
    4646        enum EventExceptionCode {
    47             UNSPECIFIED_EVENT_TYPE_ERR = EventExceptionOffset
     47            UNSPECIFIED_EVENT_TYPE_ERR = EventExceptionOffset,
     48            DISPATCH_REQUEST_ERR
    4849        };
    4950
  • trunk/Source/WebCore/dom/EventException.idl

    r89269 r90972  
    4646        // EventExceptionCode
    4747        const unsigned short UNSPECIFIED_EVENT_TYPE_ERR = 0;
    48 
     48        const unsigned short DISPATCH_REQUEST_ERR = 1;
    4949    };
    5050
  • trunk/Source/WebCore/dom/EventTarget.cpp

    r89567 r90972  
    327327    }
    328328
     329    if (event->isBeingDispatched()) {
     330        ec = EventException::DISPATCH_REQUEST_ERR;
     331        return false;
     332    }
     333
    329334    if (!scriptExecutionContext())
    330335        return false;
     
    338343    event->setCurrentTarget(this);
    339344    event->setEventPhase(Event::AT_TARGET);
    340     return fireEventListeners(event.get());
     345    bool defaultPrevented = fireEventListeners(event.get());
     346    event->setEventPhase(0);
     347    return defaultPrevented;
    341348}
    342349
     
    448455
    449456} // namespace WebCore
    450 
  • trunk/Source/WebCore/dom/ExceptionCode.cpp

    r87961 r90972  
    113113
    114114static const char* const eventExceptionNames[] = {
    115     "UNSPECIFIED_EVENT_TYPE_ERR"
     115    "UNSPECIFIED_EVENT_TYPE_ERR",
     116    "DISPATCH_REQUEST_ERR"
    116117};
    117118
    118119static const char* const eventExceptionDescriptions[] = {
    119     "The Event's type was not specified by initializing the event before the method was called."
     120    "The Event's type was not specified by initializing the event before the method was called.",
     121    "The Event object is already being dispatched."
    120122};
    121123
Note: See TracChangeset for help on using the changeset viewer.