OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/renderer/chrome_content_renderer_client.h" | 5 #include "chrome/renderer/chrome_content_renderer_client.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 ChromeContentRendererClient client; | 401 ChromeContentRendererClient client; |
402 SearchBouncer::GetInstance()->OnSetSearchURLs( | 402 SearchBouncer::GetInstance()->OnSetSearchURLs( |
403 std::vector<GURL>(), GURL("http://example.com/n")); | 403 std::vector<GURL>(), GURL("http://example.com/n")); |
404 EXPECT_FALSE(client.ShouldSuppressErrorPage(nullptr, | 404 EXPECT_FALSE(client.ShouldSuppressErrorPage(nullptr, |
405 GURL("http://example.com"))); | 405 GURL("http://example.com"))); |
406 EXPECT_TRUE(client.ShouldSuppressErrorPage(nullptr, | 406 EXPECT_TRUE(client.ShouldSuppressErrorPage(nullptr, |
407 GURL("http://example.com/n"))); | 407 GURL("http://example.com/n"))); |
408 SearchBouncer::GetInstance()->OnSetSearchURLs( | 408 SearchBouncer::GetInstance()->OnSetSearchURLs( |
409 std::vector<GURL>(), GURL::EmptyGURL()); | 409 std::vector<GURL>(), GURL::EmptyGURL()); |
410 } | 410 } |
| 411 |
| 412 TEST_F(ChromeContentRendererClientTest, RewriteYouTubeFlashEmbed) { |
| 413 struct TestData { |
| 414 std::string original; |
| 415 std::string expected; |
| 416 } test_data[] = { |
| 417 // { original, expected } |
| 418 { "youtube.com", "" }, |
| 419 { "www.youtube.com", "" }, |
| 420 { "http://www.youtube.com", "" }, |
| 421 { "https://www.youtube.com", "" }, |
| 422 { "http://www.foo.youtube.com", "" }, |
| 423 { "https://www.foo.youtube.com", "" }, |
| 424 // Non-YouTube domains shouldn't be modified |
| 425 { "http://www.plus.google.com", "" }, |
| 426 // URL isn't using Flash |
| 427 { "http://www.youtube.com/embed/deadbeef", "" }, |
| 428 // URL isn't using Flash, no www |
| 429 { "http://youtube.com/embed/deadbeef", "" }, |
| 430 // URL isn't using Flash, has JS API enabled |
| 431 { "http://www.youtube.com/embed/deadbeef?enablejsapi=1", "" }, |
| 432 // URL isn't using Flash, is invalid |
| 433 { "http://www.youtube.com/embed/deadbeef&start=4", "" }, |
| 434 // URL is using Flash, no www |
| 435 { "http://youtube.com/v/deadbeef", |
| 436 "http://youtube.com/embed/deadbeef" }, |
| 437 // URL is using Flash, has JS API enabled |
| 438 { "http://www.youtube.com/v/deadbeef?enablejsapi=1", "" }, |
| 439 // URL is using Flash, is valid, https |
| 440 { "https://www.youtube.com/v/deadbeef", |
| 441 "https://www.youtube.com/embed/deadbeef" }, |
| 442 // URL is using Flash, is valid, http |
| 443 { "http://www.youtube.com/v/deadbeef", |
| 444 "http://www.youtube.com/embed/deadbeef" }, |
| 445 // URL is using Flash, is valid, not a complete URL, no www or protocol |
| 446 { "youtube.com/v/deadbeef", "" }, |
| 447 // URL is using Flash, is valid, not a complete URL,or protocol |
| 448 { "www.youtube.com/v/deadbeef", "" }, |
| 449 // URL is using Flash, valid |
| 450 { "https://www.foo.youtube.com/v/deadbeef", |
| 451 "https://www.foo.youtube.com/embed/deadbeef" }, |
| 452 // URL is using Flash, is valid, has one parameter |
| 453 { "http://www.youtube.com/v/deadbeef?start=4", |
| 454 "http://www.youtube.com/embed/deadbeef?start=4" }, |
| 455 // URL is using Flash, is valid, has multiple parameters |
| 456 { "http://www.youtube.com/v/deadbeef?start=4&fs=1", |
| 457 "http://www.youtube.com/embed/deadbeef?start=4&fs=1" }, |
| 458 // URL is using Flash, is invalid, has one parameter |
| 459 { "http://www.youtube.com/v/deadbeef&start=4", |
| 460 "http://www.youtube.com/embed/deadbeef?start=4" }, |
| 461 // URL is using Flash, is invalid, has multiple parameters |
| 462 { "http://www.youtube.com/v/deadbeef&start=4&fs=1?foo=bar", |
| 463 "http://www.youtube.com/embed/deadbeef?start=4&fs=1&foo=bar" }, |
| 464 // URL is using Flash, is invalid, has multiple parameters |
| 465 { "http://www.youtube.com/v/deadbeef&start=4&fs=1", |
| 466 "http://www.youtube.com/embed/deadbeef?start=4&fs=1" }, |
| 467 // URL is invalid |
| 468 { "http://www.youtube.com/abcd/v/deadbeef", "" }, |
| 469 // URL is valid |
| 470 { "http://www.youtube.com/v/abcd/", "http://www.youtube.com/embed/abcd/" }, |
| 471 // URL is valid |
| 472 { "http://www.youtube.com/v/123/", "http://www.youtube.com/embed/123/" }, |
| 473 }; |
| 474 |
| 475 ChromeContentRendererClient client; |
| 476 |
| 477 for (auto data : test_data) |
| 478 EXPECT_EQ(data.expected, client.OverrideFlashEmbedWithHTML(data.original)); |
| 479 } |
OLD | NEW |