Fix Page.setContent method

The patch fixes an unfortunate bug in Page.setContent method and
adds a test to cover it.

References #50.
This commit is contained in:
Andrey Lushnikov 2017-07-05 18:09:17 -07:00
parent 4fb7f7754c
commit 9faecc2e67
2 changed files with 8 additions and 1 deletions

View File

@ -248,7 +248,7 @@ class Page extends EventEmitter {
* @return {!Promise}
*/
async setContent(html) {
this.evaluate(() => {
this.evaluate((html) => {
document.open();
document.write(html);
document.close();

View File

@ -497,6 +497,13 @@ describe('Puppeteer', function() {
expect(request.headers['foo']).toBe('bar');
}));
});
describe('Page.setContent', function() {
it('should work', SX(async function() {
await page.setContent('<div>hello</div>');
let result = await page.evaluate(() => document.body.innerHTML);
expect(result).toBe('<div>hello</div>');
}));
});
describe('Network Events', function() {
it('Page.Events.Request', SX(async function() {
let requests = [];