mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
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:
parent
4fb7f7754c
commit
9faecc2e67
@ -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();
|
||||
|
@ -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 = [];
|
||||
|
Loading…
Reference in New Issue
Block a user