diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index e9b96fc1061..36ad1fdac68 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -4413,12 +4413,12 @@ impl Document { }) .cloned(); - let cloned_stylesheet = sheet.clone(); - let insertion_point2 = insertion_point.clone(); - self.window.layout_mut().add_stylesheet( - cloned_stylesheet, - insertion_point2.as_ref().map(|s| s.sheet.clone()), - ); + if self.has_browsing_context() { + self.window.layout_mut().add_stylesheet( + sheet.clone(), + insertion_point.as_ref().map(|s| s.sheet.clone()), + ); + } DocumentOrShadowRoot::add_stylesheet( owner, @@ -4439,10 +4439,11 @@ impl Document { /// Remove a stylesheet owned by `owner` from the list of document sheets. #[cfg_attr(crown, allow(crown::unrooted_must_root))] // Owner needs to be rooted already necessarily. pub(crate) fn remove_stylesheet(&self, owner: &Element, stylesheet: &Arc) { - let cloned_stylesheet = stylesheet.clone(); - self.window - .layout_mut() - .remove_stylesheet(cloned_stylesheet); + if self.has_browsing_context() { + self.window + .layout_mut() + .remove_stylesheet(stylesheet.clone()); + } DocumentOrShadowRoot::remove_stylesheet( owner, diff --git a/tests/wpt/meta/html/rendering/non-replaced-elements/flow-content-0/slot-element-focusable.tentative.html.ini b/tests/wpt/meta/html/rendering/non-replaced-elements/flow-content-0/slot-element-focusable.tentative.html.ini index 3b41a3cb0bd..af19c2689cb 100644 --- a/tests/wpt/meta/html/rendering/non-replaced-elements/flow-content-0/slot-element-focusable.tentative.html.ini +++ b/tests/wpt/meta/html/rendering/non-replaced-elements/flow-content-0/slot-element-focusable.tentative.html.ini @@ -1,5 +1,4 @@ [slot-element-focusable.tentative.html] - expected: CRASH [slot element with display: block should be focusable] expected: FAIL diff --git a/tests/wpt/meta/shadow-dom/MouseEvent-prototype-offsetX-offsetY.html.ini b/tests/wpt/meta/shadow-dom/MouseEvent-prototype-offsetX-offsetY.html.ini index 4b44502efa0..e2e1b1805e1 100644 --- a/tests/wpt/meta/shadow-dom/MouseEvent-prototype-offsetX-offsetY.html.ini +++ b/tests/wpt/meta/shadow-dom/MouseEvent-prototype-offsetX-offsetY.html.ini @@ -1,4 +1,9 @@ [MouseEvent-prototype-offsetX-offsetY.html] - expected: CRASH [MouseEvent's offsetX and offsetY attributes must be relative to the target.] expected: FAIL + + [MouseEvent's offsetX and offsetY attributes must be relative to the shadow host when an event is dispatched inside its shadow tree.] + expected: FAIL + + [MouseEvent's offsetX and offsetY attributes must be relative to the target when an event is dispatched on a slotted content.] + expected: FAIL diff --git a/tests/wpt/meta/shadow-dom/ShadowRoot-interface.html.ini b/tests/wpt/meta/shadow-dom/ShadowRoot-interface.html.ini index 6fcd0c00cab..f8c1a5160e7 100644 --- a/tests/wpt/meta/shadow-dom/ShadowRoot-interface.html.ini +++ b/tests/wpt/meta/shadow-dom/ShadowRoot-interface.html.ini @@ -1,25 +1,6 @@ [ShadowRoot-interface.html] - expected: CRASH [ShadowRoot.activeElement must return the focused element of the context object when shadow root is open.] expected: FAIL [ShadowRoot.activeElement must return the focused element of the context object when shadow root is closed.] expected: FAIL - - [ShadowRoot.innerHTML must return the result of the HTML fragment serialization algorithm when shadow root is open.] - expected: FAIL - - [ShadowRoot.innerHTML must return the result of the HTML fragment serialization algorithm when shadow root is closed.] - expected: FAIL - - [ShadowRoot.innerHTML must replace all with the result of invoking the fragment parsing algorithm when shadow root is open.] - expected: FAIL - - [ShadowRoot.innerHTML must replace all with the result of invoking the fragment parsing algorithm when shadow root is closed.] - expected: FAIL - - [ShadowRoot.styleSheets must return a StyleSheetList sequence containing the shadow root style sheets when shadow root is open.] - expected: FAIL - - [ShadowRoot.styleSheets must return a StyleSheetList sequence containing the shadow root style sheets when shadow root is closed.] - expected: FAIL