diff options
author | bbudge@chromium.org <bbudge@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-17 16:04:45 +0000 |
---|---|---|
committer | bbudge@chromium.org <bbudge@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-17 16:04:45 +0000 |
commit | e533ae1594f3ace2286425c2ff54ba61d6395c40 (patch) | |
tree | f066bcbfdc49eb075ac3040871af9f7d0094cc59 /chrome/renderer/chrome_content_renderer_client_unittest.cc | |
parent | c2c122a6efe14f42d0c27bec1c0b32d85aacbafa (diff) | |
download | chromium_src-e533ae1594f3ace2286425c2ff54ba61d6395c40.zip chromium_src-e533ae1594f3ace2286425c2ff54ba61d6395c40.tar.gz chromium_src-e533ae1594f3ace2286425c2ff54ba61d6395c40.tar.bz2 |
Expand whitelist for media stream APIs.
Pre-review heads up.
BUG=none
Review URL: https://chromiumcodereview.appspot.com/23466009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@223618 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/chrome_content_renderer_client_unittest.cc')
-rw-r--r-- | chrome/renderer/chrome_content_renderer_client_unittest.cc | 87 |
1 files changed, 62 insertions, 25 deletions
diff --git a/chrome/renderer/chrome_content_renderer_client_unittest.cc b/chrome/renderer/chrome_content_renderer_client_unittest.cc index 9155400..ca1335f 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 |