Title: [91302] trunk/Source/WebKit/qt
Revision
91302
Author
[email protected]
Date
2011-07-19 14:31:17 -0700 (Tue, 19 Jul 2011)

Log Message

[Qt] Fix leak of QWebPage in errorPageExtension tests
https://bugs.webkit.org/show_bug.cgi?id=64814

Reviewed by Noam Rosenthal.

QWebView::setPage() doesn't take ownership, so the ErrorPages were leaking. So now
allocate them on the stack. This shouldn't change any behavior.

* tests/qwebpage/tst_qwebpage.cpp:
(tst_QWebPage::errorPageExtension):
(tst_QWebPage::errorPageExtensionInIFrames):
(tst_QWebPage::errorPageExtensionInFrameset):

Modified Paths

Diff

Modified: trunk/Source/WebKit/qt/ChangeLog (91301 => 91302)


--- trunk/Source/WebKit/qt/ChangeLog	2011-07-19 21:22:23 UTC (rev 91301)
+++ trunk/Source/WebKit/qt/ChangeLog	2011-07-19 21:31:17 UTC (rev 91302)
@@ -1,3 +1,18 @@
+2011-07-19  Caio Marcelo de Oliveira Filho  <[email protected]>
+
+        [Qt] Fix leak of QWebPage in errorPageExtension tests
+        https://bugs.webkit.org/show_bug.cgi?id=64814
+
+        Reviewed by Noam Rosenthal.
+
+        QWebView::setPage() doesn't take ownership, so the ErrorPages were leaking. So now
+        allocate them on the stack. This shouldn't change any behavior.
+
+        * tests/qwebpage/tst_qwebpage.cpp:
+        (tst_QWebPage::errorPageExtension):
+        (tst_QWebPage::errorPageExtensionInIFrames):
+        (tst_QWebPage::errorPageExtensionInFrameset):
+
 2011-07-18  Hui Huang  <[email protected]>
 
         [Qt] Compiling error in Source/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp with Qt 4.7 or older

Modified: trunk/Source/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp (91301 => 91302)


--- trunk/Source/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp	2011-07-19 21:22:23 UTC (rev 91301)
+++ trunk/Source/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp	2011-07-19 21:31:17 UTC (rev 91302)
@@ -2511,42 +2511,42 @@
 
 void tst_QWebPage::errorPageExtension()
 {
-    ErrorPage* page = new ErrorPage;
-    m_view->setPage(page);
+    ErrorPage page;
+    m_view->setPage(&page);
 
     QSignalSpy spyLoadFinished(m_view, SIGNAL(loadFinished(bool)));
 
     m_view->setUrl(QUrl("data:text/html,foo"));
     QTRY_COMPARE(spyLoadFinished.count(), 1);
 
-    page->mainFrame()->setUrl(QUrl("http://non.existent/url"));
+    page.mainFrame()->setUrl(QUrl("http://non.existent/url"));
     QTRY_COMPARE(spyLoadFinished.count(), 2);
-    QCOMPARE(page->mainFrame()->toPlainText(), QString("error"));
-    QCOMPARE(page->history()->count(), 2);
-    QCOMPARE(page->history()->currentItem().url(), QUrl("http://non.existent/url"));
-    QCOMPARE(page->history()->canGoBack(), true);
-    QCOMPARE(page->history()->canGoForward(), false);
+    QCOMPARE(page.mainFrame()->toPlainText(), QString("error"));
+    QCOMPARE(page.history()->count(), 2);
+    QCOMPARE(page.history()->currentItem().url(), QUrl("http://non.existent/url"));
+    QCOMPARE(page.history()->canGoBack(), true);
+    QCOMPARE(page.history()->canGoForward(), false);
 
-    page->triggerAction(QWebPage::Back);
-    QTRY_COMPARE(page->history()->canGoBack(), false);
-    QTRY_COMPARE(page->history()->canGoForward(), true);
+    page.triggerAction(QWebPage::Back);
+    QTRY_COMPARE(page.history()->canGoBack(), false);
+    QTRY_COMPARE(page.history()->canGoForward(), true);
 
-    page->triggerAction(QWebPage::Forward);
-    QTRY_COMPARE(page->history()->canGoBack(), true);
-    QTRY_COMPARE(page->history()->canGoForward(), false);
+    page.triggerAction(QWebPage::Forward);
+    QTRY_COMPARE(page.history()->canGoBack(), true);
+    QTRY_COMPARE(page.history()->canGoForward(), false);
 
-    page->triggerAction(QWebPage::Back);
-    QTRY_COMPARE(page->history()->canGoBack(), false);
-    QTRY_COMPARE(page->history()->canGoForward(), true);
-    QTRY_COMPARE(page->history()->currentItem().url(), QUrl("data:text/html,foo"));
+    page.triggerAction(QWebPage::Back);
+    QTRY_COMPARE(page.history()->canGoBack(), false);
+    QTRY_COMPARE(page.history()->canGoForward(), true);
+    QTRY_COMPARE(page.history()->currentItem().url(), QUrl("data:text/html,foo"));
 
     m_view->setPage(0);
 }
 
 void tst_QWebPage::errorPageExtensionInIFrames()
 {
-    ErrorPage* page = new ErrorPage;
-    m_view->setPage(page);
+    ErrorPage page;
+    m_view->setPage(&page);
 
     m_view->page()->mainFrame()->load(QUrl(
         "data:text/html,"
@@ -2556,22 +2556,22 @@
     QSignalSpy spyLoadFinished(m_view, SIGNAL(loadFinished(bool)));
     QTRY_COMPARE(spyLoadFinished.count(), 1);
 
-    QCOMPARE(page->mainFrame()->childFrames()[1]->toPlainText(), QString("error"));
+    QCOMPARE(page.mainFrame()->childFrames()[1]->toPlainText(), QString("error"));
 
     m_view->setPage(0);
 }
 
 void tst_QWebPage::errorPageExtensionInFrameset()
 {
-    ErrorPage* page = new ErrorPage;
-    m_view->setPage(page);
+    ErrorPage page;
+    m_view->setPage(&page);
 
     m_view->load(QUrl("qrc:///resources/index.html"));
 
     QSignalSpy spyLoadFinished(m_view, SIGNAL(loadFinished(bool)));
     QTRY_COMPARE(spyLoadFinished.count(), 1);
-    QCOMPARE(page->mainFrame()->childFrames().count(), 2);
-    QCOMPARE(page->mainFrame()->childFrames()[1]->toPlainText(), QString("error"));
+    QCOMPARE(page.mainFrame()->childFrames().count(), 2);
+    QCOMPARE(page.mainFrame()->childFrames()[1]->toPlainText(), QString("error"));
 
     m_view->setPage(0);
 }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to