Skip to content

test: add coverage for removeEventListener boolean capture - #65245

Open
lazerg wants to merge 1 commit into
nodejs:mainfrom
lazerg:fix/issue-65244-remove-listener-capture-boolean
Open

test: add coverage for removeEventListener boolean capture#65245
lazerg wants to merge 1 commit into
nodejs:mainfrom
lazerg:fix/issue-65244-remove-listener-capture-boolean

Conversation

@lazerg

@lazerg lazerg commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

removeEventListener() read capture off the options object only, so the boolean shorthand target.removeEventListener('foo', fn, true) was flattened to capture: false and never matched a listener registered with capture on. addEventListener() already handles the boolean form, so the two went out of sync and the listener stayed attached. Browsers remove it.

Fixes #65244

@nodejs-github-bot nodejs-github-bot added the needs-ci PRs that need a full CI run. label Aug 12, 2026
@codecov

codecov Bot commented Aug 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.20%. Comparing base (f96dccc) to head (66ee4d8).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #65245      +/-   ##
==========================================
+ Coverage   90.15%   90.20%   +0.04%     
==========================================
  Files         751      751              
  Lines      253443   253443              
  Branches    47729    47756      +27     
==========================================
+ Hits       228496   228622     +126     
+ Misses      16201    16072     -129     
- Partials     8746     8749       +3     

see 37 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@trivikr

trivikr commented Aug 23, 2026

Copy link
Copy Markdown
Member

This needs a rebase.

removeEventListener(type, fn, true) never matched a listener added
the same way, because removeEventListener compared
options?.capture === true directly while addEventListener flattened
a boolean third argument via validateEventListenerOptions().

The underlying fix landed independently in nodejs#64894 (worker:
add support for Web Workers), as a side effect of an unrelated
refactor, so this PR now only adds the regression test that would
have caught it. WPT does not cover this path: the
EventTarget-removeEventListener.any.js test is skipped in
test/wpt/status/dom/events.json.

Fixes: nodejs#65244
Signed-off-by: Lazizbek Ergashev <lazerg2@gmail.com>
@lazerg
lazerg force-pushed the fix/issue-65244-remove-listener-capture-boolean branch from dd80e58 to 66ee4d8 Compare August 23, 2026 22:13
@trivikr trivikr changed the title events: accept boolean options in removeEventListener test: add coverage for removeEventListener boolean capture Aug 23, 2026
@trivikr trivikr added request-ci Add this label to start a Jenkins CI on a PR. test Issues and PRs related to the tests. labels Aug 23, 2026
@lazerg

lazerg commented Aug 23, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto main. The removeEventListener fix already landed in #64894, an unrelated Web Workers PR, as a side effect of that change. So this PR now only adds the regression test. WPT skips this test path (EventTarget-removeEventListener.any.js), so nothing else guards against this bug coming back. CI is green.

@trivikr trivikr added the author ready PRs that have at least one approval, no outstanding review comments, and a CI started. label Aug 23, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Aug 23, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs that have at least one approval, no outstanding review comments, and a CI started. needs-ci PRs that need a full CI run. test Issues and PRs related to the tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

EventTarget removeEventListener does not match all listeners

4 participants