Chromium Code Reviews| 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..a2504262f6f013591c4c175a04bb7c120fa75b86 |
| --- /dev/null |
| +++ b/content/browser/appcache/appcache_browsertest.cc |
| @@ -0,0 +1,69 @@ |
| +// 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 "content/public/common/content_features.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" |
| + |
| +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() {} |
| + |
| +protected: |
| + void SetUpCommandLine(base::CommandLine* command_line) override { |
| + command_line->AppendSwitchASCII("enable-features", |
|
jam
2017/07/25 01:00:05
nit: use content::kEnableFeatures
ananta
2017/07/25 01:14:28
Done.
|
| + features::kNetworkService.name); |
|
jam
2017/07/25 01:00:05
nit: indentation
ananta
2017/07/25 01:14:28
Done.
|
| + } |
| + |
| + void SetUpOnMainThread() override { |
| + host_resolver()->AddRule("*", "127.0.0.1"); |
|
jam
2017/07/25 01:00:05
are you sure you need this? this is for tests that
ananta
2017/07/25 01:14:28
Thanks. Removed.
|
| + ASSERT_TRUE(embedded_test_server()->Start()); |
| + } |
| +}; |
| + |
| +// This test validates that navigating to a TLD which has an AppCache |
| +// associated with it and then navigating to another TLD within that |
| +// host does not hang. |
| +IN_PROC_BROWSER_TEST_F(AppCacheNetworkServiceBrowserTest, |
| + VerifySubresourceFactoryClearedOnNewNavigation) { |
| + if (!base::FeatureList::IsEnabled(features::kNetworkService)) |
|
jam
2017/07/25 01:00:05
nit: this isn't needed since the test sets it
ananta
2017/07/25 01:14:28
Removed
|
| + return; |
| + |
| + GURL main_url = embedded_test_server()->GetURL( |
| + "/appcache/simple_page_with_manifest.html"); |
| + |
| + TitleWatcher title_watcher(shell()->web_contents(), L"AppCache updated"); |
| + |
| + // Load the main page twice. The second navigation should have AppCache |
| + // initialized for the page. |
| + EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
| + EXPECT_EQ(title_watcher.WaitAndGetTitle(), L"AppCache updated"); |
| + |
| + 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()); |
| + |
| + GURL page_no_manifest = embedded_test_server()->GetURL( |
| + "/appcache/simple_page_no_manifest.html"); |
| + |
| + EXPECT_TRUE(NavigateToURL(shell(), page_no_manifest)); |
| + EXPECT_EQ(page_no_manifest, observer.last_navigation_url()); |
| + EXPECT_TRUE(observer.last_navigation_succeeded()); |
| +} |
| + |
| +} // namespace content |