Last Comment Bug 675621 - Useless assertion [@ nsContentUtils::MaybeFireNodeRemoved] when calling insertAdjacentHTML
: Useless assertion [@ nsContentUtils::MaybeFireNodeRemoved] when calling inser...
Status: RESOLVED FIXED
[inbound]
:
Product: Core
Classification: Components
Component: DOM: Core & HTML (show other bugs)
: Trunk
: All All
: -- trivial (vote)
: mozilla8
Assigned To: Henri Sivonen (:hsivonen) (Not reading bugmail or doing reviews until 2016-10-03)
:
:
Mentors:
Depends on:
Blocks: 613662
  Show dependency treegraph
 
Reported: 2011-08-01 07:36 PDT by Henri Sivonen (:hsivonen) (Not reading bugmail or doing reviews until 2016-10-03)
Modified: 2011-08-06 02:48 PDT (History)
4 users (show)
hsivonen: in‑testsuite?
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
Suppress the assertion (1.27 KB, patch)
2011-08-01 07:37 PDT, Henri Sivonen (:hsivonen) (Not reading bugmail or doing reviews until 2016-10-03)
bugs: review-
Details | Diff | Splinter Review
Move the update batch (2.57 KB, patch)
2011-08-05 05:43 PDT, Henri Sivonen (:hsivonen) (Not reading bugmail or doing reviews until 2016-10-03)
bugs: review+
Details | Diff | Splinter Review

Description Henri Sivonen (:hsivonen) (Not reading bugmail or doing reviews until 2016-10-03) 2011-08-01 07:36:19 PDT
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.
Comment 1 Henri Sivonen (:hsivonen) (Not reading bugmail or doing reviews until 2016-10-03) 2011-08-01 07:37:56 PDT
Created attachment 549785 [details] [diff] [review]
Suppress the assertion
Comment 2 Olli Pettay [:smaug] (reviewing overload) 2011-08-01 07:52:31 PDT
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.
Comment 3 Jonas Sicking (:sicking) No longer reading bugmail consistently 2011-08-01 12:02:55 PDT
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.
Comment 4 Henri Sivonen (:hsivonen) (Not reading bugmail or doing reviews until 2016-10-03) 2011-08-05 05:43:05 PDT
Created attachment 551014 [details] [diff] [review]
Move the update batch

Fix using the approach Jonas suggested.
Comment 5 Henri Sivonen (:hsivonen) (Not reading bugmail or doing reviews until 2016-10-03) 2011-08-05 09:48:38 PDT
Thanks. Pushed:
http://hg.mozilla.org/integration/mozilla-inbound/rev/3e9fb8cfe7fd
Comment 6 Marco Bonardo [::mak] 2011-08-06 02:48:07 PDT
http://hg.mozilla.org/mozilla-central/rev/3e9fb8cfe7fd

Note You need to log in before you can comment on or make changes to this bug.