OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include <stdint.h> | |
6 | |
7 #include "base/command_line.h" | |
8 #include "content/public/common/content_features.h" | |
9 #include "content/public/test/browser_test_utils.h" | |
10 #include "content/public/test/content_browser_test.h" | |
11 #include "content/public/test/content_browser_test_utils.h" | |
12 #include "content/public/test/test_navigation_observer.h" | |
13 #include "content/public/test/test_utils.h" | |
14 #include "content/shell/browser/shell.h" | |
15 #include "net/dns/mock_host_resolver.h" | |
16 #include "net/test/embedded_test_server/embedded_test_server.h" | |
17 | |
18 namespace content { | |
19 | |
20 // This class currently enables the network service feature, which allows us to | |
21 // test the AppCache code in that mode. | |
22 class AppCacheNetworkServiceBrowserTest : public ContentBrowserTest { | |
23 public: | |
24 AppCacheNetworkServiceBrowserTest() {} | |
25 | |
26 protected: | |
27 void SetUpCommandLine(base::CommandLine* command_line) override { | |
28 command_line->AppendSwitchASCII("enable-features", | |
jam
2017/07/25 01:00:05
nit: use content::kEnableFeatures
ananta
2017/07/25 01:14:28
Done.
| |
29 features::kNetworkService.name); | |
jam
2017/07/25 01:00:05
nit: indentation
ananta
2017/07/25 01:14:28
Done.
| |
30 } | |
31 | |
32 void SetUpOnMainThread() override { | |
33 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.
| |
34 ASSERT_TRUE(embedded_test_server()->Start()); | |
35 } | |
36 }; | |
37 | |
38 // This test validates that navigating to a TLD which has an AppCache | |
39 // associated with it and then navigating to another TLD within that | |
40 // host does not hang. | |
41 IN_PROC_BROWSER_TEST_F(AppCacheNetworkServiceBrowserTest, | |
42 VerifySubresourceFactoryClearedOnNewNavigation) { | |
43 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
| |
44 return; | |
45 | |
46 GURL main_url = embedded_test_server()->GetURL( | |
47 "/appcache/simple_page_with_manifest.html"); | |
48 | |
49 TitleWatcher title_watcher(shell()->web_contents(), L"AppCache updated"); | |
50 | |
51 // Load the main page twice. The second navigation should have AppCache | |
52 // initialized for the page. | |
53 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | |
54 EXPECT_EQ(title_watcher.WaitAndGetTitle(), L"AppCache updated"); | |
55 | |
56 TestNavigationObserver observer(shell()->web_contents()); | |
57 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | |
58 EXPECT_EQ(main_url, observer.last_navigation_url()); | |
59 EXPECT_TRUE(observer.last_navigation_succeeded()); | |
60 | |
61 GURL page_no_manifest = embedded_test_server()->GetURL( | |
62 "/appcache/simple_page_no_manifest.html"); | |
63 | |
64 EXPECT_TRUE(NavigateToURL(shell(), page_no_manifest)); | |
65 EXPECT_EQ(page_no_manifest, observer.last_navigation_url()); | |
66 EXPECT_TRUE(observer.last_navigation_succeeded()); | |
67 } | |
68 | |
69 } // namespace content | |
OLD | NEW |