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

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

Issue 2108953002: Add onscroll/onresize EventHandler support to ViewportAPI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: added 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
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <style> 2 <style>
3 body { 3 body {
4 height: 2000px; 4 height: 2000px;
5 width: 2000px; 5 width: 2000px;
6 } 6 }
7 </style> 7 </style>
8 8
9 <script src="../../../resources/testharness.js"></script> 9 <script src="../../../resources/testharness.js"></script>
10 <script src="../../../resources/testharnessreport.js"></script> 10 <script src="../../../resources/testharnessreport.js"></script>
11 <script> 11 <script>
12 var numCallsScroll = 0; 12 var numCallsScroll = 0;
13 var numCallsResize = 0; 13 var numCallsResize = 0;
14 var pageScaleFactor = 2; 14 var pageScaleFactor = 2;
15 15
16 function viewport() { 16 function viewport() {
17 return window.visualViewport; 17 return window.visualViewport;
18 } 18 }
19 19
20 var t = async_test('verify that the scroll and resize events get fired on wind ow.visualViewport'); 20 var t = async_test('verify that the scroll and resize events get fired on wind ow.visualViewport');
21 21
22 window.onload = t.step_func(function() { 22 window.onload = t.step_func(function() {
23 // Turn off smooth scrolling. 23 // Turn off smooth scrolling.
24 internals.settings.setScrollAnimatorEnabled(false); 24 internals.settings.setScrollAnimatorEnabled(false);
25 25
26 window.visualViewport.addEventListener('scroll', function(e) { 26 window.visualViewport.onscroll = function() {
27 numCallsScroll++; 27 numCallsScroll++;
28 }); 28 }
29 29 window.visualViewport.onresize = function() {
30 window.visualViewport.addEventListener('resize', function(e) {
31 numCallsResize++; 30 numCallsResize++;
32 }); 31 }
33 32
34 // Scroll both viewports. 33 // Scroll both viewports.
35 eventSender.mouseMoveTo(100, 100); 34 eventSender.mouseMoveTo(100, 100);
36 eventSender.continuousMouseScrollBy(100, 100); 35 eventSender.continuousMouseScrollBy(100, 100);
37 assert_equals(numCallsScroll, 0); 36 assert_equals(numCallsScroll, 0);
38 assert_equals(numCallsResize, 0); 37 assert_equals(numCallsResize, 0);
39 38
40 // TODO(ymalik): Remove hook to internals to pinch-zoom here and browser 39 // TODO(ymalik): Remove hook to internals to pinch-zoom here and browser
41 // zoom below. This will be required to upstream to w3c repo. 40 // zoom below. This will be required to upstream to w3c repo.
42 internals.setPageScaleFactor(pageScaleFactor); 41 internals.setPageScaleFactor(pageScaleFactor);
43 42
44 // Verify viewport dimensions exclude scrollbar. 43 // Verify viewport dimensions exclude scrollbar.
45 requestAnimationFrame(function() { 44 requestAnimationFrame(function() {
46 t.step(function() { 45 t.step(function() {
47 assert_equals(numCallsScroll, 0, "scroll listener not called for scale") ; 46 assert_equals(numCallsScroll, 0, "scroll listener not called for scale") ;
48 assert_equals(numCallsResize, 1, "resize listener called for scale"); 47 assert_equals(numCallsResize, 1, "resize listener called for scale");
49 }); 48 });
50 internals.setVisualViewportOffset(10, 10); 49 internals.setVisualViewportOffset(10, 10);
51 requestAnimationFrame(function() { 50 requestAnimationFrame(function() {
52 t.step(function() { 51 t.step(function() {
53 assert_equals(numCallsScroll, 1, "scroll listener called for offset ch ange"); 52 assert_equals(numCallsScroll, 1, "scroll listener called for offset ch ange");
54 assert_equals(numCallsResize, 1, "resize listener not called for offse t change"); 53 assert_equals(numCallsResize, 1, "resize listener not called for offse t change");
55 }); 54 });
56 t.done(); 55 t.done();
57 }); 56 });
58 }); 57 });
59 }); 58 });
60 </script> 59 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698