Changeset 246701 in webkit
- Timestamp:
- Jun 21, 2019 3:47:17 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r246700 r246701 1 2019-06-21 Jiewen Tan <jiewen_tan@apple.com> 2 3 WebPageProxy::loadData should accept ShouldOpenExternalURLsPolicy 4 https://bugs.webkit.org/show_bug.cgi?id=199114 5 <rdar://problem/51671674> 6 7 Reviewed by Youenn Fablet. 8 9 Covered by new test content within existing tests. 10 11 * loader/FrameLoaderTypes.h: 12 Adds an EnumTraits for ShouldOpenExternalURLsPolicy. 13 1 14 2019-06-21 Saam Barati <sbarati@apple.com> 2 15 -
trunk/Source/WebCore/loader/FrameLoaderTypes.h
r244540 r246701 220 220 }; 221 221 222 template<> struct EnumTraits<WebCore::ShouldOpenExternalURLsPolicy> { 223 using values = EnumValues< 224 WebCore::ShouldOpenExternalURLsPolicy, 225 WebCore::ShouldOpenExternalURLsPolicy::ShouldNotAllow, 226 WebCore::ShouldOpenExternalURLsPolicy::ShouldAllowExternalSchemes, 227 WebCore::ShouldOpenExternalURLsPolicy::ShouldAllow 228 >; 229 }; 230 222 231 } // namespace WTF -
trunk/Source/WebKit/ChangeLog
r246697 r246701 1 2019-06-21 Jiewen Tan <jiewen_tan@apple.com> 2 3 WebPageProxy::loadData should accept ShouldOpenExternalURLsPolicy 4 https://bugs.webkit.org/show_bug.cgi?id=199114 5 <rdar://problem/51671674> 6 7 Reviewed by Youenn Fablet. 8 9 This patch teaches WebPageProxy::loadData to accept ShouldOpenExternalURLsPolicy policy, 10 and then utilize it in RedirectSOAuthorizationSession. Therefore, the response loaded after 11 successful interceptions will be able to propagate the same policy from the last navigation 12 as it were continuous loading. 13 14 Besides the above, this patch also fixes some minor issues. 15 16 * Shared/LoadParameters.h: 17 * UIProcess/Cocoa/SOAuthorization/NavigationSOAuthorizationSession.mm: 18 (WebKit::NavigationSOAuthorizationSession::shouldStartInternal): 19 (WebKit::NavigationSOAuthorizationSession::webViewDidMoveToWindow): 20 * UIProcess/Cocoa/SOAuthorization/PopUpSOAuthorizationSession.h: 21 * UIProcess/Cocoa/SOAuthorization/PopUpSOAuthorizationSession.mm: 22 (WebKit::PopUpSOAuthorizationSession::completeInternal): 23 * UIProcess/Cocoa/SOAuthorization/RedirectSOAuthorizationSession.h: 24 * UIProcess/Cocoa/SOAuthorization/RedirectSOAuthorizationSession.mm: 25 (WebKit::shouldOpenExternalURLsPolicy): 26 (WebKit::RedirectSOAuthorizationSession::completeInternal): 27 * UIProcess/Cocoa/SOAuthorization/SOAuthorizationSession.h: 28 * UIProcess/Cocoa/SOAuthorization/SOAuthorizationSession.mm: 29 (WebKit::SOAuthorizationSession::complete): 30 * UIProcess/Cocoa/SOAuthorization/SubFrameSOAuthorizationSession.h: 31 * UIProcess/Cocoa/SOAuthorization/SubFrameSOAuthorizationSession.mm: 32 (WebKit::SubFrameSOAuthorizationSession::fallBackToWebPathInternal): 33 (WebKit::SubFrameSOAuthorizationSession::completeInternal): 34 (WebKit::SubFrameSOAuthorizationSession::loadDataToFrame): 35 (WebKit::SubFrameSOAuthorizationSession::postDidCancelMessageToParent): 36 * UIProcess/WebPageProxy.cpp: 37 (WebKit::WebPageProxy::loadRequestWithNavigationShared): 38 (WebKit::WebPageProxy::loadFile): 39 (WebKit::WebPageProxy::loadData): 40 (WebKit::WebPageProxy::loadDataWithNavigationShared): 41 * UIProcess/WebPageProxy.h: 42 * WebProcess/WebPage/WebPage.cpp: 43 (WebKit::WebPage::loadDataImpl): 44 (WebKit::WebPage::loadData): 45 * WebProcess/WebPage/WebPage.h: 46 1 47 2019-06-21 Tim Horton <timothy_horton@apple.com> 2 48 -
trunk/Source/WebKit/Shared/LoadParameters.h
r239427 r246701 64 64 Optional<WebsitePoliciesData> websitePolicies; 65 65 66 uint64_tshouldOpenExternalURLsPolicy;66 WebCore::ShouldOpenExternalURLsPolicy shouldOpenExternalURLsPolicy; 67 67 bool shouldTreatAsContinuingLoad { false }; 68 68 UserData userData; -
trunk/Source/WebKit/UIProcess/API/APINavigationAction.h
r246519 r246701 60 60 bool shouldPerformDownload() const { return !m_navigationActionData.downloadAttribute.isNull(); } 61 61 bool isRedirect() const { return m_navigationActionData.isRedirect; } 62 WebCore::ShouldOpenExternalURLsPolicy shouldOpenExternalURLsPolicy() const { return m_navigationActionData.shouldOpenExternalURLsPolicy; } 62 63 63 64 bool isProcessingUserGesture() const { return m_userInitiatedAction; } -
trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/NavigationSOAuthorizationSession.mm
r246514 r246701 50 50 void NavigationSOAuthorizationSession::shouldStartInternal() 51 51 { 52 auto* page Ptr =page();53 ASSERT(page Ptr);52 auto* page = this->page(); 53 ASSERT(page); 54 54 beforeStart(); 55 if (!page Ptr->isInWindow()) {55 if (!page->isInWindow()) { 56 56 setState(State::Waiting); 57 page Ptr->addObserver(*this);57 page->addObserver(*this); 58 58 return; 59 59 } … … 63 63 void NavigationSOAuthorizationSession::webViewDidMoveToWindow() 64 64 { 65 auto* page Ptr =page();66 if (state() != State::Waiting || !page Ptr || !pagePtr->isInWindow())65 auto* page = this->page(); 66 if (state() != State::Waiting || !page || !page->isInWindow()) 67 67 return; 68 68 start(); 69 page Ptr->removeObserver(*this);69 page->removeObserver(*this); 70 70 } 71 71 -
trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/PopUpSOAuthorizationSession.h
r246514 r246701 56 56 void fallBackToWebPathInternal() final; 57 57 void abortInternal() final; 58 void completeInternal( WebCore::ResourceResponse&&, NSData *) final;58 void completeInternal(const WebCore::ResourceResponse&, NSData *) final; 59 59 60 60 void initSecretWebView(); -
trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/PopUpSOAuthorizationSession.mm
r246514 r246701 133 133 } 134 134 135 void PopUpSOAuthorizationSession::completeInternal( WebCore::ResourceResponse&& response, NSData *data)135 void PopUpSOAuthorizationSession::completeInternal(const WebCore::ResourceResponse& response, NSData *data) 136 136 { 137 137 if (response.httpStatusCode() != 200 || !page()) { -
trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/RedirectSOAuthorizationSession.h
r246514 r246701 44 44 void fallBackToWebPathInternal() final; 45 45 void abortInternal() final; 46 void completeInternal( WebCore::ResourceResponse&&, NSData *) final;46 void completeInternal(const WebCore::ResourceResponse&, NSData *) final; 47 47 48 48 // NavigationSOAuthorizationSession -
trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/RedirectSOAuthorizationSession.mm
r246514 r246701 33 33 34 34 namespace WebKit { 35 using namespace WebCore; 35 36 36 37 Ref<SOAuthorizationSession> RedirectSOAuthorizationSession::create(SOAuthorization *soAuthorization, Ref<API::NavigationAction>&& navigationAction, WebPageProxy& page, Callback&& completionHandler) … … 54 55 } 55 56 56 void RedirectSOAuthorizationSession::completeInternal( WebCore::ResourceResponse&& response, NSData *data)57 void RedirectSOAuthorizationSession::completeInternal(const ResourceResponse& response, NSData *data) 57 58 { 58 auto* pagePtr = page(); 59 if ((response.httpStatusCode() != 302 && response.httpStatusCode() != 200) || !pagePtr) { 59 auto* navigationAction = this->navigationAction(); 60 ASSERT(navigationAction); 61 auto* page = this->page(); 62 if ((response.httpStatusCode() != 302 && response.httpStatusCode() != 200) || !page) { 60 63 fallBackToWebPathInternal(); 61 64 return; … … 64 67 if (response.httpStatusCode() == 302) { 65 68 #if PLATFORM(IOS) 66 auto* navigationActionPtr = navigationAction();67 ASSERT(navigationActionPtr);68 69 // MobileSafari has a WBSURLSpoofingMitigator, which will not display the provisional URL for navigations without user gestures. 69 70 // For slow loads that are initiated from the MobileSafari Favorites screen, the aforementioned behavior will create a period … … 72 73 // request URL, instead of directly loading a new request. The html page should be super fast to load and therefore will not 73 74 // show an empty URL or a blank page. These changes ensure a relevant URL bar and useful page content during the load. 74 if (!navigationAction Ptr->isProcessingUserGesture()) {75 page Ptr->setShouldSuppressSOAuthorizationInNextNavigationPolicyDecision();76 auto html = makeString("<script>location = '", response.httpHeaderFields().get( WebCore::HTTPHeaderName::Location), "'</script>").utf8();75 if (!navigationAction->isProcessingUserGesture()) { 76 page->setShouldSuppressSOAuthorizationInNextNavigationPolicyDecision(); 77 auto html = makeString("<script>location = '", response.httpHeaderFields().get(HTTPHeaderName::Location), "'</script>").utf8(); 77 78 auto data = IPC::DataReference(reinterpret_cast<const uint8_t*>(html.data()), html.length()); 78 page Ptr->loadData(data, "text/html"_s, "UTF-8"_s, navigationActionPtr->request().url());79 page->loadData(data, "text/html"_s, "UTF-8"_s, navigationAction->request().url(), nullptr, navigationAction->shouldOpenExternalURLsPolicy()); 79 80 return; 80 81 } 81 82 #endif 82 page Ptr->loadRequest(WebCore::ResourceRequest(response.httpHeaderFields().get(WebCore::HTTPHeaderName::Location)));83 page->loadRequest(ResourceRequest(response.httpHeaderFields().get(HTTPHeaderName::Location))); 83 84 } 84 85 if (response.httpStatusCode() == 200) { 85 page Ptr->setShouldSuppressSOAuthorizationInNextNavigationPolicyDecision();86 page Ptr->loadData(IPC::DataReference(static_cast<const uint8_t*>(data.bytes), data.length), "text/html"_s, "UTF-8"_s, response.url().string());86 page->setShouldSuppressSOAuthorizationInNextNavigationPolicyDecision(); 87 page->loadData(IPC::DataReference(static_cast<const uint8_t*>(data.bytes), data.length), "text/html"_s, "UTF-8"_s, response.url().string(), nullptr, navigationAction->shouldOpenExternalURLsPolicy()); 87 88 } 88 89 } -
trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/SOAuthorizationSession.h
r246514 r246701 99 99 virtual void fallBackToWebPathInternal() = 0; 100 100 virtual void abortInternal() = 0; 101 virtual void completeInternal( WebCore::ResourceResponse&&, NSData *) = 0;101 virtual void completeInternal(const WebCore::ResourceResponse&, NSData *) = 0; 102 102 103 103 void becomeCompleted(); -
trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/SOAuthorizationSession.mm
r246514 r246701 155 155 auto cookies = toCookieVector([NSHTTPCookie cookiesWithResponseHeaderFields:httpResponse.allHeaderFields forURL:response.url()]); 156 156 if (cookies.isEmpty()) { 157 completeInternal( WTFMove(response), data);157 completeInternal(response, data); 158 158 return; 159 159 } … … 164 164 if (!weakThis) 165 165 return; 166 weakThis->completeInternal( WTFMove(response), data.get());166 weakThis->completeInternal(response, data.get()); 167 167 }); 168 168 } -
trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/SubFrameSOAuthorizationSession.h
r246514 r246701 48 48 void fallBackToWebPathInternal() final; 49 49 void abortInternal() final; 50 void completeInternal( WebCore::ResourceResponse&&, NSData *) final;50 void completeInternal(const WebCore::ResourceResponse&, NSData *) final; 51 51 52 52 // NavigationSOAuthorizationSession -
trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/SubFrameSOAuthorizationSession.mm
r246514 r246701 60 60 if (!weakThis) 61 61 return; 62 auto* page Ptr= weakThis->page();62 auto* page = weakThis->page(); 63 63 auto* navigationActionPtr = weakThis->navigationAction(); 64 if (!page Ptr|| !navigationActionPtr)64 if (!page || !navigationActionPtr) 65 65 return; 66 66 67 67 if (auto* targetFrame = navigationActionPtr->targetFrame()) { 68 if (auto* frame = page Ptr->process().webFrame(targetFrame->handle().frameID())) {69 page Ptr->setShouldSuppressSOAuthorizationInNextNavigationPolicyDecision();68 if (auto* frame = page->process().webFrame(targetFrame->handle().frameID())) { 69 page->setShouldSuppressSOAuthorizationInNextNavigationPolicyDecision(); 70 70 // Issue a new load to the original URL as the original load is aborted before start. 71 71 frame->loadURL(navigationActionPtr->request().url()); … … 80 80 } 81 81 82 void SubFrameSOAuthorizationSession::completeInternal( WebCore::ResourceResponse&& response, NSData *data)82 void SubFrameSOAuthorizationSession::completeInternal(const WebCore::ResourceResponse& response, NSData *data) 83 83 { 84 84 if (response.httpStatusCode() != 200) { … … 104 104 void SubFrameSOAuthorizationSession::loadDataToFrame(const IPC::DataReference& data, const URL& baseURL) 105 105 { 106 auto* page Ptr =page();106 auto* page = this->page(); 107 107 auto* navigationActionPtr = navigationAction(); 108 if (!page Ptr|| !navigationActionPtr)108 if (!page || !navigationActionPtr) 109 109 return; 110 110 111 111 if (auto* targetFrame = navigationActionPtr->targetFrame()) { 112 if (auto* frame = page Ptr->process().webFrame(targetFrame->handle().frameID())) {113 page Ptr->setShouldSuppressSOAuthorizationInNextNavigationPolicyDecision();112 if (auto* frame = page->process().webFrame(targetFrame->handle().frameID())) { 113 page->setShouldSuppressSOAuthorizationInNextNavigationPolicyDecision(); 114 114 frame->loadData(data, "text/html", "UTF-8", baseURL); 115 115 } … … 119 119 void SubFrameSOAuthorizationSession::postDidCancelMessageToParent(Function<void()>&& callback) 120 120 { 121 auto* page Ptr =page();121 auto* page = this->page(); 122 122 auto* navigationActionPtr = navigationAction(); 123 if (!page Ptr|| !navigationActionPtr)123 if (!page || !navigationActionPtr) 124 124 return; 125 125 126 126 if (auto* targetFrame = navigationActionPtr->targetFrame()) { 127 page Ptr->runJavaScriptInFrame(targetFrame->handle().frameID(), soAuthorizationPostDidCancelMessageToParent, false, [callback = WTFMove(callback)] (API::SerializedScriptValue*, bool, const ExceptionDetails&, ScriptValueCallback::Error) {127 page->runJavaScriptInFrame(targetFrame->handle().frameID(), soAuthorizationPostDidCancelMessageToParent, false, [callback = WTFMove(callback)] (API::SerializedScriptValue*, bool, const ExceptionDetails&, ScriptValueCallback::Error) { 128 128 callback(); 129 129 }); -
trunk/Source/WebKit/UIProcess/WebPageProxy.cpp
r246694 r246701 1118 1118 loadParameters.navigationID = navigation.navigationID(); 1119 1119 loadParameters.request = WTFMove(request); 1120 loadParameters.shouldOpenExternalURLsPolicy = (uint64_t)shouldOpenExternalURLsPolicy;1120 loadParameters.shouldOpenExternalURLsPolicy = shouldOpenExternalURLsPolicy; 1121 1121 loadParameters.userData = UserData(process->transformObjectsToHandles(userData).get()); 1122 1122 loadParameters.shouldTreatAsContinuingLoad = shouldTreatAsContinuingLoad == ShouldTreatAsContinuingLoad::Yes; … … 1173 1173 loadParameters.navigationID = navigation->navigationID(); 1174 1174 loadParameters.request = fileURL; 1175 loadParameters.shouldOpenExternalURLsPolicy = (uint64_t)ShouldOpenExternalURLsPolicy::ShouldNotAllow;1175 loadParameters.shouldOpenExternalURLsPolicy = ShouldOpenExternalURLsPolicy::ShouldNotAllow; 1176 1176 loadParameters.userData = UserData(process().transformObjectsToHandles(userData).get()); 1177 1177 SandboxExtension::createHandle(resourceDirectoryPath, SandboxExtension::Type::ReadOnly, loadParameters.sandboxExtensionHandle); … … 1185 1185 } 1186 1186 1187 RefPtr<API::Navigation> WebPageProxy::loadData(const IPC::DataReference& data, const String& MIMEType, const String& encoding, const String& baseURL, API::Object* userData )1187 RefPtr<API::Navigation> WebPageProxy::loadData(const IPC::DataReference& data, const String& MIMEType, const String& encoding, const String& baseURL, API::Object* userData, ShouldOpenExternalURLsPolicy shouldOpenExternalURLsPolicy) 1188 1188 { 1189 1189 RELEASE_LOG_IF_ALLOWED(Loading, "loadData: webPID = %i, pageID = %" PRIu64, m_process->processIdentifier(), m_pageID.toUInt64()); … … 1198 1198 1199 1199 auto navigation = m_navigationState->createLoadDataNavigation(std::make_unique<API::SubstituteData>(data.vector(), MIMEType, encoding, baseURL, userData)); 1200 loadDataWithNavigationShared(m_process.copyRef(), navigation, data, MIMEType, encoding, baseURL, userData, ShouldTreatAsContinuingLoad::No );1200 loadDataWithNavigationShared(m_process.copyRef(), navigation, data, MIMEType, encoding, baseURL, userData, ShouldTreatAsContinuingLoad::No, WTF::nullopt, shouldOpenExternalURLsPolicy); 1201 1201 return navigation; 1202 1202 } 1203 1203 1204 void WebPageProxy::loadDataWithNavigationShared(Ref<WebProcessProxy>&& process, API::Navigation& navigation, const IPC::DataReference& data, const String& MIMEType, const String& encoding, const String& baseURL, API::Object* userData, ShouldTreatAsContinuingLoad shouldTreatAsContinuingLoad, Optional<WebsitePoliciesData>&& websitePolicies )1204 void WebPageProxy::loadDataWithNavigationShared(Ref<WebProcessProxy>&& process, API::Navigation& navigation, const IPC::DataReference& data, const String& MIMEType, const String& encoding, const String& baseURL, API::Object* userData, ShouldTreatAsContinuingLoad shouldTreatAsContinuingLoad, Optional<WebsitePoliciesData>&& websitePolicies, ShouldOpenExternalURLsPolicy shouldOpenExternalURLsPolicy) 1205 1205 { 1206 1206 RELEASE_LOG_IF_ALLOWED(Loading, "loadDataWithNavigation: webPID = %i, pageID = %" PRIu64, process->processIdentifier(), m_pageID.toUInt64()); … … 1221 1221 loadParameters.userData = UserData(process->transformObjectsToHandles(userData).get()); 1222 1222 loadParameters.websitePolicies = WTFMove(websitePolicies); 1223 loadParameters.shouldOpenExternalURLsPolicy = shouldOpenExternalURLsPolicy; 1223 1224 addPlatformLoadParameters(loadParameters); 1224 1225 -
trunk/Source/WebKit/UIProcess/WebPageProxy.h
r246694 r246701 529 529 RefPtr<API::Navigation> loadRequest(WebCore::ResourceRequest&&, WebCore::ShouldOpenExternalURLsPolicy = WebCore::ShouldOpenExternalURLsPolicy::ShouldAllowExternalSchemes, API::Object* userData = nullptr); 530 530 RefPtr<API::Navigation> loadFile(const String& fileURL, const String& resourceDirectoryURL, API::Object* userData = nullptr); 531 RefPtr<API::Navigation> loadData(const IPC::DataReference&, const String& MIMEType, const String& encoding, const String& baseURL, API::Object* userData = nullptr );531 RefPtr<API::Navigation> loadData(const IPC::DataReference&, const String& MIMEType, const String& encoding, const String& baseURL, API::Object* userData = nullptr, WebCore::ShouldOpenExternalURLsPolicy = WebCore::ShouldOpenExternalURLsPolicy::ShouldNotAllow); 532 532 void loadAlternateHTML(const IPC::DataReference&, const String& encoding, const URL& baseURL, const URL& unreachableURL, API::Object* userData = nullptr); 533 533 void loadWebArchiveData(API::Data*, API::Object* userData = nullptr); … … 1510 1510 uint64_t navigationID, const WebCore::ResourceResponse&, const WebCore::ResourceRequest&, bool canShowMIMEType, const String& downloadAttribute, uint64_t listenerID, const UserData&); 1511 1511 void startURLSchemeTaskShared(Ref<WebProcessProxy>&&, URLSchemeTaskParameters&&); 1512 void loadDataWithNavigationShared(Ref<WebProcessProxy>&&, API::Navigation&, const IPC::DataReference&, const String& MIMEType, const String& encoding, const String& baseURL, API::Object* userData, WebCore::ShouldTreatAsContinuingLoad, Optional<WebsitePoliciesData>&& = WTF::nullopt );1512 void loadDataWithNavigationShared(Ref<WebProcessProxy>&&, API::Navigation&, const IPC::DataReference&, const String& MIMEType, const String& encoding, const String& baseURL, API::Object* userData, WebCore::ShouldTreatAsContinuingLoad, Optional<WebsitePoliciesData>&& = WTF::nullopt, WebCore::ShouldOpenExternalURLsPolicy = WebCore::ShouldOpenExternalURLsPolicy::ShouldNotAllow); 1513 1513 void loadRequestWithNavigationShared(Ref<WebProcessProxy>&&, API::Navigation&, WebCore::ResourceRequest&&, WebCore::ShouldOpenExternalURLsPolicy, API::Object* userData, WebCore::ShouldTreatAsContinuingLoad, Optional<WebsitePoliciesData>&& = WTF::nullopt); 1514 1514 void backForwardGoToItemShared(Ref<WebProcessProxy>&&, const WebCore::BackForwardItemIdentifier&, CompletionHandler<void(SandboxExtension::Handle&&)>&&); -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp
r246413 r246701 1534 1534 // Initate the load in WebCore. 1535 1535 FrameLoadRequest frameLoadRequest { *m_mainFrame->coreFrame(), loadParameters.request, ShouldOpenExternalURLsPolicy::ShouldNotAllow }; 1536 ShouldOpenExternalURLsPolicy externalURLsPolicy = static_cast<ShouldOpenExternalURLsPolicy>(loadParameters.shouldOpenExternalURLsPolicy); 1537 frameLoadRequest.setShouldOpenExternalURLsPolicy(externalURLsPolicy); 1536 frameLoadRequest.setShouldOpenExternalURLsPolicy(loadParameters.shouldOpenExternalURLsPolicy); 1538 1537 frameLoadRequest.setShouldTreatAsContinuingLoad(loadParameters.shouldTreatAsContinuingLoad); 1539 1538 frameLoadRequest.setLockHistory(loadParameters.lockHistory); … … 1548 1547 } 1549 1548 1550 void WebPage::loadDataImpl(uint64_t navigationID, bool shouldTreatAsContinuingLoad, Optional<WebsitePoliciesData>&& websitePolicies, Ref<SharedBuffer>&& sharedBuffer, const String& MIMEType, const String& encodingName, const URL& baseURL, const URL& unreachableURL, const UserData& userData )1549 void WebPage::loadDataImpl(uint64_t navigationID, bool shouldTreatAsContinuingLoad, Optional<WebsitePoliciesData>&& websitePolicies, Ref<SharedBuffer>&& sharedBuffer, const String& MIMEType, const String& encodingName, const URL& baseURL, const URL& unreachableURL, const UserData& userData, ShouldOpenExternalURLsPolicy shouldOpenExternalURLsPolicy) 1551 1550 { 1552 1551 SendStopResponsivenessTimer stopper; … … 1564 1563 1565 1564 // Initate the load in WebCore. 1566 FrameLoadRequest frameLoadRequest(*m_mainFrame->coreFrame(), request, ShouldOpenExternalURLsPolicy::ShouldNotAllow, substituteData);1565 FrameLoadRequest frameLoadRequest(*m_mainFrame->coreFrame(), request, shouldOpenExternalURLsPolicy, substituteData); 1567 1566 frameLoadRequest.setShouldTreatAsContinuingLoad(shouldTreatAsContinuingLoad); 1568 1567 m_mainFrame->coreFrame()->loader().load(WTFMove(frameLoadRequest)); … … 1575 1574 auto sharedBuffer = SharedBuffer::create(reinterpret_cast<const char*>(loadParameters.data.data()), loadParameters.data.size()); 1576 1575 URL baseURL = loadParameters.baseURLString.isEmpty() ? WTF::blankURL() : URL(URL(), loadParameters.baseURLString); 1577 loadDataImpl(loadParameters.navigationID, loadParameters.shouldTreatAsContinuingLoad, WTFMove(loadParameters.websitePolicies), WTFMove(sharedBuffer), loadParameters.MIMEType, loadParameters.encodingName, baseURL, URL(), loadParameters.userData );1576 loadDataImpl(loadParameters.navigationID, loadParameters.shouldTreatAsContinuingLoad, WTFMove(loadParameters.websitePolicies), WTFMove(sharedBuffer), loadParameters.MIMEType, loadParameters.encodingName, baseURL, URL(), loadParameters.userData, loadParameters.shouldOpenExternalURLsPolicy); 1578 1577 } 1579 1578 -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.h
r246677 r246701 1285 1285 String sourceForFrame(WebFrame*); 1286 1286 1287 void loadDataImpl(uint64_t navigationID, bool shouldTreatAsContinuingLoad, Optional<WebsitePoliciesData>&&, Ref<WebCore::SharedBuffer>&&, const String& MIMEType, const String& encodingName, const URL& baseURL, const URL& failingURL, const UserData& );1287 void loadDataImpl(uint64_t navigationID, bool shouldTreatAsContinuingLoad, Optional<WebsitePoliciesData>&&, Ref<WebCore::SharedBuffer>&&, const String& MIMEType, const String& encodingName, const URL& baseURL, const URL& failingURL, const UserData&, WebCore::ShouldOpenExternalURLsPolicy = WebCore::ShouldOpenExternalURLsPolicy::ShouldNotAllow); 1288 1288 1289 1289 // Actions -
trunk/Tools/ChangeLog
r246694 r246701 1 2019-06-21 Jiewen Tan <jiewen_tan@apple.com> 2 3 WebPageProxy::loadData should accept ShouldOpenExternalURLsPolicy 4 https://bugs.webkit.org/show_bug.cgi?id=199114 5 <rdar://problem/51671674> 6 7 Reviewed by Youenn Fablet. 8 9 * TestWebKitAPI/Tests/WebKitCocoa/TestSOAuthorization.mm: 10 (-[TestSOAuthorizationNavigationDelegate init]): 11 (-[TestSOAuthorizationNavigationDelegate webView:decidePolicyForNavigationAction:decisionHandler:]): 12 (configureSOAuthorizationWebView): 13 (TestWebKitAPI::TEST): 14 1 15 2019-06-21 Youenn Fablet <youenn@apple.com> 2 16 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/TestSOAuthorization.mm
r246514 r246701 33 33 #import "PlatformUtilities.h" 34 34 #import "TestWKWebView.h" 35 #import <WebKit/WKNavigationActionPrivate.h> 35 36 #import <WebKit/WKNavigationDelegatePrivate.h> 36 37 #import <WebKit/WKNavigationPrivate.h> … … 122 123 @interface TestSOAuthorizationNavigationDelegate : NSObject <WKNavigationDelegate, WKUIDelegate> 123 124 @property bool isDefaultPolicy; 125 @property bool shouldOpenExternalSchemes; 124 126 - (instancetype)init; 125 127 @end … … 129 131 - (instancetype)init 130 132 { 131 if (self = [super init]) 133 if (self = [super init]) { 132 134 self.isDefaultPolicy = true; 135 self.shouldOpenExternalSchemes = false; 136 } 133 137 return self; 134 138 } … … 143 147 - (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler 144 148 { 149 EXPECT_EQ(navigationAction._shouldOpenExternalSchemes, self.shouldOpenExternalSchemes); 145 150 if (self.isDefaultPolicy) { 146 151 decisionHandler(WKNavigationActionPolicyAllow); … … 243 248 } 244 249 245 static void configureSOAuthorizationWebView(TestWKWebView *webView, TestSOAuthorizationNavigationDelegate *delegate) 250 enum class OpenExternalSchemesPolicy : bool { 251 Allow, 252 Disallow 253 }; 254 255 static void configureSOAuthorizationWebView(TestWKWebView *webView, TestSOAuthorizationNavigationDelegate *delegate, OpenExternalSchemesPolicy policy = OpenExternalSchemesPolicy::Disallow) 246 256 { 247 257 [webView setNavigationDelegate:delegate]; 248 258 [webView setUIDelegate:delegate]; 259 delegate.shouldOpenExternalSchemes = policy == OpenExternalSchemesPolicy::Allow; 249 260 } 250 261 … … 278 289 auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]); 279 290 auto delegate = adoptNS([[TestSOAuthorizationNavigationDelegate alloc] init]); 280 configureSOAuthorizationWebView(webView.get(), delegate.get() );291 configureSOAuthorizationWebView(webView.get(), delegate.get(), OpenExternalSchemesPolicy::Allow); 281 292 282 293 [webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]]; … … 295 306 auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]); 296 307 auto delegate = adoptNS([[TestSOAuthorizationNavigationDelegate alloc] init]); 297 configureSOAuthorizationWebView(webView.get(), delegate.get() );308 configureSOAuthorizationWebView(webView.get(), delegate.get(), OpenExternalSchemesPolicy::Allow); 298 309 299 310 [webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]]; … … 314 325 auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]); 315 326 auto delegate = adoptNS([[TestSOAuthorizationNavigationDelegate alloc] init]); 316 configureSOAuthorizationWebView(webView.get(), delegate.get() );327 configureSOAuthorizationWebView(webView.get(), delegate.get(), OpenExternalSchemesPolicy::Allow); 317 328 318 329 [webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]]; … … 337 348 auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]); 338 349 auto delegate = adoptNS([[TestSOAuthorizationNavigationDelegate alloc] init]); 339 configureSOAuthorizationWebView(webView.get(), delegate.get() );350 configureSOAuthorizationWebView(webView.get(), delegate.get(), OpenExternalSchemesPolicy::Allow); 340 351 341 352 [webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]]; … … 360 371 auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]); 361 372 auto delegate = adoptNS([[TestSOAuthorizationNavigationDelegate alloc] init]); 362 configureSOAuthorizationWebView(webView.get(), delegate.get() );373 configureSOAuthorizationWebView(webView.get(), delegate.get(), OpenExternalSchemesPolicy::Allow); 363 374 364 375 [webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]]; … … 383 394 auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]); 384 395 auto delegate = adoptNS([[TestSOAuthorizationNavigationDelegate alloc] init]); 385 configureSOAuthorizationWebView(webView.get(), delegate.get() );396 configureSOAuthorizationWebView(webView.get(), delegate.get(), OpenExternalSchemesPolicy::Allow); 386 397 387 398 [webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]]; … … 407 418 auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]); 408 419 auto delegate = adoptNS([[TestSOAuthorizationNavigationDelegate alloc] init]); 409 configureSOAuthorizationWebView(webView.get(), delegate.get() );420 configureSOAuthorizationWebView(webView.get(), delegate.get(), OpenExternalSchemesPolicy::Allow); 410 421 411 422 [webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]]; … … 434 445 auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]); 435 446 auto delegate = adoptNS([[TestSOAuthorizationNavigationDelegate alloc] init]); 436 configureSOAuthorizationWebView(webView.get(), delegate.get() );447 configureSOAuthorizationWebView(webView.get(), delegate.get(), OpenExternalSchemesPolicy::Allow); 437 448 438 449 // Force App Links with a request.URL that has a different host than the current one (empty host) and ShouldOpenExternalURLsPolicy::ShouldAllow. … … 468 479 auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]); 469 480 auto delegate = adoptNS([[TestSOAuthorizationNavigationDelegate alloc] init]); 470 configureSOAuthorizationWebView(webView.get(), delegate.get() );481 configureSOAuthorizationWebView(webView.get(), delegate.get(), OpenExternalSchemesPolicy::Allow); 471 482 472 483 // Force App Links with a request.URL that has a different host than the current one (empty host) and ShouldOpenExternalURLsPolicy::ShouldAllow. … … 505 516 // A separate delegate that implements decidePolicyForNavigationAction. 506 517 auto delegate = adoptNS([[TestSOAuthorizationNavigationDelegate alloc] init]); 507 configureSOAuthorizationWebView(webView.get(), delegate.get() );518 configureSOAuthorizationWebView(webView.get(), delegate.get(), OpenExternalSchemesPolicy::Allow); 508 519 [delegate setIsDefaultPolicy:false]; 509 520 … … 534 545 auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]); 535 546 auto delegate = adoptNS([[TestSOAuthorizationNavigationDelegate alloc] init]); 536 configureSOAuthorizationWebView(webView.get(), delegate.get() );547 configureSOAuthorizationWebView(webView.get(), delegate.get(), OpenExternalSchemesPolicy::Allow); 537 548 538 549 [webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]]; … … 558 569 auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]); 559 570 auto delegate = adoptNS([[TestSOAuthorizationNavigationDelegate alloc] init]); 560 configureSOAuthorizationWebView(webView.get(), delegate.get() );571 configureSOAuthorizationWebView(webView.get(), delegate.get(), OpenExternalSchemesPolicy::Allow); 561 572 562 573 [webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]]; … … 593 604 auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]); 594 605 auto delegate = adoptNS([[TestSOAuthorizationNavigationDelegate alloc] init]); 595 configureSOAuthorizationWebView(webView.get(), delegate.get() );606 configureSOAuthorizationWebView(webView.get(), delegate.get(), OpenExternalSchemesPolicy::Allow); 596 607 597 608 [webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]]; … … 627 638 auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]); 628 639 auto delegate = adoptNS([[TestSOAuthorizationNavigationDelegate alloc] init]); 629 configureSOAuthorizationWebView(webView.get(), delegate.get() );640 configureSOAuthorizationWebView(webView.get(), delegate.get(), OpenExternalSchemesPolicy::Allow); 630 641 631 642 auto testURL = URL(URL(), "https://www.example.com"); … … 668 679 auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]); 669 680 auto delegate = adoptNS([[TestSOAuthorizationNavigationDelegate alloc] init]); 670 configureSOAuthorizationWebView(webView.get(), delegate.get() );681 configureSOAuthorizationWebView(webView.get(), delegate.get(), OpenExternalSchemesPolicy::Allow); 671 682 672 683 [webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]]; … … 692 703 auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]); 693 704 auto delegate = adoptNS([[TestSOAuthorizationNavigationDelegate alloc] init]); 694 [webView setNavigationDelegate:delegate.get()]; 695 [webView setUIDelegate:delegate.get()]; 705 configureSOAuthorizationWebView(webView.get(), delegate.get(), OpenExternalSchemesPolicy::Allow); 696 706 697 707 // The session will be waiting since the web view is is not int the window. … … 728 738 auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]); 729 739 auto delegate = adoptNS([[TestSOAuthorizationNavigationDelegate alloc] init]); 730 configureSOAuthorizationWebView(webView.get(), delegate.get() );740 configureSOAuthorizationWebView(webView.get(), delegate.get(), OpenExternalSchemesPolicy::Allow); 731 741 732 742 [webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]]; … … 759 769 auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]); 760 770 auto delegate = adoptNS([[TestSOAuthorizationNavigationDelegate alloc] init]); 761 configureSOAuthorizationWebView(webView.get(), delegate.get() );771 configureSOAuthorizationWebView(webView.get(), delegate.get(), OpenExternalSchemesPolicy::Allow); 762 772 763 773 for (int i = 0; i < 2; i++) { … … 792 802 auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]); 793 803 auto delegate = adoptNS([[TestSOAuthorizationNavigationDelegate alloc] init]); 794 configureSOAuthorizationWebView(webView.get(), delegate.get() );804 configureSOAuthorizationWebView(webView.get(), delegate.get(), OpenExternalSchemesPolicy::Allow); 795 805 796 806 [webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]]; … … 827 837 auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]); 828 838 auto delegate = adoptNS([[TestSOAuthorizationNavigationDelegate alloc] init]); 829 [webView setNavigationDelegate:delegate.get()]; 830 [webView setUIDelegate:delegate.get()]; 839 configureSOAuthorizationWebView(webView.get(), delegate.get(), OpenExternalSchemesPolicy::Allow); 831 840 832 841 // The session will be waiting since the web view is is not int the window. … … 868 877 auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]); 869 878 auto delegate = adoptNS([[TestSOAuthorizationNavigationDelegate alloc] init]); 870 configureSOAuthorizationWebView(webView.get(), delegate.get() );879 configureSOAuthorizationWebView(webView.get(), delegate.get(), OpenExternalSchemesPolicy::Allow); 871 880 872 881 // Add a http body to the request to mimic a SAML request. … … 898 907 [webView loadHTMLString:@"" baseURL:(NSURL *)URL(URL(), "http://www.webkit.org")]; 899 908 Util::run(&navigationCompleted); 909 910 [delegate setShouldOpenExternalSchemes:true]; 900 911 [webView evaluateJavaScript: @"location = 'http://www.example.com'" completionHandler:nil]; 901 912 Util::run(&authorizationPerformed); … … 914 925 auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]); 915 926 auto delegate = adoptNS([[TestSOAuthorizationNavigationDelegate alloc] init]); 916 configureSOAuthorizationWebView(webView.get(), delegate.get() );927 configureSOAuthorizationWebView(webView.get(), delegate.get(), OpenExternalSchemesPolicy::Allow); 917 928 918 929 [webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]]; … … 935 946 auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]); 936 947 auto delegate = adoptNS([[TestSOAuthorizationNavigationDelegate alloc] init]); 937 configureSOAuthorizationWebView(webView.get(), delegate.get() );948 configureSOAuthorizationWebView(webView.get(), delegate.get(), OpenExternalSchemesPolicy::Allow); 938 949 939 950 [webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]]; … … 960 971 auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]); 961 972 auto delegate = adoptNS([[TestSOAuthorizationNavigationDelegate alloc] init]); 962 configureSOAuthorizationWebView(webView.get(), delegate.get() );973 configureSOAuthorizationWebView(webView.get(), delegate.get(), OpenExternalSchemesPolicy::Allow); 963 974 964 975 [webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]]; … … 993 1004 auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]); 994 1005 auto delegate = adoptNS([[TestSOAuthorizationNavigationDelegate alloc] init]); 995 configureSOAuthorizationWebView(webView.get(), delegate.get() );1006 configureSOAuthorizationWebView(webView.get(), delegate.get(), OpenExternalSchemesPolicy::Allow); 996 1007 997 1008 [webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]]; … … 1025 1036 auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]); 1026 1037 auto delegate = adoptNS([[TestSOAuthorizationNavigationDelegate alloc] init]); 1027 configureSOAuthorizationWebView(webView.get(), delegate.get() );1038 configureSOAuthorizationWebView(webView.get(), delegate.get(), OpenExternalSchemesPolicy::Allow); 1028 1039 1029 1040 [webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]]; … … 1057 1068 auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]); 1058 1069 auto delegate = adoptNS([[TestSOAuthorizationNavigationDelegate alloc] init]); 1059 configureSOAuthorizationWebView(webView.get(), delegate.get() );1070 configureSOAuthorizationWebView(webView.get(), delegate.get(), OpenExternalSchemesPolicy::Allow); 1060 1071 1061 1072 [webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]]; … … 1096 1107 auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]); 1097 1108 auto delegate = adoptNS([[TestSOAuthorizationNavigationDelegate alloc] init]); 1098 configureSOAuthorizationWebView(webView.get(), delegate.get() );1109 configureSOAuthorizationWebView(webView.get(), delegate.get(), OpenExternalSchemesPolicy::Allow); 1099 1110 1100 1111 [webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]]; … … 1133 1144 auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]); 1134 1145 auto delegate = adoptNS([[TestSOAuthorizationNavigationDelegate alloc] init]); 1135 configureSOAuthorizationWebView(webView.get(), delegate.get() );1146 configureSOAuthorizationWebView(webView.get(), delegate.get(), OpenExternalSchemesPolicy::Allow); 1136 1147 1137 1148 [webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]]; … … 1168 1179 Util::run(&navigationCompleted); 1169 1180 1181 [delegate setShouldOpenExternalSchemes:true]; 1170 1182 navigationCompleted = false; 1171 1183 #if PLATFORM(MAC) … … 1245 1257 Util::run(&navigationCompleted); 1246 1258 1259 [delegate setShouldOpenExternalSchemes:true]; 1247 1260 #if PLATFORM(MAC) 1248 1261 [webView sendClicksAtPoint:NSMakePoint(200, 200) numberOfClicks:1]; … … 1421 1434 Util::run(&navigationCompleted); 1422 1435 1436 [delegate setShouldOpenExternalSchemes:true]; 1423 1437 #if PLATFORM(MAC) 1424 1438 [webView sendClicksAtPoint:NSMakePoint(200, 200) numberOfClicks:1];
Note: See TracChangeset
for help on using the changeset viewer.