diff --git a/Libraries/LibWeb/HTML/HTMLLinkElement.cpp b/Libraries/LibWeb/HTML/HTMLLinkElement.cpp index 0adacae602e..2d59eb9fc41 100644 --- a/Libraries/LibWeb/HTML/HTMLLinkElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLLinkElement.cpp @@ -487,13 +487,11 @@ void HTMLLinkElement::process_stylesheet_resource(bool success, Fetch::Infrastru dispatch_event(*DOM::Event::create(realm(), HTML::EventNames::error)); } else { auto const decoded_string = maybe_decoded_string.release_value(); - m_loaded_style_sheet = parse_css_stylesheet(CSS::Parser::ParsingParams(document(), *response.url()), decoded_string); + VERIFY(!response.url_list().is_empty()); + auto location = response.url_list().first(); + m_loaded_style_sheet = parse_css_stylesheet(CSS::Parser::ParsingParams(document(), location), decoded_string, location); if (m_loaded_style_sheet) { - Optional<::URL::URL> location; - if (!response.url_list().is_empty()) - location = response.url_list().first(); - document_or_shadow_root_style_sheets().create_a_css_style_sheet( "text/css"_string, this, diff --git a/Tests/LibWeb/Layout/data/import-a.css b/Tests/LibWeb/Layout/data/import-a.css new file mode 100644 index 00000000000..ad942cacb5e --- /dev/null +++ b/Tests/LibWeb/Layout/data/import-a.css @@ -0,0 +1,5 @@ +@import "import-b.css"; + +#target { + width: 50px; +} diff --git a/Tests/LibWeb/Layout/data/import-b.css b/Tests/LibWeb/Layout/data/import-b.css new file mode 100644 index 00000000000..ebe0467b83d --- /dev/null +++ b/Tests/LibWeb/Layout/data/import-b.css @@ -0,0 +1,3 @@ +#target { + width: 200px !important; +} diff --git a/Tests/LibWeb/Layout/expected/import-from-linked-style-sheet.txt b/Tests/LibWeb/Layout/expected/import-from-linked-style-sheet.txt new file mode 100644 index 00000000000..e72c44d809d --- /dev/null +++ b/Tests/LibWeb/Layout/expected/import-from-linked-style-sheet.txt @@ -0,0 +1,16 @@ +Viewport <#document> at (0,0) content-size 800x600 children: not-inline + BlockContainer at (0,0) content-size 800x33 [BFC] children: not-inline + BlockContainer
at (8,8) content-size 784x17 children: not-inline + BlockContainer