| 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 4419ac5de2c243a9c5004c4a0f17b79373b88689..fd47fe211c833a30b53f0328828b30d9d44e1af7 100644
|
| --- a/content/renderer/manifest/manifest_parser_unittest.cc
|
| +++ b/content/renderer/manifest/manifest_parser_unittest.cc
|
| @@ -66,6 +66,8 @@ TEST_F(ManifestParserTest, EmptyStringNull) {
|
| ASSERT_TRUE(manifest.start_url.is_empty());
|
| ASSERT_EQ(manifest.display, Manifest::DISPLAY_MODE_UNSPECIFIED);
|
| ASSERT_EQ(manifest.orientation, blink::WebScreenOrientationLockDefault);
|
| + ASSERT_TRUE(manifest.gcm_sender_id.is_null());
|
| + ASSERT_FALSE(manifest.gcm_user_visible_only);
|
| }
|
|
|
| TEST_F(ManifestParserTest, ValidNoContentParses) {
|
| @@ -81,14 +83,16 @@ TEST_F(ManifestParserTest, ValidNoContentParses) {
|
| ASSERT_TRUE(manifest.start_url.is_empty());
|
| ASSERT_EQ(manifest.display, Manifest::DISPLAY_MODE_UNSPECIFIED);
|
| ASSERT_EQ(manifest.orientation, blink::WebScreenOrientationLockDefault);
|
| + ASSERT_TRUE(manifest.gcm_sender_id.is_null());
|
| + ASSERT_FALSE(manifest.gcm_user_visible_only);
|
| }
|
|
|
| TEST_F(ManifestParserTest, MultipleErrorsReporting) {
|
| Manifest manifest = ParseManifest("{ \"name\": 42, \"short_name\": 4,"
|
| "\"orientation\": {}, \"display\": \"foo\", \"start_url\": null,"
|
| - "\"icons\": {} }");
|
| + "\"icons\": {}, \"gcm_user_visible_only\": 42 }");
|
|
|
| - EXPECT_EQ(6u, GetErrorCount());
|
| + EXPECT_EQ(7u, GetErrorCount());
|
|
|
| EXPECT_EQ("Manifest parsing error: property 'name' ignored,"
|
| " type string expected.",
|
| @@ -107,6 +111,9 @@ TEST_F(ManifestParserTest, MultipleErrorsReporting) {
|
| EXPECT_EQ("Manifest parsing error: property 'icons' ignored, "
|
| "type array expected.",
|
| errors()[5]);
|
| + EXPECT_EQ("Manifest parsing error: property 'gcm_user_visible_only' ignored, "
|
| + "type boolean expected.",
|
| + errors()[6]);
|
| }
|
|
|
| TEST_F(ManifestParserTest, NameParseRules) {
|
| @@ -793,7 +800,7 @@ TEST_F(ManifestParserTest, GCMSenderIDParseRules) {
|
| EXPECT_EQ(0u, GetErrorCount());
|
| }
|
|
|
| - // Don't parse if property isn't a string.
|
| + // Don't parse if the property isn't a string.
|
| {
|
| Manifest manifest = ParseManifest("{ \"gcm_sender_id\": {} }");
|
| EXPECT_TRUE(manifest.gcm_sender_id.is_null());
|
| @@ -812,4 +819,50 @@ TEST_F(ManifestParserTest, GCMSenderIDParseRules) {
|
| }
|
| }
|
|
|
| +TEST_F(ManifestParserTest, GCMUserVisibleOnlyParseRules) {
|
| + // Smoke test.
|
| + {
|
| + Manifest manifest = ParseManifest("{ \"gcm_user_visible_only\": true }");
|
| + EXPECT_TRUE(manifest.gcm_user_visible_only);
|
| + EXPECT_EQ(0u, GetErrorCount());
|
| + }
|
| +
|
| + // Don't parse if the property isn't a boolean.
|
| + {
|
| + Manifest manifest = ParseManifest("{ \"gcm_user_visible_only\": {} }");
|
| + EXPECT_FALSE(manifest.gcm_user_visible_only);
|
| + EXPECT_EQ(1u, GetErrorCount());
|
| + EXPECT_EQ(
|
| + "Manifest parsing error: property 'gcm_user_visible_only' ignored,"
|
| + " type boolean expected.",
|
| + errors()[0]);
|
| + }
|
| + {
|
| + Manifest manifest = ParseManifest(
|
| + "{ \"gcm_user_visible_only\": \"true\" }");
|
| + EXPECT_FALSE(manifest.gcm_user_visible_only);
|
| + EXPECT_EQ(1u, GetErrorCount());
|
| + EXPECT_EQ(
|
| + "Manifest parsing error: property 'gcm_user_visible_only' ignored,"
|
| + " type boolean expected.",
|
| + errors()[0]);
|
| + }
|
| + {
|
| + Manifest manifest = ParseManifest("{ \"gcm_user_visible_only\": 1 }");
|
| + EXPECT_FALSE(manifest.gcm_user_visible_only);
|
| + EXPECT_EQ(1u, GetErrorCount());
|
| + EXPECT_EQ(
|
| + "Manifest parsing error: property 'gcm_user_visible_only' ignored,"
|
| + " type boolean expected.",
|
| + errors()[0]);
|
| + }
|
| +
|
| + // "False" should set the boolean false without throwing errors.
|
| + {
|
| + Manifest manifest = ParseManifest("{ \"gcm_user_visible_only\": false }");
|
| + EXPECT_FALSE(manifest.gcm_user_visible_only);
|
| + EXPECT_EQ(0u, GetErrorCount());
|
| + }
|
| +}
|
| +
|
| } // namespace content
|
|
|