1
0
Fork 0
mirror of https://github.com/thoughtbot/capybara-webkit synced 2023-03-27 23:22:28 -04:00
capybara-webkit/src/WebPage.h

110 lines
3.9 KiB
C
Raw Normal View History

2012-03-26 18:41:33 -04:00
#ifndef _WEBPAGE_H
#define _WEBPAGE_H
2013-01-06 22:05:41 -05:00
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
#include <QtWebKitWidgets>
#else
2011-02-18 22:53:06 -05:00
#include <QtWebKit>
2013-01-06 22:05:41 -05:00
#endif
#include <QtNetwork>
2011-02-18 22:53:06 -05:00
class WebPageManager;
2013-01-20 18:57:04 -05:00
class InvocationResult;
class NetworkReplyProxy;
class QWebView;
2011-02-18 22:53:06 -05:00
class WebPage : public QWebPage {
Q_OBJECT
public:
WebPage(WebPageManager *, QObject *parent = 0);
InvocationResult invokeCapybaraFunction(const char *name, bool allowUnattached, const QStringList &arguments);
InvocationResult invokeCapybaraFunction(QString &name, bool allowUnattached, const QStringList &arguments);
QString failureString();
2011-06-08 05:36:45 -04:00
QString userAgentForUrl(const QUrl &url ) const;
void setUserAgent(QString userAgent);
void setConfirmAction(QString action);
QString setConfirmAction(QString action, QString message);
QString setPromptAction(QString action, QString message, QString response);
QString setPromptAction(QString action, QString message);
void setPromptAction(QString action);
void setPromptText(QString action);
QString acceptAlert(QString);
2011-08-12 16:50:43 -04:00
int getLastStatus();
2011-08-23 11:18:08 -04:00
void setCustomNetworkAccessManager();
bool render(const QString &fileName, const QSize &minimumSize);
virtual bool extension (Extension extension, const ExtensionOption *option=0, ExtensionReturn *output=0);
void setSkipImageLoading(bool skip);
QVariantList consoleMessages();
2012-12-30 14:41:23 -05:00
QVariantList alertMessages();
QVariantList confirmMessages();
2012-12-30 15:04:44 -05:00
QVariantList promptMessages();
void createWindow();
2013-04-25 23:00:21 -04:00
void resetLocalStorage();
2012-03-26 18:41:33 -04:00
QWebPage *createWindow(WebWindowType type);
QString uuid();
2012-03-28 11:46:07 -04:00
QString getWindowName();
bool matchesWindowSelector(QString);
void setFocus();
void unsupportedContentFinishedReply(QNetworkReply *reply);
QStringList pageHeaders();
QByteArray body();
QString contentType();
void mouseEvent(QEvent::Type type, const QPoint &position, Qt::MouseButton button);
bool clickTest(QWebElement element, int absoluteX, int absoluteY);
void resize(int, int);
int modalCount();
QString modalMessage(int);
2011-02-18 22:53:06 -05:00
public slots:
bool shouldInterruptJavaScript();
void injectJavascriptHelpers();
void loadStarted();
void loadFinished(bool);
bool isLoading() const;
void frameCreated(QWebFrame *);
void handleSslErrorsForReply(QNetworkReply *reply, const QList<QSslError> &);
void handleUnsupportedContent(QNetworkReply *reply);
void replyFinished(QUrl &, QNetworkReply *);
void remove();
signals:
void pageFinished(bool);
2012-07-11 23:36:22 -04:00
void requestCreated(QByteArray &url, QNetworkReply *reply);
2012-06-29 10:41:08 -04:00
void replyFinished(QNetworkReply *reply);
2011-02-26 13:02:43 -05:00
protected:
virtual void javaScriptConsoleMessage(const QString &message, int lineNumber, const QString &sourceID);
virtual void javaScriptAlert(QWebFrame *frame, const QString &message);
virtual bool javaScriptConfirm(QWebFrame *frame, const QString &message);
virtual bool javaScriptPrompt(QWebFrame *frame, const QString &message, const QString &defaultValue, QString *result);
2011-07-18 17:16:57 -04:00
virtual QString chooseFile(QWebFrame * parentFrame, const QString &suggestedFile);
virtual bool supportsExtension(Extension extension) const;
2011-02-26 13:02:43 -05:00
private:
QString m_capybaraJavascript;
QString m_userAgent;
bool m_loading;
bool m_failed;
2012-11-18 02:48:24 -05:00
QStringList getAttachedFileNames();
2011-08-12 15:49:40 -04:00
void loadJavascript();
void setUserStylesheet();
bool m_confirmAction;
bool m_promptAction;
QVariantList m_consoleMessages;
2012-12-30 14:41:23 -05:00
QVariantList m_alertMessages;
QVariantList m_confirmMessages;
QString m_prompt_text;
2012-12-30 15:04:44 -05:00
QVariantList m_promptMessages;
QString m_uuid;
WebPageManager *m_manager;
QString m_errorPageMessage;
void setFrameProperties(QWebFrame *, QUrl &, NetworkReplyProxy *);
QPoint m_mousePosition;
QList<QVariantMap> m_modalResponses;
QStringList m_modalMessages;
void addModalMessage(bool, const QString &, const QRegExp &);
2011-02-18 22:53:06 -05:00
};
2012-03-26 18:41:33 -04:00
#endif //_WEBPAGE_H