Chromium Code Reviews| 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> |