Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5810)

Unified Diff: chrome/browser/crash_recovery_browsertest.cc

Issue 101203007: Override cache policy when changing a reload to a back/forward navigation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/renderer/render_view_impl.cc » ('j') | content/renderer/render_view_impl.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/crash_recovery_browsertest.cc
diff --git a/chrome/browser/crash_recovery_browsertest.cc b/chrome/browser/crash_recovery_browsertest.cc
index fcde2cb825f748de6fb31e2cb43ceecc3d4161cd..a8adcaf2bfb0413f6657fe3fa9852c60ab585fa0 100644
--- a/chrome/browser/crash_recovery_browsertest.cc
+++ b/chrome/browser/crash_recovery_browsertest.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "base/files/file_path.h"
+#include "base/strings/stringprintf.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
@@ -13,6 +14,9 @@
#include "content/public/browser/notification_types.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/page_transition_types.h"
+#include "net/test/embedded_test_server/embedded_test_server.h"
+#include "net/test/embedded_test_server/http_request.h"
+#include "net/test/embedded_test_server/http_response.h"
#include "testing/gtest/include/gtest/gtest.h"
using content::NavigationController;
@@ -31,6 +35,32 @@ void SimulateRendererCrash(Browser* browser) {
observer.Wait();
}
+// A request handler which is set to expire in the far future, but returns a
+// different result each time.
+class CacheExpiresHandler {
+ public:
+ explicit CacheExpiresHandler(const std::string& path)
+ : path_(path), request_count_(0) { }
+
+ scoped_ptr<net::test_server::HttpResponse> HandleRequest(
+ const net::test_server::HttpRequest& request) {
+ if (request.relative_url != path_)
+ return scoped_ptr<net::test_server::HttpResponse>();
+
+ request_count_++;
+ scoped_ptr<net::test_server::BasicHttpResponse> response(
+ new net::test_server::BasicHttpResponse);
+ response->set_content(base::StringPrintf("<title>%d</title>",
+ request_count_));
+ response->set_content_type("text/html");
+ response->AddCustomHeader("Expires", "Thu, 1 Jan 2099 00:00:00 GMT");
darin (slow to review) 2014/01/07 07:39:59 nit: another approach here would be to set a cache
davidben 2014/01/08 17:38:03 Ah yeah, that would be better. Done.
+ return response.PassAs<net::test_server::HttpResponse>();
+ }
+ private:
+ std::string path_;
+ int request_count_;
+};
+
} // namespace
class CrashRecoveryBrowserTest : public InProcessBrowserTest {
@@ -62,6 +92,37 @@ IN_PROC_BROWSER_TEST_F(CrashRecoveryBrowserTest, Reload) {
EXPECT_NE(title_before_crash, title_after_crash);
}
+// Test that reload after a crash forces a cache revalidation.
+IN_PROC_BROWSER_TEST_F(CrashRecoveryBrowserTest, ReloadCacheRevalidate) {
+ const char kTestPath[] = "/test";
+
+ // Use the test server so as not to bypass cache behavior. The title of the
+ // active tab should change only when this URL is reloaded.
+ ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
+ embedded_test_server()->RegisterRequestHandler(
+ base::Bind(&CacheExpiresHandler::HandleRequest,
+ base::Owned(new CacheExpiresHandler(kTestPath))));
+ ui_test_utils::NavigateToURL(browser(),
+ embedded_test_server()->GetURL(kTestPath));
+
+ base::string16 title_before_crash;
+ base::string16 title_after_crash;
+
+ ASSERT_TRUE(ui_test_utils::GetCurrentTabTitle(browser(),
+ &title_before_crash));
+ SimulateRendererCrash(browser());
+ content::WindowedNotificationObserver observer(
+ content::NOTIFICATION_LOAD_STOP,
+ content::Source<NavigationController>(
+ &browser()->tab_strip_model()->GetActiveWebContents()->
+ GetController()));
+ chrome::Reload(browser(), CURRENT_TAB);
+ observer.Wait();
+ ASSERT_TRUE(ui_test_utils::GetCurrentTabTitle(browser(),
+ &title_after_crash));
+ EXPECT_NE(title_before_crash, title_after_crash);
+}
+
// Tests that loading a crashed page in a new tab correctly updates the title.
// There was an earlier bug (1270510) in process-per-site in which the max page
// ID of the RenderProcessHost was stale, so the NavigationEntry in the new tab
« no previous file with comments | « no previous file | content/renderer/render_view_impl.cc » ('j') | content/renderer/render_view_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698