Title: [225302] trunk/Tools
Revision
225302
Author
simon.fra...@apple.com
Date
2017-11-29 16:18:05 -0800 (Wed, 29 Nov 2017)

Log Message

API test fix after r225288.

Make the test work on iOS.

* TestWebKitAPI/Tests/WebKit/NoHistoryItemScrollToFragment.mm:
(-[DidScrollToFragmentScrollViewDelegate scrollViewDidScroll:]):
(TestWebKitAPI::TEST):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (225301 => 225302)


--- trunk/Tools/ChangeLog	2017-11-30 00:16:19 UTC (rev 225301)
+++ trunk/Tools/ChangeLog	2017-11-30 00:18:05 UTC (rev 225302)
@@ -1,5 +1,15 @@
 2017-11-29  Simon Fraser  <simon.fra...@apple.com>
 
+        API test fix after r225288.
+
+        Make the test work on iOS.
+
+        * TestWebKitAPI/Tests/WebKit/NoHistoryItemScrollToFragment.mm:
+        (-[DidScrollToFragmentScrollViewDelegate scrollViewDidScroll:]):
+        (TestWebKitAPI::TEST):
+
+2017-11-29  Simon Fraser  <simon.fra...@apple.com>
+
         REGRESSION (r213590): Scrolling to anchors broken in web views when content loaded via HTML string
         https://bugs.webkit.org/show_bug.cgi?id=180155
         rdar://problem/34220827

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit/NoHistoryItemScrollToFragment.mm (225301 => 225302)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit/NoHistoryItemScrollToFragment.mm	2017-11-30 00:16:19 UTC (rev 225301)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit/NoHistoryItemScrollToFragment.mm	2017-11-30 00:18:05 UTC (rev 225302)
@@ -37,6 +37,7 @@
 
 static bool testDone;
 
+#if PLATFORM(MAC)
 @interface DidScrollToFragmentDelegate : NSObject <WKUIDelegatePrivate>
 @end
 
@@ -49,6 +50,25 @@
 
 @end
 
+#endif
+#if PLATFORM(IOS)
+
+@interface DidScrollToFragmentScrollViewDelegate : NSObject <UIScrollViewDelegate>
+
+@end
+
+@implementation DidScrollToFragmentScrollViewDelegate
+
+- (void)scrollViewDidScroll:(UIScrollView *)scrollView
+{
+    // Ignore scrolls to 0,0 and from inset changes.
+    if (scrollView.contentOffset.y > 300)
+        testDone = true;
+}
+
+@end
+#endif
+
 namespace TestWebKitAPI {
 
 TEST(WebKit, NoHistoryItemScrollToFragment)
@@ -56,8 +76,15 @@
     auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
     auto processPoolConfig = adoptNS([[_WKProcessPoolConfiguration alloc] init]);
     auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500) configuration:configuration.get() processPoolConfiguration:processPoolConfig.get()]);
+
+#if PLATFORM(MAC)
     auto delegate = adoptNS([[DidScrollToFragmentDelegate alloc] init]);
     [webView setUIDelegate:delegate.get()];
+#endif
+#if PLATFORM(IOS)
+    auto delegateForScrollView = adoptNS([[DidScrollToFragmentScrollViewDelegate alloc] init]);
+    [webView scrollView].delegate = delegateForScrollView.get();
+#endif
 
     NSURL* resourceURL = [[NSBundle mainBundle] URLForResource:@"scroll-to-anchor" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"];
     NSString *testFileContents = [NSString stringWithContentsOfURL:resourceURL encoding:NSUTF8StringEncoding error:nil];
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to