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

Side by Side Diff: trunk/src/chrome/renderer/content_settings_observer_browsertest.cc

Issue 269893004: Revert 268203 "There are many ways to get it wrong." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 render_thread_->sink().ClearMessages(); 114 render_thread_->sink().ClearMessages();
115 115
116 // 3. Reload page. 116 // 3. Reload page.
117 std::string url_str = "data:text/html;charset=utf-8,"; 117 std::string url_str = "data:text/html;charset=utf-8,";
118 url_str.append(html); 118 url_str.append(html);
119 GURL url(url_str); 119 GURL url(url_str);
120 Reload(url); 120 Reload(url);
121 ProcessPendingMessages(); 121 ProcessPendingMessages();
122 122
123 // 4. Verify that the notification that javascript was blocked is sent after 123 // 4. Verify that the notification that javascript was blocked is sent after
124 // the navigation notification is sent. 124 // the navigation notifiction is sent.
125 int navigation_index = -1; 125 int navigation_index = -1;
126 int block_index = -1; 126 int block_index = -1;
127 for (size_t i = 0; i < render_thread_->sink().message_count(); ++i) { 127 for (size_t i = 0; i < render_thread_->sink().message_count(); ++i) {
128 const IPC::Message* msg = render_thread_->sink().GetMessageAt(i); 128 const IPC::Message* msg = render_thread_->sink().GetMessageAt(i);
129 if (msg->type() == GetNavigationIPCType()) 129 if (msg->type() == GetNavigationIPCType())
130 navigation_index = i; 130 navigation_index = i;
131 if (msg->type() == ChromeViewHostMsg_ContentBlocked::ID) 131 if (msg->type() == ChromeViewHostMsg_ContentBlocked::ID)
132 block_index = i; 132 block_index = i;
133 } 133 }
134 EXPECT_NE(-1, navigation_index); 134 EXPECT_NE(-1, navigation_index);
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 } 369 }
370 EXPECT_FALSE(was_blocked); 370 EXPECT_FALSE(was_blocked);
371 371
372 // Verify that images are allowed. 372 // Verify that images are allowed.
373 EXPECT_CALL( 373 EXPECT_CALL(
374 mock_observer, 374 mock_observer,
375 OnContentBlocked(CONTENT_SETTINGS_TYPE_IMAGES)).Times(0); 375 OnContentBlocked(CONTENT_SETTINGS_TYPE_IMAGES)).Times(0);
376 EXPECT_TRUE(observer->allowImage(true, mock_observer.image_url_)); 376 EXPECT_TRUE(observer->allowImage(true, mock_observer.image_url_));
377 ::testing::Mock::VerifyAndClearExpectations(&observer); 377 ::testing::Mock::VerifyAndClearExpectations(&observer);
378 } 378 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698