Add a smart pointer to hold JSValueProtect() objects From bug 239495
Bugs like void setWheelEventMonitorTestCallbackAndStartMonitoring(bool expectWheelEndOrCancel, bool expectMomentumEnd, WebCore::Frame& frame, JSContextRef context, JSObjectRef jsCallbackFunction) { Page* page = frame.page(); if (!page || !page->isMonitoringWheelEvents()) return; JSValueProtect(context, jsCallbackFunction); if (auto wheelEventTestMonitor = page->wheelEventTestMonitor()) { wheelEventTestMonitor->setTestCallbackAndStartMonitoring(expectWheelEndOrCancel, expectMomentumEnd, [=](void) { JSObjectCallAsFunction(context, jsCallbackFunction, nullptr, 0, nullptr, nullptr); JSValueUnprotect(context, jsCallbackFunction); }); } }
<rdar://problem/92513529>