OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <memory> | 5 #include <memory> |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 host_resolver()->AddIPLiteralRule("*", "127.0.0.1", "localhost"); | 66 host_resolver()->AddIPLiteralRule("*", "127.0.0.1", "localhost"); |
67 | 67 |
68 ASSERT_TRUE(embedded_test_server()->Start()); | 68 ASSERT_TRUE(embedded_test_server()->Start()); |
69 } | 69 } |
70 | 70 |
71 void SupervisedUserNavigationThrottleTest::SetUpCommandLine( | 71 void SupervisedUserNavigationThrottleTest::SetUpCommandLine( |
72 base::CommandLine* command_line) { | 72 base::CommandLine* command_line) { |
73 command_line->AppendSwitchASCII(switches::kSupervisedUserId, "asdf"); | 73 command_line->AppendSwitchASCII(switches::kSupervisedUserId, "asdf"); |
74 } | 74 } |
75 | 75 |
76 // Tests that showing the blocking interstitial for a WebContents without a | 76 // Tests that navigating to a blocked page simply fails if there is no |
77 // SupervisedUserNavigationObserver doesn't crash. | 77 // SupervisedUserNavigationObserver. |
78 IN_PROC_BROWSER_TEST_F(SupervisedUserNavigationThrottleTest, | 78 IN_PROC_BROWSER_TEST_F(SupervisedUserNavigationThrottleTest, |
79 NoNavigationObserverBlock) { | 79 NoNavigationObserverBlock) { |
80 Profile* profile = browser()->profile(); | 80 Profile* profile = browser()->profile(); |
81 SupervisedUserSettingsService* supervised_user_settings_service = | 81 SupervisedUserSettingsService* supervised_user_settings_service = |
82 SupervisedUserSettingsServiceFactory::GetForProfile(profile); | 82 SupervisedUserSettingsServiceFactory::GetForProfile(profile); |
83 supervised_user_settings_service->SetLocalSetting( | 83 supervised_user_settings_service->SetLocalSetting( |
84 supervised_users::kContentPackDefaultFilteringBehavior, | 84 supervised_users::kContentPackDefaultFilteringBehavior, |
85 std::unique_ptr<base::Value>( | 85 std::unique_ptr<base::Value>( |
86 new base::Value(SupervisedUserURLFilter::BLOCK))); | 86 new base::Value(SupervisedUserURLFilter::BLOCK))); |
87 | 87 |
88 std::unique_ptr<WebContents> web_contents( | 88 std::unique_ptr<WebContents> web_contents( |
89 WebContents::Create(WebContents::CreateParams(profile))); | 89 WebContents::Create(WebContents::CreateParams(profile))); |
90 NavigationController& controller = web_contents->GetController(); | 90 NavigationController& controller = web_contents->GetController(); |
91 content::TestNavigationObserver observer(web_contents.get()); | 91 content::TestNavigationObserver observer(web_contents.get()); |
92 controller.LoadURL(GURL("http://www.example.com"), content::Referrer(), | 92 controller.LoadURL(GURL("http://www.example.com"), content::Referrer(), |
93 ui::PAGE_TRANSITION_TYPED, std::string()); | 93 ui::PAGE_TRANSITION_TYPED, std::string()); |
94 observer.Wait(); | 94 observer.Wait(); |
95 content::NavigationEntry* entry = controller.GetActiveEntry(); | 95 content::NavigationEntry* entry = controller.GetActiveEntry(); |
96 ASSERT_TRUE(entry); | 96 ASSERT_TRUE(entry); |
97 EXPECT_EQ(content::PAGE_TYPE_INTERSTITIAL, entry->GetPageType()); | 97 EXPECT_EQ(content::PAGE_TYPE_NORMAL, entry->GetPageType()); |
| 98 EXPECT_FALSE(observer.last_navigation_succeeded()); |
98 } | 99 } |
99 | 100 |
100 IN_PROC_BROWSER_TEST_F(SupervisedUserNavigationThrottleTest, | 101 IN_PROC_BROWSER_TEST_F(SupervisedUserNavigationThrottleTest, |
101 BlockMainFrameWithInterstitial) { | 102 BlockMainFrameWithInterstitial) { |
102 BlockHost(kExampleHost2); | 103 BlockHost(kExampleHost2); |
103 | 104 |
104 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | 105 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
105 | 106 |
106 GURL allowed_url = embedded_test_server()->GetURL( | 107 GURL allowed_url = embedded_test_server()->GetURL( |
107 kExampleHost, "/supervised_user/simple.html"); | 108 kExampleHost, "/supervised_user/simple.html"); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 | 155 |
155 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | 156 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
156 | 157 |
157 GURL blocked_url = embedded_test_server()->GetURL( | 158 GURL blocked_url = embedded_test_server()->GetURL( |
158 kExampleHost, "/supervised_user/simple.html"); | 159 kExampleHost, "/supervised_user/simple.html"); |
159 ui_test_utils::NavigateToURL(browser(), blocked_url); | 160 ui_test_utils::NavigateToURL(browser(), blocked_url); |
160 // Even though the URL is marked as blocked, the load should go through, since | 161 // Even though the URL is marked as blocked, the load should go through, since |
161 // the user isn't supervised. | 162 // the user isn't supervised. |
162 EXPECT_FALSE(tab->ShowingInterstitialPage()); | 163 EXPECT_FALSE(tab->ShowingInterstitialPage()); |
163 } | 164 } |
OLD | NEW |