Title: [238948] trunk
Revision
238948
Author
[email protected]
Date
2018-12-06 21:34:21 -0800 (Thu, 06 Dec 2018)

Log Message

Injected bundle for WebKitTestRunner leaks WKTypeRef objects
<https://webkit.org/b/192481>
<rdar://problem/46539059>

Reviewed by Simon Fraser.

Source/WebKit:

Change function parameter name from `returnData[Ref]` to
`returnRetainedData[Ref]` to document that the value returned is
a +1 retained WKTypeRef object.

* WebProcess/InjectedBundle/API/c/WKBundle.cpp:
(WKBundlePostSynchronousMessage):
* WebProcess/InjectedBundle/API/c/WKBundle.h:
* WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:
(WKBundlePagePostSynchronousMessageForTesting):
* WebProcess/InjectedBundle/API/c/WKBundlePage.h:

Tools:

This patch:
- Fixes leaks in various injected bundle methods that return +1
  retained WKTypeRef objects via pointer.
- Asserts the returned object is the expected WKTypeRef.
- Replaces 0 with nullptr in many places.

* WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
(WTR::InjectedBundle::didCreatePage):
* 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::clearDidReceiveServerRedirectForProvisionalNavigation):
(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::statisticsProcessStatisticsAndDataRecords):
(WTR::TestRunner::statisticsUpdateCookieBlocking):
(WTR::TestRunner::statisticsSubmitTelemetry):
(WTR::TestRunner::statisticsClearInMemoryAndPersistentStore):
(WTR::TestRunner::statisticsClearThroughWebsiteDataRemoval):
(WTR::TestRunner::statisticsResetToConsistentState):
(WTR::TestRunner::getAllStorageAccessEntries):
(WTR::TestRunner::hasDOMCache):
(WTR::TestRunner::domCacheSize):
(WTR::TestRunner::injectUserScript):
(WTR::TestRunner::keyExistsInKeychain):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (238947 => 238948)


--- trunk/Source/WebKit/ChangeLog	2018-12-07 01:47:04 UTC (rev 238947)
+++ trunk/Source/WebKit/ChangeLog	2018-12-07 05:34:21 UTC (rev 238948)
@@ -1,3 +1,22 @@
+2018-12-06  David Kilzer  <[email protected]>
+
+        Injected bundle for WebKitTestRunner leaks WKTypeRef objects
+        <https://webkit.org/b/192481>
+        <rdar://problem/46539059>
+
+        Reviewed by Simon Fraser.
+
+        Change function parameter name from `returnData[Ref]` to
+        `returnRetainedData[Ref]` to document that the value returned is
+        a +1 retained WKTypeRef object.
+
+        * WebProcess/InjectedBundle/API/c/WKBundle.cpp:
+        (WKBundlePostSynchronousMessage):
+        * WebProcess/InjectedBundle/API/c/WKBundle.h:
+        * WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:
+        (WKBundlePagePostSynchronousMessageForTesting):
+        * WebProcess/InjectedBundle/API/c/WKBundlePage.h:
+
 2018-12-06  Frederic Wang  <[email protected]>
 
         Allow control over child order when adding nodes to the scrolling tree

Modified: trunk/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundle.cpp (238947 => 238948)


--- trunk/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundle.cpp	2018-12-07 01:47:04 UTC (rev 238947)
+++ trunk/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundle.cpp	2018-12-07 05:34:21 UTC (rev 238948)
@@ -68,12 +68,12 @@
     WebKit::toImpl(bundleRef)->postMessage(WebKit::toWTFString(messageNameRef), WebKit::toImpl(messageBodyRef));
 }
 
-void WKBundlePostSynchronousMessage(WKBundleRef bundleRef, WKStringRef messageNameRef, WKTypeRef messageBodyRef, WKTypeRef* returnDataRef)
+void WKBundlePostSynchronousMessage(WKBundleRef bundleRef, WKStringRef messageNameRef, WKTypeRef messageBodyRef, WKTypeRef* returnRetainedDataRef)
 {
     RefPtr<API::Object> returnData;
     WebKit::toImpl(bundleRef)->postSynchronousMessage(WebKit::toWTFString(messageNameRef), WebKit::toImpl(messageBodyRef), returnData);
-    if (returnDataRef)
-        *returnDataRef = WebKit::toAPI(returnData.leakRef());
+    if (returnRetainedDataRef)
+        *returnRetainedDataRef = WebKit::toAPI(returnData.leakRef());
 }
 
 WKConnectionRef WKBundleGetApplicationConnection(WKBundleRef bundleRef)

Modified: trunk/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundle.h (238947 => 238948)


--- trunk/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundle.h	2018-12-07 01:47:04 UTC (rev 238947)
+++ trunk/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundle.h	2018-12-07 05:34:21 UTC (rev 238948)
@@ -74,7 +74,7 @@
 WK_EXPORT void WKBundleSetServiceWorkerProxyCreationCallback(WKBundleRef bundle, void (*)(uint64_t));
 
 WK_EXPORT void WKBundlePostMessage(WKBundleRef bundle, WKStringRef messageName, WKTypeRef messageBody);
-WK_EXPORT void WKBundlePostSynchronousMessage(WKBundleRef bundle, WKStringRef messageName, WKTypeRef messageBody, WKTypeRef* returnData);
+WK_EXPORT void WKBundlePostSynchronousMessage(WKBundleRef bundle, WKStringRef messageName, WKTypeRef messageBody, WKTypeRef* returnRetainedData);
 
 WK_EXPORT WKConnectionRef WKBundleGetApplicationConnection(WKBundleRef bundle);
 

Modified: trunk/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp (238947 => 238948)


--- trunk/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp	2018-12-07 01:47:04 UTC (rev 238947)
+++ trunk/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp	2018-12-07 05:34:21 UTC (rev 238948)
@@ -697,7 +697,7 @@
     WebKit::toImpl(pageRef)->postMessageIgnoringFullySynchronousMode(WebKit::toWTFString(messageNameRef), WebKit::toImpl(messageBodyRef));
 }
 
-void WKBundlePagePostSynchronousMessageForTesting(WKBundlePageRef pageRef, WKStringRef messageNameRef, WKTypeRef messageBodyRef, WKTypeRef* returnDataRef)
+void WKBundlePagePostSynchronousMessageForTesting(WKBundlePageRef pageRef, WKStringRef messageNameRef, WKTypeRef messageBodyRef, WKTypeRef* returnRetainedDataRef)
 {
     WebKit::WebPage* page = WebKit::toImpl(pageRef);
     page->layoutIfNeeded();
@@ -704,8 +704,8 @@
 
     RefPtr<API::Object> returnData;
     page->postSynchronousMessageForTesting(WebKit::toWTFString(messageNameRef), WebKit::toImpl(messageBodyRef), returnData);
-    if (returnDataRef)
-        *returnDataRef = WebKit::toAPI(returnData.leakRef());
+    if (returnRetainedDataRef)
+        *returnRetainedDataRef = WebKit::toAPI(returnData.leakRef());
 }
 
 void WKBundlePageAddUserScript(WKBundlePageRef pageRef, WKStringRef source, _WKUserScriptInjectionTime injectionTime, WKUserContentInjectedFrames injectedFrames)

Modified: trunk/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePage.h (238947 => 238948)


--- trunk/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePage.h	2018-12-07 01:47:04 UTC (rev 238947)
+++ trunk/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePage.h	2018-12-07 05:34:21 UTC (rev 238948)
@@ -128,7 +128,7 @@
 WK_EXPORT void WKBundlePagePostMessage(WKBundlePageRef page, WKStringRef messageName, WKTypeRef messageBody);
 
 // Switches a connection into a fully synchronous mode, so all messages become synchronous until we get a response.
-WK_EXPORT void WKBundlePagePostSynchronousMessageForTesting(WKBundlePageRef page, WKStringRef messageName, WKTypeRef messageBody, WKTypeRef* returnData);
+WK_EXPORT void WKBundlePagePostSynchronousMessageForTesting(WKBundlePageRef page, WKStringRef messageName, WKTypeRef messageBody, WKTypeRef* returnRetainedData);
 // Same as WKBundlePagePostMessage() but the message cannot become synchronous, even if the connection is in fully synchronous mode.
 WK_EXPORT void WKBundlePagePostMessageIgnoringFullySynchronousMode(WKBundlePageRef page, WKStringRef messageName, WKTypeRef messageBody);
 

Modified: trunk/Tools/ChangeLog (238947 => 238948)


--- trunk/Tools/ChangeLog	2018-12-07 01:47:04 UTC (rev 238947)
+++ trunk/Tools/ChangeLog	2018-12-07 05:34:21 UTC (rev 238948)
@@ -1,3 +1,46 @@
+2018-12-06  David Kilzer  <[email protected]>
+
+        Injected bundle for WebKitTestRunner leaks WKTypeRef objects
+        <https://webkit.org/b/192481>
+        <rdar://problem/46539059>
+
+        Reviewed by Simon Fraser.
+
+        This patch:
+        - Fixes leaks in various injected bundle methods that return +1
+          retained WKTypeRef objects via pointer.
+        - Asserts the returned object is the expected WKTypeRef.
+        - Replaces 0 with nullptr in many places.
+
+        * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
+        (WTR::InjectedBundle::didCreatePage):
+        * 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::clearDidReceiveServerRedirectForProvisionalNavigation):
+        (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::statisticsProcessStatisticsAndDataRecords):
+        (WTR::TestRunner::statisticsUpdateCookieBlocking):
+        (WTR::TestRunner::statisticsSubmitTelemetry):
+        (WTR::TestRunner::statisticsClearInMemoryAndPersistentStore):
+        (WTR::TestRunner::statisticsClearThroughWebsiteDataRemoval):
+        (WTR::TestRunner::statisticsResetToConsistentState):
+        (WTR::TestRunner::getAllStorageAccessEntries):
+        (WTR::TestRunner::hasDOMCache):
+        (WTR::TestRunner::domCacheSize):
+        (WTR::TestRunner::injectUserScript):
+        (WTR::TestRunner::keyExistsInKeychain):
+
 2018-12-06  Jonathan Bedard  <[email protected]>
 
         REGRESSION: run-webkit-tests may fail when using booted simulators

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp (238947 => 238948)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp	2018-12-07 01:47:04 UTC (rev 238947)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp	2018-12-07 05:34:21 UTC (rev 238948)
@@ -119,16 +119,16 @@
         return;
 
     WKRetainPtr<WKStringRef> messsageName(AdoptWK, WKStringCreateWithUTF8CString("Initialization"));
-    WKTypeRef result = 0;
-    WKBundlePostSynchronousMessage(m_bundle, messsageName.get(), 0, &result);
+    WKTypeRef result = nullptr;
+    WKBundlePostSynchronousMessage(m_bundle, messsageName.get(), nullptr, &result);
     ASSERT(WKGetTypeID(result) == WKDictionaryGetTypeID());
-    WKDictionaryRef initializationDictionary = static_cast<WKDictionaryRef>(result);
+    WKRetainPtr<WKDictionaryRef> initializationDictionary(AdoptWK, static_cast<WKDictionaryRef>(result));
 
     WKRetainPtr<WKStringRef> resumeTestingKey(AdoptWK, WKStringCreateWithUTF8CString("ResumeTesting"));
-    WKTypeRef resumeTestingValue = WKDictionaryGetItemForKey(initializationDictionary, resumeTestingKey.get());
+    WKTypeRef resumeTestingValue = WKDictionaryGetItemForKey(initializationDictionary.get(), resumeTestingKey.get());
     ASSERT(WKGetTypeID(resumeTestingValue) == WKBooleanGetTypeID());
     if (WKBooleanGetValue(static_cast<WKBooleanRef>(resumeTestingValue)))
-        beginTesting(initializationDictionary, BegingTestingMode::Resume);
+        beginTesting(initializationDictionary.get(), BegingTestingMode::Resume);
 }
 
 void InjectedBundle::willDestroyPage(WKBundlePageRef page)

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp (238947 => 238948)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp	2018-12-07 01:47:04 UTC (rev 238947)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp	2018-12-07 05:34:21 UTC (rev 238948)
@@ -128,10 +128,11 @@
 bool TestRunner::shouldDumpPixels() const
 {
     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("GetDumpPixels"));
-    WKTypeRef result = 0;
-    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), 0, &result);
-    ASSERT(WKGetTypeID(result) == WKBooleanGetTypeID());
-    return WKBooleanGetValue(static_cast<WKBooleanRef>(result));
+    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());
 }
 
 void TestRunner::setDumpPixels(bool dumpPixels)
@@ -151,11 +152,11 @@
 WhatToDump TestRunner::whatToDump() const
 {
     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("GetWhatToDump"));
-    WKTypeRef result = 0;
-    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), 0, &result);
-    ASSERT(WKGetTypeID(result) == WKUInt64GetTypeID());
-    auto uint64value = WKUInt64GetValue(static_cast<WKUInt64Ref>(result));
-    return static_cast<WhatToDump>(uint64value);
+    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()));
 }
 
 void TestRunner::setWhatToDump(WhatToDump whatToDump)
@@ -206,10 +207,11 @@
 bool TestRunner::shouldWaitUntilDone() const
 {
     WKRetainPtr<WKStringRef> messsageName(AdoptWK, WKStringCreateWithUTF8CString("GetWaitUntilDone"));
-    WKTypeRef result = 0;
-    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messsageName.get(), 0, &result);
-    ASSERT(WKGetTypeID(result) == WKBooleanGetTypeID());
-    return WKBooleanGetValue(static_cast<WKBooleanRef>(result));
+    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());
 }
 
 void TestRunner::waitToDumpWatchdogTimerFired()
@@ -263,10 +265,11 @@
 bool TestRunner::shouldDumpFrameLoadCallbacks()
 {
     WKRetainPtr<WKStringRef> messsageName(AdoptWK, WKStringCreateWithUTF8CString("GetDumpFrameLoadCallbacks"));
-    WKTypeRef result = 0;
-    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messsageName.get(), 0, &result);
-    ASSERT(WKGetTypeID(result) == WKBooleanGetTypeID());
-    return WKBooleanGetValue(static_cast<WKBooleanRef>(result));
+    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());
 }
 
 unsigned TestRunner::imageCountInGeneralPasteboard() const
@@ -749,16 +752,17 @@
 bool TestRunner::didReceiveServerRedirectForProvisionalNavigation() const
 {
     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("DidReceiveServerRedirectForProvisionalNavigation"));
-    WKTypeRef returnData = 0;
-
-    WKBundlePagePostSynchronousMessageForTesting(InjectedBundle::singleton().page()->page(), messageName.get(), 0, &returnData);
-    return WKBooleanGetValue(static_cast<WKBooleanRef>(returnData));
+    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());
 }
 
 void TestRunner::clearDidReceiveServerRedirectForProvisionalNavigation()
 {
     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("ClearDidReceiveServerRedirectForProvisionalNavigation"));
-    WKBundlePagePostSynchronousMessageForTesting(InjectedBundle::singleton().page()->page(), messageName.get(), 0, nullptr);
+    WKBundlePagePostSynchronousMessageForTesting(InjectedBundle::singleton().page()->page(), messageName.get(), nullptr, nullptr);
 }
 
 void TestRunner::setPageVisibility(JSStringRef state)
@@ -1203,10 +1207,11 @@
 bool TestRunner::secureEventInputIsEnabled() const
 {
     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SecureEventInputIsEnabled"));
-    WKTypeRef returnData = 0;
-
-    WKBundlePagePostSynchronousMessageForTesting(InjectedBundle::singleton().page()->page(), messageName.get(), 0, &returnData);
-    return WKBooleanGetValue(static_cast<WKBooleanRef>(returnData));
+    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());
 }
 
 void TestRunner::setBlockAllPlugins(bool shouldBlock)
@@ -1508,9 +1513,11 @@
 {
     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("IsStatisticsPrevalentResource"));
     WKRetainPtr<WKStringRef> messageBody(AdoptWK, WKStringCreateWithJSString(hostName));
-    WKTypeRef returnData = 0;
+    WKTypeRef returnData = nullptr;
     WKBundlePagePostSynchronousMessageForTesting(InjectedBundle::singleton().page()->page(), messageName.get(), messageBody.get(), &returnData);
-    return WKBooleanGetValue(static_cast<WKBooleanRef>(returnData));
+    ASSERT(WKGetTypeID(returnData) == WKBooleanGetTypeID());
+    WKRetainPtr<WKBooleanRef> result(AdoptWK, static_cast<WKBooleanRef>(returnData));
+    return WKBooleanGetValue(result.get());
 }
 
 bool TestRunner::isStatisticsVeryPrevalentResource(JSStringRef hostName)
@@ -1517,9 +1524,11 @@
 {
     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("IsStatisticsVeryPrevalentResource"));
     WKRetainPtr<WKStringRef> messageBody(AdoptWK, WKStringCreateWithJSString(hostName));
-    WKTypeRef returnData = 0;
+    WKTypeRef returnData = nullptr;
     WKBundlePagePostSynchronousMessageForTesting(InjectedBundle::singleton().page()->page(), messageName.get(), messageBody.get(), &returnData);
-    return WKBooleanGetValue(static_cast<WKBooleanRef>(returnData));
+    ASSERT(WKGetTypeID(returnData) == WKBooleanGetTypeID());
+    WKRetainPtr<WKBooleanRef> result(AdoptWK, static_cast<WKBooleanRef>(returnData));
+    return WKBooleanGetValue(result.get());
 }
 
 bool TestRunner::isStatisticsRegisteredAsSubresourceUnder(JSStringRef subresourceHost, JSStringRef topFrameHost)
@@ -1543,9 +1552,11 @@
     
     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("IsStatisticsRegisteredAsSubresourceUnder"));
     WKRetainPtr<WKDictionaryRef> messageBody(AdoptWK, WKDictionaryCreate(rawKeys.data(), rawValues.data(), rawKeys.size()));
-    WKTypeRef returnData = 0;
+    WKTypeRef returnData = nullptr;
     WKBundlePagePostSynchronousMessageForTesting(InjectedBundle::singleton().page()->page(), messageName.get(), messageBody.get(), &returnData);
-    return WKBooleanGetValue(static_cast<WKBooleanRef>(returnData));
+    ASSERT(WKGetTypeID(returnData) == WKBooleanGetTypeID());
+    WKRetainPtr<WKBooleanRef> result(AdoptWK, static_cast<WKBooleanRef>(returnData));
+    return WKBooleanGetValue(result.get());
 }
 
 bool TestRunner::isStatisticsRegisteredAsSubFrameUnder(JSStringRef subFrameHost, JSStringRef topFrameHost)
@@ -1569,9 +1580,11 @@
 
     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("IsStatisticsRegisteredAsSubFrameUnder"));
     WKRetainPtr<WKDictionaryRef> messageBody(AdoptWK, WKDictionaryCreate(rawKeys.data(), rawValues.data(), rawKeys.size()));
-    WKTypeRef returnData = 0;
+    WKTypeRef returnData = nullptr;
     WKBundlePagePostSynchronousMessageForTesting(InjectedBundle::singleton().page()->page(), messageName.get(), messageBody.get(), &returnData);
-    return WKBooleanGetValue(static_cast<WKBooleanRef>(returnData));
+    ASSERT(WKGetTypeID(returnData) == WKBooleanGetTypeID());
+    WKRetainPtr<WKBooleanRef> result(AdoptWK, static_cast<WKBooleanRef>(returnData));
+    return WKBooleanGetValue(result.get());
 }
 
 bool TestRunner::isStatisticsRegisteredAsRedirectingTo(JSStringRef hostRedirectedFrom, JSStringRef hostRedirectedTo)
@@ -1595,9 +1608,11 @@
     
     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("IsStatisticsRegisteredAsRedirectingTo"));
     WKRetainPtr<WKDictionaryRef> messageBody(AdoptWK, WKDictionaryCreate(rawKeys.data(), rawValues.data(), rawKeys.size()));
-    WKTypeRef returnData = 0;
+    WKTypeRef returnData = nullptr;
     WKBundlePagePostSynchronousMessageForTesting(InjectedBundle::singleton().page()->page(), messageName.get(), messageBody.get(), &returnData);
-    return WKBooleanGetValue(static_cast<WKBooleanRef>(returnData));
+    ASSERT(WKGetTypeID(returnData) == WKBooleanGetTypeID());
+    WKRetainPtr<WKBooleanRef> result(AdoptWK, static_cast<WKBooleanRef>(returnData));
+    return WKBooleanGetValue(result.get());
 }
 
 void TestRunner::setStatisticsHasHadUserInteraction(JSStringRef hostName, bool value, JSValueRef completionHandler)
@@ -1638,9 +1653,11 @@
 {
     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("IsStatisticsHasHadUserInteraction"));
     WKRetainPtr<WKStringRef> messageBody(AdoptWK, WKStringCreateWithJSString(hostName));
-    WKTypeRef returnData = 0;
+    WKTypeRef returnData = nullptr;
     WKBundlePagePostSynchronousMessageForTesting(InjectedBundle::singleton().page()->page(), messageName.get(), messageBody.get(), &returnData);
-    return WKBooleanGetValue(static_cast<WKBooleanRef>(returnData));
+    ASSERT(WKGetTypeID(returnData) == WKBooleanGetTypeID());
+    WKRetainPtr<WKBooleanRef> result(AdoptWK, static_cast<WKBooleanRef>(returnData));
+    return WKBooleanGetValue(result.get());
 }
 
 void TestRunner::setStatisticsGrandfathered(JSStringRef hostName, bool value)
@@ -1674,9 +1691,11 @@
 {
     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("IsStatisticsGrandfathered"));
     WKRetainPtr<WKStringRef> messageBody(AdoptWK, WKStringCreateWithJSString(hostName));
-    WKTypeRef returnData = 0;
+    WKTypeRef returnData = nullptr;
     WKBundlePagePostSynchronousMessageForTesting(InjectedBundle::singleton().page()->page(), messageName.get(), messageBody.get(), &returnData);
-    return WKBooleanGetValue(static_cast<WKBooleanRef>(returnData));
+    ASSERT(WKGetTypeID(returnData) == WKBooleanGetTypeID());
+    WKRetainPtr<WKBooleanRef> result(AdoptWK, static_cast<WKBooleanRef>(returnData));
+    return WKBooleanGetValue(result.get());
 }
 
 void TestRunner::setStatisticsSubframeUnderTopFrameOrigin(JSStringRef hostName, JSStringRef topFrameHostName)
@@ -1884,7 +1903,7 @@
 void TestRunner::statisticsProcessStatisticsAndDataRecords()
 {
     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("StatisticsProcessStatisticsAndDataRecords"));
-    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), 0, nullptr);
+    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), nullptr, nullptr);
 }
 
 void TestRunner::statisticsUpdateCookieBlocking(JSValueRef completionHandler)
@@ -1892,7 +1911,7 @@
     cacheTestRunnerCallback(StatisticsDidSetBlockCookiesForHostCallbackID, completionHandler);
 
     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("StatisticsUpdateCookieBlocking"));
-    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), 0, nullptr);
+    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), nullptr, nullptr);
 }
 
 void TestRunner::statisticsCallDidSetBlockCookiesForHostCallback()
@@ -1903,7 +1922,7 @@
 void TestRunner::statisticsSubmitTelemetry()
 {
     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("StatisticsSubmitTelemetry"));
-    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), 0, nullptr);
+    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), nullptr, nullptr);
 }
 
 void TestRunner::setStatisticsNotifyPagesWhenDataRecordsWereScanned(bool value)
@@ -1960,7 +1979,7 @@
     cacheTestRunnerCallback(StatisticsDidClearThroughWebsiteDataRemovalCallbackID, callback);
 
     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("StatisticsClearInMemoryAndPersistentStore"));
-    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), 0, nullptr);
+    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), nullptr, nullptr);
 }
 
 void TestRunner::statisticsClearInMemoryAndPersistentStoreModifiedSinceHours(unsigned hours, JSValueRef callback)
@@ -1977,7 +1996,7 @@
     cacheTestRunnerCallback(StatisticsDidClearThroughWebsiteDataRemovalCallbackID, callback);
     
     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("StatisticsClearThroughWebsiteDataRemoval"));
-    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), 0, nullptr);
+    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), nullptr, nullptr);
 }
 
 void TestRunner::setStatisticsCacheMaxAgeCap(double seconds)
@@ -1997,7 +2016,7 @@
     cacheTestRunnerCallback(StatisticsDidResetToConsistentStateCallbackID, completionHandler);
     
     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("StatisticsResetToConsistentState"));
-    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), 0, nullptr);
+    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), nullptr, nullptr);
 }
 
 void TestRunner::statisticsCallDidResetToConsistentStateCallback()
@@ -2049,7 +2068,7 @@
     cacheTestRunnerCallback(AllStorageAccessEntriesCallbackID, callback);
     
     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("GetAllStorageAccessEntries"));
-    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), 0, nullptr);
+    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), nullptr, nullptr);
 }
 
 void TestRunner::callDidReceiveAllStorageAccessEntriesCallback(Vector<String>& domains)
@@ -2337,9 +2356,11 @@
 {
     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("HasDOMCache"));
     WKRetainPtr<WKStringRef> messageBody(AdoptWK, WKStringCreateWithJSString(origin));
-    WKTypeRef returnData = 0;
+    WKTypeRef returnData = nullptr;
     WKBundlePagePostSynchronousMessageForTesting(InjectedBundle::singleton().page()->page(), messageName.get(), messageBody.get(), &returnData);
-    return WKBooleanGetValue(static_cast<WKBooleanRef>(returnData));
+    ASSERT(WKGetTypeID(returnData) == WKBooleanGetTypeID());
+    WKRetainPtr<WKBooleanRef> result(AdoptWK, static_cast<WKBooleanRef>(returnData));
+    return WKBooleanGetValue(result.get());
 }
 
 uint64_t TestRunner::domCacheSize(JSStringRef origin)
@@ -2346,7 +2367,7 @@
 {
     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("DOMCacheSize"));
     WKRetainPtr<WKStringRef> messageBody(AdoptWK, WKStringCreateWithJSString(origin));
-    WKTypeRef returnData = 0;
+    WKTypeRef returnData = nullptr;
     WKBundlePagePostSynchronousMessageForTesting(InjectedBundle::singleton().page()->page(), messageName.get(), messageBody.get(), &returnData);
     return WKUInt64GetValue(static_cast<WKUInt64Ref>(returnData));
 }
@@ -2373,8 +2394,7 @@
 {
     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("InjectUserScript"));
     WKRetainPtr<WKStringRef> messageBody(AdoptWK, WKStringCreateWithJSString(script));
-    WKTypeRef returnData = 0;
-    WKBundlePagePostSynchronousMessageForTesting(InjectedBundle::singleton().page()->page(), messageName.get(), messageBody.get(), &returnData);
+    WKBundlePagePostSynchronousMessageForTesting(InjectedBundle::singleton().page()->page(), messageName.get(), messageBody.get(), nullptr);
 }
 
 void TestRunner::sendDisplayConfigurationChangedMessageForTesting()
@@ -2629,9 +2649,11 @@
     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("KeyExistsInKeychain"));
     WKRetainPtr<WKDictionaryRef> messageBody(AdoptWK, WKDictionaryCreate(rawKeys.data(), rawValues.data(), rawKeys.size()));
 
-    WKTypeRef returnData = 0;
+    WKTypeRef returnData = nullptr;
     WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), &returnData);
-    return WKBooleanGetValue(static_cast<WKBooleanRef>(returnData));
+    ASSERT(WKGetTypeID(returnData) == WKBooleanGetTypeID());
+    WKRetainPtr<WKBooleanRef> result(AdoptWK, static_cast<WKBooleanRef>(returnData));
+    return WKBooleanGetValue(result.get());
 }
 
 } // namespace WTR
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to