Bug: C-C TB, many assertions during mochitest: ASSERTION: Want to fire DOMNodeRemoved event, but it's not safe: 'Error'
Status: NEW
Priority: --
Created: 2022-09-07 00:46:39+00:00
Resolved: 2023-07-31 17:14:18+00:00

This is new. I did not see it back in June.
(I did not see it in July, too. But I was not so sure. Some tests
timed out and it may have skipped the execution paths that could have
resulted in the assertions.)

This is visible in other people's mochitest run of debug version on try-comm-central..
For example,
Geoff's job:
https://treeherder.mozilla.org/jobs?repo=try-comm-central&selectedTaskRun=PxyWYSGER5SKcQcw5mplPg.0&revision=f81fb02e91f1b701693102ae185ead269b3390ec
See linux64 debug mochitest bct1:
https://firefoxci.taskcluster-artifacts.net/PxyWYSGER5SKcQcw5mplPg/0/public/logs/live_backing.log

I am attaching the output of the following command against the local
log to show where the
assertion is recorded.
```
egrep "(TEST_START|TEST_END|ASSERTION: Want to fire DOMNodeRemoved)" log1484-mochitest.txt &
```

From it, I can tell the following tests produced the assertion.

30:20.65 TEST_START: comm/calendar/test/browser/preferences/browser_alarmDefaultValue.js
30:34.85 TEST_START: comm/calendar/test/browser/preferences/browser_categoryColors.js
48:46.31 TEST_START: comm/mail/components/addrbook/test/browser/browser_contact_tree.js
51:48.11 TEST_START: comm/mail/components/addrbook/test/browser/browser_edit_card.js
53:20.54 TEST_START: comm/mail/components/addrbook/test/browser/browser_edit_photo.js
53:29.70 TEST_START: comm/mail/components/addrbook/test/browser/browser_focus.js
53:40.46 TEST_START: comm/mail/components/addrbook/test/browser/browser_open_actions.js
71:29.46 TEST_START: comm/mail/components/preferences/test/browser/browser_chat.js
71:38.39 TEST_START: comm/mail/components/preferences/test/browser/browser_cloudfile.js
72:02.95 TEST_START: comm/mail/components/preferences/test/browser/browser_compose.js
72:13.45 TEST_START: comm/mail/components/preferences/test/browser/browser_general.js
72:56.38 TEST_START: comm/mail/components/preferences/test/browser/browser_openPreferences.js
73:03.98 TEST_START: comm/mail/components/preferences/test/browser/browser_privacy.js
922:04.93 TEST_START: comm/mail/test/browser/message-header/browser_messageHeader.js
925:07.80 TEST_START: comm/mail/test/browser/message-window/browser_vcardActions.js


Typical stack trace is

```
30:25.61 GECKO(475750) [Parent 475750, Main Thread] ###!!! ASSERTION: Want to fire DOMNodeRemoved event, but it's not safe: 'Error', file /NEW-SSD/NREF-COMM-CENTRAL/mozilla/dom/base/nsContentUtils.cpp:4924
Initializing stack-fixing for the first stack frame, this may take a while...
31:04.54 GECKO(475750) #01: NS_DebugBreak (/NEW-SSD/NREF-COMM-CENTRAL/mozilla/xpcom/base/nsDebugImpl.cpp:493)
31:04.59 GECKO(475750) #02: nsContentUtils::MaybeFireNodeRemoved(nsINode*, nsINode*) (/NEW-SSD/NREF-COMM-CENTRAL/mozilla/dom/base/nsContentUtils.cpp:4925)
31:04.60 GECKO(475750) #03: nsINode::ReplaceOrInsertBefore(bool, nsINode*, nsINode*, mozilla::ErrorResult&) (/NEW-SSD/NREF-COMM-CENTRAL/mozilla/dom/base/nsINode.cpp:2491)
31:04.60 GECKO(475750) #04: nsINode::ReplaceChildren(nsINode*, mozilla::ErrorResult&) (/NEW-SSD/NREF-COMM-CENTRAL/mozilla/dom/base/nsINode.cpp:2149)
31:04.61 GECKO(475750) #05: nsINode::ReplaceChildren(mozilla::dom::Sequence<mozilla::dom::OwningNodeOrString> const&, mozilla::ErrorResult&) (/NEW-SSD/NREF-COMM-CENTRAL/mozilla/dom/base/nsINode.cpp:2120)
31:04.61 GECKO(475750) #06: mozilla::dom::Element_Binding::replaceChildren(JSContext*, JS::Handle<JSObject*>, void*, JSJitMethodCallArgs const&) (/NEW-SSD/moz-obj-dir/objdir-tb3/dom/bindings/ElementBinding.cpp:10594)
```
or most common stack trace seems to be (with mozilla::dom::FragmentOrElemtn::FireNodeRemovedForChildren())

```
51:41.63 GECKO(480496) [Parent 480496, Main Thread] ###!!! ASSERTION: Want to fire DOMNodeRemoved event, but it's not safe: 'Error', file /NEW-SSD/NREF-COMM-CENTRAL/mozilla/dom/base/nsContentUtils.cpp:4924
51:41.63 GECKO(480496) #01: NS_DebugBreak (/NEW-SSD/NREF-COMM-CENTRAL/mozilla/xpcom/base/nsDebugImpl.cpp:493)
51:41.63 GECKO(480496) #02: nsContentUtils::MaybeFireNodeRemoved(nsINode*, nsINode*) (/NEW-SSD/NREF-COMM-CENTRAL/mozilla/dom/base/nsContentUtils.cpp:4925)
51:41.63 GECKO(480496) #03: mozilla::dom::FragmentOrElement::FireNodeRemovedForChildren() (/NEW-SSD/NREF-COMM-CENTRAL/mozilla/dom/base/FragmentOrElement.cpp:2020)
51:41.63 GECKO(480496) #04: nsINode::ReplaceOrInsertBefore(bool, nsINode*, nsINode*, mozilla::ErrorResult&) (/NEW-SSD/NREF-COMM-CENTRAL/mozilla/dom/base/nsINode.cpp:2498)
51:41.63 GECKO(480496) #05: nsINode::ReplaceChildren(nsINode*, mozilla::ErrorResult&) (/NEW-SSD/NREF-COMM-CENTRAL/mozilla/dom/base/nsINode.cpp:2149)
51:41.63 GECKO(480496) #06: nsINode::ReplaceChildren(mozilla::dom::Sequence<mozilla::dom::OwningNodeOrString> const&, mozilla::ErrorResult&) (/NEW-SSD/NREF-COMM-CENTRAL/mozilla/dom/base/nsINode.cpp:2120)
51:41.63 GECKO(480496) #07: mozilla::dom::Element_Binding::replaceChildren(JSContext*, JS::Handle<JSObject*>, void*, JSJitMethodCallArgs const&) (/NEW-SSD/moz-obj-dir/objdir-tb3/dom/bindings/ElementBinding.cpp:10594)
51:41.63 GECKO(480496) #08: bool mozilla::dom::binding_detail::GenericMethod<mozilla::dom::binding_detail::NormalThisPolicy, mozilla::dom::binding_detail::ThrowExceptions>(JSContext*, unsigned int, JS::Value*) (/NEW-SSD/NREF-COMM-CENTRAL/mozilla/dom/bindings/BindingUtils.cpp:3287)
```
cf. Actually, Firefox has experienced similar issues before. But here I am reporting the C-C TB mochitest and very recent appearance at that.
bug 655858 		"ASSERTION: Want to fire DOMNodeRemoved event, but it's not safe" with XML error in innerHTML setter
bug 691242 		"ASSERTION: Want to fire DOMNodeRemoved event, but it's not safe" with NoScript