Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/stl_util.h" | 10 #include "base/stl_util.h" |
| 11 #include "base/strings/string_piece.h" | 11 #include "base/strings/string_piece.h" |
| 12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 13 #include "base/test/scoped_feature_list.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/content_settings/host_content_settings_map_factory.h" | 15 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| 16 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | |
| 17 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
| 18 #include "chrome/browser/ui/browser_window.h" | 17 #include "chrome/browser/ui/browser_window.h" |
| 19 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 18 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 20 #include "chrome/common/chrome_features.h" | 19 #include "chrome/common/chrome_features.h" |
| 21 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
| 22 #include "chrome/test/base/in_process_browser_test.h" | 21 #include "chrome/test/base/in_process_browser_test.h" |
| 23 #include "chrome/test/base/test_switches.h" | 22 #include "chrome/test/base/test_switches.h" |
| 24 #include "chrome/test/base/ui_test_utils.h" | 23 #include "chrome/test/base/ui_test_utils.h" |
| 25 #include "components/content_settings/core/browser/host_content_settings_map.h" | 24 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 26 #include "components/zoom/zoom_controller.h" | 25 #include "components/zoom/zoom_controller.h" |
| (...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 563 VerifyPluginIsThrottled(GetActiveWebContents(), "plugin"); | 562 VerifyPluginIsThrottled(GetActiveWebContents(), "plugin"); |
| 564 } | 563 } |
| 565 | 564 |
| 566 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, BlockTinyPlugins) { | 565 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, BlockTinyPlugins) { |
| 567 LoadHTML("/block_tiny_plugins.html"); | 566 LoadHTML("/block_tiny_plugins.html"); |
| 568 | 567 |
| 569 VerifyPluginMarkedEssential(GetActiveWebContents(), "tiny_same_origin"); | 568 VerifyPluginMarkedEssential(GetActiveWebContents(), "tiny_same_origin"); |
| 570 VerifyPluginIsPlaceholderOnly("tiny_cross_origin_1"); | 569 VerifyPluginIsPlaceholderOnly("tiny_cross_origin_1"); |
| 571 VerifyPluginIsPlaceholderOnly("tiny_cross_origin_2"); | 570 VerifyPluginIsPlaceholderOnly("tiny_cross_origin_2"); |
| 572 VerifyPluginIsPlaceholderOnly("completely_obscured"); | 571 VerifyPluginIsPlaceholderOnly("completely_obscured"); |
| 573 | |
| 574 TabSpecificContentSettings* tab_specific_content_settings = | |
| 575 TabSpecificContentSettings::FromWebContents(GetActiveWebContents()); | |
| 576 EXPECT_FALSE(tab_specific_content_settings->blocked_plugin_names().empty()); | |
|
tommycli
2017/04/20 18:42:14
This portion never flaked by coincidence, since Ve
| |
| 577 } | 572 } |
| 578 | 573 |
| 579 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, BackgroundTabTinyPlugins) { | 574 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, BackgroundTabTinyPlugins) { |
| 580 content::WebContents* background_contents = | 575 content::WebContents* background_contents = |
| 581 LoadHTMLInBackgroundTab("/background_tab_tiny_plugins.html"); | 576 LoadHTMLInBackgroundTab("/background_tab_tiny_plugins.html"); |
| 582 EXPECT_FALSE(PluginLoaded(background_contents, "tiny")); | 577 EXPECT_FALSE(PluginLoaded(background_contents, "tiny")); |
| 583 | 578 |
| 584 ActivateTab(background_contents); | 579 ActivateTab(background_contents); |
| 585 VerifyPluginIsPlaceholderOnly("tiny"); | 580 VerifyPluginIsPlaceholderOnly("tiny"); |
| 586 } | 581 } |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 610 // Although this is redundant with the Field Trial testing configuration, | 605 // Although this is redundant with the Field Trial testing configuration, |
| 611 // the official builders don't read that. | 606 // the official builders don't read that. |
| 612 feature_list.InitWithFeatures({features::kFilterSameOriginTinyPlugin}, | 607 feature_list.InitWithFeatures({features::kFilterSameOriginTinyPlugin}, |
| 613 {features::kPreferHtmlOverPlugins}); | 608 {features::kPreferHtmlOverPlugins}); |
| 614 } | 609 } |
| 615 | 610 |
| 616 private: | 611 private: |
| 617 base::test::ScopedFeatureList feature_list; | 612 base::test::ScopedFeatureList feature_list; |
| 618 }; | 613 }; |
| 619 | 614 |
| 620 // Flaky on every platform. crbug.com/680544, crbug.com/682039 | |
| 621 IN_PROC_BROWSER_TEST_F(PluginPowerSaverFilterSameOriginTinyPluginsBrowserTest, | 615 IN_PROC_BROWSER_TEST_F(PluginPowerSaverFilterSameOriginTinyPluginsBrowserTest, |
| 622 DISABLED_BlockSameOriginTinyPlugin) { | 616 BlockSameOriginTinyPlugin) { |
| 623 LoadHTML("/same_origin_tiny_plugin.html"); | 617 LoadHTML("/same_origin_tiny_plugin.html"); |
| 624 | |
| 625 VerifyPluginIsPlaceholderOnly("tiny_same_origin"); | 618 VerifyPluginIsPlaceholderOnly("tiny_same_origin"); |
| 626 | |
| 627 TabSpecificContentSettings* tab_specific_content_settings = | |
| 628 TabSpecificContentSettings::FromWebContents(GetActiveWebContents()); | |
| 629 EXPECT_FALSE(tab_specific_content_settings->blocked_plugin_names().empty()); | |
| 630 } | 619 } |
| 631 | 620 |
| 632 // Separate test case with HTML By Default feature flag on. | 621 // Separate test case with HTML By Default feature flag on. |
| 633 class PluginPowerSaverPreferHtmlBrowserTest | 622 class PluginPowerSaverPreferHtmlBrowserTest |
| 634 : public PluginPowerSaverBrowserTest { | 623 : public PluginPowerSaverBrowserTest { |
| 635 public: | 624 public: |
| 636 void SetUpInProcessBrowserTestFixture() override { | 625 void SetUpInProcessBrowserTestFixture() override { |
| 637 // Although this is redundant with the Field Trial testing configuration, | 626 // Although this is redundant with the Field Trial testing configuration, |
| 638 // the official builders don't read that. | 627 // the official builders don't read that. |
| 639 feature_list.InitAndEnableFeature(features::kPreferHtmlOverPlugins); | 628 feature_list.InitAndEnableFeature(features::kPreferHtmlOverPlugins); |
| 640 } | 629 } |
| 641 | 630 |
| 642 private: | 631 private: |
| 643 base::test::ScopedFeatureList feature_list; | 632 base::test::ScopedFeatureList feature_list; |
| 644 }; | 633 }; |
| 645 | 634 |
| 646 IN_PROC_BROWSER_TEST_F(PluginPowerSaverPreferHtmlBrowserTest, | 635 IN_PROC_BROWSER_TEST_F(PluginPowerSaverPreferHtmlBrowserTest, |
| 647 ThrottlePluginsOnAllowContentSetting) { | 636 ThrottlePluginsOnAllowContentSetting) { |
| 648 HostContentSettingsMap* content_settings_map = | 637 HostContentSettingsMap* content_settings_map = |
| 649 HostContentSettingsMapFactory::GetForProfile(browser()->profile()); | 638 HostContentSettingsMapFactory::GetForProfile(browser()->profile()); |
| 650 | 639 |
| 651 content_settings_map->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS, | 640 content_settings_map->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS, |
| 652 CONTENT_SETTING_ALLOW); | 641 CONTENT_SETTING_ALLOW); |
| 653 LoadPeripheralPlugin(); | 642 LoadPeripheralPlugin(); |
| 654 VerifyPluginIsThrottled(GetActiveWebContents(), "plugin"); | 643 VerifyPluginIsThrottled(GetActiveWebContents(), "plugin"); |
| 655 } | 644 } |
| OLD | NEW |