Closed Bug 367387 Opened 18 years ago Closed 16 years ago

[SessionStore] text not always saved for elements without id

Categories

(Firefox :: Session Restore, defect)

defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 346337

People

(Reporter: tabmix.onemen, Unassigned)

References

Details

Attachments

(1 file, 1 obsolete file)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a2pre) Gecko/20070118 Minefield/3.0a2pre
Build Identifier: 

Text not always saved for elements without id if more then one text field in a frame use the same name

Reproducible: Always

Steps to Reproduce:
1. Load a page with several text elements (for example http://forums.mozillazine.org/viewtopic.php?t=511547)
2. In the right side in the page type something into the 2 Search fields (Forums (Old) and Knowledge Base)
3. Close Firefox
4. Open Firefox (make sure your preference are to restore the last session)
Actual Results:  
Only the first Search field elements was restored
and sometimes with the data from the 2nd search field


Expected Results:  
The text in the 2 Search fields elements are restored

For elements without id we use the element name and find the element with
node = document.getElementsByName(name)[0]

but when several text fields in one frame use the same name then we lost.

the fix will be to save the index for the text filed name and use 
node = document.getElementsByName(name)[index]
Attached patch fixSplinter Review
for textarea without id determine the textarea's index in the name array 
and encode it into the textarea's ID
I'm not convinced that we should go further down the road of these hacks unless there's no better solution in the Firefox 3 time frame. Using XPath when there's no id available seems like a cleaner solution and would allow to save text elements without id/name as well (would depend on bug 319768).

What we'd also have to evaluate is whether it's really necessary to rebuild an element's internal id every 10 seconds. Once should be enough, unless we're seriously expecting text elements to move around in the DOM (OTOH the performance penalty should hardly be notable yet).
Status: UNCONFIRMED → NEW
Ever confirmed: true
Component: General → Session Restore
QA Contact: general → session.restore
Blocks: 450465
Attached patch WIP using XPath (obsolete) — Splinter Review
Comment on attachment 334001 [details] [diff] [review]
WIP using XPath

I've attached an extended version of this patch to bug 346337.
Attachment #334001 - Attachment is obsolete: true
Status: NEW → RESOLVED
Closed: 16 years ago
Resolution: --- → DUPLICATE
Is this bug really fixed by bug 346337 because I can still reproduce it (comment #0) ?

Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.9.1b1pre) Gecko/20080915032512 Minefield/3.1b1pre
(In reply to comment #6)
It is fixed. The problem you are observing is that we're not correctly restoring text fields where two fields have the same ID (of which there should only be one per page to start with).

If you want the StR from comment #0 to actually work, you'll thus have to contact one of the mozillaZine admins and have them fix the rest of this issue on their side. Thanks.
(In reply to comment #7)
Thanks for reply, I did a test on locally modified page (removed the id's) and
then the text fields were restored properly; with the same id's first text field
was restored with the content from the second one but I conclude this case now
belongs to the tech evangelism.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: