| 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 "base/logging.h" | 5 #include "base/logging.h" |
| 6 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" | 6 #include "chrome/browser/extensions/extension_action_runner.h" |
| 7 #include "chrome/browser/extensions/extension_apitest.h" | 7 #include "chrome/browser/extensions/extension_apitest.h" |
| 8 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
| 9 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 9 #include "chrome/test/base/ui_test_utils.h" | 10 #include "chrome/test/base/ui_test_utils.h" |
| 10 #include "extensions/common/extension.h" | 11 #include "extensions/common/extension.h" |
| 11 #include "extensions/test/result_catcher.h" | 12 #include "extensions/test/result_catcher.h" |
| 12 #include "net/test/embedded_test_server/embedded_test_server.h" | 13 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 13 | 14 |
| 14 namespace extensions { | 15 namespace extensions { |
| 15 namespace { | 16 namespace { |
| 16 | 17 |
| 17 // Times out on win syzyasan, http://crbug.com/166026 | 18 // Times out on win syzyasan, http://crbug.com/166026 |
| 18 #if defined(SYZYASAN) | 19 #if defined(SYZYASAN) |
| (...skipping 14 matching lines...) Expand all Loading... |
| 33 ui_test_utils::NavigateToURL( | 34 ui_test_utils::NavigateToURL( |
| 34 browser(), | 35 browser(), |
| 35 embedded_test_server()->GetURL( | 36 embedded_test_server()->GetURL( |
| 36 "/extensions/api_test/active_tab/page.html")); | 37 "/extensions/api_test/active_tab/page.html")); |
| 37 EXPECT_TRUE(catcher.GetNextResult()) << message_; | 38 EXPECT_TRUE(catcher.GetNextResult()) << message_; |
| 38 } | 39 } |
| 39 | 40 |
| 40 // Granting to the extension should give it access to page.html. | 41 // Granting to the extension should give it access to page.html. |
| 41 { | 42 { |
| 42 ResultCatcher catcher; | 43 ResultCatcher catcher; |
| 43 ExtensionActionAPI::Get(browser()->profile())->ExecuteExtensionAction( | 44 ExtensionActionRunner::GetForWebContents( |
| 44 extension, browser(), true); | 45 browser()->tab_strip_model()->GetActiveWebContents()) |
| 46 ->RunAction(extension, true); |
| 45 EXPECT_TRUE(catcher.GetNextResult()) << message_; | 47 EXPECT_TRUE(catcher.GetNextResult()) << message_; |
| 46 } | 48 } |
| 47 | 49 |
| 48 // Changing page should go back to it not having access. | 50 // Changing page should go back to it not having access. |
| 49 { | 51 { |
| 50 ResultCatcher catcher; | 52 ResultCatcher catcher; |
| 51 ui_test_utils::NavigateToURL( | 53 ui_test_utils::NavigateToURL( |
| 52 browser(), | 54 browser(), |
| 53 embedded_test_server()->GetURL( | 55 embedded_test_server()->GetURL( |
| 54 "/extensions/api_test/active_tab/final_page.html")); | 56 "/extensions/api_test/active_tab/final_page.html")); |
| 55 EXPECT_TRUE(catcher.GetNextResult()) << message_; | 57 EXPECT_TRUE(catcher.GetNextResult()) << message_; |
| 56 } | 58 } |
| 57 } | 59 } |
| 58 | 60 |
| 59 } // namespace | 61 } // namespace |
| 60 } // namespace extensions | 62 } // namespace extensions |
| OLD | NEW |