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

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: 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..92bcfa66901f341ffbfc057ae5ed9a8b3ac3d425
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/scroll-behavior/visual-viewport-scroll-no-onscroll-event.html
@@ -0,0 +1,62 @@
+<!DOCTYPE html>
+<script src="../../resources/js-test.js"></script>
+<style>
+ #target {
+ width: 2000px;
+ height: 1500px;
+ }
+</style>
+<script language="JavaScript" type="text/javascript">
bokan 2015/11/05 14:43:52 Just <script> is fine.
ymalik 2015/11/05 15:57:01 Done. Thanks.
+ 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.mouseScrollBy(0, -10);
bokan 2015/11/05 14:43:52 Maybe I'm missing something but how does this work
ymalik 2015/11/05 15:57:01 The -10 here is the number of mouse wheel ticks. S
bokan 2015/11/05 16:35:48 Got it, that makes more sense, thanks.
+ } 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.mouseScrollBy(0, 1);
+ } else {
+ shouldBe('numScrollsReceived', '1');
+ finishJSTest();
bokan 2015/11/05 14:43:52 Could you add a return here, it seems we're hittin
ymalik 2015/11/05 15:57:01 If we were hitting it twice, it would reflect in t
bokan 2015/11/05 16:35:48 It is reflected in the expected results, there's t
ymalik 2015/11/05 16:40:26 The first "numScrollsReceived is 1" is from the pr
bokan 2015/11/05 17:02:47 DOH! Brain fart on my part :/
+ }
+ ++numRAFCalls;
+ window.requestAnimationFrame(failureSentinel);
+ }
+
+ window.requestAnimationFrame(failureSentinel);
+ }
+
+ onload = runTest;
+</script>
+<div id="target"></div>

Powered by Google App Engine
This is Rietveld 408576698