summaryrefslogtreecommitdiffstats
path: root/chrome/renderer
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-25 00:25:01 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-25 00:25:01 +0000
commit546ddd17b101f5a18e4cd55485378de9f6eea1c3 (patch)
treed3002707dbc78c9234a1b6a6725f60f727640a76 /chrome/renderer
parentbc9c4ca354c8ffe411b35f4430479dca0fe6cf67 (diff)
downloadchromium_src-546ddd17b101f5a18e4cd55485378de9f6eea1c3.zip
chromium_src-546ddd17b101f5a18e4cd55485378de9f6eea1c3.tar.gz
chromium_src-546ddd17b101f5a18e4cd55485378de9f6eea1c3.tar.bz2
Don't disable view-source mode on cancellation. On error, we should turn off
view-source mode not to show error page in view-source mode. However, on cancellation, it's not necessary and sometimes render non-error page with view-source: prefix in non view-source mode by mistake. In fixing this, I pushed down SetInViewSourceMode to RenderView from WebFrameImpl. We can control view-source state more precisely by this way. Patch by tyoshino@google.com Original review: http://codereview.chromium.org/122026 BUG=4516 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19205 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r--chrome/renderer/render_view.cc6
-rw-r--r--chrome/renderer/render_view_unittest.cc35
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());
+}