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

Side by Side Diff: content/renderer/pepper/plugin_power_saver_helper_browsertest.cc

Issue 2211753002: Plugin Power Saver Tiny: Fix Plugin.PowerSaver.PeripheralHeuristic UMA (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge. and change to enum Created 4 years, 4 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <tuple> 5 #include <tuple>
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "content/common/frame_messages.h" 9 #include "content/common/frame_messages.h"
10 #include "content/common/view_message_enums.h" 10 #include "content/common/view_message_enums.h"
(...skipping 29 matching lines...) Expand all
40 protected: 40 protected:
41 IPC::TestSink* sink_; 41 IPC::TestSink* sink_;
42 42
43 DISALLOW_COPY_AND_ASSIGN(PluginPowerSaverHelperTest); 43 DISALLOW_COPY_AND_ASSIGN(PluginPowerSaverHelperTest);
44 }; 44 };
45 45
46 TEST_F(PluginPowerSaverHelperTest, TemporaryOriginWhitelist) { 46 TEST_F(PluginPowerSaverHelperTest, TemporaryOriginWhitelist) {
47 EXPECT_EQ(RenderFrame::CONTENT_STATUS_PERIPHERAL, 47 EXPECT_EQ(RenderFrame::CONTENT_STATUS_PERIPHERAL,
48 frame()->GetPeripheralContentStatus( 48 frame()->GetPeripheralContentStatus(
49 url::Origin(GURL("http://same.com")), 49 url::Origin(GURL("http://same.com")),
50 url::Origin(GURL("http://other.com")), gfx::Size(100, 100))); 50 url::Origin(GURL("http://other.com")), gfx::Size(100, 100),
51 RenderFrame::DONT_RECORD_DECISION));
51 52
52 // Clear out other messages so we find just the plugin power saver IPCs. 53 // Clear out other messages so we find just the plugin power saver IPCs.
53 sink_->ClearMessages(); 54 sink_->ClearMessages();
54 55
55 frame()->WhitelistContentOrigin(url::Origin(GURL("http://other.com"))); 56 frame()->WhitelistContentOrigin(url::Origin(GURL("http://other.com")));
56 57
57 EXPECT_EQ(RenderFrame::CONTENT_STATUS_ESSENTIAL_CROSS_ORIGIN_WHITELISTED, 58 EXPECT_EQ(RenderFrame::CONTENT_STATUS_ESSENTIAL_CROSS_ORIGIN_WHITELISTED,
58 frame()->GetPeripheralContentStatus( 59 frame()->GetPeripheralContentStatus(
59 url::Origin(GURL("http://same.com")), 60 url::Origin(GURL("http://same.com")),
60 url::Origin(GURL("http://other.com")), gfx::Size(100, 100))); 61 url::Origin(GURL("http://other.com")), gfx::Size(100, 100),
62 RenderFrame::DONT_RECORD_DECISION));
61 63
62 // Test that we've sent an IPC to the browser. 64 // Test that we've sent an IPC to the browser.
63 ASSERT_EQ(1u, sink_->message_count()); 65 ASSERT_EQ(1u, sink_->message_count());
64 const IPC::Message* msg = sink_->GetMessageAt(0); 66 const IPC::Message* msg = sink_->GetMessageAt(0);
65 EXPECT_EQ(FrameHostMsg_PluginContentOriginAllowed::ID, msg->type()); 67 EXPECT_EQ(FrameHostMsg_PluginContentOriginAllowed::ID, msg->type());
66 FrameHostMsg_PluginContentOriginAllowed::Param params; 68 FrameHostMsg_PluginContentOriginAllowed::Param params;
67 FrameHostMsg_PluginContentOriginAllowed::Read(msg, &params); 69 FrameHostMsg_PluginContentOriginAllowed::Read(msg, &params);
68 EXPECT_TRUE(url::Origin(GURL("http://other.com")) 70 EXPECT_TRUE(url::Origin(GURL("http://other.com"))
69 .IsSameOriginWith(std::get<0>(params))); 71 .IsSameOriginWith(std::get<0>(params)));
70 } 72 }
(...skipping 11 matching lines...) Expand all
82 // Runs until the unthrottle closure is run. 84 // Runs until the unthrottle closure is run.
83 loop.Run(); 85 loop.Run();
84 } 86 }
85 87
86 TEST_F(PluginPowerSaverHelperTest, ClearWhitelistOnNavigate) { 88 TEST_F(PluginPowerSaverHelperTest, ClearWhitelistOnNavigate) {
87 frame()->WhitelistContentOrigin(url::Origin(GURL("http://other.com"))); 89 frame()->WhitelistContentOrigin(url::Origin(GURL("http://other.com")));
88 90
89 EXPECT_EQ(RenderFrame::CONTENT_STATUS_ESSENTIAL_CROSS_ORIGIN_WHITELISTED, 91 EXPECT_EQ(RenderFrame::CONTENT_STATUS_ESSENTIAL_CROSS_ORIGIN_WHITELISTED,
90 frame()->GetPeripheralContentStatus( 92 frame()->GetPeripheralContentStatus(
91 url::Origin(GURL("http://same.com")), 93 url::Origin(GURL("http://same.com")),
92 url::Origin(GURL("http://other.com")), gfx::Size(100, 100))); 94 url::Origin(GURL("http://other.com")), gfx::Size(100, 100),
95 RenderFrame::DONT_RECORD_DECISION));
93 96
94 LoadHTML("<html></html>"); 97 LoadHTML("<html></html>");
95 98
96 EXPECT_EQ(RenderFrame::CONTENT_STATUS_PERIPHERAL, 99 EXPECT_EQ(RenderFrame::CONTENT_STATUS_PERIPHERAL,
97 frame()->GetPeripheralContentStatus( 100 frame()->GetPeripheralContentStatus(
98 url::Origin(GURL("http://same.com")), 101 url::Origin(GURL("http://same.com")),
99 url::Origin(GURL("http://other.com")), gfx::Size(100, 100))); 102 url::Origin(GURL("http://other.com")), gfx::Size(100, 100),
103 RenderFrame::DONT_RECORD_DECISION));
100 } 104 }
101 105
102 } // namespace content 106 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/pepper/plugin_power_saver_helper.cc ('k') | content/renderer/render_frame_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698