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/extension_apitest.h" | 6 #include "chrome/browser/extensions/extension_apitest.h" |
7 #include "chrome/browser/extensions/extension_service.h" | 7 #include "chrome/browser/extensions/extension_service.h" |
8 #include "chrome/browser/extensions/extension_system.h" | 8 #include "chrome/browser/extensions/extension_system.h" |
9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
10 #include "chrome/common/extensions/extension.h" | 10 #include "chrome/common/extensions/extension.h" |
11 #include "chrome/test/base/ui_test_utils.h" | 11 #include "chrome/test/base/ui_test_utils.h" |
| 12 #include "net/test/embedded_test_server/embedded_test_server.h" |
12 | 13 |
13 namespace extensions { | 14 namespace extensions { |
14 namespace { | 15 namespace { |
15 | 16 |
16 // Times out on win asan, http://crbug.com/166026 | 17 // Times out on win asan, http://crbug.com/166026 |
17 #if defined(OS_WIN) && defined(ADDRESS_SANITIZER) | 18 #if defined(OS_WIN) && defined(ADDRESS_SANITIZER) |
18 #define MAYBE_ActiveTab DISABLED_ActiveTab | 19 #define MAYBE_ActiveTab DISABLED_ActiveTab |
19 #else | 20 #else |
20 #define MAYBE_ActiveTab ActiveTab | 21 #define MAYBE_ActiveTab ActiveTab |
21 #endif | 22 #endif |
22 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_ActiveTab) { | 23 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_ActiveTab) { |
23 ASSERT_TRUE(StartTestServer()); | 24 ASSERT_TRUE(StartEmbeddedTestServer()); |
24 | 25 |
25 const Extension* extension = | 26 const Extension* extension = |
26 LoadExtension(test_data_dir_.AppendASCII("active_tab")); | 27 LoadExtension(test_data_dir_.AppendASCII("active_tab")); |
27 ASSERT_TRUE(extension); | 28 ASSERT_TRUE(extension); |
28 | 29 |
29 ExtensionService* service = | 30 ExtensionService* service = |
30 ExtensionSystem::Get(browser()->profile())->extension_service(); | 31 ExtensionSystem::Get(browser()->profile())->extension_service(); |
31 | 32 |
32 // Shouldn't be initially granted based on activeTab. | 33 // Shouldn't be initially granted based on activeTab. |
33 { | 34 { |
34 ResultCatcher catcher; | 35 ResultCatcher catcher; |
35 ui_test_utils::NavigateToURL(browser(), test_server()->GetURL("page.html")); | 36 ui_test_utils::NavigateToURL( |
| 37 browser(), |
| 38 embedded_test_server()->GetURL( |
| 39 "/extensions/api_test/active_tab/page.html")); |
36 EXPECT_TRUE(catcher.GetNextResult()) << message_; | 40 EXPECT_TRUE(catcher.GetNextResult()) << message_; |
37 } | 41 } |
38 | 42 |
39 // Granting to the extension should give it access to page.html. | 43 // Granting to the extension should give it access to page.html. |
40 { | 44 { |
41 ResultCatcher catcher; | 45 ResultCatcher catcher; |
42 service->toolbar_model()->ExecuteBrowserAction(extension, browser(), NULL); | 46 service->toolbar_model()->ExecuteBrowserAction(extension, browser(), NULL); |
43 EXPECT_TRUE(catcher.GetNextResult()) << message_; | 47 EXPECT_TRUE(catcher.GetNextResult()) << message_; |
44 } | 48 } |
45 | 49 |
46 // Changing page should go back to it not having access. | 50 // Changing page should go back to it not having access. |
47 { | 51 { |
48 ResultCatcher catcher; | 52 ResultCatcher catcher; |
49 ui_test_utils::NavigateToURL(browser(), | 53 ui_test_utils::NavigateToURL( |
50 test_server()->GetURL("final_page.html")); | 54 browser(), |
| 55 embedded_test_server()->GetURL( |
| 56 "/extensions/api_test/active_tab/final_page.html")); |
51 EXPECT_TRUE(catcher.GetNextResult()) << message_; | 57 EXPECT_TRUE(catcher.GetNextResult()) << message_; |
52 } | 58 } |
53 } | 59 } |
54 | 60 |
55 } // namespace | 61 } // namespace |
56 } // namespace extensions | 62 } // namespace extensions |
OLD | NEW |