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 0e500aec9e2c2bce3f123bbd36cd2b8d1ecc2f07..4ab92863772309182ab87f56dc799945b9c07df3 100644 |
--- a/content/renderer/manifest/manifest_parser_unittest.cc |
+++ b/content/renderer/manifest/manifest_parser_unittest.cc |
@@ -7,6 +7,7 @@ |
#include "base/strings/string_util.h" |
#include "content/public/common/manifest.h" |
#include "testing/gtest/include/gtest/gtest.h" |
+#include "third_party/WebKit/public/web/WebRuntimeFeatures.h" |
namespace content { |
@@ -160,4 +161,45 @@ TEST_F(ManifestParserTest, StartURLParseRules) { |
} |
} |
+TEST_F(ManifestParserTest, GCMSenderIDParseRules) { |
+ bool push_messaging_enabled = |
+ blink::WebRuntimeFeatures::isPushMessagingEnabled(); |
+ |
+ blink::WebRuntimeFeatures::enablePushMessaging(true); |
+ |
+ // Smoke test. |
+ { |
+ Manifest manifest = ParseManifest("{ \"gcm_sender_id\": \"foo\" }"); |
+ ASSERT_TRUE(EqualsASCII(manifest.gcm_sender_id.string(), "foo")); |
+ } |
+ |
+ // Trim whitespaces. |
+ { |
+ Manifest manifest = ParseManifest("{ \"gcm_sender_id\": \" foo \" }"); |
+ ASSERT_TRUE(EqualsASCII(manifest.gcm_sender_id.string(), "foo")); |
+ } |
+ |
+ // Don't parse if name isn't a string. |
+ { |
+ Manifest manifest = ParseManifest("{ \"gcm_sender_id\": {} }"); |
+ ASSERT_TRUE(manifest.gcm_sender_id.is_null()); |
+ } |
+ |
+ // Don't parse if name isn't a string. |
+ { |
+ Manifest manifest = ParseManifest("{ \"gcm_sender_id\": 42 }"); |
+ ASSERT_TRUE(manifest.gcm_sender_id.is_null()); |
+ } |
+ |
+ blink::WebRuntimeFeatures::enablePushMessaging(false); |
+ |
+ // Check that we don't parse it if PushMessaging isn't enabled. |
+ { |
+ Manifest manifest = ParseManifest("{ \"gcm_sender_id\": \"foo\" }"); |
+ ASSERT_TRUE(manifest.gcm_sender_id.is_null()); |
+ } |
+ |
+ blink::WebRuntimeFeatures::enablePushMessaging(push_messaging_enabled); |
+} |
+ |
} // namespace content |