Index: content/renderer/manifest/manifest_parser_unittest.cc |
diff --git a/content/renderer/manifest/manifest_parser_unittest.cc b/content/renderer/manifest/manifest_parser_unittest.cc |
index 8b21c69d5d3e225f69d251ff3cd8e447bfada1a8..14a4310d6c6c51474fc55ddc7af0c1d9a3f6b396 100644 |
--- a/content/renderer/manifest/manifest_parser_unittest.cc |
+++ b/content/renderer/manifest/manifest_parser_unittest.cc |
@@ -982,6 +982,58 @@ TEST_F(ManifestParserTest, IconPurposeParseRules) { |
} |
} |
+TEST_F(ManifestParserTest, ShareTargetParseRules) { |
+ // Contains share_target field but no keys. |
+ { |
+ Manifest manifest = ParseManifest("{ \"share_target\": {} }"); |
+ EXPECT_TRUE(manifest.share_target.is_null()); |
+ EXPECT_TRUE(manifest.IsEmpty()); |
+ EXPECT_EQ(0u, GetErrorCount()); |
+ } |
+ |
+ // Contains share_target and url_template, but url_template is empty. |
+ { |
+ Manifest manifest = |
+ ParseManifest("{ \"share_target\": { \"url_template\": \"\" } }"); |
+ EXPECT_TRUE( |
+ base::EqualsASCII(manifest.share_target.url_template.string(), "")); |
+ EXPECT_FALSE(manifest.IsEmpty()); |
+ EXPECT_EQ(0u, GetErrorCount()); |
+ } |
+ |
+ // Don't parse if property isn't a string. |
+ { |
+ Manifest manifest = |
+ ParseManifest("{ \"share_target\": { \"url_template\": {} } }"); |
+ EXPECT_TRUE(manifest.share_target.is_null()); |
+ ASSERT_TRUE(manifest.IsEmpty()); |
+ EXPECT_EQ(1u, GetErrorCount()); |
+ EXPECT_EQ("property 'url_template' ignored, type string expected.", |
+ errors()[0]); |
+ } |
+ |
+ // Don't parse if property isn't a string. |
+ { |
+ Manifest manifest = |
+ ParseManifest("{ \"share_target\": { \"url_template\": 42 } }"); |
+ EXPECT_TRUE(manifest.share_target.is_null()); |
+ ASSERT_TRUE(manifest.IsEmpty()); |
+ EXPECT_EQ(1u, GetErrorCount()); |
+ EXPECT_EQ("property 'url_template' ignored, type string expected.", |
+ errors()[0]); |
+ } |
+ |
+ // Contains share_target and url_template, and url_template is valid template. |
Matt Giuca
2017/01/18 07:51:32
What if it's an invalid template? Is it expected t
constantina
2017/01/18 23:28:10
Test added. We will let it parse correctly, at lea
|
+ { |
+ Manifest manifest = ParseManifest( |
+ "{ \"share_target\": {\"url_template\": \"share/?title={title}\" } }"); |
+ EXPECT_TRUE(base::EqualsASCII(manifest.share_target.url_template.string(), |
+ "share/?title={title}")); |
+ EXPECT_FALSE(manifest.IsEmpty()); |
+ EXPECT_EQ(0u, GetErrorCount()); |
+ } |
+} |
+ |
TEST_F(ManifestParserTest, RelatedApplicationsParseRules) { |
// If no application, empty list. |
{ |