Chromium Code Reviews| 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 898916fbe7657a8be1d6a079058986f32b62f16a..f09390e494718f2c34b2bbf40acb1bc981b6ced1 100644 |
| --- a/chrome/renderer/chrome_content_renderer_client_unittest.cc |
| +++ b/chrome/renderer/chrome_content_renderer_client_unittest.cc |
| @@ -408,3 +408,74 @@ TEST_F(ChromeContentRendererClientTest, ShouldSuppressErrorPage) { |
| SearchBouncer::GetInstance()->OnSetSearchURLs( |
| std::vector<GURL>(), GURL::EmptyGURL()); |
| } |
| + |
| +TEST_F(ChromeContentRendererClientTest, RewriteYouTubeFlashEmbed) { |
| + struct TestData { |
| + std::string original; |
| + std::string expected; |
| + } test_data[] = { |
| + // { original, expected } |
| + {"youtube.com", ""}, |
| + {"www.youtube.com", ""}, |
| + {"http://www.youtube.com", ""}, |
| + {"https://www.youtube.com", ""}, |
| + {"http://www.foo.youtube.com", ""}, |
| + {"https://www.foo.youtube.com", ""}, |
| + // Non-YouTube domains shouldn't be modified |
| + {"http://www.plus.google.com", ""}, |
| + // URL isn't using Flash |
| + {"http://www.youtube.com/embed/deadbeef", ""}, |
| + // URL isn't using Flash, no www |
| + {"http://youtube.com/embed/deadbeef", ""}, |
| + // URL isn't using Flash, has JS API enabled |
| + {"http://www.youtube.com/embed/deadbeef?enablejsapi=1", ""}, |
| + // URL isn't using Flash, invalid parameter construct |
| + {"http://www.youtube.com/embed/deadbeef&start=4", ""}, |
| + // URL is using Flash, no www |
| + {"http://youtube.com/v/deadbeef", "http://youtube.com/embed/deadbeef"}, |
| + // URL is using Flash, has JS API enabled |
| + {"http://www.youtube.com/v/deadbeef?enablejsapi=1", ""}, |
| + // URL is using Flash, is valid, https |
| + {"https://www.youtube.com/v/deadbeef", |
| + "https://www.youtube.com/embed/deadbeef"}, |
| + // URL is using Flash, is valid, http |
| + {"http://www.youtube.com/v/deadbeef", |
| + "http://www.youtube.com/embed/deadbeef"}, |
| + // URL is using Flash, is valid, not a complete URL, no www or protocol |
| + {"youtube.com/v/deadbeef", ""}, |
| + // URL is using Flash, is valid, not a complete URL,or protocol |
| + {"www.youtube.com/v/deadbeef", ""}, |
| + // URL is using Flash, valid |
| + {"https://www.foo.youtube.com/v/deadbeef", |
| + "https://www.foo.youtube.com/embed/deadbeef"}, |
| + // URL is using Flash, is valid, has one parameter |
| + {"http://www.youtube.com/v/deadbeef?start=4", |
| + "http://www.youtube.com/embed/deadbeef?start=4"}, |
| + // URL is using Flash, is valid, has multiple parameters |
| + {"http://www.youtube.com/v/deadbeef?start=4&fs=1", |
| + "http://www.youtube.com/embed/deadbeef?start=4&fs=1"}, |
| + // URL is using Flash, invalid parameter construct, has one parameter |
| + {"http://www.youtube.com/v/deadbeef&start=4", |
| + "http://www.youtube.com/embed/deadbeef?start=4"}, |
| + // URL is using Flash, invalid parameter construct, has multiple |
| + // parameters |
| + {"http://www.youtube.com/v/deadbeef&start=4&fs=1?foo=bar", |
| + "http://www.youtube.com/embed/deadbeef?start=4&fs=1&foo=bar"}, |
| + // URL is using Flash, invalid parameter construct, has multiple |
| + // parameters |
| + {"http://www.youtube.com/v/deadbeef&start=4&fs=1", |
| + "http://www.youtube.com/embed/deadbeef?start=4&fs=1"}, |
| + // Invalid parameter construct |
| + {"http://www.youtube.com/abcd/v/deadbeef", ""}, |
| + // Invalid parameter construct |
| + {"http://www.youtube.com/v/abcd/", "http://www.youtube.com/embed/abcd/"}, |
| + // Invalid parameter construct |
| + {"http://www.youtube.com/v/123/", "http://www.youtube.com/embed/123/"}, |
| + }; |
| + |
| + ChromeContentRendererClient client; |
| + |
| + for (auto data : test_data) |
|
mlamouri (slow - plz ping)
2016/08/08 12:45:17
const auto&
kdsilva
2016/08/08 19:09:04
Done.
|
| + EXPECT_EQ(GURL(data.expected), |
| + client.OverrideFlashEmbedWithHTML(GURL(data.original))); |
| +} |