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

Side by Side Diff: chrome/browser/plugins/plugin_power_saver_browsertest.cc

Issue 2342893003: Plugin Power Saver Tiny: Fix Field Trial testing config (Closed)
Patch Set: Fix prerender tests Created 4 years, 3 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
« no previous file with comments | « no previous file | chrome/test/data/prerender/prerender_plugin_delay_load.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 <stdint.h> 5 #include <stdint.h>
6 #include <string> 6 #include <string>
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/feature_list.h"
11 #include "base/stl_util.h" 10 #include "base/stl_util.h"
12 #include "base/strings/string_piece.h" 11 #include "base/strings/string_piece.h"
13 #include "base/strings/stringprintf.h" 12 #include "base/strings/stringprintf.h"
13 #include "base/test/scoped_feature_list.h"
14 #include "build/build_config.h" 14 #include "build/build_config.h"
15 #include "chrome/browser/ui/browser.h" 15 #include "chrome/browser/ui/browser.h"
16 #include "chrome/browser/ui/browser_window.h" 16 #include "chrome/browser/ui/browser_window.h"
17 #include "chrome/browser/ui/tabs/tab_strip_model.h" 17 #include "chrome/browser/ui/tabs/tab_strip_model.h"
18 #include "chrome/common/chrome_features.h" 18 #include "chrome/common/chrome_features.h"
19 #include "chrome/common/chrome_switches.h" 19 #include "chrome/common/chrome_switches.h"
20 #include "chrome/test/base/in_process_browser_test.h" 20 #include "chrome/test/base/in_process_browser_test.h"
21 #include "chrome/test/base/test_switches.h" 21 #include "chrome/test/base/test_switches.h"
22 #include "chrome/test/base/ui_test_utils.h" 22 #include "chrome/test/base/ui_test_utils.h"
23 #include "components/zoom/zoom_controller.h" 23 #include "components/zoom/zoom_controller.h"
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 407
408 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, EssentialPlugins) { 408 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, EssentialPlugins) {
409 LoadHTML( 409 LoadHTML(
410 "<object id='small_same_origin' data='fake.swf' " 410 "<object id='small_same_origin' data='fake.swf' "
411 " type='application/x-ppapi-tests' width='400' height='100'>" 411 " type='application/x-ppapi-tests' width='400' height='100'>"
412 "</object>" 412 "</object>"
413 "<object id='small_same_origin_poster' data='fake.swf' " 413 "<object id='small_same_origin_poster' data='fake.swf' "
414 " type='application/x-ppapi-tests' width='400' height='100' " 414 " type='application/x-ppapi-tests' width='400' height='100' "
415 " poster='click_me.png'>" 415 " poster='click_me.png'>"
416 "</object>" 416 "</object>"
417 "<object id='tiny_cross_origin_1' data='http://a.com/fake.swf' "
418 " type='application/x-ppapi-tests' width='3' height='3'>"
419 "</object>"
420 "<object id='tiny_cross_origin_2' data='http://a.com/fake.swf' "
421 " type='application/x-ppapi-tests' width='1' height='1'>"
422 "</object>"
423 "<object id='large_cross_origin' data='http://b.com/fake.swf' " 417 "<object id='large_cross_origin' data='http://b.com/fake.swf' "
424 " type='application/x-ppapi-tests' width='400' height='500'>" 418 " type='application/x-ppapi-tests' width='400' height='500'>"
425 "</object>" 419 "</object>"
426 "<object id='medium_16_9_cross_origin' data='http://c.com/fake.swf' " 420 "<object id='medium_16_9_cross_origin' data='http://c.com/fake.swf' "
427 " type='application/x-ppapi-tests' width='480' height='270'>" 421 " type='application/x-ppapi-tests' width='480' height='270'>"
428 "</object>"); 422 "</object>");
429 423
430 VerifyPluginMarkedEssential(GetActiveWebContents(), "small_same_origin"); 424 VerifyPluginMarkedEssential(GetActiveWebContents(), "small_same_origin");
431 VerifyPluginMarkedEssential(GetActiveWebContents(), 425 VerifyPluginMarkedEssential(GetActiveWebContents(),
432 "small_same_origin_poster"); 426 "small_same_origin_poster");
433 VerifyPluginMarkedEssential(GetActiveWebContents(), "tiny_cross_origin_1");
434 VerifyPluginMarkedEssential(GetActiveWebContents(), "tiny_cross_origin_2");
435 VerifyPluginMarkedEssential(GetActiveWebContents(), "large_cross_origin"); 427 VerifyPluginMarkedEssential(GetActiveWebContents(), "large_cross_origin");
436 VerifyPluginMarkedEssential(GetActiveWebContents(), 428 VerifyPluginMarkedEssential(GetActiveWebContents(),
437 "medium_16_9_cross_origin"); 429 "medium_16_9_cross_origin");
438 } 430 }
439 431
440 // Flaky on WebKit Mac dbg bots: crbug.com/599484. 432 // Flaky on WebKit Mac dbg bots: crbug.com/599484.
441 #if defined(OS_MACOSX) 433 #if defined(OS_MACOSX)
442 #define MAYBE_SmallCrossOrigin DISABLED_SmallCrossOrigin 434 #define MAYBE_SmallCrossOrigin DISABLED_SmallCrossOrigin
443 #else 435 #else
444 #define MAYBE_SmallCrossOrigin SmallCrossOrigin 436 #define MAYBE_SmallCrossOrigin SmallCrossOrigin
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, ZoomIndependent) { 652 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, ZoomIndependent) {
661 zoom::ZoomController::FromWebContents(GetActiveWebContents()) 653 zoom::ZoomController::FromWebContents(GetActiveWebContents())
662 ->SetZoomLevel(4.0); 654 ->SetZoomLevel(4.0);
663 LoadHTML( 655 LoadHTML(
664 "<object id='plugin' data='http://otherorigin.com/fake.swf' " 656 "<object id='plugin' data='http://otherorigin.com/fake.swf' "
665 " type='application/x-ppapi-tests' width='400' height='200'>" 657 " type='application/x-ppapi-tests' width='400' height='200'>"
666 "</object>"); 658 "</object>");
667 VerifyPluginIsThrottled(GetActiveWebContents(), "plugin"); 659 VerifyPluginIsThrottled(GetActiveWebContents(), "plugin");
668 } 660 }
669 661
670 // Separate test case that blocks tiny plugins. This requires a separate test 662 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, BlockTinyPlugins) {
671 // case, because we need to initialize the renderer with a different feature
672 // setting.
673 class PluginPowerSaverBlockTinyBrowserTest
674 : public PluginPowerSaverBrowserTest {
675 public:
676 void SetUp() override {
677 base::FeatureList::ClearInstanceForTesting();
678 PluginPowerSaverBrowserTest::SetUp();
679 }
680 void SetUpInProcessBrowserTestFixture() override {
681 base::FeatureList::ClearInstanceForTesting();
682 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList);
683 feature_list->InitializeFromCommandLine(features::kBlockSmallContent.name,
684 std::string());
685 base::FeatureList::SetInstance(std::move(feature_list));
686 }
687 };
688
689 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBlockTinyBrowserTest, BlockTinyPlugins) {
690 LoadHTML( 663 LoadHTML(
691 "<object id='tiny_same_origin' data='fake.swf' " 664 "<object id='tiny_same_origin' data='fake.swf' "
692 " type='application/x-ppapi-tests' width='3' height='3'>" 665 " type='application/x-ppapi-tests' width='3' height='3'>"
693 "</object>" 666 "</object>"
694 "<object id='tiny_cross_origin_1' data='http://a.com/fake.swf' " 667 "<object id='tiny_cross_origin_1' data='http://a.com/fake.swf' "
695 " type='application/x-ppapi-tests' width='3' height='3'>" 668 " type='application/x-ppapi-tests' width='3' height='3'>"
696 "</object>" 669 "</object>"
697 "<object id='tiny_cross_origin_2' data='http://a.com/fake.swf' " 670 "<object id='tiny_cross_origin_2' data='http://a.com/fake.swf' "
698 " type='application/x-ppapi-tests' width='1' height='1'>" 671 " type='application/x-ppapi-tests' width='1' height='1'>"
699 "</object>"); 672 "</object>");
700 673
701 VerifyPluginMarkedEssential(GetActiveWebContents(), "tiny_same_origin"); 674 VerifyPluginMarkedEssential(GetActiveWebContents(), "tiny_same_origin");
702 VerifyPluginIsPlaceholderOnly("tiny_cross_origin_1"); 675 VerifyPluginIsPlaceholderOnly("tiny_cross_origin_1");
703 VerifyPluginIsPlaceholderOnly("tiny_cross_origin_2"); 676 VerifyPluginIsPlaceholderOnly("tiny_cross_origin_2");
704 } 677 }
705 678
706 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBlockTinyBrowserTest, 679 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, BackgroundTabTinyPlugins) {
707 BackgroundTabTinyPlugins) {
708 content::WebContents* background_contents = LoadHTMLInBackgroundTab( 680 content::WebContents* background_contents = LoadHTMLInBackgroundTab(
709 "<object id='tiny' data='http://a.com/fake.swf' " 681 "<object id='tiny' data='http://a.com/fake.swf' "
710 " type='application/x-ppapi-tests' width='3' height='3'>" 682 " type='application/x-ppapi-tests' width='3' height='3'>"
711 "</object>"); 683 "</object>");
712 EXPECT_FALSE(PluginLoaded(background_contents, "tiny")); 684 EXPECT_FALSE(PluginLoaded(background_contents, "tiny"));
713 685
714 ActivateTab(background_contents); 686 ActivateTab(background_contents);
715 VerifyPluginIsPlaceholderOnly("tiny"); 687 VerifyPluginIsPlaceholderOnly("tiny");
716 } 688 }
717 689
718 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBlockTinyBrowserTest, 690 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, ExpandingTinyPlugins) {
719 ExpandingTinyPlugins) {
720 LoadHTML( 691 LoadHTML(
721 "<object id='expand_to_peripheral' data='http://a.com/fake.swf' " 692 "<object id='expand_to_peripheral' data='http://a.com/fake.swf' "
722 " type='application/x-ppapi-tests' width='4' height='4'></object>" 693 " type='application/x-ppapi-tests' width='4' height='4'></object>"
723 "<object id='expand_to_essential' data='http://b.com/fake.swf' " 694 "<object id='expand_to_essential' data='http://b.com/fake.swf' "
724 " type='application/x-ppapi-tests' width='4' height='4'></object>"); 695 " type='application/x-ppapi-tests' width='4' height='4'></object>");
725 696
726 VerifyPluginIsPlaceholderOnly("expand_to_peripheral"); 697 VerifyPluginIsPlaceholderOnly("expand_to_peripheral");
727 VerifyPluginIsPlaceholderOnly("expand_to_essential"); 698 VerifyPluginIsPlaceholderOnly("expand_to_essential");
728 699
729 std::string script = 700 std::string script =
730 "window.document.getElementById('expand_to_peripheral').height = 200;" 701 "window.document.getElementById('expand_to_peripheral').height = 200;"
731 "window.document.getElementById('expand_to_peripheral').width = 200;" 702 "window.document.getElementById('expand_to_peripheral').width = 200;"
732 "window.document.getElementById('expand_to_essential').height = 400;" 703 "window.document.getElementById('expand_to_essential').height = 400;"
733 "window.document.getElementById('expand_to_essential').width = 400;"; 704 "window.document.getElementById('expand_to_essential').width = 400;";
734 ASSERT_TRUE(content::ExecuteScript(GetActiveWebContents(), script)); 705 ASSERT_TRUE(content::ExecuteScript(GetActiveWebContents(), script));
735 706
736 VerifyPluginIsThrottled(GetActiveWebContents(), "expand_to_peripheral"); 707 VerifyPluginIsThrottled(GetActiveWebContents(), "expand_to_peripheral");
737 VerifyPluginMarkedEssential(GetActiveWebContents(), "expand_to_essential"); 708 VerifyPluginMarkedEssential(GetActiveWebContents(), "expand_to_essential");
738 } 709 }
710
711 // Separate test case that allows tiny plugins. This requires a separate test
712 // case, because we need to initialize the renderer with a different feature
713 // setting.
714 class PluginPowerSaverAllowTinyBrowserTest
715 : public PluginPowerSaverBrowserTest {
716 public:
717 void SetUpInProcessBrowserTestFixture() override {
718 feature_list.InitAndDisableFeature(features::kBlockSmallContent);
719 }
720
721 private:
722 base::test::ScopedFeatureList feature_list;
723 };
724
725 IN_PROC_BROWSER_TEST_F(PluginPowerSaverAllowTinyBrowserTest,
726 EssentialTinyPlugins) {
727 LoadHTML(
728 "<object id='tiny_cross_origin_1' data='http://a.com/fake.swf' "
729 " type='application/x-ppapi-tests' width='3' height='3'>"
730 "</object>"
731 "<object id='tiny_cross_origin_2' data='http://a.com/fake.swf' "
732 " type='application/x-ppapi-tests' width='1' height='1'>"
733 "</object>");
734
735 VerifyPluginMarkedEssential(GetActiveWebContents(), "tiny_cross_origin_1");
736 VerifyPluginMarkedEssential(GetActiveWebContents(), "tiny_cross_origin_2");
737 }
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/prerender/prerender_plugin_delay_load.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698