Changeset 241950 in webkit
- Timestamp:
- Feb 22, 2019 10:24:57 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r241936 r241950 1 2019-02-22 Chris Dumez <cdumez@apple.com> 2 3 REGRESSION(PSON) Scroll position is sometimes not restored on history navigation 4 https://bugs.webkit.org/show_bug.cgi?id=194924 5 <rdar://problem/48216125> 6 7 Reviewed by Geoffrey Garen. 8 9 When process-swapping, we would create a new WebPage in the new process, which would 10 call restoreSessionInternal() to restore the HistoryItems based on the UIProcess's 11 backforward list. The issue is that this session restoring would send HistoryItem 12 updates back to the UIProcess. Without PSON, this would be unnecessary but harmless. 13 With PSON though, this may end up overwriting values set by the previous process, 14 such as the scroll position. 15 16 Address the issue by temporarily disabling the HistoryItem update notifications to 17 the UIProcess while restoring a session. 18 19 * UIProcess/API/Cocoa/WKBackForwardListItem.mm: 20 (-[WKBackForwardListItem _scrollPosition]): 21 * UIProcess/API/Cocoa/WKBackForwardListItemPrivate.h: 22 * WebProcess/WebPage/WebPage.cpp: 23 (WebKit::WebPage::restoreSessionInternal): 24 1 25 2019-02-21 Adrian Perez de Castro <aperez@igalia.com> 2 26 -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKBackForwardListItem.mm
r235828 r241950 72 72 } 73 73 74 - (CGPoint) _scrollPosition 75 { 76 return CGPointMake(_item->pageState().mainFrameState.scrollPosition.x(), _item->pageState().mainFrameState.scrollPosition.y()); 77 } 78 74 79 #pragma mark WKObject protocol implementation 75 80 -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKBackForwardListItemPrivate.h
r218444 r241950 33 33 - (CGImageRef)_copySnapshotForTesting WK_API_AVAILABLE(macosx(10.12.3), ios(10.3)); 34 34 35 @property (nonatomic) CGPoint _scrollPosition WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); 36 35 37 @end 36 38 -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp
r241899 r241950 2705 2705 void WebPage::restoreSessionInternal(const Vector<BackForwardListItemState>& itemStates, WasRestoredByAPIRequest restoredByAPIRequest, WebBackForwardListProxy::OverwriteExistingItem overwrite) 2706 2706 { 2707 // Since we're merely restoring HistoryItems from the UIProcess, there is no need to send HistoryItem update notifications back to the UIProcess. 2708 // Also, with process-swap on navigation, these updates may actually overwrite important state in the UIProcess such as the scroll position. 2709 SetForScope<void (*)(WebCore::HistoryItem&)> bypassHistoryItemUpdateNotifications(WebCore::notifyHistoryItemChanged, [](WebCore::HistoryItem&){}); 2707 2710 for (const auto& itemState : itemStates) { 2708 2711 auto historyItem = toHistoryItem(itemState); -
trunk/Tools/ChangeLog
r241948 r241950 1 2019-02-22 Chris Dumez <cdumez@apple.com> 2 3 REGRESSION(PSON) Scroll position is sometimes not restored on history navigation 4 https://bugs.webkit.org/show_bug.cgi?id=194924 5 <rdar://problem/48216125> 6 7 Reviewed by Geoffrey Garen. 8 9 Add API test coverage. 10 11 * TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm: 12 1 13 2019-02-22 Chris Dumez <cdumez@apple.com> 2 14 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm
r241948 r241950 30 30 #import "TestNavigationDelegate.h" 31 31 #import "TestWKWebView.h" 32 #import <WebKit/WKBackForwardListItemPrivate.h> 32 33 #import <WebKit/WKContentRuleListStore.h> 33 34 #import <WebKit/WKNavigationDelegatePrivate.h> … … 4862 4863 } 4863 4864 4865 #endif // PLATFORM(MAC) 4866 4864 4867 static const char* tallPageBytes = R"PSONRESOURCE( 4865 4868 <!DOCTYPE html> … … 4876 4879 </head> 4877 4880 <body> 4881 <script> 4882 // Pages with dedicated workers do not go into page cache. 4883 var myWorker = new Worker('worker.js'); 4884 </script> 4878 4885 <a id="testLink" href="pson://www.apple.com/main.html">Test</a> 4879 4886 </body> … … 4881 4888 )PSONRESOURCE"; 4882 4889 4890 static unsigned waitUntilScrollPositionIsRestored(WKWebView *webView) 4891 { 4892 unsigned scrollPosition = 0; 4893 do { 4894 [webView evaluateJavaScript:@"window.scrollY" completionHandler: [&] (id result, NSError *error) { 4895 scrollPosition = [result integerValue]; 4896 done = true; 4897 }]; 4898 TestWebKitAPI::Util::run(&done); 4899 done = false; 4900 } while (!scrollPosition); 4901 4902 return scrollPosition; 4903 } 4904 4883 4905 TEST(ProcessSwap, ScrollPositionRestoration) 4884 4906 { … … 4891 4913 [handler addMappingFromURLString:@"pson://www.webkit.org/main.html" toData:tallPageBytes]; 4892 4914 [webViewConfiguration setURLSchemeHandler:handler.get() forURLScheme:@"PSON"]; 4893 4894 [[webViewConfiguration preferences] _setUsesPageCache:NO];4895 4915 4896 4916 auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:webViewConfiguration.get()]); … … 4908 4928 TestWebKitAPI::Util::run(&done); 4909 4929 done = false; 4930 4931 do { 4932 TestWebKitAPI::Util::sleep(0.05); 4933 } while (lroundf([[[webView backForwardList] currentItem] _scrollPosition].y) != 5000); 4910 4934 4911 4935 [webView evaluateJavaScript:@"testLink.click()" completionHandler: nil]; … … 4925 4949 done = false; 4926 4950 4927 [webView evaluateJavaScript:@"window.scrollY" completionHandler: [&] (id result, NSError *error) { 4928 EXPECT_EQ(5000, [result integerValue]); 4951 auto scrollPosition = waitUntilScrollPositionIsRestored(webView.get()); 4952 EXPECT_EQ(5000U, scrollPosition); 4953 4954 [webView evaluateJavaScript:@"scroll(0, 4000)" completionHandler: [&] (id result, NSError *error) { 4929 4955 done = true; 4930 4956 }]; 4931 4957 TestWebKitAPI::Util::run(&done); 4932 4958 done = false; 4933 } 4934 4935 #endif // PLATFORM(MAC) 4959 4960 do { 4961 TestWebKitAPI::Util::sleep(0.05); 4962 } while (lroundf([[[webView backForwardList] currentItem] _scrollPosition].y) != 4000); 4963 4964 [webView evaluateJavaScript:@"testLink.click()" completionHandler: nil]; 4965 4966 TestWebKitAPI::Util::run(&done); 4967 done = false; 4968 4969 [webView evaluateJavaScript:@"window.scrollY" completionHandler: [&] (id result, NSError *error) { 4970 EXPECT_EQ(0, [result integerValue]); 4971 done = true; 4972 }]; 4973 TestWebKitAPI::Util::run(&done); 4974 done = false; 4975 4976 [webView goBack]; 4977 TestWebKitAPI::Util::run(&done); 4978 done = false; 4979 4980 scrollPosition = waitUntilScrollPositionIsRestored(webView.get()); 4981 EXPECT_EQ(4000U, scrollPosition); 4982 } 4936 4983 4937 4984 static NSString *blockmeFilter = @"[{\"action\":{\"type\":\"block\"},\"trigger\":{\"url-filter\":\".*blockme.html\"}}]";
Note: See TracChangeset
for help on using the changeset viewer.