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

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: Fixed unittest error 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_view_host.h" 28 #include "content/public/browser/render_view_host.h"
28 #include "content/public/browser/render_widget_host.h" 29 #include "content/public/browser/render_widget_host.h"
29 #include "content/public/browser/web_contents.h" 30 #include "content/public/browser/web_contents.h"
30 #include "content/public/test/browser_test_utils.h" 31 #include "content/public/test/browser_test_utils.h"
31 #include "extensions/browser/api/web_request/web_request_api.h" 32 #include "extensions/browser/api/web_request/web_request_api.h"
32 #include "extensions/browser/blocked_action_type.h" 33 #include "extensions/browser/blocked_action_type.h"
33 #include "extensions/browser/extension_system.h" 34 #include "extensions/browser/extension_system.h"
34 #include "extensions/common/extension_builder.h" 35 #include "extensions/common/extension_builder.h"
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 ASSERT_TRUE(StartEmbeddedTestServer()); 155 ASSERT_TRUE(StartEmbeddedTestServer());
155 ASSERT_TRUE(RunExtensionSubtest("webrequest", "test_complex.html")) << 156 ASSERT_TRUE(RunExtensionSubtest("webrequest", "test_complex.html")) <<
156 message_; 157 message_;
157 } 158 }
158 159
159 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, WebRequestTypes) { 160 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, WebRequestTypes) {
160 ASSERT_TRUE(StartEmbeddedTestServer()); 161 ASSERT_TRUE(StartEmbeddedTestServer());
161 ASSERT_TRUE(RunExtensionSubtest("webrequest", "test_types.html")) << message_; 162 ASSERT_TRUE(RunExtensionSubtest("webrequest", "test_types.html")) << message_;
162 } 163 }
163 164
165 #if defined(OS_CHROMEOS)
166 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, WebRequestPublicSession) {
167 ASSERT_TRUE(StartEmbeddedTestServer());
168 // Set Public Session state.
169 chromeos::LoginState::Get()->SetLoggedInState(
170 chromeos::LoginState::LOGGED_IN_ACTIVE,
171 chromeos::LoginState::LOGGED_IN_USER_PUBLIC_ACCOUNT);
172 ASSERT_TRUE(RunExtensionSubtest("webrequest_public_session", "test.html")) <<
173 message_;
174 }
175 #endif // defined(OS_CHROMEOS)
176
164 // Test that a request to an OpenSearch description document (OSDD) generates 177 // Test that a request to an OpenSearch description document (OSDD) generates
165 // an event with the expected details. 178 // an event with the expected details.
166 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, WebRequestTestOSDD) { 179 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, WebRequestTestOSDD) {
167 // An OSDD request is only generated when a main frame at is loaded at /, so 180 // An OSDD request is only generated when a main frame at is loaded at /, so
168 // serve osdd/index.html from the root of the test server: 181 // serve osdd/index.html from the root of the test server:
169 embedded_test_server()->ServeFilesFromDirectory( 182 embedded_test_server()->ServeFilesFromDirectory(
170 test_data_dir_.AppendASCII("webrequest/osdd")); 183 test_data_dir_.AppendASCII("webrequest/osdd"));
171 ASSERT_TRUE(StartEmbeddedTestServer()); 184 ASSERT_TRUE(StartEmbeddedTestServer());
172 185
173 search_test_utils::WaitForTemplateURLServiceToLoad( 186 search_test_utils::WaitForTemplateURLServiceToLoad(
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 ASSERT_TRUE(granter); 601 ASSERT_TRUE(granter);
589 granter->RevokeForTesting(); 602 granter->RevokeForTesting();
590 base::RunLoop().RunUntilIdle(); 603 base::RunLoop().RunUntilIdle();
591 PerformXhrInPage(web_contents, kHost, port, kXhrPath); 604 PerformXhrInPage(web_contents, kHost, port, kXhrPath);
592 EXPECT_EQ(xhr_count, 605 EXPECT_EQ(xhr_count,
593 GetWebRequestCountFromBackgroundPage(extension, profile())); 606 GetWebRequestCountFromBackgroundPage(extension, profile()));
594 EXPECT_EQ(BLOCKED_ACTION_WEB_REQUEST, runner->GetBlockedActions(extension)); 607 EXPECT_EQ(BLOCKED_ACTION_WEB_REQUEST, runner->GetBlockedActions(extension));
595 } 608 }
596 609
597 } // namespace extensions 610 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698