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

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

Issue 1421693002: Plugin Power Saver: Do not always throttle plugins with posters. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@0025-pps-poster-pixel-tests
Patch Set: Created 5 years, 2 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 | components/plugins/renderer/loadable_plugin_placeholder.h » ('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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/strings/string_piece.h" 6 #include "base/strings/string_piece.h"
7 #include "base/strings/stringprintf.h" 7 #include "base/strings/stringprintf.h"
8 #include "chrome/browser/ui/browser.h" 8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/tabs/tab_strip_model.h" 9 #include "chrome/browser/ui/tabs/tab_strip_model.h"
10 #include "chrome/common/chrome_switches.h" 10 #include "chrome/common/chrome_switches.h"
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 " width='400' height='500'" 218 " width='400' height='500'"
219 " poster='snapshot1x.png 1x, snapshot2x.png 2x'></embed>"); 219 " poster='snapshot1x.png 1x, snapshot2x.png 2x'></embed>");
220 220
221 EXPECT_FALSE(PluginLoaded(GetActiveWebContents(), "plugin_src")); 221 EXPECT_FALSE(PluginLoaded(GetActiveWebContents(), "plugin_src"));
222 EXPECT_FALSE(PluginLoaded(GetActiveWebContents(), "plugin_srcset")); 222 EXPECT_FALSE(PluginLoaded(GetActiveWebContents(), "plugin_srcset"));
223 EXPECT_FALSE(PluginLoaded(GetActiveWebContents(), "plugin_legacy_syntax")); 223 EXPECT_FALSE(PluginLoaded(GetActiveWebContents(), "plugin_legacy_syntax"));
224 EXPECT_FALSE(PluginLoaded(GetActiveWebContents(), "plugin_embed_src")); 224 EXPECT_FALSE(PluginLoaded(GetActiveWebContents(), "plugin_embed_src"));
225 EXPECT_FALSE(PluginLoaded(GetActiveWebContents(), "plugin_embed_srcset")); 225 EXPECT_FALSE(PluginLoaded(GetActiveWebContents(), "plugin_embed_srcset"));
226 } 226 }
227 227
228 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, LargePostersNotThrottled) {
229 // This test verifies that small posters are throttled, large posters are not,
230 // and that large posters can whitelist origins for other plugins.
231 LoadHTML(
232 "<object id='poster_small' data='http://a.com/fake.swf' "
233 " type='application/x-ppapi-tests' width='50' height='50' "
234 " poster='click_me.png'></object>"
235 "<object id='poster_whitelisted_origin' data='http://b.com/fake.swf' "
236 " type='application/x-ppapi-tests' width='50' height='50' "
237 " poster='click_me.png'></object>"
238 "<object id='plugin_whitelisted_origin' data='http://b.com/fake.swf' "
239 " type='application/x-ppapi-tests' width='50' height='50'></object>"
240 "<br>"
241 "<object id='poster_large' data='http://b.com/fake.swf' "
242 " type='application/x-ppapi-tests' width='400' height='300' "
243 " poster='click_me.png'></object>");
244
245 EXPECT_FALSE(PluginLoaded(GetActiveWebContents(), "poster_small"));
246 VerifyPluginMarkedEssential(GetActiveWebContents(),
247 "plugin_whitelisted_origin");
248 VerifyPluginMarkedEssential(GetActiveWebContents(), "poster_large");
249 }
250
228 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, 251 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest,
229 PluginMarkedEssentialAfterPosterClicked) { 252 PluginMarkedEssentialAfterPosterClicked) {
230 LoadHTML( 253 LoadHTML(
231 "<object id='plugin' type='application/x-ppapi-tests' " 254 "<object id='plugin' type='application/x-ppapi-tests' "
232 " width='400' height='100' poster='snapshot1x.png'></object>"); 255 " width='400' height='100' poster='snapshot1x.png'></object>");
233 EXPECT_FALSE(PluginLoaded(GetActiveWebContents(), "plugin")); 256 EXPECT_FALSE(PluginLoaded(GetActiveWebContents(), "plugin"));
234 257
235 SimulateClickAndAwaitMarkedEssential("plugin", gfx::Point(50, 50)); 258 SimulateClickAndAwaitMarkedEssential("plugin", gfx::Point(50, 50));
236 } 259 }
237 260
238 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, OriginWhitelisting) { 261 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, OriginWhitelisting) {
239 LoadHTML( 262 LoadHTML(
240 "<object id='plugin1' data='http://otherorigin.com/fake1.swf' " 263 "<object id='plugin_small' data='http://a.com/fake1.swf' "
241 " type='application/x-ppapi-tests' width='400' height='100'></object>" 264 " type='application/x-ppapi-tests' width='100' height='100'></object>"
242 "<object id='plugin2' data='http://otherorigin.com/fake2.swf' " 265 "<object id='plugin_small_poster' data='http://a.com/fake1.swf' "
266 " type='application/x-ppapi-tests' width='100' height='100' "
267 " poster='click_me.png'></object>"
268 "<object id='plugin_large' data='http://a.com/fake2.swf' "
243 " type='application/x-ppapi-tests' width='400' height='500'>" 269 " type='application/x-ppapi-tests' width='400' height='500'>"
244 "</object>"); 270 "</object>");
245 VerifyPluginMarkedEssential(GetActiveWebContents(), "plugin1"); 271 VerifyPluginMarkedEssential(GetActiveWebContents(), "plugin_small");
246 VerifyPluginMarkedEssential(GetActiveWebContents(), "plugin2"); 272 VerifyPluginMarkedEssential(GetActiveWebContents(), "plugin_small_poster");
273 VerifyPluginMarkedEssential(GetActiveWebContents(), "plugin_large");
247 } 274 }
248 275
249 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, LargeCrossOriginObscured) { 276 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, LargeCrossOriginObscured) {
250 LoadHTML( 277 LoadHTML(
251 "<div id='container' " 278 "<div id='container' "
252 " style='width: 400px; height: 100px; overflow: hidden;'>" 279 " style='width: 400px; height: 100px; overflow: hidden;'>"
253 " <object id='plugin' data='http://otherorigin.com/fake.swf' " 280 " <object id='plugin' data='http://otherorigin.com/fake.swf' "
254 " type='application/x-ppapi-tests' width='400' height='500'>" 281 " type='application/x-ppapi-tests' width='400' height='500'>"
255 " </object>" 282 " </object>"
256 "</div>"); 283 "</div>");
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 332
306 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, ZoomIndependent) { 333 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, ZoomIndependent) {
307 ui_zoom::ZoomController::FromWebContents(GetActiveWebContents()) 334 ui_zoom::ZoomController::FromWebContents(GetActiveWebContents())
308 ->SetZoomLevel(4.0); 335 ->SetZoomLevel(4.0);
309 LoadHTML( 336 LoadHTML(
310 "<object id='plugin' data='http://otherorigin.com/fake.swf' " 337 "<object id='plugin' data='http://otherorigin.com/fake.swf' "
311 " type='application/x-ppapi-tests' width='400' height='200'>" 338 " type='application/x-ppapi-tests' width='400' height='200'>"
312 "</object>"); 339 "</object>");
313 VerifyPluginIsThrottled(GetActiveWebContents(), "plugin"); 340 VerifyPluginIsThrottled(GetActiveWebContents(), "plugin");
314 } 341 }
OLDNEW
« no previous file with comments | « no previous file | components/plugins/renderer/loadable_plugin_placeholder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698