diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 1e2a3747751..ec2ad98c464 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -1180,7 +1180,9 @@ impl Document { let node = elem.upcast::(); elem.set_focus_state(false); // FIXME: pass appropriate relatedTarget - self.fire_focus_event(FocusEventType::Blur, node, None, can_gc); + if node.is_connected() { + self.fire_focus_event(FocusEventType::Blur, node, None, can_gc); + } // Notify the embedder to hide the input method. if elem.input_method_type().is_some() { diff --git a/tests/wpt/meta/MANIFEST.json b/tests/wpt/meta/MANIFEST.json index 8ba5d8b0ff6..750266dc59c 100644 --- a/tests/wpt/meta/MANIFEST.json +++ b/tests/wpt/meta/MANIFEST.json @@ -7459,6 +7459,15 @@ } } }, + "focus": { + "focus-element-crash.html": [ + "27df1c0b13081827685fa96e0cba2f7b9b03c89a", + [ + null, + {} + ] + ] + }, "fullscreen": { "crashtests": { "backdrop-list-item.html": [ diff --git a/tests/wpt/meta/dom/nodes/insertion-removing-steps/blur-event.window.js.ini b/tests/wpt/meta/dom/nodes/insertion-removing-steps/blur-event.window.js.ini deleted file mode 100644 index 9b57360d600..00000000000 --- a/tests/wpt/meta/dom/nodes/insertion-removing-steps/blur-event.window.js.ini +++ /dev/null @@ -1,2 +0,0 @@ -[blur-event.window.html] - expected: CRASH diff --git a/tests/wpt/tests/focus/focus-element-crash.html b/tests/wpt/tests/focus/focus-element-crash.html new file mode 100644 index 00000000000..27df1c0b130 --- /dev/null +++ b/tests/wpt/tests/focus/focus-element-crash.html @@ -0,0 +1,33 @@ + + + + + + + + + + + + +
+ +
+ + + + + + + +