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

RESOLVED FIXED in mozilla8

Status

()

Core
DOM: Core & HTML
--
trivial
RESOLVED FIXED
6 years ago
6 years ago

People

(Reporter: hsivonen, Assigned: hsivonen)

Tracking

Trunk
mozilla8
Points:
---
Bug Flags:
in-testsuite ?

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [inbound])

Attachments

(1 attachment, 1 obsolete attachment)

(Assignee)

Description

6 years ago
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.
(Assignee)

Comment 1

6 years ago
Created attachment 549785 [details] [diff] [review]
Suppress the assertion
Assignee: nobody → hsivonen
Status: NEW → ASSIGNED
Attachment #549785 - Flags: review?(Olli.Pettay)

Updated

6 years ago
Attachment #549785 - Flags: review?(Olli.Pettay) → review+

Comment 2

6 years ago
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.
(Assignee)

Comment 4

6 years ago
Created attachment 551014 [details] [diff] [review]
Move the update batch

Fix using the approach Jonas suggested.
Attachment #549785 - Attachment is obsolete: true
Attachment #551014 - Flags: review?(Olli.Pettay)

Updated

6 years ago
Attachment #551014 - Flags: review?(Olli.Pettay) → review+
(Assignee)

Comment 5

6 years ago
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
Last Resolved: 6 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.