forked from WebKit/WebKit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcrash.html
63 lines (57 loc) · 2.88 KB
/
crash.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><!-- webkit-test-runner [ CSSCustomPropertiesAndValuesEnabled=true ] -->
<!-- https://chromium.googlesource.com/chromium/src/+/01ce431409e3a019858677626a983c55168da6dc/third_party/WebKit/LayoutTests/custom-properties/register-property.html -->
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<style>
#test1 {
font-size: var(--foo, 30px);
--foo: var(--bar, 20px);
--bar: var(--baz, var(--foo));
}
</style>
<div>
<h2 id=test1>This is text</h2>
</div>
<script>
var computedStyle = getComputedStyle(test1);
var inlineStyle = test1.style;
test(function() {
assert_equals(computedStyle.getPropertyValue('--baz'), '');
assert_equals(computedStyle.getPropertyValue('--foo'), '');
assert_equals(computedStyle.getPropertyValue('--bar'), '');
assert_equals(computedStyle.getPropertyValue('font-size'), '30px');
}, "Fallback is handled correctly, and we don't crash");
test(function() {
inlineStyle.setProperty('--baz', ' 40px');
assert_equals(computedStyle.getPropertyValue('--baz'), ' 40px');
assert_equals(computedStyle.getPropertyValue('--foo'), '');
assert_equals(computedStyle.getPropertyValue('--bar'), '');
assert_equals(computedStyle.getPropertyValue('--baz'), ' 40px');
assert_equals(computedStyle.getPropertyValue('font-size'), '30px');
inlineStyle.removeProperty('--baz');
assert_equals(computedStyle.getPropertyValue('--baz'), '');
assert_equals(computedStyle.getPropertyValue('--foo'), '');
assert_equals(computedStyle.getPropertyValue('--bar'), '');
assert_equals(computedStyle.getPropertyValue('font-size'), '30px');
assert_equals(computedStyle.getPropertyValue('--baz'), '');
}, "Setting the inline style is handled correctly");
test(function() {
CSS.registerProperty({name: '--foo', syntax: '<length>', initialValue: '200px', inherits: true});
CSS.registerProperty({name: '--bar', syntax: '<length>', initialValue: '200px', inherits: true});
CSS.registerProperty({name: '--baz', syntax: '<length>', initialValue: '200px', inherits: true});
}, "CSS.registerProperty");
test(function() {
inlineStyle.setProperty('--baz', ' 40px');
assert_equals(computedStyle.getPropertyValue('--baz'), '40px');
assert_equals(computedStyle.getPropertyValue('--foo'), '');
assert_equals(computedStyle.getPropertyValue('--bar'), '');
assert_equals(computedStyle.getPropertyValue('--baz'), '40px');
assert_equals(computedStyle.getPropertyValue('font-size'), '30px');
inlineStyle.removeProperty('--baz');
assert_equals(computedStyle.getPropertyValue('--baz'), '200px');
assert_equals(computedStyle.getPropertyValue('--foo'), '');
assert_equals(computedStyle.getPropertyValue('--bar'), '');
assert_equals(computedStyle.getPropertyValue('font-size'), '30px');
assert_equals(computedStyle.getPropertyValue('--baz'), '200px');
}, "Setting the inline style is handled correctly when registered");
</script>