From 7c6db7b036dad16d4740a43b7fb1e8e9a2785cc1 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Tue, 3 May 2011 11:06:49 -0400 Subject: [PATCH] begin making javascript interactive elements work headless --- ext/jasmine-webkit-specrunner/specrunner.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ext/jasmine-webkit-specrunner/specrunner.cpp b/ext/jasmine-webkit-specrunner/specrunner.cpp index 939b59e..b0f78d6 100644 --- a/ext/jasmine-webkit-specrunner/specrunner.cpp +++ b/ext/jasmine-webkit-specrunner/specrunner.cpp @@ -36,6 +36,8 @@ signals: void consoleLog(const QString &msg, int lineNumber, const QString &sourceID); protected: void javaScriptConsoleMessage(const QString & message, int lineNumber, const QString & sourceID); + bool javaScriptConfirm(QWebFrame *frame, const QString &msg); + void javaScriptAlert(QWebFrame *frame, const QString &msg); }; void HeadlessSpecRunnerPage::javaScriptConsoleMessage(const QString &message, int lineNumber, const QString &sourceID) @@ -43,6 +45,19 @@ void HeadlessSpecRunnerPage::javaScriptConsoleMessage(const QString &message, in emit consoleLog(message, lineNumber, sourceID); } +bool HeadlessSpecRunnerPage::javaScriptConfirm(QWebFrame *frame, const QString &msg) +{ + std::cout << "[TODO] "; + std::cout << "jasmine-headless-webkit can't handle confirm() yet! You should mock window.confirm for now. Returning true." << std::endl; + return true; +} + +void HeadlessSpecRunnerPage::javaScriptAlert(QWebFrame *frame, const QString &msg) +{ + std::cout << "[alert] "; + std::cout << qPrintable(msg) << std::endl; +} + class HeadlessSpecRunner: public QObject { Q_OBJECT