Skip to content

Should not opened in window if the default behavior was prevented inside the event handler (for #5910 in TestCafe) #2582

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

Merged
merged 2 commits into from
Feb 9, 2021

Conversation

AlexKamaev
Copy link
Contributor

@AlexKamaev AlexKamaev commented Feb 5, 2021

New mechanism of postHandlers which will be called after all user handlers are called.
This mechanism allows us to prevent opening of new window in multiple window mode, if the event was prevented inside on the user listeners

@AlexKamaev AlexKamaev marked this pull request as draft February 5, 2021 09:58
@AlexKamaev AlexKamaev closed this Feb 5, 2021
@AlexKamaev AlexKamaev reopened this Feb 5, 2021
@testcafe-build-bot
Copy link
Collaborator

✅ Tests for the commit ae38370 have passed. See details.

if (!settings.get().allowMultipleWindows)
return;

window.addEventListener('click', e => {
Copy link
Contributor

@miherlosev miherlosev Feb 8, 2021

Choose a reason for hiding this comment

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

Use a native method for addEventListener method here.
@LavrovArtem if it's possible add this method to eslint-plugin-hammerhead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this PR is still in DRAFT. I discussed this approach with @LavrovArtem and we decided to modify it

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ready, please review

@testcafe-build-bot
Copy link
Collaborator

✅ Tests for the commit 37a87e2 have passed. See details.

@AlexKamaev AlexKamaev marked this pull request as ready for review February 8, 2021 11:14
@@ -29,6 +29,7 @@ export function addListeningElement (el, events) {
internalHandlers: [],
outerHandlers: [],
outerHandlersWrapper: null,
postHandlers: [],
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't like this name because it can be understood in several ways.

It's internal hammerhead handlers, which are called last.

I guess, the internalHandlers are handlers which are called before users' scripts.
So, I propose to clean up the code and perform some renames:
internalHandlers -> internalBeforeHanlders
postHandlers -> internlaAfterHanlders

@LavrovArtem What do you think about it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like this suggestion

@AlexKamaev
Copy link
Contributor Author

Tests in TestCafe failed since TestCafe requires update as well:
DevExpress/testcafe#5928

@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit d211a3a have failed. See details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants