Changeset 241845 in webkit
- Timestamp:
- Feb 20, 2019, 3:30:03 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r241844 r241845 1 2019-02-20 Chris Dumez <cdumez@apple.com> 2 3 Regression(PSON) "Reload without content extensions" does not work when the main resource is blocked 4 https://bugs.webkit.org/show_bug.cgi?id=194872 5 <rdar://problem/47924500> 6 7 Reviewed by Alex Christensen. 8 9 [WKWebView _reloadWithoutContentBlockers] relies on a ReloadOption flag that is passed to WebCore 10 instead of using WebsitePolicies.contentBlockersEnabled flag. If the reload causes a process swap 11 due to PSON, then the new process does not know about this ReloadOption and fails to honor it. 12 13 Since the modern way to do this is WebsitePolicies, and since WebsitePolicies are properly 14 propagated cross-process in case of process swap, this patch updates _reloadWithoutContentBlockers 15 to set a flag on the Navigation which we use to later set the WebsitePolicies.contentBlockersEnabled 16 flag in WebPageProxy::receivedNavigationPolicyDecision(). 17 18 * UIProcess/API/APINavigation.h: 19 (API::Navigation::setUserContentExtensionsEnabled): 20 (API::Navigation::userContentExtensionsEnabled const): 21 * UIProcess/WebPageProxy.cpp: 22 (WebKit::WebPageProxy::reload): 23 (WebKit::WebPageProxy::receivedNavigationPolicyDecision): 24 1 25 2019-02-20 Truitt Savell <tsavell@apple.com> 2 26 -
trunk/Source/WebKit/UIProcess/API/APINavigation.h
r241451 r241845 125 125 const WebCore::SecurityOriginData& requesterOrigin() const { return m_lastNavigationAction.requesterOrigin; } 126 126 127 void setUserContentExtensionsEnabled(bool enabled) { m_userContentExtensionsEnabled = enabled; } 128 bool userContentExtensionsEnabled() const { return m_userContentExtensionsEnabled; } 129 127 130 WebCore::LockHistory lockHistory() const { return m_lastNavigationAction.lockHistory; } 128 131 WebCore::LockBackForwardList lockBackForwardList() const { return m_lastNavigationAction.lockBackForwardList; } … … 166 169 WebKit::FrameInfoData m_originatingFrameInfo; 167 170 WebCore::SecurityOriginData m_destinationFrameSecurityOrigin; 171 bool m_userContentExtensionsEnabled { true }; 168 172 }; 169 173 -
trunk/Source/WebKit/UIProcess/WebPageProxy.cpp
r241823 r241845 1347 1347 auto navigation = m_navigationState->createReloadNavigation(); 1348 1348 1349 // Store decision to reload without content blockers on the navigation so that we can later set the corresponding 1350 // WebsitePolicies flag in WebPageProxy::receivedNavigationPolicyDecision(). 1351 if (options.contains(WebCore::ReloadOption::DisableContentBlockers)) 1352 navigation->setUserContentExtensionsEnabled(false); 1353 1349 1354 m_process->send(Messages::WebPage::Reload(navigation->navigationID(), options.toRaw(), sandboxExtensionHandle), m_pageID); 1350 1355 m_process->responsivenessTimer().start(); … … 2739 2744 if (policies->websiteDataStore()) 2740 2745 changeWebsiteDataStore(policies->websiteDataStore()->websiteDataStore()); 2746 } 2747 2748 if (navigation && !navigation->userContentExtensionsEnabled()) { 2749 if (!data) 2750 data = WebsitePoliciesData { }; 2751 data->contentBlockersEnabled = false; 2741 2752 } 2742 2753 -
trunk/Tools/ChangeLog
r241843 r241845 1 2019-02-20 Chris Dumez <cdumez@apple.com> 2 3 Regression(PSON) "Reload without content extensions" does not work when the main resource is blocked 4 https://bugs.webkit.org/show_bug.cgi?id=194872 5 <rdar://problem/47924500> 6 7 Reviewed by Alex Christensen. 8 9 Add API test coverage. 10 11 * TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm: 12 1 13 2019-02-20 Jer Noble <jer.noble@apple.com> 2 14 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm
r241823 r241845 4914 4914 } 4915 4915 4916 static const char* notifyLoadedBytes = R"PSONRESOURCE( 4917 <script> 4918 window.webkit.messageHandlers.pson.postMessage("Loaded"); 4919 </script> 4920 )PSONRESOURCE"; 4921 4922 TEST(ProcessSwap, ContentExtensionBlocksMainLoadThenReloadWithoutExtensions) 4923 { 4924 [[WKContentRuleListStore defaultStore] removeContentRuleListForIdentifier:@"ContentBlockingAfterProcessSwapExtension" completionHandler:^(NSError *error) { 4925 done = true; 4926 }]; 4927 TestWebKitAPI::Util::run(&done); 4928 done = false; 4929 4930 auto processPoolConfiguration = psonProcessPoolConfiguration(); 4931 auto processPool = adoptNS([[WKProcessPool alloc] _initWithConfiguration:processPoolConfiguration.get()]); 4932 4933 auto webViewConfiguration = adoptNS([[WKWebViewConfiguration alloc] init]); 4934 [webViewConfiguration setProcessPool:processPool.get()]; 4935 4936 RetainPtr<PSONMessageHandler> messageHandler = adoptNS([[PSONMessageHandler alloc] init]); 4937 [[webViewConfiguration userContentController] addScriptMessageHandler:messageHandler.get() name:@"pson"]; 4938 4939 __block bool doneCompiling = false; 4940 [[WKContentRuleListStore defaultStore] compileContentRuleListForIdentifier:@"ContentBlockingAfterProcessSwapExtension" encodedContentRuleList:blockmeFilter completionHandler:^(WKContentRuleList *ruleList, NSError *error) { 4941 4942 EXPECT_NOT_NULL(ruleList); 4943 EXPECT_NULL(error); 4944 4945 [webViewConfiguration.get().userContentController addContentRuleList:ruleList]; 4946 4947 doneCompiling = true; 4948 }]; 4949 TestWebKitAPI::Util::run(&doneCompiling); 4950 4951 auto handler = adoptNS([[PSONScheme alloc] init]); 4952 [handler addMappingFromURLString:@"pson://www.apple.com/blockme.html" toData:notifyLoadedBytes]; 4953 [webViewConfiguration setURLSchemeHandler:handler.get() forURLScheme:@"PSON"]; 4954 4955 auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:webViewConfiguration.get()]); 4956 auto delegate = adoptNS([[PSONNavigationDelegate alloc] init]); 4957 [webView setNavigationDelegate:delegate.get()]; 4958 4959 NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"pson://www.webkit.org/main.html"]]; 4960 [webView loadRequest:request]; 4961 TestWebKitAPI::Util::run(&done); 4962 done = false; 4963 4964 receivedMessage = false; 4965 failed = false; 4966 request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"pson://www.apple.com/blockme.html"]]; 4967 [webView loadRequest:request]; 4968 TestWebKitAPI::Util::run(&failed); 4969 failed = false; 4970 EXPECT_FALSE(receivedMessage); 4971 4972 [webView _loadAlternateHTMLString:@"Blocked" baseURL:[NSURL URLWithString:@"data:text/html,"] forUnreachableURL:[NSURL URLWithString:@"pson://www.apple.com/blockme.html"]]; 4973 TestWebKitAPI::Util::run(&done); 4974 done = false; 4975 4976 [webView _reloadWithoutContentBlockers]; 4977 TestWebKitAPI::Util::run(&done); 4978 done = false; 4979 4980 EXPECT_FALSE(failed); 4981 EXPECT_TRUE(receivedMessage); 4982 EXPECT_WK_STREQ(@"pson://www.apple.com/blockme.html", [[webView URL] absoluteString]); 4983 4984 [[WKContentRuleListStore defaultStore] removeContentRuleListForIdentifier:@"ContentBlockingAfterProcessSwapExtension" completionHandler:^(NSError *error) { 4985 done = true; 4986 }]; 4987 TestWebKitAPI::Util::run(&done); 4988 done = false; 4989 } 4990 4916 4991 static bool isCapturing = false; 4917 4992 @interface GetUserMediaUIDelegate : NSObject<WKUIDelegate>
Note:
See TracChangeset
for help on using the changeset viewer.