Skip to content

Add EventTarget WPT test AddEventListenerOptions-once - #34169

Closed
Ethan-Arrowood wants to merge 2 commits into
nodejs:masterfrom
Ethan-Arrowood:add-event-target-wpt
Closed

Add EventTarget WPT test AddEventListenerOptions-once#34169
Ethan-Arrowood wants to merge 2 commits into
nodejs:masterfrom
Ethan-Arrowood:add-event-target-wpt

Conversation

@Ethan-Arrowood

@Ethan-ArrowoodEthan-Arrowood commented Jul 2, 2020

Copy link
Copy Markdown
Contributor
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-botnodejs-github-bot added the test Issues and PRs related to the tests. label Jul 2, 2020
@Ethan-ArrowoodEthan-Arrowood mentioned this pull request Jul 2, 2020
3 tasks
Comment threadtest/parallel/test-eventtarget-whatwg-once.js Outdated

@benjamingrbenjamingr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM + please add the reference - thanks for this!

@Ethan-ArrowoodEthan-Arrowood changed the title Add EventTarget WPT testsAdd EventTarget WPT test AddEventListenerOptions-onceJul 2, 2020
@Ethan-Arrowood
Ethan-Arrowood marked this pull request as ready for review July 2, 2020 15:51
@Ethan-Arrowood

Copy link
Copy Markdown
ContributorAuthor

This test is what is failing the CI: https://github.com/nodejs/node/pull/34169/checks?check_run_id=831452407#step:11:10071

Any ideas?

Comment threadtest/parallel/test-eventtarget-whatwg-once.js Outdated
Comment threadtest/parallel/test-eventtarget-whatwg-once.js Outdated
Comment threadtest/parallel/test-eventtarget-whatwg-passive.js Outdated
@Ethan-Arrowood

Ethan-Arrowood commented Jul 7, 2020

Copy link
Copy Markdown
ContributorAuthor

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:

{constdocument=newEventTarget();consthandler=common.mustCall(2)// Both should only fire on first eventdocument.addEventListener('test',handler,{once: true});document.addEventListener('test',handler,{once: true});// Fire eventsdocument.dispatchEvent(newEvent('test'));document.dispatchEvent(newEvent('test'));}

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

@jasnell

Copy link
Copy Markdown
Member

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
Copy Markdown
ContributorAuthor

Awesome worked like a charm! Thank you

@Ethan-Arrowood

Copy link
Copy Markdown
ContributorAuthor

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
Copy Markdown
Member

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

Comment threadtest/parallel/test-eventtarget-whatwg-customevent.js Outdated
@lundibundi

Copy link
Copy Markdown
Member

@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.

Comment threadtest/parallel/test-eventtarget-whatwg-customevent.js Outdated
Comment threadtest/parallel/test-eventtarget-whatwg-customevent.js Outdated
@Ethan-Arrowood

Copy link
Copy Markdown
ContributorAuthor

Alright squashed and fixed up your comments.

Comment threadtest/parallel/test-eventtarget-whatwg-customevent.js Outdated
@lundibundilundibundi added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Aug 24, 2020
@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot

This comment has been minimized.

@Ethan-ArrowoodEthan-Arrowood mentioned this pull request Nov 6, 2020
4 tasks
@Ethan-Arrowood

Copy link
Copy Markdown
ContributorAuthor

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

Comment threadtest/parallel/test-eventtarget-whatwg-once.js Outdated
@aduh95aduh95 added dont-land-on-v10.x request-ci Add this label to start a Jenkins CI on a PR. labels Nov 6, 2020
@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Nov 9, 2020
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@Ethan-Arrowood

Copy link
Copy Markdown
ContributorAuthor

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

@aduh95

Copy link
Copy Markdown
Contributor

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

@aduh95aduh95 removed the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. 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
Comment threadtest/parallel/test-eventtarget-whatwg-once.js Outdated
@aduh95aduh95 added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. request-ci Add this label to start a Jenkins CI on a PR. labels Nov 9, 2020
@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Nov 9, 2020
@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

aduh95 pushed a commit that referenced this pull request 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
Copy Markdown
Contributor

Landed in 7cba786

@aduh95aduh95 closed this Nov 10, 2020
codebytere pushed a commit that referenced this pull request 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>
@codebyterecodebytere mentioned this pull request Nov 22, 2020
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author readyPRs that have at least one approval, no pending requests for changes, and a CI started.testIssues and PRs related to the tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants

@Ethan-Arrowood@jasnell@lundibundi@nodejs-github-bot@aduh95@benjamingr@richardlau