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

Unified Diff: chrome/renderer/content_settings_observer_browsertest.cc

Issue 1906533002: Add 'autoplay' content settings and expose it to Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
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 d57647d7f56cd9e51d711fe62060a5b9a332d137..d997028989447b15f636ebb29f78e5c8f2d146cd 100644
--- a/chrome/renderer/content_settings_observer_browsertest.cc
+++ b/chrome/renderer/content_settings_observer_browsertest.cc
@@ -376,3 +376,41 @@ TEST_F(ChromeRenderViewTest, ContentSettingsInterstitialPages) {
EXPECT_TRUE(observer->allowImage(true, mock_observer.image_url_));
::testing::Mock::VerifyAndClearExpectations(&observer);
}
+
+TEST_F(ChromeRenderViewTest, AutoplayContentSettings) {
+ MockContentSettingsObserver mock_observer(view_->GetMainRenderFrame());
+
+ // Load some HTML.
+ LoadHTML("<html>Foo</html>");
+
+ // Set the default setting.
+ RendererContentSettingRules content_setting_rules;
+ ContentSettingsForOneType& autoplay_setting_rules =
+ content_setting_rules.autoplay_rules;
+ autoplay_setting_rules.push_back(
+ ContentSettingPatternSource(ContentSettingsPattern::Wildcard(),
+ ContentSettingsPattern::Wildcard(),
+ CONTENT_SETTING_ALLOW,
+ std::string(),
+ false));
+
+ ContentSettingsObserver* observer =
+ ContentSettingsObserver::Get(view_->GetMainRenderFrame());
+ observer->SetContentSettingRules(&content_setting_rules);
+
+ EXPECT_TRUE(observer->allowAutoplay(false));
+ ::testing::Mock::VerifyAndClearExpectations(&observer);
Bernhard Bauer 2016/04/25 14:01:49 The initial :: isn't necessary if you're in the gl
+
+ // Add rule to block autoplay.
+ autoplay_setting_rules.insert(
+ autoplay_setting_rules.begin(),
+ ContentSettingPatternSource(
+ ContentSettingsPattern::Wildcard(),
+ ContentSettingsPattern::Wildcard(),
+ CONTENT_SETTING_BLOCK,
+ std::string(),
+ false));
+
+ EXPECT_FALSE(observer->allowAutoplay(true));
+ ::testing::Mock::VerifyAndClearExpectations(&observer);
+}

Powered by Google App Engine
This is Rietveld 408576698