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

Side by Side 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 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 "chrome/browser/chrome_notification_types.h" 6 #include "chrome/browser/chrome_notification_types.h"
7 #include "chrome/browser/extensions/extension_apitest.h" 7 #include "chrome/browser/extensions/extension_apitest.h"
8 #include "chrome/browser/extensions/extension_service.h" 8 #include "chrome/browser/extensions/extension_service.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 // Reload extension and wait for rules to be set up again. This should not 315 // Reload extension and wait for rules to be set up again. This should not
316 // crash the browser. 316 // crash the browser.
317 ExtensionTestMessageListener listener2("done", true); 317 ExtensionTestMessageListener listener2("done", true);
318 ExtensionTestMessageListener listener_incognito2("done_incognito", true); 318 ExtensionTestMessageListener listener_incognito2("done_incognito", true);
319 319
320 ReloadExtension(extension->id()); 320 ReloadExtension(extension->id());
321 321
322 EXPECT_TRUE(listener2.WaitUntilSatisfied()); 322 EXPECT_TRUE(listener2.WaitUntilSatisfied());
323 EXPECT_TRUE(listener_incognito2.WaitUntilSatisfied()); 323 EXPECT_TRUE(listener_incognito2.WaitUntilSatisfied());
324 } 324 }
325
326 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, ExtensionRequests) {
327 ASSERT_TRUE(StartEmbeddedTestServer());
328 ExtensionTestMessageListener listener_main1("web_request_status1", true);
329 ExtensionTestMessageListener listener_main2("web_request_status2", true);
330
331 ExtensionTestMessageListener listener_app("app_done", false);
332 ExtensionTestMessageListener listener_extension("extension_done", true);
333
334 // Set up webRequest listener
335 ASSERT_TRUE(LoadExtension(
336 test_data_dir_.AppendASCII("webrequest_extensions/main")));
337 EXPECT_TRUE(listener_main1.WaitUntilSatisfied());
338 EXPECT_TRUE(listener_main2.WaitUntilSatisfied());
339
340 // Perform some network activity in an app and another extension.
341 ASSERT_TRUE(LoadExtension(
342 test_data_dir_.AppendASCII("webrequest_extensions/app")));
343 ASSERT_TRUE(LoadExtension(
344 test_data_dir_.AppendASCII("webrequest_extensions/extension")));
345
346 EXPECT_TRUE(listener_app.WaitUntilSatisfied());
347 EXPECT_TRUE(listener_extension.WaitUntilSatisfied());
348
349 // Load a page, a content script will ping us when it is ready.
350 ExtensionTestMessageListener listener_pageready("contentscript_ready", true);
351 ui_test_utils::NavigateToURL(browser(), embedded_test_server()->GetURL(
352 "/extensions/test_file.html?match_webrequest_test"));
353
354 // The extension and app-generated requests should not have triggered any
355 // webRequest event filtered by type 'xmlhttprequest'.
356 // (check this here instead of before the navigation, in case the webRequest
357 // event routing is slow for some reason).
358 ExtensionTestMessageListener listener_result(false);
359 listener_main1.Reply("");
360 EXPECT_TRUE(listener_result.WaitUntilSatisfied());
361 EXPECT_EQ("Did not intercept any requests.", listener_result.message());
362
not at google - send to devlin 2015/08/04 23:12:03 extra blank line
robwu 2015/08/05 16:38:08 Done.
363
364 // Proceed with the final tests: Let the content script fire a request.
365 EXPECT_TRUE(listener_pageready.WaitUntilSatisfied());
366 listener_pageready.Reply("");
367
368 ExtensionTestMessageListener listener_contentscript("contentscript_done",
369 true);
370 ExtensionTestMessageListener listener_framescript("framescript_done", false);
371 EXPECT_TRUE(listener_contentscript.WaitUntilSatisfied());
372 listener_contentscript.Reply("");
373 EXPECT_TRUE(listener_framescript.WaitUntilSatisfied());
374
375 // Collect the visited URLs. The content script and subframe does not run in
376 // the extension's process, so the requests should be visible to the main
377 // 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 -
378 listener_result.Reset();
379 listener_main2.Reply("");
380 EXPECT_TRUE(listener_result.WaitUntilSatisfied());
381 EXPECT_EQ("Intercepted requests: ?contentscript, ?framescript",
382 listener_result.message());
383 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698