Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
test: setContent with disabled javascript (#21399)
Yury Semikhatskyc30d88a63a25
diff --git a/packages/playwright-core/src/server/webkit/wkPage.ts b/packages/playwright-core/src/server/webkit/wkPage.tsindex 74fea4617f..d47292373e 100644--- a/packages/playwright-core/src/server/webkit/wkPage.ts+++ b/packages/playwright-core/src/server/webkit/wkPage.ts@@ -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;diff --git a/tests/library/browsercontext-basic.spec.ts b/tests/library/browsercontext-basic.spec.tsindex e0b74be625..373eb954a1 100644--- a/tests/library/browsercontext-basic.spec.ts+++ b/tests/library/browsercontext-basic.spec.ts@@ -223,6 +223,14 @@ it('should not hang on promises after disabling javascript', async ({ browserNamexpect(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();