OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <script src="../../../resources/js-test.js"></script> | 2 <script src="../../../resources/js-test.js"></script> |
3 <style> | 3 <style> |
4 body { | 4 body { |
5 height: 2000px; | 5 height: 2000px; |
6 width: 2000px; | 6 width: 2000px; |
7 } | 7 } |
8 </style> | 8 </style> |
9 | 9 |
10 <script> | 10 <script> |
11 window.jsTestIsAsync = true; | 11 window.jsTestIsAsync = true; |
12 var numCalls = 0; | 12 var numCalls = 0; |
13 | 13 |
14 description("This test verifies that that visualviewportchanged event gets \ | 14 description("This test verifies that that visualviewportchanged event gets \ |
15 fired when the visual viewport is scaled or scrolled."); | 15 fired when the visual viewport is scaled or scrolled."); |
16 | 16 |
17 function verifySetViewportOffsets() { | 17 function verifySetViewportOffsets() { |
18 // Set viewport offset. Listener called twice. | 18 // Set viewport offset. Listener called twice. |
19 document.visualViewport.scrollTop = 20; | 19 window.visualViewport.scrollTop = 20; |
20 requestAnimationFrame(function() { | 20 requestAnimationFrame(function() { |
21 shouldBe("numCalls", "3"); | 21 shouldBe("numCalls", "3"); |
22 document.visualViewport.scrollLeft = 0; | 22 window.visualViewport.scrollLeft = 0; |
23 requestAnimationFrame(function() { | 23 requestAnimationFrame(function() { |
24 shouldBe("numCalls", "4"); | 24 shouldBe("numCalls", "4"); |
25 finishJSTest(); | 25 finishJSTest(); |
26 }); | 26 }); |
27 }); | 27 }); |
28 } | 28 } |
29 | 29 |
30 function runTest() { | 30 function runTest() { |
31 if (!window.eventSender || !window.internals) { | 31 if (!window.eventSender || !window.internals) { |
32 finishJSTest(); | 32 finishJSTest(); |
(...skipping 18 matching lines...) Expand all Loading... |
51 internals.setVisualViewportOffset(10, 10); | 51 internals.setVisualViewportOffset(10, 10); |
52 requestAnimationFrame(function() { | 52 requestAnimationFrame(function() { |
53 shouldBe("numCalls", "2"); | 53 shouldBe("numCalls", "2"); |
54 verifySetViewportOffsets(); | 54 verifySetViewportOffsets(); |
55 }); | 55 }); |
56 }); | 56 }); |
57 } | 57 } |
58 </script> | 58 </script> |
59 | 59 |
60 <body onload="runTest()"></body> | 60 <body onload="runTest()"></body> |
OLD | NEW |