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
|
<!DOCTYPE html>
<title>CSS Fonts Module Level 4: parsing @font-face src:local()</title>
<link rel="help" href="https://drafts.csswg.org/css-fonts-4/#local-font-fallback">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style id="testStyle">
</style>
<script>
const sheet = testStyle.sheet;
tests = [
// Unquoted collapsing space
{ src:'local( A )', valid:true },
{ src:'local(A B)', valid:true },
{ src:'local(A B)', valid:true },
{ src:'local( A B )', valid:true },
// Unquoted local() with invalid CSS-wide keywords excluded from <custom-ident>
{ src:'local(default)', valid:false },
{ src:'local(inherit)', valid:false },
{ src:'local(revert)', valid:false },
{ src:'local(unset)', valid:false },
// Unquoted local() with CSS-wide keywords as part of the name
{ src:'local(default A)', valid:true },
{ src:'local(inherit A)', valid:true },
{ src:'local(revert A)', valid:true },
{ src:'local(unset A)', valid:true },
// Quoted local() with CSS-wide keywords
{ src:'local("default")', valid:true },
{ src:'local("inherit")', valid:true },
{ src:'local("revert")', valid:true },
{ src:'local("unset")', valid:true }
];
for (let t of tests) {
test(() => {
assert_equals(sheet.cssRules.length, 0, "testSheet should initially be empty");
sheet.insertRule("@font-face { src: " + t.src + "}");
assert_equals(sheet.cssRules[0].style.getPropertyValue("src") != "", t.valid);
sheet.deleteRule(0);
}, "Check that src: " + t.src + " is " + (t.valid ? "valid" : "invalid"));
}
</script>
|