Bug 7899 - FrameTree:uniqueChildName doesn't return unique names
Summary: FrameTree:uniqueChildName doesn't return unique names
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Frames (show other bugs)
Version: 420+
Hardware: Mac OS X 10.4
: P2 Normal
Assignee: Nobody
URL:
Keywords:
: 14895 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-03-21 20:18 PST by Justin Garcia
Modified: 2017-01-28 11:00 PST (History)
4 users (show)

See Also:


Attachments
testcase (674 bytes, text/html)
2006-03-21 20:26 PST, Justin Garcia
no flags Details
reduction1 (338 bytes, text/html)
2006-12-22 23:12 PST, Geoffrey Garen
no flags Details
reduction2 (442 bytes, text/html)
2006-12-22 23:12 PST, Geoffrey Garen
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Justin Garcia 2006-03-21 20:18:19 PST
The number used for unique frame names is the childCount() of the parent frame:
    char suffix[40];
    snprintf(suffix, sizeof(suffix), "/<!--frame%u-->-->", childCount());
This is wrong.  See the attached test case.
Comment 1 Justin Garcia 2006-03-21 20:26:51 PST
Created attachment 7224 [details]
testcase

Creates two unnamed iframes, removes the first one and reinserts it.  It gets a generated name when it is reinserted, but that name is the same as the frame that is already in the document.  This name collision prevents the inserted frame from being constructed.
Comment 2 Geoffrey Garen 2006-12-22 23:12:15 PST
Created attachment 11979 [details]
reduction1

Attaching two unique reductions for triggering this bug.
Comment 3 Geoffrey Garen 2006-12-22 23:12:59 PST
Created attachment 11980 [details]
reduction2

Attaching two unique reductions for how you can trigger this bug.
Comment 4 Geoffrey Garen 2006-12-22 23:17:41 PST
It would be trivial to fix this bug by replacing childCount() with a never-decrementing count of the number of frames that have been added to the page. In fact, we could gut the whole uniqueChildName function and just use the count for unique-ing.

Since a page can have a maximum of 200 frames, the count would be (virtually) guaranteed to be unique.

The only problem is this comment: "Create a repeatable name." Why does the name need to be repeatable? What does repeatable mean? Using a global count would give a frame a new name if you removed and then re-added it to the document. So I don't think that would be "repeatable."

On the other hand, this bug demonstrates that frames *need* to acquire new names when you remove and then re-add them to the document.
Comment 5 Darin Adler 2006-12-30 12:50:50 PST
(In reply to comment #4)
> The only problem is this comment: "Create a repeatable name." Why does the name
> need to be repeatable? What does repeatable mean? Using a global count would
> give a frame a new name if you removed and then re-added it to the document. So
> I don't think that would be "repeatable."

My understanding was that the name of the frame needs to be the same for the same page the next time the page is loaded. Something about back/forward perhaps?
Comment 6 Brett Wilson (Google) 2007-08-07 11:31:09 PDT
*** Bug 14895 has been marked as a duplicate of this bug. ***
Comment 7 Brett Wilson (Google) 2007-08-07 11:49:55 PDT
This bug is causing some crashes for me, and is showing up in the topcrash list for my embedding application. Should it be P1?

The crash is in EventHandler::passWheelEventToWidget (and presumably other input events) when you use the scroll wheel over certain iframes (seems to depend on timing, can can be hard to reproduce) because the widget for the RenderWidget is NULL.

The widget is normally set when the load is committed for the frame, which of course requires that the load be started. The load is started from the redirect timer in the FrameLoader.

What happens is that frame 1 comes in and sets the redirect timer to start the load. Other stuff happens, frames get deleted, etc. to cause the name to be the same (this is where the timing sutff comes in). Frame 2 then gets created and happens to get the same "unique" child name as Frame 1. In FrameLoader::requestFrame, we now get the *old* frame in |frame|, cancel the old (correct) load, and start loading the new frame's URL in it. Frame 2 is never initialized, leading to a crash.
Comment 8 Brett Wilson (Google) 2007-08-08 09:05:25 PDT
Actually, it looks like this crash doesn't happen in Safari since the Mac Event handling code filters out sending messages to anything with a NULL widget. However, this still causes frames to not be loaded, as in the example. There could be other subtle bugs and crashes caused by the uninitialized frame, as well as, of course, the missing content.
Comment 9 David Kilzer (:ddkilzer) 2007-08-09 07:05:01 PDT
(In reply to comment #8)
> Actually, it looks like this crash doesn't happen in Safari since the Mac Event
> handling code filters out sending messages to anything with a NULL widget.
> However, this still causes frames to not be loaded, as in the example. There
> could be other subtle bugs and crashes caused by the uninitialized frame, as
> well as, of course, the missing content.

How is it crashing in your application but not in Safari?  Are you using WebKit in your application?  A (partial) stack trace of the issue would be helpful.