| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/common/content_settings.h" | 5 #include "chrome/common/content_settings.h" |
| 6 #include "chrome/common/render_messages.h" | 6 #include "chrome/common/render_messages.h" |
| 7 #include "chrome/renderer/content_settings_observer.h" | 7 #include "chrome/renderer/content_settings_observer.h" |
| 8 #include "chrome/test/base/chrome_render_view_test.h" | 8 #include "chrome/test/base/chrome_render_view_test.h" |
| 9 #include "content/public/renderer/render_view.h" | 9 #include "content/public/renderer/render_view.h" |
| 10 #include "ipc/ipc_message_macros.h" | 10 #include "ipc/ipc_message_macros.h" |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 } | 142 } |
| 143 EXPECT_NE(-1, navigation_index); | 143 EXPECT_NE(-1, navigation_index); |
| 144 EXPECT_NE(-1, block_index); | 144 EXPECT_NE(-1, block_index); |
| 145 EXPECT_LT(navigation_index, block_index); | 145 EXPECT_LT(navigation_index, block_index); |
| 146 } | 146 } |
| 147 | 147 |
| 148 TEST_F(ChromeRenderViewTest, PluginsTemporarilyAllowed) { | 148 TEST_F(ChromeRenderViewTest, PluginsTemporarilyAllowed) { |
| 149 // Load some HTML. | 149 // Load some HTML. |
| 150 LoadHTML("<html>Foo</html>"); | 150 LoadHTML("<html>Foo</html>"); |
| 151 | 151 |
| 152 // Block plugins. | |
| 153 ContentSettings settings; | |
| 154 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) | |
| 155 settings.settings[i] = CONTENT_SETTING_ALLOW; | |
| 156 settings.settings[CONTENT_SETTINGS_TYPE_PLUGINS] = CONTENT_SETTING_BLOCK; | |
| 157 ContentSettingsObserver* observer = ContentSettingsObserver::Get(view_); | 152 ContentSettingsObserver* observer = ContentSettingsObserver::Get(view_); |
| 158 observer->SetContentSettings(settings); | |
| 159 observer->SetDefaultContentSettings(&settings); | |
| 160 EXPECT_FALSE(observer->plugins_temporarily_allowed()); | 153 EXPECT_FALSE(observer->plugins_temporarily_allowed()); |
| 161 | 154 |
| 162 // Temporarily allow plugins. | 155 // Temporarily allow plugins. |
| 163 OnMessageReceived(ChromeViewMsg_LoadBlockedPlugins(MSG_ROUTING_NONE)); | 156 OnMessageReceived(ChromeViewMsg_LoadBlockedPlugins(MSG_ROUTING_NONE)); |
| 164 EXPECT_TRUE(observer->plugins_temporarily_allowed()); | 157 EXPECT_TRUE(observer->plugins_temporarily_allowed()); |
| 165 | 158 |
| 166 // Simulate a navigation within the page. | 159 // Simulate a navigation within the page. |
| 167 DidNavigateWithinPage(GetMainFrame(), true); | 160 DidNavigateWithinPage(GetMainFrame(), true); |
| 168 EXPECT_TRUE(observer->plugins_temporarily_allowed()); | 161 EXPECT_TRUE(observer->plugins_temporarily_allowed()); |
| 169 | 162 |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 | 314 |
| 322 // Verify that the script was not blocked. | 315 // Verify that the script was not blocked. |
| 323 bool was_blocked = false; | 316 bool was_blocked = false; |
| 324 for (size_t i = 0; i < render_thread_->sink().message_count(); ++i) { | 317 for (size_t i = 0; i < render_thread_->sink().message_count(); ++i) { |
| 325 const IPC::Message* msg = render_thread_->sink().GetMessageAt(i); | 318 const IPC::Message* msg = render_thread_->sink().GetMessageAt(i); |
| 326 if (msg->type() == ChromeViewHostMsg_ContentBlocked::ID) | 319 if (msg->type() == ChromeViewHostMsg_ContentBlocked::ID) |
| 327 was_blocked = true; | 320 was_blocked = true; |
| 328 } | 321 } |
| 329 EXPECT_FALSE(was_blocked); | 322 EXPECT_FALSE(was_blocked); |
| 330 } | 323 } |
| OLD | NEW |