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

Side by Side Diff: chrome/browser/extensions/api/web_request/web_request_apitest.cc

Issue 2455393002: PS - Adjusting webRequest API for use in Public Sessions (Closed)
Patch Set: webRequest and webRequestBlocking are safe permissions now Created 4 years, 1 month 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/macros.h" 6 #include "base/macros.h"
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #include "chrome/browser/chrome_notification_types.h" 10 #include "chrome/browser/chrome_notification_types.h"
11 #include "chrome/browser/extensions/active_tab_permission_granter.h" 11 #include "chrome/browser/extensions/active_tab_permission_granter.h"
12 #include "chrome/browser/extensions/extension_action_runner.h" 12 #include "chrome/browser/extensions/extension_action_runner.h"
13 #include "chrome/browser/extensions/extension_apitest.h" 13 #include "chrome/browser/extensions/extension_apitest.h"
14 #include "chrome/browser/extensions/extension_service.h" 14 #include "chrome/browser/extensions/extension_service.h"
15 #include "chrome/browser/extensions/tab_helper.h" 15 #include "chrome/browser/extensions/tab_helper.h"
16 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/search_engines/template_url_service_factory.h" 17 #include "chrome/browser/search_engines/template_url_service_factory.h"
18 #include "chrome/browser/ui/browser.h" 18 #include "chrome/browser/ui/browser.h"
19 #include "chrome/browser/ui/browser_navigator_params.h" 19 #include "chrome/browser/ui/browser_navigator_params.h"
20 #include "chrome/browser/ui/login/login_handler.h" 20 #include "chrome/browser/ui/login/login_handler.h"
21 #include "chrome/browser/ui/tabs/tab_strip_model.h" 21 #include "chrome/browser/ui/tabs/tab_strip_model.h"
22 #include "chrome/common/extensions/extension_process_policy.h" 22 #include "chrome/common/extensions/extension_process_policy.h"
23 #include "chrome/test/base/search_test_utils.h" 23 #include "chrome/test/base/search_test_utils.h"
24 #include "chrome/test/base/ui_test_utils.h" 24 #include "chrome/test/base/ui_test_utils.h"
25 #include "chromeos/login/login_state.h"
25 #include "content/public/browser/notification_registrar.h" 26 #include "content/public/browser/notification_registrar.h"
26 #include "content/public/browser/notification_service.h" 27 #include "content/public/browser/notification_service.h"
27 #include "content/public/browser/render_frame_host.h" 28 #include "content/public/browser/render_frame_host.h"
28 #include "content/public/browser/render_view_host.h" 29 #include "content/public/browser/render_view_host.h"
29 #include "content/public/browser/render_widget_host.h" 30 #include "content/public/browser/render_widget_host.h"
30 #include "content/public/browser/web_contents.h" 31 #include "content/public/browser/web_contents.h"
31 #include "content/public/test/browser_test_utils.h" 32 #include "content/public/test/browser_test_utils.h"
32 #include "extensions/browser/api/web_request/web_request_api.h" 33 #include "extensions/browser/api/web_request/web_request_api.h"
33 #include "extensions/browser/blocked_action_type.h" 34 #include "extensions/browser/blocked_action_type.h"
34 #include "extensions/browser/extension_system.h" 35 #include "extensions/browser/extension_system.h"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 ASSERT_TRUE(StartEmbeddedTestServer()); 156 ASSERT_TRUE(StartEmbeddedTestServer());
156 ASSERT_TRUE(RunExtensionSubtest("webrequest", "test_complex.html")) << 157 ASSERT_TRUE(RunExtensionSubtest("webrequest", "test_complex.html")) <<
157 message_; 158 message_;
158 } 159 }
159 160
160 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, WebRequestTypes) { 161 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, WebRequestTypes) {
161 ASSERT_TRUE(StartEmbeddedTestServer()); 162 ASSERT_TRUE(StartEmbeddedTestServer());
162 ASSERT_TRUE(RunExtensionSubtest("webrequest", "test_types.html")) << message_; 163 ASSERT_TRUE(RunExtensionSubtest("webrequest", "test_types.html")) << message_;
163 } 164 }
164 165
166 #if defined(OS_CHROMEOS)
167 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, WebRequestPublicSession) {
168 ASSERT_TRUE(StartEmbeddedTestServer());
169 // Set Public Session state.
170 chromeos::LoginState::Get()->SetLoggedInState(
171 chromeos::LoginState::LOGGED_IN_ACTIVE,
172 chromeos::LoginState::LOGGED_IN_USER_PUBLIC_ACCOUNT);
173 // Disable a CHECK while doing api tests.
174 WebRequestPermissions::AllowAllExtensionLocationsInPublicSessionForTesting(
175 true);
176 ASSERT_TRUE(RunExtensionSubtest("webrequest_public_session", "test.html")) <<
177 message_;
178 WebRequestPermissions::AllowAllExtensionLocationsInPublicSessionForTesting(
179 false);
180 }
181 #endif // defined(OS_CHROMEOS)
182
165 // Test that a request to an OpenSearch description document (OSDD) generates 183 // Test that a request to an OpenSearch description document (OSDD) generates
166 // an event with the expected details. 184 // an event with the expected details.
167 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, WebRequestTestOSDD) { 185 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, WebRequestTestOSDD) {
168 // An OSDD request is only generated when a main frame at is loaded at /, so 186 // An OSDD request is only generated when a main frame at is loaded at /, so
169 // serve osdd/index.html from the root of the test server: 187 // serve osdd/index.html from the root of the test server:
170 embedded_test_server()->ServeFilesFromDirectory( 188 embedded_test_server()->ServeFilesFromDirectory(
171 test_data_dir_.AppendASCII("webrequest/osdd")); 189 test_data_dir_.AppendASCII("webrequest/osdd"));
172 ASSERT_TRUE(StartEmbeddedTestServer()); 190 ASSERT_TRUE(StartEmbeddedTestServer());
173 191
174 search_test_utils::WaitForTemplateURLServiceToLoad( 192 search_test_utils::WaitForTemplateURLServiceToLoad(
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 ASSERT_TRUE(granter); 643 ASSERT_TRUE(granter);
626 granter->RevokeForTesting(); 644 granter->RevokeForTesting();
627 base::RunLoop().RunUntilIdle(); 645 base::RunLoop().RunUntilIdle();
628 PerformXhrInFrame(main_frame, kHost, port, kXhrPath); 646 PerformXhrInFrame(main_frame, kHost, port, kXhrPath);
629 EXPECT_EQ(xhr_count, 647 EXPECT_EQ(xhr_count,
630 GetWebRequestCountFromBackgroundPage(extension, profile())); 648 GetWebRequestCountFromBackgroundPage(extension, profile()));
631 EXPECT_EQ(BLOCKED_ACTION_WEB_REQUEST, runner->GetBlockedActions(extension)); 649 EXPECT_EQ(BLOCKED_ACTION_WEB_REQUEST, runner->GetBlockedActions(extension));
632 } 650 }
633 651
634 } // namespace extensions 652 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698