Streamline JSRetainPtr, fix leaks of JSString and JSGlobalContext
authordarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 15 Sep 2018 16:17:24 +0000 (16:17 +0000)
committerdarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 15 Sep 2018 16:17:24 +0000 (16:17 +0000)
commit91cd8ad658e46f2089a8d8e9845255df7e90c5e6
tree9ef403bf9304de4c10d8d2a792ad5d6db99a2912
parent3137cc3be8a2dad4ba19f4e5d4b08ecd47771f15
Streamline JSRetainPtr, fix leaks of JSString and JSGlobalContext
https://bugs.webkit.org/show_bug.cgi?id=189455

Reviewed by Keith Miller.

Source/JavaScriptCore:

* API/JSObjectRef.cpp:
(OpaqueJSPropertyNameArray): Use Ref<OpaqueJSString> instead of
JSRetainPtr<JSStringRef>.
(JSObjectCopyPropertyNames): Remove now-unneeded use of leakRef and
adopt constructor.
(JSPropertyNameArrayGetNameAtIndex): Use ptr() instead of get() since
the array elements are now Ref.

* API/JSRetainPtr.h: While JSRetainPtr is written as a template,
it only works for two specific unrelated types, JSStringRef and
JSGlobalContextRef. Simplified the default constructor using data
member initialization. Prepared to make the adopt constructor private
(got everything compiling that way, then made it public again so that
Apple internal software will still build). Got rid of unneeded
templated constructor and assignment operator, since it's not relevant
since there is no inheritance between JSRetainPtr template types.
Added WARN_UNUSED_RETURN to leakRef as in RefPtr and RetainPtr.
Added move constructor and move assignment operator for slightly better
performance. Simplified implementations of various member functions
so they are more obviously correct, by using leakPtr in more of them
and using std::exchange to make the flow of values more obvious.

* API/JSValue.mm:
(+[JSValue valueWithNewSymbolFromDescription:inContext:]): Added a
missing JSStringRelease to fix a leak.

* API/tests/CustomGlobalObjectClassTest.c:
(customGlobalObjectClassTest): Added a JSGlobalContextRelease to fix a leak.
(globalObjectSetPrototypeTest): Ditto.
(globalObjectPrivatePropertyTest): Ditto.

* API/tests/ExecutionTimeLimitTest.cpp:
(testResetAfterTimeout): Added a call to JSStringRelease to fix a leak.
(testExecutionTimeLimit): Ditto, lots more.

* API/tests/FunctionOverridesTest.cpp:
(testFunctionOverrides): Added a call to JSStringRelease to fix a leak.

* API/tests/JSObjectGetProxyTargetTest.cpp:
(testJSObjectGetProxyTarget): Added a call to JSGlobalContextRelease to fix
a leak.

* API/tests/PingPongStackOverflowTest.cpp:
(testPingPongStackOverflow): Added calls to JSGlobalContextRelease and
JSStringRelease to fix leaks.

* API/tests/testapi.c:
(throwException): Added. Helper function for repeated idiom where we want
to throw an exception, but with additional JSStringRelease calls so we don't
have to leak just to keep the code simpler to read.
(MyObject_getProperty): Use throwException.
(MyObject_setProperty): Ditto.
(MyObject_deleteProperty): Ditto.
(isValueEqualToString): Added. Helper function for an idiom where we check
if something is a string and then if it's equal to a particular string
constant, but a version that has an additional JSStringRelease call so we
don't have to leak just to keep the code simpler to read.
(MyObject_callAsFunction): Use isValueEqualToString and throwException.
(MyObject_callAsConstructor): Ditto.
(MyObject_hasInstance): Ditto.
(globalContextNameTest): Added a JSGlobalContextRelease to fix a leak.
(testMarkingConstraintsAndHeapFinalizers): Ditto.

Source/WebCore:

* Modules/plugins/QuickTimePluginReplacement.mm:
(WebCore::jsValueWithDictionaryInContext): Adding a missing
JSStringRelease to fix a leak.

Source/WebKit:

* WebProcess/Automation/WebAutomationSessionProxy.cpp:
(WebKit::toJSString): Use adopt function instead of adopt construuctor.
(WebKit::evaluate): Ditto.
(WebKit::evaluateJavaScriptCallback): Ditto.
(WebKit::WebAutomationSessionProxy::evaluateJavaScriptFunction): Ditto.

Tools:

There is a lot of copied and pasted code for WebKit vs. Legacy WebKit
testing and even for macOS vs. iOS vs. Windows platform-specific code.
For now, this patch just makes corresponding changes to the copied code.
Later we might get better results by merging more code instead of having
all these separate copies.

* DumpRenderTree/AccessibilityController.cpp:
(AccessibilityController::makeWindowObject): Use the adopt function
instead of the special Adopt constructor of JSRetainPtr.

* DumpRenderTree/AccessibilityTextMarker.cpp: Removed unneeded include.

* DumpRenderTree/AccessibilityUIElement.cpp: Ditto.
(allAttributesCallback): Don't adopt at this level; changed the
underlying function to return a JSRetainPtr so the adopt is right next
to the call to the create or copy function.
(attributesOfLinkedUIElementsCallback): Ditto.
(attributesOfDocumentLinksCallback): Ditto.
(attributesOfChildrenCallback): Ditto.
(parameterizedAttributeNamesCallback): Ditto.
(attributesOfColumnHeadersCallback): Ditto.
(attributesOfRowHeadersCallback): Ditto.
(attributesOfColumnsCallback): Ditto.
(attributesOfRowsCallback): Ditto.
(attributesOfVisibleCellsCallback): Ditto.
(attributesOfHeaderCallback): Ditto.
(rowIndexRangeCallback): Ditto.
(columnIndexRangeCallback): Ditto.
(rangeForLineCallback): Ditto.
(boundsForRangeCallback): Ditto.
(rangeForPositionCallback): Ditto.
(stringForRangeCallback): Ditto.
(attributedStringForRangeCallback): Ditto.
(uiElementCountForSearchPredicateCallback): Use the free adopt
function instead of the adopt member function.
(uiElementForSearchPredicateCallback): Ditto.
(selectTextWithCriteriaCallback): Don't adopt at this level.
(attributedStringForElementCallback): Ditto.
(setValueCallback): Use free adopt.
(stringAttributeValueCallback): Don't adopt at this level.
(uiElementArrayAttributeValueCallback): Ditto.
(uiElementAttributeValueCallback): Ditto.
(stringForTextMarkerRangeCallback): Ditto.
(attributedStringForTextMarkerRangeCallback): Ditto.
(attributedStringForTextMarkerRangeWithOptionsCallback): Ditto.
(getARIADropEffectsCallback): Ditto.
(getClassListCallback): Ditto.
(getRoleCallback): Ditto.
(getSubroleCallback): Ditto.
(getRoleDescriptionCallback): Ditto.
(getComputedRoleStringCallback): Ditto.
(getTitleCallback): Ditto.
(getDescriptionCallback): Ditto.
(getStringValueCallback): Ditto.
(getLanguageCallback): Ditto.
(getHelpTextCallback): Ditto.
(getOrientationCallback): Ditto.
(getPathDescriptionCallback): Ditto.
(getSelectedTextRangeCallback): Ditto.
(speakAsCallback): Ditto.
(getValueDescriptionCallback): Ditto.
(getAccessibilityValueCallback): Ditto.
(getDocumentEncodingCallback): Ditto.
(getDocumentURICallback): Ditto.
(getURLCallback): Ditto.
(characterAtOffsetCallback): Ditto.
(wordAtOffsetCallback): Ditto.
(lineAtOffsetCallback): Ditto.
(sentenceAtOffsetCallback): Ditto.
(stringForSelectionCallback): Ditto.
(getIdentifierCallback): Ditto.
(getTraitsCallback): Ditto.
(supportedActionsCallback): Ditto.
(mathPostscriptsDescriptionCallback): Ditto.
(mathPrescriptsDescriptionCallback): Ditto.
(AccessibilityUIElement::rangeForLine): Updated to return JSRetainPtr.
(AccessibilityUIElement::rangeForPosition): Ditto.
(AccessibilityUIElement::speakAs): Ditto.
(AccessibilityUIElement::pathDescription const): Ditto.
(AccessibilityUIElement::stringForTextMarkerRange): Ditto.
(AccessibilityUIElement::attributedStringForTextMarkerRange): Ditto.
(AccessibilityUIElement::attributedStringForTextMarkerRangeWithOptions): Ditto.

* DumpRenderTree/AccessibilityUIElement.h: Use JSRetainPtr instead of
raw pointers for the results of the functions that create strings.
The old way was difficult to get right; the functions didn't even follow
the create/copy naming rule.

* DumpRenderTree/Bindings/CodeGeneratorDumpRenderTree.pm:
(_platformTypeConstructor): Use the adopt function instead of the
JSRetainPtr adopt constructor. Also nullptr instead of 0.

* DumpRenderTree/GCController.cpp:
(GCController::makeWindowObject): Use adopt function instead of constructor.

* DumpRenderTree/TestRunner.cpp:
(pathToLocalResourceCallback): Use adopt function instead of constructor.
(addDisallowedURLCallback): Ditto.
(addURLToRedirectCallback): Ditto.
(clearApplicationCacheForOriginCallback): Ditto.
(applicationCacheDiskUsageForOriginCallback): Ditto.
(decodeHostNameCallback): Don't adopt at this level.
(encodeHostNameCallback): Ditto.
(execCommandCallback): Use adopt instead of JSRetainPtr::adopt.
(findStringCallback): Use adopt function instead of constructor.
(isCommandEnabledCallback): Ditto.
(overridePreferenceCallback): Ditto.
(queueLoadCallback): Ditto.
(queueLoadHTMLStringCallback): Ditto.
(queueLoadingScriptCallback): Ditto.
(queueNonLoadingScriptCallback): Ditto.
(setAuthenticationPasswordCallback): Ditto.
(setAuthenticationUsernameCallback): Ditto.
(setDomainRelaxationForbiddenForURLSchemeCallback): Ditto.
(setMockGeolocationPositionUnavailableErrorCallback): Ditto.
(setPOSIXLocaleCallback): Ditto.
(setPersistentUserStyleSheetLocationCallback): Ditto.
(setUserStyleSheetLocationCallback): Ditto.
(setValueForUserCallback): Ditto.
(setWillSendRequestClearHeaderCallback): Ditto.
(setPageVisibilityCallback): Ditto.
(evaluateInWebInspectorCallback): Ditto.
(evaluateScriptInIsolatedWorldCallback): Ditto.
(evaluateScriptInIsolatedWorldAndReturnValueCallback): Ditto.
(addOriginAccessWhitelistEntryCallback): Ditto.
(removeOriginAccessWhitelistEntryCallback): Ditto.
(setScrollbarPolicyCallback): Ditto.
(addUserScriptCallback): Ditto.
(addUserStyleSheetCallback): Ditto.
(apiTestNewWindowDataLoadBaseURLCallback): Ditto.
(authenticateSessionCallback): Ditto.
(getTitleTextDirectionCallback): Ditto.
(getInspectorTestStubURLCallback): Ditto.
(simulateLegacyWebNotificationClickCallback): Ditto.
(setTextDirectionCallback): Ditto.
(grantWebNotificationPermissionCallback): Ditto.
(denyWebNotificationPermissionCallback): Ditto.
(accummulateLogsForChannel): Ditto.
(runUIScriptCallback): Ditto.
(TestRunner::makeWindowObject): Ditto.
(TestRunner::uiScriptDidComplete): Ditto.
(TestRunner::setOpenPanelFiles): Ditto.

* DumpRenderTree/TestRunner.h: Use JSRetainPtr instead of
raw pointers for the results of the functions that create strings.

* DumpRenderTree/ios/AccessibilityControllerIOS.mm:
(AccessibilityController::platformName const): Use the adopt
function instead of the adopt constructor.

* DumpRenderTree/ios/AccessibilityUIElementIOS.mm:
(createEmptyJSString): Added. This helper function makes reduces the
repetitive code to create empty strings.
(concatenateAttributeAndValue): Changed to return a JSRetainPtr.
(AccessibilityUIElement::identifier): Ditto.
(AccessibilityUIElement::traits): Ditto.
(AccessibilityUIElement::url): Ditto.
(AccessibilityUIElement::speakAs): Ditto.
(AccessibilityUIElement::stringForSelection): Ditto.
(AccessibilityUIElement::stringForRange): Ditto.
(AccessibilityUIElement::attributedStringForRange): Ditto.
(AccessibilityUIElement::attributedStringForElement): Ditto.
(AccessibilityUIElement::pathDescription const): Ditto.
(AccessibilityUIElement::stringForTextMarkerRange): Ditto.
(AccessibilityUIElement::attributedStringForTextMarkerRange): Ditto.
(AccessibilityUIElement::attributedStringForTextMarkerRangeWithOptions): Ditto.
(AccessibilityUIElement::attributesOfLinkedUIElements): Ditto.
(AccessibilityUIElement::attributesOfDocumentLinks): Ditto.
(AccessibilityUIElement::attributesOfChildren): Ditto.
(AccessibilityUIElement::allAttributes): Ditto.
(AccessibilityUIElement::stringAttributeValue): Ditto.
(AccessibilityUIElement::parameterizedAttributeNames): Ditto.
(AccessibilityUIElement::role): Ditto.
(AccessibilityUIElement::subrole): Ditto.
(AccessibilityUIElement::roleDescription): Ditto.
(AccessibilityUIElement::computedRoleString): Ditto.
(AccessibilityUIElement::title): Ditto.
(AccessibilityUIElement::description): Ditto.
(AccessibilityUIElement::orientation const): Ditto.
(AccessibilityUIElement::stringValue): Ditto.
(AccessibilityUIElement::language): Ditto.
(AccessibilityUIElement::helpText const): Ditto.
(AccessibilityUIElement::valueDescription): Ditto.
(AccessibilityUIElement::ariaDropEffects const): Ditto.
(AccessibilityUIElement::boundsForRange): Ditto.
(AccessibilityUIElement::attributesOfColumnHeaders): Ditto.
(AccessibilityUIElement::attributesOfRowHeaders): Ditto.
(AccessibilityUIElement::attributesOfColumns): Ditto.
(AccessibilityUIElement::attributesOfRows): Ditto.
(AccessibilityUIElement::attributesOfVisibleCells): Ditto.
(AccessibilityUIElement::attributesOfHeader): Ditto.
(AccessibilityUIElement::rowIndexRange): Ditto.
(AccessibilityUIElement::columnIndexRange): Ditto.
(AccessibilityUIElement::selectedTextRange): Ditto.
(AccessibilityUIElement::accessibilityValue const): Ditto.
(AccessibilityUIElement::documentEncoding): Ditto.
(AccessibilityUIElement::documentURI): Ditto.
(AccessibilityUIElement::selectTextWithCriteria): Ditto.
(AccessibilityUIElement::classList const): Ditto.

* DumpRenderTree/mac/AccessibilityCommonMac.h: Changed the
createJSStringRef method to return a JSRetainPtr.
* DumpRenderTree/mac/AccessibilityCommonMac.mm:
(-[NSString createJSStringRef]): Ditto.
(searchPredicateParameterizedAttributeForSearchCriteria): Use the
adopt function instead of the adopt constructor.
* DumpRenderTree/mac/AccessibilityControllerMac.mm:
(AccessibilityController::platformName const): Ditto.

* DumpRenderTree/mac/AccessibilityNotificationHandler.mm:
(-[NSString createJSStringRef]): Return a JSRetainPtr.
(makeValueRefForValue): Updated for the above, no adopt needed here now.
(makeObjectRefForDictionary): Ditto.
(-[AccessibilityNotificationHandler _notificationReceived:]): Ditto.

* DumpRenderTree/mac/AccessibilityUIElementMac.mm:
(createEmptyJSString): Added. This helper function makes reduces the
repetitive code to create empty strings.
(concatenateAttributeAndValue): Changed to return a JSRetainPtr.
(descriptionOfElements): Ditto.
(selectTextParameterizedAttributeForCriteria): Ditto.
(AccessibilityUIElement::attributesOfLinkedUIElements): Ditto.
(AccessibilityUIElement::attributesOfDocumentLinks): Ditto.
(AccessibilityUIElement::attributesOfChildren): Ditto.
(AccessibilityUIElement::allAttributes): Ditto.
(AccessibilityUIElement::stringAttributeValue): Ditto.
(AccessibilityUIElement::parameterizedAttributeNames): Ditto.
(AccessibilityUIElement::role): Ditto.
(AccessibilityUIElement::subrole): Ditto.
(AccessibilityUIElement::roleDescription): Ditto.
(AccessibilityUIElement::computedRoleString): Ditto.
(AccessibilityUIElement::title): Ditto.
(AccessibilityUIElement::description): Ditto.
(AccessibilityUIElement::orientation const): Ditto.
(AccessibilityUIElement::stringValue): Ditto.
(AccessibilityUIElement::language): Ditto.
(AccessibilityUIElement::helpText const): Ditto.
(AccessibilityUIElement::valueDescription): Ditto.
(AccessibilityUIElement::speakAs): Ditto.
(AccessibilityUIElement::classList const): Ditto.
(AccessibilityUIElement::ariaDropEffects const): Ditto.
(AccessibilityUIElement::rangeForLine): Ditto.
(AccessibilityUIElement::rangeForPosition): Ditto.
(AccessibilityUIElement::boundsForRange): Ditto.
(AccessibilityUIElement::stringForRange): Ditto.
(AccessibilityUIElement::attributedStringForRange): Ditto.
(AccessibilityUIElement::selectTextWithCriteria): Ditto.
(AccessibilityUIElement::attributesOfColumnHeaders): Ditto.
(AccessibilityUIElement::attributesOfRowHeaders): Ditto.
(AccessibilityUIElement::attributesOfColumns): Ditto.
(AccessibilityUIElement::attributesOfRows): Ditto.
(AccessibilityUIElement::attributesOfVisibleCells): Ditto.
(AccessibilityUIElement::attributesOfHeader): Ditto.
(AccessibilityUIElement::rowIndexRange): Ditto.
(AccessibilityUIElement::columnIndexRange): Ditto.
(AccessibilityUIElement::pathDescription const): Ditto.
(AccessibilityUIElement::selectedTextRange): Ditto.
(AccessibilityUIElement::accessibilityValue const): Ditto.
(AccessibilityUIElement::documentEncoding): Ditto.
(AccessibilityUIElement::documentURI): Ditto.
(AccessibilityUIElement::url): Ditto.
(AccessibilityUIElement::stringForTextMarkerRange): Ditto.
(createJSStringRef): Ditto.
(AccessibilityUIElement::attributedStringForTextMarkerRange): Ditto.
(AccessibilityUIElement::attributedStringForTextMarkerRangeWithOptions): Ditto.
(AccessibilityUIElement::supportedActions): Ditto.
(AccessibilityUIElement::mathPostscriptsDescription const): Ditto.
(AccessibilityUIElement::mathPrescriptsDescription const): Ditto.

* DumpRenderTree/mac/FrameLoadDelegate.mm:
(-[FrameLoadDelegate didClearWindowObjectForFrame:inIsolatedWorld:]):
Use the adopt function instead of the adopt constructor.
* DumpRenderTree/mac/TestRunnerMac.mm:
(originsArrayToJS): Ditto.
(TestRunner::copyDecodedHostName): Return a JSRetainPtr.
(TestRunner::copyEncodedHostName): Ditto.
(TestRunner::pathToLocalResource): Ditto.
(TestRunner::queueLoad): Use adopt function instead of constructor.
(TestRunner::findString): Ditto.
(TestRunner::inspectorTestStubURL): Return a JSRetainPtr.

* DumpRenderTree/win/AccessibilityControllerWin.cpp:
(AccessibilityController::winNotificationReceived): Use adopt function
instead of adopt constructor.
(AccessibilityController::platformName const): Ditto.

* DumpRenderTree/win/AccessibilityUIElementWin.cpp:
(createEmptyJSString): Added. This helper function makes reduces the
repetitive code to create empty strings.
(AccessibilityUIElement::allAttributes): Changed to return a JSRetainPtr.
(AccessibilityUIElement::attributesOfLinkedUIElements): Ditto.
(AccessibilityUIElement::attributesOfDocumentLinks): Ditto.
(AccessibilityUIElement::attributesOfChildren): Ditto.
(AccessibilityUIElement::parameterizedAttributeNames): Ditto.
(AccessibilityUIElement::role): Ditto.
(AccessibilityUIElement::subrole): Ditto.
(AccessibilityUIElement::roleDescription): Ditto.
(AccessibilityUIElement::computedRoleString): Ditto.
(AccessibilityUIElement::title): Ditto.
(AccessibilityUIElement::description): Ditto.
(AccessibilityUIElement::stringValue): Ditto.
(AccessibilityUIElement::language): Ditto.
(AccessibilityUIElement::helpText const): Ditto.
(AccessibilityUIElement::valueDescription): Ditto.
(AccessibilityUIElement::ariaDropEffects const): Ditto.
(AccessibilityUIElement::orientation const): Ditto.
(AccessibilityUIElement::attributesOfColumnHeaders): Ditto.
(AccessibilityUIElement::attributesOfRowHeaders): Ditto.
(AccessibilityUIElement::attributesOfColumns): Ditto.
(AccessibilityUIElement::attributesOfRows): Ditto.
(AccessibilityUIElement::attributesOfVisibleCells): Ditto.
(AccessibilityUIElement::attributesOfHeader): Ditto.
(AccessibilityUIElement::rowIndexRange): Ditto.
(AccessibilityUIElement::columnIndexRange): Ditto.
(AccessibilityUIElement::boundsForRange): Ditto.
(AccessibilityUIElement::stringForRange): Ditto.
(AccessibilityUIElement::attributedStringForRange): Ditto.
(AccessibilityUIElement::selectTextWithCriteria): Ditto.
(AccessibilityUIElement::selectedTextRange): Ditto.
(AccessibilityUIElement::stringAttributeValue): Ditto.
(AccessibilityUIElement::accessibilityValue const): Ditto.
(AccessibilityUIElement::documentEncoding): Ditto.
(AccessibilityUIElement::documentURI): Ditto.
(AccessibilityUIElement::url): Ditto.
(AccessibilityUIElement::classList const): Ditto.

* DumpRenderTree/win/TestRunnerWin.cpp:
(TestRunner::copyDecodedHostName): Changed to return a JSRetainPtr.
(TestRunner::copyEncodedHostName): Ditto.
(TestRunner::pathToLocalResource): Ditto.
(TestRunner::queueLoad): Ditto.
(TestRunner::findString): Ditto.
(TestRunner::inspectorTestStubURL): Ditto.

* TestRunnerShared/Bindings/JSWrapper.h:
(WTR::setProperty): Use adopt function instead of constructor.
* TestRunnerShared/UIScriptContext/UIScriptContext.cpp:
(UIScriptContext::UIScriptContext): Ditto.
(UIScriptContext::runUIScript): Ditto.
* TestRunnerShared/UIScriptContext/UIScriptController.cpp:
(WTR::toDeviceOrientation): Ditto.

* TestRunnerShared/cocoa/LayoutTestSpellChecker.mm:
(nsTextCheckingType): Changed this function to not take an rvalue
reference to a JSRetainPtr since it doesn't take ownership.
(-[LayoutTestSpellChecker setResultsFromJSObject:inContext:]): Updated
for the above change.

* TestWebKitAPI/JavaScriptTest.cpp:
(TestWebKitAPI::javaScriptCallback): Use adopt function instead of
adopt member function.

* TestWebKitAPI/Tests/WebKit/WKPageIsPlayingAudio.cpp: Removed unneeded include.
* TestWebKitAPI/Tests/WebKitCocoa/PictureInPictureDelegate.mm: Ditto.
* TestWebKitAPI/Tests/mac/DOMNodeFromJSObject.mm: Use adopt function instead of
adopt constructor.
* TestWebKitAPI/Tests/mac/JSWrapperForNodeInWebFrame.mm: Ditto.

* WebKitTestRunner/InjectedBundle/AccessibilityController.cpp:
Removed unneeded includes.
* WebKitTestRunner/InjectedBundle/AccessibilityTextMarker.cpp: Ditto.
* WebKitTestRunner/InjectedBundle/AccessibilityTextMarkerRange.cpp: Ditto.
* WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp: Ditto.

* WebKitTestRunner/InjectedBundle/Bindings/CodeGeneratorTestRunner.pm:
(_platformTypeConstructor): Use the adopt function instead of the
JSRetainPtr adopt constructor. Also nullptr instead of 0.

* WebKitTestRunner/InjectedBundle/EventSendingController.cpp:
(WTR::arrayLength): Use adopt function instead of constructor.
(WTR::parseModifierArray): Ditto.
* WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
(WTR::propertyValue): Ditto.
(WTR::dumpPath): Ditto.
(WTR::toJS): Ditto.
* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::findString): Ditto.
(WTR::TestRunner::statisticsDidRunTelemetryCallback): Ditto.
(WTR::TestRunner::callDidReceiveAllStorageAccessEntriesCallback): Ditto.
(WTR::TestRunner::setOpenPanelFiles): Ditto.
* WebKitTestRunner/InjectedBundle/ios/AccessibilityControllerIOS.mm:
(WTR::AccessibilityController::platformName): Ditto.

* WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm:
(-[NSString createJSStringRef]): Return a JSRetainPtr.
This fixes storage leaks in many functions below, which were using
the create function and putting the value right into a JSRetainPtr
without adoption.
(WTR::createEmptyJSString): Added. This helper function reduces the
repetitive code to create empty strings.
(WTR::concatenateAttributeAndValue): Return a JSRetainPtr.
(WTR::AccessibilityUIElement::attributesOfLinkedUIElements):
Use createEmptyJSString, fixing a storage leak due to missing adoption.
(WTR::AccessibilityUIElement::attributesOfDocumentLinks): Ditto.
(WTR::AccessibilityUIElement::attributesOfChildren): Ditto.
(WTR::AccessibilityUIElement::allAttributes): Ditto.
(WTR::AccessibilityUIElement::stringAttributeValue): Ditto.
(WTR::AccessibilityUIElement::parameterizedAttributeNames): Ditto.
(WTR::AccessibilityUIElement::role): Ditto.
(WTR::AccessibilityUIElement::subrole): Ditto.
(WTR::AccessibilityUIElement::roleDescription): Ditto.
(WTR::AccessibilityUIElement::computedRoleString): Ditto.
(WTR::AccessibilityUIElement::title): Ditto.
(WTR::AccessibilityUIElement::orientation const): Ditto.
(WTR::AccessibilityUIElement::language): Ditto.
(WTR::AccessibilityUIElement::valueDescription): Ditto.
(WTR::AccessibilityUIElement::ariaDropEffects const): Ditto.
(WTR::AccessibilityUIElement::boundsForRange): Ditto.
(WTR::AccessibilityUIElement::stringForRange): Removed unneeded null check.
(WTR::AccessibilityUIElement::attributedStringForRange): Ditto.
(WTR::AccessibilityUIElement::attributesOfColumnHeaders):
Use createEmptyJSString, fixing a storage leak due to missing adoption.
(WTR::AccessibilityUIElement::attributesOfRowHeaders): Ditto.
(WTR::AccessibilityUIElement::attributesOfColumns): Ditto.
(WTR::AccessibilityUIElement::attributesOfRows): Ditto.
(WTR::AccessibilityUIElement::attributesOfVisibleCells): Ditto.
(WTR::AccessibilityUIElement::attributesOfHeader): Ditto.
(WTR::AccessibilityUIElement::selectedTextRange): Ditto.
(WTR::AccessibilityUIElement::accessibilityValue const): Ditto.
(WTR::AccessibilityUIElement::documentEncoding): Ditto.
(WTR::AccessibilityUIElement::documentURI): Ditto.
(WTR::AccessibilityUIElement::stringForSelection): Removed unneeded
null check.
(WTR::AccessibilityUIElement::stringForTextMarkerRange):
Use createEmptyJSString, fixing a storage leak due to missing adoption.

* WebKitTestRunner/InjectedBundle/mac/AccessibilityCommonMac.h:
Use JSRetainPtr for the return value of createJSStringRef.
* WebKitTestRunner/InjectedBundle/mac/AccessibilityCommonMac.mm:
(-[NSString createJSStringRef]): Ditto.
(WTR::searchPredicateParameterizedAttributeForSearchCriteria): Use the
adopt function instead of the adopt constructor.
* WebKitTestRunner/InjectedBundle/mac/AccessibilityControllerMac.mm:
(WTR::AccessibilityController::platformName): Ditto

* WebKitTestRunner/InjectedBundle/mac/AccessibilityNotificationHandler.mm:
(-[NSString createJSStringRef]): Return a JSRetainPtr.
(makeValueRefForValue): Updated for above by removing adopt.
(makeObjectRefForDictionary): Ditto.
(-[AccessibilityNotificationHandler _notificationReceived:]): Ditto.

* WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm:
(WTR::createEmptyJSString): Added. This helper function makes reduces the
repetitive code to create empty strings.
(WTR::concatenateAttributeAndValue): Return a JSRetainPtr.
(WTR::descriptionOfElements): Ditto.
(WTR::selectTextParameterizedAttributeForCriteria): Ditto.
(WTR::AccessibilityUIElement::accessibilityValue const): Use createEmptyJSString,
fixing a storage leak due to missing adoption.
(WTR::AccessibilityUIElement::documentEncoding): Ditto.
(WTR::AccessibilityUIElement::documentURI): Ditto.
(WTR::createJSStringRef): Return a JSRetainPtr.

* WebKitTestRunner/StringFunctions.h:
(WTR::toWK): Take a const& to eliminate a little bit of reference count churn.
(WTR::toJS): Use the adopt function instead of the constructor.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236032 268f45cc-cd09-0410-ab3c-d52691b4dbfc
60 files changed:
Source/JavaScriptCore/API/JSObjectRef.cpp
Source/JavaScriptCore/API/JSRetainPtr.h
Source/JavaScriptCore/API/JSValue.mm
Source/JavaScriptCore/API/tests/CustomGlobalObjectClassTest.c
Source/JavaScriptCore/API/tests/ExecutionTimeLimitTest.cpp
Source/JavaScriptCore/API/tests/FunctionOverridesTest.cpp
Source/JavaScriptCore/API/tests/JSObjectGetProxyTargetTest.cpp
Source/JavaScriptCore/API/tests/PingPongStackOverflowTest.cpp
Source/JavaScriptCore/API/tests/testapi.c
Source/JavaScriptCore/ChangeLog
Source/WebCore/ChangeLog
Source/WebCore/Modules/plugins/QuickTimePluginReplacement.mm
Source/WebKit/ChangeLog
Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.cpp
Tools/ChangeLog
Tools/DumpRenderTree/AccessibilityController.cpp
Tools/DumpRenderTree/AccessibilityTextMarker.cpp
Tools/DumpRenderTree/AccessibilityUIElement.cpp
Tools/DumpRenderTree/AccessibilityUIElement.h
Tools/DumpRenderTree/Bindings/CodeGeneratorDumpRenderTree.pm
Tools/DumpRenderTree/GCController.cpp
Tools/DumpRenderTree/TestRunner.cpp
Tools/DumpRenderTree/TestRunner.h
Tools/DumpRenderTree/ios/AccessibilityControllerIOS.mm
Tools/DumpRenderTree/ios/AccessibilityUIElementIOS.mm
Tools/DumpRenderTree/mac/AccessibilityCommonMac.h
Tools/DumpRenderTree/mac/AccessibilityCommonMac.mm
Tools/DumpRenderTree/mac/AccessibilityControllerMac.mm
Tools/DumpRenderTree/mac/AccessibilityNotificationHandler.mm
Tools/DumpRenderTree/mac/AccessibilityUIElementMac.mm
Tools/DumpRenderTree/mac/FrameLoadDelegate.mm
Tools/DumpRenderTree/mac/TestRunnerMac.mm
Tools/DumpRenderTree/win/AccessibilityControllerWin.cpp
Tools/DumpRenderTree/win/AccessibilityUIElementWin.cpp
Tools/DumpRenderTree/win/TestRunnerWin.cpp
Tools/TestRunnerShared/Bindings/JSWrapper.h
Tools/TestRunnerShared/UIScriptContext/UIScriptContext.cpp
Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp
Tools/TestRunnerShared/cocoa/LayoutTestSpellChecker.mm
Tools/TestWebKitAPI/JavaScriptTest.cpp
Tools/TestWebKitAPI/Tests/WebKit/WKPageIsPlayingAudio.cpp
Tools/TestWebKitAPI/Tests/WebKitCocoa/PictureInPictureDelegate.mm
Tools/TestWebKitAPI/Tests/mac/DOMNodeFromJSObject.mm
Tools/TestWebKitAPI/Tests/mac/JSWrapperForNodeInWebFrame.mm
Tools/WebKitTestRunner/InjectedBundle/AccessibilityController.cpp
Tools/WebKitTestRunner/InjectedBundle/AccessibilityTextMarker.cpp
Tools/WebKitTestRunner/InjectedBundle/AccessibilityTextMarkerRange.cpp
Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp
Tools/WebKitTestRunner/InjectedBundle/Bindings/CodeGeneratorTestRunner.pm
Tools/WebKitTestRunner/InjectedBundle/EventSendingController.cpp
Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp
Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp
Tools/WebKitTestRunner/InjectedBundle/ios/AccessibilityControllerIOS.mm
Tools/WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm
Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityCommonMac.h
Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityCommonMac.mm
Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityControllerMac.mm
Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityNotificationHandler.mm
Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm
Tools/WebKitTestRunner/StringFunctions.h