Skip to content

Commit 15cb522

Browse files
committed
Validate that #126 can be done
1 parent 50d8e9d commit 15cb522

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
namespace AngleSharp.Css.Tests.Library
2+
{
3+
using AngleSharp.Css.Dom;
4+
using AngleSharp.Css.Values;
5+
using AngleSharp.Dom;
6+
using AngleSharp.Html.Dom;
7+
using NUnit.Framework;
8+
9+
[TestFixture]
10+
public class ExtractInfosTests
11+
{
12+
[Test]
13+
public void GetFontUrl_Issue126()
14+
{
15+
var css = @"@font-face {
16+
font-family: 'Inter';
17+
font-style: normal;
18+
font-weight: 400;
19+
src: url(https://example.org/some-font.ttf) format('truetype');
20+
}";
21+
var html = $"<style>{css}</style>";
22+
var document = html.ToHtmlDocument(Configuration.Default.WithCss());
23+
var style = document.QuerySelector<IHtmlStyleElement>("style");
24+
var sheet = style.Sheet as ICssStyleSheet;
25+
var fontFace = sheet.Rules[0] as ICssFontFaceRule;
26+
var src = fontFace.GetProperty("src").RawValue;
27+
var url = ((src as ICssMultipleValue)[0] as ICssMultipleValue)[0] as CssUrlValue;
28+
Assert.AreEqual("https://example.org/some-font.ttf", url.Path);
29+
}
30+
}
31+
}

0 commit comments

Comments
 (0)