X Tutup
The Wayback Machine - https://web.archive.org/web/20220322223620/https://github.com/nodejs/node/pull/34169
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

Add EventTarget WPT test AddEventListenerOptions-once #34169

Closed

Conversation

Ethan-Arrowood
Copy link
Contributor

@Ethan-Arrowood Ethan-Arrowood commented Jul 2, 2020

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

First of many PRs adding WPT tests for EventTarget (and eventually AbortController)

@nodejs-github-bot nodejs-github-bot added the test label Jul 2, 2020
Copy link
Member

@benjamingr benjamingr left a comment

LGTM + please add the reference - thanks for this!

@Ethan-Arrowood Ethan-Arrowood changed the title Add EventTarget WPT tests Add EventTarget WPT test AddEventListenerOptions-once Jul 2, 2020
@Ethan-Arrowood Ethan-Arrowood marked this pull request as ready for review Jul 2, 2020
@Ethan-Arrowood Ethan-Arrowood requested a review from benjamingr Jul 2, 2020
@Ethan-Arrowood
Copy link
Contributor Author

@Ethan-Arrowood Ethan-Arrowood commented Jul 7, 2020

jasnell
jasnell approved these changes Jul 7, 2020
@Ethan-Arrowood
Copy link
Contributor Author

@Ethan-Arrowood Ethan-Arrowood commented Jul 7, 2020

New commit moves away from the count checking and reorganizes the tests using mustCall. This now deviates a bit from the WPT tests but I believe achieves the same thing. If this is not the intended change I can revert the last commit!

One note; I tried implementing this:

{
  const document = new EventTarget();

  const handler = common.mustCall(2)
  // Both should only fire on first event
  document.addEventListener('test', handler, { once: true });
  document.addEventListener('test', handler, { once: true });
  // Fire events
  document.dispatchEvent(new Event('test'));
  document.dispatchEvent(new Event('test'));
}

But it fails - probably my own misunderstanding of common.mustCall. Maybe you two have some in sight here?

@jasnell
Copy link
Member

@jasnell jasnell commented Jul 7, 2020

It's failing because, unlike EventEmitter, a given function can only be added once. So the second document.addEventListener('test', handler, { once: true }); has no effect. Try changing it to document.addEventListener('test', handler.bind(), { once: true }); and it should hopefully work.

@Ethan-Arrowood
Copy link
Contributor Author

@Ethan-Arrowood Ethan-Arrowood commented Jul 7, 2020

Awesome worked like a charm! Thank you

jasnell
jasnell approved these changes Jul 8, 2020
@Ethan-Arrowood
Copy link
Contributor Author

@Ethan-Arrowood Ethan-Arrowood commented Aug 3, 2020

Hey! I have another test file ready to go. Should I push it to this PR/branch or include it in another branch?

@jasnell
Copy link
Member

@jasnell jasnell commented Aug 3, 2020

@Ethan-Arrowood ... just push it here. We can do another CI run on this and give it another day to land.

jasnell
jasnell approved these changes Aug 3, 2020
@lundibundi
Copy link
Member

@lundibundi lundibundi commented Aug 23, 2020

@Ethan-Arrowood could you please squash/fixup the appropriate commits and remove the merge commit, our CI doesn't handle merge commits very well? This looks ready to land to me after a successful CI.

@Ethan-Arrowood
Copy link
Contributor Author

@Ethan-Arrowood Ethan-Arrowood commented Aug 24, 2020

Alright squashed and fixed up your comments.

@lundibundi lundibundi added the author ready label Aug 24, 2020
@nodejs-github-bot

This comment has been hidden.

@nodejs-github-bot

This comment has been hidden.

@Ethan-Arrowood
Copy link
Contributor Author

@Ethan-Arrowood Ethan-Arrowood commented Nov 6, 2020

This pr #33621 introduces some conflicts with test-eventtarget-whatwg-once.js.

I'm pushing another rebase that fixes some of that. I guess this PR needs to be reviewed again

@aduh95 aduh95 added dont-land-on-v10.x dont-land-on-v12.x dont-land-on-v14.x request-ci labels Nov 6, 2020
@github-actions github-actions bot removed the request-ci label Nov 9, 2020
@nodejs-github-bot
Copy link
Contributor

@nodejs-github-bot nodejs-github-bot commented Nov 9, 2020

@Ethan-Arrowood
Copy link
Contributor Author

@Ethan-Arrowood Ethan-Arrowood commented Nov 9, 2020

@aduh95 let me know if theres anything else I should do here

@aduh95
Copy link
Contributor

@aduh95 aduh95 commented Nov 9, 2020

@Ethan-Arrowood can you rebase to resolve the git conflict please?

@aduh95 aduh95 removed the author ready label Nov 9, 2020
add reference comments for WPT tests

convert to common mustCall

Update test/parallel/test-eventtarget-whatwg-once.js

Co-authored-by: James M Snell <jasnell@gmail.com>

Update test/parallel/test-eventtarget-whatwg-passive.js

Co-authored-by: James M Snell <jasnell@gmail.com>

convert other tests to utilize common mustcall

improve test with bind

add customevent wpt

add no-unused-vars comment

reorder header

utilize common.mustcall

remove internal and use global EventTarget
@aduh95 aduh95 added author ready request-ci labels Nov 9, 2020
@github-actions github-actions bot removed the request-ci label Nov 9, 2020
@nodejs-github-bot

This comment has been hidden.

@nodejs-github-bot

This comment has been hidden.

@nodejs-github-bot
Copy link
Contributor

@nodejs-github-bot nodejs-github-bot commented Nov 10, 2020

aduh95 added a commit that referenced this issue Nov 10, 2020
Add WPT AddEventListenerOptions-once test.

PR-URL: #34169
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
@aduh95
Copy link
Contributor

@aduh95 aduh95 commented Nov 10, 2020

Landed in 7cba786

@aduh95 aduh95 closed this Nov 10, 2020
codebytere added a commit that referenced this issue Nov 22, 2020
Add WPT AddEventListenerOptions-once test.

PR-URL: #34169
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
@codebytere codebytere mentioned this pull request Nov 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready dont-land-on-v12.x dont-land-on-v14.x test
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

7 participants
X Tutup