summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorcreis@chromium.org <creis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-28 20:19:50 +0000
committercreis@chromium.org <creis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-28 20:19:50 +0000
commitd2bfb9a347378e06cf0b750bbabc3b6606bb83db (patch)
tree7a5c9f46305523736c670e3ea81197efb5a94bd5 /chrome
parentc2ce0b613efa992b5dd68d39395ac1ed9da0ea3f (diff)
downloadchromium_src-d2bfb9a347378e06cf0b750bbabc3b6606bb83db.zip
chromium_src-d2bfb9a347378e06cf0b750bbabc3b6606bb83db.tar.gz
chromium_src-d2bfb9a347378e06cf0b750bbabc3b6606bb83db.tar.bz2
Fixes a DCHECK when visiting chrome://theme.
This URL sets off an error case that calls RDH::OnReadCompleted without calling RDH::Read. ResourceDispatcherHost then tries to read from a failed request. We can avoid this by ensuring has_started_reading is true when OnReadCompleted is called (whether Read is called or not). BUG=40250 TEST=ResourceDispatcherHostUITest.CrossSiteFailedRequest Review URL: http://codereview.chromium.org/2860030 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@51037 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/renderer_host/resource_dispatcher_host.cc5
-rw-r--r--chrome/browser/renderer_host/resource_dispatcher_host_uitest.cc23
2 files changed, 28 insertions, 0 deletions
diff --git a/chrome/browser/renderer_host/resource_dispatcher_host.cc b/chrome/browser/renderer_host/resource_dispatcher_host.cc
index 4b3421e..24d493f 100644
--- a/chrome/browser/renderer_host/resource_dispatcher_host.cc
+++ b/chrome/browser/renderer_host/resource_dispatcher_host.cc
@@ -1298,6 +1298,11 @@ void ResourceDispatcherHost::OnReadCompleted(URLRequest* request,
DCHECK(request);
RESOURCE_LOG("OnReadCompleted: " << request->url().spec());
ResourceDispatcherHostRequestInfo* info = InfoForRequest(request);
+
+ // OnReadCompleted can be called without Read (e.g., for chrome:// URLs).
+ // Make sure we know that a read has begun.
+ info->set_has_started_reading(true);
+
if (PauseRequestIfNeeded(info)) {
info->set_paused_read_bytes(bytes_read);
RESOURCE_LOG("OnReadCompleted pausing: " << request->url().spec());
diff --git a/chrome/browser/renderer_host/resource_dispatcher_host_uitest.cc b/chrome/browser/renderer_host/resource_dispatcher_host_uitest.cc
index 5deea27..fa022db 100644
--- a/chrome/browser/renderer_host/resource_dispatcher_host_uitest.cc
+++ b/chrome/browser/renderer_host/resource_dispatcher_host_uitest.cc
@@ -317,4 +317,27 @@ TEST_F(ResourceDispatcherTest, CrossOriginRedirectBlocked) {
L"Title Of More Awesomeness", 2);
}
+// Tests that ResourceDispatcherHostRequestInfo is updated correctly on failed
+// requests, to prevent calling Read on a request that has already failed.
+// See bug 40250.
+TEST_F(ResourceDispatcherTest, CrossSiteFailedRequest) {
+ scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0));
+ ASSERT_TRUE(browser_proxy.get());
+ scoped_refptr<TabProxy> tab(browser_proxy->GetActiveTab());
+ ASSERT_TRUE(tab.get());
+
+ // Visit another URL first to trigger a cross-site navigation.
+ GURL url(chrome::kChromeUINewTabURL);
+ ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, tab->NavigateToURL(url));
+
+ // Visit a URL that fails without calling ResourceDispatcherHost::Read.
+ GURL broken_url("chrome://theme");
+ ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, tab->NavigateToURL(broken_url));
+
+ // Make sure the navigation finishes.
+ std::wstring tab_title;
+ EXPECT_TRUE(tab->GetTabTitle(&tab_title));
+ EXPECT_EQ(L"chrome://theme/ is not available", tab_title);
+}
+
} // namespace