Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / events / touch / touch-action-touch-handlers.html
blobfe9b4d6ef5ffd2b6402edfc0b12b4b9916d31d3a
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../../../resources/js-test.js"></script>
5 <style>
6 #touchActionDiv {
7 height: 50px;
8 width: 200px;
9 border: 1px solid blue;
12 .display-none {
13 display: none;
16 .touch-action-none {
17 touch-action: none;
19 </style>
20 </head>
21 <body onload="runTests()">
22 <p id="description">
23 This test verifies the touch event handlers tracked for the compositor for
24 elements with various touch-action settings.
25 </p>
27 <div id="touchActionDiv"> </div>
29 <div id="console"></div>
30 <div style="height: 1000px;"></div>
31 <script>
32 var nestedDocument;
34 function getTouchHandlerCount(doc) {
35 window.internals.updateStyleAndReturnAffectedElementCount();
36 return window.internals.touchEventHandlerCount(doc);
39 function runTests() {
40 if (!window.internals) {
41 return;
44 var div = document.getElementById("touchActionDiv");
46 debug("Should start with no handlers");
47 shouldBe("getTouchHandlerCount(document)", "0");
49 debug("touch-action: auto should not add any handlers");
50 div.style.touchAction = "auto";
51 shouldBe("getTouchHandlerCount(document)", "0");
53 debug("transition from auto should add a handler");
54 div.style.touchAction = "none";
55 shouldBe("getTouchHandlerCount(document)", "1");
57 debug("transition between non-auto values should maintain handler");
58 div.style.touchAction = "pan-y";
59 shouldBe("getTouchHandlerCount(document)", "1");
61 debug("multiple touch-action applications shouldn't affect handler count");
62 div.className = "touch-action-none";
63 shouldBe("getTouchHandlerCount(document)", "1");
65 debug("modifying any unrelated CSS property shouldn't affect handler count");
66 div.style.backgroundColor = 'red';
67 shouldBe("getTouchHandlerCount(document)", "1");
69 debug("setting display:none should remove handler");
70 div.className = "display-none";
71 shouldBe("getTouchHandlerCount(document)", "0");
73 debug("and removing it should bring back handler");
74 div.className = "";
75 shouldBe("getTouchHandlerCount(document)", "1");
77 debug("adding another listener should bump up handler count");
78 var listener = function() { };
79 div.addEventListener("touchstart", listener);
80 shouldBe("getTouchHandlerCount(document)", "2");
82 debug("removing node should remove touch-action handler but not others");
83 document.body.removeChild(div);
84 shouldBe("getTouchHandlerCount(document)", "1");
86 debug("re-attaching node should add handler");
87 document.body.insertBefore(div, document.body.firstChild);
88 shouldBe("getTouchHandlerCount(document)", "2");
90 debug("transitioning to auto should decrease handler count");
91 div.style.touchAction = "auto";
92 shouldBe("getTouchHandlerCount(document)", "1");
94 debug("touch-action on div inside frame should add a handler");
95 var iframe = document.createElement("iframe");
96 document.body.appendChild(iframe);
97 nestedDocument = iframe.contentWindow.document;
98 nestedDocument.open('text/html', 'replace');
99 nestedDocument.write("<!DOCTYPE html>\n<div style='touch-action: none'></div>");
100 nestedDocument.close();
101 window.internals.forceCompositingUpdate(document);
102 shouldBe("getTouchHandlerCount(nestedDocument)", "2");
103 shouldBe("getTouchHandlerCount(document)", "2");
105 </script>
106 </body>
107 </html>