Diff
Modified: trunk/Source/WebKit/mac/ChangeLog (203185 => 203186)
--- trunk/Source/WebKit/mac/ChangeLog 2016-07-13 20:33:33 UTC (rev 203185)
+++ trunk/Source/WebKit/mac/ChangeLog 2016-07-13 20:51:01 UTC (rev 203186)
@@ -1,3 +1,15 @@
+2016-07-13 Beth Dakin <[email protected]>
+
+ Add more candidate tests
+ https://bugs.webkit.org/show_bug.cgi?id=159730
+
+ Reviewed by Tim Horton.
+
+ Move shouldRequestCandidates from WebViewInternal to WebViewPrivate so that
+ we can use it in tests.
+ * WebView/WebViewInternal.h:
+ * WebView/WebViewPrivate.h:
+
2016-07-13 Enrica Casucci <[email protected]>
Update supported platforms in xcconfig files to match the sdk names.
Modified: trunk/Source/WebKit/mac/WebView/WebViewInternal.h (203185 => 203186)
--- trunk/Source/WebKit/mac/WebView/WebViewInternal.h 2016-07-13 20:33:33 UTC (rev 203185)
+++ trunk/Source/WebKit/mac/WebView/WebViewInternal.h 2016-07-13 20:51:01 UTC (rev 203186)
@@ -297,7 +297,6 @@
@interface WebView (WebUpdateWebViewAdditions)
- (void)updateWebViewAdditions;
-- (BOOL)shouldRequestCandidates;
- (void)webViewAdditionsWillDestroyView;
- (id)candidateList;
@end
Modified: trunk/Source/WebKit/mac/WebView/WebViewPrivate.h (203185 => 203186)
--- trunk/Source/WebKit/mac/WebView/WebViewPrivate.h 2016-07-13 20:33:33 UTC (rev 203185)
+++ trunk/Source/WebKit/mac/WebView/WebViewPrivate.h 2016-07-13 20:51:01 UTC (rev 203186)
@@ -1070,6 +1070,7 @@
@interface WebView (WebShowCandidates)
- (void)showCandidates:(NSArray *)candidates forString:(NSString *)string inRect:(NSRect)rectOfTypedString forSelectedRange:(NSRange)range view:(NSView *)view completionHandler:(void (^)(NSTextCheckingResult *acceptedCandidate))completionBlock;
- (void)forceRequestCandidatesForTesting;
+- (BOOL)shouldRequestCandidates;
@end
#ifdef __cplusplus
Modified: trunk/Tools/ChangeLog (203185 => 203186)
--- trunk/Tools/ChangeLog 2016-07-13 20:33:33 UTC (rev 203185)
+++ trunk/Tools/ChangeLog 2016-07-13 20:51:01 UTC (rev 203186)
@@ -1,3 +1,19 @@
+2016-07-13 Beth Dakin <[email protected]>
+
+ Add more candidate tests
+ https://bugs.webkit.org/show_bug.cgi?id=159730
+
+ Reviewed by Tim Horton.
+
+ This patch re-names ViewWithEditableAreaLeak.mm to CandidateTests.mm and adds
+ two new tests to that file.
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/Tests/WebKit2Cocoa/focus-inputs.html: Added.
+ * TestWebKitAPI/Tests/mac/CandidateTests.mm: Copied from TestWebKitAPI/Tests/mac/ViewWithEditableAreaLeak.mm.
+ (-[CandidateRequestFrameLoadDelegate webView:didFinishLoadForFrame:]):
+ (TestWebKitAPI::TEST):
+ * TestWebKitAPI/Tests/mac/ViewWithEditableAreaLeak.mm: Removed.
+
2016-07-13 Joanmarie Diggs <[email protected]>
AX: [ATK] spinbutton-crash.html fails
Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (203185 => 203186)
--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2016-07-13 20:33:33 UTC (rev 203185)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2016-07-13 20:51:01 UTC (rev 203186)
@@ -167,7 +167,7 @@
7C83E03D1D0A60D600FEBCF3 /* UtilitiesCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7C83E0391D0A602700FEBCF3 /* UtilitiesCocoa.mm */; };
7C83E03F1D0A61A000FEBCF3 /* libicucore.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 7C83E0331D0A5F2700FEBCF3 /* libicucore.dylib */; };
7C83E0401D0A63E300FEBCF3 /* FirstResponderScrollingPosition.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9B79164F1BD89D0D00D50B8F /* FirstResponderScrollingPosition.mm */; };
- 7C83E0411D0A63F200FEBCF3 /* ViewWithEditableAreaLeak.mm in Sources */ = {isa = PBXBuildFile; fileRef = 93CFA8681CEBCFED000565A8 /* ViewWithEditableAreaLeak.mm */; };
+ 7C83E0411D0A63F200FEBCF3 /* CandidateTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 93CFA8681CEBCFED000565A8 /* CandidateTests.mm */; };
7C83E0421D0A63FD00FEBCF3 /* WebViewCloseInsideDidFinishLoadForFrame.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51B454EB1B4E236B0085EAA6 /* WebViewCloseInsideDidFinishLoadForFrame.mm */; };
7C83E04C1D0A641800FEBCF3 /* WebCoreNSURLSession.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD89D0381C4EDB2A00040A04 /* WebCoreNSURLSession.mm */; };
7C83E04D1D0A641800FEBCF3 /* DFACombiner.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 260BA5781B1D2E7B004FA07C /* DFACombiner.cpp */; };
@@ -342,6 +342,7 @@
835CF9671D25FCD6001A65D4 /* RestoreSessionStateWithoutNavigation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 835CF9661D25FCD6001A65D4 /* RestoreSessionStateWithoutNavigation.cpp */; };
83CF1C301C4F1B8B00688447 /* StringUtilities.mm in Sources */ = {isa = PBXBuildFile; fileRef = 83CF1C2C1C4F19AE00688447 /* StringUtilities.mm */; };
930AD402150698D00067970F /* lots-of-text.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 930AD401150698B30067970F /* lots-of-text.html */; };
+ 93575C561D30368A000D604D /* focus-inputs.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 93575C551D30366E000D604D /* focus-inputs.html */; };
9361002914DC95A70061379D /* lots-of-iframes.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 9361002814DC957B0061379D /* lots-of-iframes.html */; };
93625D271CD9741C006DC1F1 /* large-video-without-audio.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 93625D261CD973AF006DC1F1 /* large-video-without-audio.html */; };
936F72801CD7D9EC0068A0FB /* large-video-with-audio.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 936F727E1CD7D9D00068A0FB /* large-video-with-audio.html */; };
@@ -836,6 +837,7 @@
8DD76FA10486AA7600D96B5E /* TestWebKitAPI */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = TestWebKitAPI; sourceTree = BUILT_PRODUCTS_DIR; };
930AD401150698B30067970F /* lots-of-text.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "lots-of-text.html"; sourceTree = "<group>"; };
9331407B17B4419000F083B1 /* DidNotHandleKeyDown.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DidNotHandleKeyDown.cpp; sourceTree = "<group>"; };
+ 93575C551D30366E000D604D /* focus-inputs.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "focus-inputs.html"; sourceTree = "<group>"; };
9361002814DC957B0061379D /* lots-of-iframes.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "lots-of-iframes.html"; sourceTree = "<group>"; };
93625D261CD973AF006DC1F1 /* large-video-without-audio.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "large-video-without-audio.html"; sourceTree = "<group>"; };
936F727E1CD7D9D00068A0FB /* large-video-with-audio.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "large-video-with-audio.html"; sourceTree = "<group>"; };
@@ -853,7 +855,7 @@
93AF4ECD1506F064007FD57E /* NewFirstVisuallyNonEmptyLayoutForImages_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NewFirstVisuallyNonEmptyLayoutForImages_Bundle.cpp; sourceTree = "<group>"; };
93AF4ECF1506F123007FD57E /* lots-of-images.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "lots-of-images.html"; sourceTree = "<group>"; };
93CFA8661CEB9DE1000565A8 /* autofocused-text-input.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "autofocused-text-input.html"; sourceTree = "<group>"; };
- 93CFA8681CEBCFED000565A8 /* ViewWithEditableAreaLeak.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ViewWithEditableAreaLeak.mm; sourceTree = "<group>"; };
+ 93CFA8681CEBCFED000565A8 /* CandidateTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CandidateTests.mm; sourceTree = "<group>"; };
93D3D19B17B1A7B000C7C415 /* all-content-in-one-iframe.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "all-content-in-one-iframe.html"; sourceTree = "<group>"; };
93D3D19D17B1A84200C7C415 /* LayoutMilestonesWithAllContentInFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LayoutMilestonesWithAllContentInFrame.cpp; sourceTree = "<group>"; };
93E943F11CD3E87E00AC08C2 /* VideoControlsManager.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = VideoControlsManager.mm; sourceTree = "<group>"; };
@@ -1295,6 +1297,8 @@
A16F66B81C40E9E100BD4D24 /* Resources */ = {
isa = PBXGroup;
children = (
+ 93575C551D30366E000D604D /* focus-inputs.html */,
+ 93CFA8661CEB9DE1000565A8 /* autofocused-text-input.html */,
9984FACD1CFFB038008D198C /* editable-body.html */,
CDE195B21CFE0ADE0053D256 /* FullscreenTopContentInset.html */,
A16F66B91C40EA2000BD4D24 /* ContentFiltering.html */,
@@ -1317,7 +1321,6 @@
46C519E41D35629600DAA51A /* LocalStorageNullEntries.localstorage-shm */,
51714EB21CF8C761004723C4 /* WebProcessKillIDBCleanup-1.html */,
51714EB31CF8C761004723C4 /* WebProcessKillIDBCleanup-2.html */,
- 93CFA8661CEB9DE1000565A8 /* autofocused-text-input.html */,
936F727E1CD7D9D00068A0FB /* large-video-with-audio.html */,
936F727F1CD7D9D00068A0FB /* large-video-with-audio.mp4 */,
93625D261CD973AF006DC1F1 /* large-video-without-audio.html */,
@@ -1686,7 +1689,7 @@
939BFE3918E5548900883275 /* StringTruncator.mm */,
37A6895D148A9B50005100FA /* SubresourceErrorCrash.mm */,
E490296714E2E3A4002BEDD1 /* TypingStyleCrash.mm */,
- 93CFA8681CEBCFED000565A8 /* ViewWithEditableAreaLeak.mm */,
+ 93CFA8681CEBCFED000565A8 /* CandidateTests.mm */,
51FBBB4C1513D4E900822738 /* WebViewCanPasteURL.mm */,
C2EB2DD116CAC7AC009B52EE /* WebViewDidCreateJavaScriptContext.mm */,
51B454EB1B4E236B0085EAA6 /* WebViewCloseInsideDidFinishLoadForFrame.mm */,
@@ -2092,7 +2095,7 @@
7C83E0421D0A63FD00FEBCF3 /* WebViewCloseInsideDidFinishLoadForFrame.mm in Sources */,
7CCE7EBE1A411A7E00447C4C /* DynamicDeviceScaleFactor.mm in Sources */,
37BCA61C1B596BA9002012CA /* ShouldOpenExternalURLsInNewWindowActions.mm in Sources */,
- 7C83E0411D0A63F200FEBCF3 /* ViewWithEditableAreaLeak.mm in Sources */,
+ 7C83E0411D0A63F200FEBCF3 /* CandidateTests.mm in Sources */,
7CEFA9661AC0B9E200B910FD /* _WKUserContentExtensionStore.mm in Sources */,
7CCE7EE01A411A9A00447C4C /* EditorCommands.mm in Sources */,
7CCE7EBF1A411A7E00447C4C /* ElementAtPointInWebFrame.mm in Sources */,
Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/focus-inputs.html (0 => 203186)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/focus-inputs.html (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/focus-inputs.html 2016-07-13 20:51:01 UTC (rev 203186)
@@ -0,0 +1,15 @@
+<html>
+<head>
+<script>
+function focusPasswordField() {
+ var password = document.getElementById("password");
+ password.focus();
+}
+</script>
+</head>
+
+<body>
+<input type="text" autofocus/>
+<input id="password" type="password" />
+</body>
+</html>
Copied: trunk/Tools/TestWebKitAPI/Tests/mac/CandidateTests.mm (from rev 203185, trunk/Tools/TestWebKitAPI/Tests/mac/ViewWithEditableAreaLeak.mm) (0 => 203186)
--- trunk/Tools/TestWebKitAPI/Tests/mac/CandidateTests.mm (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/mac/CandidateTests.mm 2016-07-13 20:51:01 UTC (rev 203186)
@@ -0,0 +1,148 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#import "PlatformUtilities.h"
+#import <WebKit/WebViewPrivate.h>
+#import <wtf/RetainPtr.h>
+
+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
+
+static bool webViewWasDeallocated = false;
+static bool didFinishLoad = false;
+static bool didCallShowCandidates = false;
+static bool candidatesWereRequested = false;
+
+@interface DoNotLeakWebView : WebView
+@end
+
+@implementation DoNotLeakWebView
+
+- (void)dealloc
+{
+ webViewWasDeallocated = true;
+ [super dealloc];
+}
+
+- (void)showCandidates:(NSArray *)candidates forString:(NSString *)string inRect:(NSRect)rectOfTypedString forSelectedRange:(NSRange)range view:(NSView *)view completionHandler:(void (^)(NSTextCheckingResult *acceptedCandidate))completionBlock
+{
+ [super showCandidates:candidates forString:string inRect:rectOfTypedString forSelectedRange:range view:view completionHandler:completionBlock];
+ didCallShowCandidates = true;
+}
+
+@end
+
+@interface DoNotLeakFrameLoadDelegate : NSObject <WebFrameLoadDelegate> {
+}
+@end
+
+@implementation DoNotLeakFrameLoadDelegate
+
+- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame
+{
+ [sender forceRequestCandidatesForTesting];
+ didFinishLoad = true;
+}
+
+@end
+
+@interface CandidateRequestFrameLoadDelegate : NSObject <WebFrameLoadDelegate> {
+}
+@end
+
+@implementation CandidateRequestFrameLoadDelegate
+
+- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame
+{
+ didFinishLoad = true;
+}
+
+@end
+
+namespace TestWebKitAPI {
+
+TEST(CandidateTests, DoNotLeakViewThatLoadsEditableArea)
+{
+ DoNotLeakWebView *webView = [[DoNotLeakWebView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)];
+ DoNotLeakFrameLoadDelegate *delegate = [[DoNotLeakFrameLoadDelegate alloc] init];
+ [webView setFrameLoadDelegate:delegate];
+
+ NSURL *contentURL = [[NSBundle mainBundle] URLForResource:@"autofocused-text-input" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"];
+ [[webView mainFrame] loadRequest:[NSURLRequest requestWithURL:contentURL]];
+
+ TestWebKitAPI::Util::run(&didFinishLoad);
+ TestWebKitAPI::Util::run(&didCallShowCandidates);
+
+ [webView release];
+ EXPECT_TRUE(webViewWasDeallocated);
+}
+
+TEST(CandidateTests, RequestCandidatesForTextInput)
+{
+ WebView *webView = [[WebView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)];
+ [webView forceRequestCandidatesForTesting];
+ CandidateRequestFrameLoadDelegate *delegate = [[CandidateRequestFrameLoadDelegate alloc] init];
+ [webView setFrameLoadDelegate:delegate];
+
+ NSURL *contentURL = [[NSBundle mainBundle] URLForResource:@"focus-inputs" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"];
+ [[webView mainFrame] loadRequest:[NSURLRequest requestWithURL:contentURL]];
+
+ TestWebKitAPI::Util::run(&didFinishLoad);
+
+ [webView forceRequestCandidatesForTesting];
+
+ if ([webView shouldRequestCandidates])
+ candidatesWereRequested = true;
+
+ [webView release];
+ EXPECT_TRUE(candidatesWereRequested);
+}
+
+TEST(CandidateTests, DoNotRequestCandidatesForPasswordInput)
+{
+ WebView *webView = [[WebView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)];
+ [webView forceRequestCandidatesForTesting];
+ CandidateRequestFrameLoadDelegate *delegate = [[CandidateRequestFrameLoadDelegate alloc] init];
+ [webView setFrameLoadDelegate:delegate];
+
+ NSURL *contentURL = [[NSBundle mainBundle] URLForResource:@"focus-inputs" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"];
+ [[webView mainFrame] loadRequest:[NSURLRequest requestWithURL:contentURL]];
+
+ TestWebKitAPI::Util::run(&didFinishLoad);
+
+ [webView forceRequestCandidatesForTesting];
+ [webView stringByEvaluatingJavaScriptFromString:@"focusPasswordField()"];
+
+ if ([webView shouldRequestCandidates])
+ candidatesWereRequested = true;
+
+ [webView release];
+ EXPECT_FALSE(candidatesWereRequested);
+}
+
+}
+
+#endif // PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
Deleted: trunk/Tools/TestWebKitAPI/Tests/mac/ViewWithEditableAreaLeak.mm (203185 => 203186)
--- trunk/Tools/TestWebKitAPI/Tests/mac/ViewWithEditableAreaLeak.mm 2016-07-13 20:33:33 UTC (rev 203185)
+++ trunk/Tools/TestWebKitAPI/Tests/mac/ViewWithEditableAreaLeak.mm 2016-07-13 20:51:01 UTC (rev 203186)
@@ -1,91 +0,0 @@
-/*
- * Copyright (C) 2016 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#import "PlatformUtilities.h"
-#import <WebKit/WebViewPrivate.h>
-#import <wtf/RetainPtr.h>
-
-#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
-
-static bool webViewWasDeallocated = false;
-static bool didFinishLoad = false;
-static bool didCallShowCandidates = false;
-
-@interface DoNotLeakWebView : WebView
-@end
-
-@implementation DoNotLeakWebView
-
-- (void)dealloc
-{
- webViewWasDeallocated = true;
- [super dealloc];
-}
-
-- (void)showCandidates:(NSArray *)candidates forString:(NSString *)string inRect:(NSRect)rectOfTypedString forSelectedRange:(NSRange)range view:(NSView *)view completionHandler:(void (^)(NSTextCheckingResult *acceptedCandidate))completionBlock
-{
- [super showCandidates:candidates forString:string inRect:rectOfTypedString forSelectedRange:range view:view completionHandler:completionBlock];
- didCallShowCandidates = true;
-}
-
-@end
-
-@interface DoNotLeakFrameLoadDelegate : NSObject <WebFrameLoadDelegate> {
-}
-@end
-
-@implementation DoNotLeakFrameLoadDelegate
-
-- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame
-{
- [sender forceRequestCandidatesForTesting];
- didFinishLoad = true;
-}
-
-@end
-
-namespace TestWebKitAPI {
-
-TEST(DoNotLeakWebView, ViewThatLoadsEditableArea)
-{
- DoNotLeakWebView *webView = [[DoNotLeakWebView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)];
- DoNotLeakFrameLoadDelegate *delegate = [[DoNotLeakFrameLoadDelegate alloc] init];
- [webView setFrameLoadDelegate:delegate];
-
- NSURL *contentURL = [[NSBundle mainBundle] URLForResource:@"autofocused-text-input" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"];
- [[webView mainFrame] loadRequest:[NSURLRequest requestWithURL:contentURL]];
-
- TestWebKitAPI::Util::run(&didFinishLoad);
- TestWebKitAPI::Util::run(&didCallShowCandidates);
-
- [webView release];
- EXPECT_TRUE(webViewWasDeallocated);
-}
-
-}
-
-#endif // PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200