Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / events / touch / layout-triggers.html
blob79f1e6f27466dd41b8a343de6280e9fa150f93d9
1 <!DOCTYPE html>
2 <style>
3 #box {
4 position: absolute;
6 </style>
7 <div id=box></div>
8 <script src="../../../resources/js-test.js"></script>
9 <script>
10 description("Check which type of events trigger layout when it's dirty. Events that do a hit-test must update layout, but all other events shouldn't need to.");
12 var counter = 10;
13 function triggersLayout(action) {
14 // Dirty layout
15 box.style.height = counter + 'px';
16 counter++;
17 window.internals.updateStyleAndReturnAffectedElementCount();
18 shouldNotBe('internals.needsLayoutCount()', '0', true);
20 // Run the action under test
21 action();
23 return (internals.needsLayoutCount() == 0);
26 var triggeredLayout;
27 var jsTestIsAsync = true;
29 onload = function() {
30 var targetX = 5;
31 var targetY = 5;
32 setPrintTestResultsLazily();
33 eventSender.forceLayoutOnEvents = false;
35 // EventHandler::hitTestResultAtPoint exits early when the first layout has not yet occurred.
36 debug('Forcing initial layout');
37 document.body.offsetTop;
38 shouldBeZero('internals.needsLayoutCount()');
40 debug('Sending touchstart');
41 triggeredLayout = triggersLayout(function() {
42 eventSender.addTouchPoint(targetX, targetY);
43 eventSender.touchStart();
44 });
45 shouldBeTrue('triggeredLayout');
47 debug('Sending touchmove');
48 triggeredLayout = triggersLayout(function() {
49 eventSender.updateTouchPoint(0, targetX + 1, targetY);
50 eventSender.touchStart();
51 });
52 shouldBeFalse('triggeredLayout');
54 debug('Sending touchend');
55 triggeredLayout = triggersLayout(function() {
56 eventSender.releaseTouchPoint(0);
57 eventSender.touchEnd();
58 });
59 shouldBeFalse('triggeredLayout');
61 debug('Sending GestureTapDown');
62 triggeredLayout = triggersLayout(function() {
63 eventSender.gestureTapDown(targetX, targetY);
64 });
65 shouldBeTrue('triggeredLayout');
67 debug('Sending GestureShowPress');
68 triggeredLayout = triggersLayout(function() {
69 eventSender.gestureShowPress(targetX, targetY);
70 });
71 shouldBeTrue('triggeredLayout');
73 debug('Sending GestureScrollBegin');
74 triggeredLayout = triggersLayout(function() {
75 eventSender.gestureScrollBegin(targetX, targetY);
76 });
77 shouldBeTrue('triggeredLayout');
79 debug('Sending GestureScrollUpdate');
80 triggeredLayout = triggersLayout(function() {
81 eventSender.gestureScrollUpdate(0, 5);
82 });
83 shouldBeTrue('triggeredLayout');
85 debug('Sending GestureScrollEnd');
86 triggeredLayout = triggersLayout(function() {
87 eventSender.gestureScrollEnd(0, 5);
88 });
89 shouldBeFalse('triggeredLayout');
91 finishJSTest();
94 </script>