Commit a5f4a612 authored by zeno.albisser@digia.com's avatar zeno.albisser@digia.com
Browse files

[Qt] Remove Qt specific WorkQueueItem definitions.

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

This patch is preparation work for removing
WorkQueue related code from TestRunnerQt and
replacing it with generic TestRunner code.

Reviewed by Benjamin Poulain.

Source/JavaScriptCore:

* API/JSStringRefQt.cpp:
(JSStringCreateWithQString):
    Adding a convenience function to create a
    JSStringRef from a QString.
* API/JSStringRefQt.h:

Tools:

* DumpRenderTree/qt/TestRunnerQt.cpp:
(TestRunnerQt::queueBackNavigation):
(TestRunnerQt::queueForwardNavigation):
(TestRunnerQt::queueLoadHTMLString):
(TestRunnerQt::queueReload):
(TestRunnerQt::queueLoadingScript):
(TestRunnerQt::queueNonLoadingScript):
(TestRunner::queueLoad):
* DumpRenderTree/qt/TestRunnerQt.h:
(TestRunnerQt):
* DumpRenderTree/qt/WorkQueueItemQt.cpp:
(LoadItem::invoke):
(LoadHTMLStringItem::invoke):
(LoadAlternateHTMLStringItem::invoke):
(ReloadItem::invoke):
(ScriptItem::invoke):
(BackForwardItem::invoke):
* DumpRenderTree/qt/WorkQueueItemQt.h:
(LoadAlternateHTMLStringItem::LoadAlternateHTMLStringItem):
(LoadAlternateHTMLStringItem):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@146976 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 7f65ba38
......@@ -38,3 +38,13 @@ QString JSStringCopyQString(JSStringRef string)
{
return string->qString();
}
JSRetainPtr<JSStringRef> JSStringCreateWithQString(const QString& qString)
{
RefPtr<OpaqueJSString> jsString = OpaqueJSString::create(qString);
if (jsString)
return JSRetainPtr<JSStringRef>(Adopt, jsString.release().leakRef());
return JSRetainPtr<JSStringRef>(Adopt, OpaqueJSString::create().leakRef());
}
......@@ -28,6 +28,7 @@
#define JSStringRefQt_h
#include "JSBase.h"
#include "JSRetainPtr.h"
#include <QString>
/* QString convenience methods */
......@@ -39,5 +40,6 @@
@result A QString containing string.
*/
JS_EXPORT QString JSStringCopyQString(JSStringRef string);
JS_EXPORT JSRetainPtr<JSStringRef> JSStringCreateWithQString(const QString&);
#endif /* JSStringRefQt_h */
2013-03-27 Zeno Albisser <zeno@webkit.org>
[Qt] Remove Qt specific WorkQueueItem definitions.
https://bugs.webkit.org/show_bug.cgi?id=112891
This patch is preparation work for removing
WorkQueue related code from TestRunnerQt and
replacing it with generic TestRunner code.
Reviewed by Benjamin Poulain.
* API/JSStringRefQt.cpp:
(JSStringCreateWithQString):
Adding a convenience function to create a
JSStringRef from a QString.
* API/JSStringRefQt.h:
2013-03-26 Filip Pizlo <fpizlo@apple.com>
 
REGRESSION: Sometimes, operations on proven strings ignore changes to the string prototype
......
2013-03-27 Zeno Albisser <zeno@webkit.org>
[Qt] Remove Qt specific WorkQueueItem definitions.
https://bugs.webkit.org/show_bug.cgi?id=112891
This patch is preparation work for removing
WorkQueue related code from TestRunnerQt and
replacing it with generic TestRunner code.
Reviewed by Benjamin Poulain.
* DumpRenderTree/qt/TestRunnerQt.cpp:
(TestRunnerQt::queueBackNavigation):
(TestRunnerQt::queueForwardNavigation):
(TestRunnerQt::queueLoadHTMLString):
(TestRunnerQt::queueReload):
(TestRunnerQt::queueLoadingScript):
(TestRunnerQt::queueNonLoadingScript):
(TestRunner::queueLoad):
* DumpRenderTree/qt/TestRunnerQt.h:
(TestRunnerQt):
* DumpRenderTree/qt/WorkQueueItemQt.cpp:
(LoadItem::invoke):
(LoadHTMLStringItem::invoke):
(LoadAlternateHTMLStringItem::invoke):
(ReloadItem::invoke):
(ScriptItem::invoke):
(BackForwardItem::invoke):
* DumpRenderTree/qt/WorkQueueItemQt.h:
(LoadAlternateHTMLStringItem::LoadAlternateHTMLStringItem):
(LoadAlternateHTMLStringItem):
2013-03-26 Julie Parent <jparent@chromium.org>
 
Flakiness dashboard: simplify logic around which tests to show.
......@@ -331,48 +331,40 @@ void TestRunnerQt::queueBackNavigation(int howFarBackward)
{
//qDebug() << ">>>queueBackNavigation" << howFarBackward;
for (int i = 0; i != howFarBackward; ++i)
WorkQueue::shared()->queue(new BackItem(1, m_drt->webPage()));
WorkQueue::shared()->queue(new BackItem(1));
}
void TestRunnerQt::queueForwardNavigation(int howFarForward)
{
//qDebug() << ">>>queueForwardNavigation" << howFarForward;
for (int i = 0; i != howFarForward; ++i)
WorkQueue::shared()->queue(new ForwardItem(1, m_drt->webPage()));
}
void TestRunnerQt::queueLoad(const QString& url, const QString& target)
{
//qDebug() << ">>>queueLoad" << url << target;
QUrl mainResourceUrl = m_drt->webPage()->mainFrame()->url();
QString absoluteUrl = mainResourceUrl.resolved(QUrl(url)).toEncoded();
WorkQueue::shared()->queue(new LoadItem(absoluteUrl, target, m_drt->webPage()));
WorkQueue::shared()->queue(new ForwardItem(1));
}
void TestRunnerQt::queueLoadHTMLString(const QString& content, const QString& baseURL, const QString& failingURL)
{
if (failingURL.isEmpty())
WorkQueue::shared()->queue(new LoadHTMLStringItem(content, baseURL, m_drt->webPage()));
WorkQueue::shared()->queue(new LoadHTMLStringItem(JSStringCreateWithQString(content).get(), JSStringCreateWithQString(baseURL).get()));
else
WorkQueue::shared()->queue(new LoadAlternateHTMLStringItem(content, baseURL, failingURL, m_drt->webPage()));
WorkQueue::shared()->queue(new LoadAlternateHTMLStringItem(JSStringCreateWithQString(content), JSStringCreateWithQString(baseURL), JSStringCreateWithQString(failingURL)));
}
void TestRunnerQt::queueReload()
{
//qDebug() << ">>>queueReload";
WorkQueue::shared()->queue(new ReloadItem(m_drt->webPage()));
WorkQueue::shared()->queue(new ReloadItem());
}
void TestRunnerQt::queueLoadingScript(const QString& script)
{
//qDebug() << ">>>queueLoadingScript" << script;
WorkQueue::shared()->queue(new LoadingScriptItem(script, m_drt->webPage()));
WorkQueue::shared()->queue(new LoadingScriptItem(JSStringCreateWithQString(script).get()));
}
void TestRunnerQt::queueNonLoadingScript(const QString& script)
{
//qDebug() << ">>>queueNonLoadingScript" << script;
WorkQueue::shared()->queue(new NonLoadingScriptItem(script, m_drt->webPage()));
WorkQueue::shared()->queue(new NonLoadingScriptItem(JSStringCreateWithQString(script).get()));
}
void TestRunnerQt::provisionalLoad()
......@@ -829,6 +821,10 @@ void TestRunner::addDisallowedURL(JSStringRef url)
void TestRunner::queueLoad(JSStringRef url, JSStringRef target)
{
DumpRenderTree* drt = DumpRenderTree::instance();
QUrl mainResourceUrl = drt->webPage()->mainFrame()->url();
QString absoluteUrl = mainResourceUrl.resolved(QUrl(JSStringCopyQString(url))).toEncoded();
WorkQueue::shared()->queue(new LoadItem(JSStringCreateWithQString(absoluteUrl).get(), target));
}
void TestRunner::removeAllVisitedLinks()
......
......@@ -107,7 +107,6 @@ public Q_SLOTS:
void setWillSendRequestClearHeader(const QStringList& headers);
void queueBackNavigation(int howFarBackward);
void queueForwardNavigation(int howFarForward);
void queueLoad(const QString& url, const QString& target = QString());
void queueLoadHTMLString(const QString& content, const QString& baseURL = QString(), const QString& failingURL = QString());
void queueReload();
void queueLoadingScript(const QString& script);
......
......@@ -28,7 +28,10 @@
*/
#include "config.h"
#include "WorkQueueItemQt.h"
#include "DumpRenderTreeQt.h"
#include "DumpRenderTreeSupportQt.h"
#include "JSStringRefQt.h"
QWebFrame* findFrameNamed(const QString& frameName, QWebFrame* frame)
{
......@@ -45,75 +48,80 @@ QWebFrame* findFrameNamed(const QString& frameName, QWebFrame* frame)
bool LoadItem::invoke() const
{
//qDebug() << ">>>LoadItem::invoke";
Q_ASSERT(m_webPage);
WebPage* webPage = DumpRenderTree::instance()->webPage();
Q_ASSERT(webPage);
QWebFrame* frame = 0;
const QString t = target();
if (t.isEmpty())
frame = m_webPage->mainFrame();
if (JSStringGetLength(m_target.get()))
frame = findFrameNamed(JSStringCopyQString(m_target.get()), webPage->mainFrame());
else
frame = findFrameNamed(t, m_webPage->mainFrame());
frame = webPage->mainFrame();
if (!frame)
return false;
frame->load(url());
frame->load(QUrl(JSStringCopyQString(m_url.get())));
return true;
}
bool LoadHTMLStringItem::invoke() const
{
Q_ASSERT(m_webPage);
WebPage* webPage = DumpRenderTree::instance()->webPage();
Q_ASSERT(webPage);
QWebFrame* frame = m_webPage->mainFrame();
QWebFrame* frame = webPage->mainFrame();
if (!frame)
return false;
frame->setHtml(m_content, QUrl(m_baseURL));
frame->setHtml(JSStringCopyQString(m_content.get()), QUrl(JSStringCopyQString(m_baseURL.get())));
return true;
}
bool LoadAlternateHTMLStringItem::invoke() const
{
Q_ASSERT(m_webPage);
WebPage* webPage = DumpRenderTree::instance()->webPage();
Q_ASSERT(webPage);
QWebFrame* frame = m_webPage->mainFrame();
QWebFrame* frame = webPage->mainFrame();
if (!frame)
return false;
DumpRenderTreeSupportQt::setAlternateHtml(frame->handle(), m_content, QUrl(m_baseURL), QUrl(m_failingURL));
DumpRenderTreeSupportQt::setAlternateHtml(frame->handle(), JSStringCopyQString(m_content.get()), QUrl(JSStringCopyQString(m_baseURL.get())), QUrl(JSStringCopyQString(m_failingURL.get())));
return true;
}
bool ReloadItem::invoke() const
{
//qDebug() << ">>>ReloadItem::invoke";
Q_ASSERT(m_webPage);
m_webPage->triggerAction(QWebPage::Reload);
WebPage* webPage = DumpRenderTree::instance()->webPage();
Q_ASSERT(webPage);
webPage->triggerAction(QWebPage::Reload);
return true;
}
bool ScriptItem::invoke() const
{
//qDebug() << ">>>ScriptItem::invoke";
Q_ASSERT(m_webPage);
m_webPage->mainFrame()->evaluateJavaScript(script());
WebPage* webPage = DumpRenderTree::instance()->webPage();
Q_ASSERT(webPage);
webPage->mainFrame()->evaluateJavaScript(JSStringCopyQString(m_script.get()));
return true;
}
bool BackForwardItem::invoke() const
{
//qDebug() << ">>>BackForwardItem::invoke";
Q_ASSERT(m_webPage);
WebPage* webPage = DumpRenderTree::instance()->webPage();
Q_ASSERT(webPage);
if (!m_howFar)
return false;
if (m_howFar > 0) {
for (int i = 0; i != m_howFar; ++i)
m_webPage->triggerAction(QWebPage::Forward);
webPage->triggerAction(QWebPage::Forward);
} else {
for (int i = 0; i != m_howFar; --i)
m_webPage->triggerAction(QWebPage::Back);
webPage->triggerAction(QWebPage::Back);
}
return true;
}
......@@ -30,61 +30,14 @@
#ifndef WorkQueueItemQt_h
#define WorkQueueItemQt_h
#include <QPointer>
#include <QString>
#include "WorkQueueItem.h"
#include <qwebframe.h>
#include <qwebpage.h>
class WorkQueueItem {
public:
WorkQueueItem(QWebPage *page) : m_webPage(page) {}
virtual ~WorkQueueItem() { }
virtual bool invoke() const = 0;
protected:
QPointer<QWebPage> m_webPage;
};
class LoadItem : public WorkQueueItem {
public:
LoadItem(const QString &url, const QString &target, QWebPage *page)
: WorkQueueItem(page)
, m_url(url)
, m_target(target)
{
}
QString url() const { return m_url; }
QString target() const { return m_target; }
virtual bool invoke() const;
private:
QString m_url;
QString m_target;
};
class LoadHTMLStringItem : public WorkQueueItem {
public:
LoadHTMLStringItem(const QString& content, const QString &baseURL, QWebPage *page)
: WorkQueueItem(page)
, m_content(content)
, m_baseURL(baseURL)
{
}
private:
virtual bool invoke() const;
QString m_content;
QString m_baseURL;
};
class LoadAlternateHTMLStringItem : public WorkQueueItem {
public:
LoadAlternateHTMLStringItem(const QString& content, const QString& baseURL, const QString &failingURL, QWebPage *page)
: WorkQueueItem(page)
, m_content(content)
LoadAlternateHTMLStringItem(const JSRetainPtr<JSStringRef>& content, const JSRetainPtr<JSStringRef>& baseURL, const JSRetainPtr<JSStringRef>& failingURL)
: m_content(content)
, m_baseURL(baseURL)
, m_failingURL(failingURL)
{
......@@ -93,85 +46,9 @@ public:
private:
virtual bool invoke() const;
QString m_content;
QString m_baseURL;
QString m_failingURL;
};
class ReloadItem : public WorkQueueItem {
public:
ReloadItem(QWebPage *page)
: WorkQueueItem(page)
{
}
virtual bool invoke() const;
};
class ScriptItem : public WorkQueueItem {
public:
ScriptItem(const QString &script, QWebPage *page)
: WorkQueueItem(page)
, m_script(script)
{
}
QString script() const { return m_script; }
virtual bool invoke() const;
private:
QString m_script;
};
class LoadingScriptItem : public ScriptItem {
public:
LoadingScriptItem(const QString& script, QWebPage* page)
: ScriptItem(script, page)
{
}
virtual bool invoke() const { return ScriptItem::invoke(); }
};
class NonLoadingScriptItem : public ScriptItem {
public:
NonLoadingScriptItem(const QString& script, QWebPage* page)
: ScriptItem(script, page)
{
}
virtual bool invoke() const { ScriptItem::invoke(); return false; }
};
class BackForwardItem : public WorkQueueItem {
public:
virtual bool invoke() const;
protected:
BackForwardItem(int howFar, QWebPage *page)
: WorkQueueItem(page)
, m_howFar(howFar)
{
}
int m_howFar;
};
class BackItem : public BackForwardItem {
public:
BackItem(unsigned howFar, QWebPage *page)
: BackForwardItem(-howFar, page)
{
}
};
class ForwardItem : public BackForwardItem {
public:
ForwardItem(unsigned howFar, QWebPage *page)
: BackForwardItem(howFar, page)
{
}
JSRetainPtr<JSStringRef> m_content;
JSRetainPtr<JSStringRef> m_baseURL;
JSRetainPtr<JSStringRef> m_failingURL;
};
#endif // !defined(WorkQueueItemQt_h)
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