Changeset 238179 in webkit
- Timestamp:
- Nov 14, 2018 8:58:17 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r238178 r238179 1 2018-11-14 Chris Dumez <cdumez@apple.com> 2 3 WebKit.ApplicationManifestBasic API test is failing when enabling PSON 4 https://bugs.webkit.org/show_bug.cgi?id=191602 5 6 Reviewed by Alex Christensen. 7 8 Add support for process swapping for a [WKWebView loadHTML:] load by storing 9 the necessary data on the API::Navigation and doing a loadData() instead of 10 a loadRequest() after process swapping when this data is present on the 11 navigation. 12 13 * UIProcess/API/APINavigation.cpp: 14 (API::Navigation::Navigation): 15 * UIProcess/API/APINavigation.h: 16 (API::Navigation::create): 17 (API::Navigation::substituteData const): 18 * UIProcess/WebNavigationState.cpp: 19 (WebKit::WebNavigationState::createLoadDataNavigation): 20 * UIProcess/WebNavigationState.h: 21 * UIProcess/WebPageProxy.cpp: 22 (WebKit::WebPageProxy::loadData): 23 (WebKit::WebPageProxy::continueNavigationInNewProcess): 24 1 25 2018-11-14 Antti Koivisto <antti@apple.com> 2 26 -
trunk/Source/WebKit/UIProcess/API/APINavigation.cpp
r235823 r238179 60 60 } 61 61 62 Navigation::Navigation(WebKit::WebNavigationState& state, std::unique_ptr<SubstituteData>&& substituteData) 63 : Navigation(state) 64 { 65 ASSERT(substituteData); 66 m_substituteData = WTFMove(substituteData); 67 } 68 62 69 Navigation::~Navigation() 63 70 { -
trunk/Source/WebKit/UIProcess/API/APINavigation.h
r237355 r238179 27 27 28 28 #include "APIObject.h" 29 #include "DataReference.h" 29 30 #include "WebBackForwardListItem.h" 30 31 #include <WebCore/Process.h> … … 42 43 43 44 namespace API { 45 46 struct SubstituteData { 47 WTF_MAKE_FAST_ALLOCATED; 48 public: 49 SubstituteData(Vector<uint8_t>&& content, const WTF::String& MIMEType, const WTF::String& encoding, const WTF::String& baseURL, API::Object* userData) 50 : content(WTFMove(content)) 51 , MIMEType(MIMEType) 52 , encoding(encoding) 53 , baseURL(baseURL) 54 , userData(userData) 55 { } 56 57 Vector<uint8_t> content; 58 WTF::String MIMEType; 59 WTF::String encoding; 60 WTF::String baseURL; 61 RefPtr<API::Object> userData; 62 }; 44 63 45 64 class Navigation : public ObjectImpl<Object::Type::Navigation> { … … 59 78 { 60 79 return adoptRef(*new Navigation(state, WTFMove(request), fromItem)); 80 } 81 82 static Ref<Navigation> create(WebKit::WebNavigationState& state, std::unique_ptr<SubstituteData>&& substituteData) 83 { 84 return adoptRef(*new Navigation(state, WTFMove(substituteData))); 61 85 } 62 86 … … 115 139 #endif 116 140 141 const std::unique_ptr<SubstituteData>& substituteData() const { return m_substituteData; } 142 117 143 private: 118 144 explicit Navigation(WebKit::WebNavigationState&); 119 145 Navigation(WebKit::WebNavigationState&, WebCore::ResourceRequest&&, WebKit::WebBackForwardListItem* fromItem); 120 146 Navigation(WebKit::WebNavigationState&, WebKit::WebBackForwardListItem& targetItem, WebKit::WebBackForwardListItem* fromItem, WebCore::FrameLoadType); 147 Navigation(WebKit::WebNavigationState&, std::unique_ptr<SubstituteData>&&); 121 148 122 149 uint64_t m_navigationID; … … 140 167 WebCore::LockBackForwardList m_lockBackForwardList; 141 168 WTF::String m_clientRedirectSourceForHistory; 169 std::unique_ptr<SubstituteData> m_substituteData; 142 170 }; 143 171 -
trunk/Source/WebKit/UIProcess/WebNavigationState.cpp
r236227 r238179 69 69 } 70 70 71 Ref<API::Navigation> WebNavigationState::createLoadDataNavigation( )71 Ref<API::Navigation> WebNavigationState::createLoadDataNavigation(std::unique_ptr<API::SubstituteData>&& substituteData) 72 72 { 73 auto navigation = API::Navigation::create(*this );73 auto navigation = API::Navigation::create(*this, WTFMove(substituteData)); 74 74 75 75 m_navigations.set(navigation->navigationID(), navigation.ptr()); -
trunk/Source/WebKit/UIProcess/WebNavigationState.h
r237074 r238179 31 31 namespace API { 32 32 class Navigation; 33 struct SubstituteData; 33 34 } 34 35 … … 52 53 Ref<API::Navigation> createLoadRequestNavigation(WebCore::ResourceRequest&&, WebBackForwardListItem* currentItem); 53 54 Ref<API::Navigation> createReloadNavigation(); 54 Ref<API::Navigation> createLoadDataNavigation( );55 Ref<API::Navigation> createLoadDataNavigation(std::unique_ptr<API::SubstituteData>&&); 55 56 56 57 API::Navigation* navigation(uint64_t navigationID); -
trunk/Source/WebKit/UIProcess/WebPageProxy.cpp
r238078 r238179 1088 1088 return nullptr; 1089 1089 1090 auto navigation = m_navigationState->createLoadDataNavigation(); 1090 auto navigation = m_navigationState->createLoadDataNavigation(std::make_unique<API::SubstituteData>(data.vector(), MIMEType, encoding, baseURL, userData)); 1091 loadDataWithNavigation(navigation, data, MIMEType, encoding, baseURL, userData); 1092 return WTFMove(navigation); 1093 } 1094 1095 void WebPageProxy::loadDataWithNavigation(API::Navigation& navigation, const IPC::DataReference& data, const String& MIMEType, const String& encoding, const String& baseURL, API::Object* userData) 1096 { 1097 ASSERT(!m_isClosed); 1091 1098 1092 1099 auto transaction = m_pageLoadState.transaction(); … … 1098 1105 1099 1106 LoadParameters loadParameters; 1100 loadParameters.navigationID = navigation ->navigationID();1107 loadParameters.navigationID = navigation.navigationID(); 1101 1108 loadParameters.data = data; 1102 1109 loadParameters.MIMEType = MIMEType; … … 1109 1116 m_process->send(Messages::WebPage::LoadData(loadParameters), m_pageID); 1110 1117 m_process->responsivenessTimer().start(); 1111 1112 return WTFMove(navigation);1113 1118 } 1114 1119 … … 2617 2622 // FIXME: Work out timing of responding with the last policy delegate, etc 2618 2623 ASSERT(!navigation.currentRequest().isEmpty()); 2619 loadRequestWithNavigation(navigation, ResourceRequest { navigation.currentRequest() }, WebCore::ShouldOpenExternalURLsPolicy::ShouldAllowExternalSchemes, nullptr, ShouldTreatAsContinuingLoad::Yes); 2624 if (auto& substituteData = navigation.substituteData()) 2625 loadDataWithNavigation(navigation, { substituteData->content.data(), substituteData->content.size() }, substituteData->MIMEType, substituteData->encoding, substituteData->baseURL, substituteData->userData.get()); 2626 else 2627 loadRequestWithNavigation(navigation, ResourceRequest { navigation.currentRequest() }, WebCore::ShouldOpenExternalURLsPolicy::ShouldAllowExternalSchemes, nullptr, ShouldTreatAsContinuingLoad::Yes); 2620 2628 2621 2629 ASSERT(!m_mainFrame); -
trunk/Source/WebKit/UIProcess/WebPageProxy.h
r238078 r238179 1540 1540 RefPtr<API::Navigation> reattachToWebProcessWithItem(WebBackForwardListItem&); 1541 1541 1542 void loadDataWithNavigation(API::Navigation&, const IPC::DataReference&, const String& MIMEType, const String& encoding, const String& baseURL, API::Object* userData = nullptr); 1542 1543 void loadRequestWithNavigation(API::Navigation&, WebCore::ResourceRequest&&, WebCore::ShouldOpenExternalURLsPolicy, API::Object* userData, WebCore::ShouldTreatAsContinuingLoad); 1543 1544 -
trunk/Tools/ChangeLog
r238177 r238179 1 2018-11-14 Chris Dumez <cdumez@apple.com> 2 3 WebKit.ApplicationManifestBasic API test is failing when enabling PSON 4 https://bugs.webkit.org/show_bug.cgi?id=191602 5 6 Reviewed by Alex Christensen. 7 8 Add API test coverage. 9 10 * TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm: 11 1 12 2018-11-14 Jonathan Bedard <jbedard@apple.com> 2 13 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm
r238061 r238179 2648 2648 } 2649 2649 2650 TEST(ProcessSwap, SwapOnLoadHTMLString) 2651 { 2652 auto processPoolConfiguration = adoptNS([[_WKProcessPoolConfiguration alloc] init]); 2653 processPoolConfiguration.get().processSwapsOnNavigation = YES; 2654 auto processPool = adoptNS([[WKProcessPool alloc] _initWithConfiguration:processPoolConfiguration.get()]); 2655 2656 auto webViewConfiguration = adoptNS([[WKWebViewConfiguration alloc] init]); 2657 [webViewConfiguration setProcessPool:processPool.get()]; 2658 auto handler = adoptNS([[PSONScheme alloc] init]); 2659 [webViewConfiguration setURLSchemeHandler:handler.get() forURLScheme:@"pson"]; 2660 2661 auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:webViewConfiguration.get()]); 2662 auto delegate = adoptNS([[PSONNavigationDelegate alloc] init]); 2663 [webView setNavigationDelegate:delegate.get()]; 2664 2665 NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"pson://www.webkit.org/main.html"]]; 2666 [webView loadRequest:request]; 2667 2668 TestWebKitAPI::Util::run(&done); 2669 done = false; 2670 2671 auto pid1 = [webView _webProcessIdentifier]; 2672 2673 NSString *htmlString = @"<html><body>substituteData</body></html>"; 2674 [webView loadHTMLString:htmlString baseURL:[NSURL URLWithString:@"http://example.com"]]; 2675 2676 TestWebKitAPI::Util::run(&done); 2677 done = false; 2678 2679 auto pid2 = [webView _webProcessIdentifier]; 2680 EXPECT_NE(pid1, pid2); 2681 2682 [webView evaluateJavaScript:@"document.body.innerText" completionHandler:^(id innerText, NSError *error) { 2683 EXPECT_WK_STREQ(@"substituteData", (NSString *)innerText); 2684 done = true; 2685 }]; 2686 TestWebKitAPI::Util::run(&done); 2687 done = false; 2688 } 2689 2650 2690 #if PLATFORM(MAC) 2651 2691
Note: See TracChangeset
for help on using the changeset viewer.