mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Update web-platform-tests to revision b'7af9d6ec48ab04043a2bea85a3599904a1a19efa'
This commit is contained in:
parent
8050c95e31
commit
87be1008de
2742 changed files with 142451 additions and 40667 deletions
|
@ -0,0 +1,82 @@
|
|||
<!doctype html>
|
||||
<title>Resnap to focused element after relayout</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<style>
|
||||
|
||||
#snapper {
|
||||
counter-reset: child 0;
|
||||
width: 200px;
|
||||
scroll-snap-type: block mandatory;
|
||||
overflow:hidden;
|
||||
height: 100px;
|
||||
}
|
||||
.child {
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
background:red;
|
||||
text-align: center;
|
||||
box-sizing: border-box;
|
||||
counter-increment: child;
|
||||
float: left;
|
||||
}
|
||||
.child.f {
|
||||
background: green;
|
||||
scroll-snap-align: center;
|
||||
}
|
||||
.child::before {
|
||||
content: counter(child);
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<link rel=author title="Tab Atkins-Bittner" href="https://www.xanthir.com/contact/">
|
||||
<link rel="help" href="https://drafts.csswg.org/css-scroll-snap/#re-snap">
|
||||
<!--
|
||||
When re-snapping after a layout change,
|
||||
if multiple elements were capable of being the snap target previously,
|
||||
and one of them is focused,
|
||||
you must resnap to the focused one.
|
||||
-->
|
||||
<div id=snapper>
|
||||
<div class="child no-snap" tabindex=-1></div>
|
||||
<div class=child></div>
|
||||
<div class="child f" tabindex=-1></div>
|
||||
<div class="child f" tabindex=-1></div>
|
||||
<div class=child></div>
|
||||
<div class=child></div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
|
||||
var container = document.querySelector("#snapper");
|
||||
var [one,two] = document.querySelectorAll(".child.f");
|
||||
var unsnappable = document.querySelector(".child.no-snap");
|
||||
|
||||
async_test(t=>{
|
||||
requestAnimationFrame(()=>{
|
||||
testSnap(t, one, 3);
|
||||
requestAnimationFrame(()=>{
|
||||
testSnap(t, two, 4);
|
||||
requestAnimationFrame(()=>{
|
||||
testSnap(t, one, 3);
|
||||
t.done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function testSnap(t, child, expectedRow) {
|
||||
t.step(()=>{
|
||||
unsnappable.focus();
|
||||
container.style.width = "200px";
|
||||
var startingRow = container.scrollTop/100 + 1;
|
||||
assert_equals(startingRow, 2, "Initially snapped to row 2");
|
||||
child.focus();
|
||||
container.style.width = "100px";
|
||||
var endingRow = container.scrollTop/100 + 1;
|
||||
assert_equals(endingRow, expectedRow, `After resize, should snap to row ${expectedRow}.`);
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
|
@ -3,6 +3,10 @@
|
|||
<title>Tests that window should snap at user scroll end.</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/resources/testdriver.js"></script>
|
||||
<script src="/resources/testdriver-actions.js"></script>
|
||||
<script src="/resources/testdriver-vendor.js"></script>
|
||||
<script src="support/common.js"></script>
|
||||
<style>
|
||||
html {
|
||||
margin: 0px;
|
||||
|
@ -55,6 +59,9 @@ var scrolled_x = false;
|
|||
var scrolled_y = false;
|
||||
var start_x = window.scrollX;
|
||||
var start_y = window.scrollY;
|
||||
var actions_promise;
|
||||
|
||||
scrollTop = () => window.scrollY;
|
||||
|
||||
window.onscroll = function() {
|
||||
if (scrolled_x && scrolled_y) {
|
||||
|
@ -84,7 +91,21 @@ button.onclick = function() {
|
|||
// To make the test result visible.
|
||||
var content = document.getElementById("content");
|
||||
body.removeChild(content);
|
||||
snap_test.done();
|
||||
actions_promise.then( () => {
|
||||
snap_test.done();
|
||||
});
|
||||
}
|
||||
|
||||
// Inject scroll actions.
|
||||
const pos_x = 20;
|
||||
const pos_y = 20;
|
||||
const scroll_delta_x = 100;
|
||||
const scroll_delta_y = 100;
|
||||
actions_promise = new test_driver.Actions()
|
||||
.scroll(pos_x, pos_y, scroll_delta_x, scroll_delta_y)
|
||||
.send().then(() => {
|
||||
return waitForAnimationEnd(scrollTop);
|
||||
}).then(() => {
|
||||
return test_driver.click(button);
|
||||
});
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue