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

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: Changed wrong framework.js file, fixing 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
« no previous file with comments | « no previous file | chrome/browser/extensions/api/web_request/web_request_event_details_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // Disable a CHECK while doing api tests.
173 WebRequestPermissions::AllowAllExtensionLocationsInPublicSessionForTesting(
174 true);
175 ASSERT_TRUE(RunExtensionSubtest("webrequest_public_session", "test.html")) <<
176 message_;
177 WebRequestPermissions::AllowAllExtensionLocationsInPublicSessionForTesting(
Ivan Šandrk 2016/11/15 13:49:58 QQ - Does each test run from a clean state or is s
Devlin 2016/11/15 15:12:02 Short answer: depends on the test and the state yo
178 false);
179 }
180 #endif // defined(OS_CHROMEOS)
181
164 // Test that a request to an OpenSearch description document (OSDD) generates 182 // Test that a request to an OpenSearch description document (OSDD) generates
165 // an event with the expected details. 183 // an event with the expected details.
166 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, WebRequestTestOSDD) { 184 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, WebRequestTestOSDD) {
167 // An OSDD request is only generated when a main frame at is loaded at /, so 185 // 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: 186 // serve osdd/index.html from the root of the test server:
169 embedded_test_server()->ServeFilesFromDirectory( 187 embedded_test_server()->ServeFilesFromDirectory(
170 test_data_dir_.AppendASCII("webrequest/osdd")); 188 test_data_dir_.AppendASCII("webrequest/osdd"));
171 ASSERT_TRUE(StartEmbeddedTestServer()); 189 ASSERT_TRUE(StartEmbeddedTestServer());
172 190
173 search_test_utils::WaitForTemplateURLServiceToLoad( 191 search_test_utils::WaitForTemplateURLServiceToLoad(
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 ASSERT_TRUE(granter); 606 ASSERT_TRUE(granter);
589 granter->RevokeForTesting(); 607 granter->RevokeForTesting();
590 base::RunLoop().RunUntilIdle(); 608 base::RunLoop().RunUntilIdle();
591 PerformXhrInPage(web_contents, kHost, port, kXhrPath); 609 PerformXhrInPage(web_contents, kHost, port, kXhrPath);
592 EXPECT_EQ(xhr_count, 610 EXPECT_EQ(xhr_count,
593 GetWebRequestCountFromBackgroundPage(extension, profile())); 611 GetWebRequestCountFromBackgroundPage(extension, profile()));
594 EXPECT_EQ(BLOCKED_ACTION_WEB_REQUEST, runner->GetBlockedActions(extension)); 612 EXPECT_EQ(BLOCKED_ACTION_WEB_REQUEST, runner->GetBlockedActions(extension));
595 } 613 }
596 614
597 } // namespace extensions 615 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/api/web_request/web_request_event_details_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698