| 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 .Set("permissions", permissions)) | 51 .Set("permissions", permissions)) |
| 52 .SetID(id) | 52 .SetID(id) |
| 53 .Build(); | 53 .Build(); |
| 54 } | 54 } |
| 55 | 55 |
| 56 class ActiveTabTest : public ChromeRenderViewHostTestHarness { | 56 class ActiveTabTest : public ChromeRenderViewHostTestHarness { |
| 57 public: | 57 public: |
| 58 ActiveTabTest() | 58 ActiveTabTest() |
| 59 : extension(CreateTestExtension("deadbeef", true)), | 59 : extension(CreateTestExtension("deadbeef", true)), |
| 60 another_extension(CreateTestExtension("feedbeef", true)), | 60 another_extension(CreateTestExtension("feedbeef", true)), |
| 61 extension_without_active_tab(CreateTestExtension("badbeef", false)), | 61 extension_without_active_tab(CreateTestExtension("badbeef", false)) {} |
| 62 ui_thread_(BrowserThread::UI, MessageLoop::current()) {} | |
| 63 | 62 |
| 64 protected: | 63 protected: |
| 65 virtual void SetUp() OVERRIDE { | 64 virtual void SetUp() OVERRIDE { |
| 66 ChromeRenderViewHostTestHarness::SetUp(); | 65 ChromeRenderViewHostTestHarness::SetUp(); |
| 67 TabHelper::CreateForWebContents(web_contents()); | 66 TabHelper::CreateForWebContents(web_contents()); |
| 68 } | 67 } |
| 69 | 68 |
| 70 int tab_id() { | 69 int tab_id() { |
| 71 return SessionID::IdForTab(web_contents()); | 70 return SessionID::IdForTab(web_contents()); |
| 72 } | 71 } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 } | 116 } |
| 118 | 117 |
| 119 // An extension with the activeTab permission. | 118 // An extension with the activeTab permission. |
| 120 scoped_refptr<const Extension> extension; | 119 scoped_refptr<const Extension> extension; |
| 121 | 120 |
| 122 // Another extension with activeTab (for good measure). | 121 // Another extension with activeTab (for good measure). |
| 123 scoped_refptr<const Extension> another_extension; | 122 scoped_refptr<const Extension> another_extension; |
| 124 | 123 |
| 125 // An extension without the activeTab permission. | 124 // An extension without the activeTab permission. |
| 126 scoped_refptr<const Extension> extension_without_active_tab; | 125 scoped_refptr<const Extension> extension_without_active_tab; |
| 127 | |
| 128 private: | |
| 129 content::TestBrowserThread ui_thread_; | |
| 130 }; | 126 }; |
| 131 | 127 |
| 132 TEST_F(ActiveTabTest, GrantToSinglePage) { | 128 TEST_F(ActiveTabTest, GrantToSinglePage) { |
| 133 GURL google("http://www.google.com"); | 129 GURL google("http://www.google.com"); |
| 134 NavigateAndCommit(google); | 130 NavigateAndCommit(google); |
| 135 | 131 |
| 136 // No access unless it's been granted. | 132 // No access unless it's been granted. |
| 137 EXPECT_TRUE(IsBlocked(extension, google)); | 133 EXPECT_TRUE(IsBlocked(extension, google)); |
| 138 EXPECT_TRUE(IsBlocked(another_extension, google)); | 134 EXPECT_TRUE(IsBlocked(another_extension, google)); |
| 139 EXPECT_TRUE(IsBlocked(extension_without_active_tab, google)); | 135 EXPECT_TRUE(IsBlocked(extension_without_active_tab, google)); |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 Reload(); | 316 Reload(); |
| 321 | 317 |
| 322 EXPECT_FALSE(IsAllowed(extension, google, tab_id())); | 318 EXPECT_FALSE(IsAllowed(extension, google, tab_id())); |
| 323 EXPECT_FALSE(IsAllowed(extension, google_h1, tab_id())); | 319 EXPECT_FALSE(IsAllowed(extension, google_h1, tab_id())); |
| 324 EXPECT_FALSE(IsAllowed(extension, chromium, tab_id())); | 320 EXPECT_FALSE(IsAllowed(extension, chromium, tab_id())); |
| 325 EXPECT_FALSE(IsAllowed(extension, chromium_h1, tab_id())); | 321 EXPECT_FALSE(IsAllowed(extension, chromium_h1, tab_id())); |
| 326 } | 322 } |
| 327 | 323 |
| 328 } // namespace | 324 } // namespace |
| 329 } // namespace extensions | 325 } // namespace extensions |
| OLD | NEW |