Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Cleanup possible WK*Copy/Create leaks in WebKitTestRunner
https://bugs.webkit.org/show_bug.cgi?id=193340

Patch by Joseph Pecoraro <pecoraro@apple.com> on 2019-01-11
Reviewed by David Kilzer.

* WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
(WTR::InjectedBundle::didReceiveMessageToPage):
Pull the strings out into a WKRetainPtr.

* WebKitTestRunner/WebNotificationProvider.cpp:
(WTR::WebNotificationProvider::closeWebNotification):
Adopt the created value into the WKRetainPtr.

* WebKitTestRunner/mac/TestControllerMac.mm:
(WTR::generateWhitelist):
Immediately adopt a created value to avoid potential mistakes.

Canonical link: https://commits.webkit.org/207855@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239871 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
JosephPecoraro authored and webkit-commit-queue committed Jan 11, 2019
1 parent 8513ca4 commit 2aa196a
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 11 deletions.
19 changes: 19 additions & 0 deletions Tools/ChangeLog
@@ -1,3 +1,22 @@
2019-01-11 Joseph Pecoraro <pecoraro@apple.com>

Cleanup possible WK*Copy/Create leaks in WebKitTestRunner
https://bugs.webkit.org/show_bug.cgi?id=193340

Reviewed by David Kilzer.

* WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
(WTR::InjectedBundle::didReceiveMessageToPage):
Pull the strings out into a WKRetainPtr.

* WebKitTestRunner/WebNotificationProvider.cpp:
(WTR::WebNotificationProvider::closeWebNotification):
Adopt the created value into the WKRetainPtr.

* WebKitTestRunner/mac/TestControllerMac.mm:
(WTR::generateWhitelist):
Immediately adopt a created value to avoid potential mistakes.

2019-01-11 Dominik Infuehr <dinfuehr@igalia.com>

Enable DFG on ARM/Linux again
Expand Down
14 changes: 9 additions & 5 deletions Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp
Expand Up @@ -428,11 +428,15 @@ void InjectedBundle::didReceiveMessageToPage(WKBundlePageRef page, WKStringRef m

if (WKStringIsEqualToUTF8CString(messageName, "ResourceLoadStatisticsTelemetryFinished")) {
WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody);

unsigned totalPrevalentResources = (unsigned)WKUInt64GetValue(static_cast<WKUInt64Ref>(WKDictionaryGetItemForKey(messageBodyDictionary, WKStringCreateWithUTF8CString("TotalPrevalentResources"))));
unsigned totalPrevalentResourcesWithUserInteraction = (unsigned)WKUInt64GetValue(static_cast<WKUInt64Ref>(WKDictionaryGetItemForKey(messageBodyDictionary, WKStringCreateWithUTF8CString("TotalPrevalentResourcesWithUserInteraction"))));
unsigned top3SubframeUnderTopFrameOrigins = (unsigned)WKUInt64GetValue(static_cast<WKUInt64Ref>(WKDictionaryGetItemForKey(messageBodyDictionary, WKStringCreateWithUTF8CString("Top3SubframeUnderTopFrameOrigins"))));


WKRetainPtr<WKStringRef> totalPrevalentResourcesKey(AdoptWK, WKStringCreateWithUTF8CString("TotalPrevalentResources"));
WKRetainPtr<WKStringRef> totalPrevalentResourcesWithUserInteractionKey(AdoptWK, WKStringCreateWithUTF8CString("TotalPrevalentResourcesWithUserInteraction"));
WKRetainPtr<WKStringRef> top3SubframeUnderTopFrameOriginsKey(AdoptWK, WKStringCreateWithUTF8CString("Top3SubframeUnderTopFrameOrigins"));

unsigned totalPrevalentResources = (unsigned)WKUInt64GetValue(static_cast<WKUInt64Ref>(WKDictionaryGetItemForKey(messageBodyDictionary, totalPrevalentResourcesKey.get())));
unsigned totalPrevalentResourcesWithUserInteraction = (unsigned)WKUInt64GetValue(static_cast<WKUInt64Ref>(WKDictionaryGetItemForKey(messageBodyDictionary, totalPrevalentResourcesWithUserInteractionKey.get())));
unsigned top3SubframeUnderTopFrameOrigins = (unsigned)WKUInt64GetValue(static_cast<WKUInt64Ref>(WKDictionaryGetItemForKey(messageBodyDictionary, top3SubframeUnderTopFrameOriginsKey.get())));

m_testRunner->statisticsDidRunTelemetryCallback(totalPrevalentResources, totalPrevalentResourcesWithUserInteraction, top3SubframeUnderTopFrameOrigins);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion Tools/WebKitTestRunner/WebNotificationProvider.cpp
Expand Up @@ -126,7 +126,7 @@ void WebNotificationProvider::closeWebNotification(WKNotificationRef notificatio

removeGlobalIDFromIDMap(m_localToGlobalNotificationIDMap, id);

WKRetainPtr<WKUInt64Ref> wkID = WKUInt64Create(id);
WKRetainPtr<WKUInt64Ref> wkID(AdoptWK, WKUInt64Create(id));
WKRetainPtr<WKMutableArrayRef> array(AdoptWK, WKMutableArrayCreate());
WKArrayAppendItem(array.get(), wkID.get());
WKNotificationManagerProviderDidCloseNotifications(notificationManager, array.get());
Expand Down
10 changes: 5 additions & 5 deletions Tools/WebKitTestRunner/mac/TestControllerMac.mm
Expand Up @@ -293,22 +293,22 @@ static PlatformWindow wtr_NSApplication_keyWindow(id self, SEL _cmd)

static WKRetainPtr<WKArrayRef> generateWhitelist()
{
WKMutableArrayRef result = WKMutableArrayCreate();
WKRetainPtr<WKMutableArrayRef> result = adoptWK(WKMutableArrayCreate());
for (NSString *fontFamily in allowedFontFamilySet()) {
NSArray *fontsForFamily = [[NSFontManager sharedFontManager] availableMembersOfFontFamily:fontFamily];
WKRetainPtr<WKStringRef> familyInFont = adoptWK(WKStringCreateWithUTF8CString([fontFamily UTF8String]));
WKArrayAppendItem(result, familyInFont.get());
WKArrayAppendItem(result.get(), familyInFont.get());
for (NSArray *fontInfo in fontsForFamily) {
// Font name is the first entry in the array.
WKRetainPtr<WKStringRef> fontName = adoptWK(WKStringCreateWithUTF8CString([[fontInfo objectAtIndex:0] UTF8String]));
WKArrayAppendItem(result, fontName.get());
WKArrayAppendItem(result.get(), fontName.get());
}
}

for (NSString *hiddenFontFamily in systemHiddenFontFamilySet())
WKArrayAppendItem(result, adoptWK(WKStringCreateWithUTF8CString([hiddenFontFamily UTF8String])).get());
WKArrayAppendItem(result.get(), adoptWK(WKStringCreateWithUTF8CString([hiddenFontFamily UTF8String])).get());

return adoptWK(result);
return result;
}

void TestController::platformInitializeContext()
Expand Down

0 comments on commit 2aa196a

Please sign in to comment.