OLD | NEW |
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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 : extension(CreateTestExtension("deadbeef", true)), |
59 another_extension(CreateTestExtension("feedbeef", true)), | 59 another_extension(CreateTestExtension("feedbeef", true)), |
60 extension_without_active_tab(CreateTestExtension("badbeef", false)), | 60 extension_without_active_tab(CreateTestExtension("badbeef", false)), |
61 ui_thread_(BrowserThread::UI, MessageLoop::current()) { | 61 ui_thread_(BrowserThread::UI, MessageLoop::current()), |
62 } | 62 current_channel_(chrome::VersionInfo::CHANNEL_DEV) {} |
63 | |
64 virtual void SetUp() { | |
65 TabContentsTestHarness::SetUp(); | |
66 Feature::SetChannelForTesting(chrome::VersionInfo::CHANNEL_UNKNOWN); | |
67 } | |
68 | 63 |
69 protected: | 64 protected: |
70 int tab_id() { | 65 int tab_id() { |
71 return SessionID::IdForTab(tab_contents()); | 66 return SessionID::IdForTab(tab_contents()); |
72 } | 67 } |
73 | 68 |
74 ActiveTabPermissionManager* active_tab_permission_manager() { | 69 ActiveTabPermissionManager* active_tab_permission_manager() { |
75 return tab_contents()->extension_tab_helper()-> | 70 return tab_contents()->extension_tab_helper()-> |
76 active_tab_permission_manager(); | 71 active_tab_permission_manager(); |
77 } | 72 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 scoped_refptr<const Extension> extension; | 110 scoped_refptr<const Extension> extension; |
116 | 111 |
117 // Another extension with activeTab (for good measure). | 112 // Another extension with activeTab (for good measure). |
118 scoped_refptr<const Extension> another_extension; | 113 scoped_refptr<const Extension> another_extension; |
119 | 114 |
120 // An extension without the activeTab permission. | 115 // An extension without the activeTab permission. |
121 scoped_refptr<const Extension> extension_without_active_tab; | 116 scoped_refptr<const Extension> extension_without_active_tab; |
122 | 117 |
123 private: | 118 private: |
124 content::TestBrowserThread ui_thread_; | 119 content::TestBrowserThread ui_thread_; |
| 120 Feature::ScopedCurrentChannel current_channel_; |
125 }; | 121 }; |
126 | 122 |
127 TEST_F(ActiveTabTest, GrantToSinglePage) { | 123 TEST_F(ActiveTabTest, GrantToSinglePage) { |
128 GURL google("http://www.google.com"); | 124 GURL google("http://www.google.com"); |
129 NavigateAndCommit(google); | 125 NavigateAndCommit(google); |
130 | 126 |
131 // No access unless it's been granted. | 127 // No access unless it's been granted. |
132 EXPECT_TRUE(IsBlocked(extension, google)); | 128 EXPECT_TRUE(IsBlocked(extension, google)); |
133 EXPECT_TRUE(IsBlocked(another_extension, google)); | 129 EXPECT_TRUE(IsBlocked(another_extension, google)); |
134 EXPECT_TRUE(IsBlocked(extension_without_active_tab, google)); | 130 EXPECT_TRUE(IsBlocked(extension_without_active_tab, google)); |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 Reload(); | 310 Reload(); |
315 | 311 |
316 EXPECT_FALSE(IsAllowed(extension, google, tab_id())); | 312 EXPECT_FALSE(IsAllowed(extension, google, tab_id())); |
317 EXPECT_FALSE(IsAllowed(extension, google_h1, tab_id())); | 313 EXPECT_FALSE(IsAllowed(extension, google_h1, tab_id())); |
318 EXPECT_FALSE(IsAllowed(extension, chromium, tab_id())); | 314 EXPECT_FALSE(IsAllowed(extension, chromium, tab_id())); |
319 EXPECT_FALSE(IsAllowed(extension, chromium_h1, tab_id())); | 315 EXPECT_FALSE(IsAllowed(extension, chromium_h1, tab_id())); |
320 } | 316 } |
321 | 317 |
322 } // namespace | 318 } // namespace |
323 } // namespace extensions | 319 } // namespace extensions |
OLD | NEW |