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

Unified Diff: third_party/WebKit/Source/web/tests/IntersectionObserverTest.cpp

Issue 2684733002: IntersectionObserver: discard notifications upon disconnect(). (Closed)
Patch Set: Add layout test Created 3 years, 10 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
« no previous file with comments | « third_party/WebKit/Source/core/dom/IntersectionObserver.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/web/tests/IntersectionObserverTest.cpp
diff --git a/third_party/WebKit/Source/web/tests/IntersectionObserverTest.cpp b/third_party/WebKit/Source/web/tests/IntersectionObserverTest.cpp
index fd14a1ea08e9ef8a55cd8d78658cad7f3102a31e..2269127754cb71cf2817c0ec3f13a96d927507a5 100644
--- a/third_party/WebKit/Source/web/tests/IntersectionObserverTest.cpp
+++ b/third_party/WebKit/Source/web/tests/IntersectionObserverTest.cpp
@@ -127,4 +127,39 @@ TEST_F(IntersectionObserverTest, ResumePostsTask) {
EXPECT_EQ(observerCallback->callCount(), 3);
}
+TEST_F(IntersectionObserverTest, DisconnectClearsNotifications) {
+ webView().resize(WebSize(800, 600));
+ SimRequest mainResource("https://example.com/", "text/html");
+ loadURL("https://example.com/");
+ mainResource.complete(
+ "<div id='leading-space' style='height: 700px;'></div>"
+ "<div id='target'></div>"
+ "<div id='trailing-space' style='height: 700px;'></div>");
+
+ IntersectionObserverInit observerInit;
+ DummyExceptionStateForTesting exceptionState;
+ TestIntersectionObserverCallback* observerCallback =
+ new TestIntersectionObserverCallback(document());
+ IntersectionObserver* observer = IntersectionObserver::create(
+ observerInit, *observerCallback, exceptionState);
+ ASSERT_FALSE(exceptionState.hadException());
+
+ Element* target = document().getElementById("target");
+ ASSERT_TRUE(target);
+ observer->observe(target, exceptionState);
+
+ compositor().beginFrame();
+ testing::runPendingTasks();
+ EXPECT_EQ(observerCallback->callCount(), 1);
+
+ // If disconnect() is called while an observer has unsent notifications,
+ // those notifications should be discarded.
+ document().view()->layoutViewportScrollableArea()->setScrollOffset(
+ ScrollOffset(0, 300), ProgrammaticScroll);
+ compositor().beginFrame();
+ observer->disconnect();
+ testing::runPendingTasks();
+ EXPECT_EQ(observerCallback->callCount(), 1);
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/dom/IntersectionObserver.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698