OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/utf_string_conversions.h" | 5 #include "base/utf_string_conversions.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/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
9 #include "chrome/common/chrome_notification_types.h" | 9 #include "chrome/common/chrome_notification_types.h" |
| 10 #include "chrome/common/chrome_switches.h" |
10 #include "chrome/common/extensions/extension.h" | 11 #include "chrome/common/extensions/extension.h" |
11 #include "chrome/test/base/ui_test_utils.h" | 12 #include "chrome/test/base/ui_test_utils.h" |
12 #include "content/browser/tab_contents/tab_contents.h" | 13 #include "content/browser/tab_contents/tab_contents.h" |
13 #include "googleurl/src/gurl.h" | 14 #include "googleurl/src/gurl.h" |
14 #include "net/base/mock_host_resolver.h" | 15 #include "net/base/mock_host_resolver.h" |
15 | 16 |
16 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentScriptAllFrames) { | 17 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentScriptAllFrames) { |
17 ASSERT_TRUE(StartTestServer()); | 18 ASSERT_TRUE(StartTestServer()); |
18 ASSERT_TRUE(RunExtensionTest("content_scripts/all_frames")) << message_; | 19 ASSERT_TRUE(RunExtensionTest("content_scripts/all_frames")) << message_; |
19 } | 20 } |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 ASSERT_TRUE(styles_injected); | 108 ASSERT_TRUE(styles_injected); |
108 } | 109 } |
109 | 110 |
110 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentScriptCSSLocalization) { | 111 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentScriptCSSLocalization) { |
111 ASSERT_TRUE(StartTestServer()); | 112 ASSERT_TRUE(StartTestServer()); |
112 ASSERT_TRUE(RunExtensionTest("content_scripts/css_l10n")) << message_; | 113 ASSERT_TRUE(RunExtensionTest("content_scripts/css_l10n")) << message_; |
113 } | 114 } |
114 | 115 |
115 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentScriptExtensionAPIs) { | 116 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentScriptExtensionAPIs) { |
116 ASSERT_TRUE(StartTestServer()); | 117 ASSERT_TRUE(StartTestServer()); |
117 LoadExtension(test_data_dir_.AppendASCII("content_scripts/extension_api")); | 118 |
| 119 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 120 switches::kEnableExperimentalExtensionApis); |
| 121 const Extension* extension = LoadExtension( |
| 122 test_data_dir_.AppendASCII("content_scripts/extension_api")); |
| 123 |
118 ResultCatcher catcher; | 124 ResultCatcher catcher; |
119 ui_test_utils::NavigateToURL( | 125 ui_test_utils::NavigateToURL( |
120 browser(), test_server()->GetURL("functions.html")); | 126 browser(), test_server()->GetURL("functions.html")); |
121 EXPECT_TRUE(catcher.GetNextResult()); | 127 EXPECT_TRUE(catcher.GetNextResult()); |
| 128 |
| 129 // Navigate to a page that will cause a content script to run that starts |
| 130 // listening for an extension event. |
| 131 ui_test_utils::NavigateToURL( |
| 132 browser(), test_server()->GetURL("events.html")); |
| 133 |
| 134 // Navigate to an extension page that will fire the event events.js is |
| 135 // listening for. |
| 136 ui_test_utils::NavigateToURLWithDisposition( |
| 137 browser(), extension->GetResourceURL("fire_event.html"), |
| 138 NEW_FOREGROUND_TAB, ui_test_utils::BROWSER_TEST_NONE); |
| 139 EXPECT_TRUE(catcher.GetNextResult()); |
122 } | 140 } |
OLD | NEW |