Changeset 219836 in webkit
- Timestamp:
- Jul 24, 2017 1:58:09 PM (7 years ago)
- Location:
- trunk/Tools
- Files:
-
- 3 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r219830 r219836 1 2017-07-24 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 [Mac WK2] Add an API test to cover r219765 (null dereference in [WKWebView dealloc]) 4 https://bugs.webkit.org/show_bug.cgi?id=174793 5 6 Reviewed by Tim Horton. 7 8 Adds a new unit test that invokes some asynchronous NSTextInputClient SPI methods as the web view is tearing 9 down. Without r219765, this test will dereference null and crash. 10 11 * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: 12 * TestWebKitAPI/Tests/TestWebKitAPI/mac/NSTextInputClientSPI.h: Added. 13 * TestWebKitAPI/Tests/mac/WKWebViewSelectionTests.mm: 14 (TEST): 15 1 16 2017-07-24 Basuke Suzuki <Basuke.Suzuki@sony.com> 2 17 -
trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
r219768 r219836 1089 1089 2E7765CC16C4D80A00BA2BB1 /* mainIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = mainIOS.mm; sourceTree = "<group>"; }; 1090 1090 2E7765CE16C4D81100BA2BB1 /* mainMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = mainMac.mm; sourceTree = "<group>"; }; 1091 2E7EF7AC1F266A8100DFB67C /* NSTextInputClientSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NSTextInputClientSPI.h; sourceTree = "<group>"; }; 1091 1092 2E9896141D8F092B00739892 /* text-and-password-inputs.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "text-and-password-inputs.html"; sourceTree = "<group>"; }; 1092 1093 2ECFF5541D9B12F800B55394 /* NowPlayingControlsTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NowPlayingControlsTests.mm; sourceTree = "<group>"; }; … … 2649 2650 children = ( 2650 2651 C08587FB13FEC39B001EF4E5 /* InstanceMethodSwizzler.mm */, 2652 2E7EF7AC1F266A8100DFB67C /* NSTextInputClientSPI.h */, 2651 2653 ); 2652 2654 path = mac; -
trunk/Tools/TestWebKitAPI/Tests/TestWebKitAPI/mac/NSTextInputClientSPI.h
r219833 r219836 24 24 */ 25 25 26 #i nclude "config.h"26 #if PLATFORM(MAC) 27 27 28 #if WK_API_ENABLED && PLATFORM(MAC)28 #if USE(APPLE_INTERNAL_SDK) 29 29 30 #import "PlatformUtilities.h" 31 #import "TestWKWebView.h" 30 #import <AppKit/NSTextInputClient_Private.h> 32 31 33 TEST(WKWebViewSelectionTests, DoubleClickDoesNotSelectTrailingSpace) 34 { 35 RetainPtr<TestWKWebView> webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 400, 400)]); 36 [webView synchronouslyLoadTestPageNamed:@"double-click-does-not-select-trailing-space"]; 32 #else 37 33 38 __block bool finishedSelectingText = false; 39 [webView performAfterReceivingMessage:@"selected" action:^() { 40 finishedSelectingText = true; 41 }]; 42 [webView sendClicksAtPoint:NSMakePoint(200, 200) numberOfClicks:2]; 43 TestWebKitAPI::Util::run(&finishedSelectingText); 34 @protocol NSTextInputClient_Async 35 - (void)selectedRangeWithCompletionHandler:(void(^)(NSRange selectedRange))completionHandler; 36 - (void)markedRangeWithCompletionHandler:(void(^)(NSRange markedRange))completionHandler; 37 - (void)hasMarkedTextWithCompletionHandler:(void(^)(BOOL hasMarkedText))completionHandler; 38 @end 44 39 45 NSString *selectedText = [webView stringByEvaluatingJavaScript:@"getSelection().getRangeAt(0).toString()"]; 46 EXPECT_STREQ("Hello", selectedText.UTF8String); 47 } 40 #endif 48 41 49 #endif // WK_API_ENABLED &&PLATFORM(MAC)42 #endif // PLATFORM(MAC) -
trunk/Tools/TestWebKitAPI/Tests/mac/WKWebViewSelectionTests.mm
r213012 r219836 28 28 #if WK_API_ENABLED && PLATFORM(MAC) 29 29 30 #import "NSTextInputClientSPI.h" 30 31 #import "PlatformUtilities.h" 31 32 #import "TestWKWebView.h" … … 47 48 } 48 49 50 TEST(WKWebViewSelectionTests, DoNotCrashWhenCallingTextInputClientMethodsWhileDeallocatingView) 51 { 52 NSString *textContent = @"This test should not cause us to dereference null."; 53 54 auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 400, 400)]); 55 [webView synchronouslyLoadHTMLString:[NSString stringWithFormat:@"<p>%@</p>", textContent]]; 56 [webView removeFromSuperview]; 57 58 __unsafe_unretained id <NSTextInputClient_Async> inputClient = (id <NSTextInputClient_Async>)webView.get(); 59 [inputClient hasMarkedTextWithCompletionHandler:^(BOOL) { 60 [inputClient selectedRangeWithCompletionHandler:^(NSRange) { 61 [inputClient markedRangeWithCompletionHandler:^(NSRange) { }]; 62 }]; 63 }]; 64 65 EXPECT_WK_STREQ(textContent, [webView stringByEvaluatingJavaScript:@"document.body.textContent"]); 66 } 67 49 68 #endif // WK_API_ENABLED && PLATFORM(MAC)
Note: See TracChangeset
for help on using the changeset viewer.