summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/touchadjustment/simple-shadow-dom.html
blob: 27564d1b3fb35ee88a007500b28376190a4ee1ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<!DOCTYPE html>
<head>
<style>
#targetDiv {
    background: #00f;
    height: 100px;
    width: 100px;
    position: absolute;
    left: 0px;
    top: 0px;
}
</style>
</head>
<div id="targetDiv"></div>

<script src="../resources/js-test.js"></script>
<script src="resources/touchadjustment.js"></script>
<script>
function addShadowDOM() {
    var targetDiv = document.getElementById("targetDiv");
    var root = targetDiv.createShadowRoot();
    var shadowDiv = document.createElement("div");
    shadowDiv.style.width = "50px";
    shadowDiv.style.height = "50px";
    shadowDiv.style.background = "#ff0";
    shadowDiv.style.position = "absolute";
    shadowDiv.style.left = "0px";
    shadowDiv.style.top = "0px";
    shadowDiv.id = 'shadowDiv';
    shadowDiv.addEventListener('click', function() {}, false);
    root.appendChild(shadowDiv);
    return shadowDiv;
}

function runTouchTests() {
    var shadowDiv = addShadowDOM();
    element = document.getElementById("targetDiv");
    element.addEventListener('click', function() {}, false);
    document.addEventListener('click', function() {}, false);
    testTouchPoint(touchPoint(25, 25, 10), shadowDiv);
}

function runTests()
{
    if (window.testRunner && window.internals && internals.touchNodeAdjustedToBestClickableNode) {
        description('Test that a hit right in the middle of a shadow dom node returns it and not its host.')
        runTouchTests();
    }
}
runTests();
</script>