Commit a084505e authored by eric@webkit.org's avatar eric@webkit.org

2010-05-29 Dawit Alemayehu <adawit@kde.org>

        Reviewed by Kenneth Rohde Christiansen.

        Added a WebAction to stop all pending page refresh/redirect
        requests set through the <meta http-equiv="refresh"...> tag.

        https://bugs.webkit.org/show_bug.cgi?id=29899

        * Api/qwebpage.cpp:
        (QWebPage::triggerAction):
        * Api/qwebpage.h:
        * tests/qwebpage/tst_qwebpage.cpp:
        (tst_QWebPage::testStopScheduledPageRefresh):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@60410 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 98eba819
......@@ -1578,6 +1578,7 @@ InspectorController* QWebPagePrivate::inspectorController()
\value Back Navigate back in the history of navigated links.
\value Forward Navigate forward in the history of navigated links.
\value Stop Stop loading the current page.
\value StopScheduledPageRefresh Stop all pending page refresh/redirect requests.
\value Reload Reload the current page.
\value ReloadAndBypassCache Reload the current page, but do not use any local cache. (Added in Qt 4.6)
\value Cut Cut the content currently selected into the clipboard.
......@@ -1983,6 +1984,15 @@ static void openNewWindow(const QUrl& url, WebCore::Frame* frame)
}
}
static void collectChildFrames(QWebFrame* frame, QList<QWebFrame*>& list)
{
list << frame->childFrames();
QListIterator<QWebFrame*> it(frame->childFrames());
while (it.hasNext()) {
collectChildFrames(it.next(), list);
}
}
/*!
This function can be called to trigger the specified \a action.
It is also called by QtWebKit if the user triggers the action, for example
......@@ -2079,6 +2089,16 @@ void QWebPage::triggerAction(WebAction action, bool)
#endif
break;
}
case StopScheduledPageRefresh: {
QWebFrame* topFrame = mainFrame();
topFrame->d->frame->redirectScheduler()->cancel();
QList<QWebFrame*> childFrames;
collectChildFrames(topFrame, childFrames);
QListIterator<QWebFrame*> it(childFrames);
while (it.hasNext())
it.next()->d->frame->redirectScheduler()->cancel();
break;
}
default:
command = QWebPagePrivate::editorCommandForWebActions(action);
break;
......
......@@ -170,6 +170,8 @@ public:
AlignLeft,
AlignRight,
StopScheduledPageRefresh,
WebActionCount
};
......
2010-05-29 Dawit Alemayehu <adawit@kde.org>
Reviewed by Kenneth Rohde Christiansen.
Added a WebAction to stop all pending page refresh/redirect
requests set through the <meta http-equiv="refresh"...> tag.
https://bugs.webkit.org/show_bug.cgi?id=29899
* Api/qwebpage.cpp:
(QWebPage::triggerAction):
* Api/qwebpage.h:
* tests/qwebpage/tst_qwebpage.cpp:
(tst_QWebPage::testStopScheduledPageRefresh):
2010-05-28 Antti Koivisto <koivisto@iki.fi>
Reviewed by Kenneth Rohde Christiansen.
......
......@@ -122,7 +122,8 @@ private slots:
void originatingObjectInNetworkRequests();
void testJSPrompt();
void showModalDialog();
void testStopScheduledPageRefresh();
private:
QWebView* m_view;
QWebPage* m_page;
......@@ -2090,5 +2091,30 @@ void tst_QWebPage::showModalDialog()
QCOMPARE(res, QString("This is a test"));
}
void tst_QWebPage::testStopScheduledPageRefresh()
{
// Without QWebPage::StopScheduledPageRefresh
QWebPage page1;
page1.setNetworkAccessManager(new TestNetworkManager(&page1));
page1.mainFrame()->setHtml("<html><head>"
"<meta http-equiv=\"refresh\"content=\"0;URL=http://qt.nokia.com/favicon.ico\">"
"</head><body><h1>Page redirects immediately...</h1>"
"</body></html>");
QVERIFY(::waitForSignal(&page1, SIGNAL(loadFinished(bool))));
QTest::qWait(500);
QCOMPARE(page1.mainFrame()->url().toString(), QString("http://qt.nokia.com/favicon.ico"));
// With QWebPage::StopScheduledPageRefresh
QWebPage page2;
page2.setNetworkAccessManager(new TestNetworkManager(&page2));
page2.mainFrame()->setHtml("<html><head>"
"<meta http-equiv=\"refresh\"content=\"1;URL=http://qt.nokia.com/favicon.ico\">"
"</head><body><h1>Page redirect test with 1 sec timeout...</h1>"
"</body></html>");
page2.triggerAction(QWebPage::StopScheduledPageRefresh);
QTest::qWait(1500);
QCOMPARE(page2.mainFrame()->url().toString(), QString("about:blank"));
}
QTEST_MAIN(tst_QWebPage)
#include "tst_qwebpage.moc"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment