| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/strings/string_number_conversions.h" | 6 #include "base/strings/string_number_conversions.h" |
| 7 #include "chrome/common/chrome_switches.h" | 7 #include "chrome/common/chrome_switches.h" |
| 8 #include "chrome/common/extensions/extension.h" | 8 #include "chrome/common/extensions/extension.h" |
| 9 #include "chrome/common/extensions/extension_manifest_constants.h" | 9 #include "chrome/common/extensions/extension_manifest_constants.h" |
| 10 #include "chrome/common/extensions/manifest_handlers/content_scripts_handler.h" | 10 #include "chrome/common/extensions/manifest_handlers/content_scripts_handler.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 | 42 |
| 43 LoadAndExpectSuccess("ports_in_content_scripts.json"); | 43 LoadAndExpectSuccess("ports_in_content_scripts.json"); |
| 44 } | 44 } |
| 45 | 45 |
| 46 TEST_F(ContentScriptsManifestTest, OnChromeUrlsWithFlag) { | 46 TEST_F(ContentScriptsManifestTest, OnChromeUrlsWithFlag) { |
| 47 CommandLine::ForCurrentProcess()->AppendSwitch( | 47 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 48 switches::kExtensionsOnChromeURLs); | 48 switches::kExtensionsOnChromeURLs); |
| 49 scoped_refptr<Extension> extension = | 49 scoped_refptr<Extension> extension = |
| 50 LoadAndExpectSuccess("content_script_chrome_url_invalid.json"); | 50 LoadAndExpectSuccess("content_script_chrome_url_invalid.json"); |
| 51 const GURL newtab_url("chrome://newtab/"); | 51 const GURL newtab_url("chrome://newtab/"); |
| 52 EXPECT_TRUE(ContentScriptsInfo::ExtensionHasScriptAtURL(extension, | 52 EXPECT_TRUE( |
| 53 newtab_url)); | 53 ContentScriptsInfo::ExtensionHasScriptAtURL(extension.get(), newtab_url)); |
| 54 } | 54 } |
| 55 | 55 |
| 56 TEST_F(ContentScriptsManifestTest, ScriptableHosts) { | 56 TEST_F(ContentScriptsManifestTest, ScriptableHosts) { |
| 57 // TODO(yoz): Test GetScriptableHosts. | 57 // TODO(yoz): Test GetScriptableHosts. |
| 58 scoped_refptr<Extension> extension = | 58 scoped_refptr<Extension> extension = |
| 59 LoadAndExpectSuccess("content_script_yahoo.json"); | 59 LoadAndExpectSuccess("content_script_yahoo.json"); |
| 60 URLPatternSet scriptable_hosts = | 60 URLPatternSet scriptable_hosts = |
| 61 ContentScriptsInfo::GetScriptableHosts(extension); | 61 ContentScriptsInfo::GetScriptableHosts(extension.get()); |
| 62 | 62 |
| 63 URLPatternSet expected; | 63 URLPatternSet expected; |
| 64 expected.AddPattern( | 64 expected.AddPattern( |
| 65 URLPattern(URLPattern::SCHEME_HTTP, "http://yahoo.com/*")); | 65 URLPattern(URLPattern::SCHEME_HTTP, "http://yahoo.com/*")); |
| 66 | 66 |
| 67 EXPECT_EQ(expected, scriptable_hosts); | 67 EXPECT_EQ(expected, scriptable_hosts); |
| 68 } | 68 } |
| 69 | 69 |
| 70 } // namespace extensions | 70 } // namespace extensions |
| OLD | NEW |