Title: [219930] branches/safari-604-branch/Tools

Diff

Modified: branches/safari-604-branch/Tools/ChangeLog (219929 => 219930)


--- branches/safari-604-branch/Tools/ChangeLog	2017-07-26 09:52:06 UTC (rev 219929)
+++ branches/safari-604-branch/Tools/ChangeLog	2017-07-26 09:52:09 UTC (rev 219930)
@@ -1,3 +1,22 @@
+2017-07-26  Jason Marcell  <[email protected]>
+
+        Cherry-pick r219836. rdar://problem/33523818
+
+    2017-07-24  Wenson Hsieh  <[email protected]>
+
+            [Mac WK2] Add an API test to cover r219765 (null dereference in [WKWebView dealloc])
+            https://bugs.webkit.org/show_bug.cgi?id=174793
+
+            Reviewed by Tim Horton.
+
+            Adds a new unit test that invokes some asynchronous NSTextInputClient SPI methods as the web view is tearing
+            down. Without r219765, this test will dereference null and crash.
+
+            * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+            * TestWebKitAPI/Tests/TestWebKitAPI/mac/NSTextInputClientSPI.h: Added.
+            * TestWebKitAPI/Tests/mac/WKWebViewSelectionTests.mm:
+            (TEST):
+
 2017-07-22  Jason Marcell  <[email protected]>
 
         Cherry-pick r219709. rdar://problem/33462692

Modified: branches/safari-604-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (219929 => 219930)


--- branches/safari-604-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2017-07-26 09:52:06 UTC (rev 219929)
+++ branches/safari-604-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2017-07-26 09:52:09 UTC (rev 219930)
@@ -1087,6 +1087,7 @@
 		2E691AF21D79E75400129407 /* large-video-playing-scroll-away.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "large-video-playing-scroll-away.html"; sourceTree = "<group>"; };
 		2E7765CC16C4D80A00BA2BB1 /* mainIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = mainIOS.mm; sourceTree = "<group>"; };
 		2E7765CE16C4D81100BA2BB1 /* mainMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = mainMac.mm; sourceTree = "<group>"; };
+		2E7EF7AC1F266A8100DFB67C /* NSTextInputClientSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NSTextInputClientSPI.h; sourceTree = "<group>"; };
 		2E9896141D8F092B00739892 /* text-and-password-inputs.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "text-and-password-inputs.html"; sourceTree = "<group>"; };
 		2ECFF5541D9B12F800B55394 /* NowPlayingControlsTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NowPlayingControlsTests.mm; sourceTree = "<group>"; };
 		2EFF06C21D8862120004BB30 /* large-video-offscreen.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "large-video-offscreen.html"; sourceTree = "<group>"; };
@@ -2646,6 +2647,7 @@
 			isa = PBXGroup;
 			children = (
 				C08587FB13FEC39B001EF4E5 /* InstanceMethodSwizzler.mm */,
+				2E7EF7AC1F266A8100DFB67C /* NSTextInputClientSPI.h */,
 			);
 			path = mac;
 			sourceTree = "<group>";

Copied: branches/safari-604-branch/Tools/TestWebKitAPI/Tests/TestWebKitAPI/mac/NSTextInputClientSPI.h (from rev 219929, branches/safari-604-branch/Tools/TestWebKitAPI/Tests/mac/WKWebViewSelectionTests.mm) (0 => 219930)


--- branches/safari-604-branch/Tools/TestWebKitAPI/Tests/TestWebKitAPI/mac/NSTextInputClientSPI.h	                        (rev 0)
+++ branches/safari-604-branch/Tools/TestWebKitAPI/Tests/TestWebKitAPI/mac/NSTextInputClientSPI.h	2017-07-26 09:52:09 UTC (rev 219930)
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+
+#if PLATFORM(MAC)
+
+#if USE(APPLE_INTERNAL_SDK)
+
+#import <AppKit/NSTextInputClient_Private.h>
+
+#else
+
+@protocol NSTextInputClient_Async
+- (void)selectedRangeWithCompletionHandler:(void(^)(NSRange selectedRange))completionHandler;
+- (void)markedRangeWithCompletionHandler:(void(^)(NSRange markedRange))completionHandler;
+- (void)hasMarkedTextWithCompletionHandler:(void(^)(BOOL hasMarkedText))completionHandler;
+@end
+
+#endif
+
+#endif // PLATFORM(MAC)

Modified: branches/safari-604-branch/Tools/TestWebKitAPI/Tests/mac/WKWebViewSelectionTests.mm (219929 => 219930)


--- branches/safari-604-branch/Tools/TestWebKitAPI/Tests/mac/WKWebViewSelectionTests.mm	2017-07-26 09:52:06 UTC (rev 219929)
+++ branches/safari-604-branch/Tools/TestWebKitAPI/Tests/mac/WKWebViewSelectionTests.mm	2017-07-26 09:52:09 UTC (rev 219930)
@@ -27,6 +27,7 @@
 
 #if WK_API_ENABLED && PLATFORM(MAC)
 
+#import "NSTextInputClientSPI.h"
 #import "PlatformUtilities.h"
 #import "TestWKWebView.h"
 
@@ -46,4 +47,22 @@
     EXPECT_STREQ("Hello", selectedText.UTF8String);
 }
 
+TEST(WKWebViewSelectionTests, DoNotCrashWhenCallingTextInputClientMethodsWhileDeallocatingView)
+{
+    NSString *textContent = @"This test should not cause us to dereference null.";
+
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 400, 400)]);
+    [webView synchronouslyLoadHTMLString:[NSString stringWithFormat:@"<p>%@</p>", textContent]];
+    [webView removeFromSuperview];
+
+    __unsafe_unretained id <NSTextInputClient_Async> inputClient = (id <NSTextInputClient_Async>)webView.get();
+    [inputClient hasMarkedTextWithCompletionHandler:^(BOOL) {
+        [inputClient selectedRangeWithCompletionHandler:^(NSRange) {
+            [inputClient markedRangeWithCompletionHandler:^(NSRange) { }];
+        }];
+    }];
+
+    EXPECT_WK_STREQ(textContent, [webView stringByEvaluatingJavaScript:@"document.body.textContent"]);
+}
+
 #endif // WK_API_ENABLED && PLATFORM(MAC)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to