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

Unified Diff: third_party/WebKit/Source/core/html/AutoplayExperimentTest.cpp

Issue 1938443002: Allow muted third-party autoplay with -ormuted experiment option. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: removed unused flag. Created 4 years, 7 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: third_party/WebKit/Source/core/html/AutoplayExperimentTest.cpp
diff --git a/third_party/WebKit/Source/core/html/AutoplayExperimentTest.cpp b/third_party/WebKit/Source/core/html/AutoplayExperimentTest.cpp
index 115567b7c682c3231d1b03a413184858f910608c..a96605af854d6438ea66134694c08532bfc493b9 100644
--- a/third_party/WebKit/Source/core/html/AutoplayExperimentTest.cpp
+++ b/third_party/WebKit/Source/core/html/AutoplayExperimentTest.cpp
@@ -83,6 +83,7 @@ public:
MOCK_CONST_METHOD0(muted, bool());
MOCK_METHOD1(setMuted, void(bool));
MOCK_METHOD0(playInternal, void());
+ MOCK_METHOD0(pauseInternal, void());
MOCK_CONST_METHOD0(isLockedPendingUserGesture, bool());
MOCK_METHOD0(unlockUserGesture, void());
MOCK_METHOD1(recordAutoplayMetric, void(AutoplayMetrics));
@@ -474,4 +475,32 @@ TEST_F(AutoplayExperimentTest, PlayTwiceIsIgnored)
m_helper->playMethodCalled();
}
+TEST_F(AutoplayExperimentTest, CrossOriginMutedTests)
+{
+ setInterface(new NiceMock<MockAutoplayClient>("enabled-forvideo-ifsameorigin-ormuted", MockAutoplayClient::Video));
+ ON_CALL(*m_client, isCrossOrigin()).WillByDefault(Return(true));
+
+ // Cross-orgin unmuted content should be eligible.
+ setIsMuted(true);
+ EXPECT_TRUE(isEligible());
+
+ // Cross-origin muted content should not be eligible.
+ setIsMuted(false);
+ EXPECT_FALSE(isEligible());
+
+ // Start playback.
+ EXPECT_CALL(*m_client, recordAutoplayMetric(AutoplayMediaFound))
+ .Times(1);
+ m_helper->becameReadyToPlay();
+ ON_CALL(*m_client, paused()).WillByDefault(Return(false));
+ setIsMuted(true);
+ m_helper->mutedChanged();
+
+ // Verify that unmuting pauses playback.
+ setIsMuted(false);
+ EXPECT_CALL(*m_client, pauseInternal())
+ .Times(1);
+ m_helper->mutedChanged();
+}
+
}

Powered by Google App Engine
This is Rietveld 408576698