Injected bundle for WebKitTestRunner leaks WKTypeRef objects
authorddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 10 Dec 2018 21:55:56 +0000 (21:55 +0000)
committerddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 10 Dec 2018 21:55:56 +0000 (21:55 +0000)
<https://webkit.org/b/192481>
<rdar://problem/46539059>

Follow-up to address Darin's feedback.

* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::shouldDumpPixels const):
(WTR::TestRunner::whatToDump const):
(WTR::TestRunner::shouldWaitUntilDone const):
(WTR::TestRunner::shouldDumpFrameLoadCallbacks):
(WTR::TestRunner::didReceiveServerRedirectForProvisionalNavigation const):
(WTR::TestRunner::secureEventInputIsEnabled const):
(WTR::TestRunner::isStatisticsPrevalentResource):
(WTR::TestRunner::isStatisticsVeryPrevalentResource):
(WTR::TestRunner::isStatisticsRegisteredAsSubresourceUnder):
(WTR::TestRunner::isStatisticsRegisteredAsSubFrameUnder):
(WTR::TestRunner::isStatisticsRegisteredAsRedirectingTo):
(WTR::TestRunner::isStatisticsHasHadUserInteraction):
(WTR::TestRunner::isStatisticsGrandfathered):
(WTR::TestRunner::hasDOMCache):
(WTR::TestRunner::keyExistsInKeychain):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239050 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp

index 493478b..eabc1cc 100644 (file)
@@ -1,3 +1,28 @@
+2018-12-10  David Kilzer  <ddkilzer@apple.com>
+
+        Injected bundle for WebKitTestRunner leaks WKTypeRef objects
+        <https://webkit.org/b/192481>
+        <rdar://problem/46539059>
+
+        Follow-up to address Darin's feedback.
+
+        * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
+        (WTR::TestRunner::shouldDumpPixels const):
+        (WTR::TestRunner::whatToDump const):
+        (WTR::TestRunner::shouldWaitUntilDone const):
+        (WTR::TestRunner::shouldDumpFrameLoadCallbacks):
+        (WTR::TestRunner::didReceiveServerRedirectForProvisionalNavigation const):
+        (WTR::TestRunner::secureEventInputIsEnabled const):
+        (WTR::TestRunner::isStatisticsPrevalentResource):
+        (WTR::TestRunner::isStatisticsVeryPrevalentResource):
+        (WTR::TestRunner::isStatisticsRegisteredAsSubresourceUnder):
+        (WTR::TestRunner::isStatisticsRegisteredAsSubFrameUnder):
+        (WTR::TestRunner::isStatisticsRegisteredAsRedirectingTo):
+        (WTR::TestRunner::isStatisticsHasHadUserInteraction):
+        (WTR::TestRunner::isStatisticsGrandfathered):
+        (WTR::TestRunner::hasDOMCache):
+        (WTR::TestRunner::keyExistsInKeychain):
+
 2018-12-10  Jonathan Bedard  <jbedard@apple.com>
 
         webkitpy: Ref tests don't respect platform specific expectations
index 09afd8d..22579e8 100644 (file)
@@ -131,8 +131,7 @@ bool TestRunner::shouldDumpPixels() const
     WKTypeRef returnData = nullptr;
     WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), nullptr, &returnData);
     ASSERT(WKGetTypeID(returnData) == WKBooleanGetTypeID());
-    WKRetainPtr<WKBooleanRef> result(AdoptWK, static_cast<WKBooleanRef>(returnData));
-    return WKBooleanGetValue(result.get());
+    return WKBooleanGetValue(adoptWK(static_cast<WKBooleanRef>(returnData)).get());
 }
 
 void TestRunner::setDumpPixels(bool dumpPixels)
@@ -155,8 +154,7 @@ WhatToDump TestRunner::whatToDump() const
     WKTypeRef returnData = nullptr;
     WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), nullptr, &returnData);
     ASSERT(WKGetTypeID(returnData) == WKUInt64GetTypeID());
-    WKRetainPtr<WKUInt64Ref> result(AdoptWK, static_cast<WKUInt64Ref>(returnData));
-    return static_cast<WhatToDump>(WKUInt64GetValue(result.get()));
+    return static_cast<WhatToDump>(WKUInt64GetValue(adoptWK(static_cast<WKUInt64Ref>(returnData)).get()));
 }
 
 void TestRunner::setWhatToDump(WhatToDump whatToDump)
@@ -210,8 +208,7 @@ bool TestRunner::shouldWaitUntilDone() const
     WKTypeRef returnData = nullptr;
     WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messsageName.get(), nullptr, &returnData);
     ASSERT(WKGetTypeID(returnData) == WKBooleanGetTypeID());
-    WKRetainPtr<WKBooleanRef> result(AdoptWK, static_cast<WKBooleanRef>(returnData));
-    return WKBooleanGetValue(result.get());
+    return WKBooleanGetValue(adoptWK(static_cast<WKBooleanRef>(returnData)).get());
 }
 
 void TestRunner::waitToDumpWatchdogTimerFired()
@@ -268,8 +265,7 @@ bool TestRunner::shouldDumpFrameLoadCallbacks()
     WKTypeRef returnData = nullptr;
     WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messsageName.get(), nullptr, &returnData);
     ASSERT(WKGetTypeID(returnData) == WKBooleanGetTypeID());
-    WKRetainPtr<WKBooleanRef> result(AdoptWK, static_cast<WKBooleanRef>(returnData));
-    return WKBooleanGetValue(result.get());
+    return WKBooleanGetValue(adoptWK(static_cast<WKBooleanRef>(returnData)).get());
 }
 
 unsigned TestRunner::imageCountInGeneralPasteboard() const
@@ -755,8 +751,7 @@ bool TestRunner::didReceiveServerRedirectForProvisionalNavigation() const
     WKTypeRef returnData = nullptr;
     WKBundlePagePostSynchronousMessageForTesting(InjectedBundle::singleton().page()->page(), messageName.get(), nullptr, &returnData);
     ASSERT(WKGetTypeID(returnData) == WKBooleanGetTypeID());
-    WKRetainPtr<WKBooleanRef> result(AdoptWK, static_cast<WKBooleanRef>(returnData));
-    return WKBooleanGetValue(result.get());
+    return WKBooleanGetValue(adoptWK(static_cast<WKBooleanRef>(returnData)).get());
 }
 
 void TestRunner::clearDidReceiveServerRedirectForProvisionalNavigation()
@@ -1210,8 +1205,7 @@ bool TestRunner::secureEventInputIsEnabled() const
     WKTypeRef returnData = nullptr;
     WKBundlePagePostSynchronousMessageForTesting(InjectedBundle::singleton().page()->page(), messageName.get(), nullptr, &returnData);
     ASSERT(WKGetTypeID(returnData) == WKBooleanGetTypeID());
-    WKRetainPtr<WKBooleanRef> result(AdoptWK, static_cast<WKBooleanRef>(returnData));
-    return WKBooleanGetValue(result.get());
+    return WKBooleanGetValue(adoptWK(static_cast<WKBooleanRef>(returnData)).get());
 }
 
 void TestRunner::setBlockAllPlugins(bool shouldBlock)
@@ -1516,8 +1510,7 @@ bool TestRunner::isStatisticsPrevalentResource(JSStringRef hostName)
     WKTypeRef returnData = nullptr;
     WKBundlePagePostSynchronousMessageForTesting(InjectedBundle::singleton().page()->page(), messageName.get(), messageBody.get(), &returnData);
     ASSERT(WKGetTypeID(returnData) == WKBooleanGetTypeID());
-    WKRetainPtr<WKBooleanRef> result(AdoptWK, static_cast<WKBooleanRef>(returnData));
-    return WKBooleanGetValue(result.get());
+    return WKBooleanGetValue(adoptWK(static_cast<WKBooleanRef>(returnData)).get());
 }
 
 bool TestRunner::isStatisticsVeryPrevalentResource(JSStringRef hostName)
@@ -1527,8 +1520,7 @@ bool TestRunner::isStatisticsVeryPrevalentResource(JSStringRef hostName)
     WKTypeRef returnData = nullptr;
     WKBundlePagePostSynchronousMessageForTesting(InjectedBundle::singleton().page()->page(), messageName.get(), messageBody.get(), &returnData);
     ASSERT(WKGetTypeID(returnData) == WKBooleanGetTypeID());
-    WKRetainPtr<WKBooleanRef> result(AdoptWK, static_cast<WKBooleanRef>(returnData));
-    return WKBooleanGetValue(result.get());
+    return WKBooleanGetValue(adoptWK(static_cast<WKBooleanRef>(returnData)).get());
 }
 
 bool TestRunner::isStatisticsRegisteredAsSubresourceUnder(JSStringRef subresourceHost, JSStringRef topFrameHost)
@@ -1555,8 +1547,7 @@ bool TestRunner::isStatisticsRegisteredAsSubresourceUnder(JSStringRef subresourc
     WKTypeRef returnData = nullptr;
     WKBundlePagePostSynchronousMessageForTesting(InjectedBundle::singleton().page()->page(), messageName.get(), messageBody.get(), &returnData);
     ASSERT(WKGetTypeID(returnData) == WKBooleanGetTypeID());
-    WKRetainPtr<WKBooleanRef> result(AdoptWK, static_cast<WKBooleanRef>(returnData));
-    return WKBooleanGetValue(result.get());
+    return WKBooleanGetValue(adoptWK(static_cast<WKBooleanRef>(returnData)).get());
 }
 
 bool TestRunner::isStatisticsRegisteredAsSubFrameUnder(JSStringRef subFrameHost, JSStringRef topFrameHost)
@@ -1583,8 +1574,7 @@ bool TestRunner::isStatisticsRegisteredAsSubFrameUnder(JSStringRef subFrameHost,
     WKTypeRef returnData = nullptr;
     WKBundlePagePostSynchronousMessageForTesting(InjectedBundle::singleton().page()->page(), messageName.get(), messageBody.get(), &returnData);
     ASSERT(WKGetTypeID(returnData) == WKBooleanGetTypeID());
-    WKRetainPtr<WKBooleanRef> result(AdoptWK, static_cast<WKBooleanRef>(returnData));
-    return WKBooleanGetValue(result.get());
+    return WKBooleanGetValue(adoptWK(static_cast<WKBooleanRef>(returnData)).get());
 }
 
 bool TestRunner::isStatisticsRegisteredAsRedirectingTo(JSStringRef hostRedirectedFrom, JSStringRef hostRedirectedTo)
@@ -1611,8 +1601,7 @@ bool TestRunner::isStatisticsRegisteredAsRedirectingTo(JSStringRef hostRedirecte
     WKTypeRef returnData = nullptr;
     WKBundlePagePostSynchronousMessageForTesting(InjectedBundle::singleton().page()->page(), messageName.get(), messageBody.get(), &returnData);
     ASSERT(WKGetTypeID(returnData) == WKBooleanGetTypeID());
-    WKRetainPtr<WKBooleanRef> result(AdoptWK, static_cast<WKBooleanRef>(returnData));
-    return WKBooleanGetValue(result.get());
+    return WKBooleanGetValue(adoptWK(static_cast<WKBooleanRef>(returnData)).get());
 }
 
 void TestRunner::setStatisticsHasHadUserInteraction(JSStringRef hostName, bool value, JSValueRef completionHandler)
@@ -1656,8 +1645,7 @@ bool TestRunner::isStatisticsHasHadUserInteraction(JSStringRef hostName)
     WKTypeRef returnData = nullptr;
     WKBundlePagePostSynchronousMessageForTesting(InjectedBundle::singleton().page()->page(), messageName.get(), messageBody.get(), &returnData);
     ASSERT(WKGetTypeID(returnData) == WKBooleanGetTypeID());
-    WKRetainPtr<WKBooleanRef> result(AdoptWK, static_cast<WKBooleanRef>(returnData));
-    return WKBooleanGetValue(result.get());
+    return WKBooleanGetValue(adoptWK(static_cast<WKBooleanRef>(returnData)).get());
 }
 
 void TestRunner::setStatisticsGrandfathered(JSStringRef hostName, bool value)
@@ -1694,8 +1682,7 @@ bool TestRunner::isStatisticsGrandfathered(JSStringRef hostName)
     WKTypeRef returnData = nullptr;
     WKBundlePagePostSynchronousMessageForTesting(InjectedBundle::singleton().page()->page(), messageName.get(), messageBody.get(), &returnData);
     ASSERT(WKGetTypeID(returnData) == WKBooleanGetTypeID());
-    WKRetainPtr<WKBooleanRef> result(AdoptWK, static_cast<WKBooleanRef>(returnData));
-    return WKBooleanGetValue(result.get());
+    return WKBooleanGetValue(adoptWK(static_cast<WKBooleanRef>(returnData)).get());
 }
 
 void TestRunner::setStatisticsSubframeUnderTopFrameOrigin(JSStringRef hostName, JSStringRef topFrameHostName)
@@ -2359,8 +2346,7 @@ bool TestRunner::hasDOMCache(JSStringRef origin)
     WKTypeRef returnData = nullptr;
     WKBundlePagePostSynchronousMessageForTesting(InjectedBundle::singleton().page()->page(), messageName.get(), messageBody.get(), &returnData);
     ASSERT(WKGetTypeID(returnData) == WKBooleanGetTypeID());
-    WKRetainPtr<WKBooleanRef> result(AdoptWK, static_cast<WKBooleanRef>(returnData));
-    return WKBooleanGetValue(result.get());
+    return WKBooleanGetValue(adoptWK(static_cast<WKBooleanRef>(returnData)).get());
 }
 
 uint64_t TestRunner::domCacheSize(JSStringRef origin)
@@ -2652,8 +2638,7 @@ bool TestRunner::keyExistsInKeychain(JSStringRef attrLabel, JSStringRef applicat
     WKTypeRef returnData = nullptr;
     WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), &returnData);
     ASSERT(WKGetTypeID(returnData) == WKBooleanGetTypeID());
-    WKRetainPtr<WKBooleanRef> result(AdoptWK, static_cast<WKBooleanRef>(returnData));
-    return WKBooleanGetValue(result.get());
+    return WKBooleanGetValue(adoptWK(static_cast<WKBooleanRef>(returnData)).get());
 }
 
 } // namespace WTR