Closed Bug 675621 Opened 13 years ago Closed 13 years ago

Useless assertion [@ nsContentUtils::MaybeFireNodeRemoved] when calling insertAdjacentHTML

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
trivial

Tracking

()

RESOLVED FIXED
mozilla8

People

(Reporter: hsivonen, Assigned: hsivonen)

References

Details

(Whiteboard: [inbound])

Attachments

(1 file, 1 obsolete file)

Due to changes introduces in bug 650493, the step of inserting the DocumentFragment into the DOM in insertAdjacentHTML asserts about node removal mutation events:
http://mxr.mozilla.org/mozilla-central/source/content/base/src/nsContentUtils.cpp#3314

The asserting method ends up returning early:
http://mxr.mozilla.org/mozilla-central/source/content/base/src/nsContentUtils.cpp#3325

There's no harm, because the DocumentFragment comes fresh from parsing and cannot have had mutation listeners set on it. Therefore, it's OK to suppress the assertion.
Attached patch Suppress the assertion (obsolete) — Splinter Review
Assignee: nobody → hsivonen
Status: NEW → ASSIGNED
Attachment #549785 - Flags: review?(Olli.Pettay)
Attachment #549785 - Flags: review?(Olli.Pettay) → review+
Comment on attachment 549785 [details] [diff] [review]
Suppress the assertion

nsAutoScriptBlockerSuppressNodeRemoved should be after 
mozAutoDocUpdate, I think, so that script blockers are removed after removing
nsAutoScriptBlockerSuppressNodeRemoved from stack.

Make sure that you get DOMNodeRemoved events if you modify DOM in the
DOMNodeInserted listeners.
Attachment #549785 - Flags: review+ → review-
Another strategy here would be to just make the update batch span the parsing, then you can insert the fragment outside the batch without worrying about any scriptblockers causing assertions.

Though I'm fine with the approach in the patch too, but please add a comment describing this alternative strategy as ideally nsAutoScriptBlockerSuppressNodeRemoved should never be needed.
Fix using the approach Jonas suggested.
Attachment #549785 - Attachment is obsolete: true
Attachment #551014 - Flags: review?(Olli.Pettay)
Attachment #551014 - Flags: review?(Olli.Pettay) → review+
Thanks. Pushed:
http://hg.mozilla.org/integration/mozilla-inbound/rev/3e9fb8cfe7fd
Flags: in-testsuite?
Whiteboard: [inbound]
Target Milestone: --- → mozilla8
http://hg.mozilla.org/mozilla-central/rev/3e9fb8cfe7fd
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: