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

Side by Side Diff: chrome/browser/extensions/extension_process_manager_unittest.cc

Issue 12546016: Remove the Extensions URLRequestContext (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: android webview init fix merged in. Created 7 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/extensions/extension_process_manager.h" 5 #include "chrome/browser/extensions/extension_process_manager.h"
6 #include "chrome/browser/extensions/extension_error_reporter.h" 6 #include "chrome/browser/extensions/extension_error_reporter.h"
7 #include "chrome/test/base/testing_profile.h" 7 #include "chrome/test/base/testing_profile.h"
8 #include "content/public/browser/render_process_host.h" 8 #include "content/public/browser/render_process_host.h"
9 #include "content/public/browser/site_instance.h" 9 #include "content/public/browser/site_instance.h"
10 #include "content/public/test/test_browser_thread_bundle.h"
10 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
11 #include "testing/platform_test.h" 12 #include "testing/platform_test.h"
12 13
13 using content::SiteInstance; 14 using content::SiteInstance;
14 15
15 namespace { 16 namespace {
16 17
17 // make the test a PlatformTest to setup autorelease pools properly on mac 18 // make the test a PlatformTest to setup autorelease pools properly on mac
18 class ExtensionProcessManagerTest : public testing::Test { 19 class ExtensionProcessManagerTest : public testing::Test {
19 public: 20 public:
20 static void SetUpTestCase() { 21 static void SetUpTestCase() {
21 ExtensionErrorReporter::Init(false); // no noisy errors 22 ExtensionErrorReporter::Init(false); // no noisy errors
22 } 23 }
23 24
24 virtual void SetUp() { 25 virtual void SetUp() {
25 ExtensionErrorReporter::GetInstance()->ClearErrors(); 26 ExtensionErrorReporter::GetInstance()->ClearErrors();
26 } 27 }
27 }; 28 };
28 29
29 } // namespace 30 } // namespace
30 31
31 // Test that extensions get grouped in the right SiteInstance (and therefore 32 // Test that extensions get grouped in the right SiteInstance (and therefore
32 // process) based on their URLs. 33 // process) based on their URLs.
33 TEST_F(ExtensionProcessManagerTest, ProcessGrouping) { 34 TEST_F(ExtensionProcessManagerTest, ProcessGrouping) {
34 // Extensions in different profiles should always be different SiteInstances. 35 // Extensions in different profiles should always be different SiteInstances.
35 // Note: we don't initialize these, since we're not testing that 36 // Note: we don't initialize these, since we're not testing that
36 // functionality. This means we can get away with a NULL UserScriptMaster. 37 // functionality. This means we can get away with a NULL UserScriptMaster.
38 content::TestBrowserThreadBundle thread_bundle;
37 TestingProfile profile1; 39 TestingProfile profile1;
38 scoped_ptr<ExtensionProcessManager> manager1( 40 scoped_ptr<ExtensionProcessManager> manager1(
39 ExtensionProcessManager::Create(&profile1)); 41 ExtensionProcessManager::Create(&profile1));
40 42
41 TestingProfile profile2; 43 TestingProfile profile2;
42 scoped_ptr<ExtensionProcessManager> manager2( 44 scoped_ptr<ExtensionProcessManager> manager2(
43 ExtensionProcessManager::Create(&profile2)); 45 ExtensionProcessManager::Create(&profile2));
44 46
45 // Extensions with common origins ("scheme://id/") should be grouped in the 47 // Extensions with common origins ("scheme://id/") should be grouped in the
46 // same SiteInstance. 48 // same SiteInstance.
47 GURL ext1_url1("chrome-extension://ext1_id/index.html"); 49 GURL ext1_url1("chrome-extension://ext1_id/index.html");
48 GURL ext1_url2("chrome-extension://ext1_id/monkey/monkey.html"); 50 GURL ext1_url2("chrome-extension://ext1_id/monkey/monkey.html");
49 GURL ext2_url1("chrome-extension://ext2_id/index.html"); 51 GURL ext2_url1("chrome-extension://ext2_id/index.html");
50 52
51 scoped_refptr<SiteInstance> site11 = 53 scoped_refptr<SiteInstance> site11 =
52 manager1->GetSiteInstanceForURL(ext1_url1); 54 manager1->GetSiteInstanceForURL(ext1_url1);
53 scoped_refptr<SiteInstance> site12 = 55 scoped_refptr<SiteInstance> site12 =
54 manager1->GetSiteInstanceForURL(ext1_url2); 56 manager1->GetSiteInstanceForURL(ext1_url2);
55 EXPECT_EQ(site11, site12); 57 EXPECT_EQ(site11, site12);
56 58
57 scoped_refptr<SiteInstance> site21 = 59 scoped_refptr<SiteInstance> site21 =
58 manager1->GetSiteInstanceForURL(ext2_url1); 60 manager1->GetSiteInstanceForURL(ext2_url1);
59 EXPECT_NE(site11, site21); 61 EXPECT_NE(site11, site21);
60 62
61 scoped_refptr<SiteInstance> other_profile_site = 63 scoped_refptr<SiteInstance> other_profile_site =
62 manager2->GetSiteInstanceForURL(ext1_url1); 64 manager2->GetSiteInstanceForURL(ext1_url1);
63 EXPECT_NE(site11, other_profile_site); 65 EXPECT_NE(site11, other_profile_site);
64 } 66 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698