test: setContent with disabled javascript (#21399)

Fixes https://github.com/microsoft/playwright/issues/21379
This commit is contained in:
Yury Semikhatsky 2023-03-09 10:45:19 -08:00 committed by GitHub
parent 47a71731f4
commit c30d88a63a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View File

@ -570,7 +570,8 @@ export class WKPage implements PageDelegate {
const objectId = JSON.parse(p.objectId);
context = this._contextIdToContext.get(objectId.injectedScriptId);
} else {
context = this._contextIdToContext.get(this._mainFrameContextId!);
// Pick any context if the parameter is a value.
context = [...this._contextIdToContext.values()].find(c => c.frame === this._page.mainFrame());
}
if (!context)
return;

View File

@ -223,6 +223,14 @@ it('should not hang on promises after disabling javascript', async ({ browserNam
expect(await page.evaluate(async () => 2)).toBe(2);
});
it('setContent should work after disabling javascript', async ({ contextFactory, browserName, isLinux }) => {
it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/18235' });
const context = await contextFactory({ javaScriptEnabled: false });
const page = await context.newPage();
await page.setContent('<h1>Hello</h1>');
await expect(page.locator('h1')).toHaveText('Hello');
});
it('should work with offline option', async ({ browser, server }) => {
const context = await browser.newContext({ offline: true });
const page = await context.newPage();