|
158 | 158 | #include "content/public/common/content_switches.h" |
159 | 159 | #include "content/public/common/result_codes.h" |
160 | 160 | #include "content/public/common/url_constants.h" |
| 161 | +#include "content/public/common/web_preferences.h" |
161 | 162 | #include "content/public/test/browser_test_utils.h" |
162 | 163 | #include "content/public/test/download_test_observer.h" |
163 | 164 | #include "content/public/test/mock_notification_observer.h" |
@@ -5045,4 +5046,31 @@ IN_PROC_BROWSER_TEST_F(NoteTakingOnLockScreenPolicyTest, |
5045 | 5046 |
|
5046 | 5047 | #endif // defined(OS_CHROMEOS) |
5047 | 5048 |
|
| 5049 | +#if !defined(OS_ANDROID) |
| 5050 | + |
| 5051 | +IN_PROC_BROWSER_TEST_F(PolicyTest, AutoplayAllowedByPolicy) { |
| 5052 | + ASSERT_TRUE(embedded_test_server()->Start()); |
| 5053 | + content::WebContents* web_contents = |
| 5054 | + browser()->tab_strip_model()->GetActiveWebContents(); |
| 5055 | + |
| 5056 | + // Check that autoplay was not allowed. |
| 5057 | + EXPECT_EQ( |
| 5058 | + web_contents->GetRenderViewHost()->GetWebkitPreferences().autoplay_policy, |
| 5059 | + content::AutoplayPolicy::kDocumentUserActivationRequired); |
| 5060 | + |
| 5061 | + // Update policy to allow autoplay. |
| 5062 | + PolicyMap policies; |
| 5063 | + SetPolicy(&policies, key::kAutoplayAllowed, |
| 5064 | + std::make_unique<base::Value>(true)); |
| 5065 | + UpdateProviderPolicy(policies); |
| 5066 | + |
| 5067 | + // Check that autoplay was allowed by policy. |
| 5068 | + web_contents->GetRenderViewHost()->OnWebkitPreferencesChanged(); |
| 5069 | + EXPECT_EQ( |
| 5070 | + web_contents->GetRenderViewHost()->GetWebkitPreferences().autoplay_policy, |
| 5071 | + content::AutoplayPolicy::kNoUserGestureRequired); |
| 5072 | +} |
| 5073 | + |
| 5074 | +#endif // !defined(OS_ANDROID) |
| 5075 | + |
5048 | 5076 | } // namespace policy |
0 commit comments