Bug 160651 - It should be possible to re-initialize an Event after it's been dispatched
Summary: It should be possible to re-initialize an Event after it's been dispatched
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL: https://dom.spec.whatwg.org/#dom-even...
Keywords: WebExposed
Depends on:
Blocks:
 
Reported: 2016-08-07 20:22 PDT by Chris Dumez
Modified: 2016-08-09 12:38 PDT (History)
8 users (show)

See Also:


Attachments
Patch (3.83 KB, patch)
2016-08-07 20:26 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (8.95 KB, patch)
2016-08-08 09:06 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.