Fix LayoutTests/fast/dom/document-attribute-js-null.html
authorhausmann@webkit.org <hausmann@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 18 Jan 2008 10:54:20 +0000 (10:54 +0000)
committerhausmann@webkit.org <hausmann@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 18 Jan 2008 10:54:20 +0000 (10:54 +0000)
Don't crash when trying to get/set cookies without a frameloader.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@29618 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/platform/qt/CookieJarQt.cpp

index 29ded2c..ced372c 100644 (file)
@@ -2,6 +2,19 @@
 
         Reviewed by Holger.
 
+        Fix LayoutTests/fast/dom/document-attribute-js-null.html
+        
+        Don't crash when trying to get/set cookies without a frameloader.
+        
+
+        * platform/qt/CookieJarQt.cpp:
+        (WebCore::setCookies):
+        (WebCore::cookies):
+
+2008-01-18  Simon Hausmann  <hausmann@webkit.org>
+
+        Reviewed by Holger.
+
         Fix fast/dom/xmlhttprequest-get.xhtml
         
         For local file requests remove the content length and the last-modified
index 00f3e21..6ad8740 100644 (file)
@@ -50,8 +50,14 @@ void setCookies(Document* document, const KURL& url, const KURL& policyURL, cons
     QUrl u(url);
     QUrl p(policyURL);
 #if QT_VERSION >= 0x040400
-    QWebFrame* frame = static_cast<FrameLoaderClientQt*>(document->frame()->loader()->client())->webFrame();
-    QWebPage* page = frame->page();
+    Frame *frame = document->frame();
+    if (!frame)
+        return;
+    FrameLoader *loader = frame->loader();
+    if (!loader)
+        return;
+    QWebFrame* webFrame = static_cast<FrameLoaderClientQt*>(loader->client())->webFrame();
+    QWebPage* page = webFrame->page();
     QNetworkAccessManager* manager = page->networkAccessManager();
     QNetworkCookieJar* jar = manager->cookieJar();
 
@@ -66,8 +72,14 @@ String cookies(const Document* document, const KURL& url)
 {
     QUrl u(url);
 #if QT_VERSION >= 0x040400
-    QWebFrame* frame = static_cast<FrameLoaderClientQt*>(document->frame()->loader()->client())->webFrame();
-    QWebPage* page = frame->page();
+    Frame *frame = document->frame();
+    if (!frame)
+        return String();
+    FrameLoader *loader = frame->loader();
+    if (!loader)
+        return String();
+    QWebFrame* webFrame = static_cast<FrameLoaderClientQt*>(loader->client())->webFrame();
+    QWebPage* page = webFrame->page();
     QNetworkAccessManager* manager = page->networkAccessManager();
     QNetworkCookieJar* jar = manager->cookieJar();