mirror of https://github.com/vitalif/phantomjs
ChangeUrl to accept an encoded string
Issue #11243: https://github.com/ariya/phantomjs/issues/11243.1.x
parent
f72f2962d1
commit
3ae632e704
|
@ -90,10 +90,11 @@ void JsNetworkRequest::abort()
|
|||
}
|
||||
|
||||
|
||||
void JsNetworkRequest::changeUrl(const QString& url)
|
||||
void JsNetworkRequest::changeUrl(const QString& address)
|
||||
{
|
||||
if (m_networkRequest) {
|
||||
m_networkRequest->setUrl(QUrl(url));
|
||||
QUrl url = QUrl::fromEncoded(QByteArray(address.toAscii()));
|
||||
m_networkRequest->setUrl(url);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1151,6 +1151,41 @@ describe("WebPage object", function() {
|
|||
});
|
||||
});
|
||||
|
||||
|
||||
it("should change a url request with an encoded query string", function() {
|
||||
var page = new require('webpage').create();
|
||||
|
||||
var server = require('webserver').create();
|
||||
server.listen(12345, function(request, response) {
|
||||
// echo received request headers in response body
|
||||
response.write(JSON.stringify(request.headers));
|
||||
response.close();
|
||||
});
|
||||
|
||||
var url = "http://localhost:12345/cdn-cgi/pe/bag?r%5B%5D=http%3A%2F%2Fwww.example.org%2Fcdn-cgi%2Fnexp%2Fabv%3D927102467%2Fapps%2Fabetterbrowser.js";
|
||||
|
||||
var handled = false;
|
||||
runs(function() {
|
||||
expect(handled).toEqual(false);
|
||||
|
||||
page.onResourceRequested = function(requestData, request) {
|
||||
request.changeUrl(requestData.url);
|
||||
};
|
||||
|
||||
page.onResourceReceived = function(data) {
|
||||
if (data['stage'] === 'end') {
|
||||
expect(data.url).toEqual(url);
|
||||
}
|
||||
};
|
||||
|
||||
page.open(url, function (status) {
|
||||
expect(status == 'success').toEqual(true);
|
||||
handled = true;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
it('should able to abort a network request', function() {
|
||||
var page = require('webpage').create();
|
||||
var url = 'http://phantomjs.org';
|
||||
|
|
Loading…
Reference in New Issue