
This CL is the result of the following mechanical replacements, within the third_party/blink/web_tests folder, on only .html and .js files: '.createShadowRoot()' -> '.attachShadow({mode: 'open'})' 'document.createElement('content')' -> 'document.createElement('span')' Several web_tests did not pass after the above replacements were made. Those tests were reverted - the changes in this CL are only the tests that pass in the same way that they did prior to the replacements. The only exceptions, which were re-baselined here, had *only* a console warning message like this, which is now missing: CONSOLE WARNING: line 27: Element.createShadowRoot is deprecated and will be removed in M80, around February 2020. Please use... In addition, most of the same test expectations files were completely removed from the virtual/web-components-v0-disabled folder, since these tests no longer depend on WCv0 features, and no longer fail. Bug: 937746 Change-Id: I157b48633206ddb249c55a7728c94955e88746b0 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2211053 Auto-Submit: Mason Freed <masonfreed@chromium.org> Commit-Queue: Stephen Chenney <schenney@chromium.org> Reviewed-by: Stephen Chenney <schenney@chromium.org> Cr-Commit-Position: refs/heads/master@{#771452}
104 lines
3.8 KiB
HTML
104 lines
3.8 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>Touch Adjustment : Touch adjustment does not target shadow DOM elements - bug 89556</title>
|
|
<script src="../resources/js-test.js"></script>
|
|
<script src="resources/touchadjustment.js"></script>
|
|
<style>
|
|
#targetDiv {
|
|
background: #00f;
|
|
height: 100px;
|
|
position: relative;
|
|
width: 100px;
|
|
}
|
|
</style>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div id="targetDiv">
|
|
</div>
|
|
|
|
<p id='description'></p>
|
|
<div id='console'></div>
|
|
|
|
<script>
|
|
var element;
|
|
var adjustedNode;
|
|
var adjustedPoint;
|
|
|
|
function findAbsolutePosition(node) {
|
|
var pos = {left: 0, top: 0};
|
|
do {
|
|
pos.left += node.offsetLeft;
|
|
pos.top += node.offsetTop;
|
|
} while (node = node.offsetParent);
|
|
return pos;
|
|
}
|
|
|
|
function addShadowDOM() {
|
|
var targetDiv = document.getElementById("targetDiv");
|
|
var root = targetDiv.attachShadow({mode: 'open'});
|
|
var shadowDiv = document.createElement("div");
|
|
shadowDiv.style.width = "20px";
|
|
shadowDiv.style.height = "20px";
|
|
shadowDiv.style.background = "#ff0";
|
|
shadowDiv.style.position = "absolute";
|
|
shadowDiv.style.right = "10px";
|
|
shadowDiv.style.top = "10px";
|
|
shadowDiv.addEventListener('click', function() {}, false);
|
|
root.appendChild(shadowDiv);
|
|
}
|
|
|
|
function runTouchTests() {
|
|
element = document.getElementById("targetDiv");
|
|
element.addEventListener('click', function() {}, false);
|
|
document.addEventListener('click', function() {}, false);
|
|
|
|
var pos = findAbsolutePosition(element);
|
|
var x = pos.left;
|
|
var y = pos.top;
|
|
var width = element.clientWidth;
|
|
var height = element.clientHeight;
|
|
var midX = x + width / 2;
|
|
var midY = y + height / 2;
|
|
var border = 10;
|
|
var targetRadius = 10;
|
|
var padding = 30;
|
|
var targetX = x + width - targetRadius - border;
|
|
var targetY = y + targetRadius + border;
|
|
var offset = 2;
|
|
|
|
// Test touches that are just outside the bounds of the shadow-DOM. The adjusted point should be pulled within the bounds of the shadow-DOM node.
|
|
testTouch(targetX + targetRadius + offset, targetY, padding, targetX, targetY, targetRadius);
|
|
testTouch(targetX - targetRadius - offset, targetY, padding, targetX, targetY, targetRadius);
|
|
testTouch(targetX, targetY + targetRadius + offset, padding, targetX, targetY, targetRadius);
|
|
testTouch(targetX, targetY - targetRadius - offset, padding, targetX, targetY, targetRadius);
|
|
|
|
// A touch in the center of targetDiv is sufficient distance from the shadow-DOM element that the position should not snap.
|
|
testTouch(midX, midY, padding, midX, midY, 1);
|
|
}
|
|
|
|
function testTouch(touchX, touchY, padding, adjustedX, adjustedY, tolerance) {
|
|
var left = touchX - padding / 2;
|
|
var top = touchY - padding / 2;
|
|
testTouchPoint(touchPoint(left, top, padding), element, /* allowTextNodes */ false, /* disallowShadowDOM */ true);
|
|
adjustedPoint = internals.touchPositionAdjustedToBestClickableNode(left, top, padding, padding, document);
|
|
shouldBeCloseTo('adjustedPoint.x', adjustedX, tolerance);
|
|
shouldBeCloseTo('adjustedPoint.y', adjustedY, tolerance);
|
|
}
|
|
|
|
function runTests()
|
|
{
|
|
if (window.testRunner && window.internals && internals.touchNodeAdjustedToBestClickableNode) {
|
|
description('Test the case where a clickable target contains a shadow-DOM element. The adjusted point should snap to the location of the shadow-DOM element if close enough to the original touch position.')
|
|
addShadowDOM();
|
|
runTouchTests();
|
|
}
|
|
}
|
|
runTests();
|
|
</script>
|
|
</body>
|
|
</html>
|