blob: 55b891c1e48bdf4b62603690cd163482f2e7ba17 [file] [log] [blame] [edit]
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Infinity and NaN: calc() computed value.</title>
<link rel="author" title="Seokho Song" href="mailto:0xdevssh@gmail.com">
<link rel="help" href="https://drafts.csswg.org/css-values/#calc-type-checking">
<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>
const APPROX_INFINITY = 3.35544e+07;
const APPROX_NEGATIVE_INFINITY = -APPROX_INFINITY;
// For <length>
testComputedValueGreaterOrLowerThan("width", "calc(NaN * 1px)", APPROX_INFINITY);
testComputedValueGreaterOrLowerThan("width", "calc(infinity * 1px)", APPROX_INFINITY);
testComputedValueGreaterOrLowerThan("width", "calc(infinity * 1cm)", APPROX_INFINITY);
testComputedValueGreaterOrLowerThan("width", "calc(NaN * 1rem)", APPROX_INFINITY);
testComputedValueGreaterOrLowerThan("width", "calc(infinity * 1px - infinity * 1%)", APPROX_INFINITY);
testComputedValueGreaterOrLowerThan("width", "calc(infinity * 1px + infinity * 1%)", APPROX_INFINITY);
testComputedValueGreaterOrLowerThan("width", "calc(min(NaN * 1px, infinity * 1px) + max(infinity * 1px, -infinity * 1px))", APPROX_INFINITY);
testComputedValueGreaterOrLowerThan("width", "calc(infinity * 1px - max(infinity * 1%, 0%))", APPROX_INFINITY);
testComputedValueGreaterOrLowerThan("width", "calc(max(infinity * 1px, 10px))", APPROX_INFINITY);
testComputedValueGreaterOrLowerThan("margin-left", "calc(-infinity * 1px)", APPROX_NEGATIVE_INFINITY);
testComputedValueGreaterOrLowerThan("margin-left", "calc(min(1px, -infinity * 1%))", APPROX_NEGATIVE_INFINITY);
testComputedValueGreaterOrLowerThan("margin-left", "calc(-infinity * 1%)", APPROX_NEGATIVE_INFINITY);
testComputedValueGreaterOrLowerThan("margin-left", "calc(max(10000px, 0px) + min(-infinity * 1px, infinity * 1px))", APPROX_NEGATIVE_INFINITY);
testComputedValueGreaterOrLowerThan("margin-left", "calc(-infinity * 1px - infinity * 1px)", APPROX_NEGATIVE_INFINITY);
testComputedValueGreaterOrLowerThan("margin-left", "calc(min(-infinity * 1px, 10px))", APPROX_NEGATIVE_INFINITY);
// For <time>
testComputedValueGreaterOrLowerThan("animation-duration", "calc(NaN * 1s)", APPROX_INFINITY);
testComputedValueGreaterOrLowerThan("animation-duration", "calc(infinity * 1s)", APPROX_INFINITY);
testComputedValueGreaterOrLowerThan("animation-duration", "calc(1 / 0 * 1s)", APPROX_INFINITY);
testComputedValueGreaterOrLowerThan("animation-duration", "calc(max(infinity * 1s, 10s)", APPROX_INFINITY);
testComputedValueGreaterOrLowerThan("transition-delay", "calc(-infinity* 1s)", APPROX_NEGATIVE_INFINITY);
testComputedValueGreaterOrLowerThan("transition-delay", "calc(max(10000s, 0s) + min(-infinity * 1s, infinity * 1s))", APPROX_NEGATIVE_INFINITY);
testComputedValueGreaterOrLowerThan("transition-delay", "calc(min(-infinity * 1s, 10s))", APPROX_NEGATIVE_INFINITY);
// For <angle>
testTransformValuesCloseTo("rotate(calc(infinity * 1deg))", 0.0001, "rotate(0deg)");
testTransformValuesCloseTo("rotate(calc(-infinity * 1deg))", 0.0001, "rotate(0deg)");
testTransformValuesCloseTo("rotate(calc(NaN * 1deg))", 0.0001, "rotate(0deg)");
testTransformValuesCloseTo("rotate(calc(infinity * 1turn))", 0.0001, "rotate(0turn)");
testTransformValuesCloseTo("rotate(calc(-infinity * 1turn))", 0.0001, "rotate(0turn)");
testTransformValuesCloseTo("rotate(calc(NaN * 1turn))", 0.0001, "rotate(0turn)");
testTransformValuesCloseTo("rotate(calc(infinity * 1rad))", 0.0001, "rotate(0rad)");
testTransformValuesCloseTo("rotate(calc(-infinity * 1rad))", 0.0001, "rotate(0rad)");
testTransformValuesCloseTo("rotate(calc(NaN * 1rad))", 0.0001, "rotate(0rad)");
testTransformValuesCloseTo("rotate(calc(infinity * 1grad))", 0.0001, "rotate(0grad)");
testTransformValuesCloseTo("rotate(calc(-infinity * 1grad))", 0.0001, "rotate(0grad)");
testTransformValuesCloseTo("rotate(calc(NaN * 1grad))", 0.0001, "rotate(0grad)");
</script>
</body>
</html>