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

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

Issue 10826298: Force the channel to be dev for active tab and manfiest unit tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/common/extensions/manifest_tests/extension_manifest_test.h » ('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 <string> 5 #include <string>
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 .Set("version", "1.0") 48 .Set("version", "1.0")
49 .Set("manifest_version", 2) 49 .Set("manifest_version", 2)
50 .Set("permissions", permissions)) 50 .Set("permissions", permissions))
51 .SetID(id) 51 .SetID(id)
52 .Build(); 52 .Build();
53 } 53 }
54 54
55 class ActiveTabTest : public TabContentsTestHarness { 55 class ActiveTabTest : public TabContentsTestHarness {
56 public: 56 public:
57 ActiveTabTest() 57 ActiveTabTest()
58 : extension(CreateTestExtension("deadbeef", true)), 58 : current_channel_(chrome::VersionInfo::CHANNEL_DEV),
59 extension(CreateTestExtension("deadbeef", true)),
59 another_extension(CreateTestExtension("feedbeef", true)), 60 another_extension(CreateTestExtension("feedbeef", true)),
60 extension_without_active_tab(CreateTestExtension("badbeef", false)), 61 extension_without_active_tab(CreateTestExtension("badbeef", false)),
61 ui_thread_(BrowserThread::UI, MessageLoop::current()), 62 ui_thread_(BrowserThread::UI, MessageLoop::current()) {}
62 current_channel_(chrome::VersionInfo::CHANNEL_DEV) {}
63 63
64 protected: 64 protected:
65 int tab_id() { 65 int tab_id() {
66 return SessionID::IdForTab(tab_contents()); 66 return SessionID::IdForTab(tab_contents());
67 } 67 }
68 68
69 ActiveTabPermissionManager* active_tab_permission_manager() { 69 ActiveTabPermissionManager* active_tab_permission_manager() {
70 return tab_contents()->extension_tab_helper()-> 70 return tab_contents()->extension_tab_helper()->
71 active_tab_permission_manager(); 71 active_tab_permission_manager();
72 } 72 }
(...skipping 26 matching lines...) Expand all
99 99
100 bool HasTabsPermission(const scoped_refptr<const Extension>& extension) { 100 bool HasTabsPermission(const scoped_refptr<const Extension>& extension) {
101 return HasTabsPermission(extension, tab_id()); 101 return HasTabsPermission(extension, tab_id());
102 } 102 }
103 103
104 bool HasTabsPermission(const scoped_refptr<const Extension>& extension, 104 bool HasTabsPermission(const scoped_refptr<const Extension>& extension,
105 int tab_id) { 105 int tab_id) {
106 return extension->HasAPIPermissionForTab(tab_id, APIPermission::kTab); 106 return extension->HasAPIPermissionForTab(tab_id, APIPermission::kTab);
107 } 107 }
108 108
109 // Force the test to run in dev channel because the permission is only
110 // available in dev channel. Without declaring this first, the extensions
111 // below won't load due to manifest errors.
112 Feature::ScopedCurrentChannel current_channel_;
113
109 // An extension with the activeTab permission. 114 // An extension with the activeTab permission.
110 scoped_refptr<const Extension> extension; 115 scoped_refptr<const Extension> extension;
111 116
112 // Another extension with activeTab (for good measure). 117 // Another extension with activeTab (for good measure).
113 scoped_refptr<const Extension> another_extension; 118 scoped_refptr<const Extension> another_extension;
114 119
115 // An extension without the activeTab permission. 120 // An extension without the activeTab permission.
116 scoped_refptr<const Extension> extension_without_active_tab; 121 scoped_refptr<const Extension> extension_without_active_tab;
117 122
118 private: 123 private:
119 content::TestBrowserThread ui_thread_; 124 content::TestBrowserThread ui_thread_;
120 Feature::ScopedCurrentChannel current_channel_;
121 }; 125 };
122 126
123 TEST_F(ActiveTabTest, GrantToSinglePage) { 127 TEST_F(ActiveTabTest, GrantToSinglePage) {
124 GURL google("http://www.google.com"); 128 GURL google("http://www.google.com");
125 NavigateAndCommit(google); 129 NavigateAndCommit(google);
126 130
127 // No access unless it's been granted. 131 // No access unless it's been granted.
128 EXPECT_TRUE(IsBlocked(extension, google)); 132 EXPECT_TRUE(IsBlocked(extension, google));
129 EXPECT_TRUE(IsBlocked(another_extension, google)); 133 EXPECT_TRUE(IsBlocked(another_extension, google));
130 EXPECT_TRUE(IsBlocked(extension_without_active_tab, google)); 134 EXPECT_TRUE(IsBlocked(extension_without_active_tab, google));
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 Reload(); 314 Reload();
311 315
312 EXPECT_FALSE(IsAllowed(extension, google, tab_id())); 316 EXPECT_FALSE(IsAllowed(extension, google, tab_id()));
313 EXPECT_FALSE(IsAllowed(extension, google_h1, tab_id())); 317 EXPECT_FALSE(IsAllowed(extension, google_h1, tab_id()));
314 EXPECT_FALSE(IsAllowed(extension, chromium, tab_id())); 318 EXPECT_FALSE(IsAllowed(extension, chromium, tab_id()));
315 EXPECT_FALSE(IsAllowed(extension, chromium_h1, tab_id())); 319 EXPECT_FALSE(IsAllowed(extension, chromium_h1, tab_id()));
316 } 320 }
317 321
318 } // namespace 322 } // namespace
319 } // namespace extensions 323 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/common/extensions/manifest_tests/extension_manifest_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698