summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-fonts/animations/font-style-interpolation.html
blob: 4666025d545860405b62a2571a0b74e3a2a06d8a (plain)
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
<!DOCTYPE html>
<meta charset="UTF-8">
<title>font-style interpolation</title>
<link rel="help" href="https://drafts.csswg.org/css-fonts-3/#propdef-font-style">
<meta name="assert" content="Font-style should be animated smoothly.">

<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/css/support/interpolation-testcommon.js"></script>

<style>
.container {
  font-style: oblique 20deg;
}
.container2 {
  font-style: oblique 5deg;
}
.target {
  display: inline-block;
  font: 100px sans-serif;
  font-style: normal;
}
.expected {
  color: green;
  margin-right: 30px;
}
</style>

<body>
<template id="target-template">
  <span class="container">
    <div class="target">TT</div>
  </span>
</template>

<span id="inv-container" class="container">
  <div id="inv-target" class="target">TT</div>
</span>
</body>

<script>
test_interpolation({
  property: 'font-style',
  from: 'normal',
  to: 'oblique 10deg'
}, [
  {at: -2, expect: 'oblique -20deg'},
  {at: -0.25, expect: 'oblique -2.5deg'},
  {at: 0, expect: 'normal'},
  {at: 0.3, expect: 'oblique 3deg'},
  {at: 0.6, expect: 'oblique 6deg'},
  {at: 1, expect: 'oblique 10deg'},
  {at: 1.5, expect: 'oblique 15deg'},
]);

test_interpolation({
  property: 'font-style',
  from: 'oblique 5deg',
  to: 'oblique 15deg'
}, [
  { at: -2, expect: 'oblique -15deg' },
  { at: -0.25, expect: 'oblique 2.5deg' },
  { at: 0, expect: 'oblique 5deg' },
  { at: 0.3, expect: 'oblique 8deg' },
  { at: 0.6, expect: 'oblique 11deg' },
  { at: 1, expect: 'oblique 15deg' },
  { at: 1.5, expect: 'oblique 20deg' },
]);

test_interpolation({
  property: 'font-style',
  from: 'initial',
  to: 'inherit'
}, [
  { at: -2, expect: 'oblique -40deg' },
  { at: -0.25, expect: 'oblique -5deg' },
  { at: 0, expect: 'normal' },
  { at: 0.3, expect: 'oblique 6deg' },
  { at: 0.6, expect: 'oblique 12deg' },
  { at: 1, expect: 'oblique 20deg' },
  { at: 1.5, expect: 'oblique 30deg' },
]);

test_interpolation({
  property: 'font-style',
  from: 'oblique 20deg',
  to: 'normal'
}, [
  { at: -1, expect: 'oblique 40deg' },
  { at: 0, expect: 'oblique 20deg' },
  { at: 0.5, expect: 'oblique 10deg' },
  { at: 1, expect: 'normal' },
  { at: 1.5, expect: 'oblique -10deg' },
]);

test_interpolation({
  property: 'font-style',
  from: 'oblique -90deg',
  to: 'oblique 90deg'
}, [
  { at: -2, expect: 'oblique -90deg' },
  { at: -1, expect: 'oblique -90deg' },
  { at: 0, expect: 'oblique -90deg' },
  { at: 0.5, expect: 'normal' },
  { at: 1, expect: 'oblique 90deg' },
  { at: 1.5, expect: 'oblique 90deg' },
]);

test(t => {
  var container = document.getElementById('inv-container');
  var target = document.getElementById('inv-target');
  var anim = target.animate({ fontStyle: ['normal', 'inherit'] }, 1000);
  anim.pause();
  anim.currentTime = 500;
  assert_equals(getComputedStyle(target).fontStyle, 'oblique 10deg');

  container.setAttribute('class', 'container2');
  assert_equals(getComputedStyle(target).fontStyle, 'oblique 2.5deg');
}, "An interpolation to inherit updates correctly on a parent style change.");

</script>