Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(639)

Side by Side Diff: chrome/renderer/chrome_content_renderer_client_unittest.cc

Issue 2154233003: Rewrite YouTube Flash embeds (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 // youtube-nocookie.com
475 {"http://www.youtube-nocookie.com/v/123/",
476 "http://www.youtube-nocookie.com/embed/123/"},
477 // youtube-nocookie.com, isn't using flash
478 {"http://www.youtube-nocookie.com/embed/123/", ""},
479 // youtube-nocookie.com, has JS API enabled
480 {"http://www.youtube-nocookie.com/v/123?enablejsapi=1", ""},
481 // youtube-nocookie.com, has one parameter
482 {"http://www.youtube-nocookie.com/v/123?start=foo",
483 "http://www.youtube-nocookie.com/embed/123?start=foo"},
484 // youtube-nocookie.com, has multiple parameters
485 {"http://www.youtube-nocookie.com/v/123?start=foo&bar=baz",
486 "http://www.youtube-nocookie.com/embed/123?start=foo&bar=baz"},
487 // youtube-nocookie.com, invalid parameter construct, has one parameter
488 {"http://www.youtube-nocookie.com/v/123&start=foo",
489 "http://www.youtube-nocookie.com/embed/123?start=foo"},
490 // youtube-nocookie.com, invalid parameter construct, has multiple
491 // parameters
492 {"http://www.youtube-nocookie.com/v/123&start=foo&bar=baz",
493 "http://www.youtube-nocookie.com/embed/123?start=foo&bar=baz"},
494 // youtube-nocookie.com, https
495 {"https://www.youtube-nocookie.com/v/123/",
496 "https://www.youtube-nocookie.com/embed/123/"},
497 };
498
499 ChromeContentRendererClient client;
500
501 for (const auto& data : test_data)
502 EXPECT_EQ(GURL(data.expected),
503 client.OverrideFlashEmbedWithHTML(GURL(data.original)));
504 }
OLDNEW
« no previous file with comments | « chrome/renderer/chrome_content_renderer_client_browsertest.cc ('k') | chrome/test/data/flash_embeds.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698