WebKit Bugzilla
Attachment 362541 Details for
Bug 194872
: Regression(PSON) "Reload without content extensions" does not work when the main resource is blocked
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-194872-20190220143036.patch (text/plain), 8.85 KB, created by
Chris Dumez
on 2019-02-20 14:30:37 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Chris Dumez
Created:
2019-02-20 14:30:37 PST
Size:
8.85 KB
patch
obsolete
>Subversion Revision: 241816 >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 242cea16984340e3b616856d7e566a3c8fa4eb53..5813cae97e6e589ad4892a3aaf924f3d12beb7b2 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,27 @@ >+2019-02-20 Chris Dumez <cdumez@apple.com> >+ >+ Regression(PSON) "Reload without content extensions" does not work when the main resource is blocked >+ https://bugs.webkit.org/show_bug.cgi?id=194872 >+ <rdar://problem/47924500> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ [WKWebView _reloadWithoutContentBlockers] relies on a ReloadOption flag that is passed to WebCore >+ instead of using WebsitePolicies.contentBlockersEnabled flag. If the reload causes a process swap >+ due to PSON, then the new process does not know about this ReloadOption and fails to honor it. >+ >+ Since the modern way to do this is WebsitePolicies, and since WebsitePolicies are properly >+ propagated cross-process in case of process swap, this patch updates _reloadWithoutContentBlockers >+ to set a flag on the Navigation which we use to later set the WebsitePolicies.contentBlockersEnabled >+ flag in WebPageProxy::receivedNavigationPolicyDecision(). >+ >+ * UIProcess/API/APINavigation.h: >+ (API::Navigation::setUserContentExtensionsEnabled): >+ (API::Navigation::userContentExtensionsEnabled const): >+ * UIProcess/WebPageProxy.cpp: >+ (WebKit::WebPageProxy::reload): >+ (WebKit::WebPageProxy::receivedNavigationPolicyDecision): >+ > 2019-02-20 Carlos Garcia Campos <cgarcia@igalia.com> > > [WPE] Send client host fd and library name as web process creation parameters >diff --git a/Source/WebKit/UIProcess/API/APINavigation.h b/Source/WebKit/UIProcess/API/APINavigation.h >index c996c3603974621ef4f92c09882ded768961bd9d..1ac3c4374173bb4c0f823f25e5e9d006e79d8ad2 100644 >--- a/Source/WebKit/UIProcess/API/APINavigation.h >+++ b/Source/WebKit/UIProcess/API/APINavigation.h >@@ -124,6 +124,9 @@ public: > bool openedByDOMWithOpener() const { return m_lastNavigationAction.openedByDOMWithOpener; } > const WebCore::SecurityOriginData& requesterOrigin() const { return m_lastNavigationAction.requesterOrigin; } > >+ void setUserContentExtensionsEnabled(bool enabled) { m_userContentExtensionsEnabled = enabled; } >+ bool userContentExtensionsEnabled() const { return m_userContentExtensionsEnabled; } >+ > WebCore::LockHistory lockHistory() const { return m_lastNavigationAction.lockHistory; } > WebCore::LockBackForwardList lockBackForwardList() const { return m_lastNavigationAction.lockBackForwardList; } > >@@ -165,6 +168,7 @@ private: > WebKit::NavigationActionData m_lastNavigationAction; > WebKit::FrameInfoData m_originatingFrameInfo; > WebCore::SecurityOriginData m_destinationFrameSecurityOrigin; >+ bool m_userContentExtensionsEnabled { true }; > }; > > } // namespace API >diff --git a/Source/WebKit/UIProcess/WebPageProxy.cpp b/Source/WebKit/UIProcess/WebPageProxy.cpp >index 52b4c8e227a3bd3d7e457bf6c5dcd0e36b187bda..25782b416c783933bb9b5c8b690d3309d7b73a73 100644 >--- a/Source/WebKit/UIProcess/WebPageProxy.cpp >+++ b/Source/WebKit/UIProcess/WebPageProxy.cpp >@@ -1346,6 +1346,11 @@ RefPtr<API::Navigation> WebPageProxy::reload(OptionSet<WebCore::ReloadOption> op > > auto navigation = m_navigationState->createReloadNavigation(); > >+ // Store decision to reload without content blockers on the navigation so that we can later set the corresponding >+ // WebsitePolicies flag in WebPageProxy::receivedNavigationPolicyDecision(). >+ if (options.contains(WebCore::ReloadOption::DisableContentBlockers)) >+ navigation->setUserContentExtensionsEnabled(false); >+ > m_process->send(Messages::WebPage::Reload(navigation->navigationID(), options.toRaw(), sandboxExtensionHandle), m_pageID); > m_process->responsivenessTimer().start(); > >@@ -2740,6 +2745,12 @@ void WebPageProxy::receivedNavigationPolicyDecision(PolicyAction policyAction, A > changeWebsiteDataStore(policies->websiteDataStore()->websiteDataStore()); > } > >+ if (navigation && !navigation->userContentExtensionsEnabled()) { >+ if (!data) >+ data = WebsitePoliciesData { }; >+ data->contentBlockersEnabled = false; >+ } >+ > if (policyAction == PolicyAction::Use && navigation && (navigation->isSystemPreview() || navigation->shouldForceDownload())) > policyAction = PolicyAction::Download; > >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 96708e79bad6a035a8ef720dba9a8e63d295b9b1..971e0b868b9959f191d151ac9a21bcce966cf08e 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,15 @@ >+2019-02-20 Chris Dumez <cdumez@apple.com> >+ >+ Regression(PSON) "Reload without content extensions" does not work when the main resource is blocked >+ https://bugs.webkit.org/show_bug.cgi?id=194872 >+ <rdar://problem/47924500> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add API test coverage. >+ >+ * TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm: >+ > 2019-02-20 Adrian Perez de Castro <aperez@igalia.com> > > [WPE][GTK] Enable support for CONTENT_EXTENSIONS >diff --git a/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm b/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm >index 8c96bec03b3e70ffddaa349a562d72c55a41d5ef..0f23be8f5783fa59abdddb4449ce2e0468cae575 100644 >--- a/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm >+++ b/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm >@@ -4864,6 +4864,75 @@ TEST(ProcessSwap, ContentBlockingAfterProcessSwap) > done = false; > } > >+static const char* notifyLoadedBytes = R"PSONRESOURCE( >+<script> >+ window.webkit.messageHandlers.pson.postMessage("Loaded"); >+</script> >+)PSONRESOURCE"; >+ >+TEST(ProcessSwap, ContentExtensionBlocksMainLoadThenReloadWithoutExtensions) >+{ >+ [[WKContentRuleListStore defaultStore] removeContentRuleListForIdentifier:@"ContentBlockingAfterProcessSwapExtension" completionHandler:^(NSError *error) { >+ done = true; >+ }]; >+ TestWebKitAPI::Util::run(&done); >+ done = false; >+ >+ auto processPoolConfiguration = psonProcessPoolConfiguration(); >+ auto processPool = adoptNS([[WKProcessPool alloc] _initWithConfiguration:processPoolConfiguration.get()]); >+ >+ auto webViewConfiguration = adoptNS([[WKWebViewConfiguration alloc] init]); >+ [webViewConfiguration setProcessPool:processPool.get()]; >+ >+ RetainPtr<PSONMessageHandler> messageHandler = adoptNS([[PSONMessageHandler alloc] init]); >+ [[webViewConfiguration userContentController] addScriptMessageHandler:messageHandler.get() name:@"pson"]; >+ >+ __block bool doneCompiling = false; >+ [[WKContentRuleListStore defaultStore] compileContentRuleListForIdentifier:@"ContentBlockingAfterProcessSwapExtension" encodedContentRuleList:blockmeFilter completionHandler:^(WKContentRuleList *ruleList, NSError *error) { >+ >+ EXPECT_NOT_NULL(ruleList); >+ EXPECT_NULL(error); >+ >+ [webViewConfiguration.get().userContentController addContentRuleList:ruleList]; >+ >+ doneCompiling = true; >+ }]; >+ TestWebKitAPI::Util::run(&doneCompiling); >+ >+ auto handler = adoptNS([[PSONScheme alloc] init]); >+ [handler addMappingFromURLString:@"pson://www.apple.com/blockme.html" toData:notifyLoadedBytes]; >+ [webViewConfiguration setURLSchemeHandler:handler.get() forURLScheme:@"PSON"]; >+ >+ auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:webViewConfiguration.get()]); >+ auto delegate = adoptNS([[PSONNavigationDelegate alloc] init]); >+ [webView setNavigationDelegate:delegate.get()]; >+ >+ NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"pson://www.webkit.org/main.html"]]; >+ [webView loadRequest:request]; >+ TestWebKitAPI::Util::run(&done); >+ done = false; >+ >+ receivedMessage = false; >+ failed = false; >+ request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"pson://www.apple.com/blockme.html"]]; >+ [webView loadRequest:request]; >+ TestWebKitAPI::Util::run(&failed); >+ failed = false; >+ EXPECT_FALSE(receivedMessage); >+ >+ [webView _loadAlternateHTMLString:@"Blocked" baseURL:[NSURL URLWithString:@"data:text/html,"] forUnreachableURL:[NSURL URLWithString:@"pson://www.apple.com/blockme.html"]]; >+ TestWebKitAPI::Util::run(&done); >+ done = false; >+ >+ [webView _reloadWithoutContentBlockers]; >+ TestWebKitAPI::Util::run(&done); >+ done = false; >+ >+ EXPECT_FALSE(failed); >+ EXPECT_TRUE(receivedMessage); >+ EXPECT_WK_STREQ(@"pson://www.apple.com/blockme.html", [[webView URL] absoluteString]); >+} >+ > static bool isCapturing = false; > @interface GetUserMediaUIDelegate : NSObject<WKUIDelegate> > - (void)_webView:(WKWebView *)webView requestUserMediaAuthorizationForDevices:(_WKCaptureDevices)devices url:(NSURL *)url mainFrameURL:(NSURL *)mainFrameURL decisionHandler:(void (^)(BOOL authorized))decisionHandler;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 194872
:
362541
|
362546