Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / touchadjustment / pseudo-element.html
blobfca68bdbb48e63280b50d373f0ff4feed8e666e9
1 <!DOCTYPE html>
2 <title>Touch Adjustment: Shouldn't return pseudo elements - bug 395942</title>
3 <script src="../resources/js-test.js"></script>
4 <script src="resources/touchadjustment.js"></script>
5 <style>
6 #targetDiv {
7 height: 0;
8 width: 0;
10 #targetDiv:after {
11 display: block;
12 position: relative;
13 left: 50px;
14 background-color: blue;
15 width: 50px;
16 height: 50px;
17 content: '';
19 </style>
20 <div id="targetDiv">
21 </div>
23 <p id='description'></p>
24 <div id='console'></div>
26 <script>
27 var element;
28 var adjustedNode;
29 var adjustedPoint;
30 var targetBounds;
31 var touchBounds;
33 function runTouchTests() {
34 element = document.getElementById("targetDiv");
35 element.addEventListener('click', function() {}, false);
36 document.addEventListener('click', function() {}, false);
38 targetBounds = findAbsoluteBounds(element);
40 // Adjust for offset to the pseudo element
41 targetBounds = {
42 left: targetBounds.left + 50,
43 top: targetBounds.top,
44 width: 50,
45 height: 50
48 var touchRadius = 10;
49 var offset = touchRadius / 2;
50 var midX = targetBounds.left + targetBounds.width / 2;
51 var midY = targetBounds.top + targetBounds.height / 2;
53 debug('Test touch area contained within the pseudo element.');
54 testTouch(midX, midY, touchRadius, targetBounds);
55 debug('');
57 debug('Overlapping touch above the target should snap to the top of the pseudo element.');
58 testTouch(midX, targetBounds.top - offset, touchRadius, targetBounds);
59 debug('');
61 debug('Overlapping touch below the target should snap to the bottom of the pseudo element.');
62 testTouch(midX, targetBounds.top + targetBounds.height + offset, touchRadius, targetBounds);
63 debug('');
65 debug('Overlapping touch left of the target should snap to the left side of the pseudo element.');
66 testTouch(targetBounds.left - offset, midY, touchRadius, targetBounds);
67 debug('');
69 debug('Overlapping touch right of the target should snap to the right side of the pseudo element.');
70 testTouch(targetBounds.left + targetBounds.width + offset, midY, touchRadius, targetBounds);
71 debug('');
74 function testTouch(touchX, touchY, radius, targetBounds) {
76 touchBounds = {
77 x: touchX - radius,
78 y: touchY - radius,
79 width: 2 * radius,
80 height: 2 * radius
82 adjustedNode = internals.touchNodeAdjustedToBestClickableNode(touchBounds.x, touchBounds.y, touchBounds.width, touchBounds.height, document);
83 shouldBe('adjustedNode.id', 'element.id');
84 adjustedPoint = internals.touchPositionAdjustedToBestClickableNode(touchBounds.x, touchBounds.y, touchBounds.width, touchBounds.height, document);
86 shouldBeTrue('adjustedPoint.x >= targetBounds.left');
87 shouldBeTrue('adjustedPoint.x <= targetBounds.left + targetBounds.width');
88 shouldBeTrue('adjustedPoint.y >= targetBounds.top');
89 shouldBeTrue('adjustedPoint.y <= targetBounds.top + targetBounds.height');
90 shouldBeTrue('adjustedPoint.x >= touchBounds.x');
91 shouldBeTrue('adjustedPoint.x <= touchBounds.x + touchBounds.width');
92 shouldBeTrue('adjustedPoint.y >= touchBounds.y');
93 shouldBeTrue('adjustedPoint.y <= touchBounds.y + touchBounds.height');
96 description('Test touch adjustment over pseudo elements. Pseudo elements should be candidates for adjustment, but should not themselves be returned as valid target nodes.');
98 if (window.internals) {
99 runTouchTests();
101 </script>