Skip to content

Commit

Permalink
chore: set --allow-pre-commit-input flag on Android/Electron (#16383)
Browse files Browse the repository at this point in the history
  • Loading branch information
mxschmitt committed Aug 9, 2022
1 parent 2efe947 commit ff5f241
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 5 deletions.
9 changes: 8 additions & 1 deletion packages/playwright-core/src/server/android/android.ts
Expand Up @@ -35,6 +35,7 @@ import { gracefullyCloseSet } from '../../utils/processLauncher';
import { TimeoutSettings } from '../../common/timeoutSettings';
import type * as channels from '../../protocol/channels';
import { SdkObject, serverSideCallMetadata } from '../instrumentation';
import { DEFAULT_ARGS } from '../chromium/chromium';

const ARTIFACTS_FOLDER = path.join(os.tmpdir(), 'playwright-artifacts-');

Expand Down Expand Up @@ -247,7 +248,13 @@ export class AndroidDevice extends SdkObject {
debug('pw:android')('Force-stopping', pkg);
await this._backend.runCommand(`shell:am force-stop ${pkg}`);
const socketName = isUnderTest() ? 'webview_devtools_remote_playwright_test' : ('playwright-' + createGuid());
const commandLine = `_ --disable-fre --no-default-browser-check --no-first-run --remote-debugging-socket-name=${socketName}`;
const commandLine = [
'_',
'--disable-fre',
'--no-default-browser-check',
`--remote-debugging-socket-name=${socketName}`,
...DEFAULT_ARGS,
].join(' ');
debug('pw:android')('Starting', pkg, commandLine);
await this._backend.runCommand(`shell:echo "${commandLine}" > /data/local/tmp/chrome-command-line`);
await this._backend.runCommand(`shell:am start -a android.intent.action.VIEW -d about:blank ${pkg}`);
Expand Down
2 changes: 1 addition & 1 deletion packages/playwright-core/src/server/chromium/chromium.ts
Expand Up @@ -324,7 +324,7 @@ export class Chromium extends BrowserType {
}
}

const DEFAULT_ARGS = [
export const DEFAULT_ARGS = [
'--disable-field-trial-config', // https://source.chromium.org/chromium/chromium/src/+/main:testing/variations/README.md
'--disable-background-networking',
'--enable-features=NetworkService,NetworkServiceInProcess',
Expand Down
3 changes: 3 additions & 0 deletions tests/electron/electron-app.js
@@ -1,6 +1,9 @@
const { app, protocol } = require('electron');
const path = require('path');

app.commandLine.appendSwitch('disable-features', 'AutoExpandDetailsElement');
app.commandLine.appendSwitch('allow-pre-commit-input')

app.on('window-all-closed', e => e.preventDefault());

app.whenReady().then(() => {
Expand Down
4 changes: 1 addition & 3 deletions tests/page/locator-convenience.spec.ts
Expand Up @@ -202,10 +202,8 @@ it('allInnerTexts should work', async ({ page }) => {
expect(await page.locator('div').allInnerTexts()).toEqual(['A', 'B', 'C']);
});

it('isVisible and isHidden should work with details', async ({ page, isAndroid, isElectron }) => {
it('isVisible and isHidden should work with details', async ({ page }) => {
it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/10674' });
it.skip(isElectron, 'We don\'t disable the AutoExpandDetailsElement feature on Electron');
it.skip(isAndroid, 'We can\'t disable the AutoExpandDetailsElement feature on Android');
await page.setContent(`<details>
<summary>click to open</summary>
<ul>
Expand Down
7 changes: 7 additions & 0 deletions tests/page/page-keyboard.spec.ts
Expand Up @@ -379,6 +379,13 @@ it('should press the meta key', async ({ page, browserName, isMac }) => {

});

it('should work with keyboard events with empty.html', async ({ page, server }) => {
await page.goto(server.PREFIX + '/empty.html');
const lastEvent = await captureLastKeydown(page);
await page.keyboard.press('a');
expect(await lastEvent.evaluate(l => l.key)).toBe('a');
});

it('should work after a cross origin navigation', async ({ page, server }) => {
await page.goto(server.PREFIX + '/empty.html');
await page.goto(server.CROSS_PROCESS_PREFIX + '/empty.html');
Expand Down

0 comments on commit ff5f241

Please sign in to comment.