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

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

Issue 2238383003: webRequest: Also identify frames for non-RDH-initiated requests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix mek's nits Created 4 years, 4 months 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/test/data/extensions/api_test/webrequest/framework.js » ('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/ui/browser.h" 18 #include "chrome/browser/ui/browser.h"
18 #include "chrome/browser/ui/browser_navigator_params.h" 19 #include "chrome/browser/ui/browser_navigator_params.h"
19 #include "chrome/browser/ui/login/login_handler.h" 20 #include "chrome/browser/ui/login/login_handler.h"
20 #include "chrome/browser/ui/tabs/tab_strip_model.h" 21 #include "chrome/browser/ui/tabs/tab_strip_model.h"
21 #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"
22 #include "chrome/test/base/ui_test_utils.h" 24 #include "chrome/test/base/ui_test_utils.h"
23 #include "content/public/browser/notification_registrar.h" 25 #include "content/public/browser/notification_registrar.h"
24 #include "content/public/browser/notification_service.h" 26 #include "content/public/browser/notification_service.h"
25 #include "content/public/browser/render_view_host.h" 27 #include "content/public/browser/render_view_host.h"
26 #include "content/public/browser/render_widget_host.h" 28 #include "content/public/browser/render_widget_host.h"
27 #include "content/public/browser/web_contents.h" 29 #include "content/public/browser/web_contents.h"
28 #include "content/public/test/browser_test_utils.h" 30 #include "content/public/test/browser_test_utils.h"
29 #include "extensions/browser/api/web_request/web_request_api.h" 31 #include "extensions/browser/api/web_request/web_request_api.h"
30 #include "extensions/browser/blocked_action_type.h" 32 #include "extensions/browser/blocked_action_type.h"
31 #include "extensions/browser/extension_system.h" 33 #include "extensions/browser/extension_system.h"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 ASSERT_TRUE(StartEmbeddedTestServer()); 154 ASSERT_TRUE(StartEmbeddedTestServer());
153 ASSERT_TRUE(RunExtensionSubtest("webrequest", "test_complex.html")) << 155 ASSERT_TRUE(RunExtensionSubtest("webrequest", "test_complex.html")) <<
154 message_; 156 message_;
155 } 157 }
156 158
157 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, WebRequestTypes) { 159 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, WebRequestTypes) {
158 ASSERT_TRUE(StartEmbeddedTestServer()); 160 ASSERT_TRUE(StartEmbeddedTestServer());
159 ASSERT_TRUE(RunExtensionSubtest("webrequest", "test_types.html")) << message_; 161 ASSERT_TRUE(RunExtensionSubtest("webrequest", "test_types.html")) << message_;
160 } 162 }
161 163
164 // Test that a request to an OpenSearch description document (OSDD) generates
165 // an event with the expected details.
166 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, WebRequestTestOSDD) {
167 // 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:
169 embedded_test_server()->ServeFilesFromDirectory(
170 test_data_dir_.AppendASCII("webrequest/osdd"));
171 ASSERT_TRUE(StartEmbeddedTestServer());
172
173 search_test_utils::WaitForTemplateURLServiceToLoad(
174 TemplateURLServiceFactory::GetForProfile(profile()));
175 ASSERT_TRUE(RunExtensionSubtest("webrequest", "test_osdd.html")) << message_;
176 }
177
162 // Test that the webRequest events are dispatched with the expected details when 178 // Test that the webRequest events are dispatched with the expected details when
163 // a frame or tab is removed while a response is being received. 179 // a frame or tab is removed while a response is being received.
164 // Flaky: https://crbug.com/617865 180 // Flaky: https://crbug.com/617865
165 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, 181 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest,
166 DISABLED_WebRequestUnloadAfterRequest) { 182 DISABLED_WebRequestUnloadAfterRequest) {
167 ASSERT_TRUE(StartEmbeddedTestServer()); 183 ASSERT_TRUE(StartEmbeddedTestServer());
168 ASSERT_TRUE(RunExtensionSubtest("webrequest", "test_unload.html?1")) << 184 ASSERT_TRUE(RunExtensionSubtest("webrequest", "test_unload.html?1")) <<
169 message_; 185 message_;
170 ASSERT_TRUE(RunExtensionSubtest("webrequest", "test_unload.html?2")) << 186 ASSERT_TRUE(RunExtensionSubtest("webrequest", "test_unload.html?2")) <<
171 message_; 187 message_;
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 ASSERT_TRUE(granter); 588 ASSERT_TRUE(granter);
573 granter->RevokeForTesting(); 589 granter->RevokeForTesting();
574 base::RunLoop().RunUntilIdle(); 590 base::RunLoop().RunUntilIdle();
575 PerformXhrInPage(web_contents, kHost, port, kXhrPath); 591 PerformXhrInPage(web_contents, kHost, port, kXhrPath);
576 EXPECT_EQ(xhr_count, 592 EXPECT_EQ(xhr_count,
577 GetWebRequestCountFromBackgroundPage(extension, profile())); 593 GetWebRequestCountFromBackgroundPage(extension, profile()));
578 EXPECT_EQ(BLOCKED_ACTION_WEB_REQUEST, runner->GetBlockedActions(extension)); 594 EXPECT_EQ(BLOCKED_ACTION_WEB_REQUEST, runner->GetBlockedActions(extension));
579 } 595 }
580 596
581 } // namespace extensions 597 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/extensions/api_test/webrequest/framework.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698