Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test gets skipped with pattern: os == 'android'
- Manifest: layout/inspector/tests/chrome/chrome.toml
<?xml version="1.0"?>
<window title="CSSGeneric attribute of InspectorFontFace"
onload="RunTest();">
<script type="application/javascript">
<![CDATA[
SimpleTest.waitForExplicitFinish();
function RunTest() {
var rng = document.createRange();
var elem, fonts;
elem = document.getElementById("test1");
rng.selectNode(elem);
fonts = InspectorUtils.getUsedFontFaces(rng);
is(fonts.length, 1, "one font found");
is(fonts[0].CSSGeneric, "serif", "font " + fonts[0].name + " was specified as CSS generic");
var serifFamily = fonts[0].CSSFamilyName;
elem = document.getElementById("test2");
elem.style.fontFamily = serifFamily + ", serif";
rng.selectNode(elem);
fonts = InspectorUtils.getUsedFontFaces(rng);
is(fonts.length, 1, "one font found");
is(fonts[0].CSSFamilyName, serifFamily, "used the expected family (" + serifFamily + ")");
is(fonts[0].CSSGeneric, "", "font " + fonts[0].name + " was specified by name");
elem = document.getElementById("test3");
elem.getElementsByTagName("span")[0].style.fontFamily = serifFamily + ", serif";
rng.selectNode(elem);
fonts = InspectorUtils.getUsedFontFaces(rng);
is(fonts.length, 2, "two fonts found");
var checked = 0;
fonts.forEach(function(f) {
if (f.CSSFamilyName == serifFamily) {
is(f.CSSGeneric, "", "serif font " + f.name + " was specified by name");
checked++;
} else {
is(f.CSSGeneric, "monospace", "monospace font " + f.name + " was specified as generic");
checked++;
}
});
is(checked, 2, "two fonts checked");
SimpleTest.finish();
}
]]>
</script>
<!-- html:body contains elements the test will inspect -->
<div id="test1" style="font-family: serif">test one</div>
<div id="test2" style="font-family: monospace">test two</div>
<div id="test3" style="font-family: monospace">test <span>three</span></div>
</body>
</window>