chromium/third_party/blink/web_tests/fast/css/font-face-src-parsing.html

<!-- Valid src descriptor rules. -->
<style>
@font-face {
    src: url(font.ttf);
}
@font-face {
    src: url(http://foo/bar/font.ttf);
}
@font-face {
    src: url(font.svg#id);
}
@font-face {
    src: url(font.ttf) format("truetype");
}
@font-face {
    src: url(font.woff) format("woff"), local(font2);
}
@font-face {
    src: url(font.ttf) format("truetype"), url(font2.ttf);
}
@font-face {
    src: url(font.ttf), url(font2.ttf) format("truetype");
}
@font-face {
    src: url(font.ttf), local(font2), url(font3.otf) format("opentype"), local(foo bar);
}
@font-face {
    src: local(foo);
}
@font-face {
    src: local(font), local(foo bar);
}
@font-face {
    src: local("foo");
}
@font-face {
    src: local("\"foo\"");
}
@font-face {
    src: local(" foo");
}
@font-face {
    src: local("foo ");
}
@font-face {
    src: local(" foo ");
}
@font-face {
    src: local("foo bar");
}
@font-face {
    src: local('w\\d w');
}
@font-face {
    src: local(' x x\\9 x ');
}
@font-face {
    src: local('y y\\9 y');
}
@font-face {
    src: url(font.ttf),;
}
@font-face {
    src: url(font.ttf), local(font2),;
}
@font-face {
    src: ,local(font);
}
@font-face {
    src: url(font.ttf), invalid();
}
@font-face {
    src: url(foo.ttf), invalid;
}
</style>

<!-- Invalid src descriptor rules. -->
<style>
@font-face {
    src: url(font.ttf invalid);
}
@font-face {
    src: url(foo.ttf) invalid;
}
@font-face {
    src: url(foo.ttf) "invalid";
}
@font-face {
    src: url(foo.ttf) !important;
}
@font-face {
    src: initial;
}
@font-face {
    src: inherit;
}
@font-face {
    src: unset;
}
</style>
<p>Test parsing the src descriptor of @font-face.</p>

<p>Valid rules form the stylesheet:</p>
<div id="validResult"></div>

<p>Expected result for valid rules:</p>
<pre id="validExpected">
@font-face { src: url("font.ttf"); }
@font-face { src: url("http://foo/bar/font.ttf"); }
@font-face { src: url("font.svg#id"); }
@font-face { src: url("font.ttf") format("truetype"); }
@font-face { src: url("font.woff") format("woff"), local("font2"); }
@font-face { src: url("font.ttf") format("truetype"), url("font2.ttf"); }
@font-face { src: url("font.ttf"), url("font2.ttf") format("truetype"); }
@font-face { src: url("font.ttf"), local("font2"), url("font3.otf") format("opentype"), local("foo bar"); }
@font-face { src: url("font3.otf") format("opentype"), local("foo bar"); }
@font-face { src: local("foo"); }
@font-face { src: local("font"), local("foo bar"); }
@font-face { src: local("foo"); }
@font-face { src: local("\"foo\""); }
@font-face { src: local(" foo"); }
@font-face { src: local("foo "); }
@font-face { src: local(" foo "); }
@font-face { src: local("foo bar"); }
@font-face { src: local("w\d w"); }
@font-face { src: local(" x x\9 x "); }
@font-face { src: local("y y\9 y"); }
@font-face { src: url("font.ttf"); }
@font-face { src: url("font.ttf"), local("font2"); }
@font-face { src: local("font"); }
@font-face { src: url("font.ttf"); }
@font-face { src: url("foo.ttf"); }
</pre>

<p>Invalid rules form the stylesheet:</p>
<pre id="invalidResult"></pre>

<p>Expected result for invalid rules:</p>
<pre id="invalidExpected">@font-face { }
@font-face { }
@font-face { }
@font-face { }
@font-face { }
@font-face { }
@font-face { }
@font-face { }
</pre>

<script>
if (window.testRunner)
    testRunner.dumpAsText();

var validRules = document.styleSheets[0].cssRules;
var result = '';
for (var i = 0; i < validRules.length; ++i) {
    var itemText = validRules.item(i).cssText.replace(/file:.*LayoutTests\/fast\/css\//, '');
    result += itemText + '\n';
}
document.getElementById('validResult').innerText = result;

var invalidRules = document.styleSheets[1].cssRules;
result = '';
for (var i = 0; i < invalidRules.length; ++i) {
    var itemText = invalidRules.item(i).cssText.replace(/file:.*LayoutTests\/fast\/css\//, '');
    result += itemText + '\n';
}
document.getElementById('invalidResult').innerText = result;
</script>