test(android): run selected page tests on android (2) (#5882)

This commit is contained in:
Pavel Feldman 2021-03-19 12:11:58 +08:00 committed by GitHub
parent ad5c028f37
commit 1f1c8b74cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
27 changed files with 42 additions and 44 deletions

View File

@ -67,9 +67,9 @@ it('should dispose context on cross-origin navigation', (test, { mode }) => {
it('should execute after cross-site navigation', async ({ page, server }) => {
await page.goto(server.EMPTY_PAGE);
const mainFrame = page.mainFrame();
expect(await mainFrame.evaluate(() => window.location.href)).toContain('localhost');
expect(await mainFrame.evaluate(() => window.location.href)).toContain(server.EMPTY_PAGE);
await page.goto(server.CROSS_PROCESS_PREFIX + '/empty.html');
expect(await mainFrame.evaluate(() => window.location.href)).toContain('127');
expect(await mainFrame.evaluate(() => window.location.href)).toContain(server.CROSS_PROCESS_PREFIX);
});
it('should not allow cross-frame js handles', async ({ page, server }) => {

1
test/page/README.md Normal file
View File

@ -0,0 +1 @@
Put tests that are scoped to a page and can run on Chrome for Android, WebView, Electron, etc.

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
import { it, expect } from './fixtures';
import { it, expect } from '../fixtures';
it('should work', async ({ page, server }) => {
await page.goto(server.PREFIX + '/input/button.html');

View File

@ -15,8 +15,8 @@
* limitations under the License.
*/
import { it, expect } from './fixtures';
import { attachFrame } from './utils';
import { it, expect } from '../fixtures';
import { attachFrame } from '../utils';
it('should work', async ({ page, server }) => {
await page.goto(server.EMPTY_PAGE);

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
import { it, expect } from './fixtures';
import { it, expect } from '../fixtures';
it('should have a nice preview', async ({ page, server }) => {
await page.goto(`${server.PREFIX}/dom.html`);

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
import { it, expect } from './fixtures';
import { it, expect } from '../fixtures';
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>');

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
import { it, expect } from './fixtures';
import { it, expect } from '../fixtures';
it('should hover', async ({ page, server }) => {
await page.goto(server.PREFIX + '/input/scrollable.html');

View File

@ -15,8 +15,8 @@
* limitations under the License.
*/
import { it, expect } from './fixtures';
import { attachFrame } from './utils';
import { it, expect } from '../fixtures';
import { attachFrame } from '../utils';
it('should work', async ({ page, server }) => {
await page.goto(server.EMPTY_PAGE);

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
import { it, expect } from './fixtures';
import { it, expect } from '../fixtures';
it('should work', async ({ page }) => {
await page.setContent(`<input type='text' />`);

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
import { it, expect } from './fixtures';
import { it, expect } from '../fixtures';
it('should query existing element', async ({page, server}) => {
await page.goto(server.PREFIX + '/playground.html');

View File

@ -15,9 +15,11 @@
* limitations under the License.
*/
import { it, expect } from './fixtures';
import { it, expect } from '../fixtures';
it('should work', async ({ page, server }) => {
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);

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
import { it, expect } from './fixtures';
import { it, expect } from '../fixtures';
it('should select textarea', async ({ page, server, isFirefox }) => {
await page.goto(server.PREFIX + '/input/textarea.html');

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
import { it, expect } from './fixtures';
import { it, expect } from '../fixtures';
it('should work', async ({ page }) => {
await page.setContent(`<input type='text' />`);

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
import { it, expect } from './fixtures';
import { it, expect } from '../fixtures';
async function giveItAChanceToResolve(page) {
for (let i = 0; i < 5; i++)

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
import { it, expect } from './fixtures';
import { it, expect } from '../fixtures';
it('should work with css selector', async ({page, server}) => {
await page.setContent('<div>hello</div><div>beautiful</div><div>world!</div>');

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
import { it, expect } from './fixtures';
import { it, expect } from '../fixtures';
it('should work with css selector', async ({page, server}) => {
await page.setContent('<section id="testAttribute">43543</section>');

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
import { it, expect } from './fixtures';
import { it, expect } from '../fixtures';
it('should work', async ({page}) => {
const aHandle = await page.evaluateHandle(() => document.body);

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
import { it, expect } from './fixtures';
import { it, expect } from '../fixtures';
it('should work with function', async ({page}) => {
const windowHandle = await page.evaluateHandle(() => {

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
import { it, expect } from './fixtures';
import { it, expect } from '../fixtures';
it('should work', async ({page}) => {
const aHandle = await page.evaluateHandle(() => ({foo: 'bar'}));

View File

@ -15,8 +15,8 @@
* limitations under the License.
*/
import { it, expect } from './fixtures';
import type { ElementHandle } from '..';
import { it, expect } from '../fixtures';
import type { ElementHandle } from '../..';
it('should work', async ({page}) => {
const aHandle = await page.evaluateHandle(() => ({

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
import { it, expect } from './fixtures';
import { it, expect } from '../fixtures';
it('should work for primitives', async ({page}) => {
const numberHandle = await page.evaluateHandle(() => 2);

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
import { it, expect } from './fixtures';
import { it, expect } from '../fixtures';
import util from 'util';
it('should work', async ({page}) => {

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
import { it, expect, describe } from './fixtures';
import { it, expect, describe } from '../fixtures';
import * as os from 'os';
function crash(page, toImpl, browserName) {

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
import { it, expect } from './fixtures';
import { it, expect } from '../fixtures';
it('Page.Events.Request', async ({page, server}) => {
const requests = [];

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
import { it, expect } from './fixtures';
import { it, expect } from '../fixtures';
it('should fire', async ({page, server, isWebKit}) => {
const [error] = await Promise.all([

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
import { it, expect } from './fixtures';
import { it, expect } from '../fixtures';
it('should work', async ({page}) => {
const [popup] = await Promise.all([
@ -35,9 +35,7 @@ it('should work with window features', async ({page, server}) => {
expect(await popup.evaluate(() => !!window.opener)).toBe(true);
});
it('should emit for immediately closed popups', async ({browser}) => {
const context = await browser.newContext();
const page = await context.newPage();
it('should emit for immediately closed popups', async ({page}) => {
const [popup] = await Promise.all([
page.waitForEvent('popup'),
page.evaluate(() => {
@ -46,7 +44,6 @@ it('should emit for immediately closed popups', async ({browser}) => {
}),
]);
expect(popup).toBeTruthy();
await context.close();
});
it('should emit for immediately closed popups 2', (test, {browserName, video}) => {
@ -63,9 +60,7 @@ it('should emit for immediately closed popups 2', (test, {browserName, video}) =
expect(popup).toBeTruthy();
});
it('should be able to capture alert', async ({browser}) => {
const context = await browser.newContext();
const page = await context.newPage();
it('should be able to capture alert', async ({page}) => {
const evaluatePromise = page.evaluate(() => {
const win = window.open('');
win.alert('hello');
@ -75,7 +70,6 @@ it('should be able to capture alert', async ({browser}) => {
expect(dialog.message()).toBe('hello');
await dialog.dismiss();
await evaluatePromise;
await context.close();
});
it('should work with empty url', async ({page}) => {
@ -150,8 +144,7 @@ it('should work with clicking target=_blank and rel=noopener', async ({page, ser
expect(await popup.evaluate(() => !!window.opener)).toBe(false);
});
it('should not treat navigations as new popups', async ({context, server}) => {
const page = await context.newPage();
it('should not treat navigations as new popups', async ({page, server}) => {
await page.goto(server.EMPTY_PAGE);
await page.setContent('<a target=_blank rel=noopener href="/one-style.html">yo</a>');
const [popup] = await Promise.all([
@ -161,6 +154,6 @@ it('should not treat navigations as new popups', async ({context, server}) => {
let badSecondPopup = false;
page.on('popup', () => badSecondPopup = true);
await popup.goto(server.CROSS_PROCESS_PREFIX + '/empty.html');
await context.close();
await page.close();
expect(badSecondPopup).toBe(false);
});

View File

@ -15,8 +15,8 @@
* limitations under the License.
*/
import { it, expect } from './fixtures';
import { attachFrame } from './utils';
import { it, expect } from '../fixtures';
import { attachFrame } from '../utils';
it('should fire for navigation requests', async ({page, server}) => {
const requests = [];
@ -41,7 +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', async ({page, server}) => {
it('should report requests and responses handled by service worker', test => {
test.fixme(process.env.PW_ANDROID_TESTS);
}, async ({page, server}) => {
await page.goto(server.PREFIX + '/serviceworkers/fetchdummy/sw.html');
await page.evaluate(() => window['activationPromise']);
const [swResponse, request] = await Promise.all([