| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 4082 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4093 webViewHelper.webView()->mainFrame()->reload( | 4093 webViewHelper.webView()->mainFrame()->reload( |
| 4094 WebFrameLoadType::ReloadBypassingCache); | 4094 WebFrameLoadType::ReloadBypassingCache); |
| 4095 // start another reload before request is delivered. | 4095 // start another reload before request is delivered. |
| 4096 FrameTestHelpers::reloadFrameBypassingCache( | 4096 FrameTestHelpers::reloadFrameBypassingCache( |
| 4097 webViewHelper.webView()->mainFrame()); | 4097 webViewHelper.webView()->mainFrame()); |
| 4098 } | 4098 } |
| 4099 | 4099 |
| 4100 class ClearScrollStateOnCommitWebFrameClient | 4100 class ClearScrollStateOnCommitWebFrameClient |
| 4101 : public FrameTestHelpers::TestWebFrameClient { | 4101 : public FrameTestHelpers::TestWebFrameClient { |
| 4102 public: | 4102 public: |
| 4103 void didCommitProvisionalLoad(WebLocalFrame* frame, | 4103 void didCommitProvisionalLoad(WebDataSource*, |
| 4104 WebFrameLoadType, |
| 4104 const WebHistoryItem&, | 4105 const WebHistoryItem&, |
| 4105 WebHistoryCommitType) override { | 4106 WebHistoryCommitType) override { |
| 4106 frame->view()->resetScrollAndScaleState(); | 4107 if (m_webView) |
| 4108 m_webView->resetScrollAndScaleState(); |
| 4107 } | 4109 } |
| 4110 |
| 4111 void setWebView(WebView* webView) { m_webView = webView; } |
| 4112 |
| 4113 private: |
| 4114 WebView* m_webView = nullptr; |
| 4108 }; | 4115 }; |
| 4109 | 4116 |
| 4110 TEST_F(WebFrameTest, ReloadWithOverrideURLPreservesState) { | 4117 TEST_F(WebFrameTest, ReloadWithOverrideURLPreservesState) { |
| 4111 const std::string firstURL = "200-by-300.html"; | 4118 const std::string firstURL = "200-by-300.html"; |
| 4112 const std::string secondURL = "content-width-1000.html"; | 4119 const std::string secondURL = "content-width-1000.html"; |
| 4113 const std::string thirdURL = "very_tall_div.html"; | 4120 const std::string thirdURL = "very_tall_div.html"; |
| 4114 const float pageScaleFactor = 1.1684f; | 4121 const float pageScaleFactor = 1.1684f; |
| 4115 const int pageWidth = 120; | 4122 const int pageWidth = 120; |
| 4116 const int pageHeight = 100; | 4123 const int pageHeight = 100; |
| 4117 | 4124 |
| 4118 registerMockedHttpURLLoad(firstURL); | 4125 registerMockedHttpURLLoad(firstURL); |
| 4119 registerMockedHttpURLLoad(secondURL); | 4126 registerMockedHttpURLLoad(secondURL); |
| 4120 registerMockedHttpURLLoad(thirdURL); | 4127 registerMockedHttpURLLoad(thirdURL); |
| 4121 | 4128 |
| 4122 ClearScrollStateOnCommitWebFrameClient client; | 4129 ClearScrollStateOnCommitWebFrameClient client; |
| 4123 FrameTestHelpers::WebViewHelper webViewHelper; | 4130 FrameTestHelpers::WebViewHelper webViewHelper; |
| 4124 webViewHelper.initializeAndLoad(m_baseURL + firstURL, true, &client); | 4131 webViewHelper.initializeAndLoad(m_baseURL + firstURL, true, &client); |
| 4125 webViewHelper.resize(WebSize(pageWidth, pageHeight)); | 4132 webViewHelper.resize(WebSize(pageWidth, pageHeight)); |
| 4126 webViewHelper.webView()->mainFrame()->setScrollOffset( | 4133 webViewHelper.webView()->mainFrame()->setScrollOffset( |
| 4127 WebSize(pageWidth / 4, pageHeight / 4)); | 4134 WebSize(pageWidth / 4, pageHeight / 4)); |
| 4128 webViewHelper.webView()->setPageScaleFactor(pageScaleFactor); | 4135 webViewHelper.webView()->setPageScaleFactor(pageScaleFactor); |
| 4136 client.setWebView(webViewHelper.webView()); |
| 4129 | 4137 |
| 4130 WebSize previousOffset = | 4138 WebSize previousOffset = |
| 4131 webViewHelper.webView()->mainFrame()->getScrollOffset(); | 4139 webViewHelper.webView()->mainFrame()->getScrollOffset(); |
| 4132 float previousScale = webViewHelper.webView()->pageScaleFactor(); | 4140 float previousScale = webViewHelper.webView()->pageScaleFactor(); |
| 4133 | 4141 |
| 4134 // Reload the page and end up at the same url. State should be propagated. | 4142 // Reload the page and end up at the same url. State should be propagated. |
| 4135 webViewHelper.webView()->mainFrame()->reloadWithOverrideURL( | 4143 webViewHelper.webView()->mainFrame()->reloadWithOverrideURL( |
| 4136 toKURL(m_baseURL + firstURL), WebFrameLoadType::ReloadMainResource); | 4144 toKURL(m_baseURL + firstURL), WebFrameLoadType::ReloadMainResource); |
| 4137 FrameTestHelpers::pumpPendingRequestsForFrameToLoad( | 4145 FrameTestHelpers::pumpPendingRequestsForFrameToLoad( |
| 4138 webViewHelper.webView()->mainFrame()); | 4146 webViewHelper.webView()->mainFrame()); |
| (...skipping 1981 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6120 TestSubstituteDataWebFrameClient() : m_commitCalled(false) {} | 6128 TestSubstituteDataWebFrameClient() : m_commitCalled(false) {} |
| 6121 | 6129 |
| 6122 virtual void didFailProvisionalLoad(WebLocalFrame* frame, | 6130 virtual void didFailProvisionalLoad(WebLocalFrame* frame, |
| 6123 const WebURLError& error, | 6131 const WebURLError& error, |
| 6124 WebHistoryCommitType) { | 6132 WebHistoryCommitType) { |
| 6125 frame->loadHTMLString("This should appear", | 6133 frame->loadHTMLString("This should appear", |
| 6126 toKURL("data:text/html,chromewebdata"), | 6134 toKURL("data:text/html,chromewebdata"), |
| 6127 error.unreachableURL, true); | 6135 error.unreachableURL, true); |
| 6128 } | 6136 } |
| 6129 | 6137 |
| 6130 virtual void didCommitProvisionalLoad(WebLocalFrame* frame, | 6138 virtual void didCommitProvisionalLoad(WebDataSource* dataSource, |
| 6139 WebFrameLoadType, |
| 6131 const WebHistoryItem&, | 6140 const WebHistoryItem&, |
| 6132 WebHistoryCommitType) { | 6141 WebHistoryCommitType) { |
| 6133 if (frame->dataSource()->response().url() != | 6142 if (dataSource->response().url() != |
| 6134 WebURL(URLTestHelpers::toKURL("about:blank"))) | 6143 WebURL(URLTestHelpers::toKURL("about:blank"))) |
| 6135 m_commitCalled = true; | 6144 m_commitCalled = true; |
| 6136 } | 6145 } |
| 6137 | 6146 |
| 6138 bool commitCalled() const { return m_commitCalled; } | 6147 bool commitCalled() const { return m_commitCalled; } |
| 6139 | 6148 |
| 6140 private: | 6149 private: |
| 6141 bool m_commitCalled; | 6150 bool m_commitCalled; |
| 6142 }; | 6151 }; |
| 6143 | 6152 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6175 webViewHelper.webView(), std::numeric_limits<size_t>::max()); | 6184 webViewHelper.webView(), std::numeric_limits<size_t>::max()); |
| 6176 EXPECT_EQ("This should appear", text.utf8()); | 6185 EXPECT_EQ("This should appear", text.utf8()); |
| 6177 EXPECT_TRUE(webFrameClient.commitCalled()); | 6186 EXPECT_TRUE(webFrameClient.commitCalled()); |
| 6178 } | 6187 } |
| 6179 | 6188 |
| 6180 class TestWillInsertBodyWebFrameClient | 6189 class TestWillInsertBodyWebFrameClient |
| 6181 : public FrameTestHelpers::TestWebFrameClient { | 6190 : public FrameTestHelpers::TestWebFrameClient { |
| 6182 public: | 6191 public: |
| 6183 TestWillInsertBodyWebFrameClient() : m_numBodies(0), m_didLoad(false) {} | 6192 TestWillInsertBodyWebFrameClient() : m_numBodies(0), m_didLoad(false) {} |
| 6184 | 6193 |
| 6185 void didCommitProvisionalLoad(WebLocalFrame*, | 6194 void didCommitProvisionalLoad(WebDataSource*, |
| 6195 WebFrameLoadType, |
| 6186 const WebHistoryItem&, | 6196 const WebHistoryItem&, |
| 6187 WebHistoryCommitType) override { | 6197 WebHistoryCommitType) override { |
| 6188 m_numBodies = 0; | 6198 m_numBodies = 0; |
| 6189 m_didLoad = true; | 6199 m_didLoad = true; |
| 6190 } | 6200 } |
| 6191 | 6201 |
| 6192 void didCreateDocumentElement(WebLocalFrame*) override { | 6202 void didCreateDocumentElement(WebLocalFrame*) override { |
| 6193 EXPECT_EQ(0, m_numBodies); | 6203 EXPECT_EQ(0, m_numBodies); |
| 6194 } | 6204 } |
| 6195 | 6205 |
| (...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6846 webViewHelper.initializeAndLoad(m_baseURL + "first_party_redirect.html", | 6856 webViewHelper.initializeAndLoad(m_baseURL + "first_party_redirect.html", |
| 6847 true); | 6857 true); |
| 6848 EXPECT_TRUE( | 6858 EXPECT_TRUE( |
| 6849 webViewHelper.webView()->mainFrame()->document().firstPartyForCookies() == | 6859 webViewHelper.webView()->mainFrame()->document().firstPartyForCookies() == |
| 6850 redirectURL); | 6860 redirectURL); |
| 6851 } | 6861 } |
| 6852 | 6862 |
| 6853 class TestNavigationPolicyWebFrameClient | 6863 class TestNavigationPolicyWebFrameClient |
| 6854 : public FrameTestHelpers::TestWebFrameClient { | 6864 : public FrameTestHelpers::TestWebFrameClient { |
| 6855 public: | 6865 public: |
| 6856 void didNavigateWithinPage(WebLocalFrame*, | 6866 void didNavigateWithinPage(WebDataSource*, |
| 6867 WebFrameLoadType, |
| 6857 const WebHistoryItem&, | 6868 const WebHistoryItem&, |
| 6858 WebHistoryCommitType, | 6869 WebHistoryCommitType, |
| 6859 bool) override { | 6870 bool) override { |
| 6860 EXPECT_TRUE(false); | 6871 EXPECT_TRUE(false); |
| 6861 } | 6872 } |
| 6862 }; | 6873 }; |
| 6863 | 6874 |
| 6864 TEST_P(ParameterizedWebFrameTest, SimulateFragmentAnchorMiddleClick) { | 6875 TEST_P(ParameterizedWebFrameTest, SimulateFragmentAnchorMiddleClick) { |
| 6865 registerMockedHttpURLLoad("fragment_middle_click.html"); | 6876 registerMockedHttpURLLoad("fragment_middle_click.html"); |
| 6866 TestNavigationPolicyWebFrameClient client; | 6877 TestNavigationPolicyWebFrameClient client; |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7013 // Pump requests one more time after the javascript URL has executed to | 7024 // Pump requests one more time after the javascript URL has executed to |
| 7014 // trigger the actual POST load request. | 7025 // trigger the actual POST load request. |
| 7015 FrameTestHelpers::pumpPendingRequestsForFrameToLoad( | 7026 FrameTestHelpers::pumpPendingRequestsForFrameToLoad( |
| 7016 webViewHelper.webView()->mainFrame()); | 7027 webViewHelper.webView()->mainFrame()); |
| 7017 EXPECT_EQ(WebString::fromUTF8("POST"), | 7028 EXPECT_EQ(WebString::fromUTF8("POST"), |
| 7018 frame->dataSource()->getRequest().httpMethod()); | 7029 frame->dataSource()->getRequest().httpMethod()); |
| 7019 | 7030 |
| 7020 FrameTestHelpers::reloadFrame(frame); | 7031 FrameTestHelpers::reloadFrame(frame); |
| 7021 EXPECT_EQ(WebCachePolicy::ValidatingCacheData, | 7032 EXPECT_EQ(WebCachePolicy::ValidatingCacheData, |
| 7022 frame->dataSource()->getRequest().getCachePolicy()); | 7033 frame->dataSource()->getRequest().getCachePolicy()); |
| 7023 EXPECT_EQ(WebNavigationTypeFormResubmitted, | |
| 7024 frame->dataSource()->navigationType()); | |
| 7025 } | 7034 } |
| 7026 | 7035 |
| 7027 TEST_P(ParameterizedWebFrameTest, LoadHistoryItemReload) { | 7036 TEST_P(ParameterizedWebFrameTest, LoadHistoryItemReload) { |
| 7028 registerMockedHttpURLLoad("fragment_middle_click.html"); | 7037 registerMockedHttpURLLoad("fragment_middle_click.html"); |
| 7029 FrameTestHelpers::WebViewHelper webViewHelper; | 7038 FrameTestHelpers::WebViewHelper webViewHelper; |
| 7030 webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", | 7039 webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", |
| 7031 true); | 7040 true); |
| 7032 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 7041 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
| 7033 const FrameLoader& mainFrameLoader = | 7042 const FrameLoader& mainFrameLoader = |
| 7034 webViewHelper.webView()->mainFrameImpl()->frame()->loader(); | 7043 webViewHelper.webView()->mainFrameImpl()->frame()->loader(); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7090 } | 7099 } |
| 7091 | 7100 |
| 7092 virtual void didStopLoading() { | 7101 virtual void didStopLoading() { |
| 7093 if (m_parentClient) { | 7102 if (m_parentClient) { |
| 7094 m_parentClient->didStopLoading(); | 7103 m_parentClient->didStopLoading(); |
| 7095 return; | 7104 return; |
| 7096 } | 7105 } |
| 7097 TestWebFrameClient::didStopLoading(); | 7106 TestWebFrameClient::didStopLoading(); |
| 7098 } | 7107 } |
| 7099 | 7108 |
| 7100 void willSendRequest(WebLocalFrame*, WebURLRequest& request) override { | 7109 void willSendRequest(WebLocalFrame*, |
| 7110 WebURLRequest& request, |
| 7111 WebFrameLoadType) override { |
| 7101 m_policy = request.getCachePolicy(); | 7112 m_policy = request.getCachePolicy(); |
| 7102 m_willSendRequestCallCount++; | 7113 m_willSendRequestCallCount++; |
| 7103 } | 7114 } |
| 7104 | 7115 |
| 7105 private: | 7116 private: |
| 7106 TestCachePolicyWebFrameClient* m_parentClient; | 7117 TestCachePolicyWebFrameClient* m_parentClient; |
| 7107 | 7118 |
| 7108 WebCachePolicy m_policy; | 7119 WebCachePolicy m_policy; |
| 7109 TestCachePolicyWebFrameClient* m_childClient; | 7120 TestCachePolicyWebFrameClient* m_childClient; |
| 7110 int m_willSendRequestCallCount; | 7121 int m_willSendRequestCallCount; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7147 EXPECT_EQ(childClient.getCachePolicy(), | 7158 EXPECT_EQ(childClient.getCachePolicy(), |
| 7148 WebCachePolicy::UseProtocolCachePolicy); | 7159 WebCachePolicy::UseProtocolCachePolicy); |
| 7149 } | 7160 } |
| 7150 | 7161 |
| 7151 class TestSameDocumentWebFrameClient | 7162 class TestSameDocumentWebFrameClient |
| 7152 : public FrameTestHelpers::TestWebFrameClient { | 7163 : public FrameTestHelpers::TestWebFrameClient { |
| 7153 public: | 7164 public: |
| 7154 TestSameDocumentWebFrameClient() | 7165 TestSameDocumentWebFrameClient() |
| 7155 : m_frameLoadTypeReloadMainResourceSeen(false) {} | 7166 : m_frameLoadTypeReloadMainResourceSeen(false) {} |
| 7156 | 7167 |
| 7157 virtual void willSendRequest(WebLocalFrame* frame, WebURLRequest&) { | 7168 virtual void willSendRequest(WebLocalFrame* frame, |
| 7169 WebURLRequest&, |
| 7170 WebFrameLoadType) { |
| 7158 FrameLoader& frameLoader = toWebLocalFrameImpl(frame)->frame()->loader(); | 7171 FrameLoader& frameLoader = toWebLocalFrameImpl(frame)->frame()->loader(); |
| 7159 if (frameLoader.provisionalDocumentLoader()->loadType() == | 7172 if (frameLoader.provisionalDocumentLoader()->loadType() == |
| 7160 FrameLoadTypeReloadMainResource) | 7173 FrameLoadTypeReloadMainResource) |
| 7161 m_frameLoadTypeReloadMainResourceSeen = true; | 7174 m_frameLoadTypeReloadMainResourceSeen = true; |
| 7162 } | 7175 } |
| 7163 | 7176 |
| 7164 bool frameLoadTypeReloadMainResourceSeen() const { | 7177 bool frameLoadTypeReloadMainResourceSeen() const { |
| 7165 return m_frameLoadTypeReloadMainResourceSeen; | 7178 return m_frameLoadTypeReloadMainResourceSeen; |
| 7166 } | 7179 } |
| 7167 | 7180 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 7189 webViewHelper.webView()->mainFrame()); | 7202 webViewHelper.webView()->mainFrame()); |
| 7190 | 7203 |
| 7191 EXPECT_TRUE(client.frameLoadTypeReloadMainResourceSeen()); | 7204 EXPECT_TRUE(client.frameLoadTypeReloadMainResourceSeen()); |
| 7192 } | 7205 } |
| 7193 | 7206 |
| 7194 class TestSameDocumentWithImageWebFrameClient | 7207 class TestSameDocumentWithImageWebFrameClient |
| 7195 : public FrameTestHelpers::TestWebFrameClient { | 7208 : public FrameTestHelpers::TestWebFrameClient { |
| 7196 public: | 7209 public: |
| 7197 TestSameDocumentWithImageWebFrameClient() : m_numOfImageRequests(0) {} | 7210 TestSameDocumentWithImageWebFrameClient() : m_numOfImageRequests(0) {} |
| 7198 | 7211 |
| 7199 virtual void willSendRequest(WebLocalFrame*, WebURLRequest& request) { | 7212 virtual void willSendRequest(WebLocalFrame*, |
| 7213 WebURLRequest& request, |
| 7214 WebFrameLoadType) { |
| 7200 if (request.getRequestContext() == WebURLRequest::RequestContextImage) { | 7215 if (request.getRequestContext() == WebURLRequest::RequestContextImage) { |
| 7201 m_numOfImageRequests++; | 7216 m_numOfImageRequests++; |
| 7202 EXPECT_EQ(WebCachePolicy::UseProtocolCachePolicy, | 7217 EXPECT_EQ(WebCachePolicy::UseProtocolCachePolicy, |
| 7203 request.getCachePolicy()); | 7218 request.getCachePolicy()); |
| 7204 } | 7219 } |
| 7205 } | 7220 } |
| 7206 | 7221 |
| 7207 int numOfImageRequests() const { return m_numOfImageRequests; } | 7222 int numOfImageRequests() const { return m_numOfImageRequests; } |
| 7208 | 7223 |
| 7209 private: | 7224 private: |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7300 EXPECT_EQ(client.stopLoadingCount(), 2); | 7315 EXPECT_EQ(client.stopLoadingCount(), 2); |
| 7301 EXPECT_EQ(client.differentDocumentStartCount(), 1); | 7316 EXPECT_EQ(client.differentDocumentStartCount(), 1); |
| 7302 } | 7317 } |
| 7303 | 7318 |
| 7304 class TestDidNavigateCommitTypeWebFrameClient | 7319 class TestDidNavigateCommitTypeWebFrameClient |
| 7305 : public FrameTestHelpers::TestWebFrameClient { | 7320 : public FrameTestHelpers::TestWebFrameClient { |
| 7306 public: | 7321 public: |
| 7307 TestDidNavigateCommitTypeWebFrameClient() | 7322 TestDidNavigateCommitTypeWebFrameClient() |
| 7308 : m_lastCommitType(WebHistoryInertCommit) {} | 7323 : m_lastCommitType(WebHistoryInertCommit) {} |
| 7309 | 7324 |
| 7310 void didNavigateWithinPage(WebLocalFrame*, | 7325 void didNavigateWithinPage(WebDataSource*, |
| 7326 WebFrameLoadType, |
| 7311 const WebHistoryItem&, | 7327 const WebHistoryItem&, |
| 7312 WebHistoryCommitType type, | 7328 WebHistoryCommitType type, |
| 7313 bool) override { | 7329 bool) override { |
| 7314 m_lastCommitType = type; | 7330 m_lastCommitType = type; |
| 7315 } | 7331 } |
| 7316 | 7332 |
| 7317 WebHistoryCommitType lastCommitType() const { return m_lastCommitType; } | 7333 WebHistoryCommitType lastCommitType() const { return m_lastCommitType; } |
| 7318 | 7334 |
| 7319 private: | 7335 private: |
| 7320 WebHistoryCommitType m_lastCommitType; | 7336 WebHistoryCommitType m_lastCommitType; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 7337 nullptr, FrameLoader::resourceRequestFromHistoryItem( | 7353 nullptr, FrameLoader::resourceRequestFromHistoryItem( |
| 7338 item.get(), WebCachePolicy::UseProtocolCachePolicy)), | 7354 item.get(), WebCachePolicy::UseProtocolCachePolicy)), |
| 7339 FrameLoadTypeBackForward, item.get(), HistorySameDocumentLoad); | 7355 FrameLoadTypeBackForward, item.get(), HistorySameDocumentLoad); |
| 7340 EXPECT_EQ(WebBackForwardCommit, client.lastCommitType()); | 7356 EXPECT_EQ(WebBackForwardCommit, client.lastCommitType()); |
| 7341 } | 7357 } |
| 7342 | 7358 |
| 7343 class TestHistoryWebFrameClient : public FrameTestHelpers::TestWebFrameClient { | 7359 class TestHistoryWebFrameClient : public FrameTestHelpers::TestWebFrameClient { |
| 7344 public: | 7360 public: |
| 7345 TestHistoryWebFrameClient() { | 7361 TestHistoryWebFrameClient() { |
| 7346 m_replacesCurrentHistoryItem = false; | 7362 m_replacesCurrentHistoryItem = false; |
| 7347 m_frame = nullptr; | |
| 7348 } | 7363 } |
| 7349 | 7364 |
| 7350 void didStartProvisionalLoad(WebLocalFrame* frame) { | 7365 void didStartProvisionalLoad(WebDataSource*, WebFrameLoadType loadType) { |
| 7351 WebDataSource* ds = frame->provisionalDataSource(); | 7366 m_replacesCurrentHistoryItem = |
| 7352 m_replacesCurrentHistoryItem = ds->replacesCurrentHistoryItem(); | 7367 loadType == WebFrameLoadType::ReplaceCurrentItem; |
| 7353 m_frame = frame; | |
| 7354 } | 7368 } |
| 7355 | 7369 |
| 7356 bool replacesCurrentHistoryItem() { return m_replacesCurrentHistoryItem; } | 7370 bool replacesCurrentHistoryItem() { return m_replacesCurrentHistoryItem; } |
| 7357 WebFrame* frame() { return m_frame; } | |
| 7358 | 7371 |
| 7359 private: | 7372 private: |
| 7360 bool m_replacesCurrentHistoryItem; | 7373 bool m_replacesCurrentHistoryItem; |
| 7361 WebFrame* m_frame; | |
| 7362 }; | 7374 }; |
| 7363 | 7375 |
| 7364 // Tests that the first navigation in an initially blank subframe will result in | 7376 // Tests that the first navigation in an initially blank subframe will result in |
| 7365 // a history entry being replaced and not a new one being added. | 7377 // a history entry being replaced and not a new one being added. |
| 7366 TEST_P(ParameterizedWebFrameTest, FirstBlankSubframeNavigation) { | 7378 TEST_P(ParameterizedWebFrameTest, FirstBlankSubframeNavigation) { |
| 7367 registerMockedHttpURLLoad("history.html"); | 7379 registerMockedHttpURLLoad("history.html"); |
| 7368 registerMockedHttpURLLoad("find.html"); | 7380 registerMockedHttpURLLoad("find.html"); |
| 7369 | 7381 |
| 7370 TestHistoryWebFrameClient client; | 7382 TestHistoryWebFrameClient client; |
| 7371 FrameTestHelpers::WebViewHelper webViewHelper; | 7383 FrameTestHelpers::WebViewHelper webViewHelper; |
| 7372 webViewHelper.initializeAndLoad("about:blank", true, &client); | 7384 webViewHelper.initializeAndLoad("about:blank", true, &client); |
| 7373 | 7385 |
| 7374 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 7386 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
| 7375 | 7387 |
| 7376 frame->executeScript(WebScriptSource(WebString::fromUTF8( | 7388 frame->executeScript(WebScriptSource(WebString::fromUTF8( |
| 7377 "document.body.appendChild(document.createElement('iframe'))"))); | 7389 "document.body.appendChild(document.createElement('iframe'))"))); |
| 7378 | 7390 |
| 7379 WebFrame* iframe = frame->firstChild(); | 7391 WebFrame* iframe = frame->firstChild(); |
| 7380 ASSERT_EQ(&client, toWebLocalFrameImpl(iframe)->client()); | 7392 ASSERT_EQ(&client, toWebLocalFrameImpl(iframe)->client()); |
| 7381 EXPECT_EQ(iframe, client.frame()); | |
| 7382 | 7393 |
| 7383 std::string url1 = m_baseURL + "history.html"; | 7394 std::string url1 = m_baseURL + "history.html"; |
| 7384 FrameTestHelpers::loadFrame(iframe, url1); | 7395 FrameTestHelpers::loadFrame(iframe, url1); |
| 7385 EXPECT_EQ(iframe, client.frame()); | |
| 7386 EXPECT_EQ(url1, iframe->document().url().string().utf8()); | 7396 EXPECT_EQ(url1, iframe->document().url().string().utf8()); |
| 7387 EXPECT_TRUE(client.replacesCurrentHistoryItem()); | 7397 EXPECT_TRUE(client.replacesCurrentHistoryItem()); |
| 7388 | 7398 |
| 7389 std::string url2 = m_baseURL + "find.html"; | 7399 std::string url2 = m_baseURL + "find.html"; |
| 7390 FrameTestHelpers::loadFrame(iframe, url2); | 7400 FrameTestHelpers::loadFrame(iframe, url2); |
| 7391 EXPECT_EQ(iframe, client.frame()); | |
| 7392 EXPECT_EQ(url2, iframe->document().url().string().utf8()); | 7401 EXPECT_EQ(url2, iframe->document().url().string().utf8()); |
| 7393 EXPECT_FALSE(client.replacesCurrentHistoryItem()); | 7402 EXPECT_FALSE(client.replacesCurrentHistoryItem()); |
| 7394 } | 7403 } |
| 7395 | 7404 |
| 7396 // Tests that a navigation in a frame with a non-blank initial URL will create | 7405 // Tests that a navigation in a frame with a non-blank initial URL will create |
| 7397 // a new history item, unlike the case above. | 7406 // a new history item, unlike the case above. |
| 7398 TEST_P(ParameterizedWebFrameTest, FirstNonBlankSubframeNavigation) { | 7407 TEST_P(ParameterizedWebFrameTest, FirstNonBlankSubframeNavigation) { |
| 7399 registerMockedHttpURLLoad("history.html"); | 7408 registerMockedHttpURLLoad("history.html"); |
| 7400 registerMockedHttpURLLoad("find.html"); | 7409 registerMockedHttpURLLoad("find.html"); |
| 7401 | 7410 |
| 7402 TestHistoryWebFrameClient client; | 7411 TestHistoryWebFrameClient client; |
| 7403 FrameTestHelpers::WebViewHelper webViewHelper; | 7412 FrameTestHelpers::WebViewHelper webViewHelper; |
| 7404 webViewHelper.initializeAndLoad("about:blank", true, &client); | 7413 webViewHelper.initializeAndLoad("about:blank", true, &client); |
| 7405 | 7414 |
| 7406 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 7415 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
| 7407 | 7416 |
| 7408 std::string url1 = m_baseURL + "history.html"; | 7417 std::string url1 = m_baseURL + "history.html"; |
| 7409 FrameTestHelpers::loadFrame( | 7418 FrameTestHelpers::loadFrame( |
| 7410 frame, | 7419 frame, |
| 7411 "javascript:var f = document.createElement('iframe'); " | 7420 "javascript:var f = document.createElement('iframe'); " |
| 7412 "f.src = '" + | 7421 "f.src = '" + |
| 7413 url1 + | 7422 url1 + |
| 7414 "';" | 7423 "';" |
| 7415 "document.body.appendChild(f)"); | 7424 "document.body.appendChild(f)"); |
| 7416 | 7425 |
| 7417 WebFrame* iframe = frame->firstChild(); | 7426 WebFrame* iframe = frame->firstChild(); |
| 7418 EXPECT_EQ(iframe, client.frame()); | |
| 7419 EXPECT_EQ(url1, iframe->document().url().string().utf8()); | 7427 EXPECT_EQ(url1, iframe->document().url().string().utf8()); |
| 7420 | 7428 |
| 7421 std::string url2 = m_baseURL + "find.html"; | 7429 std::string url2 = m_baseURL + "find.html"; |
| 7422 FrameTestHelpers::loadFrame(iframe, url2); | 7430 FrameTestHelpers::loadFrame(iframe, url2); |
| 7423 EXPECT_EQ(iframe, client.frame()); | |
| 7424 EXPECT_EQ(url2, iframe->document().url().string().utf8()); | 7431 EXPECT_EQ(url2, iframe->document().url().string().utf8()); |
| 7425 EXPECT_FALSE(client.replacesCurrentHistoryItem()); | 7432 EXPECT_FALSE(client.replacesCurrentHistoryItem()); |
| 7426 } | 7433 } |
| 7427 | 7434 |
| 7428 // Test verifies that layout will change a layer's scrollable attibutes | 7435 // Test verifies that layout will change a layer's scrollable attibutes |
| 7429 TEST_F(WebFrameTest, overflowHiddenRewrite) { | 7436 TEST_F(WebFrameTest, overflowHiddenRewrite) { |
| 7430 registerMockedHttpURLLoad("non-scrollable.html"); | 7437 registerMockedHttpURLLoad("non-scrollable.html"); |
| 7431 std::unique_ptr<FakeCompositingWebViewClient> fakeCompositingWebViewClient = | 7438 std::unique_ptr<FakeCompositingWebViewClient> fakeCompositingWebViewClient = |
| 7432 WTF::makeUnique<FakeCompositingWebViewClient>(); | 7439 WTF::makeUnique<FakeCompositingWebViewClient>(); |
| 7433 FrameTestHelpers::WebViewHelper webViewHelper; | 7440 FrameTestHelpers::WebViewHelper webViewHelper; |
| (...skipping 1526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8960 // Manually reset to break WebViewHelper's dependency on the stack allocated | 8967 // Manually reset to break WebViewHelper's dependency on the stack allocated |
| 8961 // clients. | 8968 // clients. |
| 8962 reset(); | 8969 reset(); |
| 8963 } | 8970 } |
| 8964 | 8971 |
| 8965 class RemoteToLocalSwapWebFrameClient | 8972 class RemoteToLocalSwapWebFrameClient |
| 8966 : public FrameTestHelpers::TestWebFrameClient { | 8973 : public FrameTestHelpers::TestWebFrameClient { |
| 8967 public: | 8974 public: |
| 8968 explicit RemoteToLocalSwapWebFrameClient(WebRemoteFrame* remoteFrame) | 8975 explicit RemoteToLocalSwapWebFrameClient(WebRemoteFrame* remoteFrame) |
| 8969 : m_historyCommitType(WebHistoryInertCommit), | 8976 : m_historyCommitType(WebHistoryInertCommit), |
| 8970 m_remoteFrame(remoteFrame) {} | 8977 m_remoteFrame(remoteFrame), |
| 8978 m_localFrame(nullptr) {} |
| 8971 | 8979 |
| 8972 void didCommitProvisionalLoad( | 8980 void didCommitProvisionalLoad( |
| 8973 WebLocalFrame* frame, | 8981 WebDataSource*, |
| 8982 WebFrameLoadType, |
| 8974 const WebHistoryItem&, | 8983 const WebHistoryItem&, |
| 8975 WebHistoryCommitType historyCommitType) override { | 8984 WebHistoryCommitType historyCommitType) override { |
| 8976 m_historyCommitType = historyCommitType; | 8985 m_historyCommitType = historyCommitType; |
| 8977 m_remoteFrame->swap(frame); | 8986 if (m_localFrame) |
| 8987 m_remoteFrame->swap(m_localFrame); |
| 8978 } | 8988 } |
| 8979 | 8989 |
| 8980 WebHistoryCommitType historyCommitType() const { return m_historyCommitType; } | 8990 WebHistoryCommitType historyCommitType() const { return m_historyCommitType; } |
| 8991 void setLocalFrame(WebLocalFrame* localFrame) { m_localFrame = localFrame; } |
| 8981 | 8992 |
| 8982 WebHistoryCommitType m_historyCommitType; | 8993 WebHistoryCommitType m_historyCommitType; |
| 8983 WebRemoteFrame* m_remoteFrame; | 8994 WebRemoteFrame* m_remoteFrame; |
| 8995 WebLocalFrame* m_localFrame; |
| 8984 }; | 8996 }; |
| 8985 | 8997 |
| 8986 // The commit type should be Initial if we are swapping a RemoteFrame to a | 8998 // The commit type should be Initial if we are swapping a RemoteFrame to a |
| 8987 // LocalFrame as it is first being created. This happens when another frame | 8999 // LocalFrame as it is first being created. This happens when another frame |
| 8988 // exists in the same process, such that we create the RemoteFrame before the | 9000 // exists in the same process, such that we create the RemoteFrame before the |
| 8989 // first navigation occurs. | 9001 // first navigation occurs. |
| 8990 TEST_F(WebFrameSwapTest, HistoryCommitTypeAfterNewRemoteToLocalSwap) { | 9002 TEST_F(WebFrameSwapTest, HistoryCommitTypeAfterNewRemoteToLocalSwap) { |
| 8991 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; | 9003 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; |
| 8992 WebRemoteFrame* remoteFrame = | 9004 WebRemoteFrame* remoteFrame = |
| 8993 WebRemoteFrame::create(WebTreeScopeType::Document, &remoteFrameClient); | 9005 WebRemoteFrame::create(WebTreeScopeType::Document, &remoteFrameClient); |
| 8994 WebFrame* targetFrame = mainFrame()->firstChild(); | 9006 WebFrame* targetFrame = mainFrame()->firstChild(); |
| 8995 ASSERT_TRUE(targetFrame); | 9007 ASSERT_TRUE(targetFrame); |
| 8996 targetFrame->swap(remoteFrame); | 9008 targetFrame->swap(remoteFrame); |
| 8997 ASSERT_TRUE(mainFrame()->firstChild()); | 9009 ASSERT_TRUE(mainFrame()->firstChild()); |
| 8998 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame); | 9010 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame); |
| 8999 | 9011 |
| 9000 RemoteToLocalSwapWebFrameClient client(remoteFrame); | 9012 RemoteToLocalSwapWebFrameClient client(remoteFrame); |
| 9001 WebLocalFrame* localFrame = WebLocalFrame::createProvisional( | 9013 WebLocalFrame* localFrame = WebLocalFrame::createProvisional( |
| 9002 &client, nullptr, nullptr, remoteFrame, WebSandboxFlags::None); | 9014 &client, nullptr, nullptr, remoteFrame, WebSandboxFlags::None); |
| 9015 client.setLocalFrame(localFrame); |
| 9003 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); | 9016 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); |
| 9004 EXPECT_EQ(WebInitialCommitInChildFrame, client.historyCommitType()); | 9017 EXPECT_EQ(WebInitialCommitInChildFrame, client.historyCommitType()); |
| 9005 | 9018 |
| 9006 // Manually reset to break WebViewHelper's dependency on the stack allocated | 9019 // Manually reset to break WebViewHelper's dependency on the stack allocated |
| 9007 // TestWebFrameClient. | 9020 // TestWebFrameClient. |
| 9008 reset(); | 9021 reset(); |
| 9009 remoteFrame->close(); | 9022 remoteFrame->close(); |
| 9010 } | 9023 } |
| 9011 | 9024 |
| 9012 // The commit type should be Standard if we are swapping a RemoteFrame to a | 9025 // The commit type should be Standard if we are swapping a RemoteFrame to a |
| 9013 // LocalFrame after commits have already happened in the frame. The browser | 9026 // LocalFrame after commits have already happened in the frame. The browser |
| 9014 // process will inform us via setCommittedFirstRealLoad. | 9027 // process will inform us via setCommittedFirstRealLoad. |
| 9015 TEST_F(WebFrameSwapTest, HistoryCommitTypeAfterExistingRemoteToLocalSwap) { | 9028 TEST_F(WebFrameSwapTest, HistoryCommitTypeAfterExistingRemoteToLocalSwap) { |
| 9016 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; | 9029 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; |
| 9017 WebRemoteFrame* remoteFrame = | 9030 WebRemoteFrame* remoteFrame = |
| 9018 WebRemoteFrame::create(WebTreeScopeType::Document, &remoteFrameClient); | 9031 WebRemoteFrame::create(WebTreeScopeType::Document, &remoteFrameClient); |
| 9019 WebFrame* targetFrame = mainFrame()->firstChild(); | 9032 WebFrame* targetFrame = mainFrame()->firstChild(); |
| 9020 ASSERT_TRUE(targetFrame); | 9033 ASSERT_TRUE(targetFrame); |
| 9021 targetFrame->swap(remoteFrame); | 9034 targetFrame->swap(remoteFrame); |
| 9022 ASSERT_TRUE(mainFrame()->firstChild()); | 9035 ASSERT_TRUE(mainFrame()->firstChild()); |
| 9023 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame); | 9036 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame); |
| 9024 | 9037 |
| 9025 RemoteToLocalSwapWebFrameClient client(remoteFrame); | 9038 RemoteToLocalSwapWebFrameClient client(remoteFrame); |
| 9026 WebLocalFrame* localFrame = WebLocalFrame::createProvisional( | 9039 WebLocalFrame* localFrame = WebLocalFrame::createProvisional( |
| 9027 &client, nullptr, nullptr, remoteFrame, WebSandboxFlags::None); | 9040 &client, nullptr, nullptr, remoteFrame, WebSandboxFlags::None); |
| 9041 client.setLocalFrame(localFrame); |
| 9028 localFrame->setCommittedFirstRealLoad(); | 9042 localFrame->setCommittedFirstRealLoad(); |
| 9029 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); | 9043 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); |
| 9030 EXPECT_EQ(WebStandardCommit, client.historyCommitType()); | 9044 EXPECT_EQ(WebStandardCommit, client.historyCommitType()); |
| 9031 | 9045 |
| 9032 // Manually reset to break WebViewHelper's dependency on the stack allocated | 9046 // Manually reset to break WebViewHelper's dependency on the stack allocated |
| 9033 // TestWebFrameClient. | 9047 // TestWebFrameClient. |
| 9034 reset(); | 9048 reset(); |
| 9035 remoteFrame->close(); | 9049 remoteFrame->close(); |
| 9036 } | 9050 } |
| 9037 | 9051 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 9051 targetFrame->swap(remoteFrame); | 9065 targetFrame->swap(remoteFrame); |
| 9052 ASSERT_TRUE(mainFrame()->firstChild()); | 9066 ASSERT_TRUE(mainFrame()->firstChild()); |
| 9053 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame); | 9067 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame); |
| 9054 EXPECT_EQ(uniqueName.utf8(), | 9068 EXPECT_EQ(uniqueName.utf8(), |
| 9055 WebString(remoteFrame->frame()->tree().uniqueName()).utf8()); | 9069 WebString(remoteFrame->frame()->tree().uniqueName()).utf8()); |
| 9056 | 9070 |
| 9057 // Swap back to a LocalFrame. | 9071 // Swap back to a LocalFrame. |
| 9058 RemoteToLocalSwapWebFrameClient client(remoteFrame); | 9072 RemoteToLocalSwapWebFrameClient client(remoteFrame); |
| 9059 WebLocalFrame* localFrame = WebLocalFrame::createProvisional( | 9073 WebLocalFrame* localFrame = WebLocalFrame::createProvisional( |
| 9060 &client, nullptr, nullptr, remoteFrame, WebSandboxFlags::None); | 9074 &client, nullptr, nullptr, remoteFrame, WebSandboxFlags::None); |
| 9075 client.setLocalFrame(localFrame); |
| 9061 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); | 9076 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); |
| 9062 EXPECT_EQ(uniqueName.utf8(), localFrame->uniqueName().utf8()); | 9077 EXPECT_EQ(uniqueName.utf8(), localFrame->uniqueName().utf8()); |
| 9063 EXPECT_EQ(uniqueName.utf8(), WebString(toWebLocalFrameImpl(localFrame) | 9078 EXPECT_EQ(uniqueName.utf8(), WebString(toWebLocalFrameImpl(localFrame) |
| 9064 ->frame() | 9079 ->frame() |
| 9065 ->loader() | 9080 ->loader() |
| 9066 .currentItem() | 9081 .currentItem() |
| 9067 ->target()) | 9082 ->target()) |
| 9068 .utf8()); | 9083 .utf8()); |
| 9069 | 9084 |
| 9070 // Repeat with no name on the frame. | 9085 // Repeat with no name on the frame. |
| 9071 // (note that uniqueName is immutable after first real commit). | 9086 // (note that uniqueName is immutable after first real commit). |
| 9072 localFrame->setName(""); | 9087 localFrame->setName(""); |
| 9073 WebString uniqueName2 = localFrame->uniqueName(); | 9088 WebString uniqueName2 = localFrame->uniqueName(); |
| 9074 EXPECT_EQ("frame1", uniqueName2.utf8()); | 9089 EXPECT_EQ("frame1", uniqueName2.utf8()); |
| 9075 | 9090 |
| 9076 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient2; | 9091 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient2; |
| 9077 WebRemoteFrameImpl* remoteFrame2 = WebRemoteFrameImpl::create( | 9092 WebRemoteFrameImpl* remoteFrame2 = WebRemoteFrameImpl::create( |
| 9078 WebTreeScopeType::Document, &remoteFrameClient2); | 9093 WebTreeScopeType::Document, &remoteFrameClient2); |
| 9079 localFrame->swap(remoteFrame2); | 9094 localFrame->swap(remoteFrame2); |
| 9080 ASSERT_TRUE(mainFrame()->firstChild()); | 9095 ASSERT_TRUE(mainFrame()->firstChild()); |
| 9081 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame2); | 9096 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame2); |
| 9082 EXPECT_EQ(uniqueName2.utf8(), | 9097 EXPECT_EQ(uniqueName2.utf8(), |
| 9083 WebString(remoteFrame2->frame()->tree().uniqueName()).utf8()); | 9098 WebString(remoteFrame2->frame()->tree().uniqueName()).utf8()); |
| 9084 | 9099 |
| 9085 RemoteToLocalSwapWebFrameClient client2(remoteFrame2); | 9100 RemoteToLocalSwapWebFrameClient client2(remoteFrame2); |
| 9086 WebLocalFrame* localFrame2 = WebLocalFrame::createProvisional( | 9101 WebLocalFrame* localFrame2 = WebLocalFrame::createProvisional( |
| 9087 &client2, nullptr, nullptr, remoteFrame2, WebSandboxFlags::None); | 9102 &client2, nullptr, nullptr, remoteFrame2, WebSandboxFlags::None); |
| 9103 client.setLocalFrame(localFrame); |
| 9088 FrameTestHelpers::loadFrame(localFrame2, m_baseURL + "subframe-hello.html"); | 9104 FrameTestHelpers::loadFrame(localFrame2, m_baseURL + "subframe-hello.html"); |
| 9089 EXPECT_EQ(uniqueName2.utf8(), localFrame2->uniqueName().utf8()); | 9105 EXPECT_EQ(uniqueName2.utf8(), localFrame2->uniqueName().utf8()); |
| 9090 EXPECT_EQ(uniqueName2.utf8(), WebString(toWebLocalFrameImpl(localFrame2) | 9106 EXPECT_EQ(uniqueName2.utf8(), WebString(toWebLocalFrameImpl(localFrame2) |
| 9091 ->frame() | 9107 ->frame() |
| 9092 ->loader() | 9108 ->loader() |
| 9093 .currentItem() | 9109 .currentItem() |
| 9094 ->target()) | 9110 ->target()) |
| 9095 .utf8()); | 9111 .utf8()); |
| 9096 | 9112 |
| 9097 // Manually reset to break WebViewHelper's dependency on the stack allocated | 9113 // Manually reset to break WebViewHelper's dependency on the stack allocated |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9262 | 9278 |
| 9263 view->close(); | 9279 view->close(); |
| 9264 } | 9280 } |
| 9265 | 9281 |
| 9266 class CommitTypeWebFrameClient : public FrameTestHelpers::TestWebFrameClient { | 9282 class CommitTypeWebFrameClient : public FrameTestHelpers::TestWebFrameClient { |
| 9267 public: | 9283 public: |
| 9268 explicit CommitTypeWebFrameClient() | 9284 explicit CommitTypeWebFrameClient() |
| 9269 : m_historyCommitType(WebHistoryInertCommit) {} | 9285 : m_historyCommitType(WebHistoryInertCommit) {} |
| 9270 | 9286 |
| 9271 void didCommitProvisionalLoad( | 9287 void didCommitProvisionalLoad( |
| 9272 WebLocalFrame*, | 9288 WebDataSource*, |
| 9289 WebFrameLoadType, |
| 9273 const WebHistoryItem&, | 9290 const WebHistoryItem&, |
| 9274 WebHistoryCommitType historyCommitType) override { | 9291 WebHistoryCommitType historyCommitType) override { |
| 9275 m_historyCommitType = historyCommitType; | 9292 m_historyCommitType = historyCommitType; |
| 9276 } | 9293 } |
| 9277 | 9294 |
| 9278 WebHistoryCommitType historyCommitType() const { return m_historyCommitType; } | 9295 WebHistoryCommitType historyCommitType() const { return m_historyCommitType; } |
| 9279 | 9296 |
| 9280 private: | 9297 private: |
| 9281 WebHistoryCommitType m_historyCommitType; | 9298 WebHistoryCommitType m_historyCommitType; |
| 9282 }; | 9299 }; |
| (...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10072 | 10089 |
| 10073 class CallbackOrderingWebFrameClient | 10090 class CallbackOrderingWebFrameClient |
| 10074 : public FrameTestHelpers::TestWebFrameClient { | 10091 : public FrameTestHelpers::TestWebFrameClient { |
| 10075 public: | 10092 public: |
| 10076 CallbackOrderingWebFrameClient() : m_callbackCount(0) {} | 10093 CallbackOrderingWebFrameClient() : m_callbackCount(0) {} |
| 10077 | 10094 |
| 10078 void didStartLoading(bool toDifferentDocument) override { | 10095 void didStartLoading(bool toDifferentDocument) override { |
| 10079 EXPECT_EQ(0, m_callbackCount++); | 10096 EXPECT_EQ(0, m_callbackCount++); |
| 10080 FrameTestHelpers::TestWebFrameClient::didStartLoading(toDifferentDocument); | 10097 FrameTestHelpers::TestWebFrameClient::didStartLoading(toDifferentDocument); |
| 10081 } | 10098 } |
| 10082 void didStartProvisionalLoad(WebLocalFrame*) override { | 10099 void didStartProvisionalLoad(WebDataSource*, WebFrameLoadType) override { |
| 10083 EXPECT_EQ(1, m_callbackCount++); | 10100 EXPECT_EQ(1, m_callbackCount++); |
| 10084 } | 10101 } |
| 10085 void didCommitProvisionalLoad(WebLocalFrame*, | 10102 void didCommitProvisionalLoad(WebDataSource*, |
| 10103 WebFrameLoadType, |
| 10086 const WebHistoryItem&, | 10104 const WebHistoryItem&, |
| 10087 WebHistoryCommitType) override { | 10105 WebHistoryCommitType) override { |
| 10088 EXPECT_EQ(2, m_callbackCount++); | 10106 EXPECT_EQ(2, m_callbackCount++); |
| 10089 } | 10107 } |
| 10090 void didFinishDocumentLoad(WebLocalFrame*) override { | 10108 void didFinishDocumentLoad(WebLocalFrame*) override { |
| 10091 EXPECT_EQ(3, m_callbackCount++); | 10109 EXPECT_EQ(3, m_callbackCount++); |
| 10092 } | 10110 } |
| 10093 void didHandleOnloadEvents(WebLocalFrame*) override { | 10111 void didHandleOnloadEvents(WebLocalFrame*) override { |
| 10094 EXPECT_EQ(4, m_callbackCount++); | 10112 EXPECT_EQ(4, m_callbackCount++); |
| 10095 } | 10113 } |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10461 ExpectedRequest(const KURL& url, WebURLRequest::Priority priority) | 10479 ExpectedRequest(const KURL& url, WebURLRequest::Priority priority) |
| 10462 : url(url), priority(priority), seen(false) {} | 10480 : url(url), priority(priority), seen(false) {} |
| 10463 | 10481 |
| 10464 KURL url; | 10482 KURL url; |
| 10465 WebURLRequest::Priority priority; | 10483 WebURLRequest::Priority priority; |
| 10466 bool seen; | 10484 bool seen; |
| 10467 }; | 10485 }; |
| 10468 | 10486 |
| 10469 TestResourcePriorityWebFrameClient() {} | 10487 TestResourcePriorityWebFrameClient() {} |
| 10470 | 10488 |
| 10471 void willSendRequest(WebLocalFrame*, WebURLRequest& request) override { | 10489 void willSendRequest(WebLocalFrame*, |
| 10490 WebURLRequest& request, |
| 10491 WebFrameLoadType) override { |
| 10472 ExpectedRequest* expectedRequest = m_expectedRequests.get(request.url()); | 10492 ExpectedRequest* expectedRequest = m_expectedRequests.get(request.url()); |
| 10473 DCHECK(expectedRequest); | 10493 DCHECK(expectedRequest); |
| 10474 EXPECT_EQ(expectedRequest->priority, request.getPriority()); | 10494 EXPECT_EQ(expectedRequest->priority, request.getPriority()); |
| 10475 expectedRequest->seen = true; | 10495 expectedRequest->seen = true; |
| 10476 } | 10496 } |
| 10477 | 10497 |
| 10478 void addExpectedRequest(const KURL& url, WebURLRequest::Priority priority) { | 10498 void addExpectedRequest(const KURL& url, WebURLRequest::Priority priority) { |
| 10479 m_expectedRequests.add(url, | 10499 m_expectedRequests.add(url, |
| 10480 WTF::makeUnique<ExpectedRequest>(url, priority)); | 10500 WTF::makeUnique<ExpectedRequest>(url, priority)); |
| 10481 } | 10501 } |
| (...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11235 | 11255 |
| 11236 EXPECT_TRUE(mainFrameClient.childClient().didCallFrameDetached()); | 11256 EXPECT_TRUE(mainFrameClient.childClient().didCallFrameDetached()); |
| 11237 EXPECT_TRUE(mainFrameClient.childClient().didCallDidStopLoading()); | 11257 EXPECT_TRUE(mainFrameClient.childClient().didCallDidStopLoading()); |
| 11238 EXPECT_TRUE(mainFrameClient.childClient().didCallDidFinishDocumentLoad()); | 11258 EXPECT_TRUE(mainFrameClient.childClient().didCallDidFinishDocumentLoad()); |
| 11239 EXPECT_TRUE(mainFrameClient.childClient().didCallDidHandleOnloadEvents()); | 11259 EXPECT_TRUE(mainFrameClient.childClient().didCallDidHandleOnloadEvents()); |
| 11240 | 11260 |
| 11241 webViewHelper.reset(); | 11261 webViewHelper.reset(); |
| 11242 } | 11262 } |
| 11243 | 11263 |
| 11244 } // namespace blink | 11264 } // namespace blink |
| OLD | NEW |