nsSHEnumerator::HasMoreElements() needs to check mIndex = -1

VERIFIED FIXED in mozilla1.0

Status

()

Core
Embedding: APIs
P3
normal
VERIFIED FIXED
17 years ago
17 years ago

People

(Reporter: David Epstein, Assigned: Radha on family leave (not reading bugmail))

Tracking

Trunk
mozilla1.0
x86
Windows NT
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(URL)

Attachments

(1 attachment)

(Reporter)

Description

17 years ago
1. Ran mfcEmbed w/ qa tests
2. Ran tests for nsISHistory iface. Incl SH index tests which start at index=0.
3. Special test for SimpleEnumerator.
4. Execute this Code segment:

nsCOMPtr<nsISimpleEnumerator> theSimpleEnum;
rv = theSessionHistory->GetSHistoryEnumerator(getter_AddRefs(theSimpleEnum));

PRBool bMore = PR_FALSE;
nsCOMPtr<nsISupports> nextObj;
nsCOMPtr<nsIHistoryEntry> nextHistoryEntry;
while (NS_SUCCEEDED(theSimpleEnum->HasMoreElements(&bMore)) && bMore)
{
   theSimpleEnum->GetNext(getter_AddRefs(nextObj));
   if (!nextObj)
      continue;
   nextHistoryEntry = do_QueryInterface(nextObj);
   if (!nextHistoryEntry)
      continue;
   rv = nextHistoryEntry->GetURI(getter_AddRefs(theUri));
   rv = theUri->GetSpec(&uriSpec);
   // ...		 
} 

Result: It doesn't execute this while loop because HasMoreElements() initializes 
the mIndex to -1 but only checks between 0 and a positive counter. Also, if I 
replace the while() with a do/while() loop, it will execute, but the last url is 
repeated twice and we get an assert.

Expected: Check for mIndex = -1 in nsSHEnumerator::HasMoreElements(), in the 
"if" condition. Then the code segment will execute. See above url (line 804).
Status: NEW → ASSIGNED
Priority: -- → P3
Target Milestone: --- → mozilla1.0
(Reporter)

Comment 1

17 years ago
changed qa contact to depstein
QA Contact: mdunn → depstein
Created attachment 37726 [details] [diff] [review]
patch to nsSHistory.cpp
The attached patch to nsSHistory.cpp includes patch to bug 84556. Only the last
part of the diffs to line 804, belongs to this bug. The rest belong to bug 84556

Comment 4

17 years ago
r=valeski on the mIndex line change.

Comment 5

17 years ago
sr=rpotts
fix checked in.
Status: ASSIGNED → RESOLVED
Last Resolved: 17 years ago
Resolution: --- → FIXED
(Reporter)

Comment 7

17 years ago
nsSHEnumerator::HasMoreElements()is now working correctly. tested in testEmbed,
Tests.cpp, CTests::SimpleEnumTest(), using 7/9 build.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.