WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
312797
[Swift Testing] Add Swift-callable wrapper around InstanceMethodSwizzler for TestWebKitAPI
https://bugs.webkit.org/show_bug.cgi?id=312797
Summary
[Swift Testing] Add Swift-callable wrapper around InstanceMethodSwizzler for ...
zak ridouh
Reported
2026-04-20 12:29:22 PDT
The C++ InstanceMethodSwizzler RAII helper is gated behind #ifdef __cplusplus and is not callable from Swift, so Swift tests in TestWebKitAPI cannot mock Objective-C runtime behavior. This is the first piece of infrastructure needed to port AppKit-heavy tests (NSMenu pop-ups, gesture recognizers, drag-and-drop) to the new Swift Testing framework. Add TestMethodSwizzler, a thin @interface around InstanceMethodSwizzler that takes a block, runs it through imp_implementationWithBlock, and restores the original implementation in -dealloc. Swift callers hold the swizzler in a local binding for as long as the swizzle should remain in effect, mirroring the C++ RAII pattern. Add a smoke test that swizzles a no-arg Int-returning method on a Swift @objc class, verifies the replacement IMP is called, and verifies the original is restored once the swizzler is dropped.
Attachments
Add attachment
proposed patch, testcase, etc.
Radar WebKit Bug Importer
Comment 1
2026-04-20 12:29:28 PDT
<
rdar://problem/175186623
>
zak ridouh
Comment 2
2026-04-20 12:53:56 PDT
Pull request:
https://github.com/WebKit/WebKit/pull/63141
EWS
Comment 3
2026-05-08 00:07:07 PDT
Committed
312863@main
(a41a909424f0): <
https://commits.webkit.org/312863@main
> Reviewed commits have been landed. Closing PR #63141 and removing active labels.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug