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, invalid parameter construct | |
433 {"http://www.youtube.com/embed/deadbeef&start=4", ""}, | |
434 // URL is using Flash, no www | |
435 {"http://youtube.com/v/deadbeef", "http://youtube.com/embed/deadbeef"}, | |
436 // URL is using Flash, has JS API enabled | |
437 {"http://www.youtube.com/v/deadbeef?enablejsapi=1", ""}, | |
438 // URL is using Flash, is valid, https | |
439 {"https://www.youtube.com/v/deadbeef", | |
440 "https://www.youtube.com/embed/deadbeef"}, | |
441 // URL is using Flash, is valid, http | |
442 {"http://www.youtube.com/v/deadbeef", | |
443 "http://www.youtube.com/embed/deadbeef"}, | |
444 // URL is using Flash, is valid, not a complete URL, no www or protocol | |
445 {"youtube.com/v/deadbeef", ""}, | |
446 // URL is using Flash, is valid, not a complete URL,or protocol | |
447 {"www.youtube.com/v/deadbeef", ""}, | |
448 // URL is using Flash, valid | |
449 {"https://www.foo.youtube.com/v/deadbeef", | |
450 "https://www.foo.youtube.com/embed/deadbeef"}, | |
451 // URL is using Flash, is valid, has one parameter | |
452 {"http://www.youtube.com/v/deadbeef?start=4", | |
453 "http://www.youtube.com/embed/deadbeef?start=4"}, | |
454 // URL is using Flash, is valid, has multiple parameters | |
455 {"http://www.youtube.com/v/deadbeef?start=4&fs=1", | |
456 "http://www.youtube.com/embed/deadbeef?start=4&fs=1"}, | |
457 // URL is using Flash, invalid parameter construct, has one parameter | |
458 {"http://www.youtube.com/v/deadbeef&start=4", | |
459 "http://www.youtube.com/embed/deadbeef?start=4"}, | |
460 // URL is using Flash, invalid parameter construct, has multiple | |
461 // 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, invalid parameter construct, has multiple | |
465 // parameters | |
466 {"http://www.youtube.com/v/deadbeef&start=4&fs=1", | |
467 "http://www.youtube.com/embed/deadbeef?start=4&fs=1"}, | |
468 // Invalid parameter construct | |
469 {"http://www.youtube.com/abcd/v/deadbeef", ""}, | |
470 // Invalid parameter construct | |
471 {"http://www.youtube.com/v/abcd/", "http://www.youtube.com/embed/abcd/"}, | |
472 // Invalid parameter construct | |
473 {"http://www.youtube.com/v/123/", "http://www.youtube.com/embed/123/"}, | |
474 }; | |
475 | |
476 ChromeContentRendererClient client; | |
477 | |
478 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.
| |
479 EXPECT_EQ(GURL(data.expected), | |
480 client.OverrideFlashEmbedWithHTML(GURL(data.original))); | |
481 } | |
OLD | NEW |