Patch: Crash: blocking JS alert and deleting a window

Koos Vriezen koos.vriezen at xs4all.nl
Fri Oct 18 16:05:52 BST 2002


On Fri, 18 Oct 2002, David Faure wrote:

> On Friday 18 October 2002 14:33, Koos Vriezen wrote:
> > +#include <qobjectlist.h>
[..]
> > +        if (widget) {
> > +          // quit all modal dialogs of this view
> > +          QObjectList * dlgs = widget->topLevelWidget()->queryList("QDialog");
> > +          for (QObject* dlg = dlgs->first(); dlg; dlg = dlgs->next())
> > +            ((QDialog*)dlg)->hide();
> > +        }
> >          // We'll close the window at the end of the script execution
> >          Window* w = const_cast<Window*>(window);
> >          w->m_delayed.append( Window::DelayedAction( Window::DelayedClose ) );
> >
> > Is this correct?
>
> Looks good to me (maybe add a simplified testcase in comments, to
> explain why this is needed, like I did 2 lines above).
>
> I think this testcase does it:  setTimeout('self.close()',1000); alert("Hi");
>
> BTW the comment says "modal" and the code even closes non-modal dialogs,
> but this obviously doesn't hurt (they would be destroyed when closing the window
> anyway).

Thanks for your comments, changed and commited.

Btw, I'm trying very hard finding cases where this would lead to crashes
too. Didn't succeed yet, even:
  <html><head><script>
    setTimeout('self.location.replace("http://slashdot.org")', 3000);
  </script></head>
  <body><INPUT TYPE=TEXT onFocus='alert(somevar);this.value="some text";'>
  </body></html>
this evil script doesn't cause a crash (click on the INPUT within three
seconds). However one may ask if the alert box shouldn't disappear after a
reload/replace. Shouldn't there be something similar in
KHTMLPart::closeURL() too?

Koos





More information about the kfm-devel mailing list