Chromium Code Reviews| Index: chrome/browser/extensions/active_tab_unittest.cc |
| diff --git a/chrome/browser/extensions/active_tab_unittest.cc b/chrome/browser/extensions/active_tab_unittest.cc |
| index 93bd889d4ab37ede451f9ac9847d4cc4a0731352..162b25d9049e3239c442671832bc7a1b8579349d 100644 |
| --- a/chrome/browser/extensions/active_tab_unittest.cc |
| +++ b/chrome/browser/extensions/active_tab_unittest.cc |
| @@ -39,10 +39,13 @@ namespace { |
| scoped_refptr<const Extension> CreateTestExtension( |
| const std::string& id, |
| - bool has_active_tab_permission) { |
| + bool has_active_tab_permission, |
| + bool has_tab_capture_permission) { |
| ListBuilder permissions; |
| if (has_active_tab_permission) |
| permissions.Append("activeTab"); |
| + if (has_tab_capture_permission) |
| + permissions.Append("tabCapture"); |
| return ExtensionBuilder() |
| .SetManifest(DictionaryBuilder() |
| .Set("name", "Extension with ID " + id) |
| @@ -56,9 +59,14 @@ scoped_refptr<const Extension> CreateTestExtension( |
| class ActiveTabTest : public ChromeRenderViewHostTestHarness { |
| protected: |
| ActiveTabTest() |
| - : extension(CreateTestExtension("deadbeef", true)), |
| - another_extension(CreateTestExtension("feedbeef", true)), |
| - extension_without_active_tab(CreateTestExtension("badbeef", false)) {} |
| + : extension(CreateTestExtension("deadbeef", true, false)), |
| + another_extension(CreateTestExtension("feedbeef", true, false)), |
| + extension_without_active_tab(CreateTestExtension("badbeef", |
| + false, |
| + false)), |
| + extension_with_tab_capture(CreateTestExtension("cafebeef", |
| + true, |
| + true)) {} |
| virtual void SetUp() OVERRIDE { |
| ChromeRenderViewHostTestHarness::SetUp(); |
| @@ -122,6 +130,9 @@ class ActiveTabTest : public ChromeRenderViewHostTestHarness { |
| // An extension without the activeTab permission. |
| scoped_refptr<const Extension> extension_without_active_tab; |
| + |
| + // An extension with both the activeTab and tabCapture permission. |
| + scoped_refptr<const Extension> extension_with_tab_capture; |
| }; |
| TEST_F(ActiveTabTest, GrantToSinglePage) { |
| @@ -241,7 +252,8 @@ TEST_F(ActiveTabTest, Uninstalling) { |
| active_tab_permission_granter()->GrantIfRequested(extension.get()); |
| - EXPECT_TRUE(active_tab_permission_granter()->IsGranted(extension.get())); |
| + EXPECT_TRUE(ActiveTabPermissionGranter::IsGrantedForTab(extension.get(), |
| + web_contents())); |
| EXPECT_TRUE(IsAllowed(extension, google)); |
| // Uninstalling the extension should clear its tab permissions. |
| @@ -253,7 +265,6 @@ TEST_F(ActiveTabTest, Uninstalling) { |
| web_contents()->GetBrowserContext())), |
| content::Details<UnloadedExtensionInfo>(&details)); |
| - EXPECT_FALSE(active_tab_permission_granter()->IsGranted(extension.get())); |
| // Note: can't EXPECT_FALSE(IsAllowed) here because uninstalled extensions |
| // are just that... considered to be uninstalled, and the manager might |
| // just ignore them from here on. |
| @@ -261,7 +272,8 @@ TEST_F(ActiveTabTest, Uninstalling) { |
| // Granting the extension again should give them back. |
| active_tab_permission_granter()->GrantIfRequested(extension.get()); |
| - EXPECT_TRUE(active_tab_permission_granter()->IsGranted(extension.get())); |
| + EXPECT_TRUE(ActiveTabPermissionGranter::IsGrantedForTab(extension.get(), |
| + web_contents())); |
| EXPECT_TRUE(IsAllowed(extension, google)); |
| } |
| @@ -319,5 +331,25 @@ TEST_F(ActiveTabTest, NavigateInPage) { |
| EXPECT_FALSE(IsAllowed(extension, chromium_h1, tab_id())); |
| } |
| +// TODO(justinlin): Enable when tabCapture API is moved to stable. |
|
not at google - send to devlin
2013/09/13 22:09:45
could you use ScopedCurrentChannel in feature_chan
justinlin
2013/09/13 22:47:15
Done.
|
| +TEST_F(ActiveTabTest, DISABLED_ChromeUrlGrants) { |
| + GURL internal("chrome://version"); |
| + NavigateAndCommit(internal); |
| + active_tab_permission_granter()->GrantIfRequested( |
| + extension_with_tab_capture.get()); |
| + // Do not grant tabs/hosts permissions for tab. |
| + EXPECT_TRUE(IsBlocked(extension_with_tab_capture, internal, tab_id())); |
| + EXPECT_TRUE(PermissionsData::HasAPIPermissionForTab( |
| + extension_with_tab_capture.get(), |
| + tab_id(), |
| + APIPermission::kTabCaptureForTab)); |
| + |
| + EXPECT_TRUE(IsBlocked(extension_with_tab_capture, internal, tab_id() + 1)); |
| + EXPECT_FALSE(PermissionsData::HasAPIPermissionForTab( |
| + extension_with_tab_capture.get(), |
| + tab_id() + 1, |
| + APIPermission::kTabCaptureForTab)); |
| +} |
| + |
| } // namespace |
| } // namespace extensions |