From 5a53b7ad55a8c78eb395d03129e8b8b2c528ae33 Mon Sep 17 00:00:00 2001 From: Baffo32 Date: Mon, 13 Feb 2012 12:47:09 -0500 Subject: [PATCH] Provide an initial base URL for the root webpage so it is not sandboxed. This resolves for me http://code.google.com/p/phantomjs/issues/detail?id=257. --- src/phantom.cpp | 2 +- src/webpage.cpp | 4 ++-- src/webpage.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/phantom.cpp b/src/phantom.cpp index 2c7ea85b..950a0013 100644 --- a/src/phantom.cpp +++ b/src/phantom.cpp @@ -76,7 +76,7 @@ Phantom::Phantom(QObject *parent) return; } - m_page = new WebPage(this, &m_config); + m_page = new WebPage(this, &m_config, QUrl::fromLocalFile(m_config.scriptFile())); m_pages.append(m_page); if (m_config.scriptFile().isEmpty()) { diff --git a/src/webpage.cpp b/src/webpage.cpp index 39b09f40..7ea2426c 100644 --- a/src/webpage.cpp +++ b/src/webpage.cpp @@ -103,13 +103,13 @@ private: friend class WebPage; }; -WebPage::WebPage(QObject *parent, const Config *config) +WebPage::WebPage(QObject *parent, const Config *config, const QUrl &baseUrl) : QObject(parent) { setObjectName("WebPage"); m_webPage = new CustomPage(this); m_mainFrame = m_webPage->mainFrame(); - m_mainFrame->setHtml(BLANK_HTML); + m_mainFrame->setHtml(BLANK_HTML, baseUrl); connect(m_mainFrame, SIGNAL(javaScriptWindowObjectCleared()), SIGNAL(initialized())); connect(m_webPage, SIGNAL(loadStarted()), SIGNAL(loadStarted()), Qt::QueuedConnection); diff --git a/src/webpage.h b/src/webpage.h index 350b00d7..ad4dbcc2 100644 --- a/src/webpage.h +++ b/src/webpage.h @@ -53,7 +53,7 @@ class WebPage: public QObject Q_PROPERTY(QVariantMap scrollPosition READ scrollPosition WRITE setScrollPosition) public: - WebPage(QObject *parent, const Config *config); + WebPage(QObject *parent, const Config *config, const QUrl &baseUrl = QUrl()); QWebFrame *mainFrame();