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

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

Issue 9323071: Use InterstitialPage through a delegate interface instead of deriving from it. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix cros Created 8 years, 10 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) 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 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 ContentSettingsForOneType& image_setting_rules = 338 ContentSettingsForOneType& image_setting_rules =
339 content_setting_rules.image_rules; 339 content_setting_rules.image_rules;
340 image_setting_rules.push_back( 340 image_setting_rules.push_back(
341 ContentSettingPatternSource( 341 ContentSettingPatternSource(
342 ContentSettingsPattern::Wildcard(), 342 ContentSettingsPattern::Wildcard(),
343 ContentSettingsPattern::Wildcard(), 343 ContentSettingsPattern::Wildcard(),
344 CONTENT_SETTING_BLOCK, "", false)); 344 CONTENT_SETTING_BLOCK, "", false));
345 345
346 ContentSettingsObserver* observer = ContentSettingsObserver::Get(view_); 346 ContentSettingsObserver* observer = ContentSettingsObserver::Get(view_);
347 observer->SetContentSettingRules(&content_setting_rules); 347 observer->SetContentSettingRules(&content_setting_rules);
348 observer->SetAsInterstitial(); 348 observer->OnSetAsInterstitial();
349 349
350 // Load a page which contains a script. 350 // Load a page which contains a script.
351 std::string html = "<html>" 351 std::string html = "<html>"
352 "<head>" 352 "<head>"
353 "<script src='data:foo'></script>" 353 "<script src='data:foo'></script>"
354 "</head>" 354 "</head>"
355 "<body>" 355 "<body>"
356 "</body>" 356 "</body>"
357 "</html>"; 357 "</html>";
358 LoadHTML(html.c_str()); 358 LoadHTML(html.c_str());
359 359
360 // Verify that the script was allowed. 360 // Verify that the script was allowed.
361 bool was_blocked = false; 361 bool was_blocked = false;
362 for (size_t i = 0; i < render_thread_->sink().message_count(); ++i) { 362 for (size_t i = 0; i < render_thread_->sink().message_count(); ++i) {
363 const IPC::Message* msg = render_thread_->sink().GetMessageAt(i); 363 const IPC::Message* msg = render_thread_->sink().GetMessageAt(i);
364 if (msg->type() == ChromeViewHostMsg_ContentBlocked::ID) 364 if (msg->type() == ChromeViewHostMsg_ContentBlocked::ID)
365 was_blocked = true; 365 was_blocked = true;
366 } 366 }
367 EXPECT_FALSE(was_blocked); 367 EXPECT_FALSE(was_blocked);
368 368
369 // Verify that images are allowed. 369 // Verify that images are allowed.
370 EXPECT_CALL( 370 EXPECT_CALL(
371 mock_observer, 371 mock_observer,
372 OnContentBlocked(CONTENT_SETTINGS_TYPE_IMAGES, std::string())).Times(0); 372 OnContentBlocked(CONTENT_SETTINGS_TYPE_IMAGES, std::string())).Times(0);
373 EXPECT_TRUE(observer->AllowImage(GetMainFrame(), true, 373 EXPECT_TRUE(observer->AllowImage(GetMainFrame(), true,
374 mock_observer.image_url_)); 374 mock_observer.image_url_));
375 ::testing::Mock::VerifyAndClearExpectations(&observer); 375 ::testing::Mock::VerifyAndClearExpectations(&observer);
376 } 376 }
OLDNEW
« no previous file with comments | « chrome/renderer/content_settings_observer.cc ('k') | content/browser/tab_contents/interstitial_page.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698