<!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>