OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "base/logging.h" |
| 6 #include "chrome/browser/extensions/extension_apitest.h" |
| 7 #include "chrome/browser/extensions/extension_service.h" |
| 8 #include "chrome/browser/extensions/extension_system.h" |
| 9 #include "chrome/browser/ui/browser.h" |
| 10 #include "chrome/browser/ui/browser_tabstrip.h" |
| 11 #include "chrome/common/extensions/extension.h" |
| 12 #include "chrome/test/base/ui_test_utils.h" |
| 13 |
| 14 namespace extensions { |
| 15 namespace { |
| 16 |
| 17 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ActiveTab) { |
| 18 ASSERT_TRUE(StartTestServer()); |
| 19 |
| 20 const Extension* extension = |
| 21 LoadExtension(test_data_dir_.AppendASCII("active_tab")); |
| 22 ASSERT_TRUE(extension); |
| 23 |
| 24 ExtensionService* service = |
| 25 ExtensionSystem::Get(browser()->profile())->extension_service(); |
| 26 |
| 27 // Shouldn't be initially granted based on activeTab. |
| 28 { |
| 29 ResultCatcher catcher; |
| 30 ui_test_utils::NavigateToURL(browser(), test_server()->GetURL("page.html")); |
| 31 EXPECT_TRUE(catcher.GetNextResult()) << message_; |
| 32 } |
| 33 |
| 34 // Granting to the extension should give it access to page.html. |
| 35 { |
| 36 ResultCatcher catcher; |
| 37 service->toolbar_model()->ExecuteBrowserAction(extension, browser(), NULL); |
| 38 EXPECT_TRUE(catcher.GetNextResult()) << message_; |
| 39 } |
| 40 |
| 41 // Changing page should go back to it not having access. |
| 42 { |
| 43 ResultCatcher catcher; |
| 44 ui_test_utils::NavigateToURL(browser(), |
| 45 test_server()->GetURL("final_page.html")); |
| 46 EXPECT_TRUE(catcher.GetNextResult()) << message_; |
| 47 } |
| 48 } |
| 49 |
| 50 } // namespace |
| 51 } // namespace extensions |
OLD | NEW |