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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/dom/viewport/scroll-resize-events-fired.html

Issue 2096783004: Seperate visualviewportchanged event into scroll and resize events (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix crash + tests Created 4 years, 5 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 unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <style>
3 body {
4 height: 2000px;
5 width: 2000px;
6 }
7 </style>
8
9 <script src="../../../resources/testharness.js"></script>
10 <script src="../../../resources/testharnessreport.js"></script>
11 <script>
12 var numCallsScroll = 0;
13 var numCallsResize = 0;
14 var pageScaleFactor = 2;
15
16 function viewport() {
17 return window.visualViewport;
18 }
19
20 var t = async_test('verify that the scroll and resize events get fired on wind ow.visualViewport');
21
22 function verifySetViewportOffsets() {
23 // Set viewport offset.
24 window.visualViewport.scrollTop = 20;
25 requestAnimationFrame(function() {
26 t.step(function() {
27 assert_equals(numCallsScroll, 2, "scroll listener called for scrollTop") ;
28 assert_equals(numCallsResize, 1, "resize listener not called for scrollT op");
29 });
30 window.visualViewport.scrollLeft = 0;
31 requestAnimationFrame(function() {
32 t.step(function() {
33 assert_equals(numCallsScroll, 3, "scroll listener called for scrollLef t");
34 assert_equals(numCallsResize, 1, "resize listener not called for scrol lLeft");
35 });
36 t.done();
37 });
38 });
39 }
40
41 window.onload = t.step_func(function() {
42 // Turn off smooth scrolling.
43 internals.settings.setScrollAnimatorEnabled(false);
44
45 window.visualViewport.addEventListener('scroll', function(e) {
46 numCallsScroll++;
47 });
48
49 window.visualViewport.addEventListener('resize', function(e) {
50 numCallsResize++;
51 });
52
53 // Scroll both viewports.
54 eventSender.mouseMoveTo(100, 100);
55 eventSender.continuousMouseScrollBy(100, 100);
56 assert_equals(numCallsScroll, 0);
57 assert_equals(numCallsResize, 0);
58
59 // TODO(ymalik): Remove hook to internals to pinch-zoom here and browser
60 // zoom below. This will be required to upstream to w3c repo.
61 internals.setPageScaleFactor(pageScaleFactor);
62
63 // Verify viewport dimensions exclude scrollbar.
64 requestAnimationFrame(function() {
65 t.step(function() {
66 assert_equals(numCallsScroll, 0, "scroll listener not called for scale") ;
67 assert_equals(numCallsResize, 1, "resize listener called for scale");
68 });
69 internals.setVisualViewportOffset(10, 10);
70 requestAnimationFrame(function() {
71 t.step(function() {
72 assert_equals(numCallsScroll, 1, "scroll listener called for offset ch ange");
73 assert_equals(numCallsResize, 1, "resize listener not called for offse t change");
74 });
75 verifySetViewportOffsets();
76 });
77 });
78 });
79 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698