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

Unified Diff: chrome/renderer/content_settings_observer_browsertest.cc

Issue 8773035: Content settings: allow scripts on interstitial pages. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Oops, adding tests killed by the previous patch set. Created 9 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/renderer/content_settings_observer.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/content_settings_observer_browsertest.cc
diff --git a/chrome/renderer/content_settings_observer_browsertest.cc b/chrome/renderer/content_settings_observer_browsertest.cc
index d05df62b42cf824e0375c83640f5b3335368f3dc..db720f57b4ee7a8781eb43f9c8c6d7309d0cb26d 100644
--- a/chrome/renderer/content_settings_observer_browsertest.cc
+++ b/chrome/renderer/content_settings_observer_browsertest.cc
@@ -322,3 +322,55 @@ TEST_F(ChromeRenderViewTest, ContentSettingsAllowScripts) {
}
EXPECT_FALSE(was_blocked);
}
+
+TEST_F(ChromeRenderViewTest, ContentSettingsInterstitialPages) {
+ MockContentSettingsObserver mock_observer(view_);
+ // Block scripts.
+ RendererContentSettingRules content_setting_rules;
+ ContentSettingsForOneType& script_setting_rules =
+ content_setting_rules.script_rules;
+ script_setting_rules.push_back(
+ ContentSettingPatternSource(
+ ContentSettingsPattern::Wildcard(),
+ ContentSettingsPattern::Wildcard(),
+ CONTENT_SETTING_BLOCK, "", false));
+ // Block images.
+ ContentSettingsForOneType& image_setting_rules =
+ content_setting_rules.image_rules;
+ image_setting_rules.push_back(
+ ContentSettingPatternSource(
+ ContentSettingsPattern::Wildcard(),
+ ContentSettingsPattern::Wildcard(),
+ CONTENT_SETTING_BLOCK, "", false));
+
+ ContentSettingsObserver* observer = ContentSettingsObserver::Get(view_);
+ observer->SetContentSettingRules(&content_setting_rules);
+ observer->SetAsInterstitial();
+
+ // Load a page which contains a script.
+ std::string html = "<html>"
+ "<head>"
+ "<script src='data:foo'></script>"
+ "</head>"
+ "<body>"
+ "</body>"
+ "</html>";
+ LoadHTML(html.c_str());
+
+ // Verify that the script was allowed.
+ bool was_blocked = false;
+ for (size_t i = 0; i < render_thread_->sink().message_count(); ++i) {
+ const IPC::Message* msg = render_thread_->sink().GetMessageAt(i);
+ if (msg->type() == ChromeViewHostMsg_ContentBlocked::ID)
+ was_blocked = true;
+ }
+ EXPECT_FALSE(was_blocked);
+
+ // Verify that images are allowed.
+ EXPECT_CALL(
+ mock_observer,
+ OnContentBlocked(CONTENT_SETTINGS_TYPE_IMAGES, std::string())).Times(0);
+ EXPECT_TRUE(observer->AllowImage(GetMainFrame(), true,
+ mock_observer.image_url_));
+ ::testing::Mock::VerifyAndClearExpectations(&observer);
+}
« no previous file with comments | « chrome/renderer/content_settings_observer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698