Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix event handler processing algorithm special cases #2428

Merged
merged 4 commits into from
Mar 15, 2017

Conversation

domenic
Copy link
Member

@domenic domenic commented Mar 9, 2017

This is a follow-up to 7163372, which
forgot about the case of ErrorEvents whose type is not "error", and
BeforeUnloadEvents whose type is not "beforeunload", as noted in #2398.

/cc @bzbarsky

Tests: web-platform-tests/wpt#5109

After this gets merged I need to file all the browser bugs for #2398.

This is a follow-up to 7163372, which
forgot about the case of new ErrorEvent("click", ...), as noted in
#2398 (comment).
@bzbarsky
Copy link
Contributor

bzbarsky commented Mar 9, 2017

After this gets merged I need to file all the browser bugs for #2398.

Fwiw, I filed https://bugzilla.mozilla.org/show_bug.cgi?id=1345996 already for Gecko.

@bzbarsky
Copy link
Contributor

bzbarsky commented Mar 9, 2017

This looks good for the error case. I still think it would be better to make similar changes for the "beforeunload" case, because I'm not very happy relying on no one adding a BeforeUnloadEvent constructor.

Actually, I wonder what browser behavior is around non-BeforeUnloadEvent objects with type "beforeunloadevent". In this case, the handler will be a BeforeUnloadEventHandler, so return values will be converted to string-or-null. So if the event is not a BeforeUnloadEvent (e.g. new Event("beforeunload", { cancelable: true }), we will never cancel it, though that's not imemdiately obvious from the spec. That does match what Gecko does, at least; can't speak for others.

@domenic
Copy link
Member Author

domenic commented Mar 9, 2017

For the case of new CustomEvent("beforeunload", { cancelable: true }) with a handler that returns false, it appears everyone except Gecko cancels the event. We should probably update the spec to key off the event handler type then... I'll update the spec.

@bzbarsky
Copy link
Contributor

bzbarsky commented Mar 9, 2017

We should probably update the spec to key off the event handler type then

That won't help. The handler type is BeforeUnloadEventHandler, since the handler type matches the event type.

@bzbarsky
Copy link
Contributor

bzbarsky commented Mar 9, 2017

As in, it sounds like non-Gecko engines do not have OnBeforeUnloadEventHandlerNonNull at all and instead hand-roll something on top of EventHandlerNonNull or something.

@domenic
Copy link
Member Author

domenic commented Mar 9, 2017

Yes, that was the conclusion I was coming to as well. I think I am OK going with Gecko on this one even though it's in the minority, because it is a worthwhile goal to have these be implementable in Web IDL.

domenic added a commit to web-platform-tests/wpt that referenced this pull request Mar 9, 2017
Follows whatwg/html#2428. This also fixes beforeunload-canceling.html to use promise_test instead of async_test to avoid running two tests concurrently.
domenic added a commit to web-platform-tests/wpt that referenced this pull request Mar 9, 2017
Follows whatwg/html#2428. This also fixes beforeunload-canceling.html to use promise_test instead of async_test to avoid running two tests concurrently.
@domenic domenic changed the title Fix "special error event handling" for event handlers Fix event handler processing algorithm special cases Mar 9, 2017
@domenic
Copy link
Member Author

domenic commented Mar 9, 2017

OK, PTAL @bzbarsky. I've updated the OP and also added tests.

Copy link
Contributor

@bzbarsky bzbarsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thank you!

@domenic domenic merged commit c065e99 into master Mar 15, 2017
@domenic domenic deleted the event-handler-processing-fixup branch March 15, 2017 20:16
domenic added a commit to web-platform-tests/wpt that referenced this pull request Mar 15, 2017
Follows whatwg/html#2428. This also fixes beforeunload-canceling.html to use promise_test instead of async_test to avoid running two tests concurrently.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

2 participants