| OLD | NEW |
| 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 "base/run_loop.h" | 5 #include "base/run_loop.h" |
| 6 #include "content/common/frame_messages.h" | 6 #include "content/common/frame_messages.h" |
| 7 #include "content/common/view_message_enums.h" | 7 #include "content/common/view_message_enums.h" |
| 8 #include "content/public/common/content_constants.h" | 8 #include "content/public/common/content_constants.h" |
| 9 #include "content/public/test/render_view_test.h" | 9 #include "content/public/test/render_view_test.h" |
| 10 #include "content/renderer/pepper/plugin_power_saver_helper.h" | 10 #include "content/renderer/pepper/plugin_power_saver_helper.h" |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 kFlashPluginName, 100, 100, | 122 kFlashPluginName, 100, 100, |
| 123 &cross_origin_main_content)); | 123 &cross_origin_main_content)); |
| 124 EXPECT_FALSE(cross_origin_main_content); | 124 EXPECT_FALSE(cross_origin_main_content); |
| 125 | 125 |
| 126 // Test that we've sent an IPC to the browser. | 126 // Test that we've sent an IPC to the browser. |
| 127 ASSERT_EQ(1u, sink_->message_count()); | 127 ASSERT_EQ(1u, sink_->message_count()); |
| 128 const IPC::Message* msg = sink_->GetMessageAt(0); | 128 const IPC::Message* msg = sink_->GetMessageAt(0); |
| 129 EXPECT_EQ(FrameHostMsg_PluginContentOriginAllowed::ID, msg->type()); | 129 EXPECT_EQ(FrameHostMsg_PluginContentOriginAllowed::ID, msg->type()); |
| 130 FrameHostMsg_PluginContentOriginAllowed::Param params; | 130 FrameHostMsg_PluginContentOriginAllowed::Param params; |
| 131 FrameHostMsg_PluginContentOriginAllowed::Read(msg, ¶ms); | 131 FrameHostMsg_PluginContentOriginAllowed::Read(msg, ¶ms); |
| 132 EXPECT_EQ(GURL("http://b.com"), get<0>(params)); | 132 EXPECT_EQ(GURL("http://b.com"), base::get<0>(params)); |
| 133 } | 133 } |
| 134 | 134 |
| 135 TEST_F(PluginPowerSaverHelperTest, UnthrottleOnExPostFactoWhitelist) { | 135 TEST_F(PluginPowerSaverHelperTest, UnthrottleOnExPostFactoWhitelist) { |
| 136 base::RunLoop loop; | 136 base::RunLoop loop; |
| 137 frame()->RegisterPeripheralPlugin(GURL("http://other.com"), | 137 frame()->RegisterPeripheralPlugin(GURL("http://other.com"), |
| 138 loop.QuitClosure()); | 138 loop.QuitClosure()); |
| 139 | 139 |
| 140 std::set<GURL> origin_whitelist; | 140 std::set<GURL> origin_whitelist; |
| 141 origin_whitelist.insert(GURL("http://other.com")); | 141 origin_whitelist.insert(GURL("http://other.com")); |
| 142 frame()->OnMessageReceived(FrameMsg_UpdatePluginContentOriginWhitelist( | 142 frame()->OnMessageReceived(FrameMsg_UpdatePluginContentOriginWhitelist( |
| 143 frame()->GetRoutingID(), origin_whitelist)); | 143 frame()->GetRoutingID(), origin_whitelist)); |
| 144 | 144 |
| 145 // Runs until the unthrottle closure is run. | 145 // Runs until the unthrottle closure is run. |
| 146 loop.Run(); | 146 loop.Run(); |
| 147 } | 147 } |
| 148 | 148 |
| 149 TEST_F(PluginPowerSaverHelperTest, ClearWhitelistOnNavigate) { | 149 TEST_F(PluginPowerSaverHelperTest, ClearWhitelistOnNavigate) { |
| 150 helper()->WhitelistContentOrigin(GURL("http://b.com")); | 150 helper()->WhitelistContentOrigin(GURL("http://b.com")); |
| 151 | 151 |
| 152 EXPECT_FALSE(helper()->ShouldThrottleContent( | 152 EXPECT_FALSE(helper()->ShouldThrottleContent( |
| 153 GURL("http://b.com"), kFlashPluginName, 100, 100, nullptr)); | 153 GURL("http://b.com"), kFlashPluginName, 100, 100, nullptr)); |
| 154 | 154 |
| 155 LoadHTML("<html></html>"); | 155 LoadHTML("<html></html>"); |
| 156 | 156 |
| 157 EXPECT_TRUE(helper()->ShouldThrottleContent( | 157 EXPECT_TRUE(helper()->ShouldThrottleContent( |
| 158 GURL("http://b.com"), kFlashPluginName, 100, 100, nullptr)); | 158 GURL("http://b.com"), kFlashPluginName, 100, 100, nullptr)); |
| 159 } | 159 } |
| 160 | 160 |
| 161 } // namespace content | 161 } // namespace content |
| OLD | NEW |