Closed Bug 1263937 Opened 9 years ago Closed 9 years ago

Dispatching an event should not unset stop propagation flag

Categories

(Core :: DOM: Events, defect)

defect
Not set
normal

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: ayg, Assigned: ayg)

Details

(Whiteboard: btpp-active)

Test: <!DOCTYPE html> <script> document.documentElement.textContent = "pass"; var ev = document.createEvent("Event"); ev.initEvent("type", false, false); ev.stopPropagation(); document.addEventListener("type", function() { document.documentElement.textContent = "fail" }, false); document.dispatchEvent(ev); document.dispatchEvent(ev); </script> We fail. IE 11 and Chrome pass. This is tested by <http://w3c-test.org/dom/events/Event-initEvent.html> (which we have in-tree under testing/web-platform/tests/). I looked at the code but can't figure out where to fix it. Masayuki, could you give me a pointer?
Flags: needinfo?(masayuki)
See the latter half of EventTargetChainItem::HandleEventTargetChain. We should clear the flags for system group dispatch, but then return back the values default group had before we return from the method.
Flags: needinfo?(masayuki)
Whiteboard: btpp-active
smaug said in bug 698929 comment 6 that he wants the spec to change here. Filed an issue: https://github.com/whatwg/dom/issues/219
It looks like we reset the defaultPrevented flag only on initEvent. Do you think we should change the propagation flags to match defaultPrevented, which is also what Chrome and Safari do? Or change defaultPrevented to reset on dispatch instead of (or in addition to) init? I don't know if any implementations reset defaultPrevented on dispatch -- I couldn't get IE 11 to work in testing. Also, if we do reset on dispatch, it makes the most sense to reset at the beginning of dispatch, not the end (and not to reset in initEvent).
Flags: needinfo?(bugs)
(In reply to :Aryeh Gregor (working until May 8) from comment #3) > It looks like we reset the defaultPrevented flag only on initEvent. Do you > think we should change the propagation flags to match defaultPrevented, > which is also what Chrome and Safari do? Meaning what? That initEvent would clear all those flags, but end of dispatchEvent wouldn't clear any? > Or change defaultPrevented to > reset on dispatch instead of (or in addition to) init? defaultPrevented shouldn't change after dispatchEvent(), since one could check that value after dispatch. > Also, if we do reset on dispatch, it makes the most sense to reset at the > beginning of dispatch, not the end (and not to reset in initEvent). Oh, that. We'll what do other browsers do?
Flags: needinfo?(bugs)
(In reply to Olli Pettay [:smaug] from comment #4) > Meaning what? That initEvent would clear all those flags, but end of > dispatchEvent wouldn't clear any? Yes. That's what Blink/WebKit do, and what the current spec says. > defaultPrevented shouldn't change after dispatchEvent(), since one could > check that value after dispatch. It could be reset at the beginning of dispatch, though. (But I don't think other browsers do that.) > Oh, that. We'll what do other browsers do? Blink/WebKit apparently only reset any of the flags (propagation/immediate propagation/default prevented) on initEvent(). IE 11 resets propagation and immediate propagation flags at the end of dispatchEvent(), but not for initEvent(), so we match them for those two. I can't get .preventDefault() to work in IE 11 (.defaultPrevented is always false), and the Edge VM I downloaded hung on startup, so I don't know about that one.
Flags: needinfo?(bugs)
So initEvent could definitely clear the flags, but we need to fix also the system group handling so that if something in system group stops propagation, it doesn't show up in the next dispatch times. So, reset the propagation stopped value after dispatch to the state it was after default group dispatching. (and if spec will change, clear the flags at the end of dispatch.)
Flags: needinfo?(bugs)
Looks like the spec has been changed to match us: https://github.com/whatwg/dom/issues/219 Test updates are underway upstream: https://github.com/w3c/web-platform-tests/pull/3469
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.