fix(page): teach page.setContent to work with tricky content (#4366)
Fix #4364
This commit is contained in:
parent
e2e6b88934
commit
27c9f754b1
@ -132,11 +132,11 @@ class DOMWorld {
|
||||
* @param {string} html
|
||||
*/
|
||||
async setContent(html) {
|
||||
await this.evaluate(html => {
|
||||
await this.evaluate(base64html => {
|
||||
document.open();
|
||||
document.write(html);
|
||||
document.write(atob(base64html));
|
||||
document.close();
|
||||
}, html);
|
||||
}, Buffer.from(html).toString('base64'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -203,11 +203,11 @@ class DOMWorld {
|
||||
} = options;
|
||||
// We rely upon the fact that document.open() will reset frame lifecycle with "init"
|
||||
// lifecycle event. @see https://crrev.com/608658
|
||||
await this.evaluate(html => {
|
||||
await this.evaluate(base64html => {
|
||||
document.open();
|
||||
document.write(html);
|
||||
document.write(atob(base64html));
|
||||
document.close();
|
||||
}, html);
|
||||
}, Buffer.from(html).toString('base64'));
|
||||
const watcher = new LifecycleWatcher(this._frameManager, this._frame, waitUntil, timeout);
|
||||
const error = await Promise.race([
|
||||
watcher.timeoutOrTerminationPromise(),
|
||||
|
@ -749,6 +749,10 @@ module.exports.addTests = function({testRunner, expect, headless, puppeteer, CHR
|
||||
for (let i = 0; i < 20; ++i)
|
||||
await page.setContent('<div>yo</div>');
|
||||
});
|
||||
it('should work with tricky content', async({page, server}) => {
|
||||
await page.setContent('<div>hello world</div>' + '\x7F');
|
||||
expect(await page.$eval('div', div => div.textContent)).toBe('hello world');
|
||||
});
|
||||
});
|
||||
|
||||
describe_fails_ffox('Page.setBypassCSP', function() {
|
||||
|
Loading…
Reference in New Issue
Block a user