Skip to content

Commit 10845f2

Browse files
committed
Added test to verify fix for #133
1 parent 6d52e79 commit 10845f2

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/AngleSharp.Css.Tests/Library/StringRepresentation.cs

+27
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@ namespace AngleSharp.Css.Tests.Library
22
{
33
using AngleSharp.Css.Dom;
44
using AngleSharp.Css.Parser;
5+
using AngleSharp.Css.Tests.Mocks;
56
using AngleSharp.Css.Values;
7+
using AngleSharp.Dom;
8+
using AngleSharp.Html.Dom;
9+
using AngleSharp.Io;
610
using NUnit.Framework;
711
using System.IO;
12+
using System.Threading.Tasks;
813
using static CssConstructionFunctions;
914

1015
[TestFixture]
@@ -151,5 +156,27 @@ public void BorderWithEmptyPx_Issue129()
151156

152157
Assert.AreEqual("border-width: 1px", css);
153158
}
159+
160+
[Test]
161+
public async Task MediaListForLinkedStyleSheet_Issue133()
162+
{
163+
var html = "<link href=\"style.css\" rel=\"stylesheet\">";
164+
var mockRequester = new MockRequester();
165+
mockRequester.BuildResponse(request =>
166+
{
167+
if (request.Address.Path.EndsWith("style.css"))
168+
{
169+
return "div#A { color: blue; }";
170+
}
171+
172+
return null;
173+
});
174+
var config = Configuration.Default.WithCss().WithMockRequester(mockRequester);
175+
var context = BrowsingContext.New(config);
176+
var document = await context.OpenAsync((res) => res.Content(html));
177+
var link = document.QuerySelector<IHtmlLinkElement>("link");
178+
Assert.AreEqual("", link.Sheet.Media.MediaText);
179+
Assert.IsTrue(link.Sheet.Media.Validate(new DefaultRenderDevice()));
180+
}
154181
}
155182
}

0 commit comments

Comments
 (0)