mirror of
https://github.com/servo/servo.git
synced 2025-09-27 15:20:09 +01:00
Assert that style element has an owner in parse_own_css
(#39458)
The existing `assert!(node.is_connected())` is wrong. What it *wants* to assert is that the style element has an owner, which is either a Document or a ShadowRoot that the element is a descendant of. However, if the element is descendant of a ShadowRoot which is itself not connected to a document then the assertion would fail. Instead, we use `node.is_in_a_document_tree() || node.is_in_a_shadow_tree()`, which more accurately reflects the intent. Testing: This change adds the test case from https://github.com/servo/servo/issues/37781 as a crashtest Fixes https://github.com/servo/servo/issues/39457 Fixes https://github.com/servo/servo/issues/37781 --------- Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
This commit is contained in:
parent
dd8e4f231c
commit
206dcff080
3 changed files with 27 additions and 1 deletions
|
@ -97,7 +97,10 @@ impl HTMLStyleElement {
|
|||
|
||||
pub(crate) fn parse_own_css(&self) {
|
||||
let node = self.upcast::<Node>();
|
||||
assert!(node.is_connected());
|
||||
assert!(
|
||||
node.is_in_a_document_tree() || node.is_in_a_shadow_tree(),
|
||||
"This stylesheet does not have an owner, so there's no reason to parse its contents"
|
||||
);
|
||||
|
||||
// Step 4. of <https://html.spec.whatwg.org/multipage/#the-style-element%3Aupdate-a-style-block>
|
||||
let mut type_attribute = self.Type();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue