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

Unified Diff: content/renderer/pepper/plugin_power_saver_helper_browsertest.cc

Issue 764763005: Plugin Power Saver: Always mark 'tiny' plugins as essential. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@0201-plugin-power-saver-use-poster-frame-on-blocked-only
Patch Set: Created 6 years 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/pepper/plugin_power_saver_helper_browsertest.cc
diff --git a/content/renderer/pepper/plugin_power_saver_helper_browsertest.cc b/content/renderer/pepper/plugin_power_saver_helper_browsertest.cc
index bba3ad23370304b1a83919662d110660419c3329..b68004f9f7ced1fbd66e6706b3ca38c0314c8de4 100644
--- a/content/renderer/pepper/plugin_power_saver_helper_browsertest.cc
+++ b/content/renderer/pepper/plugin_power_saver_helper_browsertest.cc
@@ -76,40 +76,56 @@ TEST_F(PluginPowerSaverHelperTest, PosterImage) {
}
TEST_F(PluginPowerSaverHelperTest, AllowSameOrigin) {
- bool cross_origin = false;
- EXPECT_FALSE(power_saver_helper()->ShouldThrottleContent(
- GURL(), 100, 100, &cross_origin));
- EXPECT_FALSE(cross_origin);
+ EXPECT_FALSE(
+ power_saver_helper()->ShouldThrottleContent(GURL(), 100, 100, nullptr));
- EXPECT_FALSE(power_saver_helper()->ShouldThrottleContent(
- GURL(), 1000, 1000, &cross_origin));
- EXPECT_FALSE(cross_origin);
+ EXPECT_FALSE(
+ power_saver_helper()->ShouldThrottleContent(GURL(), 1000, 1000, nullptr));
}
TEST_F(PluginPowerSaverHelperTest, DisallowCrossOriginUnlessLarge) {
- bool cross_origin = false;
+ bool is_main_attraction = false;
EXPECT_TRUE(power_saver_helper()->ShouldThrottleContent(
- GURL("http://other.com"), 100, 100, &cross_origin));
- EXPECT_TRUE(cross_origin);
+ GURL("http://other.com"), 100, 100, &is_main_attraction));
+ EXPECT_FALSE(is_main_attraction);
+
+ EXPECT_FALSE(power_saver_helper()->ShouldThrottleContent(
+ GURL("http://other.com"), 1000, 1000, &is_main_attraction));
+ EXPECT_TRUE(is_main_attraction);
+}
+TEST_F(PluginPowerSaverHelperTest, AlwaysAllowTinyContent) {
+ bool is_main_attraction = false;
EXPECT_FALSE(power_saver_helper()->ShouldThrottleContent(
- GURL("http://other.com"), 1000, 1000, &cross_origin));
- EXPECT_TRUE(cross_origin);
+ GURL(), 1, 1, &is_main_attraction));
+ EXPECT_FALSE(is_main_attraction);
+
+ EXPECT_FALSE(power_saver_helper()->ShouldThrottleContent(
+ GURL("http://other.com"), 1, 1, &is_main_attraction));
+ EXPECT_FALSE(is_main_attraction);
+
+ EXPECT_FALSE(power_saver_helper()->ShouldThrottleContent(
+ GURL("http://other.com"), 5, 5, &is_main_attraction));
+ EXPECT_FALSE(is_main_attraction);
+
+ EXPECT_TRUE(power_saver_helper()->ShouldThrottleContent(
+ GURL("http://other.com"), 10, 10, &is_main_attraction));
+ EXPECT_FALSE(is_main_attraction);
}
TEST_F(PluginPowerSaverHelperTest, TemporaryOriginWhitelist) {
- bool cross_origin = false;
+ bool is_main_attraction = false;
EXPECT_TRUE(power_saver_helper()->ShouldThrottleContent(
- GURL("http://other.com"), 100, 100, &cross_origin));
- EXPECT_TRUE(cross_origin);
+ GURL("http://other.com"), 100, 100, &is_main_attraction));
+ EXPECT_FALSE(is_main_attraction);
// Clear out other messages so we find just the plugin power saver IPCs.
sink_->ClearMessages();
power_saver_helper()->WhitelistContentOrigin(GURL("http://other.com"));
EXPECT_FALSE(power_saver_helper()->ShouldThrottleContent(
- GURL("http://other.com"), 100, 100, &cross_origin));
- EXPECT_TRUE(cross_origin);
+ GURL("http://other.com"), 100, 100, &is_main_attraction));
+ EXPECT_FALSE(is_main_attraction);
// Test that we've sent an IPC to the browser.
ASSERT_EQ(1u, sink_->message_count());
@@ -137,16 +153,13 @@ TEST_F(PluginPowerSaverHelperTest, UnthrottleOnExPostFactoWhitelist) {
TEST_F(PluginPowerSaverHelperTest, ClearWhitelistOnNavigate) {
power_saver_helper()->WhitelistContentOrigin(GURL("http://other.com"));
- bool cross_origin = false;
EXPECT_FALSE(power_saver_helper()->ShouldThrottleContent(
- GURL("http://other.com"), 100, 100, &cross_origin));
- EXPECT_TRUE(cross_origin);
+ GURL("http://other.com"), 100, 100, nullptr));
LoadHTML("<html></html>");
EXPECT_TRUE(power_saver_helper()->ShouldThrottleContent(
- GURL("http://other.com"), 100, 100, &cross_origin));
- EXPECT_TRUE(cross_origin);
+ GURL("http://other.com"), 100, 100, nullptr));
}
} // namespace content
« no previous file with comments | « content/renderer/pepper/pepper_plugin_instance_throttler.cc ('k') | content/renderer/pepper/plugin_power_saver_helper_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698