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

Suppress the assertion (1.27 KB, patch)
2011-08-01 07:37 PDT, Henri Sivonen (:hsivonen)
bugs: review-
Details | Diff | Review
Move the update batch (2.57 KB, patch)
2011-08-05 05:43 PDT, Henri Sivonen (:hsivonen)
bugs: review+
Details | Diff | Review

Description Henri Sivonen (:hsivonen) 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:

The asserting method ends up returning early:

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) 2011-08-01 07:37:56 PDT
Created attachment 549785 [details] [diff] [review]
Suppress the assertion
Comment 2 Olli Pettay [:smaug] 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) 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) 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) 2011-08-05 09:48:38 PDT
Thanks. Pushed:
Comment 6 Marco Bonardo [::mak] 2011-08-06 02:48:07 PDT

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