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

Unified Diff: content/browser/appcache/appcache_browsertest.cc

Issue 2991443002: The Appcache subresource URL factory needs to inform the URLLoaderClient if there is a failure. (Closed)
Patch Set: Disable the test for Android Created 3 years, 5 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/browser/appcache/appcache_subresource_url_factory.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/appcache/appcache_browsertest.cc
diff --git a/content/browser/appcache/appcache_browsertest.cc b/content/browser/appcache/appcache_browsertest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..2dc6cbb1bc2befd21100f4fc6a6fe8ed79539caf
--- /dev/null
+++ b/content/browser/appcache/appcache_browsertest.cc
@@ -0,0 +1,104 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <stdint.h>
+
+#include "base/command_line.h"
+#include "base/strings/utf_string_conversions.h"
+#include "content/browser/appcache/appcache_subresource_url_factory.h"
+#include "content/public/common/content_features.h"
+#include "content/public/common/content_switches.h"
+#include "content/public/test/browser_test_utils.h"
+#include "content/public/test/content_browser_test.h"
+#include "content/public/test/content_browser_test_utils.h"
+#include "content/public/test/test_navigation_observer.h"
+#include "content/public/test/test_utils.h"
+#include "content/shell/browser/shell.h"
+#include "net/dns/mock_host_resolver.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"
+namespace content {
+
+// This class currently enables the network service feature, which allows us to
+// test the AppCache code in that mode.
+class AppCacheNetworkServiceBrowserTest : public ContentBrowserTest {
+ public:
+ AppCacheNetworkServiceBrowserTest() {}
+
+ // Handler to count the number of requests.
+ std::unique_ptr<net::test_server::HttpResponse> HandleRequest(
+ const net::test_server::HttpRequest& request) {
+ request_count_++;
+ return std::unique_ptr<net::test_server::HttpResponse>();
+ }
+
+ // Call this to reset the request_count_.
+ void Clear() { request_count_ = 0; }
+
+ int request_count() const { return request_count_; }
+
+ protected:
+ void SetUpCommandLine(base::CommandLine* command_line) override {
+ command_line->AppendSwitchASCII(switches::kEnableFeatures,
+ features::kNetworkService.name);
+ }
+
+ private:
+ // Tracks the number of requests.
+ int request_count_ = 0;
+};
+
+// The network service process launch DCHECK's on Android. The bug
+// here http://crbug.com/748764. It looks like unsandboxed utility
+// processes are not supported on Android.
+#if !defined(OS_ANDROID)
+// This test validates that navigating to a TLD which has an AppCache
+// associated with it and then navigating to another TLD within that
+// host clears the previously registered factory. We verify this by
+// validating that request count for the last navigation.
+IN_PROC_BROWSER_TEST_F(AppCacheNetworkServiceBrowserTest,
+ VerifySubresourceFactoryClearedOnNewNavigation) {
+ std::unique_ptr<net::EmbeddedTestServer> embedded_test_server(
+ new net::EmbeddedTestServer());
+
+ embedded_test_server->RegisterRequestHandler(
+ base::Bind(&AppCacheNetworkServiceBrowserTest::HandleRequest,
+ base::Unretained(this)));
+
+ base::FilePath content_test_data(FILE_PATH_LITERAL("content/test/data"));
+ embedded_test_server->AddDefaultHandlers(content_test_data);
+
+ ASSERT_TRUE(embedded_test_server->Start());
+
+ GURL main_url =
+ embedded_test_server->GetURL("/appcache/simple_page_with_manifest.html");
+
+ base::string16 expected_title = base::ASCIIToUTF16("AppCache updated");
+ TitleWatcher title_watcher(shell()->web_contents(), expected_title);
+
+ // Load the main page twice. The second navigation should have AppCache
+ // initialized for the page.
+ EXPECT_TRUE(NavigateToURL(shell(), main_url));
+ EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle());
+
+ TestNavigationObserver observer(shell()->web_contents());
+ EXPECT_TRUE(NavigateToURL(shell(), main_url));
+ EXPECT_EQ(main_url, observer.last_navigation_url());
+ EXPECT_TRUE(observer.last_navigation_succeeded());
+
+ Clear();
+ GURL page_no_manifest =
+ embedded_test_server->GetURL("/appcache/simple_page_no_manifest.html");
+
+ EXPECT_TRUE(NavigateToURL(shell(), page_no_manifest));
+ // We expect two requests for simple_page_no_manifest.html. The request
+ // for the main page and the logo.
+ EXPECT_EQ(request_count(), 2);
+ EXPECT_EQ(page_no_manifest, observer.last_navigation_url());
+ EXPECT_TRUE(observer.last_navigation_succeeded());
+}
+#endif
+
+} // namespace content
« no previous file with comments | « no previous file | content/browser/appcache/appcache_subresource_url_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698