Title: [262136] trunk/Tools
Revision
262136
Author
[email protected]
Date
2020-05-25 21:48:57 -0700 (Mon, 25 May 2020)

Log Message

[iOS] ActionSheetTests.DataDetectorsLinkIsNotPresentedAsALink is failing consistently
https://bugs.webkit.org/show_bug.cgi?id=212363
<rdar://problem/63508866>

Reviewed by Tim Horton.

This test began to consistently throw an exception after <https://trac.webkit.org/r261157>, due to how
UserInterfaceSwizzler always instantiates the shared UIApplication. This apparently causes -[WKContentView
resizableSnapshotViewFromRect:afterScreenUpdates:withCapInsets:] to return `nil` instead of a replica view. As a
result, we crash under `createFallbackTargetedPreview` as we're attempting to assemble a targeted preview for
the context menu interaction.

Since this seems to only affect this particular API test, work around it by swizzling out
`-resizableSnapshotViewFromRect:afterScreenUpdates:withCapInsets:` in this API test to return a non-null UIView.

* TestWebKitAPI/Tests/ios/ActionSheetTests.mm:
(TestWebKitAPI::swizzledResizableSnapshotViewFromRect):
(TestWebKitAPI::TEST):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (262135 => 262136)


--- trunk/Tools/ChangeLog	2020-05-26 03:44:12 UTC (rev 262135)
+++ trunk/Tools/ChangeLog	2020-05-26 04:48:57 UTC (rev 262136)
@@ -1,3 +1,24 @@
+2020-05-25  Wenson Hsieh  <[email protected]>
+
+        [iOS] ActionSheetTests.DataDetectorsLinkIsNotPresentedAsALink is failing consistently
+        https://bugs.webkit.org/show_bug.cgi?id=212363
+        <rdar://problem/63508866>
+
+        Reviewed by Tim Horton.
+
+        This test began to consistently throw an exception after <https://trac.webkit.org/r261157>, due to how
+        UserInterfaceSwizzler always instantiates the shared UIApplication. This apparently causes -[WKContentView
+        resizableSnapshotViewFromRect:afterScreenUpdates:withCapInsets:] to return `nil` instead of a replica view. As a
+        result, we crash under `createFallbackTargetedPreview` as we're attempting to assemble a targeted preview for
+        the context menu interaction.
+
+        Since this seems to only affect this particular API test, work around it by swizzling out
+        `-resizableSnapshotViewFromRect:afterScreenUpdates:withCapInsets:` in this API test to return a non-null UIView.
+
+        * TestWebKitAPI/Tests/ios/ActionSheetTests.mm:
+        (TestWebKitAPI::swizzledResizableSnapshotViewFromRect):
+        (TestWebKitAPI::TEST):
+
 2020-05-24  Sam Weinig  <[email protected]>
 
         Extended Color Cleanup: Use the name SimpleColor consistently

Modified: trunk/Tools/TestWebKitAPI/Tests/ios/ActionSheetTests.mm (262135 => 262136)


--- trunk/Tools/TestWebKitAPI/Tests/ios/ActionSheetTests.mm	2020-05-26 03:44:12 UTC (rev 262135)
+++ trunk/Tools/TestWebKitAPI/Tests/ios/ActionSheetTests.mm	2020-05-26 04:48:57 UTC (rev 262136)
@@ -152,9 +152,19 @@
     EXPECT_WK_STREQ("Hello world", [webView stringByEvaluatingJavaScript:@"getSelection().toString()"]);
 }
 
+static UIView *swizzledResizableSnapshotViewFromRect(id, SEL, CGRect rect, BOOL, UIEdgeInsets)
+{
+    return [[[UIView alloc] initWithFrame:CGRectMake(0, 0, rect.size.width, rect.size.height)] autorelease];
+}
+
 TEST(ActionSheetTests, DataDetectorsLinkIsNotPresentedAsALink)
 {
     IPadUserInterfaceSwizzler iPadUserInterface;
+    InstanceMethodSwizzler snapshotViewSwizzler {
+        UIView.class,
+        @selector(resizableSnapshotViewFromRect:afterScreenUpdates:withCapInsets:),
+        reinterpret_cast<IMP>(swizzledResizableSnapshotViewFromRect)
+    };
 
     auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 1024, 768)]);
     auto observer = adoptNS([[ActionSheetObserver alloc] init]);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to