Skip to content
Permalink
Browse files
[Qt] better test coverage for ErrorPageExtension
https://bugs.webkit.org/show_bug.cgi?id=31583

Reviewed by Kenneth Christiansen.

Improved the coverage of current ErrorPageExtension tests by
adding autotests involving frameset and iframes.

* tests/qwebpage/tst_qwebpage.cpp:
(ErrorPage::extension): Make the ErrorPageExtension
to work for all frames, not only the main frame.
(tst_QWebPage::errorPageExtension): Stop using
the 'frameset.html' resouce in this method since
an autotest specific for frameset's is being added.
(tst_QWebPage::errorPageExtensionInIFrames): Added.
(tst_QWebPage::errorPageExtensionInFrameset): Added.

Canonical link: https://commits.webkit.org/42505@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@51076 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Antonio Gomes committed Nov 17, 2009
1 parent 8833cdd commit b5d9d54dbdfd404a6e99d62f41a91e86f574647f
Showing with 56 additions and 9 deletions.
  1. +19 −0 WebKit/qt/ChangeLog
  2. +37 −9 WebKit/qt/tests/qwebpage/tst_qwebpage.cpp
@@ -1,3 +1,22 @@
2009-11-17 Antonio Gomes <tonikitoo@webkit.org>

Reviewed by Kenneth Christiansen.

[Qt] better test coverage for ErrorPageExtension
https://bugs.webkit.org/show_bug.cgi?id=31583

Improved the coverage of current ErrorPageExtension tests by
adding autotests involving frameset and iframes.

* tests/qwebpage/tst_qwebpage.cpp:
(ErrorPage::extension): Make the ErrorPageExtension
to work for all frames, not only the main frame.
(tst_QWebPage::errorPageExtension): Stop using
the 'frameset.html' resouce in this method since
an autotest specific for frameset's is being added.
(tst_QWebPage::errorPageExtensionInIFrames): Added.
(tst_QWebPage::errorPageExtensionInFrameset): Added.

2009-11-16 Simon Hausmann <simon.hausmann@nokia.com>

Reviewed by Kenneth Rohde Christiansen.
@@ -147,6 +147,8 @@ private slots:
void inputMethods();
void defaultTextEncoding();
void errorPageExtension();
void errorPageExtensionInIFrames();
void errorPageExtensionInFrameset();

void crashTests_LazyInitializationOfMainFrame();

@@ -1629,12 +1631,8 @@ class ErrorPage : public QWebPage
const ErrorPageExtensionOption* info = static_cast<const ErrorPageExtensionOption*>(option);
ErrorPageExtensionReturn* errorPage = static_cast<ErrorPageExtensionReturn*>(output);

if (info->frame == mainFrame()) {
errorPage->content = "data:text/html,error";
return true;
}

return false;
errorPage->content = "data:text/html,error";
return true;
}
};

@@ -1645,11 +1643,10 @@ void tst_QWebPage::errorPageExtension()

QSignalSpy spyLoadFinished(m_view, SIGNAL(loadFinished(bool)));

page->mainFrame()->load(QUrl("qrc:///frametest/index.html"));
m_view->setUrl(QUrl("data:text/html,foo"));
QTRY_COMPARE(spyLoadFinished.count(), 1);

page->mainFrame()->setUrl(QUrl("http://non.existent/url"));
QTest::qWait(2000);
QTRY_COMPARE(spyLoadFinished.count(), 2);
QCOMPARE(page->mainFrame()->toPlainText(), QString("data:text/html,error"));
QCOMPARE(page->history()->count(), 2);
@@ -1671,7 +1668,38 @@ void tst_QWebPage::errorPageExtension()
QTest::qWait(2000);
QCOMPARE(page->history()->canGoBack(), false);
QCOMPARE(page->history()->canGoForward(), true);
QCOMPARE(page->history()->currentItem().url(), QUrl("qrc:///frametest/index.html"));
QCOMPARE(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);

m_view->setHtml(QString("data:text/html,"
"<h1>h1</h1>"
"<iframe src='data:text/html,<p/>p'></iframe>"
"<iframe src='non-existent.html'></iframe>"));
QSignalSpy spyLoadFinished(m_view, SIGNAL(loadFinished(bool)));
QTRY_COMPARE(spyLoadFinished.count(), 1);

QCOMPARE(page->mainFrame()->childFrames()[1]->toPlainText(), QString("data:text/html,error"));

m_view->setPage(0);
}

void tst_QWebPage::errorPageExtensionInFrameset()
{
ErrorPage* page = new ErrorPage;
m_view->setPage(page);

m_view->load(QUrl("qrc:///frametest/index.html"));

QSignalSpy spyLoadFinished(m_view, SIGNAL(loadFinished(bool)));
QTRY_COMPARE(spyLoadFinished.count(), 1);
QCOMPARE(page->mainFrame()->childFrames()[1]->toPlainText(), QString("data:text/html,error"));

m_view->setPage(0);
}

0 comments on commit b5d9d54

Please sign in to comment.