diff --git a/docs/api.md b/docs/api.md index 410cfe8c30..9503239674 100644 --- a/docs/api.md +++ b/docs/api.md @@ -3686,7 +3686,7 @@ const { selectors, firefox } = require('playwright'); // Or 'chromium' or 'webk const browser = await firefox.launch(); const page = await browser.newPage(); - await page.goto('https://example.com'); + await page.setContent(`
`); // Use the selector prefixed with its name. const button = await page.$('tag=button'); diff --git a/test/workers.jest.js b/test/workers.jest.js index f3ee4f9395..e4a9ffcd8a 100644 --- a/test/workers.jest.js +++ b/test/workers.jest.js @@ -58,13 +58,13 @@ describe('Workers', function() { }); it('should evaluate', async function({page}) { const workerCreatedPromise = page.waitForEvent('worker'); - page.evaluate(() => new Worker(URL.createObjectURL(new Blob(['console.log(1)'], {type: 'application/javascript'})))); + await page.evaluate(() => new Worker(URL.createObjectURL(new Blob(['console.log(1)'], {type: 'application/javascript'})))); const worker = await workerCreatedPromise; expect(await worker.evaluate('1+1')).toBe(2); }); it('should report errors', async function({page}) { const errorPromise = new Promise(x => page.on('pageerror', x)); - page.evaluate(() => new Worker(URL.createObjectURL(new Blob([` + await page.evaluate(() => new Worker(URL.createObjectURL(new Blob([` setTimeout(() => { // Do a console.log just to check that we do not confuse it with an error. console.log('hey'); @@ -77,7 +77,7 @@ describe('Workers', function() { it('should clear upon navigation', async function({server, page}) { await page.goto(server.EMPTY_PAGE); const workerCreatedPromise = page.waitForEvent('worker'); - page.evaluate(() => new Worker(URL.createObjectURL(new Blob(['console.log(1)'], {type: 'application/javascript'})))); + await page.evaluate(() => new Worker(URL.createObjectURL(new Blob(['console.log(1)'], {type: 'application/javascript'})))); const worker = await workerCreatedPromise; expect(page.workers().length).toBe(1); let destroyed = false; @@ -89,7 +89,7 @@ describe('Workers', function() { it('should clear upon cross-process navigation', async function({server, page}) { await page.goto(server.EMPTY_PAGE); const workerCreatedPromise = page.waitForEvent('worker'); - page.evaluate(() => new Worker(URL.createObjectURL(new Blob(['console.log(1)'], {type: 'application/javascript'})))); + await page.evaluate(() => new Worker(URL.createObjectURL(new Blob(['console.log(1)'], {type: 'application/javascript'})))); const worker = await workerCreatedPromise; expect(page.workers().length).toBe(1); let destroyed = false; diff --git a/utils/generate_types/test/test.ts b/utils/generate_types/test/test.ts index f695f3a581..ce226edb01 100644 --- a/utils/generate_types/test/test.ts +++ b/utils/generate_types/test/test.ts @@ -63,7 +63,7 @@ playwright.chromium.launch().then(async browser => { page.on('console', message => { console.log(message.text()); }); - page.evaluate(() => console.log(5, 'hello', { foo: 'bar' })); + await page.evaluate(() => console.log(5, 'hello', { foo: 'bar' })); { const result = await page.evaluate(() => {