Update web-platform-tests to revision 0b22439430b6d8d9a6d43a0908e86c0366f207c0

This commit is contained in:
WPT Sync Bot 2019-07-06 10:25:38 +00:00
parent 39ec04a065
commit c8e806d0ef
93 changed files with 2118 additions and 597 deletions

View file

@ -1,77 +0,0 @@
<!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

@ -0,0 +1,111 @@
<!DOCTYPE html>
<title>CSSOM View - scrollIntoView considers horizontal-tb and rtl direction</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: scroll;
width: 300px;
height: 300px;
}
#container{
width: 600px;
height: 600px;
}
#target {
background-color: #ff0;
}
</style>
<body>
<div id="scroller">
<div id="container">
<!-- ROW-1 -->
<div class="row">
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
</div>
<!-- ROW-2 -->
<div class="row">
<div class="box"></div>
<div class="box" id="target"></div>
<div class="box"></div>
</div>
<!-- ROW-3 -->
<div class="row">
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
</div>
</div>
</div>
<script>
// In horizontal-tb mode and rtl direction, X corresponds to the inline axis
// and is oriented leftward. Y corresponds to the block axis and is oriented
// downward. So the beginning edges are the top and right edges and the ending
// edges are the bottom and left edges.
// According to the spec, x is min(0, max(x, element padding edge width - element scrolling area width)).
// So x is nonpositive and decreases leftward.
// This assumes that the horizontal scrollbar is on the bottom side
// and the vertical scrollbar is on the left side.
var target = document.getElementById("target");
var scroller = document.getElementById("scroller");
var scrollbar_width = scroller.offsetWidth - scroller.clientWidth;
var scroller_width = scroller.offsetWidth;
var scroller_height = scroller.offsetHeight;
var box_width = target.offsetWidth;
var box_height = target.offsetHeight;
var expectedX = {
inlineStart: -box_width,
inlineCenter: -((3*box_width - scroller_width)/2) - scrollbar_width/2,
inlineEnd: -(2*box_width - scroller_width) - scrollbar_width,
};
var expectedY = {
blockStart: box_height,
blockCenter: (3*box_height - scroller_height)/2 + scrollbar_width/2,
blockEnd: 2*box_height - scroller_height + scrollbar_width,
};
[
[{block: "start", inline: "start"}, expectedX.inlineStart, expectedY.blockStart],
[{block: "start", inline: "center"}, expectedX.inlineCenter, expectedY.blockStart],
[{block: "start", inline: "end"}, expectedX.inlineEnd, expectedY.blockStart],
[{block: "center", inline: "start"}, expectedX.inlineStart, expectedY.blockCenter],
[{block: "center", inline: "center"}, expectedX.inlineCenter, expectedY.blockCenter],
[{block: "center", inline: "end"}, expectedX.inlineEnd, expectedY.blockCenter],
[{block: "end", inline: "start"}, expectedX.inlineStart, expectedY.blockEnd],
[{block: "end", inline: "center"}, expectedX.inlineCenter, expectedY.blockEnd],
[{block: "end", inline: "end"}, expectedX.inlineEnd, expectedY.blockEnd],
].forEach(([input, expectedX, expectedY]) => {
test(() => {
scroller.scrollTo(0, 0);
target.scrollIntoView(input);
assert_approx_equals(scroller.scrollLeft, expectedX, 0.5, "scrollX");
assert_approx_equals(scroller.scrollTop, expectedY, 0.5, "scrollY");
}, `scrollIntoView(${JSON.stringify(input)})`);
})
</script>
</body>
</html>

View file

@ -0,0 +1,106 @@
<!DOCTYPE html>
<title>CSSOM View - scrollIntoView considers horizontal-tb writing mode</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">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
.box {
float: left;
width: 200px;
height: 200px;
}
#scroller {
overflow: scroll;
width: 300px;
height: 300px;
}
#container{
width: 600px;
height: 600px;
}
#target {
background-color: #ff0;
}
</style>
<body>
<div id="scroller">
<div id="container">
<!-- ROW-1 -->
<div class="row">
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
</div>
<!-- ROW-2 -->
<div class="row">
<div class="box"></div>
<div class="box" id="target"></div>
<div class="box"></div>
</div>
<!-- ROW-3 -->
<div class="row">
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
</div>
</div>
</div>
<script>
// In horizontal-tb mode, X corresponds to the inline axis and is oriented
// rightward. Y corresponds to the block axis and is oriented downward.
// So the beginning edges are the top and left edges and the ending
// edges are the bottom and right edges.
// This assumes that the horizontal scrollbar is on the bottom side and
// the vertical scrollbar is on the right side.
var target = document.getElementById("target");
var scroller = document.getElementById("scroller");
var scrollbar_width = scroller.offsetWidth - scroller.clientWidth;
var scroller_width = scroller.offsetWidth;
var scroller_height = scroller.offsetHeight;
var box_width = target.offsetWidth;
var box_height = target.offsetHeight;
var expectedX = {
inlineStart: box_width,
inlineCenter: (3*box_width - scroller_width)/2 + scrollbar_width/2,
inlineEnd: 2*box_width - scroller_width + scrollbar_width,
};
var expectedY = {
blockStart: box_height,
blockCenter: (3*box_height - scroller_height)/2 + scrollbar_width/2,
blockEnd: 2*box_height - scroller_height + scrollbar_width,
};
[
[{block: "start", inline: "start"}, expectedX.inlineStart, expectedY.blockStart],
[{block: "start", inline: "center"}, expectedX.inlineCenter, expectedY.blockStart],
[{block: "start", inline: "end"}, expectedX.inlineEnd, expectedY.blockStart],
[{block: "center", inline: "start"}, expectedX.inlineStart, expectedY.blockCenter],
[{block: "center", inline: "center"}, expectedX.inlineCenter, expectedY.blockCenter],
[{block: "center", inline: "end"}, expectedX.inlineEnd, expectedY.blockCenter],
[{block: "end", inline: "start"}, expectedX.inlineStart, expectedY.blockEnd],
[{block: "end", inline: "center"}, expectedX.inlineCenter, expectedY.blockEnd],
[{block: "end", inline: "end"}, expectedX.inlineEnd, expectedY.blockEnd],
].forEach(([input, expectedX, expectedY]) => {
test(() => {
scroller.scrollTo(0, 0);
target.scrollIntoView(input);
assert_approx_equals(scroller.scrollLeft, expectedX, 0.5, "scrollX");
assert_approx_equals(scroller.scrollTop, expectedY, 0.5, "scrollY");
}, `scrollIntoView(${JSON.stringify(input)})`);
})
</script>
</body>
</html>

View file

@ -0,0 +1,112 @@
<!DOCTYPE html>
<title>CSSOM View - scrollIntoView considers vertical-lr and rtl direction</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 {
writing-mode: vertical-lr;
direction: rtl;
overflow: scroll;
width: 300px;
height: 300px;
}
#container{
width: 600px;
height: 600px;
}
#target {
background-color: #ff0;
}
</style>
<body>
<div id="scroller">
<div id="container">
<!-- ROW-1 -->
<div class="row">
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
</div>
<!-- ROW-2 -->
<div class="row">
<div class="box"></div>
<div class="box" id="target"></div>
<div class="box"></div>
</div>
<!-- ROW-3 -->
<div class="row">
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
</div>
</div>
</div>
<script>
// In vertical-lr mode and rtl direction, X corresponds to the block axis
// and is oriented rightward. Y corresponds to the inline axis and is oriented
// upward. So the beginning edges are the bottom and left edges and the ending
// edges are the top and right edges.
// According to the spec, y be min(0, max(y, element padding edge height - element scrolling area height)).
// So y is nonpositive and decreases upward.
// This assumes that the horizontal scrollbar
// is on the bottom side and the vertical scrollbar is on the right side.
var target = document.getElementById("target");
var scroller = document.getElementById("scroller");
var scrollbar_width = scroller.offsetWidth - scroller.clientWidth;
var scroller_width = scroller.offsetWidth;
var scroller_height = scroller.offsetHeight;
var box_width = target.offsetWidth;
var box_height = target.offsetHeight;
var expectedX = {
blockStart: box_width,
blockCenter: (3*box_width - scroller_width)/2 + scrollbar_width/2,
blockEnd: 2*box_width - scroller_width + scrollbar_width,
};
var expectedY = {
inlineStart: -box_height,
inlineCenter: -((3*box_height - scroller_height)/2) - scrollbar_width/2,
inlineEnd: -(2*box_height - scroller_height) - scrollbar_width,
};
[
[{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);
target.scrollIntoView(input);
assert_approx_equals(scroller.scrollLeft, expectedX, 0.5, "scrollX");
assert_approx_equals(scroller.scrollTop, expectedY, 0.5, "scrollY");
}, `scrollIntoView(${JSON.stringify(input)})`);
})
</script>
</body>
</html>

View file

@ -0,0 +1,107 @@
<!DOCTYPE html>
<title>CSSOM View - scrollIntoView considers vertical-lr writing mode</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">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
.box {
float: left;
width: 200px;
height: 200px;
}
#scroller {
writing-mode: vertical-lr;
overflow: scroll;
width: 300px;
height: 300px;
}
#container{
width: 600px;
height: 600px;
}
#target {
background-color: #ff0;
}
</style>
<body>
<div id="scroller">
<div id="container">
<!-- ROW-1 -->
<div class="row">
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
</div>
<!-- ROW-2 -->
<div class="row">
<div class="box"></div>
<div class="box" id="target"></div>
<div class="box"></div>
</div>
<!-- ROW-3 -->
<div class="row">
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
</div>
</div>
</div>
<script>
// In vertical-lr mode, X corresponds to the block axis and is oriented
// rightward. Y corresponds to the inline axis and is oriented downward.
// So the beginning edges are the top and left edges and the ending
// edges are the bottom and right edges.
// This assumes that the horizontal scrollbar is on the bottom side and
// the vertical scrollbar is on the right side.
var target = document.getElementById("target");
var scroller = document.getElementById("scroller");
var scrollbar_width = scroller.offsetWidth - scroller.clientWidth;
var scroller_width = scroller.offsetWidth;
var scroller_height = scroller.offsetHeight;
var box_width = target.offsetWidth;
var box_height = target.offsetHeight;
var expectedX = {
blockStart: box_width,
blockCenter: (3*box_width - scroller_width)/2 + (scrollbar_width/2),
blockEnd: (2*box_width) - scroller_width + scrollbar_width,
};
var expectedY = {
inlineStart: box_height,
inlineCenter: ((3*box_height - scroller_height)/2) + (scrollbar_width/2),
inlineEnd: ((2*box_height) - scroller_height) + scrollbar_width,
};
[
[{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);
target.scrollIntoView(input);
assert_approx_equals(scroller.scrollLeft, expectedX, 0.5, "scrollX");
assert_approx_equals(scroller.scrollTop, expectedY, 0.5, "scrollY");
}, `scrollIntoView(${JSON.stringify(input)})`);
})
</script>
</body>
</html>

View file

@ -55,7 +55,11 @@
<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.
// So the beginning edges are the top and right edges and the ending
// edges are the bottom and left edges.
// 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;
@ -102,17 +106,6 @@ if(scroller.scrollLeft === 0) {
};
}
// This formats dict as a string suitable as test name.
// format_value() is provided by testharness.js,
// which also preserves sign for -0.
function format_dict(dict) {
const props = [];
for (let prop in dict) {
props.push(`${prop}: ${format_value(dict[prop])}`);
}
return `{${props.join(", ")}}`;
}
[
[{block: "start", inline: "start"}, expectedX.blockStart, expectedY.inlineStart],
[{block: "start", inline: "center"}, expectedX.blockStart, expectedY.inlineCenter],
@ -129,7 +122,7 @@ function format_dict(dict) {
target.scrollIntoView(input);
assert_approx_equals(scroller.scrollLeft, expectedX, 0.5, "scrollX");
assert_approx_equals(scroller.scrollTop, expectedY, 0.5, "scrollY");
}, `scrollIntoView(${format_dict(input)})`);
}, `scrollIntoView(${JSON.stringify(input)})`);
})
</script>