[packages/phantomjs] - initial from web

arekm arekm at pld-linux.org
Fri Sep 27 10:30:21 CEST 2013


commit c68333c0cbeaef227b1962f6934db0763b757115
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date:   Fri Sep 27 10:29:50 2013 +0200

    - initial from web

 0001-gifwriter-bgcolor-narrowing.patch |  27 +++
 0002-unbundle-giflib.patch             |  50 ++++++
 0003-unbundle-mongoose.patch           |  48 +++++
 0004-unbundle-breakpad.patch           |  93 ++++++++++
 0005-unbundle-qt.patch                 | 313 +++++++++++++++++++++++++++++++++
 0006-unbundle-linenoise.patch          |  22 +++
 0007-unbundle-QCommandLine.patch       | 124 +++++++++++++
 0008-unbundle-coffee-script.patch      |  62 +++++++
 phantomjs.spec                         |  78 ++++++++
 9 files changed, 817 insertions(+)
---
diff --git a/phantomjs.spec b/phantomjs.spec
new file mode 100644
index 0000000..079b611
--- /dev/null
+++ b/phantomjs.spec
@@ -0,0 +1,78 @@
+Summary:	Headless WebKit with a JavaScript API
+Name:		phantomjs
+Version:	1.9.0
+Release:	1
+License:	BSD
+Group:		Applications/Networking
+URL:		http://phantomjs.org/
+Source0:	http://phantomjs.googlecode.com/files/%{name}-%{version}-source.zip
+# Source0-md5:	a779eb301cac2df9f366be5b2d17cef7
+Patch1:		0001-gifwriter-bgcolor-narrowing.patch
+Patch2:		0002-unbundle-giflib.patch
+Patch3:		0003-unbundle-mongoose.patch
+Patch4:		0004-unbundle-breakpad.patch
+Patch5:		0005-unbundle-qt.patch
+Patch6:		0006-unbundle-linenoise.patch
+Patch7:		0007-unbundle-QCommandLine.patch
+Patch8:		0008-unbundle-coffee-script.patch
+BuildRequires:	QtWebKit-devel
+BuildRequires:	coffee-script
+BuildRequires:	giflib-devel
+BuildRequires:	linenoise-devel
+BuildRequires:	mongoose-devel
+BuildRequires:	qcommandline-devel
+BuildRequires:	unzip
+Requires:	coffee-script
+
+%description
+PhantomJS is a headless WebKit with JavaScript API. It has fast and
+native support for various web standards: DOM handling, CSS selector,
+JSON, Canvas, and SVG. It can be used for screen scraping and web
+testing. It includes an implementation of the WebDriver API.
+
+%prep
+%setup -q
+
+# remove bundled sources
+rm -r src/gif/config.h
+rm -r src/gif/egif_lib.c
+rm -r src/gif/gif_err.c
+rm -r src/gif/gif_hash.c
+rm -r src/gif/gif_hash.h
+rm -r src/gif/gif_lib.h
+rm -r src/gif/gif_lib_private.h
+rm -r src/gif/gifalloc.c
+rm -r src/gif/quantize.c
+rm -r src/mongoose
+rm -r src/qt
+rm -r src/linenoise
+rm -r src/qcommandline
+rm -r src/coffee-script
+
+%patch1 -p1 -b.gifwriter-bgcolor-narrowing
+%patch2 -p1 -b.giflib
+%patch3 -p1 -b.mongoose
+%patch4 -p1 -b.breakpad
+%patch5 -p1 -b.qt
+%patch6 -p1 -b.linenoise
+%patch7 -p1 -b.qcommandline
+%patch8 -p1 -b.coffee-script
+
+%build
+export CFLAGS="%{rpmcflags}"
+qmake-qt4
+%{__make}
+
+%install
+rm -rf $RPM_BUILD_ROOT
+install -d $RPM_BUILD_ROOT%{_bindir}
+
+cp bin/phantomjs $RPM_BUILD_ROOT%{_bindir}/
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%files
+%defattr(644,root,root,755)
+%doc README.md LICENSE.BSD CONTRIBUTING.md ChangeLog examples/
+%attr(755,root,root) %{_bindir}/%{name}
diff --git a/0001-gifwriter-bgcolor-narrowing.patch b/0001-gifwriter-bgcolor-narrowing.patch
new file mode 100644
index 0000000..2fce1f9
--- /dev/null
+++ b/0001-gifwriter-bgcolor-narrowing.patch
@@ -0,0 +1,27 @@
+From e895d93f4c3b758fe8ed5c8e656b2c80b1400d3c Mon Sep 17 00:00:00 2001
+From: Dan Callaghan <dcallagh at redhat.com>
+Date: Fri, 3 Aug 2012 12:21:40 +1000
+Subject: [PATCH 1/8] gifwriter bgcolor narrowing
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+gif/gifwriter.cpp: In function ‘bool exportGif(const QImage&, const QString&)’:
+gif/gifwriter.cpp:109:47: warning: narrowing conversion of ‘bgcolor’ from ‘int’ to ‘char’ inside { } is ill-formed in C++11 [-Wnarrowing]
+
+diff --git a/src/gif/gifwriter.cpp b/src/gif/gifwriter.cpp
+index c0a010c..27c66c7 100644
+--- a/src/gif/gifwriter.cpp
++++ b/src/gif/gifwriter.cpp
+@@ -106,7 +106,7 @@ bool exportGif(const QImage &img, const QString &fileName)
+     gif->ImageCount = 1;
+     EGifPutScreenDesc(gif, image.width(), image.height(), 256, 0, &cmap);
+     if (bgcolor >= 0) {
+-        char extension[] = { 1, 0, 0, bgcolor };
++        unsigned char extension[] = { 1, 0, 0, (unsigned char) bgcolor };
+         EGifPutExtension(gif, GRAPHICS_EXT_FUNC_CODE, 4, extension);
+     }
+     EGifPutImageDesc(gif, 0, 0, image.width(), image.height(), 0, &cmap);
+-- 
+1.7.11.7
+
diff --git a/0002-unbundle-giflib.patch b/0002-unbundle-giflib.patch
new file mode 100644
index 0000000..cb537db
--- /dev/null
+++ b/0002-unbundle-giflib.patch
@@ -0,0 +1,50 @@
+From 85508524373ab559e821466c1b8430a8dc544c85 Mon Sep 17 00:00:00 2001
+From: Dan Callaghan <dcallagh at redhat.com>
+Date: Fri, 3 Aug 2012 12:12:38 +1000
+Subject: [PATCH 2/8] unbundle giflib
+
+
+diff --git a/src/gif/gif.pri b/src/gif/gif.pri
+index e2dd0a8..ad0c951 100644
+--- a/src/gif/gif.pri
++++ b/src/gif/gif.pri
+@@ -1,22 +1,8 @@
+ VPATH += $$PWD
+ INCLUDEPATH += $$PWD
+ 
+-DEFINES += HAVE_CONFIG_H
+-DEFINES += HAVE_FCNTL_H
+-DEFINES += HAVE_STDARG_H
+-!win32-msvc* {
+-    DEFINES += HAVE_STDINT_H
+-    DEFINES += HAVE_UNISTD_H
+-}
++LIBS += -lgif
+ 
+-SOURCES += gif_err.c
+-SOURCES += gifalloc.c
+-SOURCES += egif_lib.c
+-SOURCES += gif_hash.c
+-SOURCES += quantize.c
+ SOURCES += gifwriter.cpp
+ 
+-HEADERS += gif_hash.h
+-HEADERS += gif_lib_private.h
+-HEADERS += gif_lib.h
+ HEADERS += gifwriter.h
+diff --git a/src/gif/gifwriter.cpp b/src/gif/gifwriter.cpp
+index 27c66c7..53cdc28 100644
+--- a/src/gif/gifwriter.cpp
++++ b/src/gif/gifwriter.cpp
+@@ -29,7 +29,7 @@
+ 
+ #include "gifwriter.h"
+ 
+-#include "gif_lib.h"
++#include <gif_lib.h>
+ 
+ #include <QImage>
+ #include <QFile>
+-- 
+1.7.11.7
+
diff --git a/0003-unbundle-mongoose.patch b/0003-unbundle-mongoose.patch
new file mode 100644
index 0000000..279fb1d
--- /dev/null
+++ b/0003-unbundle-mongoose.patch
@@ -0,0 +1,48 @@
+From 87699a4bc1aee240a6bf127f36d5ef1b8b2953c6 Mon Sep 17 00:00:00 2001
+From: Dan Callaghan <dcallagh at redhat.com>
+Date: Fri, 3 Aug 2012 12:14:12 +1000
+Subject: [PATCH 3/8] unbundle mongoose
+
+
+diff --git a/src/phantomjs.pro b/src/phantomjs.pro
+index e6f5de8..2b3fb1b 100644
+--- a/src/phantomjs.pro
++++ b/src/phantomjs.pro
+@@ -56,7 +56,7 @@ OTHER_FILES += \
+     repl.js
+ 
+ include(gif/gif.pri)
+-include(mongoose/mongoose.pri)
++LIBS += -lmongoose
+ include(linenoise/linenoise.pri)
+ include(qcommandline/qcommandline.pri)
+ 
+diff --git a/src/webserver.cpp b/src/webserver.cpp
+index 9c60354..e26f6c4 100644
+--- a/src/webserver.cpp
++++ b/src/webserver.cpp
+@@ -32,7 +32,7 @@
+ #include "webserver.h"
+ 
+ #include "encoding.h"
+-#include "mongoose/mongoose.h"
++#include <mongoose.h>
+ 
+ #include <QByteArray>
+ #include <QHostAddress>
+diff --git a/src/webserver.h b/src/webserver.h
+index 1cbb564..bdfdc50 100644
+--- a/src/webserver.h
++++ b/src/webserver.h
+@@ -35,7 +35,7 @@
+ #include <QMutex>
+ #include <QSemaphore>
+ 
+-#include "mongoose.h"
++#include <mongoose.h>
+ 
+ class Config;
+ 
+-- 
+1.7.11.7
+
diff --git a/0004-unbundle-breakpad.patch b/0004-unbundle-breakpad.patch
new file mode 100644
index 0000000..29a9e56
--- /dev/null
+++ b/0004-unbundle-breakpad.patch
@@ -0,0 +1,93 @@
+From ee970c5d54f41a45e3288c5b107b5aa0c065291f Mon Sep 17 00:00:00 2001
+From: Dan Callaghan <dcallagh at redhat.com>
+Date: Fri, 3 Aug 2012 12:16:20 +1000
+Subject: [PATCH 4/8] unbundle breakpad
+
+
+diff --git a/src/main.cpp b/src/main.cpp
+index 734c084..64560aa 100644
+--- a/src/main.cpp
++++ b/src/main.cpp
+@@ -32,12 +32,14 @@
+ #include "env.h"
+ #include "phantom.h"
+ 
++#ifdef HAVE_BREAKPAD
+ #ifdef Q_OS_LINUX
+ #include "client/linux/handler/exception_handler.h"
+ #endif
+ #ifdef Q_OS_MAC
+ #include "client/mac/handler/exception_handler.h"
+ #endif
++#endif
+ 
+ #include <QApplication>
+ #include <QSslSocket>
+@@ -62,6 +64,7 @@ Q_IMPORT_PLUGIN(qico)
+ 
+ int main(int argc, char** argv, const char** envp)
+ {
++#ifdef HAVE_BREAKPAD
+     // Setup Google Breakpad exception handler
+ #ifdef Q_OS_LINUX
+     google_breakpad::ExceptionHandler eh("/tmp", NULL, Utils::exceptionHandler, NULL, true);
+@@ -88,6 +91,7 @@ int main(int argc, char** argv, const char** envp)
+         free(szBuffer);
+     }
+ #endif
++#endif
+ 
+     QApplication app(argc, argv);
+ 
+diff --git a/src/phantomjs.pro b/src/phantomjs.pro
+index 2b3fb1b..d453b31 100644
+--- a/src/phantomjs.pro
++++ b/src/phantomjs.pro
+@@ -60,44 +60,6 @@ LIBS += -lmongoose
+ include(linenoise/linenoise.pri)
+ include(qcommandline/qcommandline.pri)
+ 
+-linux*|mac {
+-    INCLUDEPATH += breakpad/src
+-
+-    SOURCES += breakpad/src/client/minidump_file_writer.cc \
+-      breakpad/src/common/convert_UTF.c \
+-      breakpad/src/common/md5.cc \
+-      breakpad/src/common/string_conversion.cc 
+-}
+-
+-linux* {
+-    SOURCES += breakpad/src/client/linux/crash_generation/crash_generation_client.cc \
+-      breakpad/src/client/linux/handler/exception_handler.cc \
+-      breakpad/src/client/linux/log/log.cc \
+-      breakpad/src/client/linux/minidump_writer/linux_dumper.cc \
+-      breakpad/src/client/linux/minidump_writer/linux_ptrace_dumper.cc \
+-      breakpad/src/client/linux/minidump_writer/minidump_writer.cc \
+-      breakpad/src/common/linux/file_id.cc \
+-      breakpad/src/common/linux/guid_creator.cc \
+-      breakpad/src/common/linux/memory_mapped_file.cc \
+-      breakpad/src/common/linux/safe_readlink.cc
+-}
+-
+-mac {
+-    SOURCES += breakpad/src/client/mac/crash_generation/crash_generation_client.cc \
+-      breakpad/src/client/mac/handler/exception_handler.cc \
+-      breakpad/src/client/mac/handler/minidump_generator.cc \
+-      breakpad/src/client/mac/handler/dynamic_images.cc \
+-      breakpad/src/client/mac/handler/breakpad_nlist_64.cc \
+-      breakpad/src/common/mac/bootstrap_compat.cc \
+-      breakpad/src/common/mac/file_id.cc \
+-      breakpad/src/common/mac/macho_id.cc \
+-      breakpad/src/common/mac/macho_utilities.cc \
+-      breakpad/src/common/mac/macho_walker.cc \
+-      breakpad/src/common/mac/string_utilities.cc
+-
+-    OBJECTIVE_SOURCES += breakpad/src/common/mac/MachIPC.mm
+-}
+-
+ win32: RC_FILE = phantomjs_win.rc
+ os2:   RC_FILE = phantomjs_os2.rc
+ 
+-- 
+1.7.11.7
+
diff --git a/0005-unbundle-qt.patch b/0005-unbundle-qt.patch
new file mode 100644
index 0000000..f21b8fb
--- /dev/null
+++ b/0005-unbundle-qt.patch
@@ -0,0 +1,313 @@
+From 82ce4028e1883b4c1fee98be04548698e2ca6c6d Mon Sep 17 00:00:00 2001
+From: Dan Callaghan <dcallagh at redhat.com>
+Date: Fri, 3 Aug 2012 12:17:32 +1000
+Subject: [PATCH 5/8] unbundle qt
+
+
+diff --git a/src/config.cpp b/src/config.cpp
+index 226c98f..2bf3fdb 100644
+--- a/src/config.cpp
++++ b/src/config.cpp
+@@ -168,7 +168,11 @@ void Config::loadJsonFile(const QString &filePath)
+     // Add this object to the global scope
+     webPage.mainFrame()->addToJavaScriptWindowObject("config", this);
+     // Apply the JSON config settings to this very object
+-    webPage.mainFrame()->evaluateJavaScript(configurator.arg(jsonConfig), QString());
++    webPage.mainFrame()->evaluateJavaScript(configurator.arg(jsonConfig)
++#ifdef HAVE_QT_JS_STACK_TRACES
++            , QString()
++#endif
++            );
+ }
+ 
+ QString Config::helpText() const
+diff --git a/src/csconverter.cpp b/src/csconverter.cpp
+index e81303d..6abe1ff 100644
+--- a/src/csconverter.cpp
++++ b/src/csconverter.cpp
+@@ -49,8 +49,10 @@ CSConverter::CSConverter()
+     : QObject(QCoreApplication::instance())
+ {
+     m_webPage.mainFrame()->evaluateJavaScript(
+-        Utils::readResourceFileUtf8(":/coffee-script/extras/coffee-script.js"),
+-        QString("phantomjs://coffee-script/extras/coffee-script.js")
++        Utils::readResourceFileUtf8(":/coffee-script/extras/coffee-script.js")
++#ifdef HAVE_QT_JS_STACK_TRACES
++        , QString("phantomjs://coffee-script/extras/coffee-script.js")
++#endif
+     );
+     m_webPage.mainFrame()->addToJavaScriptWindowObject("converter", this);
+ }
+@@ -63,8 +65,10 @@ QVariant CSConverter::convert(const QString &script)
+         "    [true, this.CoffeeScript.compile(converter.source)];" \
+         "} catch (error) {" \
+         "    [false, error.message];" \
+-        "}",
+-        QString()
++        "}"
++#ifdef HAVE_QT_JS_STACK_TRACES
++        , QString()
++#endif
+     );
+     return result;
+ }
+diff --git a/src/main.cpp b/src/main.cpp
+index 64560aa..ead0562 100644
+--- a/src/main.cpp
++++ b/src/main.cpp
+@@ -58,10 +58,6 @@ Q_IMPORT_PLUGIN(qico)
+ #endif
+ #endif
+ 
+-#if QT_VERSION != QT_VERSION_CHECK(4, 8, 4)
+-#error Something is wrong with the setup. Please report to the mailing list!
+-#endif
+-
+ int main(int argc, char** argv, const char** envp)
+ {
+ #ifdef HAVE_BREAKPAD
+diff --git a/src/phantom.cpp b/src/phantom.cpp
+index 1f31795..efc4449 100644
+--- a/src/phantom.cpp
++++ b/src/phantom.cpp
+@@ -372,7 +372,11 @@ void Phantom::loadModule(const QString &moduleSource, const QString &filename)
+       "require.cache['" + filename + "'].exports," +
+       "require.cache['" + filename + "']" +
+       "));";
+-   m_page->mainFrame()->evaluateJavaScript(scriptSource, filename);
++   m_page->mainFrame()->evaluateJavaScript(scriptSource
++#ifdef HAVE_QT_JS_STACK_TRACES
++        , filename
++#endif
++        );
+ }
+ 
+ bool Phantom::injectJs(const QString &jsFilePath)
+@@ -419,8 +423,10 @@ void Phantom::onInitialized()
+ 
+     // Bootstrap the PhantomJS scope
+     m_page->mainFrame()->evaluateJavaScript(
+-                Utils::readResourceFileUtf8(":/bootstrap.js"),
+-                QString("phantomjs://bootstrap.js")
++                Utils::readResourceFileUtf8(":/bootstrap.js")
++#ifdef HAVE_QT_JS_STACK_TRACES
++                , QString("phantomjs://bootstrap.js")
++#endif
+                 );
+ }
+ 
+diff --git a/src/phantomjs.pro b/src/phantomjs.pro
+index d453b31..9a690fc 100644
+--- a/src/phantomjs.pro
++++ b/src/phantomjs.pro
+@@ -6,9 +6,7 @@ CONFIG += console
+ DESTDIR = ../bin
+ 
+ RESOURCES = phantomjs.qrc \
+-    ghostdriver/ghostdriver.qrc \
+-    qt/src/3rdparty/webkit/Source/WebCore/inspector/front-end/WebKit.qrc \
+-    qt/src/3rdparty/webkit/Source/WebCore/generated/InspectorBackendStub.qrc
++    ghostdriver/ghostdriver.qrc
+ 
+ HEADERS += csconverter.h \
+     phantom.h \
+diff --git a/src/repl.cpp b/src/repl.cpp
+index 5ac69da..7b1872d 100644
+--- a/src/repl.cpp
++++ b/src/repl.cpp
+@@ -147,7 +147,11 @@ REPL::REPL(QWebFrame *webframe, Phantom *parent)
+     linenoiseSetCompletionCallback(REPL::offerCompletion);
+ 
+     // Inject REPL utility functions
+-    m_webframe->evaluateJavaScript(Utils::readResourceFileUtf8(":/repl.js"), QString("phantomjs://repl.js"));
++    m_webframe->evaluateJavaScript(Utils::readResourceFileUtf8(":/repl.js")
++#ifdef HAVE_QT_JS_STACK_TRACES
++            , QString("phantomjs://repl.js")
++#endif
++            );
+ 
+     // Add self to JavaScript world
+     m_webframe->addToJavaScriptWindowObject("_repl", this);
+@@ -184,8 +188,10 @@ void REPL::offerCompletion(const char *buf, linenoiseCompletions *lc)
+     QStringList completions = REPL::getInstance()->m_webframe->evaluateJavaScript(
+                 QString(JS_RETURN_POSSIBLE_COMPLETIONS).arg(
+                     toInspect,
+-                    toComplete),
+-                QString()
++                    toComplete)
++#ifdef HAVE_QT_JS_STACK_TRACES
++                , QString()
++#endif
+                 ).toStringList();
+ 
+     foreach (QString c, completions) {
+@@ -210,7 +216,11 @@ void REPL::startLoop()
+             // Send the user input to the main Phantom frame for evaluation
+             m_webframe->evaluateJavaScript(
+                         QString(JS_EVAL_USER_INPUT).arg(
+-                            QString(userInput).replace('"', "\\\"")), QString("phantomjs://repl-input"));
++                            QString(userInput).replace('"', "\\\""))
++#ifdef HAVE_QT_JS_STACK_TRACES
++                        , QString("phantomjs://repl-input")
++#endif
++                        );
+ 
+             // Save command in the REPL history
+             linenoiseHistoryAdd(userInput);
+diff --git a/src/utils.cpp b/src/utils.cpp
+index 8bbdeca..df2a866 100644
+--- a/src/utils.cpp
++++ b/src/utils.cpp
+@@ -119,7 +119,11 @@ bool Utils::injectJsInFrame(const QString &jsFilePath, const Encoding &jsFileEnc
+         return false;
+     }
+     // Execute JS code in the context of the document
+-    targetFrame->evaluateJavaScript(scriptBody, jsFilePath);
++    targetFrame->evaluateJavaScript(scriptBody
++#ifdef HAVE_QT_JS_STACK_TRACES
++            , jsFilePath
++#endif
++            );
+     return true;
+ }
+ 
+@@ -138,7 +142,11 @@ bool Utils::loadJSForDebug(const QString& jsFilePath, const Encoding& jsFileEnc,
+     targetFrame->setHtml(remoteDebuggerHarnessSrc);
+ 
+     if (autorun) {
+-        targetFrame->evaluateJavaScript("__run()", QString());
++        targetFrame->evaluateJavaScript("__run()"
++#ifdef HAVE_QT_JS_STACK_TRACES
++                , QString()
++#endif
++                );
+     }
+ 
+     return true;
+diff --git a/src/webpage.cpp b/src/webpage.cpp
+index c76a4b8..fe6f816 100644
+--- a/src/webpage.cpp
++++ b/src/webpage.cpp
+@@ -570,7 +570,9 @@ void WebPage::applySettings(const QVariantMap &def)
+     opt->setAttribute(QWebSettings::JavascriptEnabled, def[PAGE_SETTINGS_JS_ENABLED].toBool());
+     opt->setAttribute(QWebSettings::XSSAuditingEnabled, def[PAGE_SETTINGS_XSS_AUDITING].toBool());
+     opt->setAttribute(QWebSettings::LocalContentCanAccessRemoteUrls, def[PAGE_SETTINGS_LOCAL_ACCESS_REMOTE].toBool());
++#ifdef HAVE_QWEBSETTINGS_WEBSECURITYENABLED
+     opt->setAttribute(QWebSettings::WebSecurityEnabled, def[PAGE_SETTINGS_WEB_SECURITY_ENABLED].toBool());
++#endif
+     opt->setAttribute(QWebSettings::JavascriptCanOpenWindows, def[PAGE_SETTINGS_JS_CAN_OPEN_WINDOWS].toBool());
+     opt->setAttribute(QWebSettings::JavascriptCanCloseWindows, def[PAGE_SETTINGS_JS_CAN_CLOSE_WINDOWS].toBool());
+ 
+@@ -679,8 +681,11 @@ QVariant WebPage::evaluateJavaScript(const QString &code)
+     qDebug() << "WebPage - evaluateJavaScript" << function;
+ 
+     evalResult = m_currentFrame->evaluateJavaScript(
+-                function,                                   //< function evaluated
+-                QString("phantomjs://webpage.evaluate()")); //< reference source file
++                function                                    //< function evaluated
++#ifdef HAVE_QT_JS_STACK_TRACES
++                , QString("phantomjs://webpage.evaluate()") //< reference source file
++#endif
++                );
+ 
+     qDebug() << "WebPage - evaluateJavaScript result" << evalResult;
+ 
+@@ -821,7 +826,11 @@ void WebPage::openUrl(const QString &address, const QVariant &op, const QVariant
+         networkOp = QNetworkAccessManager::DeleteOperation;
+ 
+     if (networkOp == QNetworkAccessManager::UnknownOperation) {
+-        m_mainFrame->evaluateJavaScript("console.error('Unknown network operation: " + operation + "');", QString());
++        m_mainFrame->evaluateJavaScript("console.error('Unknown network operation: " + operation + "');"
++#ifdef HAVE_QT_JS_STACK_TRACES
++                , QString()
++#endif
++                );
+         return;
+     }
+ 
+@@ -1161,7 +1170,11 @@ bool WebPage::renderPdf(const QString &fileName)
+ 
+     printer.setPageMargins(marginLeft, marginTop, marginRight, marginBottom, QPrinter::Point);
+ 
++#ifdef HAVE_QWEBFRAME_PRINT_ADDONS
+     m_mainFrame->print(&printer, this);
++#else
++    m_mainFrame->print(&printer);
++#endif
+     return true;
+ }
+ 
+@@ -1180,6 +1193,7 @@ QString WebPage::windowName() const
+     return m_mainFrame->evaluateJavaScript("window.name;").toString();
+ }
+ 
++#ifdef HAVE_QWEBFRAME_PRINT_ADDONS
+ qreal getHeight(const QVariantMap &map, const QString &key)
+ {
+     QVariant footer = map.value(key);
+@@ -1219,7 +1233,11 @@ QString getHeaderFooter(const QVariantMap &map, const QString &key, QWebFrame *f
+             }
+         }
+     }
+-    frame->evaluateJavaScript("console.error('Bad header callback given, use phantom.callback);", QString());
++    frame->evaluateJavaScript("console.error('Bad header callback given, use phantom.callback);"
++#ifdef HAVE_QT_JS_STACK_TRACES
++            , QString()
++#endif
++            );
+     return QString();
+ }
+ 
+@@ -1232,6 +1250,7 @@ QString WebPage::footer(int page, int numPages)
+ {
+     return getHeaderFooter(m_paperSize, "footer", m_mainFrame, page, numPages);
+ }
++#endif
+ 
+ void WebPage::_uploadFile(const QString &selector, const QStringList &fileNames)
+ {
+@@ -1255,7 +1274,11 @@ bool WebPage::injectJs(const QString &jsFilePath) {
+ }
+ 
+ void WebPage::_appendScriptElement(const QString &scriptUrl) {
+-    m_currentFrame->evaluateJavaScript(QString(JS_APPEND_SCRIPT_ELEMENT).arg(scriptUrl), scriptUrl);
++    m_currentFrame->evaluateJavaScript(QString(JS_APPEND_SCRIPT_ELEMENT).arg(scriptUrl)
++#ifdef HAVE_QT_JS_STACK_TRACES
++            , scriptUrl
++#endif
++            );
+ }
+ 
+ QObject *WebPage::_getGenericCallback() {
+diff --git a/src/webpage.h b/src/webpage.h
+index e065bb4..0bdfa27 100644
+--- a/src/webpage.h
++++ b/src/webpage.h
+@@ -43,7 +43,10 @@ class NetworkAccessManager;
+ class QWebInspector;
+ class Phantom;
+ 
+-class WebPage : public QObject, public QWebFrame::PrintCallback
++class WebPage: public QObject
++#ifdef HAVE_QWEBFRAME_PRINT_ADDONS
++    , public QWebFrame::PrintCallback
++#endif
+ {
+     Q_OBJECT
+     Q_PROPERTY(QString title READ title)
+@@ -128,10 +131,12 @@ public:
+ 
+     void showInspector(const int remotePort = -1);
+ 
++#ifdef HAVE_QWEBFRAME_PRINT_ADDONS
+     QString footer(int page, int numPages);
+     qreal footerHeight() const;
+     QString header(int page, int numPages);
+     qreal headerHeight() const;
++#endif
+ 
+     void setZoomFactor(qreal zoom);
+     qreal zoomFactor() const;
+-- 
+1.7.11.7
+
diff --git a/0006-unbundle-linenoise.patch b/0006-unbundle-linenoise.patch
new file mode 100644
index 0000000..23268e3
--- /dev/null
+++ b/0006-unbundle-linenoise.patch
@@ -0,0 +1,22 @@
+From ece8e682b74a9e6e28349e5844af424a26b261ee Mon Sep 17 00:00:00 2001
+From: Dan Callaghan <dcallagh at redhat.com>
+Date: Tue, 8 Jan 2013 21:52:20 +1000
+Subject: [PATCH 6/8] unbundle linenoise
+
+
+diff --git a/src/phantomjs.pro b/src/phantomjs.pro
+index 9a690fc..69e055d 100644
+--- a/src/phantomjs.pro
++++ b/src/phantomjs.pro
+@@ -55,7 +55,7 @@ OTHER_FILES += \
+ 
+ include(gif/gif.pri)
+ LIBS += -lmongoose
+-include(linenoise/linenoise.pri)
++LIBS += -llinenoise
+ include(qcommandline/qcommandline.pri)
+ 
+ win32: RC_FILE = phantomjs_win.rc
+-- 
+1.7.11.7
+
diff --git a/0007-unbundle-QCommandLine.patch b/0007-unbundle-QCommandLine.patch
new file mode 100644
index 0000000..42f92eb
--- /dev/null
+++ b/0007-unbundle-QCommandLine.patch
@@ -0,0 +1,124 @@
+From 72f8a143a14a6aebf4b894c6c6281955c9af220c Mon Sep 17 00:00:00 2001
+From: Dan Callaghan <dcallagh at redhat.com>
+Date: Thu, 10 Jan 2013 11:08:13 +1000
+Subject: [PATCH 7/8] unbundle QCommandLine
+
+This relies on some patches for QCommandLine which have been submitted
+upstream:
+
+http://dev.iksaif.net/issues/252
+
+diff --git a/src/config.cpp b/src/config.cpp
+index 2bf3fdb..9a6ecc8 100644
+--- a/src/config.cpp
++++ b/src/config.cpp
+@@ -39,7 +39,7 @@
+ #include <QNetworkProxy>
+ 
+ #include "terminal.h"
+-#include "qcommandline.h"
++#include <qcommandline/qcommandline.h>
+ #include "utils.h"
+ #include "consts.h"
+ 
+@@ -48,32 +48,58 @@
+ 
+ static const struct QCommandLineConfigEntry flags[] =
+ {
+-    { QCommandLine::Option, '\0', "cookies-file", "Sets the file name to store the persistent cookies", QCommandLine::Optional },
+-    { QCommandLine::Option, '\0', "config", "Specifies JSON-formatted configuration file", QCommandLine::Optional },
+-    { QCommandLine::Option, '\0', "debug", "Prints additional warning and debug message: 'true' or 'false' (default)", QCommandLine::Optional },
+-    { QCommandLine::Option, '\0', "disk-cache", "Enables disk cache: 'true' or 'false' (default)", QCommandLine::Optional },
+-    { QCommandLine::Option, '\0', "ignore-ssl-errors", "Ignores SSL errors (expired/self-signed certificate errors): 'true' or 'false' (default)", QCommandLine::Optional },
+-    { QCommandLine::Option, '\0', "load-images", "Loads all inlined images: 'true' (default) or 'false'", QCommandLine::Optional },
+-    { QCommandLine::Option, '\0', "local-storage-path", "Specifies the location for offline local storage", QCommandLine::Optional },
+-    { QCommandLine::Option, '\0', "local-storage-quota", "Sets the maximum size of the offline local storage (in KB)", QCommandLine::Optional },
+-    { QCommandLine::Option, '\0', "local-to-remote-url-access", "Allows local content to access remote URL: 'true' or 'false' (default)", QCommandLine::Optional },
+-    { QCommandLine::Option, '\0', "max-disk-cache-size", "Limits the size of the disk cache (in KB)", QCommandLine::Optional },
+-    { QCommandLine::Option, '\0', "output-encoding", "Sets the encoding for the terminal output, default is 'utf8'", QCommandLine::Optional },
+-    { QCommandLine::Option, '\0', "remote-debugger-port", "Starts the script in a debug harness and listens on the specified port", QCommandLine::Optional },
+-    { QCommandLine::Option, '\0', "remote-debugger-autorun", "Runs the script in the debugger immediately: 'true' or 'false' (default)", QCommandLine::Optional },
+-    { QCommandLine::Option, '\0', "proxy", "Sets the proxy server, e.g. '--proxy=http://proxy.company.com:8080'", QCommandLine::Optional },
+-    { QCommandLine::Option, '\0', "proxy-auth", "Provides authentication information for the proxy, e.g. ''-proxy-auth=username:password'", QCommandLine::Optional },
+-    { QCommandLine::Option, '\0', "proxy-type", "Specifies the proxy type, 'http' (default), 'none' (disable completely), or 'socks5'", QCommandLine::Optional },
+-    { QCommandLine::Option, '\0', "script-encoding", "Sets the encoding used for the starting script, default is 'utf8'", QCommandLine::Optional },
+-    { QCommandLine::Option, '\0', "web-security", "Enables web security, 'true' (default) or 'false'", QCommandLine::Optional },
+-    { QCommandLine::Option, '\0', "ssl-protocol", "Sets the SSL protocol (supported protocols: 'SSLv3' (default), 'SSLv2', 'TLSv1', 'any')", QCommandLine::Optional },
+-    { QCommandLine::Option, '\0', "ssl-certificates-path", "Sets the location for custom CA certificates (if none set, uses system default)", QCommandLine::Optional },
+-    { QCommandLine::Option, '\0', "webdriver", "Starts in 'Remote WebDriver mode' (embedded GhostDriver): '[[<IP>:]<PORT>]' (default '127.0.0.1:8910') ", QCommandLine::Optional },
+-    { QCommandLine::Option, '\0', "webdriver-logfile", "File where to write the WebDriver's Log (default 'none') (NOTE: needs '--webdriver') ", QCommandLine::Optional },
+-    { QCommandLine::Option, '\0', "webdriver-loglevel", "WebDriver Logging Level: (supported: 'ERROR', 'WARN', 'INFO', 'DEBUG') (default 'INFO') (NOTE: needs '--webdriver') ", QCommandLine::Optional },
+-    { QCommandLine::Option, '\0', "webdriver-selenium-grid-hub", "URL to the Selenium Grid HUB: 'URL_TO_HUB' (default 'none') (NOTE: needs '--webdriver') ", QCommandLine::Optional },
+-    { QCommandLine::Param, '\0', "script", "Script", QCommandLine::Flags(QCommandLine::Optional|QCommandLine::ParameterFence)},
+-    { QCommandLine::Param, '\0', "argument", "Script argument", QCommandLine::OptionalMultiple },
++    { QCommandLine::Option, '\0', "cookies-file", "Sets the file name to store the persistent cookies",
++        QCommandLine::Flags(QCommandLine::Optional|QCommandLine::NoShortName) },
++    { QCommandLine::Option, '\0', "config", "Specifies JSON-formatted configuration file",
++        QCommandLine::Flags(QCommandLine::Optional|QCommandLine::NoShortName) },
++    { QCommandLine::Option, '\0', "debug", "Prints additional warning and debug message: 'true' or 'false' (default)",
++        QCommandLine::Flags(QCommandLine::Optional|QCommandLine::NoShortName) },
++    { QCommandLine::Option, '\0', "disk-cache", "Enables disk cache: 'true' or 'false' (default)",
++        QCommandLine::Flags(QCommandLine::Optional|QCommandLine::NoShortName) },
++    { QCommandLine::Option, '\0', "ignore-ssl-errors", "Ignores SSL errors (expired/self-signed certificate errors): 'true' or 'false' (default)",
++        QCommandLine::Flags(QCommandLine::Optional|QCommandLine::NoShortName) },
++    { QCommandLine::Option, '\0', "load-images", "Loads all inlined images: 'true' (default) or 'false'",
++        QCommandLine::Flags(QCommandLine::Optional|QCommandLine::NoShortName) },
++    { QCommandLine::Option, '\0', "local-storage-path", "Specifies the location for offline local storage",
++        QCommandLine::Flags(QCommandLine::Optional|QCommandLine::NoShortName) },
++    { QCommandLine::Option, '\0', "local-storage-quota", "Sets the maximum size of the offline local storage (in KB)",
++        QCommandLine::Flags(QCommandLine::Optional|QCommandLine::NoShortName) },
++    { QCommandLine::Option, '\0', "local-to-remote-url-access", "Allows local content to access remote URL: 'true' or 'false' (default)",
++        QCommandLine::Flags(QCommandLine::Optional|QCommandLine::NoShortName) },
++    { QCommandLine::Option, '\0', "max-disk-cache-size", "Limits the size of the disk cache (in KB)",
++        QCommandLine::Flags(QCommandLine::Optional|QCommandLine::NoShortName) },
++    { QCommandLine::Option, '\0', "output-encoding", "Sets the encoding for the terminal output, default is 'utf8'",
++        QCommandLine::Flags(QCommandLine::Optional|QCommandLine::NoShortName) },
++    { QCommandLine::Option, '\0', "remote-debugger-port", "Starts the script in a debug harness and listens on the specified port",
++        QCommandLine::Flags(QCommandLine::Optional|QCommandLine::NoShortName) },
++    { QCommandLine::Option, '\0', "remote-debugger-autorun", "Runs the script in the debugger immediately: 'true' or 'false' (default)",
++        QCommandLine::Flags(QCommandLine::Optional|QCommandLine::NoShortName) },
++    { QCommandLine::Option, '\0', "proxy", "Sets the proxy server, e.g. '--proxy=http://proxy.company.com:8080'",
++        QCommandLine::Flags(QCommandLine::Optional|QCommandLine::NoShortName) },
++    { QCommandLine::Option, '\0', "proxy-auth", "Provides authentication information for the proxy, e.g. ''-proxy-auth=username:password'",
++        QCommandLine::Flags(QCommandLine::Optional|QCommandLine::NoShortName) },
++    { QCommandLine::Option, '\0', "proxy-type", "Specifies the proxy type, 'http' (default), 'none' (disable completely), or 'socks5'",
++        QCommandLine::Flags(QCommandLine::Optional|QCommandLine::NoShortName) },
++    { QCommandLine::Option, '\0', "script-encoding", "Sets the encoding used for the starting script, default is 'utf8'",
++        QCommandLine::Flags(QCommandLine::Optional|QCommandLine::NoShortName) },
++    { QCommandLine::Option, '\0', "web-security", "Enables web security, 'true' (default) or 'false'",
++        QCommandLine::Flags(QCommandLine::Optional|QCommandLine::NoShortName) },
++    { QCommandLine::Option, '\0', "ssl-protocol", "Sets the SSL protocol (supported protocols: 'SSLv3' (default), 'SSLv2', 'TLSv1', 'any')",
++        QCommandLine::Flags(QCommandLine::Optional|QCommandLine::NoShortName) },
++    { QCommandLine::Option, '\0', "ssl-certificates-path", "Sets the location for custom CA certificates (if none set, uses system default)",
++        QCommandLine::Flags(QCommandLine::Optional|QCommandLine::NoShortName) },
++    { QCommandLine::Option, '\0', "webdriver", "Starts in 'Remote WebDriver mode' (embedded GhostDriver): '[[<IP>:]<PORT>]' (default '127.0.0.1:8910') ",
++        QCommandLine::Flags(QCommandLine::Optional|QCommandLine::NoShortName) },
++    { QCommandLine::Option, '\0', "webdriver-logfile", "File where to write the WebDriver's Log (default 'none') (NOTE: needs '--webdriver') ",
++        QCommandLine::Flags(QCommandLine::Optional|QCommandLine::NoShortName) },
++    { QCommandLine::Option, '\0', "webdriver-loglevel", "WebDriver Logging Level: (supported: 'ERROR', 'WARN', 'INFO', 'DEBUG') (default 'INFO') (NOTE: needs '--webdriver') ",
++        QCommandLine::Flags(QCommandLine::Optional|QCommandLine::NoShortName) },
++    { QCommandLine::Option, '\0', "webdriver-selenium-grid-hub", "URL to the Selenium Grid HUB: 'URL_TO_HUB' (default 'none') (NOTE: needs '--webdriver') ",
++        QCommandLine::Flags(QCommandLine::Optional|QCommandLine::NoShortName) },
++    { QCommandLine::Param, '\0', "script", "Script",
++        QCommandLine::Flags(QCommandLine::Optional|QCommandLine::ParameterFence|QCommandLine::SuppressHelp)},
++    { QCommandLine::Param, '\0', "argument", "Script argument",
++        QCommandLine::Flags(QCommandLine::OptionalMultiple|QCommandLine::SuppressHelp) },
+     { QCommandLine::Switch, 'w', "wd", "Equivalent to '--webdriver' option above", QCommandLine::Optional },
+     { QCommandLine::Switch, 'h', "help", "Shows this message and quits", QCommandLine::Optional },
+     { QCommandLine::Switch, 'v', "version", "Prints out PhantomJS version", QCommandLine::Optional },
+diff --git a/src/phantomjs.pro b/src/phantomjs.pro
+index 69e055d..8bb3541 100644
+--- a/src/phantomjs.pro
++++ b/src/phantomjs.pro
+@@ -56,7 +56,7 @@ OTHER_FILES += \
+ include(gif/gif.pri)
+ LIBS += -lmongoose
+ LIBS += -llinenoise
+-include(qcommandline/qcommandline.pri)
++LIBS += -lqcommandline
+ 
+ win32: RC_FILE = phantomjs_win.rc
+ os2:   RC_FILE = phantomjs_os2.rc
+-- 
+1.7.11.7
+
diff --git a/0008-unbundle-coffee-script.patch b/0008-unbundle-coffee-script.patch
new file mode 100644
index 0000000..e49435b
--- /dev/null
+++ b/0008-unbundle-coffee-script.patch
@@ -0,0 +1,62 @@
+From 6ac405d555c7f80c95b0636be64e3739d194318e Mon Sep 17 00:00:00 2001
+From: Dan Callaghan <dcallagh at redhat.com>
+Date: Mon, 11 Feb 2013 10:32:55 +1000
+Subject: [PATCH 8/8] unbundle coffee-script
+
+
+diff --git a/src/csconverter.cpp b/src/csconverter.cpp
+index 6abe1ff..8806e8d 100644
+--- a/src/csconverter.cpp
++++ b/src/csconverter.cpp
+@@ -49,9 +49,9 @@ CSConverter::CSConverter()
+     : QObject(QCoreApplication::instance())
+ {
+     m_webPage.mainFrame()->evaluateJavaScript(
+-        Utils::readResourceFileUtf8(":/coffee-script/extras/coffee-script.js")
++        Utils::readResourceFileUtf8("/usr/share/coffee-script/extras/coffee-script.js")
+ #ifdef HAVE_QT_JS_STACK_TRACES
+-        , QString("phantomjs://coffee-script/extras/coffee-script.js")
++        , QString("/usr/share/coffee-script/extras/coffee-script.js")
+ #endif
+     );
+     m_webPage.mainFrame()->addToJavaScriptWindowObject("converter", this);
+diff --git a/src/modules/_coffee-script.js b/src/modules/_coffee-script.js
+index 4366c50..a8e8f7d 100644
+--- a/src/modules/_coffee-script.js
++++ b/src/modules/_coffee-script.js
+@@ -8,4 +8,4 @@ require.stub('fs', {
+     }
+ });
+ 
+-module.exports = require('../coffee-script');
++module.exports = require('/usr/lib/node_modules/coffee-script');
+diff --git a/src/phantomjs.qrc b/src/phantomjs.qrc
+index 31839b5..1e9fc94 100644
+--- a/src/phantomjs.qrc
++++ b/src/phantomjs.qrc
+@@ -11,22 +11,5 @@
+         <file>modules/child_process.js</file>
+         <file>modules/_coffee-script.js</file>
+         <file>repl.js</file>
+-
+-        <file>coffee-script/package.json</file>
+-        <file>coffee-script/lib/coffee-script/coffee-script.js</file>
+-        <file>coffee-script/lib/coffee-script/optparse.js</file>
+-        <file>coffee-script/lib/coffee-script/command.js</file>
+-        <file>coffee-script/lib/coffee-script/scope.js</file>
+-        <file>coffee-script/lib/coffee-script/parser.js</file>
+-        <file>coffee-script/lib/coffee-script/browser.js</file>
+-        <file>coffee-script/lib/coffee-script/nodes.js</file>
+-        <file>coffee-script/lib/coffee-script/grammar.js</file>
+-        <file>coffee-script/lib/coffee-script/lexer.js</file>
+-        <file>coffee-script/lib/coffee-script/repl.js</file>
+-        <file>coffee-script/lib/coffee-script/cake.js</file>
+-        <file>coffee-script/lib/coffee-script/helpers.js</file>
+-        <file>coffee-script/lib/coffee-script/rewriter.js</file>
+-        <file>coffee-script/lib/coffee-script/index.js</file>
+-        <file>coffee-script/extras/coffee-script.js</file>
+     </qresource>
+ </RCC>
+-- 
+1.7.11.7
+
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/phantomjs.git/commitdiff/c68333c0cbeaef227b1962f6934db0763b757115



More information about the pld-cvs-commit mailing list