puppeteer/third_party/phantomjs/test/module/webpage/modify-header.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

28 lines
959 B
JavaScript

async_test(function () {
var webpage = require('webpage');
// NOTE: HTTP header names are case-insensitive. Our test server
// returns the name in lowercase.
var page = webpage.create();
assert_type_of(page.customHeaders, 'object');
assert_deep_equals(page.customHeaders, {});
page.customHeaders = { 'CustomHeader': 'CustomValue' };
page.onResourceRequested = this.step_func(function(requestData, request) {
assert_type_of(request.setHeader, 'function');
request.setHeader('CustomHeader', 'ModifiedCustomValue');
});
page.open(TEST_HTTP_BASE + 'echo', this.step_func_done(function (status) {
var json, headers;
assert_equals(status, 'success');
json = JSON.parse(page.plainText);
headers = json.headers;
assert_own_property(headers, 'customheader');
assert_equals(headers.customheader, 'ModifiedCustomValue');
}));
}, "modifying HTTP headers");