Closed Bug 1325850 Opened 5 years ago Closed 3 years ago

Need automated tests of nsIContentIterator


(Core :: DOM: Core & HTML, task, P3)




Tracking Status
firefox66 --- fixed


(Reporter: masayuki, Assigned: masayuki)




(2 files)

nsIContentIterator initializes its member with complicated logic. On the other hand, it's not tested so many cases. However, we've found some bugs in some edge cases. So, for reducing the risk of touching the implementation, we should have automated tests for this.

I think that we should make nsIContentIterator scriptable and its instance creatable with nsIDOMWIndowUtils.
Priority: -- → P3
I think I can fix this by new-year vacation.
Assignee: nobody → masayuki
OS: Unspecified → All
Hardware: Unspecified → All
And I think that we shouldn't make nsIContentIterator scriptable directly because we already have some methods which take non-scriptable concrete classes for improving its performance.  So, I think that there should be nsIScriptableContentIterator and its implementation should be simple delegator for nsIContentIterator.
The concrete classes of nsIContentIterator are enough complicated, but they
are not tested simply.  Therefore, it's dangerous to touch them even if we
meed bugs of them.  Additionally, it's used in some hot paths, therefore,
I'd like to keep them simple as far as possible.

Therefore, this patch creates a mediator class between script and each
nsIContentIterator instance.  So, this change shouldn't affect any of
actual behavior nor performance.
nsContentIterator in post-order collects nodes starting from deepest first
child to next siblings and parents.  I.e., collecting end points (i.e.,
"close tag" if element node).  This is tested by

nsContentIterator in pre-order collects nodes starting from most ancestor to
last deepest child node.  I.e., collecting start points (i.e., "open tag" if
element node).  This is tested by test_content_iterator_pre_order.html.

nsContentSubtreeIterator collects most ancestor nodes which are selected
entirely by specified range or positions.  This is tested by

I.e., all of them start with "test_content_iterator_" for making find easier.
Pushed by
part 1: Create ScriptableContentIterator to make each concrete class of nsIContentIterator scriptable r=smaug
part 2: Add automated tests for nsIContentIterator concrete classes r=smaug
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla66
Component: DOM → DOM: Core & HTML
Type: defect → task
You need to log in before you can comment on or make changes to this bug.