| 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 "chrome/browser/extensions/extension_apitest.h" | 6 #include "chrome/browser/extensions/extension_apitest.h" |
| 6 #include "chrome/browser/extensions/extension_service.h" | 7 #include "chrome/browser/extensions/extension_service.h" |
| 7 #include "content/browser/tab_contents/tab_contents.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/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 "content/browser/tab_contents/tab_contents.h" |
| 12 #include "googleurl/src/gurl.h" | 13 #include "googleurl/src/gurl.h" |
| 13 #include "net/base/mock_host_resolver.h" | 14 #include "net/base/mock_host_resolver.h" |
| 14 | 15 |
| 15 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentScriptAllFrames) { | 16 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentScriptAllFrames) { |
| 16 ASSERT_TRUE(StartTestServer()); | 17 ASSERT_TRUE(StartTestServer()); |
| 17 ASSERT_TRUE(RunExtensionTest("content_scripts/all_frames")) << message_; | 18 ASSERT_TRUE(RunExtensionTest("content_scripts/all_frames")) << message_; |
| 18 } | 19 } |
| 19 | 20 |
| 20 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentScriptAboutBlankIframes) { | 21 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentScriptAboutBlankIframes) { |
| 21 ASSERT_TRUE(StartTestServer()); | 22 ASSERT_TRUE(StartTestServer()); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 52 } | 53 } |
| 53 | 54 |
| 54 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentScriptIgnoreHostPermissions) { | 55 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentScriptIgnoreHostPermissions) { |
| 55 host_resolver()->AddRule("a.com", "127.0.0.1"); | 56 host_resolver()->AddRule("a.com", "127.0.0.1"); |
| 56 host_resolver()->AddRule("b.com", "127.0.0.1"); | 57 host_resolver()->AddRule("b.com", "127.0.0.1"); |
| 57 ASSERT_TRUE(StartTestServer()); | 58 ASSERT_TRUE(StartTestServer()); |
| 58 ASSERT_TRUE(RunExtensionTest( | 59 ASSERT_TRUE(RunExtensionTest( |
| 59 "content_scripts/dont_match_host_permissions")) << message_; | 60 "content_scripts/dont_match_host_permissions")) << message_; |
| 60 } | 61 } |
| 61 | 62 |
| 63 IN_PROC_BROWSER_TEST_F( |
| 64 ExtensionApiTest, ContentScriptInjectedIntoMultipartPage) { |
| 65 ASSERT_TRUE(StartTestServer()); |
| 66 |
| 67 // Start with a renderer already open at a URL. |
| 68 GURL url(test_server()->GetURL("multipart-slow")); |
| 69 ui_test_utils::NavigateToURL(browser(), url); |
| 70 |
| 71 string16 title; |
| 72 ui_test_utils::GetCurrentTabTitle(browser(), &title); |
| 73 EXPECT_EQ(std::string("PASS"), UTF16ToUTF8(title)); |
| 74 } |
| 75 |
| 62 // crbug.com/39249 -- content scripts js should not run on view source. | 76 // crbug.com/39249 -- content scripts js should not run on view source. |
| 63 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentScriptViewSource) { | 77 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentScriptViewSource) { |
| 64 ASSERT_TRUE(StartTestServer()); | 78 ASSERT_TRUE(StartTestServer()); |
| 65 ASSERT_TRUE(RunExtensionTest("content_scripts/view_source")) << message_; | 79 ASSERT_TRUE(RunExtensionTest("content_scripts/view_source")) << message_; |
| 66 } | 80 } |
| 67 | 81 |
| 68 IN_PROC_BROWSER_TEST_F( | 82 IN_PROC_BROWSER_TEST_F( |
| 69 ExtensionApiTest, ContentScriptStylesInjectedIntoExistingRenderers) { | 83 ExtensionApiTest, ContentScriptStylesInjectedIntoExistingRenderers) { |
| 70 ASSERT_TRUE(StartTestServer()); | 84 ASSERT_TRUE(StartTestServer()); |
| 71 | 85 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 90 L"document.defaultView.getComputedStyle(document.body, null)." | 104 L"document.defaultView.getComputedStyle(document.body, null)." |
| 91 L"getPropertyValue('background-color') == 'rgb(255, 0, 0)')", | 105 L"getPropertyValue('background-color') == 'rgb(255, 0, 0)')", |
| 92 &styles_injected)); | 106 &styles_injected)); |
| 93 ASSERT_TRUE(styles_injected); | 107 ASSERT_TRUE(styles_injected); |
| 94 } | 108 } |
| 95 | 109 |
| 96 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentScriptCSSLocalization) { | 110 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentScriptCSSLocalization) { |
| 97 ASSERT_TRUE(StartTestServer()); | 111 ASSERT_TRUE(StartTestServer()); |
| 98 ASSERT_TRUE(RunExtensionTest("content_scripts/css_l10n")) << message_; | 112 ASSERT_TRUE(RunExtensionTest("content_scripts/css_l10n")) << message_; |
| 99 } | 113 } |
| OLD | NEW |