| OLD | NEW |
| 1 // Copyright (c) 2012 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 "chrome/common/extensions/manifest_tests/extension_manifest_test.h" | 5 #include "chrome/common/extensions/manifest_tests/extension_manifest_test.h" |
| 6 | 6 |
| 7 #include "base/strings/string_number_conversions.h" | 7 #include "base/string_number_conversions.h" |
| 8 #include "chrome/common/extensions/api/content_scripts/content_scripts_handler.h
" |
| 8 #include "chrome/common/extensions/extension.h" | 9 #include "chrome/common/extensions/extension.h" |
| 9 #include "chrome/common/extensions/extension_manifest_constants.h" | 10 #include "chrome/common/extensions/extension_manifest_constants.h" |
| 10 #include "extensions/common/error_utils.h" | 11 #include "extensions/common/error_utils.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 13 |
| 13 namespace errors = extension_manifest_errors; | 14 namespace errors = extension_manifest_errors; |
| 14 | 15 |
| 15 TEST_F(ExtensionManifestTest, ContentScriptMatchPattern) { | 16 namespace extensions { |
| 17 |
| 18 class ContentScriptsManifestTest : public ExtensionManifestTest { |
| 19 protected: |
| 20 virtual void SetUp() OVERRIDE { |
| 21 ExtensionManifestTest::SetUp(); |
| 22 (new ContentScriptsHandler)->Register(); |
| 23 } |
| 24 }; |
| 25 |
| 26 TEST_F(ContentScriptsManifestTest, ContentScriptMatchPattern) { |
| 16 Testcase testcases[] = { | 27 Testcase testcases[] = { |
| 17 // chrome:// urls are not allowed. | 28 // chrome:// urls are not allowed. |
| 18 Testcase("content_script_chrome_url_invalid.json", | 29 Testcase("content_script_chrome_url_invalid.json", |
| 19 extensions::ErrorUtils::FormatErrorMessage( | 30 ErrorUtils::FormatErrorMessage( |
| 20 errors::kInvalidMatch, | 31 errors::kInvalidMatch, |
| 21 base::IntToString(0), | 32 base::IntToString(0), |
| 22 base::IntToString(0), | 33 base::IntToString(0), |
| 23 URLPattern::GetParseResultString( | 34 URLPattern::GetParseResultString( |
| 24 URLPattern::PARSE_ERROR_INVALID_SCHEME))), | 35 URLPattern::PARSE_ERROR_INVALID_SCHEME))), |
| 25 | 36 |
| 26 // Match paterns must be strings. | 37 // Match paterns must be strings. |
| 27 Testcase("content_script_match_pattern_not_string.json", | 38 Testcase("content_script_match_pattern_not_string.json", |
| 28 extensions::ErrorUtils::FormatErrorMessage(errors::kInvalidMatch, | 39 ErrorUtils::FormatErrorMessage(errors::kInvalidMatch, |
| 29 base::IntToString(0), | 40 base::IntToString(0), |
| 30 base::IntToString(0), | 41 base::IntToString(0), |
| 31 errors::kExpectString)) | 42 errors::kExpectString)) |
| 32 }; | 43 }; |
| 33 RunTestcases(testcases, arraysize(testcases), | 44 RunTestcases(testcases, arraysize(testcases), |
| 34 EXPECT_TYPE_ERROR); | 45 EXPECT_TYPE_ERROR); |
| 35 | 46 |
| 36 LoadAndExpectSuccess("ports_in_content_scripts.json"); | 47 LoadAndExpectSuccess("ports_in_content_scripts.json"); |
| 37 } | 48 } |
| 49 |
| 50 } // namespace extensions |
| OLD | NEW |