fontfaceset-add-css-connected.html (1055B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <link rel="author" title="Myles C. Maxfield" href="mmaxfield@apple.com"> 4 <link rel="help" href="https://drafts.csswg.org/css-font-loading-3/#dom-fontfaceset-add"> 5 <meta name="assert" content="Ensure that calling add() with a CSS-connected FontFace throws." /> 6 <script src="/resources/testharness.js"></script> 7 <script src="/resources/testharnessreport.js"></script> 8 <style> 9 @font-face { 10 font-family: "WebFont"; 11 src: url("resources/Rochester.otf") format("opentype"); 12 } 13 </style> 14 <script> 15 test(function(t) { 16 let font = document.fonts.keys().next().value; 17 let fontFaceSet = new FontFaceSet([]); 18 assert_equals(fontFaceSet.size, 0); 19 assert_throws_dom("InvalidModificationError", function() { fontFaceSet.add(font); }); 20 assert_equals(fontFaceSet.size, 0); 21 let newFont = new FontFace("MyFont", "url('resources/Rochester.otf')"); 22 fontFaceSet.add(newFont); 23 assert_equals(fontFaceSet.size, 1); 24 fontFaceSet.add(newFont); 25 assert_equals(fontFaceSet.size, 1); 26 }); 27 </script> 28 </html>