Skip to content
This repository was archived by the owner on May 30, 2023. It is now read-only.

Be ready for bleeding edge WebKit #14386

Closed
wants to merge 7 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
[submodule "qtbase"]
path = src/qt/qtbase
url = https://github.com/Vitallium/qtbase.git
branch = phantomjs
[submodule "qtwebkit"]
path = src/qt/qtwebkit
url = https://github.com/Vitallium/qtwebkit.git
branch = phantomjs
[submodule "3rdparty-win"]
path = src/qt/3rdparty
url = https://github.com/Vitallium/phantomjs-3rdparty-win.git
3 changes: 2 additions & 1 deletion src/bootstrap.js
Original file line number Diff line number Diff line change
@@ -73,7 +73,8 @@ phantom.__defineErrorSignalHandler__ = function(obj, page, handlers) {
return (!!handlerObj && typeof handlerObj.callback === "function" && typeof handlerObj.connector === "function") ?
handlers[handlerName].callback :
undefined;
}
},
configurable: true
});
};

6 changes: 3 additions & 3 deletions src/config.cpp
Original file line number Diff line number Diff line change
@@ -34,8 +34,8 @@

#include <QDir>
#include <QFileInfo>
#include <QtWebKitWidgets/QWebPage>
#include <QtWebKitWidgets/QWebFrame>
#include <QWebPage>
#include <QWebFrame>
#include <QNetworkProxy>

#include "terminal.h"
@@ -177,7 +177,7 @@ 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));
}

QString Config::helpText() const
4 changes: 2 additions & 2 deletions src/consts.h
Original file line number Diff line number Diff line change
@@ -33,9 +33,9 @@
#define CONSTS_H

#define PHANTOMJS_VERSION_MAJOR 2
#define PHANTOMJS_VERSION_MINOR 2
#define PHANTOMJS_VERSION_MINOR 5
#define PHANTOMJS_VERSION_PATCH 0
#define PHANTOMJS_VERSION_STRING "2.2.0-development"
#define PHANTOMJS_VERSION_STRING "2.5.0-development"

#define HTTP_HEADER_CONTENT_LENGTH "content-length"
#define HTTP_HEADER_CONTENT_TYPE "content-type"
3 changes: 2 additions & 1 deletion src/modules/webpage.js
Original file line number Diff line number Diff line change
@@ -115,7 +115,8 @@ function definePageSignalHandler(page, handlers, handlerName, signalName) {
return !!handlers[handlerName] && typeof handlers[handlerName].callback === "function" ?
handlers[handlerName].callback :
undefined;
}
},
configurable: true
});
}

2 changes: 1 addition & 1 deletion src/mongoose/mongoose.c
Original file line number Diff line number Diff line change
@@ -57,6 +57,7 @@

#if defined(_WIN32) && !defined(__SYMBIAN32__) // Windows specific
#define _WIN32_WINNT 0x0400 // To make it link in VS2005
#include <winsock2.h>
#include <windows.h>

#ifndef PATH_MAX
@@ -67,7 +68,6 @@
#include <process.h>
#include <direct.h>
#else // _WIN32
#include <winsock2.h>
#include <io.h>
#include <fcntl.h>

9 changes: 3 additions & 6 deletions src/phantom.cpp
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@
#include <QMetaProperty>
#include <QScreen>
#include <QStandardPaths>
#include <QtWebKitWidgets/QWebPage>
#include <QWebPage>

#include "callback.h"
#include "childprocess.h"
@@ -386,7 +386,7 @@ void Phantom::loadModule(const QString& moduleSource, const QString& filename)
"require.cache['" + filename + "'].exports," +
"require.cache['" + filename + "']" +
"));";
m_page->mainFrame()->evaluateJavaScript(scriptSource, QString(JAVASCRIPT_SOURCE_PLATFORM_URL).arg(QFileInfo(filename).fileName()));
m_page->mainFrame()->evaluateJavaScript(scriptSource);
}

bool Phantom::injectJs(const QString& jsFilePath)
@@ -482,10 +482,7 @@ void Phantom::onInitialized()
m_page->mainFrame()->addToJavaScriptWindowObject("phantom", this);

// Bootstrap the PhantomJS scope
m_page->mainFrame()->evaluateJavaScript(
Utils::readResourceFileUtf8(":/bootstrap.js"),
QString(JAVASCRIPT_SOURCE_PLATFORM_URL).arg("bootstrap.js")
);
m_page->mainFrame()->evaluateJavaScript(Utils::readResourceFileUtf8(":/bootstrap.js"));
}

bool Phantom::setCookies(const QVariantList& cookies)
2 changes: 1 addition & 1 deletion src/qt/3rdparty
Submodule 3rdparty updated 131 files
1 change: 0 additions & 1 deletion src/qt/qtbase
Submodule qtbase deleted from 225fe2
1 change: 0 additions & 1 deletion src/qt/qtwebkit
Submodule qtwebkit deleted from bf7003
7 changes: 3 additions & 4 deletions src/repl.cpp
Original file line number Diff line number Diff line change
@@ -147,7 +147,7 @@ REPL::REPL(QWebFrame* webframe, Phantom* parent)
linenoiseSetCompletionCallback(REPL::offerCompletion);

// Inject REPL utility functions
m_webframe->evaluateJavaScript(Utils::readResourceFileUtf8(":/repl.js"), QString(JAVASCRIPT_SOURCE_PLATFORM_URL).arg("repl.js"));
m_webframe->evaluateJavaScript(Utils::readResourceFileUtf8(":/repl.js"));

// Add self to JavaScript world
m_webframe->addToJavaScriptWindowObject("_repl", this);
@@ -184,8 +184,7 @@ 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)
).toStringList();

foreach(QString c, completions) {
@@ -210,7 +209,7 @@ 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('"', "\\\"")));

// Save command in the REPL history
linenoiseHistoryAdd(userInput);
2 changes: 1 addition & 1 deletion src/repl.h
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@
#ifndef REPL_H
#define REPL_H

#include <QtWebKitWidgets/QWebFrame>
#include <QWebFrame>

#include "phantom.h"

2 changes: 1 addition & 1 deletion src/system.cpp
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@
#include <QVariantMap>
#include <QTextCodec>

#include "../env.h"
#include "env.h"
#include "terminal.h"

#if defined(Q_OS_LINUX) || defined(Q_OS_MAC)
8 changes: 4 additions & 4 deletions src/utils.cpp
Original file line number Diff line number Diff line change
@@ -36,7 +36,7 @@
#include <QDebug>
#include <QDateTime>
#include <QDir>
#include <QtWebKitWidgets/QWebFrame>
#include <QWebFrame>

static QString findScript(const QString& jsFilePath, const QString& libraryPath)
{
@@ -135,7 +135,7 @@ bool injectJsInFrame(const QString& jsFilePath, const QString& jsFileLanguage, c
return false;
}
// Execute JS code in the context of the document
targetFrame->evaluateJavaScript(scriptBody, QString(JAVASCRIPT_SOURCE_CODE_URL).arg(QFileInfo(scriptPath).fileName()));
targetFrame->evaluateJavaScript(scriptBody);
return true;
}

@@ -150,10 +150,10 @@ bool loadJSForDebug(const QString& jsFilePath, const QString& jsFileLanguage, co
QString scriptBody = jsFromScriptFile(scriptPath, jsFileLanguage, jsFileEnc);

scriptBody = QString("function __run() {\n%1\n}").arg(scriptBody);
targetFrame->evaluateJavaScript(scriptBody, QString(JAVASCRIPT_SOURCE_CODE_URL).arg(QFileInfo(scriptPath).fileName()));
targetFrame->evaluateJavaScript(scriptBody);

if (autorun) {
targetFrame->evaluateJavaScript("__run()", QString());
targetFrame->evaluateJavaScript("__run()");
}

return true;
14 changes: 5 additions & 9 deletions src/webpage.cpp
Original file line number Diff line number Diff line change
@@ -51,9 +51,9 @@
#include <QUrl>
#include <QUuid>
#include <QWebElement>
#include <QWebFrame>
#include <QWebHistory>
#include <QWebHistoryItem>
#include <QWebFrame>
#include <QWebInspector>
#include <QWebPage>
#include <math.h>
@@ -367,7 +367,6 @@ WebPage::WebPage(QObject* parent, const QUrl& baseUrl)
// security context for Document instance. Setting up it later will not cause any effect
// see <qt\src\3rdparty\webkit\Source\WebCore\dom\Document.cpp:4468>
QWebSettings* settings = m_customWebPage->settings();
settings->setAttribute(QWebSettings::WebSecurityEnabled, phantomCfg->webSecurityEnabled());

m_mainFrame = m_customWebPage->mainFrame();
m_currentFrame = m_mainFrame;
@@ -634,7 +633,6 @@ 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());
opt->setAttribute(QWebSettings::WebSecurityEnabled, def[PAGE_SETTINGS_WEB_SECURITY_ENABLED].toBool());
opt->setAttribute(QWebSettings::JavascriptCanOpenWindows, def[PAGE_SETTINGS_JS_CAN_OPEN_WINDOWS].toBool());
opt->setAttribute(QWebSettings::JavascriptCanCloseWindows, def[PAGE_SETTINGS_JS_CAN_CLOSE_WINDOWS].toBool());

@@ -768,9 +766,7 @@ QVariant WebPage::evaluateJavaScript(const QString& code)

qDebug() << "WebPage - evaluateJavaScript" << function;

evalResult = m_currentFrame->evaluateJavaScript(
function, //< function evaluated
QString("phantomjs://webpage.evaluate()")); //< reference source file
evalResult = m_currentFrame->evaluateJavaScript(function);

qDebug() << "WebPage - evaluateJavaScript result" << evalResult;

@@ -942,7 +938,7 @@ void WebPage::openUrl(const QString& address, const QVariant& op, const QVariant
}

if (networkOp == QNetworkAccessManager::UnknownOperation) {
m_mainFrame->evaluateJavaScript("console.error('Unknown network operation: " + operation + "');", QString());
m_mainFrame->evaluateJavaScript("console.error('Unknown network operation: " + operation + "');");
return;
}

@@ -1350,7 +1346,7 @@ 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);");
return QString();
}

@@ -1389,7 +1385,7 @@ 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));
}

QObject* WebPage::_getGenericCallback()
6 changes: 3 additions & 3 deletions src/webpage.h
Original file line number Diff line number Diff line change
@@ -33,8 +33,8 @@

#include <QMap>
#include <QVariantMap>
#include <QtWebKitWidgets/QWebPage>
#include <QtWebKitWidgets/QWebFrame>
#include <QWebPage>
#include <QWebFrame>
#include <QPdfWriter>

#include "cookiejar.h"
@@ -46,7 +46,7 @@ class NetworkAccessManager;
class QWebInspector;
class Phantom;

class WebPage : public QObject, public QWebFrame::PrintCallback
class WebPage : public QObject
{
Q_OBJECT
Q_PROPERTY(QString title READ title)