diff options
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/renderer/render_view.cc | 6 | ||||
-rw-r--r-- | chrome/renderer/render_view_unittest.cc | 35 |
2 files changed, 41 insertions, 0 deletions
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index 7168c6d..e2db735 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -1146,6 +1146,9 @@ void RenderView::DidFailProvisionalLoadWithError(WebView* webview, if (error.reason == net::ERR_ABORTED) return; + // Make sure we never show errors in view source mode. + frame->SetInViewSourceMode(false); + // If this is a failed back/forward/reload navigation, then we need to do a // 'replace' load. This is necessary to avoid messing up session history. // Otherwise, we do a normal load, which simulates a 'go' navigation as far @@ -1288,6 +1291,9 @@ void RenderView::DidFinishLoadForFrame(WebView* webview, WebFrame* frame) { void RenderView::DidFailLoadWithError(WebView* webview, const WebURLError& error, WebFrame* frame) { + // Currently this function is empty. When you implement something here and it + // will display any error messages in HTML, please make sure to call + // frame->SetInViewSourceMode(false) not to show them in view source mode. } void RenderView::DidFinishDocumentLoadForFrame(WebView* webview, diff --git a/chrome/renderer/render_view_unittest.cc b/chrome/renderer/render_view_unittest.cc index 95a468c..4ab5be0 100644 --- a/chrome/renderer/render_view_unittest.cc +++ b/chrome/renderer/render_view_unittest.cc @@ -6,7 +6,11 @@ #include "chrome/common/native_web_keyboard_event.h" #include "chrome/common/render_messages.h" #include "chrome/test/render_view_test.h" +#include "net/base/net_errors.h" #include "testing/gtest/include/gtest/gtest.h" +#include "webkit/api/public/WebURLError.h" + +using WebKit::WebURLError; TEST_F(RenderViewTest, OnLoadAlternateHTMLText) { // Test a new navigation. @@ -779,3 +783,34 @@ TEST_F(RenderViewTest, InsertCharacters) { NOTIMPLEMENTED(); #endif } + +#if 0 +// TODO(tyoshino): After fixing flakiness, enable this test. +TEST_F(RenderViewTest, DidFailProvisionalLoadWithErrorForError) { + GetMainFrame()->SetInViewSourceMode(true); + WebURLError error; + error.domain.fromUTF8("test_domain"); + error.reason = net::ERR_FILE_NOT_FOUND; + error.unreachableURL = GURL("http://foo"); + WebFrame* web_frame = GetMainFrame(); + WebView* web_view = web_frame->GetView(); + // An error occurred. + view_->DidFailProvisionalLoadWithError(web_view, error, web_frame); + // Frame should exit view-source mode. + EXPECT_FALSE(web_frame->GetInViewSourceMode()); +} +#endif + +TEST_F(RenderViewTest, DidFailProvisionalLoadWithErrorForCancellation) { + GetMainFrame()->SetInViewSourceMode(true); + WebURLError error; + error.domain.fromUTF8("test_domain"); + error.reason = net::ERR_ABORTED; + error.unreachableURL = GURL("http://foo"); + WebFrame* web_frame = GetMainFrame(); + WebView* web_view = web_frame->GetView(); + // A cancellation occurred. + view_->DidFailProvisionalLoadWithError(web_view, error, web_frame); + // Frame should stay in view-source mode. + EXPECT_TRUE(web_frame->GetInViewSourceMode()); +} |