Skip to content

Commit 314805d

Browse files
committed
Added test to validate #140
1 parent 10845f2 commit 314805d

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Released on tbd.
99
- Fixed missing semicolon in `@page` rule (#135)
1010
- Fixed integer serialization of keyframe stops (#128)
1111
- Fixed ordering of rows and columns in `grid` and `grid-gap` (#137)
12+
- Fixed inclusion of CSS from stylesheets (#140)
1213
- Added further compactification of CSS tuples (#89, #93)
1314

1415
# 0.17.0

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

+39
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ namespace AngleSharp.Css.Tests.Library
22
{
33
using AngleSharp.Css.Dom;
44
using AngleSharp.Css.Parser;
5+
using AngleSharp.Css.RenderTree;
56
using AngleSharp.Css.Tests.Mocks;
67
using AngleSharp.Css.Values;
78
using AngleSharp.Dom;
@@ -178,5 +179,43 @@ public async Task MediaListForLinkedStyleSheet_Issue133()
178179
Assert.AreEqual("", link.Sheet.Media.MediaText);
179180
Assert.IsTrue(link.Sheet.Media.Validate(new DefaultRenderDevice()));
180181
}
182+
183+
[Test]
184+
public async Task ExternalCssNotConsidered_Issue140()
185+
{
186+
var html = @"<html>
187+
<head><link href=""https://some/tested/url.css"" rel=""stylesheet""></head>
188+
<body><label>HI</label></body>
189+
</html>";
190+
var mockRequester = new MockRequester();
191+
mockRequester.BuildResponse(request =>
192+
{
193+
if (request.Address.Path.EndsWith("url.css"))
194+
{
195+
return @"label, .test {
196+
min-width: 50px;
197+
border: 1px solid green;
198+
}";
199+
}
200+
201+
return null;
202+
});
203+
var config = Configuration.Default
204+
.WithRenderDevice(new DefaultRenderDevice
205+
{
206+
DeviceWidth = 1920,
207+
DeviceHeight = 1080,
208+
})
209+
.WithCss()
210+
.WithMockRequester(mockRequester);
211+
var context = BrowsingContext.New(config);
212+
var document = await context.OpenAsync((res) => res.Content(html));
213+
var window = document.DefaultView;
214+
var tree = window.Render();
215+
var label = tree.Find(document.QuerySelector("label"));
216+
var minWidth = window.GetComputedStyle(label.Ref as IHtmlElement).GetMinWidth();
217+
218+
Assert.AreEqual("50px", minWidth);
219+
}
181220
}
182221
}

0 commit comments

Comments
 (0)