| 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/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/macros.h" | 6 #include "base/macros.h" |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 #include "chrome/browser/extensions/extension_apitest.h" | 8 #include "chrome/browser/extensions/extension_apitest.h" |
| 9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 | 64 |
| 65 scoped_refptr<const Extension> content_script_; | 65 scoped_refptr<const Extension> content_script_; |
| 66 scoped_refptr<const Extension> execute_script_; | 66 scoped_refptr<const Extension> execute_script_; |
| 67 | 67 |
| 68 DISALLOW_COPY_AND_ASSIGN(AllUrlsApiTest); | 68 DISALLOW_COPY_AND_ASSIGN(AllUrlsApiTest); |
| 69 }; | 69 }; |
| 70 | 70 |
| 71 IN_PROC_BROWSER_TEST_F(AllUrlsApiTest, WhitelistedExtension) { | 71 IN_PROC_BROWSER_TEST_F(AllUrlsApiTest, WhitelistedExtension) { |
| 72 WhitelistExtensions(); | 72 WhitelistExtensions(); |
| 73 | 73 |
| 74 auto bystander = LoadExtension( | 74 auto* bystander = LoadExtension( |
| 75 test_data_dir_.AppendASCII("all_urls").AppendASCII("bystander")); | 75 test_data_dir_.AppendASCII("all_urls").AppendASCII("bystander")); |
| 76 ASSERT_TRUE(bystander); | 76 ASSERT_TRUE(bystander); |
| 77 | 77 |
| 78 ASSERT_TRUE(StartEmbeddedTestServer()); | 78 ASSERT_TRUE(StartEmbeddedTestServer()); |
| 79 | 79 |
| 80 // Now verify that we run content scripts on different URLs, including | 80 // Now verify that we run content scripts on different URLs, including |
| 81 // internal pages, data URLs, regular HTTP pages, and resource URLs from | 81 // internal pages, data URLs, regular HTTP pages, and resource URLs from |
| 82 // extensions. | 82 // extensions. |
| 83 const std::string test_urls[] = { | 83 const std::string test_urls[] = { |
| 84 "chrome://newtab/", | 84 "chrome://newtab/", |
| 85 "data:text/html;charset=utf-8,<html>asdf</html>", | 85 "data:text/html;charset=utf-8,<html>asdf</html>", |
| 86 "chrome://version/", | 86 "chrome://version/", |
| 87 "about:blank", | 87 "about:blank", |
| 88 embedded_test_server()->GetURL(kAllUrlsTarget).spec(), | 88 embedded_test_server()->GetURL(kAllUrlsTarget).spec(), |
| 89 bystander->GetResourceURL("page.html").spec() | 89 bystander->GetResourceURL("page.html").spec() |
| 90 }; | 90 }; |
| 91 for (const auto& test_url : test_urls) | 91 for (const auto& test_url : test_urls) |
| 92 NavigateAndWait(test_url); | 92 NavigateAndWait(test_url); |
| 93 } | 93 } |
| 94 | 94 |
| 95 // Test that an extension NOT whitelisted for scripting can ask for <all_urls> | 95 // Test that an extension NOT whitelisted for scripting can ask for <all_urls> |
| 96 // and run scripts on non-restricted all pages. | 96 // and run scripts on non-restricted all pages. |
| 97 IN_PROC_BROWSER_TEST_F(AllUrlsApiTest, RegularExtensions) { | 97 IN_PROC_BROWSER_TEST_F(AllUrlsApiTest, RegularExtensions) { |
| 98 // Now verify we can script a regular http page. | 98 // Now verify we can script a regular http page. |
| 99 ASSERT_TRUE(StartEmbeddedTestServer()); | 99 ASSERT_TRUE(StartEmbeddedTestServer()); |
| 100 NavigateAndWait(embedded_test_server()->GetURL(kAllUrlsTarget).spec()); | 100 NavigateAndWait(embedded_test_server()->GetURL(kAllUrlsTarget).spec()); |
| 101 } | 101 } |
| 102 | 102 |
| 103 } // namespace extensions | 103 } // namespace extensions |
| OLD | NEW |