1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
|
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title> CSS Scroll Snap 2 Test: scroll-start-* computed values</title>
<link rel="help" href="https://drafts.csswg.org/css-scroll-snap-2/#scroll-start">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/css/support/computed-testcommon.js"></script>
</head>
<body>
<div id="target"></div>
<script>
test_computed_value("scroll-start", "start");
test_computed_value("scroll-start", "start start", "start");
test_computed_value("scroll-start", "100px");
test_computed_value("scroll-start", "50%");
test_computed_value("scroll-start", "center");
test_computed_value("scroll-start", "100px 200px");
test_computed_value("scroll-start", "50% 100px");
test_computed_value("scroll-start", "start 50%");
test_computed_value("scroll-start", "center start", "center");
test_computed_value("scroll-start", "end center");
test_computed_value("scroll-start", "top end");
test_computed_value("scroll-start", "bottom top");
test_computed_value("scroll-start", "left bottom");
test_computed_value("scroll-start", "right left");
test_computed_value("scroll-start", "auto right");
test_computed_value("scroll-start", "calc(1px)", "1px")
test_computed_value("scroll-start", "calc(1px) start", "1px")
test_computed_value("scroll-start-block", "100px");
test_computed_value("scroll-start-block", "50%");
test_computed_value("scroll-start-block", "start");
test_computed_value("scroll-start-block", "center");
test_computed_value("scroll-start-block", "end");
test_computed_value("scroll-start-block", "top");
test_computed_value("scroll-start-block", "bottom");
test_computed_value("scroll-start-block", "left");
test_computed_value("scroll-start-block", "right");
test_computed_value("scroll-start-block", "auto");
test_computed_value("scroll-start-block", "calc(-1px)", "0px");
test_computed_value("scroll-start-inline", "100px");
test_computed_value("scroll-start-inline", "50%");
test_computed_value("scroll-start-inline", "start");
test_computed_value("scroll-start-inline", "center");
test_computed_value("scroll-start-inline", "end");
test_computed_value("scroll-start-inline", "top");
test_computed_value("scroll-start-inline", "bottom");
test_computed_value("scroll-start-inline", "left");
test_computed_value("scroll-start-inline", "right");
test_computed_value("scroll-start-inline", "auto");
test_computed_value("scroll-start-inline", "calc(-1px)", "0px");
test_computed_value("scroll-start-x", "100px");
test_computed_value("scroll-start-x", "50%");
test_computed_value("scroll-start-x", "start");
test_computed_value("scroll-start-x", "center");
test_computed_value("scroll-start-x", "end");
test_computed_value("scroll-start-x", "top");
test_computed_value("scroll-start-x", "bottom");
test_computed_value("scroll-start-x", "left");
test_computed_value("scroll-start-x", "right");
test_computed_value("scroll-start-x", "auto");
test_computed_value("scroll-start-x", "calc(-1px)", "0px");
test_computed_value("scroll-start-y", "100px");
test_computed_value("scroll-start-y", "50%");
test_computed_value("scroll-start-y", "start");
test_computed_value("scroll-start-y", "center");
test_computed_value("scroll-start-y", "end");
test_computed_value("scroll-start-y", "top");
test_computed_value("scroll-start-y", "bottom");
test_computed_value("scroll-start-y", "left");
test_computed_value("scroll-start-y", "right");
test_computed_value("scroll-start-y", "auto");
test_computed_value("scroll-start-y", "calc(-1px)", "0px");
target.style = "";
// Test logical-physical mapping.
test((t) => {
t.add_cleanup(() => { target.style = ""; });
target.style.scrollStartBlock = "100px";
assert_equals(getComputedStyle(target).scrollStartX, "auto");
assert_equals(getComputedStyle(target).scrollStartY, "100px");
}, "scroll-start-block maps to scroll-start-y in horizontal writing mode.");
test((t) => {
t.add_cleanup(() => { target.style = ""; });
target.style.scrollStartInline = "200px";
assert_equals(getComputedStyle(target).scrollStartX, "200px");
assert_equals(getComputedStyle(target).scrollStartY, "auto");
}, "scroll-start-inline maps to scroll-start-x in horizontal writing mode.");
test((t) => {
t.add_cleanup(() => { target.style = ""; });
target.style.scrollStartX = "100px";
assert_equals(getComputedStyle(target).scrollStartBlock, "auto");
assert_equals(getComputedStyle(target).scrollStartInline, "100px");
}, "scroll-start-x maps to scroll-start-inline in horizontal writing mode.");
test((t) => {
t.add_cleanup(() => { target.style = ""; });
target.style.scrollStartY = "200px";
assert_equals(getComputedStyle(target).scrollStartBlock, "200px");
assert_equals(getComputedStyle(target).scrollStartInline, "auto");
}, "scroll-start-y maps to scroll-start-block in horizontal writing mode.");
test((t) => {
t.add_cleanup(() => { target.style = ""; });
target.style.scrollStartBlock = "100px";
target.style.writingMode = "vertical-lr";
assert_equals(getComputedStyle(target).scrollStartX, "100px");
assert_equals(getComputedStyle(target).scrollStartY, "auto");
}, "scroll-start-block maps to scroll-start-x in vertical writing mode.");
test((t) => {
t.add_cleanup(() => { target.style = ""; });
target.style.scrollStartInline = "200px";
target.style.writingMode = "vertical-lr";
assert_equals(getComputedStyle(target).scrollStartX, "auto");
assert_equals(getComputedStyle(target).scrollStartY, "200px");
}, "scroll-start-inline maps to scroll-start-y in vertical writing mode.");
test((t) => {
t.add_cleanup(() => { target.style = ""; });
target.style.scrollStartX = "100px";
target.style.writingMode = "vertical-lr";
assert_equals(getComputedStyle(target).scrollStartBlock, "100px");
assert_equals(getComputedStyle(target).scrollStartInline, "auto");
}, "scroll-start-x maps to scroll-start-block in vertical writing mode.");
test((t) => {
t.add_cleanup(() => { target.style = ""; });
target.style.scrollStartY = "200px";
target.style.writingMode = "vertical-lr";
assert_equals(getComputedStyle(target).scrollStartBlock, "auto");
assert_equals(getComputedStyle(target).scrollStartInline, "200px");
}, "scroll-start-y maps to scroll-start-inline in vertical writing mode.");
</script>
</body>
</html>
|