- Notifications
You must be signed in to change notification settings - Fork 3.3k
/
Copy pathcustom-property-transition-length.html
63 lines (54 loc) · 1.82 KB
/
custom-property-transition-length.html
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
<!DOCTYPE html>
<linkrel="help" href="https://drafts.css-houdini.org/css-properties-values-api-1">
<scriptsrc="/resources/testharness.js"></script>
<scriptsrc="/resources/testharnessreport.js"></script>
<scriptsrc="../resources/utils.js"></script>
<divid="target"></div>
<script>
transition_test({
syntax: "<length>",
from: "100px",
to: "200px",
expected: "150px"
},'A custom property of type <length> can yield a CSS Transition');
// This tests if there is a transition to a random floating-point number.
promise_test(async()=>{
constcustomProperty=generate_name();
CSS.registerProperty({
name: customProperty,
syntax: "<length>",
inherits: false,
initialValue: "100px"
});
assert_equals(
getComputedStyle(target).getPropertyValue(customProperty),
"100px",
"Element has the expected initial value"
);
consttransitionEventPromise=newPromise(resolve=>{
letlistener=event=>{
target.removeEventListener("transitionrun",listener);
assert_equals(
event.propertyName,
customProperty,
"TransitionEvent has the expected property name"
);
resolve();
};
target.addEventListener("transitionrun",listener);
});
target.style.transition=`${customProperty} 1s -500ms linear`;
target.style.setProperty(customProperty,"112.24859px");
constanimations=target.getAnimations();
assert_equals(animations.length,1,"A single animation is running");
consttransition=animations[0];
assert_class_string(
transition,
"CSSTransition",
"A CSSTransition is running"
);
assert_equals(transition.playState,"running","The transition is running");
awaittransitionEventPromise;
},'The to value of a custom property to a random floating-point number can '+
'yield a CSS Transition');
</script>