|
| 1 | +<!DOCTYPE html> |
| 2 | +<html> |
| 3 | +<head> |
| 4 | +<meta charset="utf-8"> |
| 5 | +<title>CSS Variables: perspective-origin with var() references</title> |
| 6 | +<link rel="help" href="https://drafts.csswg.org/css-transforms-2/#perspective-origin-property"> |
| 7 | +<link rel="help" href="https://drafts.csswg.org/css-variables-2/"> |
| 8 | +<meta name="assert" content="perspective-origin correctly resolves CSS variables in both value positions"> |
| 9 | +<script src="/resources/testharness.js"></script> |
| 10 | +<script src="/resources/testharnessreport.js"></script> |
| 11 | +<style> |
| 12 | + .target { |
| 13 | + width: 200px; |
| 14 | + height: 200px; |
| 15 | + perspective: 800px; |
| 16 | + } |
| 17 | +</style> |
| 18 | +</head> |
| 19 | +<body> |
| 20 | +<script> |
| 21 | +function test_perspective_origin_var(style, expected, description) { |
| 22 | + test(() => { |
| 23 | + const div = document.createElement('div'); |
| 24 | + div.className = 'target'; |
| 25 | + div.setAttribute('style', style); |
| 26 | + document.body.appendChild(div); |
| 27 | + assert_equals(getComputedStyle(div).perspectiveOrigin, expected); |
| 28 | + div.remove(); |
| 29 | + }, description); |
| 30 | +} |
| 31 | + |
| 32 | +test_perspective_origin_var( |
| 33 | + '--x: 0%; perspective-origin: var(--x) 50%', |
| 34 | + '0px 100px', |
| 35 | + 'var() as first value of perspective-origin' |
| 36 | +); |
| 37 | + |
| 38 | +test_perspective_origin_var( |
| 39 | + '--y: 0%; perspective-origin: 50% var(--y)', |
| 40 | + '100px 0px', |
| 41 | + 'var() as second value of perspective-origin' |
| 42 | +); |
| 43 | + |
| 44 | +test_perspective_origin_var( |
| 45 | + '--x: 10%; --y: 20%; perspective-origin: var(--x) var(--y)', |
| 46 | + '20px 40px', |
| 47 | + 'var() as both values of perspective-origin' |
| 48 | +); |
| 49 | + |
| 50 | +test_perspective_origin_var( |
| 51 | + '--pos: 25%; perspective-origin: var(--pos) var(--pos)', |
| 52 | + '50px 50px', |
| 53 | + 'same var() for both values of perspective-origin' |
| 54 | +); |
| 55 | + |
| 56 | +test_perspective_origin_var( |
| 57 | + '--y: top; perspective-origin: 50% var(--y)', |
| 58 | + '100px 0px', |
| 59 | + 'var() as second value with keyword' |
| 60 | +); |
| 61 | + |
| 62 | +test_perspective_origin_var( |
| 63 | + '--x: left; perspective-origin: var(--x) 50%', |
| 64 | + '0px 100px', |
| 65 | + 'var() as first value with keyword' |
| 66 | +); |
| 67 | +</script> |
| 68 | +</body> |
| 69 | +</html> |
0 commit comments