-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Expand file tree
/
Copy pathurl-request-modifiers-font-face-parsing.html
More file actions
63 lines (55 loc) · 1.92 KB
/
url-request-modifiers-font-face-parsing.html
File metadata and controls
63 lines (55 loc) · 1.92 KB
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>
<title>Request URL Modifiers: @font-face src parsing</title>
<link rel="help" href="https://drafts.csswg.org/css-values-5/#request-url-modifiers">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
function test_font_face_src(description, src, valid) {
test(t => {
const style = document.createElement("style");
style.textContent = `@font-face { font-family: "Test"; src: ${src}; }`;
document.head.appendChild(style);
t.add_cleanup(() => style.remove());
const rule = style.sheet.cssRules[0];
if (valid) {
assert_not_equals(rule.style.getPropertyValue("src"), "", "should be valid");
} else {
assert_equals(rule.style.getPropertyValue("src"), "", "should be invalid");
}
}, description);
}
// Valid modifiers in @font-face src
test_font_face_src(
"cross-origin(anonymous) in @font-face src",
'url("fonts/Ahem.ttf" cross-origin(anonymous))',
true);
test_font_face_src(
"referrer-policy(no-referrer) in @font-face src",
'url("fonts/Ahem.ttf" referrer-policy(no-referrer))',
true);
test_font_face_src(
"integrity() in @font-face src",
'url("fonts/Ahem.ttf" integrity("sha384-foobar"))',
true);
test_font_face_src(
"multiple modifiers in @font-face src",
'url("fonts/Ahem.ttf" cross-origin(anonymous) referrer-policy(no-referrer))',
true);
test_font_face_src(
"modifiers with format() in @font-face src",
'url("fonts/Ahem.ttf" cross-origin(anonymous)) format("truetype")',
true);
test_font_face_src(
"unknown modifier in @font-face src",
'url("fonts/Ahem.ttf" foobar(baz))',
true);
// Invalid modifiers
test_font_face_src(
"duplicate cross-origin in @font-face src",
'url("fonts/Ahem.ttf" cross-origin(anonymous) cross-origin(anonymous))',
false);
test_font_face_src(
"duplicate unknown modifier in @font-face src",
'url("fonts/Ahem.ttf" foobar(baz) foobar(qux))',
false);
</script>