Bug 160651

Summary: It should be possible to re-initialize an Event after it's been dispatched
Product: WebKit Reporter: Chris Dumez <cdumez>
Component: DOMAssignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: cdumez, commit-queue, darin, dbates, esprehn+autocc, kangil.han, rniwa, sam
Priority: P2 Keywords: WebExposed
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
URL: https://dom.spec.whatwg.org/#dom-event-initevent
See Also: https://bugs.webkit.org/show_bug.cgi?id=160664
https://bugs.webkit.org/show_bug.cgi?id=160703
Attachments:
Description Flags
Patch
none
Patch none

Description Chris Dumez 2016-08-07 20:22:00 PDT
It should be possible to re-initialize an Event after it's been dispatched:
- https://dom.spec.whatwg.org/#dom-event-initevent

Firefox follows the specification but WebKit prevents re-initialization of an already-dispatched event.
Comment 1 Chris Dumez 2016-08-07 20:26:10 PDT
Created attachment 285556 [details]
Patch
Comment 2 Darin Adler 2016-08-07 21:53:17 PDT
Comment on attachment 285556 [details]
Patch

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

> Source/WebCore/dom/Event.cpp:73
>  void Event::initEvent(const AtomicString& eventTypeArg, bool canBubbleArg, bool cancelableArg)

What about the other init event functions, for the specific types of events? I think they all have their own separate dispatched() checks. Should their behavior change or not? Do we have tests for those?

> Source/WebCore/dom/Event.cpp:76
> -    if (dispatched())
> +    if (isBeingDispatched())
>          return;

I am not sure we have enough test coverage; can't tell from the diff. Are there tests that check that we don’t allow reinitialization while being dispatched?

> Source/WebCore/dom/Event.cpp:83
> +    m_target = nullptr;

I don’t see any test coverage for this change.
Comment 3 Chris Dumez 2016-08-08 09:04:15 PDT
(In reply to comment #2)
> Comment on attachment 285556 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=285556&action=review
> 
> > Source/WebCore/dom/Event.cpp:73
> >  void Event::initEvent(const AtomicString& eventTypeArg, bool canBubbleArg, bool cancelableArg)
> 
> What about the other init event functions, for the specific types of events?
> I think they all have their own separate dispatched() checks. Should their
> behavior change or not? Do we have tests for those?

I don't believe we have testing for the ones in the subclasses. I'll look into those in a follow-up as I suspect they will need updating as well.

> 
> > Source/WebCore/dom/Event.cpp:76
> > -    if (dispatched())
> > +    if (isBeingDispatched())
> >          return;
> 
> I am not sure we have enough test coverage; can't tell from the diff. Are
> there tests that check that we don’t allow reinitialization while being
> dispatched?
> 
> > Source/WebCore/dom/Event.cpp:83
> > +    m_target = nullptr;
> 
> I don’t see any test coverage for this change.

Ok, I'll add a test to make sure this is covered.
Comment 4 Chris Dumez 2016-08-08 09:06:20 PDT
Created attachment 285567 [details]
Patch
Comment 5 WebKit Commit Bot 2016-08-08 09:36:57 PDT
Comment on attachment 285567 [details]
Patch

Clearing flags on attachment: 285567

Committed r204254: <http://trac.webkit.org/changeset/204254>
Comment 6 WebKit Commit Bot 2016-08-08 09:37:01 PDT
All reviewed patches have been landed.  Closing bug.