| 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 ad6a0c12ac82a04edeeb2a91b3f993eae3496b5e..9e42241ffada8aa56dc42f0324f6a9865c88234f 100644
|
| --- a/content/renderer/pepper/plugin_power_saver_helper_browsertest.cc
|
| +++ b/content/renderer/pepper/plugin_power_saver_helper_browsertest.cc
|
| @@ -16,6 +16,7 @@
|
| #include "third_party/WebKit/public/web/WebDocument.h"
|
| #include "third_party/WebKit/public/web/WebLocalFrame.h"
|
| #include "third_party/WebKit/public/web/WebPluginParams.h"
|
| +#include "ui/gfx/geometry/size.h"
|
| #include "url/gurl.h"
|
|
|
| namespace content {
|
| @@ -33,101 +34,27 @@ class PluginPowerSaverHelperTest : public RenderViewTest {
|
| return static_cast<RenderFrameImpl*>(view_->GetMainRenderFrame());
|
| }
|
|
|
| - blink::WebPluginParams MakeParams(const std::string& url,
|
| - const std::string& poster,
|
| - const std::string& width,
|
| - const std::string& height) {
|
| - const size_t size = 3;
|
| - blink::WebVector<blink::WebString> names(size);
|
| - blink::WebVector<blink::WebString> values(size);
|
| -
|
| - blink::WebPluginParams params;
|
| - params.url = GURL(url);
|
| -
|
| - params.attributeNames.swap(names);
|
| - params.attributeValues.swap(values);
|
| -
|
| - params.attributeNames[0] = "poster";
|
| - params.attributeNames[1] = "height";
|
| - params.attributeNames[2] = "width";
|
| - params.attributeValues[0] = blink::WebString::fromUTF8(poster);
|
| - params.attributeValues[1] = blink::WebString::fromUTF8(height);
|
| - params.attributeValues[2] = blink::WebString::fromUTF8(width);
|
| -
|
| - return params;
|
| - }
|
| -
|
| protected:
|
| IPC::TestSink* sink_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(PluginPowerSaverHelperTest);
|
| };
|
|
|
| -TEST_F(PluginPowerSaverHelperTest, AllowSameOrigin) {
|
| - EXPECT_FALSE(frame()->ShouldThrottleContent(
|
| - url::Origin(GURL("http://same.com")),
|
| - url::Origin(GURL("http://same.com")), 100, 100, nullptr));
|
| - EXPECT_FALSE(frame()->ShouldThrottleContent(
|
| - url::Origin(GURL("http://same.com")),
|
| - url::Origin(GURL("http://same.com")), 1000, 1000, nullptr));
|
| -}
|
| -
|
| -TEST_F(PluginPowerSaverHelperTest, DisallowCrossOriginUnlessLarge) {
|
| - bool cross_origin_main_content = false;
|
| - EXPECT_TRUE(
|
| - frame()->ShouldThrottleContent(url::Origin(GURL("http://same.com")),
|
| - url::Origin(GURL("http://other.com")), 100,
|
| - 100, &cross_origin_main_content));
|
| - EXPECT_FALSE(cross_origin_main_content);
|
| -
|
| - EXPECT_FALSE(
|
| - frame()->ShouldThrottleContent(url::Origin(GURL("http://same.com")),
|
| - url::Origin(GURL("http://other.com")),
|
| - 1000, 1000, &cross_origin_main_content));
|
| - EXPECT_TRUE(cross_origin_main_content);
|
| -}
|
| -
|
| -TEST_F(PluginPowerSaverHelperTest, AlwaysAllowTinyContent) {
|
| - bool cross_origin_main_content = false;
|
| - EXPECT_FALSE(frame()->ShouldThrottleContent(
|
| - url::Origin(GURL("http://same.com")),
|
| - url::Origin(GURL("http://same.com")), 1, 1, nullptr));
|
| - EXPECT_FALSE(cross_origin_main_content);
|
| -
|
| - EXPECT_FALSE(frame()->ShouldThrottleContent(
|
| - url::Origin(GURL("http://same.com")),
|
| - url::Origin(GURL("http://other.com")), 1, 1, &cross_origin_main_content));
|
| - EXPECT_FALSE(cross_origin_main_content);
|
| -
|
| - EXPECT_FALSE(frame()->ShouldThrottleContent(
|
| - url::Origin(GURL("http://same.com")),
|
| - url::Origin(GURL("http://other.com")), 5, 5, &cross_origin_main_content));
|
| - EXPECT_FALSE(cross_origin_main_content);
|
| -
|
| - EXPECT_TRUE(
|
| - frame()->ShouldThrottleContent(url::Origin(GURL("http://same.com")),
|
| - url::Origin(GURL("http://other.com")), 10,
|
| - 10, &cross_origin_main_content));
|
| - EXPECT_FALSE(cross_origin_main_content);
|
| -}
|
| -
|
| TEST_F(PluginPowerSaverHelperTest, TemporaryOriginWhitelist) {
|
| - bool cross_origin_main_content = false;
|
| - EXPECT_TRUE(
|
| - frame()->ShouldThrottleContent(url::Origin(GURL("http://same.com")),
|
| - url::Origin(GURL("http://other.com")), 100,
|
| - 100, &cross_origin_main_content));
|
| - EXPECT_FALSE(cross_origin_main_content);
|
| + EXPECT_EQ(RenderFrame::CONTENT_STATUS_PERIPHERAL,
|
| + frame()->GetPeripheralContentStatus(
|
| + url::Origin(GURL("http://same.com")),
|
| + url::Origin(GURL("http://other.com")), gfx::Size(100, 100)));
|
|
|
| // Clear out other messages so we find just the plugin power saver IPCs.
|
| sink_->ClearMessages();
|
|
|
| frame()->WhitelistContentOrigin(url::Origin(GURL("http://other.com")));
|
| - EXPECT_FALSE(
|
| - frame()->ShouldThrottleContent(url::Origin(GURL("http://same.com")),
|
| - url::Origin(GURL("http://other.com")), 100,
|
| - 100, &cross_origin_main_content));
|
| - EXPECT_FALSE(cross_origin_main_content);
|
| +
|
| + EXPECT_EQ(RenderFrame::CONTENT_STATUS_ESSENTIAL_CROSS_ORIGIN_WHITELISTED,
|
| + frame()->GetPeripheralContentStatus(
|
| + url::Origin(GURL("http://same.com")),
|
| + url::Origin(GURL("http://other.com")), gfx::Size(100, 100)));
|
|
|
| // Test that we've sent an IPC to the browser.
|
| ASSERT_EQ(1u, sink_->message_count());
|
| @@ -156,15 +83,17 @@ TEST_F(PluginPowerSaverHelperTest, UnthrottleOnExPostFactoWhitelist) {
|
| TEST_F(PluginPowerSaverHelperTest, ClearWhitelistOnNavigate) {
|
| frame()->WhitelistContentOrigin(url::Origin(GURL("http://other.com")));
|
|
|
| - EXPECT_FALSE(frame()->ShouldThrottleContent(
|
| - url::Origin(GURL("http://same.com")),
|
| - url::Origin(GURL("http://other.com")), 100, 100, nullptr));
|
| + EXPECT_EQ(RenderFrame::CONTENT_STATUS_ESSENTIAL_CROSS_ORIGIN_WHITELISTED,
|
| + frame()->GetPeripheralContentStatus(
|
| + url::Origin(GURL("http://same.com")),
|
| + url::Origin(GURL("http://other.com")), gfx::Size(100, 100)));
|
|
|
| LoadHTML("<html></html>");
|
|
|
| - EXPECT_TRUE(frame()->ShouldThrottleContent(
|
| - url::Origin(GURL("http://same.com")),
|
| - url::Origin(GURL("http://other.com")), 100, 100, nullptr));
|
| + EXPECT_EQ(RenderFrame::CONTENT_STATUS_PERIPHERAL,
|
| + frame()->GetPeripheralContentStatus(
|
| + url::Origin(GURL("http://same.com")),
|
| + url::Origin(GURL("http://other.com")), gfx::Size(100, 100)));
|
| }
|
|
|
| } // namespace content
|
|
|