| Index: chrome/renderer/chrome_content_renderer_client_unittest.cc
|
| diff --git a/chrome/renderer/chrome_content_renderer_client_unittest.cc b/chrome/renderer/chrome_content_renderer_client_unittest.cc
|
| index 915540010e9e9f142747abecc0355b42970aed6e..ca1335fda50fe38615a738f9a82ee0a704cf5e6e 100644
|
| --- a/chrome/renderer/chrome_content_renderer_client_unittest.cc
|
| +++ b/chrome/renderer/chrome_content_renderer_client_unittest.cc
|
| @@ -37,10 +37,14 @@ const bool kHostedApp = true;
|
| const char kNaClMimeType[] = "application/x-nacl";
|
| const char kExtensionUrl[] = "chrome-extension://extension_id/background.html";
|
|
|
| -const char kAllowedNaClAppURL1[] = "https://plus.google.com";
|
| -const char kAllowedNaClAppURL2[] = "https://plus.sandbox.google.com";
|
| -const char kAllowedNaClManifestURL1[] = "https://ssl.gstatic.com/s2/oz/nacl/foo";
|
| -const char kAllowedNaClManifestURL2[] = "https://ssl.gstatic.com/photos/nacl/foo";
|
| +const char kPhotosAppURL1[] = "https://foo.plus.google.com";
|
| +const char kPhotosAppURL2[] = "https://foo.plus.sandbox.google.com";
|
| +const char kPhotosManifestURL1[] = "https://ssl.gstatic.com/s2/oz/nacl/foo";
|
| +const char kPhotosManifestURL2[] = "https://ssl.gstatic.com/photos/nacl/foo";
|
| +
|
| +const char kChatAppURL1[] = "https://foo.talkgadget.google.com";
|
| +const char kChatAppURL2[] = "https://foo.talk.google.com";
|
| +const char kChatManifestURL[] = "https://ssl.gstatic.com/chat/apps/fx";
|
|
|
| bool AllowsDevInterfaces(const WebPluginParams& params) {
|
| for (size_t i = 0; i < params.attributeNames.size(); ++i) {
|
| @@ -203,46 +207,64 @@ TEST_F(ChromeContentRendererClientTest, NaClRestriction) {
|
| // interfaces. There is a whitelist for the app URL and the manifest URL.
|
| {
|
| WebPluginParams params;
|
| - // Whitelisted manifest URL #1, whitelisted app URL root #1 is allowed.
|
| + // Whitelisted Photos app is allowed (two app URLs, two manifest URLs)
|
| + EXPECT_TRUE(ChromeContentRendererClient::IsNaClAllowed(
|
| + GURL(kPhotosManifestURL1),
|
| + GURL(kPhotosAppURL1),
|
| + kNaClRestricted,
|
| + CreateExtension(kExtensionRestricted, kExtensionNotFromWebStore).get(),
|
| + ¶ms));
|
| + EXPECT_FALSE(AllowsDevInterfaces(params));
|
| EXPECT_TRUE(ChromeContentRendererClient::IsNaClAllowed(
|
| - GURL(kAllowedNaClManifestURL1),
|
| - GURL(kAllowedNaClAppURL1),
|
| + GURL(kPhotosManifestURL1),
|
| + GURL(kPhotosAppURL2),
|
| kNaClRestricted,
|
| CreateExtension(kExtensionRestricted, kExtensionNotFromWebStore).get(),
|
| ¶ms));
|
| EXPECT_FALSE(AllowsDevInterfaces(params));
|
| - // Whitelisted manifest URL #2, whitelisted app URL root #1 is allowed.
|
| EXPECT_TRUE(ChromeContentRendererClient::IsNaClAllowed(
|
| - GURL(kAllowedNaClManifestURL1),
|
| - GURL(kAllowedNaClAppURL1),
|
| + GURL(kPhotosManifestURL2),
|
| + GURL(kPhotosAppURL1),
|
| kNaClRestricted,
|
| CreateExtension(kExtensionRestricted, kExtensionNotFromWebStore).get(),
|
| ¶ms));
|
| EXPECT_FALSE(AllowsDevInterfaces(params));
|
| - // Whitelisted manifest URL #1, whitelisted app URL root #2 is allowed.
|
| EXPECT_TRUE(ChromeContentRendererClient::IsNaClAllowed(
|
| - GURL(kAllowedNaClManifestURL1),
|
| - GURL(kAllowedNaClAppURL2),
|
| + GURL(kPhotosManifestURL2),
|
| + GURL(kPhotosAppURL2),
|
| kNaClRestricted,
|
| CreateExtension(kExtensionRestricted, kExtensionNotFromWebStore).get(),
|
| ¶ms));
|
| EXPECT_FALSE(AllowsDevInterfaces(params));
|
| + // Whitelisted Chat app is allowed.
|
| + EXPECT_TRUE(ChromeContentRendererClient::IsNaClAllowed(
|
| + GURL(kChatManifestURL),
|
| + GURL(kChatAppURL1),
|
| + kNaClRestricted,
|
| + CreateExtension(kExtensionRestricted, kExtensionNotFromWebStore).get(),
|
| + ¶ms));
|
| + EXPECT_TRUE(ChromeContentRendererClient::IsNaClAllowed(
|
| + GURL(kChatManifestURL),
|
| + GURL(kChatAppURL2),
|
| + kNaClRestricted,
|
| + CreateExtension(kExtensionRestricted, kExtensionNotFromWebStore).get(),
|
| + ¶ms));
|
|
|
| // Whitelisted manifest URL, bad app URLs, NOT allowed.
|
| EXPECT_FALSE(ChromeContentRendererClient::IsNaClAllowed(
|
| - GURL(kAllowedNaClManifestURL1),
|
| + GURL(kPhotosManifestURL1),
|
| GURL("http://plus.google.com/foo"), // http scheme
|
| kNaClRestricted,
|
| CreateExtension(kExtensionRestricted, kExtensionNotFromWebStore).get(),
|
| ¶ms));
|
| EXPECT_FALSE(ChromeContentRendererClient::IsNaClAllowed(
|
| - GURL(kAllowedNaClManifestURL1),
|
| + GURL(kPhotosManifestURL1),
|
| GURL("http://plus.sandbox.google.com/foo"), // http scheme
|
| kNaClRestricted,
|
| CreateExtension(kExtensionRestricted, kExtensionNotFromWebStore).get(),
|
| ¶ms));
|
| EXPECT_FALSE(ChromeContentRendererClient::IsNaClAllowed(
|
| - GURL(kAllowedNaClManifestURL1),
|
| + GURL(kPhotosManifestURL1),
|
| GURL("https://plus.google.evil.com/foo"), // bad host
|
| kNaClRestricted,
|
| CreateExtension(kExtensionRestricted, kExtensionNotFromWebStore).get(),
|
| @@ -250,19 +272,19 @@ TEST_F(ChromeContentRendererClientTest, NaClRestriction) {
|
| // Whitelisted app URL, bad manifest URL, NOT allowed.
|
| EXPECT_FALSE(ChromeContentRendererClient::IsNaClAllowed(
|
| GURL("http://ssl.gstatic.com/s2/oz/nacl/foo"), // http scheme
|
| - GURL(kAllowedNaClAppURL1),
|
| + GURL(kPhotosAppURL1),
|
| kNaClRestricted,
|
| CreateExtension(kExtensionRestricted, kExtensionNotFromWebStore).get(),
|
| ¶ms));
|
| EXPECT_FALSE(ChromeContentRendererClient::IsNaClAllowed(
|
| GURL("https://ssl.gstatic.evil.com/s2/oz/nacl/foo"), // bad host
|
| - GURL(kAllowedNaClAppURL1),
|
| + GURL(kPhotosAppURL1),
|
| kNaClRestricted,
|
| CreateExtension(kExtensionRestricted, kExtensionNotFromWebStore).get(),
|
| ¶ms));
|
| EXPECT_FALSE(ChromeContentRendererClient::IsNaClAllowed(
|
| GURL("https://ssl.gstatic.com/wrong/s2/oz/nacl/foo"), // bad path
|
| - GURL(kAllowedNaClAppURL1),
|
| + GURL(kPhotosAppURL1),
|
| kNaClRestricted,
|
| CreateExtension(kExtensionRestricted, kExtensionNotFromWebStore).get(),
|
| ¶ms));
|
| @@ -271,8 +293,8 @@ TEST_F(ChromeContentRendererClientTest, NaClRestriction) {
|
| {
|
| WebPluginParams params;
|
| EXPECT_TRUE(ChromeContentRendererClient::IsNaClAllowed(
|
| - GURL(kAllowedNaClManifestURL1),
|
| - GURL(kAllowedNaClAppURL1),
|
| + GURL(kPhotosManifestURL1),
|
| + GURL(kPhotosAppURL1),
|
| kNaClUnrestricted,
|
| CreateExtension(kExtensionRestricted, kExtensionNotFromWebStore).get(),
|
| ¶ms));
|
| @@ -284,8 +306,8 @@ TEST_F(ChromeContentRendererClientTest, NaClRestriction) {
|
| WebPluginParams params;
|
| AddFakeDevAttribute(¶ms);
|
| EXPECT_TRUE(ChromeContentRendererClient::IsNaClAllowed(
|
| - GURL(kAllowedNaClManifestURL1),
|
| - GURL(kAllowedNaClAppURL1),
|
| + GURL(kPhotosManifestURL1),
|
| + GURL(kPhotosAppURL1),
|
| kNaClRestricted,
|
| CreateExtension(kExtensionRestricted, kExtensionNotFromWebStore).get(),
|
| ¶ms));
|
| @@ -308,14 +330,14 @@ TEST_F(ChromeContentRendererClientTest, NaClRestriction) {
|
| ¶ms));
|
| EXPECT_FALSE(ChromeContentRendererClient::IsNaClAllowed(
|
| GURL(),
|
| - GURL("https://plus.google.com.evil.com/foo3"),
|
| + GURL("https://talkgadget.google.com.evil.com/foo3"),
|
| kNaClRestricted,
|
| CreateExtension(kExtensionUnrestricted, kExtensionNotFromWebStore)
|
| .get(),
|
| ¶ms));
|
| EXPECT_FALSE(ChromeContentRendererClient::IsNaClAllowed(
|
| GURL(),
|
| - GURL("https://plus.google.com.evil.com/foo4"),
|
| + GURL("https://talkgadget.google.com.evil.com/foo4"),
|
| kNaClRestricted,
|
| CreateExtension(kExtensionUnrestricted, kExtensionFromWebStore).get(),
|
| ¶ms));
|
| @@ -342,4 +364,19 @@ TEST_F(ChromeContentRendererClientTest, NaClRestriction) {
|
| }
|
| }
|
|
|
| +TEST_F(ChromeContentRendererClientTest, AllowPepperMediaStreamAPI) {
|
| + ChromeContentRendererClient test;
|
| +#if !defined(OS_ANDROID)
|
| + EXPECT_TRUE(test.AllowPepperMediaStreamAPI(GURL(kChatAppURL1)));
|
| + EXPECT_TRUE(test.AllowPepperMediaStreamAPI(GURL(kChatAppURL2)));
|
| +#else
|
| + EXPECT_FALSE(test.AllowPepperMediaStreamAPI(GURL(kChatAppURL1)));
|
| + EXPECT_FALSE(test.AllowPepperMediaStreamAPI(GURL(kChatAppURL2)));
|
| +#endif
|
| + EXPECT_FALSE(test.AllowPepperMediaStreamAPI(
|
| + GURL("http://talkgadget.google.com")));
|
| + EXPECT_FALSE(test.AllowPepperMediaStreamAPI(
|
| + GURL("https://talkgadget.evil.com")));
|
| +}
|
| +
|
| } // namespace chrome
|
|
|