Update web-platform-tests to revision e426a6933a05bf144eba06a1d4c47ba876a4e2d1

This commit is contained in:
WPT Sync Bot 2019-05-22 10:24:35 +00:00
parent 415b26e4f1
commit 5e5eccabf8
495 changed files with 14920 additions and 784 deletions

View file

@ -0,0 +1,60 @@
<!DOCTYPE html>
<link rel="help" href="https://drafts.csswg.org/css-scroll-snap-1/#valdef-scroll-snap-type-mandatory" />
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
div {
position: absolute;
margin: 0px;
}
#scroller {
height: 500px;
width: 500px;
overflow: hidden;
}
.child {
width: 300px;
height: 300px;
background-color: blue;
}
</style>
<div id="scroller">
<div class="child" style="top: 0px; left: 0px;"></div>
<div class="child" style="top: 1000px; left: 1000px;"></div>
<div style="width: 2000px; height: 2000px;"></div>
</div>
<script>
test(() => {
scroller.scrollSnapType = "both mandatory";
// Scroll to where the first child is in view.
scroller.scrollTo(100, 100);
assert_equals(scroller.scrollLeft, 100);
assert_equals(scroller.scrollTop, 100);
// Scroll to where the second child is in view.
scroller.scrollTo(900, 900);
assert_equals(scroller.scrollLeft, 900);
assert_equals(scroller.scrollTop, 900);
}, "No snapping occurs if there is no valid snap position");
test(() => {
scroller.scrollSnapType = "x mandatory";
for (const target of document.querySelectorAll(".child")) {
target.scrollSnapAlign = "start none";
}
// Scroll to where the first child is in view.
scroller.scrollTo(100, 100);
assert_equals(scroller.scrollLeft, 100);
assert_equals(scroller.scrollTop, 100);
// Scroll to where the second child is in view.
scroller.scrollTo(900, 900);
assert_equals(scroller.scrollLeft, 900);
assert_equals(scroller.scrollTop, 900);
}, "No snapping occurs if there is no valid snap position matches scroll-snap-type");
</script>

View file

@ -0,0 +1,73 @@
<!DOCTYPE html>
<link rel="help" href="https://drafts.csswg.org/css-scroll-snap-1/#scroll-margin" />
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
div {
position: absolute;
margin: 0px;
}
#scroller {
height: 500px;
width: 500px;
overflow: hidden;
scroll-snap-type: both mandatory;
}
#target {
width: 300px;
height: 300px;
background-color: blue;
}
#another-target {
width: 300px;
height: 300px;
top: 400px;
left: 400px;
background-color: blue;
scroll-snap-align: start;
}
</style>
<div id="scroller">
<div style="width: 2000px; height: 2000px;"></div>
<div id="target"></div>
<div id="another-target"></div>
</div>
<script>
test(() => {
target.style.scrollSnapAlign = "start";
target.style.scrollMargin = "100px";
target.style.left = "300px";
target.style.top = "300px";
scroller.scrollTo(0, 0);
// `target position (300px, 300px)` - `margin (100px, 100px)`.
assert_equals(scroller.scrollLeft, 200);
assert_equals(scroller.scrollTop, 200);
target.style.scrollSnapAlign = "end";
// `target position (300px, 300px)` + `target size (300px, 300px) +
// `margin (100px, 100px) - `scroller size (500px, 500px)`.
scroller.scrollTo(0, 0);
assert_equals(scroller.scrollLeft, 200);
assert_equals(scroller.scrollTop, 200);
}, "Snaps to the positions adjusted by scroll-margin");
test(() => {
target.style.left = "0px";
target.style.top = "0px";
target.style.scrollSnapAlign = "start";
target.style.scrollMargin = "100px";
// Scroll to the position between #target and #another-target elements but
// if the scroll-margin 100px contributed to the snap start-aligned snap
// position it will be farther than #another-target.
scroller.scrollTo(200, 200);
assert_equals(scroller.scrollLeft, 0);
assert_equals(scroller.scrollTop, 0);
}, "scroll-margin doesn't contribute to the snap position of the element " +
"if it's outside of the scroll port");
</script>

View file

@ -44,8 +44,10 @@ const scroller_height = scroller.clientHeight;
target.style.scrollSnapAlign = "end start";
if (writing_mode == "vertical-rl") {
target.style.left = (scroller_width - 700) + "px";
scroller.scrollTo(-500, 0);
} else {
scroller.scrollTo(0, 0);
}
scroller.scrollTo(0, 0);
assert_equals(scroller.scrollLeft, left, "aligns correctly on x");
assert_equals(scroller.scrollTop, top, "aligns correctly on y");
target.style.left = target_left;
@ -65,8 +67,10 @@ const scroller_height = scroller.clientHeight;
target.style.scrollSnapAlign = "start end";
if (writing_mode == "vertical-rl") {
target.style.left = (scroller_width - 700) + "px";
scroller.scrollTo(-500, 0);
} else {
scroller.scrollTo(0, 0);
}
scroller.scrollTo(0, 0);
assert_equals(scroller.scrollLeft, left, "aligns correctly on x");
assert_equals(scroller.scrollTop, top, "aligns correctly on y");
target.style.left = target_left;
@ -81,7 +85,7 @@ test(() => {
target.style.scrollSnapAlign = "end start";
target.style.left = (scroller_width - 700) + "px";
scroller.scrollTo(0, 0);
scroller.scrollTo(-500, 0);
assert_equals(scroller.scrollLeft, target.clientWidth - 700,
"aligns correctly on x");
assert_equals(scroller.scrollTop, 500 - scroller_height,
@ -98,7 +102,7 @@ test(() => {
target.style.scrollSnapAlign = "start end";
target.style.left = (scroller_width - 700) + "px";
scroller.scrollTo(0, 0);
scroller.scrollTo(-500, 0);
assert_equals(scroller.scrollLeft, scroller_width - 700,
"aligns correctly on x");
assert_equals(scroller.scrollTop, 300, "aligns correctly on y");