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

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

Issue 1853543002: Add -ifsameorigin to autoplay experiment. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@autoplay
Patch Set: comment. 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: 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 7f92c663bb0a784eb97cc0a5b9d6d7763ca2acc3..57394e540075e946bfbe7ce185e554273e223024 100644
--- a/third_party/WebKit/Source/core/html/AutoplayExperimentTest.cpp
+++ b/third_party/WebKit/Source/core/html/AutoplayExperimentTest.cpp
@@ -52,6 +52,8 @@ public:
.WillByDefault(Return(false));
ON_CALL(*this, pageVisibilityState())
.WillByDefault(Return(PageVisibilityStateVisible));
+ ON_CALL(*this, isCrossOrigin())
+ .WillByDefault(Return(false));
ON_CALL(*this, absoluteBoundingBoxRect())
.WillByDefault(Return(
IntRect(10, 10, 100, 100)));
@@ -85,6 +87,7 @@ public:
MOCK_METHOD0(isLegacyViewportType, bool());
MOCK_CONST_METHOD0(pageVisibilityState, PageVisibilityState());
MOCK_CONST_METHOD0(autoplayExperimentMode, String());
+ MOCK_CONST_METHOD0(isCrossOrigin, bool());
MOCK_METHOD1(setRequestPositionUpdates, void(bool));
MOCK_CONST_METHOD0(absoluteBoundingBoxRect, IntRect());
@@ -431,4 +434,23 @@ TEST_F(AutoplayExperimentTest, DeferPlaybackUntilInViewport)
.Times(1);
moveIntoViewport();
}
+
+TEST_F(AutoplayExperimentTest, WithSameOriginTests)
+{
+ setInterface(new NiceMock<MockAutoplayClient>("enabled-forvideo-ifsameorigin", MockAutoplayClient::Video));
+ ON_CALL(*m_client, isCrossOrigin()).WillByDefault(Return(false));
+ EXPECT_TRUE(isEligible());
+ ON_CALL(*m_client, isCrossOrigin()).WillByDefault(Return(true));
+ EXPECT_FALSE(isEligible());
+}
+
+TEST_F(AutoplayExperimentTest, WithoutSameOriginTests)
+{
+ setInterface(new NiceMock<MockAutoplayClient>("enabled-forvideo", MockAutoplayClient::Video));
+ ON_CALL(*m_client, isCrossOrigin()).WillByDefault(Return(false));
+ EXPECT_TRUE(isEligible());
+ ON_CALL(*m_client, isCrossOrigin()).WillByDefault(Return(true));
+ EXPECT_TRUE(isEligible());
+}
+
}

Powered by Google App Engine
This is Rietveld 408576698