test: migrate page tests to new folio (#6054)
This commit is contained in:
parent
46949cd2df
commit
0629922774
6
.github/workflows/tests.yml
vendored
6
.github/workflows/tests.yml
vendored
|
|
@ -277,11 +277,7 @@ jobs:
|
|||
- name: Start Android Emulator
|
||||
run: utils/avd_start.sh
|
||||
- name: Run tests
|
||||
run: npm run build-folio && node tests/folio/cli.js --config=tests/config/android.config.ts
|
||||
env:
|
||||
FOLIO_JSON_OUTPUT_NAME: "test-results/report-new.json"
|
||||
- name: Run page tests
|
||||
run: npx folio test/page -p browserName=chromium --workers=1 --forbid-only --timeout=120000 --global-timeout=5400000 --retries=3 --reporter=dot,json
|
||||
run: npm run build-folio && node tests/folio/cli.js --config=tests/config/android.config.ts --reporter=dot,json
|
||||
- run: ./utils/upload_flakiness_dashboard.sh ./test-results/report.json
|
||||
if: always() && github.repository == 'microsoft/playwright' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release-'))
|
||||
- uses: actions/upload-artifact@v1
|
||||
|
|
|
|||
|
|
@ -33,3 +33,8 @@ it('should override extra headers from browser context', async ({browser, server
|
|||
expect(request.headers['foo']).toBe('Bar');
|
||||
expect(request.headers['bar']).toBe('foO');
|
||||
});
|
||||
|
||||
it('should throw for non-string header values', async ({browser}) => {
|
||||
const error3 = await browser.newContext({ extraHTTPHeaders: { 'foo': null } }).catch(e => e);
|
||||
expect(error3.message).toContain('Expected value of header "foo" to be String, but "object" is found.');
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
Put tests that are scoped to a page and can run on Chrome for Android, WebView, Electron, etc.
|
||||
|
|
@ -41,6 +41,8 @@ export class AndroidEnv implements Env<AndroidTestArgs> {
|
|||
isChromium: true,
|
||||
isFirefox: false,
|
||||
isWebKit: false,
|
||||
browserName: 'chromium' as const,
|
||||
browserChannel: undefined,
|
||||
isWindows: os.platform() === 'win32',
|
||||
isMac: os.platform() === 'darwin',
|
||||
isLinux: os.platform() === 'linux',
|
||||
|
|
|
|||
|
|
@ -26,6 +26,8 @@ export type CommonTestArgs = {
|
|||
|
||||
playwright: typeof import('../../index');
|
||||
toImpl: (rpcObject: any) => any;
|
||||
browserName: 'chromium' | 'firefox' | 'webkit';
|
||||
browserChannel: string | undefined;
|
||||
|
||||
isChromium: boolean;
|
||||
isFirefox: boolean;
|
||||
|
|
|
|||
|
|
@ -22,9 +22,7 @@ import { RemoteServer, RemoteServerOptions } from './remoteServer';
|
|||
export { expect } from 'folio';
|
||||
|
||||
export type PlaywrightTestArgs = CommonTestArgs & {
|
||||
browserName: 'chromium' | 'firefox' | 'webkit';
|
||||
browserType: BrowserType<Browser>;
|
||||
browserChannel: string | undefined;
|
||||
browserOptions: LaunchOptions;
|
||||
headful: boolean;
|
||||
createUserDataDir: () => Promise<string>;
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { it, expect } from '../fixtures';
|
||||
import { test as it, expect } from './config/pageTest';
|
||||
|
||||
it('should work', async ({ page, server }) => {
|
||||
await page.goto(server.PREFIX + '/input/button.html');
|
||||
|
|
@ -15,8 +15,8 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { it, expect } from '../fixtures';
|
||||
import { attachFrame } from '../utils';
|
||||
import { test as it, expect } from './config/pageTest';
|
||||
import { attachFrame } from '../test/utils';
|
||||
|
||||
it('should work', async ({ page, server }) => {
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { it, expect } from '../fixtures';
|
||||
import { test as it, expect } from './config/pageTest';
|
||||
|
||||
it('should have a nice preview', async ({ page, server }) => {
|
||||
await page.goto(`${server.PREFIX}/dom.html`);
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { it, expect } from '../fixtures';
|
||||
import { test as it, expect } from './config/pageTest';
|
||||
|
||||
it('should work', async ({page, server}) => {
|
||||
await page.setContent('<html><body><div class="tweet"><div class="like">100</div><div class="retweets">10</div></div></body></html>');
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { it, expect } from '../fixtures';
|
||||
import { test as it, expect } from './config/pageTest';
|
||||
|
||||
it('should hover', async ({ page, server }) => {
|
||||
await page.goto(server.PREFIX + '/input/scrollable.html');
|
||||
|
|
@ -15,8 +15,8 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { it, expect } from '../fixtures';
|
||||
import { attachFrame } from '../utils';
|
||||
import { test as it, expect } from './config/pageTest';
|
||||
import { attachFrame } from '../test/utils';
|
||||
|
||||
it('should work', async ({ page, server }) => {
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { it, expect } from '../fixtures';
|
||||
import { test as it, expect } from './config/pageTest';
|
||||
|
||||
it('should work', async ({ page }) => {
|
||||
await page.setContent(`<input type='text' />`);
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { it, expect } from '../fixtures';
|
||||
import { test as it, expect } from './config/pageTest';
|
||||
|
||||
it('should query existing element', async ({page, server}) => {
|
||||
await page.goto(server.PREFIX + '/playground.html');
|
||||
|
|
@ -15,11 +15,11 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { it, expect } from '../fixtures';
|
||||
import { test as it, expect } from './config/pageTest';
|
||||
|
||||
it('should work', async ({ page, server }) => {
|
||||
it.fixme(process.env.PW_ANDROID_TESTS);
|
||||
|
||||
it('should work', test => {
|
||||
test.fixme(process.env.PW_ANDROID_TESTS);
|
||||
}, async ({ page, server }) => {
|
||||
await page.goto(server.PREFIX + '/offscreenbuttons.html');
|
||||
for (let i = 0; i < 11; ++i) {
|
||||
const button = await page.$('#btn' + i);
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { it, expect } from '../fixtures';
|
||||
import { test as it, expect } from './config/pageTest';
|
||||
|
||||
it('should select textarea', async ({ page, server, isFirefox }) => {
|
||||
await page.goto(server.PREFIX + '/input/textarea.html');
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { it, expect } from '../fixtures';
|
||||
import { test as it, expect } from './config/pageTest';
|
||||
|
||||
it('should work', async ({ page }) => {
|
||||
await page.setContent(`<input type='text' />`);
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { it, expect } from '../fixtures';
|
||||
import { test as it, expect } from './config/pageTest';
|
||||
|
||||
async function giveItAChanceToResolve(page) {
|
||||
for (let i = 0; i < 5; i++)
|
||||
|
|
@ -114,9 +114,9 @@ it('should wait for disabled button', async ({page}) => {
|
|||
await promise;
|
||||
});
|
||||
|
||||
it('should wait for stable position', (test, { browserName, platform }) => {
|
||||
test.fixme(browserName === 'firefox' && platform === 'linux');
|
||||
}, async ({page, server}) => {
|
||||
it('should wait for stable position', async ({page, server, isFirefox, platform}) => {
|
||||
it.fixme(isFirefox && platform === 'linux');
|
||||
|
||||
await page.goto(server.PREFIX + '/input/button.html');
|
||||
const button = await page.$('button');
|
||||
await page.$eval('button', button => {
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { it, expect } from '../fixtures';
|
||||
import { test as it, expect } from './config/pageTest';
|
||||
|
||||
it('should work with css selector', async ({page, server}) => {
|
||||
await page.setContent('<div>hello</div><div>beautiful</div><div>world!</div>');
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { it, expect } from '../fixtures';
|
||||
import { test as it, expect } from './config/pageTest';
|
||||
|
||||
it('should work with css selector', async ({page, server}) => {
|
||||
await page.setContent('<section id="testAttribute">43543</section>');
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { it, expect } from '../fixtures';
|
||||
import { test as it, expect } from './config/pageTest';
|
||||
|
||||
it('should work with function', async ({page}) => {
|
||||
const windowHandle = await page.evaluateHandle(() => {
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { it, expect } from '../fixtures';
|
||||
import { test as it, expect } from './config/pageTest';
|
||||
|
||||
it('should work', async ({page}) => {
|
||||
const aHandle = await page.evaluateHandle(() => ({foo: 'bar'}));
|
||||
|
|
@ -15,8 +15,8 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { it, expect } from '../fixtures';
|
||||
import type { ElementHandle } from '../..';
|
||||
import { test as it, expect } from './config/pageTest';
|
||||
import type { ElementHandle } from '../index';
|
||||
|
||||
it('should work', async ({page}) => {
|
||||
const aHandle = await page.evaluateHandle(() => ({
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { it, expect } from '../fixtures';
|
||||
import { test as it, expect } from './config/pageTest';
|
||||
|
||||
it('should work for primitives', async ({page}) => {
|
||||
const numberHandle = await page.evaluateHandle(() => 2);
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { it, expect } from '../fixtures';
|
||||
import { test as it, expect } from './config/pageTest';
|
||||
import path from 'path';
|
||||
|
||||
it('should evaluate before anything else on the page', async ({ page, server }) => {
|
||||
|
|
@ -27,7 +27,7 @@ it('should evaluate before anything else on the page', async ({ page, server })
|
|||
});
|
||||
|
||||
it('should work with a path', async ({ page, server }) => {
|
||||
await page.addInitScript({ path: path.join(__dirname, '../assets/injectedfile.js') });
|
||||
await page.addInitScript({ path: path.join(__dirname, '../test/assets/injectedfile.js') });
|
||||
await page.goto(server.PREFIX + '/tamperable.html');
|
||||
expect(await page.evaluate(() => window['result'])).toBe(123);
|
||||
});
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { it, expect } from '../fixtures';
|
||||
import { test as it, expect } from './config/pageTest';
|
||||
import path from 'path';
|
||||
|
||||
it('should throw an error if no options are provided', async ({page, server}) => {
|
||||
|
|
@ -44,7 +44,7 @@ it('should work with a url and type=module', async ({page, server}) => {
|
|||
|
||||
it('should work with a path and type=module', async ({page, server}) => {
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
await page.addScriptTag({ path: path.join(__dirname, '../assets/es6/es6pathimport.js'), type: 'module' });
|
||||
await page.addScriptTag({ path: path.join(__dirname, '../test/assets/es6/es6pathimport.js'), type: 'module' });
|
||||
await page.waitForFunction('window.__es6injected');
|
||||
expect(await page.evaluate(() => window['__es6injected'])).toBe(42);
|
||||
});
|
||||
|
|
@ -69,16 +69,16 @@ it('should throw an error if loading from url fail', async ({page, server}) => {
|
|||
|
||||
it('should work with a path', async ({page, server}) => {
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
const scriptHandle = await page.addScriptTag({ path: path.join(__dirname, '../assets/injectedfile.js') });
|
||||
const scriptHandle = await page.addScriptTag({ path: path.join(__dirname, '../test/assets/injectedfile.js') });
|
||||
expect(scriptHandle.asElement()).not.toBeNull();
|
||||
expect(await page.evaluate(() => window['__injected'])).toBe(42);
|
||||
});
|
||||
|
||||
it('should include sourceURL when path is provided', (test, { browserName }) => {
|
||||
test.skip(browserName === 'webkit');
|
||||
}, async ({page, server}) => {
|
||||
it('should include sourceURL when path is provided', async ({page, server, isWebKit}) => {
|
||||
it.skip(isWebKit);
|
||||
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
await page.addScriptTag({ path: path.join(__dirname, '../assets/injectedfile.js') });
|
||||
await page.addScriptTag({ path: path.join(__dirname, '../test/assets/injectedfile.js') });
|
||||
const result = await page.evaluate(() => window['__injectedError'].stack);
|
||||
expect(result).toContain(path.join('assets', 'injectedfile.js'));
|
||||
});
|
||||
|
|
@ -98,9 +98,9 @@ it('should throw when added with content to the CSP page', async ({page, server}
|
|||
expect(error).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should throw when added with URL to the CSP page', test => {
|
||||
test.skip(process.env.PW_ANDROID_TESTS);
|
||||
}, async ({page, server}) => {
|
||||
it('should throw when added with URL to the CSP page', async ({page, server}) => {
|
||||
it.skip(process.env.PW_ANDROID_TESTS);
|
||||
|
||||
await page.goto(server.PREFIX + '/csp.html');
|
||||
let error = null;
|
||||
await page.addScriptTag({ url: server.CROSS_PROCESS_PREFIX + '/injectedfile.js' }).catch(e => error = e);
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { it, expect } from '../fixtures';
|
||||
import { test as it, expect } from './config/pageTest';
|
||||
import path from 'path';
|
||||
|
||||
it('should throw an error if no options are provided', async ({page, server}) => {
|
||||
|
|
@ -49,14 +49,14 @@ it('should throw an error if loading from url fail', async ({page, server}) => {
|
|||
|
||||
it('should work with a path', async ({page, server}) => {
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
const styleHandle = await page.addStyleTag({ path: path.join(__dirname, '../assets/injectedstyle.css') });
|
||||
const styleHandle = await page.addStyleTag({ path: path.join(__dirname, '../test/assets/injectedstyle.css') });
|
||||
expect(styleHandle.asElement()).not.toBeNull();
|
||||
expect(await page.evaluate(`window.getComputedStyle(document.querySelector('body')).getPropertyValue('background-color')`)).toBe('rgb(255, 0, 0)');
|
||||
});
|
||||
|
||||
it('should include sourceURL when path is provided', async ({page, server}) => {
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
await page.addStyleTag({ path: path.join(__dirname, '../assets/injectedstyle.css') });
|
||||
await page.addStyleTag({ path: path.join(__dirname, '../test/assets/injectedstyle.css') });
|
||||
const styleHandle = await page.$('style');
|
||||
const styleContent = await page.evaluate(style => style.innerHTML, styleHandle);
|
||||
expect(styleContent).toContain(path.join('assets', 'injectedstyle.css'));
|
||||
|
|
@ -76,9 +76,9 @@ it('should throw when added with content to the CSP page', async ({page, server}
|
|||
expect(error).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should throw when added with URL to the CSP page', test => {
|
||||
test.skip(process.env.PW_ANDROID_TESTS);
|
||||
}, async ({page, server}) => {
|
||||
it('should throw when added with URL to the CSP page', async ({page, server}) => {
|
||||
it.skip(process.env.PW_ANDROID_TESTS);
|
||||
|
||||
await page.goto(server.PREFIX + '/csp.html');
|
||||
let error = null;
|
||||
await page.addStyleTag({ url: server.CROSS_PROCESS_PREFIX + '/injectedstyle.css' }).catch(e => error = e);
|
||||
|
|
@ -14,7 +14,8 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { it, expect } from '../fixtures';
|
||||
|
||||
import { test as it, expect } from './config/pageTest';
|
||||
|
||||
it('should check the box', async ({page}) => {
|
||||
await page.setContent(`<input id='checkbox' type='checkbox'></input>`);
|
||||
|
|
@ -14,15 +14,16 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { it, expect } from '../fixtures';
|
||||
|
||||
import { test as it, expect } from './config/pageTest';
|
||||
|
||||
declare const renderComponent;
|
||||
declare const e;
|
||||
declare const MyButton;
|
||||
|
||||
it('should report that selector does not match anymore', test => {
|
||||
test.fail(true);
|
||||
}, async ({page, server}) => {
|
||||
it('should report that selector does not match anymore', async ({page, server}) => {
|
||||
it.fail();
|
||||
|
||||
await page.goto(server.PREFIX + '/react.html');
|
||||
await page.evaluate(() => {
|
||||
renderComponent(e('div', {}, [e(MyButton, { name: 'button1' }), e(MyButton, { name: 'button2' })]));
|
||||
|
|
@ -41,9 +42,9 @@ it('should report that selector does not match anymore', test => {
|
|||
expect(error.message).toContain('element does not match the selector anymore');
|
||||
});
|
||||
|
||||
it('should not retarget the handle when element is recycled', test => {
|
||||
test.fixme(true);
|
||||
}, async ({page, server}) => {
|
||||
it('should not retarget the handle when element is recycled', async ({page, server}) => {
|
||||
it.fixme();
|
||||
|
||||
await page.goto(server.PREFIX + '/react.html');
|
||||
await page.evaluate(() => {
|
||||
renderComponent(e('div', {}, [e(MyButton, { name: 'button1' }), e(MyButton, { name: 'button2', disabled: true })]));
|
||||
|
|
@ -70,9 +71,9 @@ it('should timeout when click opens alert', async ({page, server}) => {
|
|||
await dialog.dismiss();
|
||||
});
|
||||
|
||||
it('should retarget when element is recycled during hit testing', test => {
|
||||
test.fixme(true);
|
||||
}, async ({page, server}) => {
|
||||
it('should retarget when element is recycled during hit testing', async ({page, server}) => {
|
||||
it.fixme();
|
||||
|
||||
await page.goto(server.PREFIX + '/react.html');
|
||||
await page.evaluate(() => {
|
||||
renderComponent(e('div', {}, [e(MyButton, { name: 'button1' }), e(MyButton, { name: 'button2' })]));
|
||||
|
|
@ -87,9 +88,9 @@ it('should retarget when element is recycled during hit testing', test => {
|
|||
expect(await page.evaluate('window.button2')).toBe(undefined);
|
||||
});
|
||||
|
||||
it('should retarget when element is recycled before enabled check', test => {
|
||||
test.fixme(true);
|
||||
}, async ({page, server}) => {
|
||||
it('should retarget when element is recycled before enabled check', async ({page, server}) => {
|
||||
it.fixme();
|
||||
|
||||
await page.goto(server.PREFIX + '/react.html');
|
||||
await page.evaluate(() => {
|
||||
renderComponent(e('div', {}, [e(MyButton, { name: 'button1' }), e(MyButton, { name: 'button2', disabled: true })]));
|
||||
|
|
@ -14,12 +14,12 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { it } from '../fixtures';
|
||||
import { test as it } from './config/pageTest';
|
||||
|
||||
it('should not hit scroll bar', async ({page, server, isWebKit, platform}) => {
|
||||
it.fixme(isWebKit && platform === 'darwin');
|
||||
it.skip(process.env.PW_ANDROID_TESTS);
|
||||
|
||||
it('should not hit scroll bar', (test, { browserName, platform }) => {
|
||||
test.fixme(browserName === 'webkit' && platform === 'darwin');
|
||||
test.skip(process.env.PW_ANDROID_TESTS);
|
||||
}, async ({page, server}) => {
|
||||
await page.setContent(`
|
||||
<style>
|
||||
.categories { width: 180px; display: flex; overflow-x: scroll; }
|
||||
|
|
@ -15,11 +15,11 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { it, expect } from '../fixtures';
|
||||
import { test as it, expect } from './config/pageTest';
|
||||
|
||||
it('should avoid side effects after timeout', async ({page, server, mode}) => {
|
||||
it.skip(mode !== 'default');
|
||||
|
||||
it('should avoid side effects after timeout', (test, { mode }) => {
|
||||
test.skip(mode !== 'default');
|
||||
}, async ({page, server}) => {
|
||||
await page.goto(server.PREFIX + '/input/button.html');
|
||||
const error = await page.click('button', { timeout: 2000, __testHookBeforePointerAction: () => new Promise(f => setTimeout(f, 2500))} as any).catch(e => e);
|
||||
await page.waitForTimeout(5000); // Give it some time to click after the test hook is done waiting.
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { it, expect } from '../fixtures';
|
||||
import { test as it, expect } from './config/pageTest';
|
||||
|
||||
it('should timeout waiting for display:none to be gone', async ({page, server}) => {
|
||||
await page.goto(server.PREFIX + '/input/button.html');
|
||||
|
|
@ -15,11 +15,11 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { it, expect } from '../fixtures';
|
||||
import { test as it, expect } from './config/pageTest';
|
||||
|
||||
it('should fail when element jumps during hit testing', async ({page, mode}) => {
|
||||
it.skip(mode !== 'default');
|
||||
|
||||
it('should fail when element jumps during hit testing', (test, { mode }) => {
|
||||
test.skip(mode !== 'default');
|
||||
}, async ({page}) => {
|
||||
await page.setContent('<button>Click me</button>');
|
||||
let clicked = false;
|
||||
const handle = await page.$('button');
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { it, expect } from '../fixtures';
|
||||
import { test as it, expect } from './config/pageTest';
|
||||
|
||||
it('should timeout waiting for stable position', async ({page, server}) => {
|
||||
await page.goto(server.PREFIX + '/input/button.html');
|
||||
|
|
@ -15,8 +15,8 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { it, expect } from '../fixtures';
|
||||
import { attachFrame } from '../utils';
|
||||
import { test as it, expect } from './config/pageTest';
|
||||
import { attachFrame } from '../test/utils';
|
||||
|
||||
async function giveItAChanceToClick(page) {
|
||||
for (let i = 0; i < 5; i++)
|
||||
|
|
@ -296,9 +296,9 @@ it('should click the button inside an iframe', async ({page, server}) => {
|
|||
expect(await frame.evaluate(() => window['result'])).toBe('Clicked');
|
||||
});
|
||||
|
||||
it('should click the button with fixed position inside an iframe', (test, { browserName }) => {
|
||||
test.fixme(browserName === 'chromium' || browserName === 'webkit');
|
||||
}, async ({page, server}) => {
|
||||
it('should click the button with fixed position inside an iframe', async ({page, server, isChromium, isWebKit}) => {
|
||||
it.fixme(isChromium || isWebKit);
|
||||
|
||||
// @see https://github.com/GoogleChrome/puppeteer/issues/4110
|
||||
// @see https://bugs.chromium.org/p/chromium/issues/detail?id=986390
|
||||
// @see https://chromium-review.googlesource.com/c/chromium/src/+/1742784
|
||||
|
|
@ -370,9 +370,9 @@ it('should click the button with em border with offset', async ({page, server, i
|
|||
expect(await page.evaluate('offsetY')).toBe(isWebKit ? 12 * 2 + 10 : 10);
|
||||
});
|
||||
|
||||
it('should click a very large button with offset', test => {
|
||||
test.skip(process.env.PWTESTREPORT);
|
||||
}, async ({page, server, isWebKit}) => {
|
||||
it('should click a very large button with offset', async ({page, server, isWebKit}) => {
|
||||
it.skip(process.env.PWTESTREPORT);
|
||||
|
||||
await page.goto(server.PREFIX + '/input/button.html');
|
||||
await page.$eval('button', button => button.style.borderWidth = '8px');
|
||||
await page.$eval('button', button => button.style.height = button.style.width = '2000px');
|
||||
|
|
@ -383,9 +383,9 @@ it('should click a very large button with offset', test => {
|
|||
expect(await page.evaluate('offsetY')).toBe(isWebKit ? 1910 + 8 : 1910);
|
||||
});
|
||||
|
||||
it('should click a button in scrolling container with offset', test => {
|
||||
test.skip(process.env.PWTESTREPORT);
|
||||
}, async ({page, server, isWebKit}) => {
|
||||
it('should click a button in scrolling container with offset', async ({page, server, isWebKit}) => {
|
||||
it.skip(process.env.PWTESTREPORT);
|
||||
|
||||
await page.goto(server.PREFIX + '/input/button.html');
|
||||
await page.$eval('button', button => {
|
||||
const container = document.createElement('div');
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { it, expect } from '../fixtures';
|
||||
import { test as it, expect } from './config/pageTest';
|
||||
|
||||
it('should fire', async ({page, server}) => {
|
||||
page.on('dialog', dialog => {
|
||||
|
|
@ -62,8 +62,7 @@ it('should dismiss the confirm prompt', async ({page}) => {
|
|||
expect(result).toBe(false);
|
||||
});
|
||||
|
||||
it('should be able to close context with open alert', async ({context}) => {
|
||||
const page = await context.newPage();
|
||||
it('should be able to close context with open alert', async ({page}) => {
|
||||
const alertPromise = page.waitForEvent('dialog');
|
||||
await page.evaluate(() => {
|
||||
setTimeout(() => alert('hello'), 0);
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { it, expect } from '../fixtures';
|
||||
import { test as it, expect } from './config/pageTest';
|
||||
|
||||
it('should dispatch click event', async ({page, server}) => {
|
||||
await page.goto(server.PREFIX + '/input/button.html');
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { it, expect } from '../fixtures';
|
||||
import { test as it, expect } from './config/pageTest';
|
||||
|
||||
it('should work', async ({page}) => {
|
||||
const windowHandle = await page.evaluateHandle(() => window);
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { it, expect } from '../fixtures';
|
||||
import { test as it, expect } from './config/pageTest';
|
||||
|
||||
it('should work', async ({ page }) => {
|
||||
const result = await page.evaluate(() => 7 * 3);
|
||||
|
|
@ -122,8 +122,8 @@ it('should return undefined for objects with symbols', async ({ page }) => {
|
|||
|
||||
it('should work with function shorthands', async ({ page }) => {
|
||||
const a = {
|
||||
sum([a, b]) { return a + b; },
|
||||
async mult([a, b]) { return a * b; }
|
||||
sum([a, b]: number[]) { return a + b; },
|
||||
async mult([a, b]: number[]) { return a * b; }
|
||||
};
|
||||
expect(await page.evaluate(a.sum, [1, 2])).toBe(3);
|
||||
expect(await page.evaluate(a.mult, [2, 4])).toBe(8);
|
||||
|
|
@ -415,9 +415,9 @@ it('should not throw an error when evaluation does a navigation', async ({ page,
|
|||
expect(result).toEqual([42]);
|
||||
});
|
||||
|
||||
it('should not throw an error when evaluation does a synchronous navigation and returns an object', (test, { browserName }) => {
|
||||
test.fixme(browserName === 'webkit');
|
||||
}, async ({ page, server }) => {
|
||||
it('should not throw an error when evaluation does a synchronous navigation and returns an object', async ({ page, server, isWebKit }) => {
|
||||
it.fixme(isWebKit);
|
||||
|
||||
// It is imporant to be on about:blank for sync reload.
|
||||
const result = await page.evaluate(() => {
|
||||
window.location.reload();
|
||||
|
|
@ -435,9 +435,9 @@ it('should not throw an error when evaluation does a synchronous navigation and
|
|||
expect(result).toBe(undefined);
|
||||
});
|
||||
|
||||
it('should transfer 100Mb of data from page to node.js', (test, { mode }) => {
|
||||
test.skip(mode !== 'default');
|
||||
}, async ({ page }) => {
|
||||
it('should transfer 100Mb of data from page to node.js', async ({ mode, page }) => {
|
||||
it.skip(mode !== 'default');
|
||||
|
||||
// This is too slow with wire.
|
||||
const a = await page.evaluate(() => Array(100 * 1024 * 1024 + 1).join('a'));
|
||||
expect(a.length).toBe(100 * 1024 * 1024);
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { it, expect } from '../fixtures';
|
||||
import { test as it, expect } from './config/pageTest';
|
||||
import util from 'util';
|
||||
|
||||
it('should work', async ({page}) => {
|
||||
|
|
@ -15,60 +15,65 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { it, expect, describe } from '../fixtures';
|
||||
import { test as it, expect, PageTestArgs } from './config/pageTest';
|
||||
import * as os from 'os';
|
||||
|
||||
function crash(page, toImpl, browserName) {
|
||||
if (browserName === 'chromium')
|
||||
function crash({ page, toImpl, browserName, platform, mode }: PageTestArgs) {
|
||||
if (browserName === 'chromium') {
|
||||
page.goto('chrome://crash').catch(e => {});
|
||||
else if (browserName === 'webkit')
|
||||
} else if (browserName === 'webkit') {
|
||||
it.skip(mode !== 'default');
|
||||
it.fixme(platform === 'darwin' && parseInt(os.release(), 10) >= 20, 'Timing out after roll on BigSur');
|
||||
toImpl(page)._delegate._session.send('Page.crash', {}).catch(e => {});
|
||||
else if (browserName === 'firefox')
|
||||
} else if (browserName === 'firefox') {
|
||||
it.skip(mode !== 'default');
|
||||
toImpl(page)._delegate._session.send('Page.crash', {}).catch(e => {});
|
||||
}
|
||||
}
|
||||
|
||||
describe('', (suite, { browserName, platform, mode }) => {
|
||||
suite.skip(mode !== 'default' && browserName !== 'chromium');
|
||||
const isBigSur = platform === 'darwin' && parseInt(os.release(), 10) >= 20;
|
||||
suite.fixme(isBigSur && browserName === 'webkit', 'Timing out after roll');
|
||||
}, () => {
|
||||
it('should emit crash event when page crashes', async ({page, browserName, toImpl}) => {
|
||||
it.describe('', () => {
|
||||
it('should emit crash event when page crashes', async args => {
|
||||
const { page } = args;
|
||||
await page.setContent(`<div>This page should crash</div>`);
|
||||
crash(page, toImpl, browserName);
|
||||
crash(args);
|
||||
const crashedPage = await new Promise(f => page.on('crash', f));
|
||||
expect(crashedPage).toBe(page);
|
||||
});
|
||||
|
||||
it('should throw on any action after page crashes', async ({page, browserName, toImpl}) => {
|
||||
it('should throw on any action after page crashes', async args => {
|
||||
const { page } = args;
|
||||
await page.setContent(`<div>This page should crash</div>`);
|
||||
crash(page, toImpl, browserName);
|
||||
crash(args);
|
||||
await page.waitForEvent('crash');
|
||||
const err = await page.evaluate(() => {}).then(() => null, e => e);
|
||||
expect(err).toBeTruthy();
|
||||
expect(err.message).toContain('crash');
|
||||
});
|
||||
|
||||
it('should cancel waitForEvent when page crashes', async ({page, browserName, toImpl}) => {
|
||||
it('should cancel waitForEvent when page crashes', async args => {
|
||||
const { page } = args;
|
||||
await page.setContent(`<div>This page should crash</div>`);
|
||||
const promise = page.waitForEvent('response').catch(e => e);
|
||||
crash(page, toImpl, browserName);
|
||||
crash(args);
|
||||
const error = await promise;
|
||||
expect(error.message).toContain('Page crashed');
|
||||
});
|
||||
|
||||
it('should cancel navigation when page crashes', async ({page, browserName, toImpl, server}) => {
|
||||
it('should cancel navigation when page crashes', async args => {
|
||||
const { page, server } = args;
|
||||
await page.setContent(`<div>This page should crash</div>`);
|
||||
server.setRoute('/one-style.css', () => {});
|
||||
const promise = page.goto(server.PREFIX + '/one-style.html').catch(e => e);
|
||||
await page.waitForNavigation({ waitUntil: 'domcontentloaded' });
|
||||
crash(page, toImpl, browserName);
|
||||
crash(args);
|
||||
const error = await promise;
|
||||
expect(error.message).toContain('Navigation failed because page crashed');
|
||||
});
|
||||
|
||||
it('should be able to close context when page crashes', async ({page, browserName, toImpl}) => {
|
||||
it('should be able to close context when page crashes', async args => {
|
||||
const { page } = args;
|
||||
await page.setContent(`<div>This page should crash</div>`);
|
||||
crash(page, toImpl, browserName);
|
||||
crash(args);
|
||||
await page.waitForEvent('crash');
|
||||
await page.context().close();
|
||||
});
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { it, expect } from '../fixtures';
|
||||
import { test as it, expect } from './config/pageTest';
|
||||
|
||||
it('Page.Events.Request', async ({page, server}) => {
|
||||
const requests = [];
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { it, expect } from '../fixtures';
|
||||
import { test as it, expect } from './config/pageTest';
|
||||
|
||||
it('should fire', async ({page, server, isWebKit}) => {
|
||||
const [error] = await Promise.all([
|
||||
|
|
@ -31,9 +31,9 @@ it('should fire', async ({page, server, isWebKit}) => {
|
|||
expect(error.stack).toBe(stack);
|
||||
});
|
||||
|
||||
it('should contain sourceURL', (test, { browserName }) => {
|
||||
test.fail(browserName === 'webkit');
|
||||
}, async ({page, server}) => {
|
||||
it('should contain sourceURL', async ({page, server, isWebKit}) => {
|
||||
it.fail(isWebKit);
|
||||
|
||||
const [error] = await Promise.all([
|
||||
page.waitForEvent('pageerror'),
|
||||
page.goto(server.PREFIX + '/error.html'),
|
||||
|
|
@ -57,9 +57,9 @@ it('should handle odd values', async ({page, isFirefox}) => {
|
|||
}
|
||||
});
|
||||
|
||||
it('should handle object', (test, { browserName }) => {
|
||||
test.fixme(browserName === 'firefox');
|
||||
}, async ({page, isChromium}) => {
|
||||
it('should handle object', async ({page, isChromium, isFirefox}) => {
|
||||
it.fixme(isFirefox);
|
||||
|
||||
// Firefox just does not report this error.
|
||||
const [error] = await Promise.all([
|
||||
page.waitForEvent('pageerror'),
|
||||
|
|
@ -68,9 +68,9 @@ it('should handle object', (test, { browserName }) => {
|
|||
expect(error.message).toBe(isChromium ? 'Object' : '[object Object]');
|
||||
});
|
||||
|
||||
it('should handle window', (test, { browserName }) => {
|
||||
test.fixme(browserName === 'firefox');
|
||||
}, async ({page, isChromium}) => {
|
||||
it('should handle window', async ({page, isChromium, isFirefox}) => {
|
||||
it.fixme(isFirefox);
|
||||
|
||||
// Firefox just does not report this error.
|
||||
const [error] = await Promise.all([
|
||||
page.waitForEvent('pageerror'),
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { it, expect } from '../fixtures';
|
||||
import { test as it, expect } from './config/pageTest';
|
||||
|
||||
it('should work', async ({page}) => {
|
||||
const [popup] = await Promise.all([
|
||||
|
|
@ -46,9 +46,9 @@ it('should emit for immediately closed popups', async ({page}) => {
|
|||
expect(popup).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should emit for immediately closed popups 2', (test, {browserName, video}) => {
|
||||
test.fixme(browserName === 'firefox' && video);
|
||||
}, async ({page, server}) => {
|
||||
it('should emit for immediately closed popups 2', async ({page, server, isFirefox, video}) => {
|
||||
it.fixme(isFirefox && video);
|
||||
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
const [popup] = await Promise.all([
|
||||
page.waitForEvent('popup'),
|
||||
|
|
@ -15,8 +15,8 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { it, expect } from '../fixtures';
|
||||
import { attachFrame } from '../utils';
|
||||
import { test as it, expect } from './config/pageTest';
|
||||
import { attachFrame } from '../test/utils';
|
||||
|
||||
it('should fire for navigation requests', async ({page, server}) => {
|
||||
const requests = [];
|
||||
|
|
@ -41,9 +41,9 @@ it('should fire for fetches', async ({page, server}) => {
|
|||
expect(requests.length).toBe(2);
|
||||
});
|
||||
|
||||
it('should report requests and responses handled by service worker', test => {
|
||||
test.fixme(process.env.PW_ANDROID_TESTS);
|
||||
}, async ({page, server}) => {
|
||||
it('should report requests and responses handled by service worker', async ({page, server}) => {
|
||||
it.fixme(process.env.PW_ANDROID_TESTS);
|
||||
|
||||
await page.goto(server.PREFIX + '/serviceworkers/fetchdummy/sw.html');
|
||||
await page.evaluate(() => window['activationPromise']);
|
||||
const [swResponse, request] = await Promise.all([
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { it, expect } from '../fixtures';
|
||||
import { test as it, expect } from './config/pageTest';
|
||||
|
||||
async function giveItAChanceToFill(page) {
|
||||
for (let i = 0; i < 5; i++)
|
||||
|
|
@ -90,9 +90,9 @@ it('should fill date input after clicking', async ({page, server}) => {
|
|||
expect(await page.$eval('input', input => input.value)).toBe('2020-03-02');
|
||||
});
|
||||
|
||||
it('should throw on incorrect date', (test, { browserName }) => {
|
||||
test.skip(browserName === 'webkit', 'WebKit does not support date inputs');
|
||||
}, async ({page}) => {
|
||||
it('should throw on incorrect date', async ({page, isWebKit}) => {
|
||||
it.skip(isWebKit, 'WebKit does not support date inputs');
|
||||
|
||||
await page.setContent('<input type=date>');
|
||||
const error = await page.fill('input', '2020-13-05').catch(e => e);
|
||||
expect(error.message).toContain('Malformed value');
|
||||
|
|
@ -110,9 +110,9 @@ it('should fill month input', async ({page}) => {
|
|||
expect(await page.$eval('input', input => input.value)).toBe('2020-07');
|
||||
});
|
||||
|
||||
it('should throw on incorrect month', (test, { browserName }) => {
|
||||
test.skip(browserName !== 'chromium', 'Only Chromium supports month inputs');
|
||||
}, async ({page}) => {
|
||||
it('should throw on incorrect month', async ({page, isChromium}) => {
|
||||
it.skip(!isChromium, 'Only Chromium supports month inputs');
|
||||
|
||||
await page.setContent('<input type=month>');
|
||||
const error = await page.fill('input', '2020-13').catch(e => e);
|
||||
expect(error.message).toContain('Malformed value');
|
||||
|
|
@ -124,17 +124,17 @@ it('should fill week input', async ({page}) => {
|
|||
expect(await page.$eval('input', input => input.value)).toBe('2020-W50');
|
||||
});
|
||||
|
||||
it('should throw on incorrect week', (test, { browserName }) => {
|
||||
test.skip(browserName !== 'chromium', 'Only Chromium supports week inputs');
|
||||
}, async ({page}) => {
|
||||
it('should throw on incorrect week', async ({page, isChromium}) => {
|
||||
it.skip(!isChromium, 'Only Chromium supports week inputs');
|
||||
|
||||
await page.setContent('<input type=week>');
|
||||
const error = await page.fill('input', '2020-123').catch(e => e);
|
||||
expect(error.message).toContain('Malformed value');
|
||||
});
|
||||
|
||||
it('should throw on incorrect time', (test, { browserName }) => {
|
||||
test.skip(browserName === 'webkit', 'WebKit does not support time inputs');
|
||||
}, async ({page}) => {
|
||||
it('should throw on incorrect time', async ({page, isWebKit}) => {
|
||||
it.skip(isWebKit, 'WebKit does not support time inputs');
|
||||
|
||||
await page.setContent('<input type=time>');
|
||||
const error = await page.fill('input', '25:05').catch(e => e);
|
||||
expect(error.message).toContain('Malformed value');
|
||||
|
|
@ -146,9 +146,9 @@ it('should fill datetime-local input', async ({page, server}) => {
|
|||
expect(await page.$eval('input', input => input.value)).toBe('2020-03-02T05:15');
|
||||
});
|
||||
|
||||
it('should throw on incorrect datetime-local', (test, { browserName }) => {
|
||||
test.skip(browserName !== 'chromium', 'Only Chromium supports datetime-local inputs');
|
||||
}, async ({page, server}) => {
|
||||
it('should throw on incorrect datetime-local', async ({page, server, isChromium}) => {
|
||||
it.skip(!isChromium, 'Only Chromium supports datetime-local inputs');
|
||||
|
||||
await page.setContent('<input type=datetime-local>');
|
||||
const error = await page.fill('input', 'abc').catch(e => e);
|
||||
expect(error.message).toContain('Malformed value');
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { it, expect } from '../fixtures';
|
||||
import { test as it, expect } from './config/pageTest';
|
||||
|
||||
it('should intercept', async ({page, server}) => {
|
||||
let intercepted = false;
|
||||
|
|
@ -123,10 +123,12 @@ it('should contain referer header', async ({page, server}) => {
|
|||
expect(requests[1].headers().referer).toContain('/one-style.html');
|
||||
});
|
||||
|
||||
it('should properly return navigation response when URL has cookies', async ({context, page, server}) => {
|
||||
it('should properly return navigation response when URL has cookies', async ({page, server}) => {
|
||||
it.skip(process.env.PW_ANDROID_TESTS);
|
||||
|
||||
// Setup cookie.
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
await context.addCookies([{ url: server.EMPTY_PAGE, name: 'foo', value: 'bar'}]);
|
||||
await page.context().addCookies([{ url: server.EMPTY_PAGE, name: 'foo', value: 'bar'}]);
|
||||
|
||||
// Setup request interception.
|
||||
await page.route('**/*', route => route.continue());
|
||||
|
|
@ -159,9 +161,9 @@ it('should work with redirect inside sync XHR', async ({page, server}) => {
|
|||
expect(status).toBe(200);
|
||||
});
|
||||
|
||||
it('should pause intercepted XHR until continue', (test, { browserName}) => {
|
||||
test.fixme(browserName === 'webkit', 'Redirected request is not paused in WebKit');
|
||||
}, async ({page, server}) => {
|
||||
it('should pause intercepted XHR until continue', async ({page, server, isWebKit}) => {
|
||||
it.fixme(isWebKit, 'Redirected request is not paused in WebKit');
|
||||
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
let resolveRoute;
|
||||
const routePromise = new Promise(r => resolveRoute = r);
|
||||
|
|
@ -446,9 +448,9 @@ it('should intercept main resource during cross-process navigation', async ({pag
|
|||
expect(intercepted).toBe(true);
|
||||
});
|
||||
|
||||
it('should fulfill with redirect status', (test, { browserName, headful}) => {
|
||||
test.fixme(browserName === 'webkit', 'in WebKit the redirects are handled by the network stack and we intercept before');
|
||||
}, async ({page, server}) => {
|
||||
it('should fulfill with redirect status', async ({page, server, isWebKit}) => {
|
||||
it.fixme(isWebKit, 'in WebKit the redirects are handled by the network stack and we intercept before');
|
||||
|
||||
await page.goto(server.PREFIX + '/title.html');
|
||||
server.setRoute('/final', (req, res) => res.end('foo'));
|
||||
await page.route('**/*', async (route, request) => {
|
||||
|
|
@ -469,9 +471,9 @@ it('should fulfill with redirect status', (test, { browserName, headful}) => {
|
|||
expect(text).toBe('foo');
|
||||
});
|
||||
|
||||
it('should not fulfill with redirect status', (test, { browserName, headful}) => {
|
||||
test.skip(browserName !== 'webkit', 'we should support fulfill with redirect in webkit and delete this test');
|
||||
}, async ({page, server}) => {
|
||||
it('should not fulfill with redirect status', async ({page, server, isWebKit}) => {
|
||||
it.skip(!isWebKit, 'we should support fulfill with redirect in webkit and delete this test');
|
||||
|
||||
await page.goto(server.PREFIX + '/empty.html');
|
||||
|
||||
let status;
|
||||
|
|
@ -532,9 +534,9 @@ it('should support cors with GET', async ({page, server}) => {
|
|||
}
|
||||
});
|
||||
|
||||
it('should support cors with POST', (test, { browserName, browserChannel }) => {
|
||||
test.fail(browserName === 'chromium' && !browserChannel, 'https://github.com/microsoft/playwright/issues/6016');
|
||||
}, async ({page, server}) => {
|
||||
it('should support cors with POST', async ({page, server, isChromium, browserChannel}) => {
|
||||
it.fail(isChromium && !browserChannel, 'https://github.com/microsoft/playwright/issues/6016');
|
||||
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
await page.route('**/cars', async route => {
|
||||
await route.fulfill({
|
||||
|
|
@ -556,9 +558,9 @@ it('should support cors with POST', (test, { browserName, browserChannel }) => {
|
|||
expect(resp).toEqual(['electric', 'gas']);
|
||||
});
|
||||
|
||||
it('should support cors with credentials', (test, { browserName, browserChannel }) => {
|
||||
test.fail(browserName === 'chromium' && !browserChannel, 'https://github.com/microsoft/playwright/issues/6016');
|
||||
}, async ({page, server}) => {
|
||||
it('should support cors with credentials', async ({page, server, isChromium, browserChannel}) => {
|
||||
it.fail(isChromium && !browserChannel, 'https://github.com/microsoft/playwright/issues/6016');
|
||||
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
await page.route('**/cars', async route => {
|
||||
await route.fulfill({
|
||||
|
|
@ -616,9 +618,9 @@ it('should reject cors with disallowed credentials', async ({page, server}) => {
|
|||
expect(error).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should support cors for different methods', (test, {browserName, browserChannel}) => {
|
||||
test.fail(browserName === 'chromium' && !browserChannel, 'https://github.com/microsoft/playwright/issues/6016');
|
||||
}, async ({page, server}) => {
|
||||
it('should support cors for different methods', async ({page, server, isChromium, browserChannel}) => {
|
||||
it.fail(isChromium && !browserChannel, 'https://github.com/microsoft/playwright/issues/6016');
|
||||
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
await page.route('**/cars', async (route, request) => {
|
||||
await route.fulfill({
|
||||
|
|
@ -15,8 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { it, expect } from '../fixtures';
|
||||
|
||||
import { test as it, expect } from './config/pageTest';
|
||||
|
||||
async function giveItAChanceToResolve(page) {
|
||||
for (let i = 0; i < 5; i++)
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { it, expect } from '../fixtures';
|
||||
import { test as it, expect } from './config/pageTest';
|
||||
|
||||
const expectedOutput = '<html><head></head><body><div>hello</div></body></html>';
|
||||
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { it, expect } from '../fixtures';
|
||||
import { test as it, expect } from './config/pageTest';
|
||||
|
||||
it('should work', async ({page, server}) => {
|
||||
await page.setExtraHTTPHeaders({
|
||||
|
|
@ -53,13 +53,11 @@ it('should work with extra headers from browser context', async ({page, server})
|
|||
expect(request.headers['foo']).toBe('bar');
|
||||
});
|
||||
|
||||
it('should throw for non-string header values', async ({browser, page}) => {
|
||||
it('should throw for non-string header values', async ({page}) => {
|
||||
// @ts-expect-error headers must be strings
|
||||
const error1 = await page.setExtraHTTPHeaders({ 'foo': 1 }).catch(e => e);
|
||||
expect(error1.message).toContain('Expected value of header "foo" to be String, but "number" is found.');
|
||||
// @ts-expect-error headers must be strings
|
||||
const error2 = await page.context().setExtraHTTPHeaders({ 'foo': true }).catch(e => e);
|
||||
expect(error2.message).toContain('Expected value of header "foo" to be String, but "boolean" is found.');
|
||||
const error3 = await browser.newContext({ extraHTTPHeaders: { 'foo': null } }).catch(e => e);
|
||||
expect(error3.message).toContain('Expected value of header "foo" to be String, but "object" is found.');
|
||||
});
|
||||
|
|
@ -15,13 +15,13 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { it, expect } from '../fixtures';
|
||||
import { test as it, expect } from './config/pageTest';
|
||||
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import formidable from 'formidable';
|
||||
|
||||
const FILE_TO_UPLOAD = path.join(__dirname, '../assets/file-to-upload.txt');
|
||||
const FILE_TO_UPLOAD = path.join(__dirname, '../test/assets/file-to-upload.txt');
|
||||
|
||||
it('should upload the file', async ({page, server}) => {
|
||||
await page.goto(server.PREFIX + '/input/fileupload.html');
|
||||
|
|
@ -39,7 +39,7 @@ it('should upload the file', async ({page, server}) => {
|
|||
|
||||
it('should work', async ({page}) => {
|
||||
await page.setContent(`<input type=file>`);
|
||||
await page.setInputFiles('input', path.join(__dirname, '../assets/file-to-upload.txt'));
|
||||
await page.setInputFiles('input', path.join(__dirname, '../test/assets/file-to-upload.txt'));
|
||||
expect(await page.$eval('input', input => input.files.length)).toBe(1);
|
||||
expect(await page.$eval('input', input => input.files[0].name)).toBe('file-to-upload.txt');
|
||||
});
|
||||
|
|
@ -120,9 +120,9 @@ it('should work when file input is not attached to DOM', async ({page, server})
|
|||
expect(content).toBe('contents of the file');
|
||||
});
|
||||
|
||||
it('should not throw when filechooser belongs to iframe', (test, { browserName }) => {
|
||||
test.skip(browserName === 'firefox', 'Firefox ignores filechooser from child frame');
|
||||
}, async ({page, server}) => {
|
||||
it('should not throw when filechooser belongs to iframe', async ({page, server, isFirefox}) => {
|
||||
it.skip(isFirefox, 'Firefox ignores filechooser from child frame');
|
||||
|
||||
await page.goto(server.PREFIX + '/frames/one-frame.html');
|
||||
const frame = page.mainFrame().childFrames()[0];
|
||||
await frame.setContent(`
|
||||
|
|
@ -168,7 +168,7 @@ it('should work with CSP', async ({page, server}) => {
|
|||
server.setCSP('/empty.html', 'default-src "none"');
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
await page.setContent(`<input type=file>`);
|
||||
await page.setInputFiles('input', path.join(__dirname, '../assets/file-to-upload.txt'));
|
||||
await page.setInputFiles('input', path.join(__dirname, '../test/assets/file-to-upload.txt'));
|
||||
expect(await page.$eval('input', input => input.files.length)).toBe(1);
|
||||
expect(await page.$eval('input', input => input.files[0].name)).toBe('file-to-upload.txt');
|
||||
});
|
||||
|
|
@ -244,8 +244,8 @@ it('should detect mime type', async ({page, server}) => {
|
|||
<input type="file" name="file2">
|
||||
<input type="submit" value="Submit">
|
||||
</form>`);
|
||||
await (await page.$('input[name=file1]')).setInputFiles(path.join(__dirname, '../assets/file-to-upload.txt'));
|
||||
await (await page.$('input[name=file2]')).setInputFiles(path.join(__dirname, '../assets/pptr.png'));
|
||||
await (await page.$('input[name=file1]')).setInputFiles(path.join(__dirname, '../test/assets/file-to-upload.txt'));
|
||||
await (await page.$('input[name=file2]')).setInputFiles(path.join(__dirname, '../test/assets/pptr.png'));
|
||||
await Promise.all([
|
||||
page.click('input[type=submit]'),
|
||||
server.waitForRequest('/upload'),
|
||||
|
|
@ -254,11 +254,11 @@ it('should detect mime type', async ({page, server}) => {
|
|||
expect(file1.name).toBe('file-to-upload.txt');
|
||||
expect(file1.type).toBe('text/plain');
|
||||
expect(fs.readFileSync(file1.path).toString()).toBe(
|
||||
fs.readFileSync(path.join(__dirname, '../assets/file-to-upload.txt')).toString());
|
||||
fs.readFileSync(path.join(__dirname, '../test/assets/file-to-upload.txt')).toString());
|
||||
expect(file2.name).toBe('pptr.png');
|
||||
expect(file2.type).toBe('image/png');
|
||||
expect(fs.readFileSync(file2.path).toString()).toBe(
|
||||
fs.readFileSync(path.join(__dirname, '../assets/pptr.png')).toString());
|
||||
fs.readFileSync(path.join(__dirname, '../test/assets/pptr.png')).toString());
|
||||
});
|
||||
|
||||
it('should be able to read selected file', async ({page, server}) => {
|
||||
|
|
@ -307,8 +307,8 @@ it('should not accept multiple files for single-file input', async ({page, serve
|
|||
]);
|
||||
let error = null;
|
||||
await fileChooser.setFiles([
|
||||
path.relative(process.cwd(), __dirname + '/assets/file-to-upload.txt'),
|
||||
path.relative(process.cwd(), __dirname + '/assets/pptr.png')
|
||||
path.join(__dirname, '../test/assets/file-to-upload.txt'),
|
||||
path.join(__dirname, '../test/assets/pptr.png')
|
||||
]).catch(e => error = e);
|
||||
expect(error).not.toBe(null);
|
||||
});
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { it, expect } from '../fixtures';
|
||||
import { test as it, expect } from './config/pageTest';
|
||||
|
||||
it('should timeout', async ({page}) => {
|
||||
const startTime = Date.now();
|
||||
|
|
@ -15,8 +15,8 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { it, expect } from '../fixtures';
|
||||
import type { Route } from '../..';
|
||||
import { test as it, expect } from './config/pageTest';
|
||||
import type { Route } from '../index';
|
||||
|
||||
it('should pick up ongoing navigation', async ({page, server}) => {
|
||||
let response = null;
|
||||
|
|
@ -57,7 +57,7 @@ it('should resolve immediately if load state matches', async ({page, server}) =>
|
|||
await page.waitForLoadState('domcontentloaded');
|
||||
});
|
||||
|
||||
it('should work with pages that have loaded before being connected to', async ({page, context, server}) => {
|
||||
it('should work with pages that have loaded before being connected to', async ({page, server}) => {
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
const [popup] = await Promise.all([
|
||||
page.waitForEvent('popup'),
|
||||
|
|
@ -82,7 +82,7 @@ it('should wait for load state of empty url popup', async ({page, isFirefox}) =>
|
|||
expect(await popup.evaluate(() => document.readyState)).toBe(isFirefox ? 'uninitialized' : 'complete');
|
||||
});
|
||||
|
||||
it('should wait for load state of about:blank popup ', async ({browser, page}) => {
|
||||
it('should wait for load state of about:blank popup ', async ({page}) => {
|
||||
const [popup] = await Promise.all([
|
||||
page.waitForEvent('popup'),
|
||||
page.evaluate(() => window.open('about:blank') && 1),
|
||||
|
|
@ -91,7 +91,7 @@ it('should wait for load state of about:blank popup ', async ({browser, page}) =
|
|||
expect(await popup.evaluate(() => document.readyState)).toBe('complete');
|
||||
});
|
||||
|
||||
it('should wait for load state of about:blank popup with noopener ', async ({browser, page}) => {
|
||||
it('should wait for load state of about:blank popup with noopener ', async ({page}) => {
|
||||
const [popup] = await Promise.all([
|
||||
page.waitForEvent('popup'),
|
||||
page.evaluate(() => window.open('about:blank', null, 'noopener') && 1),
|
||||
|
|
@ -100,7 +100,7 @@ it('should wait for load state of about:blank popup with noopener ', async ({bro
|
|||
expect(await popup.evaluate(() => document.readyState)).toBe('complete');
|
||||
});
|
||||
|
||||
it('should wait for load state of popup with network url ', async ({browser, page, server}) => {
|
||||
it('should wait for load state of popup with network url ', async ({page, server}) => {
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
const [popup] = await Promise.all([
|
||||
page.waitForEvent('popup'),
|
||||
|
|
@ -110,7 +110,7 @@ it('should wait for load state of popup with network url ', async ({browser, pag
|
|||
expect(await popup.evaluate(() => document.readyState)).toBe('complete');
|
||||
});
|
||||
|
||||
it('should wait for load state of popup with network url and noopener ', async ({browser, page, server}) => {
|
||||
it('should wait for load state of popup with network url and noopener ', async ({page, server}) => {
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
const [popup] = await Promise.all([
|
||||
page.waitForEvent('popup'),
|
||||
|
|
@ -120,7 +120,7 @@ it('should wait for load state of popup with network url and noopener ', async (
|
|||
expect(await popup.evaluate(() => document.readyState)).toBe('complete');
|
||||
});
|
||||
|
||||
it('should work with clicking target=_blank', async ({browser, page, server}) => {
|
||||
it('should work with clicking target=_blank', async ({page, server}) => {
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
await page.setContent('<a target=_blank rel="opener" href="/one-style.html">yo</a>');
|
||||
const [popup] = await Promise.all([
|
||||
|
|
@ -131,10 +131,10 @@ it('should work with clicking target=_blank', async ({browser, page, server}) =>
|
|||
expect(await popup.evaluate(() => document.readyState)).toBe('complete');
|
||||
});
|
||||
|
||||
it('should wait for load state of newPage', async ({browser, context, page, server}) => {
|
||||
it('should wait for load state of newPage', async ({page, server}) => {
|
||||
const [newPage] = await Promise.all([
|
||||
context.waitForEvent('page'),
|
||||
context.newPage(),
|
||||
page.context().waitForEvent('page'),
|
||||
page.context().newPage(),
|
||||
]);
|
||||
await newPage.waitForLoadState();
|
||||
expect(await newPage.evaluate(() => document.readyState)).toBe('complete');
|
||||
|
|
@ -15,9 +15,9 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { it, expect } from '../fixtures';
|
||||
import type { Frame } from '../../index';
|
||||
import { expectedSSLError } from '../utils';
|
||||
import { test as it, expect } from './config/pageTest';
|
||||
import type { Frame } from '../index';
|
||||
import { expectedSSLError } from '../test/utils';
|
||||
|
||||
it('should work', async ({page, server}) => {
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
|
|
@ -15,8 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { it, expect } from '../fixtures';
|
||||
|
||||
import { test as it, expect } from './config/pageTest';
|
||||
import vm from 'vm';
|
||||
|
||||
it('should work', async ({page, server}) => {
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { it, expect } from '../fixtures';
|
||||
import { test as it, expect } from './config/pageTest';
|
||||
|
||||
it('should work', async ({page, server}) => {
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
|
|
@ -15,8 +15,8 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { it, expect } from '../fixtures';
|
||||
import { attachFrame, detachFrame } from '../utils';
|
||||
import { test as it, expect } from './config/pageTest';
|
||||
import { attachFrame, detachFrame } from '../test/utils';
|
||||
|
||||
async function giveItTimeToLog(frame) {
|
||||
await frame.evaluate(() => new Promise(f => requestAnimationFrame(() => requestAnimationFrame(f))));
|
||||
|
|
@ -15,8 +15,8 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { it, expect } from '../fixtures';
|
||||
import { attachFrame, detachFrame } from '../utils';
|
||||
import { test as it, expect } from './config/pageTest';
|
||||
import { attachFrame, detachFrame } from '../test/utils';
|
||||
|
||||
const addElement = tag => document.body.appendChild(document.createElement(tag));
|
||||
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { it, expect } from '../fixtures';
|
||||
import { test as it, expect } from './config/pageTest';
|
||||
|
||||
it('should work', async ({page, server}) => {
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
Loading…
Reference in a new issue