Skip to content

Fix method_replacement leaving own properties for inherited EventTarget - #4739

Merged
kainino0x merged 1 commit into
gpuweb:mainfrom
mwyrzykowski:eng/mikew/method_replacement
Nov 25, 2026
Merged

kainino0x merged 1 commit into
gpuweb:mainfrom
mwyrzykowski:eng/mikew/method_replacement

Conversation

@mwyrzykowski

@mwyrzykowski mwyrzykowski commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Fix method_replacement leaving own properties for inherited EventTarget

webgpu:idl,javascript:method_replacement:type="device" iterates over all methods found on a GPUDevice instance, including addEventListener, dispatchEvent, and removeEventListener, which are inherited from EventTarget.prototype rather than defined as own properties on GPUDevice.prototype.

In the finally block, restoring via ctorPrototype[method] = origFunc unconditionally defines an own property on GPUDevice.prototype instead of removing the temporary override. When webgpu:idl,javascript:device,EventTarget:test="patchingEventTargetAffectsDevice" subsequently runs in the same realm, patching EventTarget.prototype.{addEventListener,dispatchEvent,removeEventListener} has no effect on GPUDevice instances because those methods are now shadowed by the own properties left on GPUDevice.prototype.

Issue: #4738 #4738


Requirements for PR author:

  • All missing test coverage is tracked with "TODO" or .unimplemented().
  • New helpers are /** documented */ and new helper files are found in helper_index.txt.
  • Test behaves as expected in a WebGPU implementation. (If not passing, explain above.)
  • Test have be tested with compatibility mode validation enabled and behave as expected. (If not passing, explain above.)

Requirements for reviewer sign-off:

  • Tests are properly located.
  • Test descriptions are accurate and complete.
  • Tests provide complete coverage (including validation control cases). Missing coverage MUST be covered by TODOs.
  • Tests avoid over-parameterization (see case count report).

When landing this PR, be sure to make any necessary issue status updates.

@github-actions

Copy link
Copy Markdown

Results for build job (at cdf5bea):

 Test case/subcase counts did not change.

@kainino0x kainino0x left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Good find!

@kainino0x
kainino0x merged commit 1d8c6b1 into gpuweb:main Nov 25, 2026
1 check passed
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.

2 participants