LayoutTests/ChangeLog

 12011-07-08 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 NOBODY (OOPS!).
 7
 8 * fast/dom/Window/window-properties-expected.txt: Add DISPATCH_REQUEST_ERR.
 9 * fast/events/dispatch-event-being-dispatched-expected.txt: Added.
 10 * fast/events/dispatch-event-being-dispatched.html: Added.
 11 * platform/gtk/fast/dom/Window/window-properties-expected.txt:
 12 * platform/qt-wk2/fast/dom/Window/window-properties-expected.txt:
 13 * platform/qt/fast/dom/Window/window-properties-expected.txt:
 14
1152011-07-07 Kent Tamura <tkent@chromium.org>
216
317 [Chromium] Update baseline files for input-appearance-range.html.

LayoutTests/fast/dom/Window/window-properties-expected.txt

@@window.Event.prototype.preventDefault [function]
935935window.Event.prototype.stopImmediatePropagation [function]
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]
942944window.EventSource [object EventSourceConstructor]

LayoutTests/fast/events/dispatch-event-being-dispatched-expected.txt

 1Tests that dispatchEvent raises DISPATCH_REQUEST_ERR if the event being dispatched is already being dispatched.
 2
 3PASS should have got DISPATCH_REQUEST_ERR EventException
 4PASS redispatchCustom.wasInvoked is true
 5PASS should have got DISPATCH_REQUEST_ERR EventException
 6PASS checkCustom.wasInvoked is true
 7PASS should have got DISPATCH_REQUEST_ERR EventException
 8PASS successfullyParsed is true
 9
 10TEST COMPLETE
 11

LayoutTests/fast/events/dispatch-event-being-dispatched.html

 1<!DOCTYPE html>
 2<html>
 3<head>
 4<script src="../js/resources/js-test-pre.js"></script>
 5</head>
 6<body>
 7<p class="description">
 8Tests that dispatchEvent raises DISPATCH_REQUEST_ERR if the event
 9being dispatched is already being dispatched.
 10</p>
 11<pre id="console">
 12</pre>
 13<script>
 14if (window.layoutTestController)
 15 layoutTestController.dumpAsText();
 16
 17jsTestIsAsync = true;
 18
 19function shouldBeDispatchRequestErr(exception) {
 20 var ok = EventException.prototype.isPrototypeOf(exception) && exception.code == EventException.DISPATCH_REQUEST_ERR;
 21 (ok ? testPassed : testFailed)("should have got DISPATCH_REQUEST_ERR EventException");
 22}
 23
 24// try redispatching an event in the process of being dispatched with
 25// dispatchEvent
 26
 27function redispatchCustom(event) {
 28 try {
 29 window.dispatchEvent(event);
 30 testFailed('dispatchEvent of an event being dispatched should throw an exception');
 31 } catch (ex) {
 32 shouldBeDispatchRequestErr(ex);
 33 }
 34
 35 redispatchCustom.wasInvoked = true;
 36}
 37
 38var customEvent = document.createEvent('CustomEvent');
 39customEvent.initCustomEvent('foo', true, true, null);
 40var p = document.querySelector('.description');
 41p.addEventListener('foo', redispatchCustom);
 42p.dispatchEvent(customEvent);
 43shouldBeTrue('redispatchCustom.wasInvoked');
 44
 45// try redispatching an event that has already finished being dispatched
 46
 47function checkCustom(event) {
 48 checkCustom.wasInvoked = true;
 49}
 50
 51p.removeEventListener('foo', redispatchCustom, true);
 52p.addEventListener('foo', checkCustom, true);
 53p.dispatchEvent(customEvent);
 54shouldBeTrue('checkCustom.wasInvoked');
 55
 56// try redispatching an event in the process of being dispatched by
 57// the browser
 58
 59function redispatchLoad(event) {
 60 if (redispatchLoad.dispatching) {
 61 testFailed('dispatchEvent of an event being dispatched should not dispatch the event again');
 62 return;
 63 }
 64
 65 try {
 66 redispatchLoad.dispatching = true;
 67 document.dispatchEvent(event);
 68 testFailed('dispatchEvent of an event being dispatched should throw an exception');
 69 } catch (ex) {
 70 shouldBeDispatchRequestErr(ex);
 71 } finally {
 72 delete redispatchLoad.dispatching;
 73 }
 74
 75 finishJSTest();
 76}
 77
 78window.addEventListener('load', redispatchLoad, true);
 79
 80var successfullyParsed = true;
 81</script>
 82<script src="../js/resources/js-test-post.js"></script>
 83</body>
 84</html>

LayoutTests/platform/gtk/fast/dom/Window/window-properties-expected.txt

@@window.Event.prototype.preventDefault [function]
935935window.Event.prototype.stopImmediatePropagation [function]
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]
942944window.EventSource [object EventSourceConstructor]

LayoutTests/platform/qt-wk2/fast/dom/Window/window-properties-expected.txt

@@window.Event.prototype.preventDefault [function]
931931window.Event.prototype.stopImmediatePropagation [function]
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]
938940window.EventSource [object EventSourceConstructor]

LayoutTests/platform/qt/fast/dom/Window/window-properties-expected.txt

@@window.Event.prototype.preventDefault [function]
931931window.Event.prototype.stopImmediatePropagation [function]
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]
938940window.EventSource [object EventSourceConstructor]

Source/WebCore/ChangeLog

 12011-07-08 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 NOBODY (OOPS!).
 7
 8 Test: fast/events/dispatch-event-being-dispatched.html
 9
 10 * dom/Event.h:
 11 (WebCore::Event::isBeingDispatched): Added.
 12 * dom/EventException.h:
 13 * dom/EventException.idl: Add DISPATCH_REQUEST_ERR.
 14 * dom/EventTarget.cpp:
 15 (WebCore::EventTarget::dispatchEvent): Raise if being dispatched.
 16 * dom/ExceptionCode.cpp: Add gunk for DISPATCH_REQUEST_ERR.
 17
1182011-07-07 Emil A Eklund <eae@chromium.org>
219
320 Switch HitTestResult to to new layout types

Source/WebCore/dom/Event.h

@@namespace WebCore {
171171
172172 virtual Clipboard* clipboard() const { return 0; }
173173
 174 bool isBeingDispatched() const { return eventPhase(); }
174175
175176 protected:
176177 Event();

Source/WebCore/dom/EventException.h

@@namespace WebCore {
4444 static const int EventExceptionMax = 199;
4545
4646 enum EventExceptionCode {
47  UNSPECIFIED_EVENT_TYPE_ERR = EventExceptionOffset
 47 UNSPECIFIED_EVENT_TYPE_ERR = EventExceptionOffset,
 48 DISPATCH_REQUEST_ERR
4849 };
4950
5051 private:

Source/WebCore/dom/EventException.idl

@@module events {
4545
4646 // EventExceptionCode
4747 const unsigned short UNSPECIFIED_EVENT_TYPE_ERR = 0;
48 
 48 const unsigned short DISPATCH_REQUEST_ERR = 1;
4949 };
5050
5151}

Source/WebCore/dom/EventTarget.cpp

@@bool EventTarget::dispatchEvent(PassRefPtr<Event> event, ExceptionCode& ec)
326326 return false;
327327 }
328328
 329 if (event->isBeingDispatched()) {
 330 ec = EventException::DISPATCH_REQUEST_ERR;
 331 return false;
 332 }
 333
329334 if (!scriptExecutionContext())
330335 return false;
331336

@@EventListener* EventListenerIterator::nextListener()
447452}
448453
449454} // namespace WebCore
450 

Source/WebCore/dom/ExceptionCode.cpp

@@static const char* const rangeExceptionDescriptions[] = {
112112};
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
122124static const char* const xmlHttpRequestExceptionNames[] = {