diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-25 00:25:01 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-25 00:25:01 +0000 |
commit | 546ddd17b101f5a18e4cd55485378de9f6eea1c3 (patch) | |
tree | d3002707dbc78c9234a1b6a6725f60f727640a76 /chrome/renderer/render_view_unittest.cc | |
parent | bc9c4ca354c8ffe411b35f4430479dca0fe6cf67 (diff) | |
download | chromium_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/render_view_unittest.cc')
-rw-r--r-- | chrome/renderer/render_view_unittest.cc | 35 |
1 files changed, 35 insertions, 0 deletions
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()); +} |