summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp')
-rw-r--r--src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp50
1 files changed, 49 insertions, 1 deletions
diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp b/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp
index 1d6a48e7b2..6c3b296abc 100644
--- a/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp
+++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp
@@ -92,6 +92,7 @@ private slots:
void cleanupTestCase();
void acceptNavigationRequest();
+ void infiniteLoopJS();
void loadFinished();
void acceptNavigationRequestWithNewWindow();
void userStyleSheet();
@@ -106,7 +107,7 @@ private slots:
void textSelection();
void textEditing();
void backActionUpdate();
-
+ void frameAt();
void requestCache();
private:
@@ -192,6 +193,26 @@ void tst_QWebPage::acceptNavigationRequest()
m_view->setPage(0);
}
+class JSTestPage : public QWebPage
+{
+Q_OBJECT
+public:
+ JSTestPage(QObject* parent = 0)
+ : QWebPage(parent) {}
+
+public slots:
+ bool shouldInterruptJavaScript() {
+ return true;
+ }
+};
+
+void tst_QWebPage::infiniteLoopJS()
+{
+ JSTestPage* newPage = new JSTestPage(m_view);
+ m_view->setPage(newPage);
+ m_view->setHtml(QString("<html><bodytest</body></html>"), QUrl());
+ m_view->page()->mainFrame()->evaluateJavaScript("var run = true;var a = 1;while(run){a++;}");
+}
void tst_QWebPage::loadFinished()
{
@@ -1116,5 +1137,32 @@ void tst_QWebPage::backActionUpdate()
QVERIFY(action->isEnabled());
}
+void frameAtHelper(QWebPage* webPage, QWebFrame* webFrame, QPoint framePosition)
+{
+ if (!webFrame)
+ return;
+
+ framePosition += QPoint(webFrame->pos());
+ QList<QWebFrame*> children = webFrame->childFrames();
+ for (int i = 0; i < children.size(); ++i) {
+ if (children.at(i)->childFrames().size() > 0)
+ frameAtHelper(webPage, children.at(i), framePosition);
+
+ QRect frameRect(children.at(i)->pos() + framePosition, children.at(i)->geometry().size());
+ QVERIFY(children.at(i) == webPage->frameAt(frameRect.topLeft()));
+ }
+}
+
+void tst_QWebPage::frameAt()
+{
+ QWebView webView;
+ QWebPage* webPage = webView.page();
+ QSignalSpy loadSpy(webPage, SIGNAL(loadFinished(bool)));
+ QUrl url = QUrl("qrc:///frametest/iframe.html");
+ webPage->mainFrame()->load(url);
+ QTRY_COMPARE(loadSpy.count(), 1);
+ frameAtHelper(webPage, webPage->mainFrame(), webPage->mainFrame()->pos());
+}
+
QTEST_MAIN(tst_QWebPage)
#include "tst_qwebpage.moc"