4 <script src=
"../../../resources/js-test.js"></script>
9 border:
1px solid blue;
21 <body onload=
"runTests()">
23 This test verifies the touch event handlers tracked for the compositor for
24 elements with various touch-action settings.
27 <div id=
"touchActionDiv"> </div>
29 <div id=
"console"></div>
30 <div style=
"height: 1000px;"></div>
34 function getTouchHandlerCount(doc
) {
35 window
.internals
.updateStyleAndReturnAffectedElementCount();
36 return window
.internals
.touchEventHandlerCount(doc
);
40 if (!window
.internals
) {
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");
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");