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

Unified Diff: chrome/browser/extensions/api/web_request/web_request_apitest.cc

Issue 1267183003: Hide requests in an extension from other extensions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update tests (processed review comments #8). Created 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/web_request/web_request_apitest.cc
diff --git a/chrome/browser/extensions/api/web_request/web_request_apitest.cc b/chrome/browser/extensions/api/web_request/web_request_apitest.cc
index c9bdf6ea68ce89bec8ee0e35d104051a5b4ce06d..d281f3c59fede6f4c3d6fa98222f45f9571a7c8a 100644
--- a/chrome/browser/extensions/api/web_request/web_request_apitest.cc
+++ b/chrome/browser/extensions/api/web_request/web_request_apitest.cc
@@ -322,3 +322,62 @@ IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, IncognitoSplitModeReload) {
EXPECT_TRUE(listener2.WaitUntilSatisfied());
EXPECT_TRUE(listener_incognito2.WaitUntilSatisfied());
}
+
+IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, ExtensionRequests) {
+ ASSERT_TRUE(StartEmbeddedTestServer());
+ ExtensionTestMessageListener listener_main1("web_request_status1", true);
+ ExtensionTestMessageListener listener_main2("web_request_status2", true);
+
+ ExtensionTestMessageListener listener_app("app_done", false);
+ ExtensionTestMessageListener listener_extension("extension_done", true);
+
+ // Set up webRequest listener
+ ASSERT_TRUE(LoadExtension(
+ test_data_dir_.AppendASCII("webrequest_extensions/main")));
+ EXPECT_TRUE(listener_main1.WaitUntilSatisfied());
+ EXPECT_TRUE(listener_main2.WaitUntilSatisfied());
+
+ // Perform some network activity in an app and another extension.
+ ASSERT_TRUE(LoadExtension(
+ test_data_dir_.AppendASCII("webrequest_extensions/app")));
+ ASSERT_TRUE(LoadExtension(
+ test_data_dir_.AppendASCII("webrequest_extensions/extension")));
+
+ EXPECT_TRUE(listener_app.WaitUntilSatisfied());
+ EXPECT_TRUE(listener_extension.WaitUntilSatisfied());
+
+ // Load a page, a content script will ping us when it is ready.
+ ExtensionTestMessageListener listener_pageready("contentscript_ready", true);
+ ui_test_utils::NavigateToURL(browser(), embedded_test_server()->GetURL(
+ "/extensions/test_file.html?match_webrequest_test"));
+
+ // The extension and app-generated requests should not have triggered any
+ // webRequest event filtered by type 'xmlhttprequest'.
+ // (check this here instead of before the navigation, in case the webRequest
+ // event routing is slow for some reason).
+ ExtensionTestMessageListener listener_result(false);
+ listener_main1.Reply("");
+ EXPECT_TRUE(listener_result.WaitUntilSatisfied());
+ EXPECT_EQ("Did not intercept any requests.", listener_result.message());
+
not at google - send to devlin 2015/08/04 23:12:03 extra blank line
robwu 2015/08/05 16:38:08 Done.
+
+ // Proceed with the final tests: Let the content script fire a request.
+ EXPECT_TRUE(listener_pageready.WaitUntilSatisfied());
+ listener_pageready.Reply("");
+
+ ExtensionTestMessageListener listener_contentscript("contentscript_done",
+ true);
+ ExtensionTestMessageListener listener_framescript("framescript_done", false);
+ EXPECT_TRUE(listener_contentscript.WaitUntilSatisfied());
+ listener_contentscript.Reply("");
+ EXPECT_TRUE(listener_framescript.WaitUntilSatisfied());
+
+ // Collect the visited URLs. The content script and subframe does not run in
+ // the extension's process, so the requests should be visible to the main
+ // extension.
not at google - send to devlin 2015/08/04 23:12:03 +rdcronin Like I mentioned this will change with
Devlin 2015/08/04 23:19:20 Yeah, this looks like it will (or at least should)
robwu 2015/08/05 16:38:08 Done (and ran the test locally, with and without -
+ listener_result.Reset();
+ listener_main2.Reply("");
+ EXPECT_TRUE(listener_result.WaitUntilSatisfied());
+ EXPECT_EQ("Intercepted requests: ?contentscript, ?framescript",
+ listener_result.message());
+}

Powered by Google App Engine
This is Rietveld 408576698