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

Unified Diff: third_party/WebKit/LayoutTests/fast/scroll-behavior/visual-viewport-scroll-no-onscroll-event.html

Issue 1416283006: Make window.scroll properties relative to the layout viewport by default. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: worked on review comments Created 5 years, 1 month 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/LayoutTests/fast/scroll-behavior/visual-viewport-scroll-no-onscroll-event.html
diff --git a/third_party/WebKit/LayoutTests/fast/scroll-behavior/visual-viewport-scroll-no-onscroll-event.html b/third_party/WebKit/LayoutTests/fast/scroll-behavior/visual-viewport-scroll-no-onscroll-event.html
new file mode 100644
index 0000000000000000000000000000000000000000..341994f826076875c46054f9b5a980a9ca25649e
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/scroll-behavior/visual-viewport-scroll-no-onscroll-event.html
@@ -0,0 +1,63 @@
+<!DOCTYPE html>
+<script src="../../resources/js-test.js"></script>
+<style>
+ #target {
+ width: 2000px;
+ height: 1500px;
+ }
+</style>
+<script>
+ var numScrollsReceived = 0;
+ var numRAFCalls = 0;
+ if (window.testRunner && window.internals) {
+ window.jsTestIsAsync = true;
+ testRunner.dumpAsText();
+ testRunner.waitUntilDone();
+ setPrintTestResultsLazily();
+ }
+
+ description("This test ensures that scrolling the visual viewport doesn't\
+ trigger an onscroll event.");
+
+ function runTest() {
+ if (!window.testRunner || !window.internals) {
+ testFailed("This test requires test runner and internals")
+ finishJSTest();
+ return;
+ }
+
+ window.internals.setPageScaleFactor(2.0);
+ var target = document.getElementById('target');
+
+ document.onscroll = function() {
+ ++numScrollsReceived;
+ debug('OnScroll called for scroll #' + numScrollsReceived);
+ }
+
+ var failureSentinel = function() {
+ if (numRAFCalls == 0) {
+ // The first scroll should trigger onscroll because it scrolls
+ // the layout viewport.
+ eventSender.mouseMoveTo(target.offsetLeft + 5, target.offsetTop + 5);
+ eventSender.continuousMouseScrollBy(0, -400);
+ } else if (numRAFCalls == 1) {
+ shouldBe('numScrollsReceived', '1');
+ // The second scroll should not trigger onscroll because it only
+ // scrolls the visual viewport.
+ eventSender.mouseMoveTo(target.offsetLeft + 5, target.offsetTop + 5);
+ eventSender.continuousMouseScrollBy(0, 40);
+ } else {
+ shouldBe('numScrollsReceived', '1');
+ finishJSTest();
+ return;
+ }
+ ++numRAFCalls;
+ window.requestAnimationFrame(failureSentinel);
+ }
+
+ window.requestAnimationFrame(failureSentinel);
+ }
+
+ onload = runTest;
+</script>
+<div id="target"></div>

Powered by Google App Engine
This is Rietveld 408576698