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

Unified Diff: chrome/renderer/content_settings_observer_browsertest.cc

Issue 8873015: Revert 113591 - Revert 113579 - Content settings: allow scripts on interstitial pages even if Jav... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
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
===================================================================
--- chrome/renderer/content_settings_observer_browsertest.cc (revision 113593)
+++ chrome/renderer/content_settings_observer_browsertest.cc (working copy)
@@ -322,3 +322,55 @@
}
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