Crash: blocking JS and deleting a window
Simon Hausmann
hausmann at kde.org
Sat Oct 5 17:02:54 BST 2002
On Sat, Oct 05, 2002 at 01:37:43PM +0200, Koos Vriezen wrote:
> On Sat, 5 Oct 2002, Simon Hausmann wrote:
>
> > On Wed, Oct 02, 2002 at 08:44:16PM +0200, Koos Vriezen wrote:
> > > Hi,
> > >
> > > Testcase:
> > >
> > > <html><head><script>
> > > var win=open("", "xxx");
> > > var doc=win.document;
> > > doc.open();
> > > doc.write("<html><body onLoad=\"alert(somevar)\">");
> > > doc.write("</body></html>");
> > > doc.close();
> > > </script></head>
> > > <body></body></html>
> > >
> > > After the second window is created, delete it by clicking the X button.
> > > Even KCrash crashes on this one.
> > > The problem is blocking JS (here the alert box, might as well be a
> > > LiveConnect call). Currently I see these options:
> >
> > On a second though I don't understand how this can happen. The
> > alert() triggers a messagebox with the window as parent, so it
> > shouldn't be possible to close the window in the first place as the
> > messagebox is modal. Any idea?
>
> Same for 'Open Location' dialog. Bug in Qt?
Yes, I guess somewhere, or possibly in the code for not passing the
right parent.
> There are other cases, eg calls to Java, that could block JS. Something
> has to be done.
> That khtml currently even self doesn't check if it can close the window
> proves the next testcase
>
> <html><head><script>
> var win=open("", "xxx");
> var doc=win.document;
> doc.open();
>
> doc.write("<html><script>setTimeout('self.close()',1000);alert(somevar);<\/script><body>");
> doc.write("</body></html>");
> doc.close();
> </script></head>
> <body></body></html>
>
> Crash with backtrace this time.
Ouch. Ok, independent from the idea of konq sending close events. (I
attached the kparts part of the patch, as reference, but I guess we
won't need that then)
Simon
-------------- next part --------------
Index: browserextension.cpp
===================================================================
RCS file: /home/kde/kdelibs/kparts/browserextension.cpp,v
retrieving revision 1.40
diff -u -p -r1.40 browserextension.cpp
--- browserextension.cpp 2002/08/18 11:17:54 1.40
+++ browserextension.cpp 2002/10/05 16:01:52
@@ -30,6 +30,7 @@
using namespace KParts;
const char *OpenURLEvent::s_strOpenURLEvent = "KParts/BrowserExtension/OpenURLevent";
+const char *BrowserCloseEvent::s_browserCloseEventName = "KParts/BrowserExtension/CloseEvent";
class OpenURLEvent::OpenURLEventPrivate
{
@@ -394,6 +395,15 @@ bool BrowserExtension::isURLDropHandling
void BrowserExtension::setURLDropHandlingEnabled( bool enable )
{
d->m_urlDropHandlingEnabled = enable;
+}
+
+void BrowserExtension::customEvent( QCustomEvent *event )
+{
+ if ( BrowserCloseEvent::test( event ) ) {
+ // ## KDE 4.0: add virtual browserCloseEvent( ... ) method (Simon)
+ static_cast<BrowserCloseEvent *>( event )->accept();
+ return;
+ }
}
void BrowserExtension::slotCompleted()
Index: browserextension.h
===================================================================
RCS file: /home/kde/kdelibs/kparts/browserextension.h,v
retrieving revision 1.94
diff -u -p -r1.94 browserextension.h
--- browserextension.h 2002/08/18 11:17:54 1.94
+++ browserextension.h 2002/10/05 16:01:52
@@ -202,6 +202,23 @@ private:
OpenURLEventPrivate *d;
};
+class BrowserCloseEvent : public Event
+{
+public:
+ BrowserCloseEvent() : Event( s_browserCloseEventName ) {}
+
+ bool isAccepted() const { return m_accept; }
+ void accept() { m_accept = true; }
+ void ignore() { m_accept = false; }
+
+ static bool test( const QEvent *event ) { return Event::test( event, s_browserCloseEventName ); }
+
+private:
+ bool m_accept;
+
+ static const char *s_browserCloseEventName;
+};
+
class BrowserExtensionPrivate;
/**
@@ -551,6 +568,12 @@ signals:
* Used when the mouse is on an URL.
*/
void mouseOverInfo( const KFileItem* item );
+
+protected:
+ /**
+ * Reimplemented for internal reasons.
+ */
+ virtual void customEvent( QCustomEvent *event );
private slots:
void slotCompleted();
More information about the kfm-devel
mailing list