From: <rb...@us...> - 2018-05-15 09:27:49
|
Revision: 15262 http://sourceforge.net/p/htmlunit/code/15262 Author: rbri Date: 2018-05-15 09:27:45 +0000 (Tue, 15 May 2018) Log Message: ----------- implement FontFaceSet.load Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/FontFaceSet.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/FontFaceSetTest.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/FontFaceSet.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/FontFaceSet.java 2018-05-14 14:27:42 UTC (rev 15261) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/FontFaceSet.java 2018-05-15 09:27:45 UTC (rev 15262) @@ -19,6 +19,7 @@ import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClass; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxConstructor; +import com.gargoylesoftware.htmlunit.javascript.configuration.JsxFunction; import com.gargoylesoftware.htmlunit.javascript.host.event.EventTarget; /** @@ -37,4 +38,17 @@ @JsxConstructor public FontFaceSet() { } + + /** + * @param font a font specification using the CSS value syntax, e.g. "italic bold 16px Roboto" + * @param text limit the font faces to those whose Unicode range contains at least one + * of the characters in text. This does not check for individual glyph coverage. + * @return a Promise of an Array of FontFace loaded. The promise is fulfilled + * when all the fonts are loaded; it is rejected if one of the fonts failed to load. + */ + @JsxFunction + public Promise load(final String font, final String text) { + final Promise promise = Promise.resolve(null, this, new Object[] {""}, null); + return promise; + } } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/FontFaceSetTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/FontFaceSetTest.java 2018-05-14 14:27:42 UTC (rev 15261) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/FontFaceSetTest.java 2018-05-15 09:27:45 UTC (rev 15262) @@ -64,4 +64,28 @@ loadPageWithAlerts2(html); } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "then: ", + IE = "document.fonts is undefined") + public void load() throws Exception { + final String html + = "<html>\n" + + "<body>\n" + + "<script>\n" + + " if (document.fonts) {\n" + + " document.fonts.load('12px Arial', 'HtmlUnit').then(function(value) {\n" + + " alert('then: ' + value);" + + " });\n" + + " } else {\n" + + " alert('document.fonts is undefined');\n" + + " }" + + "</script>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } } |