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 13 matching lines...) Expand all Loading... |
24 #include "content/public/browser/readback_types.h" | 24 #include "content/public/browser/readback_types.h" |
25 #include "content/public/browser/render_frame_host.h" | 25 #include "content/public/browser/render_frame_host.h" |
26 #include "content/public/browser/render_view_host.h" | 26 #include "content/public/browser/render_view_host.h" |
27 #include "content/public/browser/render_widget_host.h" | 27 #include "content/public/browser/render_widget_host.h" |
28 #include "content/public/common/content_switches.h" | 28 #include "content/public/common/content_switches.h" |
29 #include "content/public/test/browser_test_utils.h" | 29 #include "content/public/test/browser_test_utils.h" |
30 #include "content/public/test/ppapi_test_utils.h" | 30 #include "content/public/test/ppapi_test_utils.h" |
31 #include "net/test/embedded_test_server/embedded_test_server.h" | 31 #include "net/test/embedded_test_server/embedded_test_server.h" |
32 #include "net/test/embedded_test_server/http_request.h" | 32 #include "net/test/embedded_test_server/http_request.h" |
33 #include "net/test/embedded_test_server/http_response.h" | 33 #include "net/test/embedded_test_server/http_response.h" |
34 #include "ppapi/shared_impl/ppapi_switches.h" | |
35 #include "third_party/WebKit/public/web/WebInputEvent.h" | 34 #include "third_party/WebKit/public/web/WebInputEvent.h" |
36 #include "third_party/skia/include/core/SkBitmap.h" | 35 #include "third_party/skia/include/core/SkBitmap.h" |
37 #include "ui/base/window_open_disposition.h" | 36 #include "ui/base/window_open_disposition.h" |
38 #include "ui/display/display.h" | 37 #include "ui/display/display.h" |
39 #include "ui/display/display_switches.h" | 38 #include "ui/display/display_switches.h" |
40 #include "ui/display/screen.h" | 39 #include "ui/display/screen.h" |
41 #include "ui/gfx/codec/png_codec.h" | 40 #include "ui/gfx/codec/png_codec.h" |
42 #include "ui/gfx/geometry/point.h" | 41 #include "ui/gfx/geometry/point.h" |
43 | 42 |
44 namespace { | 43 namespace { |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 InProcessBrowserTest::SetUpOnMainThread(); | 266 InProcessBrowserTest::SetUpOnMainThread(); |
268 ASSERT_TRUE(embedded_test_server()->Start()); | 267 ASSERT_TRUE(embedded_test_server()->Start()); |
269 | 268 |
270 embedded_test_server()->ServeFilesFromDirectory( | 269 embedded_test_server()->ServeFilesFromDirectory( |
271 ui_test_utils::GetTestFilePath( | 270 ui_test_utils::GetTestFilePath( |
272 base::FilePath(FILE_PATH_LITERAL("plugin_power_saver")), | 271 base::FilePath(FILE_PATH_LITERAL("plugin_power_saver")), |
273 base::FilePath())); | 272 base::FilePath())); |
274 } | 273 } |
275 | 274 |
276 void SetUpCommandLine(base::CommandLine* command_line) override { | 275 void SetUpCommandLine(base::CommandLine* command_line) override { |
277 command_line->AppendSwitch(switches::kEnablePepperTesting); | |
278 command_line->AppendSwitch(switches::kEnablePluginPlaceholderTesting); | 276 command_line->AppendSwitch(switches::kEnablePluginPlaceholderTesting); |
279 command_line->AppendSwitchASCII( | 277 ASSERT_TRUE(ppapi::RegisterFlashTestPlugin(command_line)); |
280 switches::kOverridePluginPowerSaverForTesting, "ignore-list"); | |
281 | |
282 ASSERT_TRUE(ppapi::RegisterPowerSaverTestPlugin(command_line)); | |
283 | 278 |
284 // Allows us to use the same reference image on HiDPI/Retina displays. | 279 // Allows us to use the same reference image on HiDPI/Retina displays. |
285 command_line->AppendSwitchASCII(switches::kForceDeviceScaleFactor, "1"); | 280 command_line->AppendSwitchASCII(switches::kForceDeviceScaleFactor, "1"); |
286 | 281 |
287 // The pixel tests run more reliably in software mode. | 282 // The pixel tests run more reliably in software mode. |
288 if (PixelTestsEnabled()) | 283 if (PixelTestsEnabled()) |
289 command_line->AppendSwitch(switches::kDisableGpu); | 284 command_line->AppendSwitch(switches::kDisableGpu); |
290 } | 285 } |
291 | 286 |
292 void SetUpInProcessBrowserTestFixture() override { | 287 void SetUpInProcessBrowserTestFixture() override { |
293 // Although this is redundant with the Field Trial testing configuration, | 288 // Although this is redundant with the Field Trial testing configuration, |
294 // the official builders don't use those, so we also enable it here. | 289 // the official builders don't use those, so we also enable it here. |
295 feature_list.InitAndEnableFeature(features::kBlockSmallContent); | 290 feature_list.InitAndEnableFeature(features::kBlockSmallContent); |
| 291 |
| 292 // Disable HTML5 By Default feature to test Plugin Power Saver specifically. |
| 293 feature_list.InitAndDisableFeature(features::kPreferHtmlOverPlugins); |
296 } | 294 } |
297 | 295 |
298 protected: | 296 protected: |
299 void LoadHTML(const std::string& html) { | 297 void LoadHTML(const std::string& html) { |
300 if (PixelTestsEnabled()) { | 298 if (PixelTestsEnabled()) { |
301 gfx::Rect bounds(gfx::Rect(0, 0, kBrowserWidth, kBrowserHeight)); | 299 gfx::Rect bounds(gfx::Rect(0, 0, kBrowserWidth, kBrowserHeight)); |
302 gfx::Rect screen_bounds = | 300 gfx::Rect screen_bounds = |
303 display::Screen::GetScreen()->GetPrimaryDisplay().bounds(); | 301 display::Screen::GetScreen()->GetPrimaryDisplay().bounds(); |
304 ASSERT_GT(screen_bounds.width(), kBrowserWidth); | 302 ASSERT_GT(screen_bounds.width(), kBrowserWidth); |
305 ASSERT_GT(screen_bounds.height(), kBrowserHeight); | 303 ASSERT_GT(screen_bounds.height(), kBrowserHeight); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 #endif | 408 #endif |
411 } | 409 } |
412 | 410 |
413 private: | 411 private: |
414 base::test::ScopedFeatureList feature_list; | 412 base::test::ScopedFeatureList feature_list; |
415 }; | 413 }; |
416 | 414 |
417 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, EssentialPlugins) { | 415 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, EssentialPlugins) { |
418 LoadHTML( | 416 LoadHTML( |
419 "<object id='small_same_origin' data='fake.swf' " | 417 "<object id='small_same_origin' data='fake.swf' " |
420 " type='application/x-ppapi-tests' width='400' height='100'>" | 418 " type='application/x-shockwave-flash' width='400' height='100'>" |
421 "</object>" | 419 "</object>" |
422 "<object id='small_same_origin_poster' data='fake.swf' " | 420 "<object id='small_same_origin_poster' data='fake.swf' " |
423 " type='application/x-ppapi-tests' width='400' height='100' " | 421 " type='application/x-shockwave-flash' width='400' height='100' " |
424 " poster='click_me.png'>" | 422 " poster='click_me.png'>" |
425 "</object>" | 423 "</object>" |
426 "<object id='large_cross_origin' data='http://b.com/fake.swf' " | 424 "<object id='large_cross_origin' data='http://b.com/fake.swf' " |
427 " type='application/x-ppapi-tests' width='400' height='500'>" | 425 " type='application/x-shockwave-flash' width='400' height='500'>" |
428 "</object>" | 426 "</object>" |
429 "<object id='medium_16_9_cross_origin' data='http://c.com/fake.swf' " | 427 "<object id='medium_16_9_cross_origin' data='http://c.com/fake.swf' " |
430 " type='application/x-ppapi-tests' width='480' height='270'>" | 428 " type='application/x-shockwave-flash' width='480' height='270'>" |
431 "</object>"); | 429 "</object>"); |
432 | 430 |
433 VerifyPluginMarkedEssential(GetActiveWebContents(), "small_same_origin"); | 431 VerifyPluginMarkedEssential(GetActiveWebContents(), "small_same_origin"); |
434 VerifyPluginMarkedEssential(GetActiveWebContents(), | 432 VerifyPluginMarkedEssential(GetActiveWebContents(), |
435 "small_same_origin_poster"); | 433 "small_same_origin_poster"); |
436 VerifyPluginMarkedEssential(GetActiveWebContents(), "large_cross_origin"); | 434 VerifyPluginMarkedEssential(GetActiveWebContents(), "large_cross_origin"); |
437 VerifyPluginMarkedEssential(GetActiveWebContents(), | 435 VerifyPluginMarkedEssential(GetActiveWebContents(), |
438 "medium_16_9_cross_origin"); | 436 "medium_16_9_cross_origin"); |
439 } | 437 } |
440 | 438 |
441 // Flaky on WebKit Mac dbg bots: crbug.com/599484. | 439 // Flaky on WebKit Mac dbg bots: crbug.com/599484. |
442 #if defined(OS_MACOSX) | 440 #if defined(OS_MACOSX) |
443 #define MAYBE_SmallCrossOrigin DISABLED_SmallCrossOrigin | 441 #define MAYBE_SmallCrossOrigin DISABLED_SmallCrossOrigin |
444 #else | 442 #else |
445 #define MAYBE_SmallCrossOrigin SmallCrossOrigin | 443 #define MAYBE_SmallCrossOrigin SmallCrossOrigin |
446 #endif | 444 #endif |
447 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, MAYBE_SmallCrossOrigin) { | 445 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, MAYBE_SmallCrossOrigin) { |
448 LoadHTML( | 446 LoadHTML( |
449 "<object id='plugin' data='http://otherorigin.com/fake.swf' " | 447 "<object id='plugin' data='http://otherorigin.com/fake.swf' " |
450 " type='application/x-ppapi-tests' width='400' height='100'>" | 448 " type='application/x-shockwave-flash' width='400' height='100'>" |
451 "</object>" | 449 "</object>" |
452 "<br>" | 450 "<br>" |
453 "<object id='plugin_poster' data='http://otherorigin.com/fake.swf' " | 451 "<object id='plugin_poster' data='http://otherorigin.com/fake.swf' " |
454 " type='application/x-ppapi-tests' width='400' height='100' " | 452 " type='application/x-shockwave-flash' width='400' height='100' " |
455 " poster='click_me.png'>" | 453 " poster='click_me.png'>" |
456 "</object>"); | 454 "</object>"); |
457 | 455 |
458 VerifyPluginIsThrottled(GetActiveWebContents(), "plugin"); | 456 VerifyPluginIsThrottled(GetActiveWebContents(), "plugin"); |
459 VerifyPluginIsPlaceholderOnly("plugin_poster"); | 457 VerifyPluginIsPlaceholderOnly("plugin_poster"); |
460 | 458 |
461 EXPECT_TRUE( | 459 EXPECT_TRUE( |
462 VerifySnapshot(FILE_PATH_LITERAL("small_cross_origin_expected.png"))); | 460 VerifySnapshot(FILE_PATH_LITERAL("small_cross_origin_expected.png"))); |
463 | 461 |
464 SimulateClickAndAwaitMarkedEssential("plugin", gfx::Point(50, 50)); | 462 SimulateClickAndAwaitMarkedEssential("plugin", gfx::Point(50, 50)); |
465 SimulateClickAndAwaitMarkedEssential("plugin_poster", gfx::Point(50, 150)); | 463 SimulateClickAndAwaitMarkedEssential("plugin_poster", gfx::Point(50, 150)); |
466 } | 464 } |
467 | 465 |
468 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, SmallerThanPlayIcon) { | 466 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, SmallerThanPlayIcon) { |
469 LoadHTML( | 467 LoadHTML( |
470 "<object id='plugin_16' type='application/x-ppapi-tests' " | 468 "<object id='plugin_16' type='application/x-shockwave-flash' " |
471 " width='16' height='16'></object>" | 469 " width='16' height='16'></object>" |
472 "<object id='plugin_32' type='application/x-ppapi-tests' " | 470 "<object id='plugin_32' type='application/x-shockwave-flash' " |
473 " width='32' height='32'></object>" | 471 " width='32' height='32'></object>" |
474 "<object id='plugin_16_64' type='application/x-ppapi-tests' " | 472 "<object id='plugin_16_64' type='application/x-shockwave-flash' " |
475 " width='16' height='64'></object>" | 473 " width='16' height='64'></object>" |
476 "<object id='plugin_64_16' type='application/x-ppapi-tests' " | 474 "<object id='plugin_64_16' type='application/x-shockwave-flash' " |
477 " width='64' height='16'></object>"); | 475 " width='64' height='16'></object>"); |
478 | 476 |
479 VerifyPluginIsThrottled(GetActiveWebContents(), "plugin_16"); | 477 VerifyPluginIsThrottled(GetActiveWebContents(), "plugin_16"); |
480 VerifyPluginIsThrottled(GetActiveWebContents(), "plugin_32"); | 478 VerifyPluginIsThrottled(GetActiveWebContents(), "plugin_32"); |
481 VerifyPluginIsThrottled(GetActiveWebContents(), "plugin_16_64"); | 479 VerifyPluginIsThrottled(GetActiveWebContents(), "plugin_16_64"); |
482 VerifyPluginIsThrottled(GetActiveWebContents(), "plugin_64_16"); | 480 VerifyPluginIsThrottled(GetActiveWebContents(), "plugin_64_16"); |
483 | 481 |
484 EXPECT_TRUE( | 482 EXPECT_TRUE( |
485 VerifySnapshot(FILE_PATH_LITERAL("smaller_than_play_icon_expected.png"))); | 483 VerifySnapshot(FILE_PATH_LITERAL("smaller_than_play_icon_expected.png"))); |
486 } | 484 } |
487 | 485 |
488 // Flaky on WebKit Mac dbg bots: crbug.com/599484. | 486 // Flaky on WebKit Mac dbg bots: crbug.com/599484. |
489 #if defined(OS_MACOSX) | 487 #if defined(OS_MACOSX) |
490 #define MAYBE_PosterTests DISABLED_PosterTests | 488 #define MAYBE_PosterTests DISABLED_PosterTests |
491 #else | 489 #else |
492 #define MAYBE_PosterTests PosterTests | 490 #define MAYBE_PosterTests PosterTests |
493 #endif | 491 #endif |
494 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, MAYBE_PosterTests) { | 492 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, MAYBE_PosterTests) { |
495 // This test simultaneously verifies the varied supported poster syntaxes, | 493 // This test simultaneously verifies the varied supported poster syntaxes, |
496 // as well as verifies that the poster is rendered correctly with various | 494 // as well as verifies that the poster is rendered correctly with various |
497 // mismatched aspect ratios and sizes, following the same rules as VIDEO. | 495 // mismatched aspect ratios and sizes, following the same rules as VIDEO. |
498 LoadHTML( | 496 LoadHTML( |
499 "<object id='plugin_src' type='application/x-ppapi-tests' " | 497 "<object id='plugin_src' type='application/x-shockwave-flash' " |
500 " width='100' height='100' poster='click_me.png'></object>" | 498 " width='100' height='100' poster='click_me.png'></object>" |
501 "<object id='plugin_srcset' type='application/x-ppapi-tests' " | 499 "<object id='plugin_srcset' type='application/x-shockwave-flash' " |
502 " width='100' height='100' " | 500 " width='100' height='100' " |
503 " poster='click_me.png 1x, click_me.png 2x'></object>" | 501 " poster='click_me.png 1x, click_me.png 2x'></object>" |
504 "<br>" | 502 "<br>" |
505 | 503 |
506 "<object id='plugin_poster_param' type='application/x-ppapi-tests' " | 504 "<object id='plugin_poster_param' type='application/x-shockwave-flash' " |
507 " width='100' height='100'>" | 505 " width='100' height='100'>" |
508 " <param name='poster' value='click_me.png 1x, click_me.png 2x'>" | 506 " <param name='poster' value='click_me.png 1x, click_me.png 2x'>" |
509 "</object>" | 507 "</object>" |
510 "<embed id='plugin_embed_src' type='application/x-ppapi-tests' " | 508 "<embed id='plugin_embed_src' type='application/x-shockwave-flash' " |
511 " width='100' height='100' poster='click_me.png'></embed>" | 509 " width='100' height='100' poster='click_me.png'></embed>" |
512 "<embed id='plugin_embed_srcset' type='application/x-ppapi-tests' " | 510 "<embed id='plugin_embed_srcset' type='application/x-shockwave-flash' " |
513 " width='100' height='100'" | 511 " width='100' height='100'" |
514 " poster='click_me.png 1x, click_me.png 2x'></embed>" | 512 " poster='click_me.png 1x, click_me.png 2x'></embed>" |
515 "<br>" | 513 "<br>" |
516 | 514 |
517 "<object id='poster_missing' type='application/x-ppapi-tests' " | 515 "<object id='poster_missing' type='application/x-shockwave-flash' " |
518 " width='100' height='100' poster='missing.png'></object>" | 516 " width='100' height='100' poster='missing.png'></object>" |
519 "<object id='poster_too_small' type='application/x-ppapi-tests' " | 517 "<object id='poster_too_small' type='application/x-shockwave-flash' " |
520 " width='100' height='50' poster='click_me.png'></object>" | 518 " width='100' height='50' poster='click_me.png'></object>" |
521 "<object id='poster_too_big' type='application/x-ppapi-tests' " | 519 "<object id='poster_too_big' type='application/x-shockwave-flash' " |
522 " width='100' height='150' poster='click_me.png'></object>" | 520 " width='100' height='150' poster='click_me.png'></object>" |
523 "<br>" | 521 "<br>" |
524 | 522 |
525 "<object id='poster_16' type='application/x-ppapi-tests' " | 523 "<object id='poster_16' type='application/x-shockwave-flash' " |
526 " width='16' height='16' poster='click_me.png'></object>" | 524 " width='16' height='16' poster='click_me.png'></object>" |
527 "<object id='poster_32' type='application/x-ppapi-tests' " | 525 "<object id='poster_32' type='application/x-shockwave-flash' " |
528 " width='32' height='32' poster='click_me.png'></object>" | 526 " width='32' height='32' poster='click_me.png'></object>" |
529 "<object id='poster_16_64' type='application/x-ppapi-tests' " | 527 "<object id='poster_16_64' type='application/x-shockwave-flash' " |
530 " width='16' height='64' poster='click_me.png'></object>" | 528 " width='16' height='64' poster='click_me.png'></object>" |
531 "<object id='poster_64_16' type='application/x-ppapi-tests' " | 529 "<object id='poster_64_16' type='application/x-shockwave-flash' " |
532 " width='64' height='16' poster='click_me.png'></object>" | 530 " width='64' height='16' poster='click_me.png'></object>" |
533 "<br>" | 531 "<br>" |
534 | 532 |
535 "<div id='container' " | 533 "<div id='container' " |
536 " style='width: 400px; height: 100px; overflow: hidden;'>" | 534 " style='width: 400px; height: 100px; overflow: hidden;'>" |
537 " <object id='poster_obscured' data='http://otherorigin.com/fake.swf' " | 535 " <object id='poster_obscured' data='http://otherorigin.com/fake.swf' " |
538 " type='application/x-ppapi-tests' width='400' height='500' " | 536 " type='application/x-shockwave-flash' width='400' height='500' " |
539 " poster='click_me.png'>" | 537 " poster='click_me.png'>" |
540 " </object>" | 538 " </object>" |
541 "</div>"); | 539 "</div>"); |
542 | 540 |
543 VerifyPluginIsPlaceholderOnly("plugin_src"); | 541 VerifyPluginIsPlaceholderOnly("plugin_src"); |
544 VerifyPluginIsPlaceholderOnly("plugin_srcset"); | 542 VerifyPluginIsPlaceholderOnly("plugin_srcset"); |
545 | 543 |
546 VerifyPluginIsPlaceholderOnly("plugin_poster_param"); | 544 VerifyPluginIsPlaceholderOnly("plugin_poster_param"); |
547 VerifyPluginIsPlaceholderOnly("plugin_embed_src"); | 545 VerifyPluginIsPlaceholderOnly("plugin_embed_src"); |
548 VerifyPluginIsPlaceholderOnly("plugin_embed_srcset"); | 546 VerifyPluginIsPlaceholderOnly("plugin_embed_srcset"); |
(...skipping 13 matching lines...) Expand all Loading... |
562 | 560 |
563 // Test that posters can be unthrottled via click. | 561 // Test that posters can be unthrottled via click. |
564 SimulateClickAndAwaitMarkedEssential("plugin_src", gfx::Point(50, 50)); | 562 SimulateClickAndAwaitMarkedEssential("plugin_src", gfx::Point(50, 50)); |
565 } | 563 } |
566 | 564 |
567 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, LargePostersNotThrottled) { | 565 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, LargePostersNotThrottled) { |
568 // This test verifies that small posters are throttled, large posters are not, | 566 // This test verifies that small posters are throttled, large posters are not, |
569 // and that large posters can whitelist origins for other plugins. | 567 // and that large posters can whitelist origins for other plugins. |
570 LoadHTML( | 568 LoadHTML( |
571 "<object id='poster_small' data='http://a.com/fake.swf' " | 569 "<object id='poster_small' data='http://a.com/fake.swf' " |
572 " type='application/x-ppapi-tests' width='50' height='50' " | 570 " type='application/x-shockwave-flash' width='50' height='50' " |
573 " poster='click_me.png'></object>" | 571 " poster='click_me.png'></object>" |
574 "<object id='poster_whitelisted_origin' data='http://b.com/fake.swf' " | 572 "<object id='poster_whitelisted_origin' data='http://b.com/fake.swf' " |
575 " type='application/x-ppapi-tests' width='50' height='50' " | 573 " type='application/x-shockwave-flash' width='50' height='50' " |
576 " poster='click_me.png'></object>" | 574 " poster='click_me.png'></object>" |
577 "<object id='plugin_whitelisted_origin' data='http://b.com/fake.swf' " | 575 "<object id='plugin_whitelisted_origin' data='http://b.com/fake.swf' " |
578 " type='application/x-ppapi-tests' width='50' height='50'></object>" | 576 " type='application/x-shockwave-flash' width='50' height='50'>" |
| 577 "</object>" |
579 "<br>" | 578 "<br>" |
580 "<object id='poster_large' data='http://b.com/fake.swf' " | 579 "<object id='poster_large' data='http://b.com/fake.swf' " |
581 " type='application/x-ppapi-tests' width='400' height='300' " | 580 " type='application/x-shockwave-flash' width='400' height='300' " |
582 " poster='click_me.png'></object>"); | 581 " poster='click_me.png'></object>"); |
583 | 582 |
584 VerifyPluginIsPlaceholderOnly("poster_small"); | 583 VerifyPluginIsPlaceholderOnly("poster_small"); |
585 VerifyPluginMarkedEssential(GetActiveWebContents(), | 584 VerifyPluginMarkedEssential(GetActiveWebContents(), |
586 "poster_whitelisted_origin"); | 585 "poster_whitelisted_origin"); |
587 VerifyPluginMarkedEssential(GetActiveWebContents(), | 586 VerifyPluginMarkedEssential(GetActiveWebContents(), |
588 "plugin_whitelisted_origin"); | 587 "plugin_whitelisted_origin"); |
589 VerifyPluginMarkedEssential(GetActiveWebContents(), "poster_large"); | 588 VerifyPluginMarkedEssential(GetActiveWebContents(), "poster_large"); |
590 } | 589 } |
591 | 590 |
592 // Flaky on ASAN bots: crbug.com/560765. | 591 // Flaky on ASAN bots: crbug.com/560765. |
593 #if defined(ADDRESS_SANITIZER) | 592 #if defined(ADDRESS_SANITIZER) |
594 #define MAYBE_OriginWhitelisting DISABLED_OriginWhitelisting | 593 #define MAYBE_OriginWhitelisting DISABLED_OriginWhitelisting |
595 #else | 594 #else |
596 #define MAYBE_OriginWhitelisting OriginWhitelisting | 595 #define MAYBE_OriginWhitelisting OriginWhitelisting |
597 #endif | 596 #endif |
598 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, MAYBE_OriginWhitelisting) { | 597 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, MAYBE_OriginWhitelisting) { |
599 LoadHTML( | 598 LoadHTML( |
600 "<object id='plugin_small' data='http://a.com/fake1.swf' " | 599 "<object id='plugin_small' data='http://a.com/fake1.swf' " |
601 " type='application/x-ppapi-tests' width='100' height='100'></object>" | 600 " type='application/x-shockwave-flash' width='100' height='100'>" |
| 601 "</object>" |
602 "<object id='plugin_small_poster' data='http://a.com/fake1.swf' " | 602 "<object id='plugin_small_poster' data='http://a.com/fake1.swf' " |
603 " type='application/x-ppapi-tests' width='100' height='100' " | 603 " type='application/x-shockwave-flash' width='100' height='100' " |
604 " poster='click_me.png'></object>" | 604 " poster='click_me.png'></object>" |
605 "<object id='plugin_large' data='http://a.com/fake2.swf' " | 605 "<object id='plugin_large' data='http://a.com/fake2.swf' " |
606 " type='application/x-ppapi-tests' width='400' height='500'>" | 606 " type='application/x-shockwave-flash' width='400' height='500'>" |
607 "</object>"); | 607 "</object>"); |
608 VerifyPluginMarkedEssential(GetActiveWebContents(), "plugin_small"); | 608 VerifyPluginMarkedEssential(GetActiveWebContents(), "plugin_small"); |
609 VerifyPluginMarkedEssential(GetActiveWebContents(), "plugin_small_poster"); | 609 VerifyPluginMarkedEssential(GetActiveWebContents(), "plugin_small_poster"); |
610 VerifyPluginMarkedEssential(GetActiveWebContents(), "plugin_large"); | 610 VerifyPluginMarkedEssential(GetActiveWebContents(), "plugin_large"); |
611 } | 611 } |
612 | 612 |
613 // Flaky on almost all platforms: crbug.com/648827. | 613 // Flaky on almost all platforms: crbug.com/648827. |
614 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, | 614 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, |
615 DISABLED_LargeCrossOriginObscured) { | 615 DISABLED_LargeCrossOriginObscured) { |
616 LoadHTML( | 616 LoadHTML( |
617 "<div id='container' " | 617 "<div id='container' " |
618 " style='width: 100px; height: 400px; overflow: hidden;'>" | 618 " style='width: 100px; height: 400px; overflow: hidden;'>" |
619 " <object id='plugin' data='http://otherorigin.com/fake.swf' " | 619 " <object id='plugin' data='http://otherorigin.com/fake.swf' " |
620 " type='application/x-ppapi-tests' width='400' height='500' " | 620 " type='application/x-shockwave-flash' width='400' height='500' " |
621 " style='float: right;'>" | 621 " style='float: right;'>" |
622 " </object>" | 622 " </object>" |
623 "</div>"); | 623 "</div>"); |
624 VerifyPluginIsThrottled(GetActiveWebContents(), "plugin"); | 624 VerifyPluginIsThrottled(GetActiveWebContents(), "plugin"); |
625 EXPECT_TRUE(VerifySnapshot( | 625 EXPECT_TRUE(VerifySnapshot( |
626 FILE_PATH_LITERAL("large_cross_origin_obscured_expected.png"))); | 626 FILE_PATH_LITERAL("large_cross_origin_obscured_expected.png"))); |
627 | 627 |
628 // Test that's unthrottled if it is unobscured. | 628 // Test that's unthrottled if it is unobscured. |
629 std::string script = | 629 std::string script = |
630 "var container = window.document.getElementById('container');" | 630 "var container = window.document.getElementById('container');" |
631 "container.setAttribute('style', 'width: 400px; height: 400px;');"; | 631 "container.setAttribute('style', 'width: 400px; height: 400px;');"; |
632 ASSERT_TRUE(content::ExecuteScript(GetActiveWebContents(), script)); | 632 ASSERT_TRUE(content::ExecuteScript(GetActiveWebContents(), script)); |
633 VerifyPluginMarkedEssential(GetActiveWebContents(), "plugin"); | 633 VerifyPluginMarkedEssential(GetActiveWebContents(), "plugin"); |
634 } | 634 } |
635 | 635 |
636 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, ExpandingSmallPlugin) { | 636 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, ExpandingSmallPlugin) { |
637 LoadHTML( | 637 LoadHTML( |
638 "<object id='plugin' data='http://otherorigin.com/fake.swf' " | 638 "<object id='plugin' data='http://otherorigin.com/fake.swf' " |
639 " type='application/x-ppapi-tests' width='400' height='80'></object>"); | 639 " type='application/x-shockwave-flash' width='400' height='80'>" |
| 640 "</object>"); |
640 VerifyPluginIsThrottled(GetActiveWebContents(), "plugin"); | 641 VerifyPluginIsThrottled(GetActiveWebContents(), "plugin"); |
641 | 642 |
642 std::string script = "window.document.getElementById('plugin').height = 400;"; | 643 std::string script = "window.document.getElementById('plugin').height = 400;"; |
643 ASSERT_TRUE(content::ExecuteScript(GetActiveWebContents(), script)); | 644 ASSERT_TRUE(content::ExecuteScript(GetActiveWebContents(), script)); |
644 VerifyPluginMarkedEssential(GetActiveWebContents(), "plugin"); | 645 VerifyPluginMarkedEssential(GetActiveWebContents(), "plugin"); |
645 } | 646 } |
646 | 647 |
647 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, BackgroundTabPlugins) { | 648 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, BackgroundTabPlugins) { |
648 content::WebContents* background_contents = LoadHTMLInBackgroundTab( | 649 content::WebContents* background_contents = LoadHTMLInBackgroundTab( |
649 "<object id='same_origin' data='fake.swf' " | 650 "<object id='same_origin' data='fake.swf' " |
650 " type='application/x-ppapi-tests'></object>" | 651 " type='application/x-shockwave-flash'></object>" |
651 "<object id='small_cross_origin' data='http://otherorigin.com/fake1.swf' " | 652 "<object id='small_cross_origin' data='http://otherorigin.com/fake1.swf' " |
652 " type='application/x-ppapi-tests' width='400' height='80'></object>"); | 653 " type='application/x-shockwave-flash' width='400' height='80'>" |
| 654 "</object>"); |
653 | 655 |
654 EXPECT_FALSE(PluginLoaded(background_contents, "same_origin")); | 656 EXPECT_FALSE(PluginLoaded(background_contents, "same_origin")); |
655 EXPECT_FALSE(PluginLoaded(background_contents, "small_cross_origin")); | 657 EXPECT_FALSE(PluginLoaded(background_contents, "small_cross_origin")); |
656 | 658 |
657 ActivateTab(background_contents); | 659 ActivateTab(background_contents); |
658 | 660 |
659 VerifyPluginMarkedEssential(background_contents, "same_origin"); | 661 VerifyPluginMarkedEssential(background_contents, "same_origin"); |
660 VerifyPluginIsThrottled(background_contents, "small_cross_origin"); | 662 VerifyPluginIsThrottled(background_contents, "small_cross_origin"); |
661 } | 663 } |
662 | 664 |
663 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, ZoomIndependent) { | 665 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, ZoomIndependent) { |
664 zoom::ZoomController::FromWebContents(GetActiveWebContents()) | 666 zoom::ZoomController::FromWebContents(GetActiveWebContents()) |
665 ->SetZoomLevel(4.0); | 667 ->SetZoomLevel(4.0); |
666 LoadHTML( | 668 LoadHTML( |
667 "<object id='plugin' data='http://otherorigin.com/fake.swf' " | 669 "<object id='plugin' data='http://otherorigin.com/fake.swf' " |
668 " type='application/x-ppapi-tests' width='400' height='200'>" | 670 " type='application/x-shockwave-flash' width='400' height='200'>" |
669 "</object>"); | 671 "</object>"); |
670 VerifyPluginIsThrottled(GetActiveWebContents(), "plugin"); | 672 VerifyPluginIsThrottled(GetActiveWebContents(), "plugin"); |
671 } | 673 } |
672 | 674 |
673 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, BlockTinyPlugins) { | 675 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, BlockTinyPlugins) { |
674 LoadHTML( | 676 LoadHTML( |
675 "<object id='tiny_same_origin' data='fake.swf' " | 677 "<object id='tiny_same_origin' data='fake.swf' " |
676 " type='application/x-ppapi-tests' width='3' height='3'>" | 678 " type='application/x-shockwave-flash' width='3' height='3'>" |
677 "</object>" | 679 "</object>" |
678 "<object id='tiny_cross_origin_1' data='http://a.com/fake.swf' " | 680 "<object id='tiny_cross_origin_1' data='http://a.com/fake.swf' " |
679 " type='application/x-ppapi-tests' width='3' height='3'>" | 681 " type='application/x-shockwave-flash' width='3' height='3'>" |
680 "</object>" | 682 "</object>" |
681 "<object id='tiny_cross_origin_2' data='http://a.com/fake.swf' " | 683 "<object id='tiny_cross_origin_2' data='http://a.com/fake.swf' " |
682 " type='application/x-ppapi-tests' width='1' height='1'>" | 684 " type='application/x-shockwave-flash' width='1' height='1'>" |
683 "</object>"); | 685 "</object>"); |
684 | 686 |
685 VerifyPluginMarkedEssential(GetActiveWebContents(), "tiny_same_origin"); | 687 VerifyPluginMarkedEssential(GetActiveWebContents(), "tiny_same_origin"); |
686 VerifyPluginIsPlaceholderOnly("tiny_cross_origin_1"); | 688 VerifyPluginIsPlaceholderOnly("tiny_cross_origin_1"); |
687 VerifyPluginIsPlaceholderOnly("tiny_cross_origin_2"); | 689 VerifyPluginIsPlaceholderOnly("tiny_cross_origin_2"); |
688 } | 690 } |
689 | 691 |
690 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, BackgroundTabTinyPlugins) { | 692 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, BackgroundTabTinyPlugins) { |
691 content::WebContents* background_contents = LoadHTMLInBackgroundTab( | 693 content::WebContents* background_contents = LoadHTMLInBackgroundTab( |
692 "<object id='tiny' data='http://a.com/fake.swf' " | 694 "<object id='tiny' data='http://a.com/fake.swf' " |
693 " type='application/x-ppapi-tests' width='3' height='3'>" | 695 " type='application/x-shockwave-flash' width='3' height='3'>" |
694 "</object>"); | 696 "</object>"); |
695 EXPECT_FALSE(PluginLoaded(background_contents, "tiny")); | 697 EXPECT_FALSE(PluginLoaded(background_contents, "tiny")); |
696 | 698 |
697 ActivateTab(background_contents); | 699 ActivateTab(background_contents); |
698 VerifyPluginIsPlaceholderOnly("tiny"); | 700 VerifyPluginIsPlaceholderOnly("tiny"); |
699 } | 701 } |
700 | 702 |
701 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, ExpandingTinyPlugins) { | 703 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, ExpandingTinyPlugins) { |
702 LoadHTML( | 704 LoadHTML( |
703 "<object id='expand_to_peripheral' data='http://a.com/fake.swf' " | 705 "<object id='expand_to_peripheral' data='http://a.com/fake.swf' " |
704 " type='application/x-ppapi-tests' width='4' height='4'></object>" | 706 " type='application/x-shockwave-flash' width='4' height='4'></object>" |
705 "<object id='expand_to_essential' data='http://b.com/fake.swf' " | 707 "<object id='expand_to_essential' data='http://b.com/fake.swf' " |
706 " type='application/x-ppapi-tests' width='4' height='4'></object>"); | 708 " type='application/x-shockwave-flash' width='4' height='4'>" |
| 709 "</object>"); |
707 | 710 |
708 VerifyPluginIsPlaceholderOnly("expand_to_peripheral"); | 711 VerifyPluginIsPlaceholderOnly("expand_to_peripheral"); |
709 VerifyPluginIsPlaceholderOnly("expand_to_essential"); | 712 VerifyPluginIsPlaceholderOnly("expand_to_essential"); |
710 | 713 |
711 std::string script = | 714 std::string script = |
712 "window.document.getElementById('expand_to_peripheral').height = 200;" | 715 "window.document.getElementById('expand_to_peripheral').height = 200;" |
713 "window.document.getElementById('expand_to_peripheral').width = 200;" | 716 "window.document.getElementById('expand_to_peripheral').width = 200;" |
714 "window.document.getElementById('expand_to_essential').height = 400;" | 717 "window.document.getElementById('expand_to_essential').height = 400;" |
715 "window.document.getElementById('expand_to_essential').width = 400;"; | 718 "window.document.getElementById('expand_to_essential').width = 400;"; |
716 ASSERT_TRUE(content::ExecuteScript(GetActiveWebContents(), script)); | 719 ASSERT_TRUE(content::ExecuteScript(GetActiveWebContents(), script)); |
717 | 720 |
718 VerifyPluginIsThrottled(GetActiveWebContents(), "expand_to_peripheral"); | 721 VerifyPluginIsThrottled(GetActiveWebContents(), "expand_to_peripheral"); |
719 VerifyPluginMarkedEssential(GetActiveWebContents(), "expand_to_essential"); | 722 VerifyPluginMarkedEssential(GetActiveWebContents(), "expand_to_essential"); |
720 } | 723 } |
721 | 724 |
722 // Separate test case that allows tiny plugins. This requires a separate test | 725 // Separate test case that allows tiny plugins. This requires a separate test |
723 // case, because we need to initialize the renderer with a different feature | 726 // case, because we need to initialize the renderer with a different feature |
724 // setting. | 727 // setting. |
725 class PluginPowerSaverAllowTinyBrowserTest | 728 class PluginPowerSaverAllowTinyBrowserTest |
726 : public PluginPowerSaverBrowserTest { | 729 : public PluginPowerSaverBrowserTest { |
727 public: | 730 public: |
728 void SetUpInProcessBrowserTestFixture() override { | 731 void SetUpInProcessBrowserTestFixture() override { |
| 732 PluginPowerSaverBrowserTest::SetUpInProcessBrowserTestFixture(); |
729 feature_list.InitAndDisableFeature(features::kBlockSmallContent); | 733 feature_list.InitAndDisableFeature(features::kBlockSmallContent); |
730 } | 734 } |
731 | 735 |
732 private: | 736 private: |
733 base::test::ScopedFeatureList feature_list; | 737 base::test::ScopedFeatureList feature_list; |
734 }; | 738 }; |
735 | 739 |
736 IN_PROC_BROWSER_TEST_F(PluginPowerSaverAllowTinyBrowserTest, | 740 IN_PROC_BROWSER_TEST_F(PluginPowerSaverAllowTinyBrowserTest, |
737 EssentialTinyPlugins) { | 741 EssentialTinyPlugins) { |
738 LoadHTML( | 742 LoadHTML( |
739 "<object id='tiny_cross_origin_1' data='http://a.com/fake.swf' " | 743 "<object id='tiny_cross_origin_1' data='http://a.com/fake.swf' " |
740 " type='application/x-ppapi-tests' width='3' height='3'>" | 744 " type='application/x-shockwave-flash' width='3' height='3'>" |
741 "</object>" | 745 "</object>" |
742 "<object id='tiny_cross_origin_2' data='http://a.com/fake.swf' " | 746 "<object id='tiny_cross_origin_2' data='http://a.com/fake.swf' " |
743 " type='application/x-ppapi-tests' width='1' height='1'>" | 747 " type='application/x-shockwave-flash' width='1' height='1'>" |
744 "</object>"); | 748 "</object>"); |
745 | 749 |
746 VerifyPluginMarkedEssential(GetActiveWebContents(), "tiny_cross_origin_1"); | 750 VerifyPluginMarkedEssential(GetActiveWebContents(), "tiny_cross_origin_1"); |
747 VerifyPluginMarkedEssential(GetActiveWebContents(), "tiny_cross_origin_2"); | 751 VerifyPluginMarkedEssential(GetActiveWebContents(), "tiny_cross_origin_2"); |
748 } | 752 } |
OLD | NEW |