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

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

Issue 2186713002: Remove onscroll/onresize EventHandler supper from ViewportAPI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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.onscroll = function() { 26 window.visualViewport.addEventListener('scroll', function(e) {
27 numCallsScroll++; 27 numCallsScroll++;
28 } 28 });
29 window.visualViewport.onresize = function() { 29
30 window.visualViewport.addEventListener('resize', function(e) {
30 numCallsResize++; 31 numCallsResize++;
31 } 32 });
32 33
33 // Scroll both viewports. 34 // Scroll both viewports.
34 eventSender.mouseMoveTo(100, 100); 35 eventSender.mouseMoveTo(100, 100);
35 eventSender.continuousMouseScrollBy(100, 100); 36 eventSender.continuousMouseScrollBy(100, 100);
36 assert_equals(numCallsScroll, 0); 37 assert_equals(numCallsScroll, 0);
37 assert_equals(numCallsResize, 0); 38 assert_equals(numCallsResize, 0);
38 39
39 // TODO(ymalik): Remove hook to internals to pinch-zoom here and browser 40 // TODO(ymalik): Remove hook to internals to pinch-zoom here and browser
40 // zoom below. This will be required to upstream to w3c repo. 41 // zoom below. This will be required to upstream to w3c repo.
41 internals.setPageScaleFactor(pageScaleFactor); 42 internals.setPageScaleFactor(pageScaleFactor);
42 43
43 // Verify viewport dimensions exclude scrollbar. 44 // Verify viewport dimensions exclude scrollbar.
44 requestAnimationFrame(function() { 45 requestAnimationFrame(function() {
45 t.step(function() { 46 t.step(function() {
46 assert_equals(numCallsScroll, 0, "scroll listener not called for scale") ; 47 assert_equals(numCallsScroll, 0, "scroll listener not called for scale") ;
47 assert_equals(numCallsResize, 1, "resize listener called for scale"); 48 assert_equals(numCallsResize, 1, "resize listener called for scale");
48 }); 49 });
49 internals.setVisualViewportOffset(10, 10); 50 internals.setVisualViewportOffset(10, 10);
50 requestAnimationFrame(function() { 51 requestAnimationFrame(function() {
51 t.step(function() { 52 t.step(function() {
52 assert_equals(numCallsScroll, 1, "scroll listener called for offset ch ange"); 53 assert_equals(numCallsScroll, 1, "scroll listener called for offset ch ange");
53 assert_equals(numCallsResize, 1, "resize listener not called for offse t change"); 54 assert_equals(numCallsResize, 1, "resize listener not called for offse t change");
54 }); 55 });
55 t.done(); 56 t.done();
56 }); 57 });
57 }); 58 });
58 }); 59 });
59 </script> 60 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698