[Qt] Fix leak of QWebPage in errorPageExtension tests
authorcaio.oliveira@openbossa.org <caio.oliveira@openbossa.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 19 Jul 2011 21:31:17 +0000 (21:31 +0000)
committercaio.oliveira@openbossa.org <caio.oliveira@openbossa.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 19 Jul 2011 21:31:17 +0000 (21:31 +0000)
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):

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

Source/WebKit/qt/ChangeLog
Source/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp

index 8248be5..0059cd0 100644 (file)
@@ -1,3 +1,18 @@
+2011-07-19  Caio Marcelo de Oliveira Filho  <caio.oliveira@openbossa.org>
+
+        [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  <hui.2.huang@nokia.com>
 
         [Qt] Compiling error in Source/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp with Qt 4.7 or older
index b269fda..a6baa64 100644 (file)
@@ -2511,42 +2511,42 @@ public:
 
 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 @@ void tst_QWebPage::errorPageExtensionInIFrames()
     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);
 }