| 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 "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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 " type='application/x-ppapi-tests' width='400' height='100'></object>" | 217 " type='application/x-ppapi-tests' width='400' height='100'></object>" |
| 218 "<object id='plugin2' data='http://otherorigin.com/fake2.swf' " | 218 "<object id='plugin2' data='http://otherorigin.com/fake2.swf' " |
| 219 " type='application/x-ppapi-tests' width='400' height='500'>" | 219 " type='application/x-ppapi-tests' width='400' height='500'>" |
| 220 "</object>"); | 220 "</object>"); |
| 221 VerifyPluginMarkedEssential(GetActiveWebContents(), "plugin1"); | 221 VerifyPluginMarkedEssential(GetActiveWebContents(), "plugin1"); |
| 222 VerifyPluginMarkedEssential(GetActiveWebContents(), "plugin2"); | 222 VerifyPluginMarkedEssential(GetActiveWebContents(), "plugin2"); |
| 223 } | 223 } |
| 224 | 224 |
| 225 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, LargeCrossOriginObscured) { | 225 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, LargeCrossOriginObscured) { |
| 226 LoadHTML( | 226 LoadHTML( |
| 227 "<div style='width: 100px; height: 100px; overflow: hidden;'>" | 227 "<div id='container' " |
| 228 " style='width: 400px; height: 100px; overflow: hidden;'>" |
| 228 " <object id='plugin' data='http://otherorigin.com/fake.swf' " | 229 " <object id='plugin' data='http://otherorigin.com/fake.swf' " |
| 229 " type='application/x-ppapi-tests' width='400' height='500'>" | 230 " type='application/x-ppapi-tests' width='400' height='500'>" |
| 230 " </object>" | 231 " </object>" |
| 231 "</div>"); | 232 "</div>"); |
| 232 VerifyPluginIsThrottled(GetActiveWebContents(), "plugin"); | 233 VerifyPluginIsThrottled(GetActiveWebContents(), "plugin"); |
| 234 |
| 235 // Test that's unthrottled if it is unobscured. |
| 236 std::string script = |
| 237 "var container = window.document.getElementById('container');" |
| 238 "container.setAttribute('style', 'width: 400px; height: 400px;');"; |
| 239 ASSERT_TRUE(content::ExecuteScript(GetActiveWebContents(), script)); |
| 240 VerifyPluginMarkedEssential(GetActiveWebContents(), "plugin"); |
| 241 } |
| 242 |
| 243 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, ExpandingSmallPlugin) { |
| 244 LoadHTML( |
| 245 "<object id='plugin' data='http://otherorigin.com/fake.swf' " |
| 246 " type='application/x-ppapi-tests' width='400' height='80'></object>"); |
| 247 VerifyPluginIsThrottled(GetActiveWebContents(), "plugin"); |
| 248 |
| 249 std::string script = "window.document.getElementById('plugin').height = 400;"; |
| 250 ASSERT_TRUE(content::ExecuteScript(GetActiveWebContents(), script)); |
| 251 VerifyPluginMarkedEssential(GetActiveWebContents(), "plugin"); |
| 233 } | 252 } |
| 234 | 253 |
| 235 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, BackgroundTabPlugins) { | 254 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, BackgroundTabPlugins) { |
| 236 std::string url_str = | 255 std::string url_str = |
| 237 "data:text/html;charset=utf-8," | 256 "data:text/html;charset=utf-8," |
| 238 "<object id='same_origin' type='application/x-ppapi-tests'></object>" | 257 "<object id='same_origin' type='application/x-ppapi-tests'></object>" |
| 239 "<object id='small_cross_origin' data='http://otherorigin.com/fake1.swf' " | 258 "<object id='small_cross_origin' data='http://otherorigin.com/fake1.swf' " |
| 240 " type='application/x-ppapi-tests' width='400' height='100'></object>"; | 259 " type='application/x-ppapi-tests' width='400' height='100'></object>"; |
| 241 ui_test_utils::NavigateToURLWithDisposition( | 260 ui_test_utils::NavigateToURLWithDisposition( |
| 242 browser(), GURL(url_str), NEW_BACKGROUND_TAB, | 261 browser(), GURL(url_str), NEW_BACKGROUND_TAB, |
| 243 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 262 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
| 244 | 263 |
| 245 ASSERT_EQ(2, browser()->tab_strip_model()->count()); | 264 ASSERT_EQ(2, browser()->tab_strip_model()->count()); |
| 246 content::WebContents* background_contents = | 265 content::WebContents* background_contents = |
| 247 browser()->tab_strip_model()->GetWebContentsAt(1); | 266 browser()->tab_strip_model()->GetWebContentsAt(1); |
| 248 EXPECT_TRUE( | 267 EXPECT_TRUE( |
| 249 content::WaitForRenderFrameReady(background_contents->GetMainFrame())); | 268 content::WaitForRenderFrameReady(background_contents->GetMainFrame())); |
| 250 | 269 |
| 251 EXPECT_FALSE(PluginLoaded(background_contents, "same_origin")); | 270 EXPECT_FALSE(PluginLoaded(background_contents, "same_origin")); |
| 252 EXPECT_FALSE(PluginLoaded(background_contents, "small_cross_origin")); | 271 EXPECT_FALSE(PluginLoaded(background_contents, "small_cross_origin")); |
| 253 | 272 |
| 254 browser()->tab_strip_model()->SelectNextTab(); | 273 browser()->tab_strip_model()->SelectNextTab(); |
| 255 EXPECT_EQ(background_contents, GetActiveWebContents()); | 274 EXPECT_EQ(background_contents, GetActiveWebContents()); |
| 256 | 275 |
| 257 VerifyPluginMarkedEssential(background_contents, "same_origin"); | 276 VerifyPluginMarkedEssential(background_contents, "same_origin"); |
| 258 VerifyPluginIsThrottled(background_contents, "small_cross_origin"); | 277 VerifyPluginIsThrottled(background_contents, "small_cross_origin"); |
| 259 } | 278 } |
| OLD | NEW |