diff options
author | rdsmith@chromium.org <rdsmith@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-26 19:35:31 +0000 |
---|---|---|
committer | rdsmith@chromium.org <rdsmith@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-26 19:35:31 +0000 |
commit | 4b4c7bfb46a9437c408caedd8ae0b4db0bf4a903 (patch) | |
tree | 9073d2575afabedba8942b130e13379f44ae0933 /chrome/renderer/net | |
parent | 9438c7d9e389ecf856b4ed4d51d4e97a4f5d6424 (diff) | |
download | chromium_src-4b4c7bfb46a9437c408caedd8ae0b4db0bf4a903.zip chromium_src-4b4c7bfb46a9437c408caedd8ae0b4db0bf4a903.tar.gz chromium_src-4b4c7bfb46a9437c408caedd8ae0b4db0bf4a903.tar.bz2 |
Added some POST protection to load stale cache functionality.
BUG=329620
R=mmenke@chromium.org
Review URL: https://codereview.chromium.org/210313003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@259662 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/net')
-rw-r--r-- | chrome/renderer/net/net_error_helper.cc | 2 | ||||
-rw-r--r-- | chrome/renderer/net/net_error_helper.h | 2 | ||||
-rw-r--r-- | chrome/renderer/net/net_error_helper_core.cc | 7 | ||||
-rw-r--r-- | chrome/renderer/net/net_error_helper_core.h | 2 | ||||
-rw-r--r-- | chrome/renderer/net/net_error_helper_core_unittest.cc | 17 |
5 files changed, 23 insertions, 7 deletions
diff --git a/chrome/renderer/net/net_error_helper.cc b/chrome/renderer/net/net_error_helper.cc index 21aa44f..1d9529a 100644 --- a/chrome/renderer/net/net_error_helper.cc +++ b/chrome/renderer/net/net_error_helper.cc @@ -179,7 +179,7 @@ void NetErrorHelper::LoadErrorPageInMainFrame(const std::string& html, frame->loadHTMLString(html, GURL(kUnreachableWebDataURL), failed_url, true); } -void NetErrorHelper::EnableErrorJSBindings(const GURL& page_url) { +void NetErrorHelper::EnableStaleLoadBindings(const GURL& page_url) { ErrorCacheLoad::Install(render_frame(), page_url); } diff --git a/chrome/renderer/net/net_error_helper.h b/chrome/renderer/net/net_error_helper.h index c745d90..5369e19 100644 --- a/chrome/renderer/net/net_error_helper.h +++ b/chrome/renderer/net/net_error_helper.h @@ -78,7 +78,7 @@ class NetErrorHelper std::string* html) const OVERRIDE; virtual void LoadErrorPageInMainFrame(const std::string& html, const GURL& failed_url) OVERRIDE; - virtual void EnableErrorJSBindings(const GURL& page_url) OVERRIDE; + virtual void EnableStaleLoadBindings(const GURL& page_url) OVERRIDE; virtual void UpdateErrorPage(const blink::WebURLError& error, bool is_failed_post) OVERRIDE; virtual void FetchNavigationCorrections( diff --git a/chrome/renderer/net/net_error_helper_core.cc b/chrome/renderer/net/net_error_helper_core.cc index 82b1059..d888a1a 100644 --- a/chrome/renderer/net/net_error_helper_core.cc +++ b/chrome/renderer/net/net_error_helper_core.cc @@ -384,8 +384,11 @@ void NetErrorHelperCore::OnFinishLoad(FrameType frame_type) { committed_error_page_info_->is_finished_loading = true; - delegate_->EnableErrorJSBindings( - committed_error_page_info_->error.unreachableURL); + // Only enable stale cache JS bindings if this wasn't a post. + if (!committed_error_page_info_->was_failed_post) { + delegate_->EnableStaleLoadBindings( + committed_error_page_info_->error.unreachableURL); + } if (committed_error_page_info_->navigation_correction_url.is_valid()) { // If there is another pending error page load, |fix_url| should have been diff --git a/chrome/renderer/net/net_error_helper_core.h b/chrome/renderer/net/net_error_helper_core.h index cbe0577..bd5297c 100644 --- a/chrome/renderer/net/net_error_helper_core.h +++ b/chrome/renderer/net/net_error_helper_core.h @@ -55,7 +55,7 @@ class NetErrorHelperCore { const GURL& failed_url) = 0; // Create extra Javascript bindings in the error page. - virtual void EnableErrorJSBindings(const GURL& page_url) = 0; + virtual void EnableStaleLoadBindings(const GURL& page_url) = 0; // Updates the currently displayed error page with a new error code. The // currently displayed error page must have finished loading, and must have diff --git a/chrome/renderer/net/net_error_helper_core_unittest.cc b/chrome/renderer/net/net_error_helper_core_unittest.cc index 31dc53e..f41da62 100644 --- a/chrome/renderer/net/net_error_helper_core_unittest.cc +++ b/chrome/renderer/net/net_error_helper_core_unittest.cc @@ -118,7 +118,8 @@ class NetErrorHelperCoreTest : public testing::Test, core_(this), update_count_(0), error_html_update_count_(0), - reload_count_(0) { + reload_count_(0), + enable_stale_load_bindings_count_(0) { core_.set_auto_reload_enabled(false); core_.set_timer_for_testing(scoped_ptr<base::Timer>(timer_)); } @@ -137,6 +138,10 @@ class NetErrorHelperCoreTest : public testing::Test, return reload_count_; } + int enable_stale_load_bindings_count() const { + return enable_stale_load_bindings_count_; + } + const std::string& last_update_string() const { return last_update_string_; } int update_count() const { return update_count_; } @@ -231,7 +236,9 @@ class NetErrorHelperCoreTest : public testing::Test, last_error_html_ = html; } - virtual void EnableErrorJSBindings(const GURL& page_url) OVERRIDE { } + virtual void EnableStaleLoadBindings(const GURL& page_url) OVERRIDE { + enable_stale_load_bindings_count_++; + } virtual void UpdateErrorPage(const WebURLError& error, bool is_failed_post) OVERRIDE { @@ -282,6 +289,8 @@ class NetErrorHelperCoreTest : public testing::Test, mutable scoped_ptr<LocalizedError::ErrorPageParams> last_error_page_params_; int reload_count_; + + int enable_stale_load_bindings_count_; }; //------------------------------------------------------------------------------ @@ -325,12 +334,14 @@ TEST_F(NetErrorHelperCoreTest, MainFrameNonDnsError) { EXPECT_EQ(NetErrorString(net::ERR_CONNECTION_RESET), html); // Error page loads. + EXPECT_EQ(0, enable_stale_load_bindings_count()); core().OnStartLoad(NetErrorHelperCore::MAIN_FRAME, NetErrorHelperCore::ERROR_PAGE); core().OnCommitLoad(NetErrorHelperCore::MAIN_FRAME); core().OnFinishLoad(NetErrorHelperCore::MAIN_FRAME); EXPECT_EQ(0, update_count()); EXPECT_EQ(0, error_html_update_count()); + EXPECT_EQ(1, enable_stale_load_bindings_count()); } TEST_F(NetErrorHelperCoreTest, MainFrameNonDnsErrorWithCorrections) { @@ -728,11 +739,13 @@ TEST_F(NetErrorHelperCoreTest, FinishedBeforeProbePost) { html); // Error page loads. + EXPECT_EQ(0, enable_stale_load_bindings_count()); core().OnStartLoad(NetErrorHelperCore::MAIN_FRAME, NetErrorHelperCore::ERROR_PAGE); core().OnCommitLoad(NetErrorHelperCore::MAIN_FRAME); core().OnFinishLoad(NetErrorHelperCore::MAIN_FRAME); EXPECT_EQ(0, update_count()); + EXPECT_EQ(0, enable_stale_load_bindings_count()); core().OnNetErrorInfo(chrome_common_net::DNS_PROBE_STARTED); EXPECT_EQ(1, update_count()); |