Update web-platform-tests to revision 8da19eeb64e1dbcc32cabc2961a44e15635d116f

This commit is contained in:
WPT Sync Bot 2019-07-04 10:26:17 +00:00
parent b32bff3b97
commit 120d9aa5dc
298 changed files with 9286 additions and 3047 deletions

View file

@ -0,0 +1,77 @@
<!DOCTYPE html>
<title>CSSOM View - scrollIntoView considers direction:rtl</title>
<meta charset="utf-8">
<link rel="author" title="Cathie Chen" href="mailto:cathiechen@igalia.com">
<link rel="help" href="https://drafts.csswg.org/cssom-view/#dom-element-scrollintoview">
<link rel="help" href="https://drafts.csswg.org/cssom-view/#scroll-an-element">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
.box {
float: left;
width: 200px;
height: 200px;
}
#scroller {
direction: rtl;
overflow-x: scroll;
width: 300px;
height: 215px;
}
#container{
width: 600px;
height: 200px;
}
#target {
background-color: #ff0;
}
</style>
<body>
<div id="scroller">
<div id="container">
<div class="row">
<div class="box"></div>
<div class="box" id="target"></div>
<div class="box"></div>
</div>
</div>
</div>
<script>
// This page is direction: rtl and scroller is direction: rtl.
// So the the overflow direction is leftward, downward. The beginning edges are the top and right edges.
// And the ending edges are the bottom and left edges.
// Acording to the spec, x is min(0, max(x, element padding edge width - element scrolling area width)).
// So x is nonpositive and decreases leftward.
var target = document.getElementById("target");
var scroller = document.getElementById("scroller");
var box_width = target.offsetWidth;
var scroller_width = scroller.offsetWidth;
var leftEdge = -2*box_width + scroller_width;
var center = -(3*box_width - scroller_width)/2;
var rightEdge = - box_width;
test(() => {
scroller.scrollTo(0, 0);
target.scrollIntoView({inline: "start"});
assert_approx_equals(scroller.scrollLeft, rightEdge, 0.5, "start should be the right edge");
}, `scrollIntoView({inline: "start"}), direction: rtl`);
test(() => {
scroller.scrollTo(0, 0);
target.scrollIntoView({inline: "center"});
assert_approx_equals(scroller.scrollLeft, center, 0.5, "should center the target");
}, `scrollIntoView({inline: "center"}), direction: rtl`);
test(() => {
scroller.scrollTo(0, 0);
target.scrollIntoView({inline: "end"});
assert_approx_equals(scroller.scrollLeft, leftEdge, 0.5, "end should be the left edge");
}, `scrollIntoView({inline: "end"}), direction: rtl`);
</script>
</body>
</html>

View file

@ -53,6 +53,9 @@
</div>
<script>
// In vertical-rl mode, X corresponds to the block axis and is oriented
// leftward. Y corresponds to the inline axis and is oriented downward.
// This assumes that the horizontal scrollbar is on the bottom side.
var target = document.getElementById("target");
var scroller = document.getElementById("scroller");
var scrollbar_width = scroller.offsetWidth - scroller.clientWidth;
@ -62,14 +65,42 @@ var scroller_height = scroller.offsetHeight;
var box_width = target.offsetWidth;
var box_height = target.offsetHeight;
var expectedX = [ ((2*box_width)-scroller_width)+scrollbar_width, ((3*box_width - scroller_width)/2)+ (scrollbar_width/2), box_width ];
var expectedY = [ box_height, ((3*box_height - scroller_height)/2) + (scrollbar_width/2), ((2*box_height)-scroller_height) + scrollbar_width ];
var expectedX;
// If scroll bar is on the left side, scroller.scrollLeft won't get bigger than 0,
scroller.scrollLeft = scrollbar_width;
if (scroller.scrollLeft == 0) {
expectedX = {
blockStart: -box_width,
blockCenter: -(((3*box_width - scroller_width)/2) + (scrollbar_width/2)),
blockEnd: -(((2*box_width) - scroller_width) + scrollbar_width),
};
} else {
expectedX = {
blockStart: -(box_width - scrollbar_width),
blockCenter: -(((3*box_width - scroller_width)/2) + (scrollbar_width/2) - scrollbar_width),
blockEnd: -((2*box_width) - scroller_width),
};
}
var expectedY = {
inlineStart: box_height,
inlineCenter: ((3*box_height - scroller_height)/2) + (scrollbar_width/2),
inlineEnd: ((2*box_height) - scroller_height) + scrollbar_width,
};
// As browsers differ in the meaning of scrollLeft when
// in a right-to-left mode, we adjust the expectation
// to match the semantics of scrollLeft.
if(scroller.scrollLeft === 0)
expectedX = [ -box_width, -(((3*box_width - scroller_width)/2)+ (scrollbar_width/2)), -(((2*box_width)-scroller_width)+scrollbar_width)];
// In vertical-rl mode, the scroll x coordinate should be nonpositive per the the spec.
// But some browsers is nonnegative, so we adjust the expectation.
scroller.scrollLeft = -1000;
if(scroller.scrollLeft === 0) {
expectedX = {
blockStart: ((2*box_width) - scroller_width) + scrollbar_width,
blockCenter: ((3*box_width - scroller_width)/2) + (scrollbar_width/2),
blockEnd: box_width,
};
}
// This formats dict as a string suitable as test name.
// format_value() is provided by testharness.js,
@ -83,15 +114,15 @@ function format_dict(dict) {
}
[
[{block: "start", inline: "start"}, expectedX[0], expectedY[0]],
[{block: "start", inline: "center"}, expectedX[0], expectedY[1]],
[{block: "start", inline: "end"}, expectedX[0], expectedY[2]],
[{block: "center", inline: "start"}, expectedX[1], expectedY[0]],
[{block: "center", inline: "center"}, expectedX[1], expectedY[1]],
[{block: "center", inline: "end"}, expectedX[1], expectedY[2]],
[{block: "end", inline: "start"}, expectedX[2], expectedY[0]],
[{block: "end", inline: "center"}, expectedX[2], expectedY[1]],
[{block: "end", inline: "end"}, expectedX[2], expectedY[2]],
[{block: "start", inline: "start"}, expectedX.blockStart, expectedY.inlineStart],
[{block: "start", inline: "center"}, expectedX.blockStart, expectedY.inlineCenter],
[{block: "start", inline: "end"}, expectedX.blockStart, expectedY.inlineEnd],
[{block: "center", inline: "start"}, expectedX.blockCenter, expectedY.inlineStart],
[{block: "center", inline: "center"}, expectedX.blockCenter, expectedY.inlineCenter],
[{block: "center", inline: "end"}, expectedX.blockCenter, expectedY.inlineEnd],
[{block: "end", inline: "start"}, expectedX.blockEnd, expectedY.inlineStart],
[{block: "end", inline: "center"}, expectedX.blockEnd, expectedY.inlineCenter],
[{block: "end", inline: "end"}, expectedX.blockEnd, expectedY.inlineEnd],
].forEach(([input, expectedX, expectedY]) => {
test(() => {
scroller.scrollTo(0, 0);