mirror of
https://github.com/microsoft/playwright.git
synced 2024-11-28 01:15:10 +03:00
test: some tests for expected API behavior (#32495)
Adding some tests discussed in https://github.com/microsoft/playwright/pull/32434
This commit is contained in:
parent
1402dee9e6
commit
d85527e9f6
@ -297,6 +297,16 @@ it('should click', async function({ page, browser, server }) {
|
||||
expect(await handle1.evaluate(() => (window as any)['_clicked'])).toBe(true);
|
||||
});
|
||||
|
||||
it('contentFrame should work', async ({ page, browser, server }) => {
|
||||
await page.goto(server.PREFIX + '/dynamic-oopif.html');
|
||||
expect(page.frames().length).toBe(2);
|
||||
expect(await countOOPIFs(browser)).toBe(1);
|
||||
expect(await page.locator('iframe').contentFrame().locator('div').count()).toBe(200);
|
||||
const oopif = await page.$('iframe');
|
||||
const content = await oopif.contentFrame();
|
||||
expect(await content.locator('div').count()).toBe(200);
|
||||
});
|
||||
|
||||
it('should allow cdp sessions on oopifs', async function({ page, browser, server }) {
|
||||
await page.goto(server.PREFIX + '/dynamic-oopif.html');
|
||||
expect(await countOOPIFs(browser)).toBe(1);
|
||||
|
@ -75,3 +75,19 @@ it('should work inside closed shadow root', async ({ page, server, browserName }
|
||||
const element = await frame.frameElement();
|
||||
expect(await element.getAttribute('name')).toBe('myframe');
|
||||
});
|
||||
|
||||
it('should work inside declarative shadow root', async ({ page, server, browserName }) => {
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
await page.setContent(`
|
||||
<div>
|
||||
<template shadowrootmode="open">
|
||||
<iframe name="myframe" srcdoc="<h1>Hi!</h1>"></iframe>
|
||||
<slot></slot>
|
||||
</template>
|
||||
<span>footer</span>
|
||||
</div>
|
||||
`);
|
||||
const frame = page.frame({ name: 'myframe' });
|
||||
const element = await frame.frameElement();
|
||||
expect(await element.getAttribute('name')).toBe('myframe');
|
||||
});
|
||||
|
@ -164,7 +164,7 @@ it('should work with regular expression passed from a different context', async
|
||||
expect(intercepted).toBe(true);
|
||||
});
|
||||
|
||||
it('should not break remote worker importScripts', async ({ page, server, browserName, browserMajorVersion }) => {
|
||||
it('should not break remote worker importScripts', async ({ page, server }) => {
|
||||
await page.route('**', async route => {
|
||||
await route.continue();
|
||||
});
|
||||
@ -189,3 +189,20 @@ it('should disable memory cache when intercepting', async ({ page, server }) =>
|
||||
await expect(page).toHaveURL(server.PREFIX + '/page.html');
|
||||
expect(interceted).toBe(2);
|
||||
});
|
||||
|
||||
it('should intercept blob url requests', async function({ page, server, browserName }) {
|
||||
it.fixme(browserName !== 'webkit');
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
await page.route('**/*', route => {
|
||||
route.fulfill({
|
||||
status: 200,
|
||||
body: 'intercepted',
|
||||
}).catch(e => null);
|
||||
});
|
||||
page.on('console', msg => console.log(msg.text()));
|
||||
const response = await page.evaluate(async () => {
|
||||
const blobUrl = URL.createObjectURL(new Blob(['failed to intercept'], { type: 'text/plain' }));
|
||||
return await fetch(blobUrl).then(response => response.text());
|
||||
});
|
||||
expect(response).toBe('intercepted');
|
||||
});
|
||||
|
@ -78,6 +78,33 @@ it('should dblclick the div', async ({ page, server }) => {
|
||||
expect(event.button).toBe(0);
|
||||
});
|
||||
|
||||
it('down and up should generate click', async ({ page, server }) => {
|
||||
await page.evaluate(() => {
|
||||
window['clickPromise'] = new Promise(resolve => {
|
||||
document.addEventListener('click', event => {
|
||||
resolve({
|
||||
type: event.type,
|
||||
detail: event.detail,
|
||||
clientX: event.clientX,
|
||||
clientY: event.clientY,
|
||||
isTrusted: event.isTrusted,
|
||||
button: event.button
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
await page.mouse.move(50, 60);
|
||||
await page.mouse.down();
|
||||
await page.mouse.up();
|
||||
const event = await page.evaluate(() => window['clickPromise']);
|
||||
expect(event.type).toBe('click');
|
||||
expect(event.detail).toBe(1);
|
||||
expect(event.clientX).toBe(50);
|
||||
expect(event.clientY).toBe(60);
|
||||
expect(event.isTrusted).toBe(true);
|
||||
expect(event.button).toBe(0);
|
||||
});
|
||||
|
||||
it('should pointerdown the div with a custom button', async ({ page, server, browserName }) => {
|
||||
await page.setContent(`<div style='width: 100px; height: 100px;'>Click me</div>`);
|
||||
await page.evaluate(() => {
|
||||
|
Loading…
Reference in New Issue
Block a user