Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions packages/playwright-core/src/cli/browserActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,6 @@ async function launchContext(options: Options, extraOptions: LaunchOptions): Pro
delete contextOptions.isMobile;
}

if (contextOptions.isMobile && browserType.name() === 'firefox')
contextOptions.isMobile = undefined;

if (options.blockServiceWorkers)
contextOptions.serviceWorkers = 'block';

Expand Down
4 changes: 2 additions & 2 deletions packages/playwright-core/src/server/firefox/ffBrowser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ export class FFBrowser extends Browser {
}

async doCreateNewContext(options: types.BrowserContextOptions): Promise<BrowserContext> {
if (options.isMobile)
throw new Error('options.isMobile is not supported in Firefox');
const { browserContextId } = await this.session.send('Browser.createBrowserContext', { removeOnDetach: true });
const context = new FFBrowserContext(this, browserContextId, options);
await context.initialize();
Expand Down Expand Up @@ -359,7 +357,9 @@ export class FFBrowserContext extends BrowserContext {
return;
const viewport = {
viewportSize: { width: this._options.viewport.width, height: this._options.viewport.height },
screenSize: this._options.screen,
deviceScaleFactor: this._options.deviceScaleFactor || 1,
isMobile: !!this._options.isMobile,
};
await this._browser.session.send('Browser.setDefaultViewport', { browserContextId: this._browserContextId, viewport });
}
Expand Down
7 changes: 5 additions & 2 deletions packages/playwright-core/src/server/firefox/ffPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,11 @@ export class FFPage implements PageDelegate {
}

async updateEmulatedViewportSize(): Promise<void> {
const viewportSize = this._page.emulatedSize()?.viewport ?? null;
await this._session.send('Page.setViewportSize', { viewportSize });
const emulatedSize = this._page.emulatedSize();
const viewportSize = emulatedSize?.viewport ?? null;
const screenSize = emulatedSize?.screen ?? null;
const isMobile = !!this._browserContext._options.isMobile;
await this._session.send('Page.setViewportSize', { viewportSize, screenSize, isMobile });
}

async bringToFront(): Promise<void> {
Expand Down
4 changes: 1 addition & 3 deletions tests/library/browsercontext-viewport.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ browserTest('should support touch with null viewport', async ({ browser, server
});

it('should set both screen and viewport options', async ({ contextFactory, browserName, isBidi }) => {
it.fail(browserName === 'firefox' && !isBidi, 'Screen size is reset to viewport');
const context = await contextFactory({
screen: { 'width': 1280, 'height': 720 },
viewport: { 'width': 1000, 'height': 600 },
Expand Down Expand Up @@ -187,9 +186,8 @@ browserTest('should be able to get correct orientation angle on non-mobile devic
await context.close();
});

it('should set window.screen.orientation.type for mobile devices', async ({ contextFactory, browserName, server, isBidi }) => {
it('should set window.screen.orientation.type for mobile devices', async ({ contextFactory, server }) => {
it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/31151' });
it.skip(browserName === 'firefox' && !isBidi, 'Firefox does not support mobile emulation');
const context = await contextFactory(devices['iPhone 14']);
const page = await context.newPage();
await page.goto(server.PREFIX + '/index.html');
Expand Down
2 changes: 0 additions & 2 deletions tests/library/defaultbrowsercontext-2.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ it('should support hasTouch option', async ({ server, launchPersistent }) => {
});

it('should work in persistent context', async ({ server, launchPersistent, browserName }) => {
it.skip(browserName === 'firefox', 'Firefox does not support mobile');

const { page } = await launchPersistent({ viewport: { width: 320, height: 480 }, isMobile: true });
await page.goto(server.PREFIX + '/empty.html');
expect(await page.evaluate(() => window.innerWidth)).toBe(980);
Expand Down
2 changes: 0 additions & 2 deletions tests/library/video.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -503,8 +503,6 @@ it.describe('screencast', () => {
});

it('should emulate an iphone', async ({ contextFactory, playwright, browserName }, testInfo) => {
it.skip(browserName === 'firefox', 'isMobile is not supported in Firefox');

const device = playwright.devices['iPhone 6'];
const context = await contextFactory({
...device,
Expand Down