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" |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 21 #include "chrome/common/chrome_switches.h" | 21 #include "chrome/common/chrome_switches.h" |
| 22 #include "chrome/test/base/in_process_browser_test.h" | 22 #include "chrome/test/base/in_process_browser_test.h" |
| 23 #include "chrome/test/base/test_switches.h" | 23 #include "chrome/test/base/test_switches.h" |
| 24 #include "chrome/test/base/ui_test_utils.h" | 24 #include "chrome/test/base/ui_test_utils.h" |
| 25 #include "components/content_settings/core/browser/host_content_settings_map.h" | 25 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 26 #include "components/zoom/zoom_controller.h" | 26 #include "components/zoom/zoom_controller.h" |
| 27 #include "content/public/browser/readback_types.h" | 27 #include "content/public/browser/readback_types.h" |
| 28 #include "content/public/browser/render_frame_host.h" | 28 #include "content/public/browser/render_frame_host.h" |
| 29 #include "content/public/browser/render_view_host.h" | 29 #include "content/public/browser/render_view_host.h" |
| 30 #include "content/public/browser/render_widget_host.h" | 30 #include "content/public/browser/render_widget_host.h" |
| 31 #include "content/public/common/content_features.h" | |
| 31 #include "content/public/common/content_switches.h" | 32 #include "content/public/common/content_switches.h" |
| 32 #include "content/public/test/browser_test_utils.h" | 33 #include "content/public/test/browser_test_utils.h" |
| 33 #include "content/public/test/ppapi_test_utils.h" | 34 #include "content/public/test/ppapi_test_utils.h" |
| 34 #include "net/test/embedded_test_server/embedded_test_server.h" | 35 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 35 #include "net/test/embedded_test_server/http_request.h" | 36 #include "net/test/embedded_test_server/http_request.h" |
| 36 #include "net/test/embedded_test_server/http_response.h" | 37 #include "net/test/embedded_test_server/http_response.h" |
| 37 #include "third_party/WebKit/public/platform/WebInputEvent.h" | 38 #include "third_party/WebKit/public/platform/WebInputEvent.h" |
| 38 #include "third_party/skia/include/core/SkBitmap.h" | 39 #include "third_party/skia/include/core/SkBitmap.h" |
| 39 #include "ui/base/window_open_disposition.h" | 40 #include "ui/base/window_open_disposition.h" |
| 40 #include "ui/display/display.h" | 41 #include "ui/display/display.h" |
| (...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 592 "window.document.getElementById('expand_to_peripheral').height = 200;" | 593 "window.document.getElementById('expand_to_peripheral').height = 200;" |
| 593 "window.document.getElementById('expand_to_peripheral').width = 200;" | 594 "window.document.getElementById('expand_to_peripheral').width = 200;" |
| 594 "window.document.getElementById('expand_to_essential').height = 400;" | 595 "window.document.getElementById('expand_to_essential').height = 400;" |
| 595 "window.document.getElementById('expand_to_essential').width = 400;"; | 596 "window.document.getElementById('expand_to_essential').width = 400;"; |
| 596 ASSERT_TRUE(content::ExecuteScript(GetActiveWebContents(), script)); | 597 ASSERT_TRUE(content::ExecuteScript(GetActiveWebContents(), script)); |
| 597 | 598 |
| 598 VerifyPluginIsThrottled(GetActiveWebContents(), "expand_to_peripheral"); | 599 VerifyPluginIsThrottled(GetActiveWebContents(), "expand_to_peripheral"); |
| 599 VerifyPluginMarkedEssential(GetActiveWebContents(), "expand_to_essential"); | 600 VerifyPluginMarkedEssential(GetActiveWebContents(), "expand_to_essential"); |
| 600 } | 601 } |
| 601 | 602 |
| 603 // Separate test case with FilterSameOriginTinyPlugins feature flag on. | |
| 604 class PluginPowerSaverFilterSameOriginTinyPluginsBrowserTest | |
| 605 : public PluginPowerSaverBrowserTest { | |
| 606 public: | |
| 607 void SetUpInProcessBrowserTestFixture() override { | |
|
jochen (gone - plz use gerrit)
2017/01/11 09:48:06
nit. please add a virtual dtor
tommycli
2017/01/11 18:34:40
Hey. The base class doesn't have an explicitly dec
| |
| 608 // Although this is redundant with the Field Trial testing configuration, | |
| 609 // the official builders don't read that. | |
| 610 feature_list.InitWithFeatures({features::kFilterSameOriginTinyPlugin}, | |
| 611 {features::kPreferHtmlOverPlugins}); | |
| 612 } | |
| 613 | |
| 614 private: | |
| 615 base::test::ScopedFeatureList feature_list; | |
| 616 }; | |
| 617 | |
| 618 IN_PROC_BROWSER_TEST_F(PluginPowerSaverFilterSameOriginTinyPluginsBrowserTest, | |
| 619 BlockSameOriginTinyPlugin) { | |
| 620 LoadHTML("/same_origin_tiny_plugin.html"); | |
| 621 | |
| 622 VerifyPluginIsPlaceholderOnly("tiny_same_origin"); | |
| 623 | |
| 624 TabSpecificContentSettings* tab_specific_content_settings = | |
| 625 TabSpecificContentSettings::FromWebContents(GetActiveWebContents()); | |
| 626 EXPECT_FALSE(tab_specific_content_settings->blocked_plugin_names().empty()); | |
| 627 } | |
| 628 | |
| 602 // Separate test case with HTML By Default feature flag on. | 629 // Separate test case with HTML By Default feature flag on. |
| 603 class PluginPowerSaverPreferHtmlBrowserTest | 630 class PluginPowerSaverPreferHtmlBrowserTest |
| 604 : public PluginPowerSaverBrowserTest { | 631 : public PluginPowerSaverBrowserTest { |
| 605 public: | 632 public: |
| 606 void SetUpInProcessBrowserTestFixture() override { | 633 void SetUpInProcessBrowserTestFixture() override { |
| 607 // Although this is redundant with the Field Trial testing configuration, | 634 // Although this is redundant with the Field Trial testing configuration, |
| 608 // the official builders don't read that. | 635 // the official builders don't read that. |
| 609 feature_list.InitAndEnableFeature(features::kPreferHtmlOverPlugins); | 636 feature_list.InitAndEnableFeature(features::kPreferHtmlOverPlugins); |
| 610 } | 637 } |
| 611 | 638 |
| 612 private: | 639 private: |
| 613 base::test::ScopedFeatureList feature_list; | 640 base::test::ScopedFeatureList feature_list; |
| 614 }; | 641 }; |
| 615 | 642 |
| 616 IN_PROC_BROWSER_TEST_F(PluginPowerSaverPreferHtmlBrowserTest, | 643 IN_PROC_BROWSER_TEST_F(PluginPowerSaverPreferHtmlBrowserTest, |
| 617 ThrottlePluginsOnAllowContentSetting) { | 644 ThrottlePluginsOnAllowContentSetting) { |
| 618 HostContentSettingsMap* content_settings_map = | 645 HostContentSettingsMap* content_settings_map = |
| 619 HostContentSettingsMapFactory::GetForProfile(browser()->profile()); | 646 HostContentSettingsMapFactory::GetForProfile(browser()->profile()); |
| 620 | 647 |
| 621 content_settings_map->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS, | 648 content_settings_map->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS, |
| 622 CONTENT_SETTING_ALLOW); | 649 CONTENT_SETTING_ALLOW); |
| 623 LoadPeripheralPlugin(); | 650 LoadPeripheralPlugin(); |
| 624 VerifyPluginIsThrottled(GetActiveWebContents(), "plugin"); | 651 VerifyPluginIsThrottled(GetActiveWebContents(), "plugin"); |
| 625 } | 652 } |
| OLD | NEW |