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

Commit

Permalink
Pass the resource URL to the resourceError handler.
Browse files Browse the repository at this point in the history
  • Loading branch information
vitallium authored and ariya committed Jan 22, 2013
1 parent 797b47a commit 6d81933
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 9 deletions.
11 changes: 9 additions & 2 deletions src/networkaccessmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,13 +318,20 @@ void NetworkAccessManager::handleNetworkError()
QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender());
qDebug() << "Network - Resource request error:"
<< reply->error()
<< "(" << reply->errorString() << ")";
<< "(" << reply->errorString() << ")"
<< "URL:" << reply->url().toString();

m_ids.remove(reply);

if (m_started.contains(reply))
m_started.remove(reply);

emit resourceError(reply->error(), reply->errorString());
QVariantMap data;
data["url"] = reply->url().toString();
data["errorCode"] = reply->error();
data["errorString"] = reply->errorString();

emit resourceError(data);

reply->deleteLater();
}
2 changes: 1 addition & 1 deletion src/networkaccessmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class NetworkAccessManager : public QNetworkAccessManager
signals:
void resourceRequested(const QVariant& data, QObject *);
void resourceReceived(const QVariant& data);
void resourceError(const QVariant& errorCode, const QVariant& errorString);
void resourceError(const QVariant& data);

private slots:
void handleStarted();
Expand Down
4 changes: 2 additions & 2 deletions src/webpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,8 @@ WebPage::WebPage(QObject *parent, const QUrl &baseUrl)
SIGNAL(resourceRequested(QVariant, QObject *)));
connect(m_networkAccessManager, SIGNAL(resourceReceived(QVariant)),
SIGNAL(resourceReceived(QVariant)));
connect(m_networkAccessManager, SIGNAL(resourceError(QVariant, QVariant)),
SIGNAL(resourceError(QVariant, QVariant)));
connect(m_networkAccessManager, SIGNAL(resourceError(QVariant)),
SIGNAL(resourceError(QVariant)));

m_customWebPage->setViewportSize(QSize(400, 300));
}
Expand Down
2 changes: 1 addition & 1 deletion src/webpage.h
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ public slots:
void javaScriptErrorSent(const QString &msg, const QString &stack);
void resourceRequested(const QVariant &requestData, QObject *request);
void resourceReceived(const QVariant &resource);
void resourceError(const QVariant &errorCode, const QVariant &errorString);
void resourceError(const QVariant &errorData);
void urlChanged(const QUrl &url);
void navigationRequested(const QUrl &url, const QString &navigationType, bool navigationLocked, bool isMainFrame);
void rawPageCreated(QObject *page);
Expand Down
7 changes: 4 additions & 3 deletions test/webpage-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1063,9 +1063,10 @@ describe("WebPage object", function() {
var handled = false;

runs(function() {
page.onResourceError = function(errorCode, errorString) {
expect(errorCode).toEqual(203);
expect(errorString).toContain('notExistResource.png - server replied: Not Found');
page.onResourceError = function(errorData) {
expect(errorData['url']).toEqual('http://localhost:12345/notExistResource.png');
expect(errorData['errorCode']).toEqual(203);
expect(errorData['errorString']).toContain('notExistResource.png - server replied: Not Found');
handled = true;
};

Expand Down

0 comments on commit 6d81933

Please sign in to comment.