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}
|
* @return {!Promise}
|
||||||
*/
|
*/
|
||||||
async setContent(html) {
|
async setContent(html) {
|
||||||
this.evaluate(() => {
|
this.evaluate((html) => {
|
||||||
document.open();
|
document.open();
|
||||||
document.write(html);
|
document.write(html);
|
||||||
document.close();
|
document.close();
|
||||||
|
@ -497,6 +497,13 @@ describe('Puppeteer', function() {
|
|||||||
expect(request.headers['foo']).toBe('bar');
|
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() {
|
describe('Network Events', function() {
|
||||||
it('Page.Events.Request', SX(async function() {
|
it('Page.Events.Request', SX(async function() {
|
||||||
let requests = [];
|
let requests = [];
|
||||||
|
Loading…
Reference in New Issue
Block a user