Bug 148800

Summary: dispatchEvent() should throw an InvalidStateError if the event's initialized flag is not set
Product: WebKit Reporter: Chris Dumez <cdumez>
Component: DOMAssignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, esprehn+autocc, kangil.han, rniwa, webkit-bug-importer
Priority: P2 Keywords: InRadar, WebExposed
Version: Other   
Hardware: Unspecified   
OS: Unspecified   
URL: https://dom.spec.whatwg.org/#dom-eventtarget-dispatchevent
Bug Depends on: 148883    
Bug Blocks:    
Attachments:
Description Flags
Patch
none
Patch none

Description Chris Dumez 2015-09-04 09:59:42 PDT
dispatchEvent() should throw an InvalidStateError if the event's initialized flag is not set, and should allow dispatching events with an empty type as long as it is initialized:
https://dom.spec.whatwg.org/#dom-eventtarget-dispatchevent (step 1)

Currently, WebKit relies on the event type being empty and throws a UNSPECIFIED_EVENT_TYPE_ERR: DOM Events Exception 0.

This is covered by the following newly imported W3C test:
http/tests/w3c/dom/events/EventTarget-dispatchEvent.html
Comment 1 Chris Dumez 2015-09-04 10:00:35 PDT
rdar://problem/22565782
rdar://problem/22565485
Comment 2 Chris Dumez 2015-09-04 10:48:02 PDT
Created attachment 260597 [details]
Patch
Comment 3 Geoffrey Garen 2015-09-04 13:53:27 PDT
Comment on attachment 260597 [details]
Patch

r=me
Comment 4 WebKit Commit Bot 2015-09-04 14:13:14 PDT
Comment on attachment 260597 [details]
Patch

Clearing flags on attachment: 260597

Committed r189386: <http://trac.webkit.org/changeset/189386>
Comment 5 WebKit Commit Bot 2015-09-04 14:13:24 PDT
All reviewed patches have been landed.  Closing bug.
Comment 6 Alexey Proskuryakov 2015-09-04 22:23:16 PDT
This change appears to have made several tests assert, rolling out.

https://build.webkit.org/results/Apple%20Yosemite%20Debug%20WK2%20(Tests)/r189417%20(6763)/results.html
Comment 7 WebKit Commit Bot 2015-09-04 22:25:06 PDT
Re-opened since this is blocked by bug 148883
Comment 8 Chris Dumez 2015-09-05 11:07:25 PDT
Created attachment 260694 [details]
Patch
Comment 9 Chris Dumez 2015-09-05 11:08:20 PDT
Comment on attachment 260694 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=260694&action=review

> Source/WebCore/dom/EventTarget.cpp:-194
> -    ASSERT(event && !event->type().isEmpty());

Fixed outdated assertion as it is now valid to dispatch an event with an empty type, as long as the event has its initialized flag set to true.
Comment 10 WebKit Commit Bot 2015-09-06 13:41:56 PDT
Comment on attachment 260694 [details]
Patch

Clearing flags on attachment: 260694

Committed r189452: <http://trac.webkit.org/changeset/189452>
Comment 11 WebKit Commit Bot 2015-09-06 13:42:01 PDT
All reviewed patches have been landed.  Closing bug.