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

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

Issue 1412963003: Plugin Power Saver: Implement pixel tests for plugin placeholders. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: git cl formatted 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
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/stl_util.h"
6 #include "base/strings/string_piece.h" 7 #include "base/strings/string_piece.h"
7 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "base/test/test_switches.h"
8 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
11 #include "chrome/browser/ui/browser_window.h"
9 #include "chrome/browser/ui/tabs/tab_strip_model.h" 12 #include "chrome/browser/ui/tabs/tab_strip_model.h"
10 #include "chrome/common/chrome_switches.h" 13 #include "chrome/common/chrome_switches.h"
11 #include "chrome/test/base/in_process_browser_test.h" 14 #include "chrome/test/base/in_process_browser_test.h"
12 #include "chrome/test/base/ui_test_utils.h" 15 #include "chrome/test/base/ui_test_utils.h"
13 #include "components/ui/zoom/zoom_controller.h" 16 #include "components/ui/zoom/zoom_controller.h"
17 #include "content/public/browser/readback_types.h"
18 #include "content/public/browser/render_view_host.h"
19 #include "content/public/browser/render_widget_host.h"
14 #include "content/public/common/content_switches.h" 20 #include "content/public/common/content_switches.h"
15 #include "content/public/test/browser_test_utils.h" 21 #include "content/public/test/browser_test_utils.h"
16 #include "content/public/test/ppapi_test_utils.h" 22 #include "content/public/test/ppapi_test_utils.h"
17 #include "net/test/embedded_test_server/embedded_test_server.h" 23 #include "net/test/embedded_test_server/embedded_test_server.h"
18 #include "net/test/embedded_test_server/http_request.h" 24 #include "net/test/embedded_test_server/http_request.h"
19 #include "net/test/embedded_test_server/http_response.h" 25 #include "net/test/embedded_test_server/http_response.h"
20 #include "ppapi/shared_impl/ppapi_switches.h" 26 #include "ppapi/shared_impl/ppapi_switches.h"
21 #include "third_party/WebKit/public/web/WebInputEvent.h" 27 #include "third_party/WebKit/public/web/WebInputEvent.h"
28 #include "third_party/skia/include/core/SkBitmap.h"
22 #include "ui/base/window_open_disposition.h" 29 #include "ui/base/window_open_disposition.h"
30 #include "ui/gfx/codec/png_codec.h"
23 #include "ui/gfx/geometry/point.h" 31 #include "ui/gfx/geometry/point.h"
32 #include "ui/gfx/screen.h"
24 33
25 namespace { 34 namespace {
26 35
36 // Use fixed browser dimensions for pixel tests.
37 const int kBrowserWidth = 600;
38 const int kBrowserHeight = 700;
39
40 // Compare only a portion of the snapshots, as different platforms will
41 // capture different sized snapshots (due to differences in browser chrome).
42 const int kComparisonWidth = 500;
43 const int kComparisonHeight = 600;
44
45 // Different platforms have slightly different pixel output, due to different
46 // graphics implementations. Slightly different pixels (in BGR space) are still
47 // counted as a matching pixel by this simple manhattan distance threshold.
48 const int kPixelManhattanDistanceTolerance = 8;
49
27 std::string RunTestScript(base::StringPiece test_script, 50 std::string RunTestScript(base::StringPiece test_script,
28 content::WebContents* contents, 51 content::WebContents* contents,
29 const std::string& element_id) { 52 const std::string& element_id) {
30 std::string script = base::StringPrintf( 53 std::string script = base::StringPrintf(
31 "var plugin = window.document.getElementById('%s');" 54 "var plugin = window.document.getElementById('%s');"
32 "if (plugin === undefined ||" 55 "if (plugin === undefined ||"
33 " (plugin.nodeName !== 'OBJECT' && plugin.nodeName !== 'EMBED')) {" 56 " (plugin.nodeName !== 'OBJECT' && plugin.nodeName !== 'EMBED')) {"
34 " window.domAutomationController.send('error');" 57 " window.domAutomationController.send('error');"
35 "} else {" 58 "} else {"
36 " %s" 59 " %s"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 scoped_ptr<net::test_server::HttpResponse> RespondWithHTML( 121 scoped_ptr<net::test_server::HttpResponse> RespondWithHTML(
99 const std::string& html, 122 const std::string& html,
100 const net::test_server::HttpRequest& request) { 123 const net::test_server::HttpRequest& request) {
101 scoped_ptr<net::test_server::BasicHttpResponse> response( 124 scoped_ptr<net::test_server::BasicHttpResponse> response(
102 new net::test_server::BasicHttpResponse()); 125 new net::test_server::BasicHttpResponse());
103 response->set_content_type("text/html"); 126 response->set_content_type("text/html");
104 response->set_content(html); 127 response->set_content(html);
105 return response.Pass(); 128 return response.Pass();
106 } 129 }
107 130
131 bool SnapshotMatches(const base::FilePath& reference, const SkBitmap& bitmap) {
132 if (bitmap.width() < kComparisonWidth ||
133 bitmap.height() < kComparisonHeight) {
134 return false;
135 }
136
137 std::string reference_data;
138 if (!base::ReadFileToString(reference, &reference_data))
139 return false;
140
141 int w = 0;
142 int h = 0;
143 std::vector<unsigned char> decoded;
144 if (!gfx::PNGCodec::Decode(
145 reinterpret_cast<unsigned char*>(string_as_array(&reference_data)),
146 reference_data.size(), gfx::PNGCodec::FORMAT_BGRA, &decoded, &w,
147 &h)) {
148 return false;
149 }
150
151 if (w < kComparisonWidth || h < kComparisonHeight)
152 return false;
153
154 int32_t* ref_pixels = reinterpret_cast<int32_t*>(&decoded[0]);
Lei Zhang 2015/10/21 23:25:33 vector_as_array
tommycli 2015/10/21 23:57:22 Done.
155 SkAutoLockPixels lock_image(bitmap);
156 int32_t* pixels = static_cast<int32_t*>(bitmap.getPixels());
157
158 int stride = bitmap.rowBytes();
159 for (int y = 0; y < kComparisonHeight; ++y) {
160 for (int x = 0; x < kComparisonWidth; ++x) {
161 int32_t pixel = pixels[y * stride / sizeof(int32_t) + x];
162 int pixel_b = pixel & 0xFF;
163 int pixel_g = (pixel >> 8) & 0xFF;
164 int pixel_r = (pixel >> 16) & 0xFF;
165
166 int32_t ref_pixel = ref_pixels[y * w + x];
167 int ref_pixel_b = ref_pixel & 0xFF;
168 int ref_pixel_g = (ref_pixel >> 8) & 0xFF;
169 int ref_pixel_r = (ref_pixel >> 16) & 0xFF;
170
171 int manhattan_distance = abs(pixel_b - ref_pixel_b) +
172 abs(pixel_g - ref_pixel_g) +
173 abs(pixel_r - ref_pixel_r);
174
175 if (manhattan_distance > kPixelManhattanDistanceTolerance)
176 return false;
177 }
178 }
179
180 return true;
181 }
182
183 // |snapshot_matches| is set to true if the snapshot matches the reference and
184 // the test passes. Otherwise, set to false.
185 void CompareSnapshotToReference(const base::FilePath& reference,
186 bool* snapshot_matches,
187 const base::Closure& done_cb,
188 const SkBitmap& bitmap,
189 content::ReadbackResponse response) {
190 DCHECK(snapshot_matches);
191 if (response != content::READBACK_SUCCESS) {
192 *snapshot_matches = false;
193 done_cb.Run();
194 return;
195 }
196
197 *snapshot_matches = SnapshotMatches(reference, bitmap);
198
199 // When rebaselining the pixel test, the test will fail, and we will
200 // overwrite the reference file. On the next try through, the test will then
201 // pass, since we just overwrote the reference file. A bit wonky.
202 if (!(*snapshot_matches) &&
203 base::CommandLine::ForCurrentProcess()->HasSwitch(
204 switches::kRebaselinePixelTests)) {
205 SkBitmap clipped_bitmap;
206 bitmap.extractSubset(&clipped_bitmap,
207 SkIRect::MakeWH(kComparisonWidth, kComparisonHeight));
208 std::vector<unsigned char> png_data;
209 gfx::PNGCodec::EncodeBGRASkBitmap(clipped_bitmap, false, &png_data);
210 base::WriteFile(reference,
211 reinterpret_cast<const char*>(vector_as_array(&png_data)),
212 png_data.size());
213 }
214
215 done_cb.Run();
216 }
217
108 } // namespace 218 } // namespace
109 219
110 class PluginPowerSaverBrowserTest : public InProcessBrowserTest { 220 class PluginPowerSaverBrowserTest : public InProcessBrowserTest {
111 public: 221 public:
222 void SetUp() override {
223 EnablePixelOutput();
224 InProcessBrowserTest::SetUp();
225 }
226
112 void SetUpOnMainThread() override { 227 void SetUpOnMainThread() override {
113 InProcessBrowserTest::SetUpOnMainThread(); 228 InProcessBrowserTest::SetUpOnMainThread();
114 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 229 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
230
231 embedded_test_server()->ServeFilesFromDirectory(
232 ui_test_utils::GetTestFilePath(
233 base::FilePath(FILE_PATH_LITERAL("plugin_power_saver")),
234 base::FilePath()));
115 } 235 }
116 236
117 void SetUpCommandLine(base::CommandLine* command_line) override { 237 void SetUpCommandLine(base::CommandLine* command_line) override {
118 command_line->AppendSwitch(switches::kEnablePluginPowerSaver); 238 command_line->AppendSwitch(switches::kEnablePluginPowerSaver);
119 command_line->AppendSwitch(switches::kEnablePepperTesting); 239 command_line->AppendSwitch(switches::kEnablePepperTesting);
120 command_line->AppendSwitch(switches::kEnablePluginPlaceholderTesting); 240 command_line->AppendSwitch(switches::kEnablePluginPlaceholderTesting);
121 command_line->AppendSwitchASCII( 241 command_line->AppendSwitchASCII(
122 switches::kOverridePluginPowerSaverForTesting, "ignore-list"); 242 switches::kOverridePluginPowerSaverForTesting, "ignore-list");
123 243
124 ASSERT_TRUE(ppapi::RegisterPowerSaverTestPlugin(command_line)); 244 ASSERT_TRUE(ppapi::RegisterPowerSaverTestPlugin(command_line));
125 } 245 }
126 246
127 protected: 247 protected:
128 void LoadHTML(const std::string& html) { 248 void LoadHTML(const std::string& html) {
249 gfx::Rect bounds(gfx::Rect(0, 0, kBrowserWidth, kBrowserHeight));
250 gfx::Rect screen_bounds =
251 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().bounds();
252 ASSERT_GT(screen_bounds.width(), kBrowserWidth);
253 ASSERT_GT(screen_bounds.height(), kBrowserHeight);
254 browser()->window()->SetBounds(bounds);
255
129 ASSERT_TRUE(embedded_test_server()->Started()); 256 ASSERT_TRUE(embedded_test_server()->Started());
130 embedded_test_server()->RegisterRequestHandler( 257 embedded_test_server()->RegisterRequestHandler(
131 base::Bind(&RespondWithHTML, html)); 258 base::Bind(&RespondWithHTML, html));
132 ui_test_utils::NavigateToURL(browser(), embedded_test_server()->base_url()); 259 ui_test_utils::NavigateToURL(browser(), embedded_test_server()->base_url());
133 EXPECT_TRUE(content::WaitForRenderFrameReady( 260 EXPECT_TRUE(content::WaitForRenderFrameReady(
134 GetActiveWebContents()->GetMainFrame())); 261 GetActiveWebContents()->GetMainFrame()));
135 } 262 }
136 263
137 content::WebContents* GetActiveWebContents() { 264 content::WebContents* GetActiveWebContents() {
138 return browser()->tab_strip_model()->GetActiveWebContents(); 265 return browser()->tab_strip_model()->GetActiveWebContents();
(...skipping 22 matching lines...) Expand all
161 " plugin.removeEventListener('message', handleEvent);" 288 " plugin.removeEventListener('message', handleEvent);"
162 "}", 289 "}",
163 GetActiveWebContents(), element_id); 290 GetActiveWebContents(), element_id);
164 ASSERT_EQ("ready", result); 291 ASSERT_EQ("ready", result);
165 292
166 content::SimulateMouseClickAt(GetActiveWebContents(), 0 /* modifiers */, 293 content::SimulateMouseClickAt(GetActiveWebContents(), 0 /* modifiers */,
167 blink::WebMouseEvent::ButtonLeft, point); 294 blink::WebMouseEvent::ButtonLeft, point);
168 295
169 VerifyPluginMarkedEssential(GetActiveWebContents(), element_id); 296 VerifyPluginMarkedEssential(GetActiveWebContents(), element_id);
170 } 297 }
298
299 bool VerifySnapshot(const std::string& expected_filename) {
300 // If we are rebaselining, give the placeholders an extra 2 seconds to
301 // settle, so we write the correct reference images. See comment below.
302 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
303 switches::kRebaselinePixelTests)) {
304 base::MessageLoop::current()->task_runner()->PostDelayedTask(
305 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(),
306 base::TimeDelta::FromSeconds(2));
307 content::RunMessageLoop();
308 }
309
310 base::FilePath reference = ui_test_utils::GetTestFilePath(
311 base::FilePath(FILE_PATH_LITERAL("plugin_power_saver")),
312 base::FilePath().AppendASCII(expected_filename));
313
314 // Because of how Pepper painting works, even if the plugin is ready, the
315 // image data may not have arrived in the backing store. Retry verifying
316 // the snapshot with a timeout.
317 return ui_test_utils::RunLoopUntil(
318 base::Bind(&PluginPowerSaverBrowserTest::TryVerifySnapshot,
319 base::Unretained(this), reference));
320 }
321
322 private:
323 bool TryVerifySnapshot(const base::FilePath& reference) {
324 bool snapshot_matches = false;
325
326 content::RenderWidgetHost* rwh =
327 GetActiveWebContents()->GetRenderViewHost()->GetWidget();
328
329 // When a widget is first shown, it can take some time before it is ready
330 // for copying from its backing store. This is a transient condition, and
331 // so it is not being treated as a test failure.
332 if (!rwh->CanCopyFromBackingStore())
333 return false;
334
335 rwh->CopyFromBackingStore(
336 gfx::Rect(), gfx::Size(),
337 base::Bind(&CompareSnapshotToReference, reference, &snapshot_matches,
338 base::MessageLoop::QuitWhenIdleClosure()),
339 kN32_SkColorType);
340
341 content::RunMessageLoop();
342
343 return snapshot_matches;
344 }
171 }; 345 };
172 346
173 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, SmallSameOrigin) { 347 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, SmallSameOrigin) {
174 LoadHTML( 348 LoadHTML(
175 "<object id='plugin' data='fake.swf' " 349 "<object id='plugin' data='fake.swf' "
176 " type='application/x-ppapi-tests' width='400' height='100'>" 350 " type='application/x-ppapi-tests' width='400' height='100'>"
177 "</object>"); 351 "</object>");
178 VerifyPluginMarkedEssential(GetActiveWebContents(), "plugin"); 352 VerifyPluginMarkedEssential(GetActiveWebContents(), "plugin");
179 } 353 }
180 354
181 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, SmallCrossOrigin) { 355 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, SmallCrossOrigin) {
182 LoadHTML( 356 LoadHTML(
183 "<object id='plugin' data='http://otherorigin.com/fake.swf' " 357 "<object id='plugin' data='http://otherorigin.com/fake.swf' "
184 " type='application/x-ppapi-tests' width='400' height='100'>" 358 " type='application/x-ppapi-tests' width='400' height='100'>"
359 "</object>"
360 "<br>"
361 "<object id='plugin_poster' data='http://otherorigin.com/fake.swf' "
362 " type='application/x-ppapi-tests' width='400' height='100' "
363 " poster='click_me.png'>"
185 "</object>"); 364 "</object>");
365
186 VerifyPluginIsThrottled(GetActiveWebContents(), "plugin"); 366 VerifyPluginIsThrottled(GetActiveWebContents(), "plugin");
367 EXPECT_FALSE(PluginLoaded(GetActiveWebContents(), "plugin_poster"));
368
369 EXPECT_TRUE(VerifySnapshot("small_cross_origin_expected.png"));
187 370
188 SimulateClickAndAwaitMarkedEssential("plugin", gfx::Point(50, 50)); 371 SimulateClickAndAwaitMarkedEssential("plugin", gfx::Point(50, 50));
372 SimulateClickAndAwaitMarkedEssential("plugin_poster", gfx::Point(50, 150));
189 } 373 }
190 374
191 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, LargeCrossOrigin) { 375 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, LargeCrossOrigin) {
192 LoadHTML( 376 LoadHTML(
193 "<object id='large' data='http://otherorigin.com/fake.swf' " 377 "<object id='large' data='http://otherorigin.com/fake.swf' "
194 " type='application/x-ppapi-tests' width='400' height='500'>" 378 " type='application/x-ppapi-tests' width='400' height='500'>"
195 "</object>" 379 "</object>"
196 "<object id='medium_16_9' data='http://otherorigin.com/fake.swf' " 380 "<object id='medium_16_9' data='http://otherorigin.com/fake.swf' "
197 " type='application/x-ppapi-tests' width='480' height='270'>" 381 " type='application/x-ppapi-tests' width='480' height='270'>"
198 "</object>"); 382 "</object>");
199 VerifyPluginMarkedEssential(GetActiveWebContents(), "large"); 383 VerifyPluginMarkedEssential(GetActiveWebContents(), "large");
200 VerifyPluginMarkedEssential(GetActiveWebContents(), "medium_16_9"); 384 VerifyPluginMarkedEssential(GetActiveWebContents(), "medium_16_9");
201 } 385 }
202 386
203 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, 387 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, SmallerThanPlayIcon) {
204 LargePluginsPeripheralWhenPosterSpecified) { 388 LoadHTML(
389 "<object id='plugin_16' type='application/x-ppapi-tests' "
390 " width='16' height='16'></object>"
391 "<object id='plugin_32' type='application/x-ppapi-tests' "
392 " width='32' height='32'></object>"
393 "<object id='plugin_16_64' type='application/x-ppapi-tests' "
394 " width='16' height='64'></object>"
395 "<object id='plugin_64_16' type='application/x-ppapi-tests' "
396 " width='64' height='16'></object>");
397
398 VerifyPluginIsThrottled(GetActiveWebContents(), "plugin_16");
399 VerifyPluginIsThrottled(GetActiveWebContents(), "plugin_32");
400 VerifyPluginIsThrottled(GetActiveWebContents(), "plugin_16_64");
401 VerifyPluginIsThrottled(GetActiveWebContents(), "plugin_64_16");
402
403 EXPECT_TRUE(VerifySnapshot("smaller_than_play_icon_expected.png"));
404 }
405
406 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, PosterTests) {
407 // This test simultaneously verifies the varied supported poster syntaxes,
408 // as well as verifies that the poster is rendered correctly with various
409 // mismatched aspect ratios and sizes, following the same rules as VIDEO.
205 LoadHTML( 410 LoadHTML(
206 "<object id='plugin_src' type='application/x-ppapi-tests' " 411 "<object id='plugin_src' type='application/x-ppapi-tests' "
207 " width='400' height='500' poster='snapshot1x.png'></object>" 412 " width='100' height='100' poster='click_me.png'></object>"
208 "<object id='plugin_srcset' type='application/x-ppapi-tests' " 413 "<object id='plugin_srcset' type='application/x-ppapi-tests' "
209 " width='400' height='500' " 414 " width='100' height='100' "
210 " poster='snapshot1x.png 1x, snapshot2x.png 2x'></object>" 415 " poster='click_me.png 1x, click_me.png 2x'></object>"
211 "<object id='plugin_legacy_syntax' type='application/x-ppapi-tests' " 416 "<br>"
212 " width='400' height='500'>" 417
213 " <param name='poster' value='snapshot1x.png 1x, snapshot2x.png 2x'>" 418 "<object id='plugin_poster_param' type='application/x-ppapi-tests' "
419 " width='100' height='100'>"
420 " <param name='poster' value='click_me.png 1x, click_me.png 2x'>"
214 "</object>" 421 "</object>"
215 "<embed id='plugin_embed_src' type='application/x-ppapi-tests' " 422 "<embed id='plugin_embed_src' type='application/x-ppapi-tests' "
216 " width='400' height='500' poster='snapshot1x.png'></embed>" 423 " width='100' height='100' poster='click_me.png'></embed>"
217 "<embed id='plugin_embed_srcset' type='application/x-ppapi-tests' " 424 "<embed id='plugin_embed_srcset' type='application/x-ppapi-tests' "
218 " width='400' height='500'" 425 " width='100' height='100'"
219 " poster='snapshot1x.png 1x, snapshot2x.png 2x'></embed>"); 426 " poster='click_me.png 1x, click_me.png 2x'></embed>"
427 "<br>"
428
429 "<object id='poster_missing' type='application/x-ppapi-tests' "
430 " width='100' height='100' poster='missing.png'></object>"
431 "<object id='poster_too_small' type='application/x-ppapi-tests' "
432 " width='100' height='50' poster='click_me.png'></object>"
433 "<object id='poster_too_big' type='application/x-ppapi-tests' "
434 " width='100' height='150' poster='click_me.png'></object>"
435 "<br>"
436
437 "<object id='poster_16' type='application/x-ppapi-tests' "
438 " width='16' height='16' poster='click_me.png'></object>"
439 "<object id='poster_32' type='application/x-ppapi-tests' "
440 " width='32' height='32' poster='click_me.png'></object>"
441 "<object id='poster_16_64' type='application/x-ppapi-tests' "
442 " width='16' height='64' poster='click_me.png'></object>"
443 "<object id='poster_64_16' type='application/x-ppapi-tests' "
444 " width='64' height='16' poster='click_me.png'></object>"
445 "<br>"
446
447 "<div id='container' "
448 " style='width: 400px; height: 100px; overflow: hidden;'>"
449 " <object id='poster_obscured' data='http://otherorigin.com/fake.swf' "
450 " type='application/x-ppapi-tests' width='400' height='500' "
451 " poster='click_me.png'>"
452 " </object>"
453 "</div>");
220 454
221 EXPECT_FALSE(PluginLoaded(GetActiveWebContents(), "plugin_src")); 455 EXPECT_FALSE(PluginLoaded(GetActiveWebContents(), "plugin_src"));
222 EXPECT_FALSE(PluginLoaded(GetActiveWebContents(), "plugin_srcset")); 456 EXPECT_FALSE(PluginLoaded(GetActiveWebContents(), "plugin_srcset"));
223 EXPECT_FALSE(PluginLoaded(GetActiveWebContents(), "plugin_legacy_syntax")); 457
458 EXPECT_FALSE(PluginLoaded(GetActiveWebContents(), "plugin_poster_param"));
224 EXPECT_FALSE(PluginLoaded(GetActiveWebContents(), "plugin_embed_src")); 459 EXPECT_FALSE(PluginLoaded(GetActiveWebContents(), "plugin_embed_src"));
225 EXPECT_FALSE(PluginLoaded(GetActiveWebContents(), "plugin_embed_srcset")); 460 EXPECT_FALSE(PluginLoaded(GetActiveWebContents(), "plugin_embed_srcset"));
461
462 EXPECT_FALSE(PluginLoaded(GetActiveWebContents(), "poster_missing"));
463 EXPECT_FALSE(PluginLoaded(GetActiveWebContents(), "poster_too_small"));
464 EXPECT_FALSE(PluginLoaded(GetActiveWebContents(), "poster_too_big"));
465
466 EXPECT_FALSE(PluginLoaded(GetActiveWebContents(), "poster_16"));
467 EXPECT_FALSE(PluginLoaded(GetActiveWebContents(), "poster_32"));
468 EXPECT_FALSE(PluginLoaded(GetActiveWebContents(), "poster_16_64"));
469 EXPECT_FALSE(PluginLoaded(GetActiveWebContents(), "poster_64_16"));
470
471 EXPECT_FALSE(PluginLoaded(GetActiveWebContents(), "poster_obscured"));
472
473 EXPECT_TRUE(VerifySnapshot("poster_tests_expected.png"));
226 } 474 }
227 475
228 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, 476 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest,
229 PluginMarkedEssentialAfterPosterClicked) { 477 PluginMarkedEssentialAfterPosterClicked) {
230 LoadHTML( 478 LoadHTML(
231 "<object id='plugin' type='application/x-ppapi-tests' " 479 "<object id='plugin' type='application/x-ppapi-tests' "
232 " width='400' height='100' poster='snapshot1x.png'></object>"); 480 " width='400' height='100' poster='snapshot1x.png'></object>");
233 EXPECT_FALSE(PluginLoaded(GetActiveWebContents(), "plugin")); 481 EXPECT_FALSE(PluginLoaded(GetActiveWebContents(), "plugin"));
234 482
235 SimulateClickAndAwaitMarkedEssential("plugin", gfx::Point(50, 50)); 483 SimulateClickAndAwaitMarkedEssential("plugin", gfx::Point(50, 50));
236 } 484 }
237 485
238 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, OriginWhitelisting) { 486 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, OriginWhitelisting) {
239 LoadHTML( 487 LoadHTML(
240 "<object id='plugin1' data='http://otherorigin.com/fake1.swf' " 488 "<object id='plugin1' data='http://otherorigin.com/fake1.swf' "
241 " type='application/x-ppapi-tests' width='400' height='100'></object>" 489 " type='application/x-ppapi-tests' width='400' height='100'></object>"
242 "<object id='plugin2' data='http://otherorigin.com/fake2.swf' " 490 "<object id='plugin2' data='http://otherorigin.com/fake2.swf' "
243 " type='application/x-ppapi-tests' width='400' height='500'>" 491 " type='application/x-ppapi-tests' width='400' height='500'>"
244 "</object>"); 492 "</object>");
245 VerifyPluginMarkedEssential(GetActiveWebContents(), "plugin1"); 493 VerifyPluginMarkedEssential(GetActiveWebContents(), "plugin1");
246 VerifyPluginMarkedEssential(GetActiveWebContents(), "plugin2"); 494 VerifyPluginMarkedEssential(GetActiveWebContents(), "plugin2");
247 } 495 }
248 496
249 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, LargeCrossOriginObscured) { 497 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, LargeCrossOriginObscured) {
250 LoadHTML( 498 LoadHTML(
251 "<div id='container' " 499 "<div id='container' "
252 " style='width: 400px; height: 100px; overflow: hidden;'>" 500 " style='width: 100px; height: 400px; overflow: hidden;'>"
253 " <object id='plugin' data='http://otherorigin.com/fake.swf' " 501 " <object id='plugin' data='http://otherorigin.com/fake.swf' "
254 " type='application/x-ppapi-tests' width='400' height='500'>" 502 " type='application/x-ppapi-tests' width='400' height='500' "
503 " style='float: right;'>"
255 " </object>" 504 " </object>"
256 "</div>"); 505 "</div>");
257 VerifyPluginIsThrottled(GetActiveWebContents(), "plugin"); 506 VerifyPluginIsThrottled(GetActiveWebContents(), "plugin");
507 EXPECT_TRUE(VerifySnapshot("large_cross_origin_obscured_expected.png"));
258 508
259 // Test that's unthrottled if it is unobscured. 509 // Test that's unthrottled if it is unobscured.
260 std::string script = 510 std::string script =
261 "var container = window.document.getElementById('container');" 511 "var container = window.document.getElementById('container');"
262 "container.setAttribute('style', 'width: 400px; height: 400px;');"; 512 "container.setAttribute('style', 'width: 400px; height: 400px;');";
263 ASSERT_TRUE(content::ExecuteScript(GetActiveWebContents(), script)); 513 ASSERT_TRUE(content::ExecuteScript(GetActiveWebContents(), script));
264 VerifyPluginMarkedEssential(GetActiveWebContents(), "plugin"); 514 VerifyPluginMarkedEssential(GetActiveWebContents(), "plugin");
265 } 515 }
266 516
267 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, ExpandingSmallPlugin) { 517 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, ExpandingSmallPlugin) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 555
306 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, ZoomIndependent) { 556 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, ZoomIndependent) {
307 ui_zoom::ZoomController::FromWebContents(GetActiveWebContents()) 557 ui_zoom::ZoomController::FromWebContents(GetActiveWebContents())
308 ->SetZoomLevel(4.0); 558 ->SetZoomLevel(4.0);
309 LoadHTML( 559 LoadHTML(
310 "<object id='plugin' data='http://otherorigin.com/fake.swf' " 560 "<object id='plugin' data='http://otherorigin.com/fake.swf' "
311 " type='application/x-ppapi-tests' width='400' height='200'>" 561 " type='application/x-ppapi-tests' width='400' height='200'>"
312 "</object>"); 562 "</object>");
313 VerifyPluginIsThrottled(GetActiveWebContents(), "plugin"); 563 VerifyPluginIsThrottled(GetActiveWebContents(), "plugin");
314 } 564 }
OLDNEW
« no previous file with comments | « base/test/test_switches.cc ('k') | chrome/browser/ui/exclusive_access/flash_fullscreen_interactive_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698