puppeteer/third_party/phantomjs/test/module/webpage/change-request-encoded-url.js
Andrey Lushnikov 4372674c99 Improve Phantom_Shim to handle more scenarios. (#49)
This patch improves phantom_shim:
- introduce WebPage.loading/WebPage.loadingProgress
- improve compatibility of WebPage.onInitialized. This allows to
  pass phantomjs tests, even though the implementation is hacky.
- teach PhantomResponse about "stage" state which could be either
  "start" or "end"
- unskip a bunch of phantom webpage tests:
  - webpage/change-request-encoded-url
  - webpage/loading.js
  - webpage/long-running-javascript.js
  - webpage/modify-header.js
  - webpage/on-initialized.js
  - webpage/remove-header.js
2017-07-05 10:07:36 +03:00

27 lines
803 B
JavaScript

var webpage = require('webpage');
async_test(function () {
var page = webpage.create();
var url = TEST_HTTP_BASE + "cdn-cgi/pe/bag?r%5B%5D="+
"http%3A%2F%2Fwww.example.org%2Fcdn-cgi%2Fnexp%2F"+
"abv%3D927102467%2Fapps%2Fabetterbrowser.js";
var receivedUrl;
page.onResourceRequested = this.step_func(function(requestData, request) {
request.changeUrl(requestData.url);
});
page.onResourceReceived = this.step_func(function(data) {
if (data.stage === 'end') {
receivedUrl = data.url;
}
});
page.open(url, this.step_func_done(function (status) {
assert_equals(status, 'success');
assert_equals(receivedUrl, url);
}));
}, "encoded URLs properly round-trip through request.changeUrl");